From 57b3ccb84cdb6a526486df41e8bf5aaf8fa07ff9 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 16 Jan 2023 08:27:22 +0100 Subject: [PATCH] feat(replay): Update rrweb & rrweb-snapshot (#6749) --- patches/rrweb+1.1.3.patch | 10176 +++++++++++++++++++++++++- patches/rrweb-snapshot+1.1.14.patch | 651 ++ 2 files changed, 10823 insertions(+), 4 deletions(-) create mode 100644 patches/rrweb-snapshot+1.1.14.patch diff --git a/patches/rrweb+1.1.3.patch b/patches/rrweb+1.1.3.patch index af53f6595d88..e4bcbec766ae 100644 --- a/patches/rrweb+1.1.3.patch +++ b/patches/rrweb+1.1.3.patch @@ -1,17 +1,10185 @@ +diff --git a/node_modules/rrweb/dist/plugins/canvas-webrtc-record.js b/node_modules/rrweb/dist/plugins/canvas-webrtc-record.js +new file mode 100755 +index 0000000..1f7e1d0 +--- /dev/null ++++ b/node_modules/rrweb/dist/plugins/canvas-webrtc-record.js +@@ -0,0 +1,1398 @@ ++var rrwebCanvasWebRTCRecord = (function (exports) { ++ 'use strict'; ++ ++ /*! simple-peer. MIT License. Feross Aboukhadijeh */ ++ const MAX_BUFFERED_AMOUNT = 64 * 1024; ++ const ICECOMPLETE_TIMEOUT = 5 * 1000; ++ const CHANNEL_CLOSING_TIMEOUT = 5 * 1000; ++ ++ function randombytes (size) { ++ const array = new Uint8Array(size); ++ for (let i = 0; i < size; i++) { ++ array[i] = (Math.random() * 256) | 0; ++ } ++ return array ++ } ++ ++ function getBrowserRTC () { ++ if (typeof globalThis === 'undefined') return null ++ const wrtc = { ++ RTCPeerConnection: ++ globalThis.RTCPeerConnection || ++ globalThis.mozRTCPeerConnection || ++ globalThis.webkitRTCPeerConnection, ++ RTCSessionDescription: ++ globalThis.RTCSessionDescription || ++ globalThis.mozRTCSessionDescription || ++ globalThis.webkitRTCSessionDescription, ++ RTCIceCandidate: ++ globalThis.RTCIceCandidate || ++ globalThis.mozRTCIceCandidate || ++ globalThis.webkitRTCIceCandidate ++ }; ++ if (!wrtc.RTCPeerConnection) return null ++ return wrtc ++ } ++ ++ function errCode (err, code) { ++ Object.defineProperty(err, 'code', { ++ value: code, ++ enumerable: true, ++ configurable: true ++ }); ++ return err ++ } ++ ++ // HACK: Filter trickle lines when trickle is disabled #354 ++ function filterTrickle (sdp) { ++ return sdp.replace(/a=ice-options:trickle\s\n/g, '') ++ } ++ ++ function warn (message) { ++ console.warn(message); ++ } ++ ++ /** ++ * WebRTC peer connection. ++ * @param {Object} opts ++ */ ++ class Peer { ++ constructor (opts = {}) { ++ this._map = new Map(); // for event emitter ++ ++ this._id = randombytes(4).toString('hex').slice(0, 7); ++ this._doDebug = opts.debug; ++ this._debug('new peer %o', opts); ++ ++ this.channelName = opts.initiator ++ ? opts.channelName || randombytes(20).toString('hex') ++ : null; ++ ++ this.initiator = opts.initiator || false; ++ this.channelConfig = opts.channelConfig || Peer.channelConfig; ++ this.channelNegotiated = this.channelConfig.negotiated; ++ this.config = Object.assign({}, Peer.config, opts.config); ++ this.offerOptions = opts.offerOptions || {}; ++ this.answerOptions = opts.answerOptions || {}; ++ this.sdpTransform = opts.sdpTransform || (sdp => sdp); ++ this.streams = opts.streams || (opts.stream ? [opts.stream] : []); // support old "stream" option ++ this.trickle = opts.trickle !== undefined ? opts.trickle : true; ++ this.allowHalfTrickle = ++ opts.allowHalfTrickle !== undefined ? opts.allowHalfTrickle : false; ++ this.iceCompleteTimeout = opts.iceCompleteTimeout || ICECOMPLETE_TIMEOUT; ++ ++ this.destroyed = false; ++ this.destroying = false; ++ this._connected = false; ++ ++ this.remoteAddress = undefined; ++ this.remoteFamily = undefined; ++ this.remotePort = undefined; ++ this.localAddress = undefined; ++ this.localFamily = undefined; ++ this.localPort = undefined; ++ ++ this._wrtc = ++ opts.wrtc && typeof opts.wrtc === 'object' ? opts.wrtc : getBrowserRTC(); ++ ++ if (!this._wrtc) { ++ if (typeof window === 'undefined') { ++ throw errCode( ++ new Error( ++ 'No WebRTC support: Specify `opts.wrtc` option in this environment' ++ ), ++ 'ERR_WEBRTC_SUPPORT' ++ ) ++ } else { ++ throw errCode( ++ new Error('No WebRTC support: Not a supported browser'), ++ 'ERR_WEBRTC_SUPPORT' ++ ) ++ } ++ } ++ ++ this._pcReady = false; ++ this._channelReady = false; ++ this._iceComplete = false; // ice candidate trickle done (got null candidate) ++ this._iceCompleteTimer = null; // send an offer/answer anyway after some timeout ++ this._channel = null; ++ this._pendingCandidates = []; ++ ++ this._isNegotiating = false; // is this peer waiting for negotiation to complete? ++ this._firstNegotiation = true; ++ this._batchedNegotiation = false; // batch synchronous negotiations ++ this._queuedNegotiation = false; // is there a queued negotiation request? ++ this._sendersAwaitingStable = []; ++ this._senderMap = new Map(); ++ this._closingInterval = null; ++ ++ this._remoteTracks = []; ++ this._remoteStreams = []; ++ ++ this._chunk = null; ++ this._cb = null; ++ this._interval = null; ++ ++ try { ++ this._pc = new this._wrtc.RTCPeerConnection(this.config); ++ } catch (err) { ++ this.destroy(errCode(err, 'ERR_PC_CONSTRUCTOR')); ++ return ++ } ++ ++ // We prefer feature detection whenever possible, but sometimes that's not ++ // possible for certain implementations. ++ this._isReactNativeWebrtc = typeof this._pc._peerConnectionId === 'number'; ++ ++ this._pc.oniceconnectionstatechange = () => { ++ this._onIceStateChange(); ++ }; ++ this._pc.onicegatheringstatechange = () => { ++ this._onIceStateChange(); ++ }; ++ this._pc.onconnectionstatechange = () => { ++ this._onConnectionStateChange(); ++ }; ++ this._pc.onsignalingstatechange = () => { ++ this._onSignalingStateChange(); ++ }; ++ this._pc.onicecandidate = event => { ++ this._onIceCandidate(event); ++ }; ++ ++ // HACK: Fix for odd Firefox behavior, see: https://github.com/feross/simple-peer/pull/783 ++ if (typeof this._pc.peerIdentity === 'object') { ++ this._pc.peerIdentity.catch(err => { ++ this.destroy(errCode(err, 'ERR_PC_PEER_IDENTITY')); ++ }); ++ } ++ ++ // Other spec events, unused by this implementation: ++ // - onconnectionstatechange ++ // - onicecandidateerror ++ // - onfingerprintfailure ++ // - onnegotiationneeded ++ ++ if (this.initiator || this.channelNegotiated) { ++ this._setupData({ ++ channel: this._pc.createDataChannel( ++ this.channelName, ++ this.channelConfig ++ ) ++ }); ++ } else { ++ this._pc.ondatachannel = event => { ++ this._setupData(event); ++ }; ++ } ++ ++ if (this.streams) { ++ this.streams.forEach(stream => { ++ this.addStream(stream); ++ }); ++ } ++ this._pc.ontrack = event => { ++ this._onTrack(event); ++ }; ++ ++ this._debug('initial negotiation'); ++ this._needsNegotiation(); ++ } ++ ++ get bufferSize () { ++ return (this._channel && this._channel.bufferedAmount) || 0 ++ } ++ ++ // HACK: it's possible channel.readyState is "closing" before peer.destroy() fires ++ // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 ++ get connected () { ++ return this._connected && this._channel.readyState === 'open' ++ } ++ ++ address () { ++ return { ++ port: this.localPort, ++ family: this.localFamily, ++ address: this.localAddress ++ } ++ } ++ ++ signal (data) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_DESTROYED') ++ if (typeof data === 'string') { ++ try { ++ data = JSON.parse(data); ++ } catch (err) { ++ data = {}; ++ } ++ } ++ this._debug('signal()'); ++ ++ if (data.renegotiate && this.initiator) { ++ this._debug('got request to renegotiate'); ++ this._needsNegotiation(); ++ } ++ if (data.transceiverRequest && this.initiator) { ++ this._debug('got request for transceiver'); ++ this.addTransceiver( ++ data.transceiverRequest.kind, ++ data.transceiverRequest.init ++ ); ++ } ++ if (data.candidate) { ++ if (this._pc.remoteDescription && this._pc.remoteDescription.type) { ++ this._addIceCandidate(data.candidate); ++ } else { ++ this._pendingCandidates.push(data.candidate); ++ } ++ } ++ if (data.sdp) { ++ this._pc ++ .setRemoteDescription(new this._wrtc.RTCSessionDescription(data)) ++ .then(() => { ++ if (this.destroyed) return ++ ++ this._pendingCandidates.forEach(candidate => { ++ this._addIceCandidate(candidate); ++ }); ++ this._pendingCandidates = []; ++ ++ if (this._pc.remoteDescription.type === 'offer') this._createAnswer(); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_SET_REMOTE_DESCRIPTION')); ++ }); ++ } ++ if ( ++ !data.sdp && ++ !data.candidate && ++ !data.renegotiate && ++ !data.transceiverRequest ++ ) { ++ this.destroy( ++ errCode( ++ new Error('signal() called with invalid signal data'), ++ 'ERR_SIGNALING' ++ ) ++ ); ++ } ++ } ++ ++ _addIceCandidate (candidate) { ++ const iceCandidateObj = new this._wrtc.RTCIceCandidate(candidate); ++ this._pc.addIceCandidate(iceCandidateObj).catch(err => { ++ if ( ++ !iceCandidateObj.address || ++ iceCandidateObj.address.endsWith('.local') ++ ) { ++ warn('Ignoring unsupported ICE candidate.'); ++ } else { ++ this.destroy(errCode(err, 'ERR_ADD_ICE_CANDIDATE')); ++ } ++ }); ++ } ++ ++ /** ++ * Send text/binary data to the remote peer. ++ * @param {ArrayBufferView|ArrayBuffer|string|Blob} chunk ++ */ ++ send (chunk) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot send after peer is destroyed'), 'ERR_DESTROYED') ++ this._channel.send(chunk); ++ } ++ ++ /** ++ * Add a Transceiver to the connection. ++ * @param {String} kind ++ * @param {Object} init ++ */ ++ addTransceiver (kind, init) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addTransceiver after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addTransceiver()'); ++ ++ if (this.initiator) { ++ try { ++ this._pc.addTransceiver(kind, init); ++ this._needsNegotiation(); ++ } catch (err) { ++ this.destroy(errCode(err, 'ERR_ADD_TRANSCEIVER')); ++ } ++ } else { ++ this.emit('signal', { ++ // request initiator to renegotiate ++ type: 'transceiverRequest', ++ transceiverRequest: { kind, init } ++ }); ++ } ++ } ++ ++ /** ++ * Add a MediaStream to the connection. ++ * @param {MediaStream} stream ++ */ ++ addStream (stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addStream after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addStream()'); ++ ++ stream.getTracks().forEach(track => { ++ this.addTrack(track, stream); ++ }); ++ } ++ ++ /** ++ * Add a MediaStreamTrack to the connection. ++ * @param {MediaStreamTrack} track ++ * @param {MediaStream} stream ++ */ ++ addTrack (track, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addTrack()'); ++ ++ const submap = this._senderMap.get(track) || new Map(); // nested Maps map [track, stream] to sender ++ let sender = submap.get(stream); ++ if (!sender) { ++ sender = this._pc.addTrack(track, stream); ++ submap.set(stream, sender); ++ this._senderMap.set(track, submap); ++ this._needsNegotiation(); ++ } else if (sender.removed) { ++ throw errCode( ++ new Error( ++ 'Track has been removed. You should enable/disable tracks that you want to re-add.' ++ ), ++ 'ERR_SENDER_REMOVED' ++ ) ++ } else { ++ throw errCode( ++ new Error('Track has already been added to that stream.'), ++ 'ERR_SENDER_ALREADY_ADDED' ++ ) ++ } ++ } ++ ++ /** ++ * Replace a MediaStreamTrack by another in the connection. ++ * @param {MediaStreamTrack} oldTrack ++ * @param {MediaStreamTrack} newTrack ++ * @param {MediaStream} stream ++ */ ++ replaceTrack (oldTrack, newTrack, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot replaceTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('replaceTrack()'); ++ ++ const submap = this._senderMap.get(oldTrack); ++ const sender = submap ? submap.get(stream) : null; ++ if (!sender) { ++ throw errCode( ++ new Error('Cannot replace track that was never added.'), ++ 'ERR_TRACK_NOT_ADDED' ++ ) ++ } ++ if (newTrack) this._senderMap.set(newTrack, submap); ++ ++ if (sender.replaceTrack != null) { ++ sender.replaceTrack(newTrack); ++ } else { ++ this.destroy( ++ errCode( ++ new Error('replaceTrack is not supported in this browser'), ++ 'ERR_UNSUPPORTED_REPLACETRACK' ++ ) ++ ); ++ } ++ } ++ ++ /** ++ * Remove a MediaStreamTrack from the connection. ++ * @param {MediaStreamTrack} track ++ * @param {MediaStream} stream ++ */ ++ removeTrack (track, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot removeTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('removeSender()'); ++ ++ const submap = this._senderMap.get(track); ++ const sender = submap ? submap.get(stream) : null; ++ if (!sender) { ++ throw errCode( ++ new Error('Cannot remove track that was never added.'), ++ 'ERR_TRACK_NOT_ADDED' ++ ) ++ } ++ try { ++ sender.removed = true; ++ this._pc.removeTrack(sender); ++ } catch (err) { ++ if (err.name === 'NS_ERROR_UNEXPECTED') { ++ this._sendersAwaitingStable.push(sender); // HACK: Firefox must wait until (signalingState === stable) https://bugzilla.mozilla.org/show_bug.cgi?id=1133874 ++ } else { ++ this.destroy(errCode(err, 'ERR_REMOVE_TRACK')); ++ } ++ } ++ this._needsNegotiation(); ++ } ++ ++ /** ++ * Remove a MediaStream from the connection. ++ * @param {MediaStream} stream ++ */ ++ removeStream (stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot removeStream after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('removeSenders()'); ++ ++ stream.getTracks().forEach(track => { ++ this.removeTrack(track, stream); ++ }); ++ } ++ ++ _needsNegotiation () { ++ this._debug('_needsNegotiation'); ++ if (this._batchedNegotiation) return // batch synchronous renegotiations ++ this._batchedNegotiation = true; ++ queueMicrotask(() => { ++ this._batchedNegotiation = false; ++ if (this.initiator || !this._firstNegotiation) { ++ this._debug('starting batched negotiation'); ++ this.negotiate(); ++ } else { ++ this._debug('non-initiator initial negotiation request discarded'); ++ } ++ this._firstNegotiation = false; ++ }); ++ } ++ ++ negotiate () { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot negotiate after peer is destroyed'), 'ERR_DESTROYED') ++ ++ if (this.initiator) { ++ if (this._isNegotiating) { ++ this._queuedNegotiation = true; ++ this._debug('already negotiating, queueing'); ++ } else { ++ this._debug('start negotiation'); ++ setTimeout(() => { ++ // HACK: Chrome crashes if we immediately call createOffer ++ this._createOffer(); ++ }, 0); ++ } ++ } else { ++ if (this._isNegotiating) { ++ this._queuedNegotiation = true; ++ this._debug('already negotiating, queueing'); ++ } else { ++ this._debug('requesting negotiation from initiator'); ++ this.emit('signal', { ++ // request initiator to renegotiate ++ type: 'renegotiate', ++ renegotiate: true ++ }); ++ } ++ } ++ this._isNegotiating = true; ++ } ++ ++ destroy (err) { ++ if (this.destroyed || this.destroying) return ++ this.destroying = true; ++ ++ this._debug('destroying (error: %s)', err && (err.message || err)); ++ ++ queueMicrotask(() => { ++ // allow events concurrent with the call to _destroy() to fire (see #692) ++ this.destroyed = true; ++ this.destroying = false; ++ ++ this._debug('destroy (error: %s)', err && (err.message || err)); ++ ++ this._connected = false; ++ this._pcReady = false; ++ this._channelReady = false; ++ this._remoteTracks = null; ++ this._remoteStreams = null; ++ this._senderMap = null; ++ ++ clearInterval(this._closingInterval); ++ this._closingInterval = null; ++ ++ clearInterval(this._interval); ++ this._interval = null; ++ this._chunk = null; ++ this._cb = null; ++ ++ if (this._channel) { ++ try { ++ this._channel.close(); ++ } catch (err) {} ++ ++ // allow events concurrent with destruction to be handled ++ this._channel.onmessage = null; ++ this._channel.onopen = null; ++ this._channel.onclose = null; ++ this._channel.onerror = null; ++ } ++ if (this._pc) { ++ try { ++ this._pc.close(); ++ } catch (err) {} ++ ++ // allow events concurrent with destruction to be handled ++ this._pc.oniceconnectionstatechange = null; ++ this._pc.onicegatheringstatechange = null; ++ this._pc.onsignalingstatechange = null; ++ this._pc.onicecandidate = null; ++ this._pc.ontrack = null; ++ this._pc.ondatachannel = null; ++ } ++ this._pc = null; ++ this._channel = null; ++ ++ if (err) this.emit('error', err); ++ this.emit('close'); ++ }); ++ } ++ ++ _setupData (event) { ++ if (!event.channel) { ++ // In some situations `pc.createDataChannel()` returns `undefined` (in wrtc), ++ // which is invalid behavior. Handle it gracefully. ++ // See: https://github.com/feross/simple-peer/issues/163 ++ return this.destroy( ++ errCode( ++ new Error('Data channel event is missing `channel` property'), ++ 'ERR_DATA_CHANNEL' ++ ) ++ ) ++ } ++ ++ this._channel = event.channel; ++ this._channel.binaryType = 'arraybuffer'; ++ ++ if (typeof this._channel.bufferedAmountLowThreshold === 'number') { ++ this._channel.bufferedAmountLowThreshold = MAX_BUFFERED_AMOUNT; ++ } ++ ++ this.channelName = this._channel.label; ++ ++ this._channel.onmessage = event => { ++ this._onChannelMessage(event); ++ }; ++ this._channel.onbufferedamountlow = () => { ++ this._onChannelBufferedAmountLow(); ++ }; ++ this._channel.onopen = () => { ++ this._onChannelOpen(); ++ }; ++ this._channel.onclose = () => { ++ this._onChannelClose(); ++ }; ++ this._channel.onerror = err => { ++ this.destroy(errCode(err, 'ERR_DATA_CHANNEL')); ++ }; ++ ++ // HACK: Chrome will sometimes get stuck in readyState "closing", let's check for this condition ++ // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 ++ let isClosing = false; ++ this._closingInterval = setInterval(() => { ++ // No "onclosing" event ++ if (this._channel && this._channel.readyState === 'closing') { ++ if (isClosing) this._onChannelClose(); // closing timed out: equivalent to onclose firing ++ isClosing = true; ++ } else { ++ isClosing = false; ++ } ++ }, CHANNEL_CLOSING_TIMEOUT); ++ } ++ ++ _startIceCompleteTimeout () { ++ if (this.destroyed) return ++ if (this._iceCompleteTimer) return ++ this._debug('started iceComplete timeout'); ++ this._iceCompleteTimer = setTimeout(() => { ++ if (!this._iceComplete) { ++ this._iceComplete = true; ++ this._debug('iceComplete timeout completed'); ++ this.emit('iceTimeout'); ++ this.emit('_iceComplete'); ++ } ++ }, this.iceCompleteTimeout); ++ } ++ ++ _createOffer () { ++ if (this.destroyed) return ++ ++ this._pc ++ .createOffer(this.offerOptions) ++ .then(offer => { ++ if (this.destroyed) return ++ if (!this.trickle && !this.allowHalfTrickle) { offer.sdp = filterTrickle(offer.sdp); } ++ offer.sdp = this.sdpTransform(offer.sdp); ++ ++ const sendOffer = () => { ++ if (this.destroyed) return ++ const signal = this._pc.localDescription || offer; ++ this._debug('signal'); ++ this.emit('signal', { ++ type: signal.type, ++ sdp: signal.sdp ++ }); ++ }; ++ ++ const onSuccess = () => { ++ this._debug('createOffer success'); ++ if (this.destroyed) return ++ if (this.trickle || this._iceComplete) sendOffer(); ++ else this.once('_iceComplete', sendOffer); // wait for candidates ++ }; ++ ++ const onError = err => { ++ this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION')); ++ }; ++ ++ this._pc.setLocalDescription(offer).then(onSuccess).catch(onError); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_CREATE_OFFER')); ++ }); ++ } ++ ++ _requestMissingTransceivers () { ++ if (this._pc.getTransceivers) { ++ this._pc.getTransceivers().forEach(transceiver => { ++ if ( ++ !transceiver.mid && ++ transceiver.sender.track && ++ !transceiver.requested ++ ) { ++ transceiver.requested = true; // HACK: Safari returns negotiated transceivers with a null mid ++ this.addTransceiver(transceiver.sender.track.kind); ++ } ++ }); ++ } ++ } ++ ++ _createAnswer () { ++ if (this.destroyed) return ++ ++ this._pc ++ .createAnswer(this.answerOptions) ++ .then(answer => { ++ if (this.destroyed) return ++ if (!this.trickle && !this.allowHalfTrickle) { answer.sdp = filterTrickle(answer.sdp); } ++ answer.sdp = this.sdpTransform(answer.sdp); ++ ++ const sendAnswer = () => { ++ if (this.destroyed) return ++ const signal = this._pc.localDescription || answer; ++ this._debug('signal'); ++ this.emit('signal', { ++ type: signal.type, ++ sdp: signal.sdp ++ }); ++ if (!this.initiator) this._requestMissingTransceivers(); ++ }; ++ ++ const onSuccess = () => { ++ if (this.destroyed) return ++ if (this.trickle || this._iceComplete) sendAnswer(); ++ else this.once('_iceComplete', sendAnswer); ++ }; ++ ++ const onError = err => { ++ this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION')); ++ }; ++ ++ this._pc.setLocalDescription(answer).then(onSuccess).catch(onError); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_CREATE_ANSWER')); ++ }); ++ } ++ ++ _onConnectionStateChange () { ++ if (this.destroyed) return ++ if (this._pc.connectionState === 'failed') { ++ this.destroy( ++ errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE') ++ ); ++ } ++ } ++ ++ _onIceStateChange () { ++ if (this.destroyed) return ++ const iceConnectionState = this._pc.iceConnectionState; ++ const iceGatheringState = this._pc.iceGatheringState; ++ ++ this._debug( ++ 'iceStateChange (connection: %s) (gathering: %s)', ++ iceConnectionState, ++ iceGatheringState ++ ); ++ this.emit('iceStateChange', iceConnectionState, iceGatheringState); ++ ++ if ( ++ iceConnectionState === 'connected' || ++ iceConnectionState === 'completed' ++ ) { ++ this._pcReady = true; ++ this._maybeReady(); ++ } ++ if (iceConnectionState === 'failed') { ++ this.destroy( ++ errCode( ++ new Error('Ice connection failed.'), ++ 'ERR_ICE_CONNECTION_FAILURE' ++ ) ++ ); ++ } ++ if (iceConnectionState === 'closed') { ++ this.destroy( ++ errCode( ++ new Error('Ice connection closed.'), ++ 'ERR_ICE_CONNECTION_CLOSED' ++ ) ++ ); ++ } ++ } ++ ++ getStats (cb) { ++ // statreports can come with a value array instead of properties ++ const flattenValues = report => { ++ if (Object.prototype.toString.call(report.values) === '[object Array]') { ++ report.values.forEach(value => { ++ Object.assign(report, value); ++ }); ++ } ++ return report ++ }; ++ ++ // Promise-based getStats() (standard) ++ if (this._pc.getStats.length === 0 || this._isReactNativeWebrtc) { ++ this._pc.getStats().then( ++ res => { ++ const reports = []; ++ res.forEach(report => { ++ reports.push(flattenValues(report)); ++ }); ++ cb(null, reports); ++ }, ++ err => cb(err) ++ ); ++ ++ // Single-parameter callback-based getStats() (non-standard) ++ } else if (this._pc.getStats.length > 0) { ++ this._pc.getStats( ++ res => { ++ // If we destroy connection in `connect` callback this code might happen to run when actual connection is already closed ++ if (this.destroyed) return ++ ++ const reports = []; ++ res.result().forEach(result => { ++ const report = {}; ++ result.names().forEach(name => { ++ report[name] = result.stat(name); ++ }); ++ report.id = result.id; ++ report.type = result.type; ++ report.timestamp = result.timestamp; ++ reports.push(flattenValues(report)); ++ }); ++ cb(null, reports); ++ }, ++ err => cb(err) ++ ); ++ ++ // Unknown browser, skip getStats() since it's anyone's guess which style of ++ // getStats() they implement. ++ } else { ++ cb(null, []); ++ } ++ } ++ ++ _maybeReady () { ++ this._debug( ++ 'maybeReady pc %s channel %s', ++ this._pcReady, ++ this._channelReady ++ ); ++ if ( ++ this._connected || ++ this._connecting || ++ !this._pcReady || ++ !this._channelReady ++ ) { return } ++ ++ this._connecting = true; ++ ++ // HACK: We can't rely on order here, for details see https://github.com/js-platform/node-webrtc/issues/339 ++ const findCandidatePair = () => { ++ if (this.destroyed) return ++ ++ this.getStats((err, items) => { ++ if (this.destroyed) return ++ ++ // Treat getStats error as non-fatal. It's not essential. ++ if (err) items = []; ++ ++ const remoteCandidates = {}; ++ const localCandidates = {}; ++ const candidatePairs = {}; ++ let foundSelectedCandidatePair = false; ++ ++ items.forEach(item => { ++ // TODO: Once all browsers support the hyphenated stats report types, remove ++ // the non-hypenated ones ++ if ( ++ item.type === 'remotecandidate' || ++ item.type === 'remote-candidate' ++ ) { ++ remoteCandidates[item.id] = item; ++ } ++ if ( ++ item.type === 'localcandidate' || ++ item.type === 'local-candidate' ++ ) { ++ localCandidates[item.id] = item; ++ } ++ if (item.type === 'candidatepair' || item.type === 'candidate-pair') { ++ candidatePairs[item.id] = item; ++ } ++ }); ++ ++ const setSelectedCandidatePair = selectedCandidatePair => { ++ foundSelectedCandidatePair = true; ++ ++ let local = localCandidates[selectedCandidatePair.localCandidateId]; ++ ++ if (local && (local.ip || local.address)) { ++ // Spec ++ this.localAddress = local.ip || local.address; ++ this.localPort = Number(local.port); ++ } else if (local && local.ipAddress) { ++ // Firefox ++ this.localAddress = local.ipAddress; ++ this.localPort = Number(local.portNumber); ++ } else if ( ++ typeof selectedCandidatePair.googLocalAddress === 'string' ++ ) { ++ // TODO: remove this once Chrome 58 is released ++ local = selectedCandidatePair.googLocalAddress.split(':'); ++ this.localAddress = local[0]; ++ this.localPort = Number(local[1]); ++ } ++ if (this.localAddress) { ++ this.localFamily = this.localAddress.includes(':') ++ ? 'IPv6' ++ : 'IPv4'; ++ } ++ ++ let remote = ++ remoteCandidates[selectedCandidatePair.remoteCandidateId]; ++ ++ if (remote && (remote.ip || remote.address)) { ++ // Spec ++ this.remoteAddress = remote.ip || remote.address; ++ this.remotePort = Number(remote.port); ++ } else if (remote && remote.ipAddress) { ++ // Firefox ++ this.remoteAddress = remote.ipAddress; ++ this.remotePort = Number(remote.portNumber); ++ } else if ( ++ typeof selectedCandidatePair.googRemoteAddress === 'string' ++ ) { ++ // TODO: remove this once Chrome 58 is released ++ remote = selectedCandidatePair.googRemoteAddress.split(':'); ++ this.remoteAddress = remote[0]; ++ this.remotePort = Number(remote[1]); ++ } ++ if (this.remoteAddress) { ++ this.remoteFamily = this.remoteAddress.includes(':') ++ ? 'IPv6' ++ : 'IPv4'; ++ } ++ ++ this._debug( ++ 'connect local: %s:%s remote: %s:%s', ++ this.localAddress, ++ this.localPort, ++ this.remoteAddress, ++ this.remotePort ++ ); ++ }; ++ ++ items.forEach(item => { ++ // Spec-compliant ++ if (item.type === 'transport' && item.selectedCandidatePairId) { ++ setSelectedCandidatePair( ++ candidatePairs[item.selectedCandidatePairId] ++ ); ++ } ++ ++ // Old implementations ++ if ( ++ (item.type === 'googCandidatePair' && ++ item.googActiveConnection === 'true') || ++ ((item.type === 'candidatepair' || ++ item.type === 'candidate-pair') && ++ item.selected) ++ ) { ++ setSelectedCandidatePair(item); ++ } ++ }); ++ ++ // Ignore candidate pair selection in browsers like Safari 11 that do not have any local or remote candidates ++ // But wait until at least 1 candidate pair is available ++ if ( ++ !foundSelectedCandidatePair && ++ (!Object.keys(candidatePairs).length || ++ Object.keys(localCandidates).length) ++ ) { ++ setTimeout(findCandidatePair, 100); ++ return ++ } else { ++ this._connecting = false; ++ this._connected = true; ++ } ++ ++ if (this._chunk) { ++ try { ++ this.send(this._chunk); ++ } catch (err) { ++ return this.destroy(errCode(err, 'ERR_DATA_CHANNEL')) ++ } ++ this._chunk = null; ++ this._debug('sent chunk from "write before connect"'); ++ ++ const cb = this._cb; ++ this._cb = null; ++ cb(null); ++ } ++ ++ // If `bufferedAmountLowThreshold` and 'onbufferedamountlow' are unsupported, ++ // fallback to using setInterval to implement backpressure. ++ if (typeof this._channel.bufferedAmountLowThreshold !== 'number') { ++ this._interval = setInterval(() => this._onInterval(), 150); ++ if (this._interval.unref) this._interval.unref(); ++ } ++ ++ this._debug('connect'); ++ this.emit('connect'); ++ }); ++ }; ++ findCandidatePair(); ++ } ++ ++ _onInterval () { ++ if ( ++ !this._cb || ++ !this._channel || ++ this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT ++ ) { ++ return ++ } ++ this._onChannelBufferedAmountLow(); ++ } ++ ++ _onSignalingStateChange () { ++ if (this.destroyed) return ++ ++ if (this._pc.signalingState === 'stable') { ++ this._isNegotiating = false; ++ ++ // HACK: Firefox doesn't yet support removing tracks when signalingState !== 'stable' ++ this._debug('flushing sender queue', this._sendersAwaitingStable); ++ this._sendersAwaitingStable.forEach(sender => { ++ this._pc.removeTrack(sender); ++ this._queuedNegotiation = true; ++ }); ++ this._sendersAwaitingStable = []; ++ ++ if (this._queuedNegotiation) { ++ this._debug('flushing negotiation queue'); ++ this._queuedNegotiation = false; ++ this._needsNegotiation(); // negotiate again ++ } else { ++ this._debug('negotiated'); ++ this.emit('negotiated'); ++ } ++ } ++ ++ this._debug('signalingStateChange %s', this._pc.signalingState); ++ this.emit('signalingStateChange', this._pc.signalingState); ++ } ++ ++ _onIceCandidate (event) { ++ if (this.destroyed) return ++ if (event.candidate && this.trickle) { ++ this.emit('signal', { ++ type: 'candidate', ++ candidate: { ++ candidate: event.candidate.candidate, ++ sdpMLineIndex: event.candidate.sdpMLineIndex, ++ sdpMid: event.candidate.sdpMid ++ } ++ }); ++ } else if (!event.candidate && !this._iceComplete) { ++ this._iceComplete = true; ++ this.emit('_iceComplete'); ++ } ++ // as soon as we've received one valid candidate start timeout ++ if (event.candidate) { ++ this._startIceCompleteTimeout(); ++ } ++ } ++ ++ _onChannelMessage (event) { ++ if (this.destroyed) return ++ let data = event.data; ++ if (data instanceof ArrayBuffer) data = new Uint8Array(data); ++ this.emit('data', data); ++ } ++ ++ _onChannelBufferedAmountLow () { ++ if (this.destroyed || !this._cb) return ++ this._debug( ++ 'ending backpressure: bufferedAmount %d', ++ this._channel.bufferedAmount ++ ); ++ const cb = this._cb; ++ this._cb = null; ++ cb(null); ++ } ++ ++ _onChannelOpen () { ++ if (this._connected || this.destroyed) return ++ this._debug('on channel open'); ++ this._channelReady = true; ++ this._maybeReady(); ++ } ++ ++ _onChannelClose () { ++ if (this.destroyed) return ++ this._debug('on channel close'); ++ this.destroy(); ++ } ++ ++ _onTrack (event) { ++ if (this.destroyed) return ++ ++ event.streams.forEach(eventStream => { ++ this._debug('on track'); ++ this.emit('track', event.track, eventStream); ++ ++ this._remoteTracks.push({ ++ track: event.track, ++ stream: eventStream ++ }); ++ ++ if ( ++ this._remoteStreams.some(remoteStream => { ++ return remoteStream.id === eventStream.id ++ }) ++ ) { return } // Only fire one 'stream' event, even though there may be multiple tracks per stream ++ ++ this._remoteStreams.push(eventStream); ++ queueMicrotask(() => { ++ this._debug('on stream'); ++ this.emit('stream', eventStream); // ensure all tracks have been added ++ }); ++ }); ++ } ++ ++ _debug (...args) { ++ if (!this._doDebug) return ++ args[0] = '[' + this._id + '] ' + args[0]; ++ console.log(...args); ++ } ++ ++ // event emitter ++ on (key, listener) { ++ const map = this._map; ++ if (!map.has(key)) map.set(key, new Set()); ++ map.get(key).add(listener); ++ } ++ ++ off (key, listener) { ++ const map = this._map; ++ const listeners = map.get(key); ++ if (!listeners) return ++ listeners.delete(listener); ++ if (listeners.size === 0) map.delete(key); ++ } ++ ++ once (key, listener) { ++ const listener_ = (...args) => { ++ this.off(key, listener_); ++ listener(...args); ++ }; ++ this.on(key, listener_); ++ } ++ ++ emit (key, ...args) { ++ const map = this._map; ++ if (!map.has(key)) return ++ for (const listener of map.get(key)) { ++ try { ++ listener(...args); ++ } catch (err) { ++ console.error(err); ++ } ++ } ++ } ++ } ++ ++ Peer.WEBRTC_SUPPORT = !!getBrowserRTC(); ++ ++ /** ++ * Expose peer and data channel config for overriding all Peer ++ * instances. Otherwise, just set opts.config or opts.channelConfig ++ * when constructing a Peer. ++ */ ++ Peer.config = { ++ iceServers: [ ++ { ++ urls: [ ++ 'stun:stun.l.google.com:19302', ++ 'stun:global.stun.twilio.com:3478' ++ ] ++ } ++ ], ++ sdpSemantics: 'unified-plan' ++ }; ++ ++ Peer.channelConfig = {}; ++ ++ const PLUGIN_NAME = "rrweb/canvas-webrtc@1"; ++ class RRWebPluginCanvasWebRTCRecord { ++ constructor({ ++ signalSendCallback, ++ peer ++ }) { ++ this.peer = null; ++ this.streamMap = /* @__PURE__ */ new Map(); ++ this.incomingStreams = /* @__PURE__ */ new Set(); ++ this.outgoingStreams = /* @__PURE__ */ new Set(); ++ this.streamNodeMap = /* @__PURE__ */ new Map(); ++ this.canvasWindowMap = /* @__PURE__ */ new Map(); ++ this.windowPeerMap = /* @__PURE__ */ new WeakMap(); ++ this.peerWindowMap = /* @__PURE__ */ new WeakMap(); ++ this.signalSendCallback = signalSendCallback; ++ window.addEventListener("message", this.windowPostMessageHandler.bind(this)); ++ if (peer) ++ this.peer = peer; ++ } ++ initPlugin() { ++ return { ++ name: PLUGIN_NAME, ++ getMirror: ({ nodeMirror, crossOriginIframeMirror }) => { ++ this.mirror = nodeMirror; ++ this.crossOriginIframeMirror = crossOriginIframeMirror; ++ }, ++ options: {} ++ }; ++ } ++ signalReceive(signal) { ++ var _a; ++ if (!this.peer) ++ this.setupPeer(); ++ (_a = this.peer) == null ? void 0 : _a.signal(signal); ++ } ++ signalReceiveFromCrossOriginIframe(signal, source) { ++ const peer = this.setupPeer(source); ++ peer.signal(signal); ++ } ++ startStream(id, stream) { ++ var _a, _b; ++ if (!this.peer) ++ this.setupPeer(); ++ const data = { ++ nodeId: id, ++ streamId: stream.id ++ }; ++ (_a = this.peer) == null ? void 0 : _a.send(JSON.stringify(data)); ++ if (!this.outgoingStreams.has(stream)) ++ (_b = this.peer) == null ? void 0 : _b.addStream(stream); ++ this.outgoingStreams.add(stream); ++ } ++ setupPeer(source) { ++ let peer; ++ if (!source) { ++ if (this.peer) ++ return this.peer; ++ peer = this.peer = new Peer({ ++ initiator: true ++ }); ++ } else { ++ const peerFromMap = this.windowPeerMap.get(source); ++ if (peerFromMap) ++ return peerFromMap; ++ peer = new Peer({ ++ initiator: false ++ }); ++ this.windowPeerMap.set(source, peer); ++ this.peerWindowMap.set(peer, source); ++ } ++ const resetPeer = (source2) => { ++ if (!source2) ++ return this.peer = null; ++ this.windowPeerMap.delete(source2); ++ this.peerWindowMap.delete(peer); ++ }; ++ peer.on("error", (err) => { ++ resetPeer(source); ++ console.log("error", err); ++ }); ++ peer.on("close", () => { ++ resetPeer(source); ++ console.log("closing"); ++ }); ++ peer.on("signal", (data) => { ++ var _a, _b; ++ if (this.inRootFrame()) { ++ if (peer === this.peer) { ++ this.signalSendCallback(data); ++ } else { ++ (_a = this.peerWindowMap.get(peer)) == null ? void 0 : _a.postMessage({ ++ type: "rrweb-canvas-webrtc", ++ data: { ++ type: "signal", ++ signal: data ++ } ++ }, "*"); ++ } ++ } else { ++ (_b = window.top) == null ? void 0 : _b.postMessage({ ++ type: "rrweb-canvas-webrtc", ++ data: { ++ type: "signal", ++ signal: data ++ } ++ }, "*"); ++ } ++ }); ++ peer.on("connect", () => { ++ if (this.inRootFrame() && peer !== this.peer) ++ return; ++ for (const [id, stream] of this.streamMap) { ++ this.startStream(id, stream); ++ } ++ }); ++ if (!this.inRootFrame()) ++ return peer; ++ peer.on("data", (data) => { ++ try { ++ const json = JSON.parse(data); ++ this.streamNodeMap.set(json.streamId, json.nodeId); ++ } catch (error) { ++ console.error("Could not parse data", error); ++ } ++ this.flushStreams(); ++ }); ++ peer.on("stream", (stream) => { ++ this.incomingStreams.add(stream); ++ this.flushStreams(); ++ }); ++ return peer; ++ } ++ setupStream(id, rootId) { ++ var _a; ++ if (id === -1) ++ return false; ++ let stream = this.streamMap.get(rootId || id); ++ if (stream) ++ return stream; ++ const el = this.mirror.getNode(id); ++ if (!el || !("captureStream" in el)) ++ return this.setupStreamInCrossOriginIframe(id, rootId || id); ++ if (!this.inRootFrame()) { ++ (_a = window.top) == null ? void 0 : _a.postMessage({ ++ type: "rrweb-canvas-webrtc", ++ data: { ++ type: "i-have-canvas", ++ rootId: rootId || id ++ } ++ }, "*"); ++ } ++ stream = el.captureStream(); ++ this.streamMap.set(rootId || id, stream); ++ this.setupPeer(); ++ return stream; ++ } ++ flushStreams() { ++ this.incomingStreams.forEach((stream) => { ++ const nodeId = this.streamNodeMap.get(stream.id); ++ if (!nodeId) ++ return; ++ this.startStream(nodeId, stream); ++ }); ++ } ++ inRootFrame() { ++ return Boolean(window.top && window.top === window); ++ } ++ setupStreamInCrossOriginIframe(id, rootId) { ++ let found = false; ++ document.querySelectorAll("iframe").forEach((iframe) => { ++ var _a; ++ if (found) ++ return; ++ const remoteId = this.crossOriginIframeMirror.getRemoteId(iframe, id); ++ if (remoteId === -1) ++ return; ++ found = true; ++ (_a = iframe.contentWindow) == null ? void 0 : _a.postMessage({ ++ type: "rrweb-canvas-webrtc", ++ data: { ++ type: "who-has-canvas", ++ id: remoteId, ++ rootId ++ } ++ }, "*"); ++ }); ++ return found; ++ } ++ isCrossOriginIframeMessageEventContent(event) { ++ return Boolean(event.data && typeof event.data === "object" && "type" in event.data && "data" in event.data && event.data.type === "rrweb-canvas-webrtc" && event.data.data); ++ } ++ windowPostMessageHandler(event) { ++ if (!this.isCrossOriginIframeMessageEventContent(event)) ++ return; ++ const { type } = event.data.data; ++ if (type === "who-has-canvas") { ++ const { id, rootId } = event.data.data; ++ this.setupStream(id, rootId); ++ } else if (type === "signal") { ++ const { signal } = event.data.data; ++ const { source } = event; ++ if (!source || !("self" in source)) ++ return; ++ if (this.inRootFrame()) { ++ this.signalReceiveFromCrossOriginIframe(signal, source); ++ } else { ++ this.signalReceive(signal); ++ } ++ } else if (type === "i-have-canvas") { ++ const { rootId } = event.data.data; ++ const { source } = event; ++ if (!source || !("self" in source)) ++ return; ++ this.canvasWindowMap.set(rootId, source); ++ } ++ } ++ } ++ ++ exports.PLUGIN_NAME = PLUGIN_NAME; ++ exports.RRWebPluginCanvasWebRTCRecord = RRWebPluginCanvasWebRTCRecord; ++ ++ Object.defineProperty(exports, '__esModule', { value: true }); ++ ++ return exports; ++ ++})({}); +diff --git a/node_modules/rrweb/dist/plugins/canvas-webrtc-record.min.js b/node_modules/rrweb/dist/plugins/canvas-webrtc-record.min.js +new file mode 100755 +index 0000000..82af9df +--- /dev/null ++++ b/node_modules/rrweb/dist/plugins/canvas-webrtc-record.min.js +@@ -0,0 +1,2 @@ ++var rrwebCanvasWebRTCRecord=function(_){"use strict";/*! simple-peer. MIT License. Feross Aboukhadijeh */function g(d){const e=new Uint8Array(d);for(let t=0;t"u")return null;const d={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return d.RTCPeerConnection?d:null}function r(d,e){return Object.defineProperty(d,"code",{value:e,enumerable:!0,configurable:!0}),d}function p(d){return d.replace(/a=ice-options:trickle\s\n/g,"")}function y(d){console.warn(d)}class l{constructor(e={}){if(this._map=new Map,this._id=g(4).toString("hex").slice(0,7),this._doDebug=e.debug,this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||g(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||l.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},l.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(t=>t),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=e.trickle!==void 0?e.trickle:!0,this.allowHalfTrickle=e.allowHalfTrickle!==void 0?e.allowHalfTrickle:!1,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&typeof e.wrtc=="object"?e.wrtc:f(),!this._wrtc)throw r(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(t){this.destroy(r(t,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(t=>{this.destroy(r(t,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this.streams&&this.streams.forEach(t=>{this.addStream(t)}),this._pc.ontrack=t=>{this._onTrack(t)},this._debug("initial negotiation"),this._needsNegotiation()}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof e=="string")try{e=JSON.parse(e)}catch{e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(t=>{this.destroy(r(t,"ERR_SET_REMOTE_DESCRIPTION"))}),!e.sdp&&!e.candidate&&!e.renegotiate&&!e.transceiverRequest&&this.destroy(r(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch(s=>{!t.address||t.address.endsWith(".local")?y("Ignoring unsupported ICE candidate."):this.destroy(r(s,"ERR_ADD_ICE_CANDIDATE"))})}send(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(s){this.destroy(r(s,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach(t=>{this.addTrack(t,e)})}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const s=this._senderMap.get(e)||new Map;let i=s.get(t);if(!i)i=this._pc.addTrack(e,t),s.set(t,i),this._senderMap.set(e,s),this._needsNegotiation();else throw i.removed?r(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):r(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(e,t,s){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const i=this._senderMap.get(e),n=i?i.get(s):null;if(!n)throw r(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,i),n.replaceTrack!=null?n.replaceTrack(t):this.destroy(r(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const s=this._senderMap.get(e),i=s?s.get(t):null;if(!i)throw r(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{i.removed=!0,this._pc.removeTrack(i)}catch(n){n.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(i):this.destroy(r(n,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach(t=>{this.removeTrack(t,e)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close")}))}_setupData(e){if(!e.channel)return this.destroy(r(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=65536),this.channelName=this._channel.label,this._channel.onmessage=s=>{this._onChannelMessage(s)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=s=>{this.destroy(r(s,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(t&&this._onChannelClose(),t=!0):t=!1},5e3)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const n=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:n.type,sdp:n.sdp})},s=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},i=n=>{this.destroy(r(n,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(s).catch(i)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(e=>{!e.mid&&e.sender.track&&!e.requested&&(e.requested=!0,this.addTransceiver(e.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const n=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:n.type,sdp:n.sdp}),this.initiator||this._requestMissingTransceivers()},s=()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},i=n=>{this.destroy(r(n,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(s).catch(i)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(r(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),(e==="connected"||e==="completed")&&(this._pcReady=!0,this._maybeReady()),e==="failed"&&this.destroy(r(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),e==="closed"&&this.destroy(r(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=s=>(Object.prototype.toString.call(s.values)==="[object Array]"&&s.values.forEach(i=>{Object.assign(s,i)}),s);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(s=>{const i=[];s.forEach(n=>{i.push(t(n))}),e(null,i)},s=>e(s)):this._pc.getStats.length>0?this._pc.getStats(s=>{if(this.destroyed)return;const i=[];s.result().forEach(n=>{const o={};n.names().forEach(u=>{o[u]=n.stat(u)}),o.id=n.id,o.type=n.type,o.timestamp=n.timestamp,i.push(t(o))}),e(null,i)},s=>e(s)):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats((t,s)=>{if(this.destroyed)return;t&&(s=[]);const i={},n={},o={};let u=!1;s.forEach(a=>{(a.type==="remotecandidate"||a.type==="remote-candidate")&&(i[a.id]=a),(a.type==="localcandidate"||a.type==="local-candidate")&&(n[a.id]=a),(a.type==="candidatepair"||a.type==="candidate-pair")&&(o[a.id]=a)});const R=a=>{u=!0;let h=n[a.localCandidateId];h&&(h.ip||h.address)?(this.localAddress=h.ip||h.address,this.localPort=Number(h.port)):h&&h.ipAddress?(this.localAddress=h.ipAddress,this.localPort=Number(h.portNumber)):typeof a.googLocalAddress=="string"&&(h=a.googLocalAddress.split(":"),this.localAddress=h[0],this.localPort=Number(h[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let c=i[a.remoteCandidateId];c&&(c.ip||c.address)?(this.remoteAddress=c.ip||c.address,this.remotePort=Number(c.port)):c&&c.ipAddress?(this.remoteAddress=c.ipAddress,this.remotePort=Number(c.portNumber)):typeof a.googRemoteAddress=="string"&&(c=a.googRemoteAddress.split(":"),this.remoteAddress=c[0],this.remotePort=Number(c[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(s.forEach(a=>{a.type==="transport"&&a.selectedCandidatePairId&&R(o[a.selectedCandidatePairId]),(a.type==="googCandidatePair"&&a.googActiveConnection==="true"||(a.type==="candidatepair"||a.type==="candidate-pair")&&a.selected)&&R(a)}),!u&&(!Object.keys(o).length||Object.keys(n).length)){setTimeout(e,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(h){return this.destroy(r(h,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const a=this._cb;this._cb=null,a(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.emit("data",t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach(t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),!this._remoteStreams.some(s=>s.id===t.id)&&(this._remoteStreams.push(t),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",t)}))})}_debug(...e){!this._doDebug||(e[0]="["+this._id+"] "+e[0],console.log(...e))}on(e,t){const s=this._map;s.has(e)||s.set(e,new Set),s.get(e).add(t)}off(e,t){const s=this._map,i=s.get(e);!i||(i.delete(t),i.size===0&&s.delete(e))}once(e,t){const s=(...i)=>{this.off(e,s),t(...i)};this.on(e,s)}emit(e,...t){const s=this._map;if(!!s.has(e))for(const i of s.get(e))try{i(...t)}catch(n){console.error(n)}}}l.WEBRTC_SUPPORT=!!f(),l.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},l.channelConfig={};const m="rrweb/canvas-webrtc@1";class C{constructor({signalSendCallback:e,peer:t}){this.peer=null,this.streamMap=new Map,this.incomingStreams=new Set,this.outgoingStreams=new Set,this.streamNodeMap=new Map,this.canvasWindowMap=new Map,this.windowPeerMap=new WeakMap,this.peerWindowMap=new WeakMap,this.signalSendCallback=e,window.addEventListener("message",this.windowPostMessageHandler.bind(this)),t&&(this.peer=t)}initPlugin(){return{name:m,getMirror:({nodeMirror:e,crossOriginIframeMirror:t})=>{this.mirror=e,this.crossOriginIframeMirror=t},options:{}}}signalReceive(e){var t;this.peer||this.setupPeer(),(t=this.peer)==null||t.signal(e)}signalReceiveFromCrossOriginIframe(e,t){this.setupPeer(t).signal(e)}startStream(e,t){var s,i;this.peer||this.setupPeer();const n={nodeId:e,streamId:t.id};(s=this.peer)==null||s.send(JSON.stringify(n)),this.outgoingStreams.has(t)||(i=this.peer)==null||i.addStream(t),this.outgoingStreams.add(t)}setupPeer(e){let t;if(e){const i=this.windowPeerMap.get(e);if(i)return i;t=new l({initiator:!1}),this.windowPeerMap.set(e,t),this.peerWindowMap.set(t,e)}else{if(this.peer)return this.peer;t=this.peer=new l({initiator:!0})}const s=i=>{if(!i)return this.peer=null;this.windowPeerMap.delete(i),this.peerWindowMap.delete(t)};return t.on("error",i=>{s(e),console.log("error",i)}),t.on("close",()=>{s(e),console.log("closing")}),t.on("signal",i=>{var n,o;this.inRootFrame()?t===this.peer?this.signalSendCallback(i):(n=this.peerWindowMap.get(t))==null||n.postMessage({type:"rrweb-canvas-webrtc",data:{type:"signal",signal:i}},"*"):(o=window.top)==null||o.postMessage({type:"rrweb-canvas-webrtc",data:{type:"signal",signal:i}},"*")}),t.on("connect",()=>{if(!(this.inRootFrame()&&t!==this.peer))for(const[i,n]of this.streamMap)this.startStream(i,n)}),this.inRootFrame()&&(t.on("data",i=>{try{const n=JSON.parse(i);this.streamNodeMap.set(n.streamId,n.nodeId)}catch(n){console.error("Could not parse data",n)}this.flushStreams()}),t.on("stream",i=>{this.incomingStreams.add(i),this.flushStreams()})),t}setupStream(e,t){var s;if(e===-1)return!1;let i=this.streamMap.get(t||e);if(i)return i;const n=this.mirror.getNode(e);return!n||!("captureStream"in n)?this.setupStreamInCrossOriginIframe(e,t||e):(this.inRootFrame()||(s=window.top)==null||s.postMessage({type:"rrweb-canvas-webrtc",data:{type:"i-have-canvas",rootId:t||e}},"*"),i=n.captureStream(),this.streamMap.set(t||e,i),this.setupPeer(),i)}flushStreams(){this.incomingStreams.forEach(e=>{const t=this.streamNodeMap.get(e.id);!t||this.startStream(t,e)})}inRootFrame(){return Boolean(window.top&&window.top===window)}setupStreamInCrossOriginIframe(e,t){let s=!1;return document.querySelectorAll("iframe").forEach(i=>{var n;if(s)return;const o=this.crossOriginIframeMirror.getRemoteId(i,e);o!==-1&&(s=!0,(n=i.contentWindow)==null||n.postMessage({type:"rrweb-canvas-webrtc",data:{type:"who-has-canvas",id:o,rootId:t}},"*"))}),s}isCrossOriginIframeMessageEventContent(e){return Boolean(e.data&&typeof e.data=="object"&&"type"in e.data&&"data"in e.data&&e.data.type==="rrweb-canvas-webrtc"&&e.data.data)}windowPostMessageHandler(e){if(!this.isCrossOriginIframeMessageEventContent(e))return;const{type:t}=e.data.data;if(t==="who-has-canvas"){const{id:s,rootId:i}=e.data.data;this.setupStream(s,i)}else if(t==="signal"){const{signal:s}=e.data.data,{source:i}=e;if(!i||!("self"in i))return;this.inRootFrame()?this.signalReceiveFromCrossOriginIframe(s,i):this.signalReceive(s)}else if(t==="i-have-canvas"){const{rootId:s}=e.data.data,{source:i}=e;if(!i||!("self"in i))return;this.canvasWindowMap.set(s,i)}}}return _.PLUGIN_NAME=m,_.RRWebPluginCanvasWebRTCRecord=C,Object.defineProperty(_,"__esModule",{value:!0}),_}({}); ++//# sourceMappingURL=canvas-webrtc-record.min.js.map +diff --git a/node_modules/rrweb/dist/plugins/canvas-webrtc-record.min.js.map b/node_modules/rrweb/dist/plugins/canvas-webrtc-record.min.js.map +new file mode 100755 +index 0000000..510c222 +--- /dev/null ++++ b/node_modules/rrweb/dist/plugins/canvas-webrtc-record.min.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"canvas-webrtc-record.min.js","sources":["../../../../node_modules/simple-peer-light/index.js","../../src/plugins/canvas-webrtc/record/index.ts"],"sourcesContent":["/*! simple-peer. MIT License. Feross Aboukhadijeh */\nconst MAX_BUFFERED_AMOUNT = 64 * 1024\nconst ICECOMPLETE_TIMEOUT = 5 * 1000\nconst CHANNEL_CLOSING_TIMEOUT = 5 * 1000\n\nfunction randombytes (size) {\n const array = new Uint8Array(size)\n for (let i = 0; i < size; i++) {\n array[i] = (Math.random() * 256) | 0\n }\n return array\n}\n\nfunction getBrowserRTC () {\n if (typeof globalThis === 'undefined') return null\n const wrtc = {\n RTCPeerConnection:\n globalThis.RTCPeerConnection ||\n globalThis.mozRTCPeerConnection ||\n globalThis.webkitRTCPeerConnection,\n RTCSessionDescription:\n globalThis.RTCSessionDescription ||\n globalThis.mozRTCSessionDescription ||\n globalThis.webkitRTCSessionDescription,\n RTCIceCandidate:\n globalThis.RTCIceCandidate ||\n globalThis.mozRTCIceCandidate ||\n globalThis.webkitRTCIceCandidate\n }\n if (!wrtc.RTCPeerConnection) return null\n return wrtc\n}\n\nfunction errCode (err, code) {\n Object.defineProperty(err, 'code', {\n value: code,\n enumerable: true,\n configurable: true\n })\n return err\n}\n\n// HACK: Filter trickle lines when trickle is disabled #354\nfunction filterTrickle (sdp) {\n return sdp.replace(/a=ice-options:trickle\\s\\n/g, '')\n}\n\nfunction warn (message) {\n console.warn(message)\n}\n\n/**\n * WebRTC peer connection.\n * @param {Object} opts\n */\nclass Peer {\n constructor (opts = {}) {\n this._map = new Map() // for event emitter\n\n this._id = randombytes(4).toString('hex').slice(0, 7)\n this._doDebug = opts.debug\n this._debug('new peer %o', opts)\n\n this.channelName = opts.initiator\n ? opts.channelName || randombytes(20).toString('hex')\n : null\n\n this.initiator = opts.initiator || false\n this.channelConfig = opts.channelConfig || Peer.channelConfig\n this.channelNegotiated = this.channelConfig.negotiated\n this.config = Object.assign({}, Peer.config, opts.config)\n this.offerOptions = opts.offerOptions || {}\n this.answerOptions = opts.answerOptions || {}\n this.sdpTransform = opts.sdpTransform || (sdp => sdp)\n this.streams = opts.streams || (opts.stream ? [opts.stream] : []) // support old \"stream\" option\n this.trickle = opts.trickle !== undefined ? opts.trickle : true\n this.allowHalfTrickle =\n opts.allowHalfTrickle !== undefined ? opts.allowHalfTrickle : false\n this.iceCompleteTimeout = opts.iceCompleteTimeout || ICECOMPLETE_TIMEOUT\n\n this.destroyed = false\n this.destroying = false\n this._connected = false\n\n this.remoteAddress = undefined\n this.remoteFamily = undefined\n this.remotePort = undefined\n this.localAddress = undefined\n this.localFamily = undefined\n this.localPort = undefined\n\n this._wrtc =\n opts.wrtc && typeof opts.wrtc === 'object' ? opts.wrtc : getBrowserRTC()\n\n if (!this._wrtc) {\n if (typeof window === 'undefined') {\n throw errCode(\n new Error(\n 'No WebRTC support: Specify `opts.wrtc` option in this environment'\n ),\n 'ERR_WEBRTC_SUPPORT'\n )\n } else {\n throw errCode(\n new Error('No WebRTC support: Not a supported browser'),\n 'ERR_WEBRTC_SUPPORT'\n )\n }\n }\n\n this._pcReady = false\n this._channelReady = false\n this._iceComplete = false // ice candidate trickle done (got null candidate)\n this._iceCompleteTimer = null // send an offer/answer anyway after some timeout\n this._channel = null\n this._pendingCandidates = []\n\n this._isNegotiating = false // is this peer waiting for negotiation to complete?\n this._firstNegotiation = true\n this._batchedNegotiation = false // batch synchronous negotiations\n this._queuedNegotiation = false // is there a queued negotiation request?\n this._sendersAwaitingStable = []\n this._senderMap = new Map()\n this._closingInterval = null\n\n this._remoteTracks = []\n this._remoteStreams = []\n\n this._chunk = null\n this._cb = null\n this._interval = null\n\n try {\n this._pc = new this._wrtc.RTCPeerConnection(this.config)\n } catch (err) {\n this.destroy(errCode(err, 'ERR_PC_CONSTRUCTOR'))\n return\n }\n\n // We prefer feature detection whenever possible, but sometimes that's not\n // possible for certain implementations.\n this._isReactNativeWebrtc = typeof this._pc._peerConnectionId === 'number'\n\n this._pc.oniceconnectionstatechange = () => {\n this._onIceStateChange()\n }\n this._pc.onicegatheringstatechange = () => {\n this._onIceStateChange()\n }\n this._pc.onconnectionstatechange = () => {\n this._onConnectionStateChange()\n }\n this._pc.onsignalingstatechange = () => {\n this._onSignalingStateChange()\n }\n this._pc.onicecandidate = event => {\n this._onIceCandidate(event)\n }\n\n // HACK: Fix for odd Firefox behavior, see: https://github.com/feross/simple-peer/pull/783\n if (typeof this._pc.peerIdentity === 'object') {\n this._pc.peerIdentity.catch(err => {\n this.destroy(errCode(err, 'ERR_PC_PEER_IDENTITY'))\n })\n }\n\n // Other spec events, unused by this implementation:\n // - onconnectionstatechange\n // - onicecandidateerror\n // - onfingerprintfailure\n // - onnegotiationneeded\n\n if (this.initiator || this.channelNegotiated) {\n this._setupData({\n channel: this._pc.createDataChannel(\n this.channelName,\n this.channelConfig\n )\n })\n } else {\n this._pc.ondatachannel = event => {\n this._setupData(event)\n }\n }\n\n if (this.streams) {\n this.streams.forEach(stream => {\n this.addStream(stream)\n })\n }\n this._pc.ontrack = event => {\n this._onTrack(event)\n }\n\n this._debug('initial negotiation')\n this._needsNegotiation()\n }\n\n get bufferSize () {\n return (this._channel && this._channel.bufferedAmount) || 0\n }\n\n // HACK: it's possible channel.readyState is \"closing\" before peer.destroy() fires\n // https://bugs.chromium.org/p/chromium/issues/detail?id=882743\n get connected () {\n return this._connected && this._channel.readyState === 'open'\n }\n\n address () {\n return {\n port: this.localPort,\n family: this.localFamily,\n address: this.localAddress\n }\n }\n\n signal (data) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_DESTROYED')\n if (typeof data === 'string') {\n try {\n data = JSON.parse(data)\n } catch (err) {\n data = {}\n }\n }\n this._debug('signal()')\n\n if (data.renegotiate && this.initiator) {\n this._debug('got request to renegotiate')\n this._needsNegotiation()\n }\n if (data.transceiverRequest && this.initiator) {\n this._debug('got request for transceiver')\n this.addTransceiver(\n data.transceiverRequest.kind,\n data.transceiverRequest.init\n )\n }\n if (data.candidate) {\n if (this._pc.remoteDescription && this._pc.remoteDescription.type) {\n this._addIceCandidate(data.candidate)\n } else {\n this._pendingCandidates.push(data.candidate)\n }\n }\n if (data.sdp) {\n this._pc\n .setRemoteDescription(new this._wrtc.RTCSessionDescription(data))\n .then(() => {\n if (this.destroyed) return\n\n this._pendingCandidates.forEach(candidate => {\n this._addIceCandidate(candidate)\n })\n this._pendingCandidates = []\n\n if (this._pc.remoteDescription.type === 'offer') this._createAnswer()\n })\n .catch(err => {\n this.destroy(errCode(err, 'ERR_SET_REMOTE_DESCRIPTION'))\n })\n }\n if (\n !data.sdp &&\n !data.candidate &&\n !data.renegotiate &&\n !data.transceiverRequest\n ) {\n this.destroy(\n errCode(\n new Error('signal() called with invalid signal data'),\n 'ERR_SIGNALING'\n )\n )\n }\n }\n\n _addIceCandidate (candidate) {\n const iceCandidateObj = new this._wrtc.RTCIceCandidate(candidate)\n this._pc.addIceCandidate(iceCandidateObj).catch(err => {\n if (\n !iceCandidateObj.address ||\n iceCandidateObj.address.endsWith('.local')\n ) {\n warn('Ignoring unsupported ICE candidate.')\n } else {\n this.destroy(errCode(err, 'ERR_ADD_ICE_CANDIDATE'))\n }\n })\n }\n\n /**\n * Send text/binary data to the remote peer.\n * @param {ArrayBufferView|ArrayBuffer|string|Blob} chunk\n */\n send (chunk) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot send after peer is destroyed'), 'ERR_DESTROYED')\n this._channel.send(chunk)\n }\n\n /**\n * Add a Transceiver to the connection.\n * @param {String} kind\n * @param {Object} init\n */\n addTransceiver (kind, init) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot addTransceiver after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('addTransceiver()')\n\n if (this.initiator) {\n try {\n this._pc.addTransceiver(kind, init)\n this._needsNegotiation()\n } catch (err) {\n this.destroy(errCode(err, 'ERR_ADD_TRANSCEIVER'))\n }\n } else {\n this.emit('signal', {\n // request initiator to renegotiate\n type: 'transceiverRequest',\n transceiverRequest: { kind, init }\n })\n }\n }\n\n /**\n * Add a MediaStream to the connection.\n * @param {MediaStream} stream\n */\n addStream (stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot addStream after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('addStream()')\n\n stream.getTracks().forEach(track => {\n this.addTrack(track, stream)\n })\n }\n\n /**\n * Add a MediaStreamTrack to the connection.\n * @param {MediaStreamTrack} track\n * @param {MediaStream} stream\n */\n addTrack (track, stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot addTrack after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('addTrack()')\n\n const submap = this._senderMap.get(track) || new Map() // nested Maps map [track, stream] to sender\n let sender = submap.get(stream)\n if (!sender) {\n sender = this._pc.addTrack(track, stream)\n submap.set(stream, sender)\n this._senderMap.set(track, submap)\n this._needsNegotiation()\n } else if (sender.removed) {\n throw errCode(\n new Error(\n 'Track has been removed. You should enable/disable tracks that you want to re-add.'\n ),\n 'ERR_SENDER_REMOVED'\n )\n } else {\n throw errCode(\n new Error('Track has already been added to that stream.'),\n 'ERR_SENDER_ALREADY_ADDED'\n )\n }\n }\n\n /**\n * Replace a MediaStreamTrack by another in the connection.\n * @param {MediaStreamTrack} oldTrack\n * @param {MediaStreamTrack} newTrack\n * @param {MediaStream} stream\n */\n replaceTrack (oldTrack, newTrack, stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot replaceTrack after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('replaceTrack()')\n\n const submap = this._senderMap.get(oldTrack)\n const sender = submap ? submap.get(stream) : null\n if (!sender) {\n throw errCode(\n new Error('Cannot replace track that was never added.'),\n 'ERR_TRACK_NOT_ADDED'\n )\n }\n if (newTrack) this._senderMap.set(newTrack, submap)\n\n if (sender.replaceTrack != null) {\n sender.replaceTrack(newTrack)\n } else {\n this.destroy(\n errCode(\n new Error('replaceTrack is not supported in this browser'),\n 'ERR_UNSUPPORTED_REPLACETRACK'\n )\n )\n }\n }\n\n /**\n * Remove a MediaStreamTrack from the connection.\n * @param {MediaStreamTrack} track\n * @param {MediaStream} stream\n */\n removeTrack (track, stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot removeTrack after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('removeSender()')\n\n const submap = this._senderMap.get(track)\n const sender = submap ? submap.get(stream) : null\n if (!sender) {\n throw errCode(\n new Error('Cannot remove track that was never added.'),\n 'ERR_TRACK_NOT_ADDED'\n )\n }\n try {\n sender.removed = true\n this._pc.removeTrack(sender)\n } catch (err) {\n if (err.name === 'NS_ERROR_UNEXPECTED') {\n this._sendersAwaitingStable.push(sender) // HACK: Firefox must wait until (signalingState === stable) https://bugzilla.mozilla.org/show_bug.cgi?id=1133874\n } else {\n this.destroy(errCode(err, 'ERR_REMOVE_TRACK'))\n }\n }\n this._needsNegotiation()\n }\n\n /**\n * Remove a MediaStream from the connection.\n * @param {MediaStream} stream\n */\n removeStream (stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot removeStream after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('removeSenders()')\n\n stream.getTracks().forEach(track => {\n this.removeTrack(track, stream)\n })\n }\n\n _needsNegotiation () {\n this._debug('_needsNegotiation')\n if (this._batchedNegotiation) return // batch synchronous renegotiations\n this._batchedNegotiation = true\n queueMicrotask(() => {\n this._batchedNegotiation = false\n if (this.initiator || !this._firstNegotiation) {\n this._debug('starting batched negotiation')\n this.negotiate()\n } else {\n this._debug('non-initiator initial negotiation request discarded')\n }\n this._firstNegotiation = false\n })\n }\n\n negotiate () {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot negotiate after peer is destroyed'), 'ERR_DESTROYED')\n\n if (this.initiator) {\n if (this._isNegotiating) {\n this._queuedNegotiation = true\n this._debug('already negotiating, queueing')\n } else {\n this._debug('start negotiation')\n setTimeout(() => {\n // HACK: Chrome crashes if we immediately call createOffer\n this._createOffer()\n }, 0)\n }\n } else {\n if (this._isNegotiating) {\n this._queuedNegotiation = true\n this._debug('already negotiating, queueing')\n } else {\n this._debug('requesting negotiation from initiator')\n this.emit('signal', {\n // request initiator to renegotiate\n type: 'renegotiate',\n renegotiate: true\n })\n }\n }\n this._isNegotiating = true\n }\n\n destroy (err) {\n if (this.destroyed || this.destroying) return\n this.destroying = true\n\n this._debug('destroying (error: %s)', err && (err.message || err))\n\n queueMicrotask(() => {\n // allow events concurrent with the call to _destroy() to fire (see #692)\n this.destroyed = true\n this.destroying = false\n\n this._debug('destroy (error: %s)', err && (err.message || err))\n\n this._connected = false\n this._pcReady = false\n this._channelReady = false\n this._remoteTracks = null\n this._remoteStreams = null\n this._senderMap = null\n\n clearInterval(this._closingInterval)\n this._closingInterval = null\n\n clearInterval(this._interval)\n this._interval = null\n this._chunk = null\n this._cb = null\n\n if (this._channel) {\n try {\n this._channel.close()\n } catch (err) {}\n\n // allow events concurrent with destruction to be handled\n this._channel.onmessage = null\n this._channel.onopen = null\n this._channel.onclose = null\n this._channel.onerror = null\n }\n if (this._pc) {\n try {\n this._pc.close()\n } catch (err) {}\n\n // allow events concurrent with destruction to be handled\n this._pc.oniceconnectionstatechange = null\n this._pc.onicegatheringstatechange = null\n this._pc.onsignalingstatechange = null\n this._pc.onicecandidate = null\n this._pc.ontrack = null\n this._pc.ondatachannel = null\n }\n this._pc = null\n this._channel = null\n\n if (err) this.emit('error', err)\n this.emit('close')\n })\n }\n\n _setupData (event) {\n if (!event.channel) {\n // In some situations `pc.createDataChannel()` returns `undefined` (in wrtc),\n // which is invalid behavior. Handle it gracefully.\n // See: https://github.com/feross/simple-peer/issues/163\n return this.destroy(\n errCode(\n new Error('Data channel event is missing `channel` property'),\n 'ERR_DATA_CHANNEL'\n )\n )\n }\n\n this._channel = event.channel\n this._channel.binaryType = 'arraybuffer'\n\n if (typeof this._channel.bufferedAmountLowThreshold === 'number') {\n this._channel.bufferedAmountLowThreshold = MAX_BUFFERED_AMOUNT\n }\n\n this.channelName = this._channel.label\n\n this._channel.onmessage = event => {\n this._onChannelMessage(event)\n }\n this._channel.onbufferedamountlow = () => {\n this._onChannelBufferedAmountLow()\n }\n this._channel.onopen = () => {\n this._onChannelOpen()\n }\n this._channel.onclose = () => {\n this._onChannelClose()\n }\n this._channel.onerror = err => {\n this.destroy(errCode(err, 'ERR_DATA_CHANNEL'))\n }\n\n // HACK: Chrome will sometimes get stuck in readyState \"closing\", let's check for this condition\n // https://bugs.chromium.org/p/chromium/issues/detail?id=882743\n let isClosing = false\n this._closingInterval = setInterval(() => {\n // No \"onclosing\" event\n if (this._channel && this._channel.readyState === 'closing') {\n if (isClosing) this._onChannelClose() // closing timed out: equivalent to onclose firing\n isClosing = true\n } else {\n isClosing = false\n }\n }, CHANNEL_CLOSING_TIMEOUT)\n }\n\n _startIceCompleteTimeout () {\n if (this.destroyed) return\n if (this._iceCompleteTimer) return\n this._debug('started iceComplete timeout')\n this._iceCompleteTimer = setTimeout(() => {\n if (!this._iceComplete) {\n this._iceComplete = true\n this._debug('iceComplete timeout completed')\n this.emit('iceTimeout')\n this.emit('_iceComplete')\n }\n }, this.iceCompleteTimeout)\n }\n\n _createOffer () {\n if (this.destroyed) return\n\n this._pc\n .createOffer(this.offerOptions)\n .then(offer => {\n if (this.destroyed) return\n if (!this.trickle && !this.allowHalfTrickle) { offer.sdp = filterTrickle(offer.sdp) }\n offer.sdp = this.sdpTransform(offer.sdp)\n\n const sendOffer = () => {\n if (this.destroyed) return\n const signal = this._pc.localDescription || offer\n this._debug('signal')\n this.emit('signal', {\n type: signal.type,\n sdp: signal.sdp\n })\n }\n\n const onSuccess = () => {\n this._debug('createOffer success')\n if (this.destroyed) return\n if (this.trickle || this._iceComplete) sendOffer()\n else this.once('_iceComplete', sendOffer) // wait for candidates\n }\n\n const onError = err => {\n this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION'))\n }\n\n this._pc.setLocalDescription(offer).then(onSuccess).catch(onError)\n })\n .catch(err => {\n this.destroy(errCode(err, 'ERR_CREATE_OFFER'))\n })\n }\n\n _requestMissingTransceivers () {\n if (this._pc.getTransceivers) {\n this._pc.getTransceivers().forEach(transceiver => {\n if (\n !transceiver.mid &&\n transceiver.sender.track &&\n !transceiver.requested\n ) {\n transceiver.requested = true // HACK: Safari returns negotiated transceivers with a null mid\n this.addTransceiver(transceiver.sender.track.kind)\n }\n })\n }\n }\n\n _createAnswer () {\n if (this.destroyed) return\n\n this._pc\n .createAnswer(this.answerOptions)\n .then(answer => {\n if (this.destroyed) return\n if (!this.trickle && !this.allowHalfTrickle) { answer.sdp = filterTrickle(answer.sdp) }\n answer.sdp = this.sdpTransform(answer.sdp)\n\n const sendAnswer = () => {\n if (this.destroyed) return\n const signal = this._pc.localDescription || answer\n this._debug('signal')\n this.emit('signal', {\n type: signal.type,\n sdp: signal.sdp\n })\n if (!this.initiator) this._requestMissingTransceivers()\n }\n\n const onSuccess = () => {\n if (this.destroyed) return\n if (this.trickle || this._iceComplete) sendAnswer()\n else this.once('_iceComplete', sendAnswer)\n }\n\n const onError = err => {\n this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION'))\n }\n\n this._pc.setLocalDescription(answer).then(onSuccess).catch(onError)\n })\n .catch(err => {\n this.destroy(errCode(err, 'ERR_CREATE_ANSWER'))\n })\n }\n\n _onConnectionStateChange () {\n if (this.destroyed) return\n if (this._pc.connectionState === 'failed') {\n this.destroy(\n errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE')\n )\n }\n }\n\n _onIceStateChange () {\n if (this.destroyed) return\n const iceConnectionState = this._pc.iceConnectionState\n const iceGatheringState = this._pc.iceGatheringState\n\n this._debug(\n 'iceStateChange (connection: %s) (gathering: %s)',\n iceConnectionState,\n iceGatheringState\n )\n this.emit('iceStateChange', iceConnectionState, iceGatheringState)\n\n if (\n iceConnectionState === 'connected' ||\n iceConnectionState === 'completed'\n ) {\n this._pcReady = true\n this._maybeReady()\n }\n if (iceConnectionState === 'failed') {\n this.destroy(\n errCode(\n new Error('Ice connection failed.'),\n 'ERR_ICE_CONNECTION_FAILURE'\n )\n )\n }\n if (iceConnectionState === 'closed') {\n this.destroy(\n errCode(\n new Error('Ice connection closed.'),\n 'ERR_ICE_CONNECTION_CLOSED'\n )\n )\n }\n }\n\n getStats (cb) {\n // statreports can come with a value array instead of properties\n const flattenValues = report => {\n if (Object.prototype.toString.call(report.values) === '[object Array]') {\n report.values.forEach(value => {\n Object.assign(report, value)\n })\n }\n return report\n }\n\n // Promise-based getStats() (standard)\n if (this._pc.getStats.length === 0 || this._isReactNativeWebrtc) {\n this._pc.getStats().then(\n res => {\n const reports = []\n res.forEach(report => {\n reports.push(flattenValues(report))\n })\n cb(null, reports)\n },\n err => cb(err)\n )\n\n // Single-parameter callback-based getStats() (non-standard)\n } else if (this._pc.getStats.length > 0) {\n this._pc.getStats(\n res => {\n // If we destroy connection in `connect` callback this code might happen to run when actual connection is already closed\n if (this.destroyed) return\n\n const reports = []\n res.result().forEach(result => {\n const report = {}\n result.names().forEach(name => {\n report[name] = result.stat(name)\n })\n report.id = result.id\n report.type = result.type\n report.timestamp = result.timestamp\n reports.push(flattenValues(report))\n })\n cb(null, reports)\n },\n err => cb(err)\n )\n\n // Unknown browser, skip getStats() since it's anyone's guess which style of\n // getStats() they implement.\n } else {\n cb(null, [])\n }\n }\n\n _maybeReady () {\n this._debug(\n 'maybeReady pc %s channel %s',\n this._pcReady,\n this._channelReady\n )\n if (\n this._connected ||\n this._connecting ||\n !this._pcReady ||\n !this._channelReady\n ) { return }\n\n this._connecting = true\n\n // HACK: We can't rely on order here, for details see https://github.com/js-platform/node-webrtc/issues/339\n const findCandidatePair = () => {\n if (this.destroyed) return\n\n this.getStats((err, items) => {\n if (this.destroyed) return\n\n // Treat getStats error as non-fatal. It's not essential.\n if (err) items = []\n\n const remoteCandidates = {}\n const localCandidates = {}\n const candidatePairs = {}\n let foundSelectedCandidatePair = false\n\n items.forEach(item => {\n // TODO: Once all browsers support the hyphenated stats report types, remove\n // the non-hypenated ones\n if (\n item.type === 'remotecandidate' ||\n item.type === 'remote-candidate'\n ) {\n remoteCandidates[item.id] = item\n }\n if (\n item.type === 'localcandidate' ||\n item.type === 'local-candidate'\n ) {\n localCandidates[item.id] = item\n }\n if (item.type === 'candidatepair' || item.type === 'candidate-pair') {\n candidatePairs[item.id] = item\n }\n })\n\n const setSelectedCandidatePair = selectedCandidatePair => {\n foundSelectedCandidatePair = true\n\n let local = localCandidates[selectedCandidatePair.localCandidateId]\n\n if (local && (local.ip || local.address)) {\n // Spec\n this.localAddress = local.ip || local.address\n this.localPort = Number(local.port)\n } else if (local && local.ipAddress) {\n // Firefox\n this.localAddress = local.ipAddress\n this.localPort = Number(local.portNumber)\n } else if (\n typeof selectedCandidatePair.googLocalAddress === 'string'\n ) {\n // TODO: remove this once Chrome 58 is released\n local = selectedCandidatePair.googLocalAddress.split(':')\n this.localAddress = local[0]\n this.localPort = Number(local[1])\n }\n if (this.localAddress) {\n this.localFamily = this.localAddress.includes(':')\n ? 'IPv6'\n : 'IPv4'\n }\n\n let remote =\n remoteCandidates[selectedCandidatePair.remoteCandidateId]\n\n if (remote && (remote.ip || remote.address)) {\n // Spec\n this.remoteAddress = remote.ip || remote.address\n this.remotePort = Number(remote.port)\n } else if (remote && remote.ipAddress) {\n // Firefox\n this.remoteAddress = remote.ipAddress\n this.remotePort = Number(remote.portNumber)\n } else if (\n typeof selectedCandidatePair.googRemoteAddress === 'string'\n ) {\n // TODO: remove this once Chrome 58 is released\n remote = selectedCandidatePair.googRemoteAddress.split(':')\n this.remoteAddress = remote[0]\n this.remotePort = Number(remote[1])\n }\n if (this.remoteAddress) {\n this.remoteFamily = this.remoteAddress.includes(':')\n ? 'IPv6'\n : 'IPv4'\n }\n\n this._debug(\n 'connect local: %s:%s remote: %s:%s',\n this.localAddress,\n this.localPort,\n this.remoteAddress,\n this.remotePort\n )\n }\n\n items.forEach(item => {\n // Spec-compliant\n if (item.type === 'transport' && item.selectedCandidatePairId) {\n setSelectedCandidatePair(\n candidatePairs[item.selectedCandidatePairId]\n )\n }\n\n // Old implementations\n if (\n (item.type === 'googCandidatePair' &&\n item.googActiveConnection === 'true') ||\n ((item.type === 'candidatepair' ||\n item.type === 'candidate-pair') &&\n item.selected)\n ) {\n setSelectedCandidatePair(item)\n }\n })\n\n // Ignore candidate pair selection in browsers like Safari 11 that do not have any local or remote candidates\n // But wait until at least 1 candidate pair is available\n if (\n !foundSelectedCandidatePair &&\n (!Object.keys(candidatePairs).length ||\n Object.keys(localCandidates).length)\n ) {\n setTimeout(findCandidatePair, 100)\n return\n } else {\n this._connecting = false\n this._connected = true\n }\n\n if (this._chunk) {\n try {\n this.send(this._chunk)\n } catch (err) {\n return this.destroy(errCode(err, 'ERR_DATA_CHANNEL'))\n }\n this._chunk = null\n this._debug('sent chunk from \"write before connect\"')\n\n const cb = this._cb\n this._cb = null\n cb(null)\n }\n\n // If `bufferedAmountLowThreshold` and 'onbufferedamountlow' are unsupported,\n // fallback to using setInterval to implement backpressure.\n if (typeof this._channel.bufferedAmountLowThreshold !== 'number') {\n this._interval = setInterval(() => this._onInterval(), 150)\n if (this._interval.unref) this._interval.unref()\n }\n\n this._debug('connect')\n this.emit('connect')\n })\n }\n findCandidatePair()\n }\n\n _onInterval () {\n if (\n !this._cb ||\n !this._channel ||\n this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT\n ) {\n return\n }\n this._onChannelBufferedAmountLow()\n }\n\n _onSignalingStateChange () {\n if (this.destroyed) return\n\n if (this._pc.signalingState === 'stable') {\n this._isNegotiating = false\n\n // HACK: Firefox doesn't yet support removing tracks when signalingState !== 'stable'\n this._debug('flushing sender queue', this._sendersAwaitingStable)\n this._sendersAwaitingStable.forEach(sender => {\n this._pc.removeTrack(sender)\n this._queuedNegotiation = true\n })\n this._sendersAwaitingStable = []\n\n if (this._queuedNegotiation) {\n this._debug('flushing negotiation queue')\n this._queuedNegotiation = false\n this._needsNegotiation() // negotiate again\n } else {\n this._debug('negotiated')\n this.emit('negotiated')\n }\n }\n\n this._debug('signalingStateChange %s', this._pc.signalingState)\n this.emit('signalingStateChange', this._pc.signalingState)\n }\n\n _onIceCandidate (event) {\n if (this.destroyed) return\n if (event.candidate && this.trickle) {\n this.emit('signal', {\n type: 'candidate',\n candidate: {\n candidate: event.candidate.candidate,\n sdpMLineIndex: event.candidate.sdpMLineIndex,\n sdpMid: event.candidate.sdpMid\n }\n })\n } else if (!event.candidate && !this._iceComplete) {\n this._iceComplete = true\n this.emit('_iceComplete')\n }\n // as soon as we've received one valid candidate start timeout\n if (event.candidate) {\n this._startIceCompleteTimeout()\n }\n }\n\n _onChannelMessage (event) {\n if (this.destroyed) return\n let data = event.data\n if (data instanceof ArrayBuffer) data = new Uint8Array(data)\n this.emit('data', data)\n }\n\n _onChannelBufferedAmountLow () {\n if (this.destroyed || !this._cb) return\n this._debug(\n 'ending backpressure: bufferedAmount %d',\n this._channel.bufferedAmount\n )\n const cb = this._cb\n this._cb = null\n cb(null)\n }\n\n _onChannelOpen () {\n if (this._connected || this.destroyed) return\n this._debug('on channel open')\n this._channelReady = true\n this._maybeReady()\n }\n\n _onChannelClose () {\n if (this.destroyed) return\n this._debug('on channel close')\n this.destroy()\n }\n\n _onTrack (event) {\n if (this.destroyed) return\n\n event.streams.forEach(eventStream => {\n this._debug('on track')\n this.emit('track', event.track, eventStream)\n\n this._remoteTracks.push({\n track: event.track,\n stream: eventStream\n })\n\n if (\n this._remoteStreams.some(remoteStream => {\n return remoteStream.id === eventStream.id\n })\n ) { return } // Only fire one 'stream' event, even though there may be multiple tracks per stream\n\n this._remoteStreams.push(eventStream)\n queueMicrotask(() => {\n this._debug('on stream')\n this.emit('stream', eventStream) // ensure all tracks have been added\n })\n })\n }\n\n _debug (...args) {\n if (!this._doDebug) return\n args[0] = '[' + this._id + '] ' + args[0]\n console.log(...args)\n }\n\n // event emitter\n on (key, listener) {\n const map = this._map\n if (!map.has(key)) map.set(key, new Set())\n map.get(key).add(listener)\n }\n\n off (key, listener) {\n const map = this._map\n const listeners = map.get(key)\n if (!listeners) return\n listeners.delete(listener)\n if (listeners.size === 0) map.delete(key)\n }\n\n once (key, listener) {\n const listener_ = (...args) => {\n this.off(key, listener_)\n listener(...args)\n }\n this.on(key, listener_)\n }\n\n emit (key, ...args) {\n const map = this._map\n if (!map.has(key)) return\n for (const listener of map.get(key)) {\n try {\n listener(...args)\n } catch (err) {\n console.error(err)\n }\n }\n }\n}\n\nPeer.WEBRTC_SUPPORT = !!getBrowserRTC()\n\n/**\n * Expose peer and data channel config for overriding all Peer\n * instances. Otherwise, just set opts.config or opts.channelConfig\n * when constructing a Peer.\n */\nPeer.config = {\n iceServers: [\n {\n urls: [\n 'stun:stun.l.google.com:19302',\n 'stun:global.stun.twilio.com:3478'\n ]\n }\n ],\n sdpSemantics: 'unified-plan'\n}\n\nPeer.channelConfig = {}\n\n// module.exports = Peer\nexport default Peer\n","import type { Mirror } from 'rrweb-snapshot';\nimport SimplePeer from 'simple-peer-light';\nimport type { RecordPlugin, ICrossOriginIframeMirror } from '@rrweb/types';\nimport type { WebRTCDataChannel } from '../types';\n\nexport const PLUGIN_NAME = 'rrweb/canvas-webrtc@1';\n\nexport type CrossOriginIframeMessageEventContent = {\n type: 'rrweb-canvas-webrtc';\n data:\n | {\n type: 'signal';\n signal: RTCSessionDescriptionInit;\n }\n | {\n type: 'who-has-canvas';\n rootId: number;\n id: number;\n }\n | {\n type: 'i-have-canvas';\n rootId: number;\n };\n};\n\nexport class RRWebPluginCanvasWebRTCRecord {\n private peer: SimplePeer.Instance | null = null;\n private mirror: Mirror;\n private crossOriginIframeMirror: ICrossOriginIframeMirror;\n private streamMap: Map = new Map();\n private incomingStreams = new Set();\n private outgoingStreams = new Set();\n private streamNodeMap = new Map();\n private canvasWindowMap = new Map();\n private windowPeerMap = new WeakMap();\n private peerWindowMap = new WeakMap();\n private signalSendCallback: (msg: RTCSessionDescriptionInit) => void;\n\n constructor({\n signalSendCallback,\n peer,\n }: {\n signalSendCallback: RRWebPluginCanvasWebRTCRecord['signalSendCallback'];\n peer?: SimplePeer.Instance;\n }) {\n this.signalSendCallback = signalSendCallback;\n window.addEventListener(\n 'message',\n this.windowPostMessageHandler.bind(this),\n );\n if (peer) this.peer = peer;\n }\n\n public initPlugin(): RecordPlugin {\n return {\n name: PLUGIN_NAME,\n getMirror: ({ nodeMirror, crossOriginIframeMirror }) => {\n this.mirror = nodeMirror;\n this.crossOriginIframeMirror = crossOriginIframeMirror;\n },\n options: {},\n };\n }\n\n public signalReceive(signal: RTCSessionDescriptionInit) {\n if (!this.peer) this.setupPeer();\n this.peer?.signal(signal);\n }\n\n public signalReceiveFromCrossOriginIframe(\n signal: RTCSessionDescriptionInit,\n source: WindowProxy,\n ) {\n const peer = this.setupPeer(source);\n peer.signal(signal);\n }\n\n private startStream(id: number, stream: MediaStream) {\n if (!this.peer) this.setupPeer();\n\n const data: WebRTCDataChannel = {\n nodeId: id,\n streamId: stream.id,\n };\n this.peer?.send(JSON.stringify(data));\n if (!this.outgoingStreams.has(stream)) this.peer?.addStream(stream);\n this.outgoingStreams.add(stream);\n }\n\n public setupPeer(source?: WindowProxy): SimplePeer.Instance {\n let peer: SimplePeer.Instance;\n\n if (!source) {\n if (this.peer) return this.peer;\n\n peer = this.peer = new SimplePeer({\n initiator: true,\n // trickle: false, // only create one WebRTC offer per session\n });\n } else {\n const peerFromMap = this.windowPeerMap.get(source);\n\n if (peerFromMap) return peerFromMap;\n\n peer = new SimplePeer({\n initiator: false,\n // trickle: false, // only create one WebRTC offer per session\n });\n this.windowPeerMap.set(source, peer);\n this.peerWindowMap.set(peer, source);\n }\n\n const resetPeer = (source?: WindowProxy) => {\n if (!source) return (this.peer = null);\n\n this.windowPeerMap.delete(source);\n this.peerWindowMap.delete(peer);\n };\n\n peer.on('error', (err: Error) => {\n resetPeer(source);\n console.log('error', err);\n });\n\n peer.on('close', () => {\n resetPeer(source);\n console.log('closing');\n });\n\n peer.on('signal', (data: RTCSessionDescriptionInit) => {\n if (this.inRootFrame()) {\n if (peer === this.peer) {\n // connected to replayer\n this.signalSendCallback(data);\n } else {\n // connected to cross-origin iframe\n this.peerWindowMap.get(peer)?.postMessage(\n {\n type: 'rrweb-canvas-webrtc',\n data: {\n type: 'signal',\n signal: data,\n },\n } as CrossOriginIframeMessageEventContent,\n '*',\n );\n }\n } else {\n // connected to root frame\n window.top?.postMessage(\n {\n type: 'rrweb-canvas-webrtc',\n data: {\n type: 'signal',\n signal: data,\n },\n } as CrossOriginIframeMessageEventContent,\n '*',\n );\n }\n });\n\n peer.on('connect', () => {\n // connected to cross-origin iframe, no need to do anything\n if (this.inRootFrame() && peer !== this.peer) return;\n\n // cross origin frame connected to root frame\n // or root frame connected to replayer\n // send all streams to peer\n for (const [id, stream] of this.streamMap) {\n this.startStream(id, stream);\n }\n });\n\n if (!this.inRootFrame()) return peer;\n\n peer.on('data', (data: SimplePeer.SimplePeerData) => {\n try {\n const json = JSON.parse(data as string) as WebRTCDataChannel;\n this.streamNodeMap.set(json.streamId, json.nodeId);\n } catch (error) {\n console.error('Could not parse data', error);\n }\n this.flushStreams();\n });\n\n peer.on('stream', (stream: MediaStream) => {\n this.incomingStreams.add(stream);\n this.flushStreams();\n });\n\n return peer;\n }\n\n public setupStream(id: number, rootId?: number): boolean | MediaStream {\n if (id === -1) return false;\n let stream: MediaStream | undefined = this.streamMap.get(rootId || id);\n if (stream) return stream;\n\n const el = this.mirror.getNode(id) as HTMLCanvasElement | null;\n\n if (!el || !('captureStream' in el))\n // we don't have it, lets check our iframes\n return this.setupStreamInCrossOriginIframe(id, rootId || id);\n\n if (!this.inRootFrame()) {\n window.top?.postMessage(\n {\n type: 'rrweb-canvas-webrtc',\n data: {\n type: 'i-have-canvas',\n rootId: rootId || id,\n },\n } as CrossOriginIframeMessageEventContent,\n '*',\n );\n }\n\n stream = el.captureStream();\n this.streamMap.set(rootId || id, stream);\n this.setupPeer();\n\n return stream;\n }\n\n private flushStreams() {\n this.incomingStreams.forEach((stream) => {\n const nodeId = this.streamNodeMap.get(stream.id);\n if (!nodeId) return;\n // got remote video stream, now let's send it to the replayer\n this.startStream(nodeId, stream);\n });\n }\n\n private inRootFrame(): boolean {\n return Boolean(window.top && window.top === window);\n }\n\n public setupStreamInCrossOriginIframe(id: number, rootId: number): boolean {\n let found = false;\n\n document.querySelectorAll('iframe').forEach((iframe) => {\n if (found) return;\n\n const remoteId = this.crossOriginIframeMirror.getRemoteId(iframe, id);\n if (remoteId === -1) return;\n\n found = true;\n iframe.contentWindow?.postMessage(\n {\n type: 'rrweb-canvas-webrtc',\n data: {\n type: 'who-has-canvas',\n id: remoteId,\n rootId,\n },\n } as CrossOriginIframeMessageEventContent,\n '*',\n );\n });\n return found;\n }\n\n private isCrossOriginIframeMessageEventContent(\n event: MessageEvent,\n ): event is MessageEvent {\n return Boolean(\n event.data &&\n typeof event.data === 'object' &&\n 'type' in event.data &&\n 'data' in event.data &&\n (event.data as CrossOriginIframeMessageEventContent).type ===\n 'rrweb-canvas-webrtc' &&\n (event.data as CrossOriginIframeMessageEventContent).data,\n );\n }\n\n /**\n * All messages being sent to the (root or sub) frame are received through `windowPostMessageHandler`.\n * @param event - The message event\n */\n private windowPostMessageHandler(\n event: MessageEvent | MessageEvent,\n ) {\n if (!this.isCrossOriginIframeMessageEventContent(event)) return;\n\n const { type } = event.data.data;\n if (type === 'who-has-canvas') {\n const { id, rootId } = event.data.data;\n this.setupStream(id, rootId);\n } else if (type === 'signal') {\n const { signal } = event.data.data;\n const { source } = event;\n if (!source || !('self' in source)) return;\n if (this.inRootFrame()) {\n this.signalReceiveFromCrossOriginIframe(signal, source);\n } else {\n this.signalReceive(signal);\n }\n } else if (type === 'i-have-canvas') {\n const { rootId } = event.data.data;\n const { source } = event;\n if (!source || !('self' in source)) return;\n this.canvasWindowMap.set(rootId, source);\n }\n }\n}\n"],"names":["n"],"mappings":";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AAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,EAAC,CAAC,KAAK,GAAG,CAAC,GAAG,eAAe,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC;;;;;;;;;;;;;"} +\ No newline at end of file +diff --git a/node_modules/rrweb/dist/plugins/canvas-webrtc-replay.js b/node_modules/rrweb/dist/plugins/canvas-webrtc-replay.js +new file mode 100755 +index 0000000..f7c8c5b +--- /dev/null ++++ b/node_modules/rrweb/dist/plugins/canvas-webrtc-replay.js +@@ -0,0 +1,1295 @@ ++var rrwebCanvasWebRTCReplay = (function (exports) { ++ 'use strict'; ++ ++ /*! simple-peer. MIT License. Feross Aboukhadijeh */ ++ const MAX_BUFFERED_AMOUNT = 64 * 1024; ++ const ICECOMPLETE_TIMEOUT = 5 * 1000; ++ const CHANNEL_CLOSING_TIMEOUT = 5 * 1000; ++ ++ function randombytes (size) { ++ const array = new Uint8Array(size); ++ for (let i = 0; i < size; i++) { ++ array[i] = (Math.random() * 256) | 0; ++ } ++ return array ++ } ++ ++ function getBrowserRTC () { ++ if (typeof globalThis === 'undefined') return null ++ const wrtc = { ++ RTCPeerConnection: ++ globalThis.RTCPeerConnection || ++ globalThis.mozRTCPeerConnection || ++ globalThis.webkitRTCPeerConnection, ++ RTCSessionDescription: ++ globalThis.RTCSessionDescription || ++ globalThis.mozRTCSessionDescription || ++ globalThis.webkitRTCSessionDescription, ++ RTCIceCandidate: ++ globalThis.RTCIceCandidate || ++ globalThis.mozRTCIceCandidate || ++ globalThis.webkitRTCIceCandidate ++ }; ++ if (!wrtc.RTCPeerConnection) return null ++ return wrtc ++ } ++ ++ function errCode (err, code) { ++ Object.defineProperty(err, 'code', { ++ value: code, ++ enumerable: true, ++ configurable: true ++ }); ++ return err ++ } ++ ++ // HACK: Filter trickle lines when trickle is disabled #354 ++ function filterTrickle (sdp) { ++ return sdp.replace(/a=ice-options:trickle\s\n/g, '') ++ } ++ ++ function warn (message) { ++ console.warn(message); ++ } ++ ++ /** ++ * WebRTC peer connection. ++ * @param {Object} opts ++ */ ++ class Peer { ++ constructor (opts = {}) { ++ this._map = new Map(); // for event emitter ++ ++ this._id = randombytes(4).toString('hex').slice(0, 7); ++ this._doDebug = opts.debug; ++ this._debug('new peer %o', opts); ++ ++ this.channelName = opts.initiator ++ ? opts.channelName || randombytes(20).toString('hex') ++ : null; ++ ++ this.initiator = opts.initiator || false; ++ this.channelConfig = opts.channelConfig || Peer.channelConfig; ++ this.channelNegotiated = this.channelConfig.negotiated; ++ this.config = Object.assign({}, Peer.config, opts.config); ++ this.offerOptions = opts.offerOptions || {}; ++ this.answerOptions = opts.answerOptions || {}; ++ this.sdpTransform = opts.sdpTransform || (sdp => sdp); ++ this.streams = opts.streams || (opts.stream ? [opts.stream] : []); // support old "stream" option ++ this.trickle = opts.trickle !== undefined ? opts.trickle : true; ++ this.allowHalfTrickle = ++ opts.allowHalfTrickle !== undefined ? opts.allowHalfTrickle : false; ++ this.iceCompleteTimeout = opts.iceCompleteTimeout || ICECOMPLETE_TIMEOUT; ++ ++ this.destroyed = false; ++ this.destroying = false; ++ this._connected = false; ++ ++ this.remoteAddress = undefined; ++ this.remoteFamily = undefined; ++ this.remotePort = undefined; ++ this.localAddress = undefined; ++ this.localFamily = undefined; ++ this.localPort = undefined; ++ ++ this._wrtc = ++ opts.wrtc && typeof opts.wrtc === 'object' ? opts.wrtc : getBrowserRTC(); ++ ++ if (!this._wrtc) { ++ if (typeof window === 'undefined') { ++ throw errCode( ++ new Error( ++ 'No WebRTC support: Specify `opts.wrtc` option in this environment' ++ ), ++ 'ERR_WEBRTC_SUPPORT' ++ ) ++ } else { ++ throw errCode( ++ new Error('No WebRTC support: Not a supported browser'), ++ 'ERR_WEBRTC_SUPPORT' ++ ) ++ } ++ } ++ ++ this._pcReady = false; ++ this._channelReady = false; ++ this._iceComplete = false; // ice candidate trickle done (got null candidate) ++ this._iceCompleteTimer = null; // send an offer/answer anyway after some timeout ++ this._channel = null; ++ this._pendingCandidates = []; ++ ++ this._isNegotiating = false; // is this peer waiting for negotiation to complete? ++ this._firstNegotiation = true; ++ this._batchedNegotiation = false; // batch synchronous negotiations ++ this._queuedNegotiation = false; // is there a queued negotiation request? ++ this._sendersAwaitingStable = []; ++ this._senderMap = new Map(); ++ this._closingInterval = null; ++ ++ this._remoteTracks = []; ++ this._remoteStreams = []; ++ ++ this._chunk = null; ++ this._cb = null; ++ this._interval = null; ++ ++ try { ++ this._pc = new this._wrtc.RTCPeerConnection(this.config); ++ } catch (err) { ++ this.destroy(errCode(err, 'ERR_PC_CONSTRUCTOR')); ++ return ++ } ++ ++ // We prefer feature detection whenever possible, but sometimes that's not ++ // possible for certain implementations. ++ this._isReactNativeWebrtc = typeof this._pc._peerConnectionId === 'number'; ++ ++ this._pc.oniceconnectionstatechange = () => { ++ this._onIceStateChange(); ++ }; ++ this._pc.onicegatheringstatechange = () => { ++ this._onIceStateChange(); ++ }; ++ this._pc.onconnectionstatechange = () => { ++ this._onConnectionStateChange(); ++ }; ++ this._pc.onsignalingstatechange = () => { ++ this._onSignalingStateChange(); ++ }; ++ this._pc.onicecandidate = event => { ++ this._onIceCandidate(event); ++ }; ++ ++ // HACK: Fix for odd Firefox behavior, see: https://github.com/feross/simple-peer/pull/783 ++ if (typeof this._pc.peerIdentity === 'object') { ++ this._pc.peerIdentity.catch(err => { ++ this.destroy(errCode(err, 'ERR_PC_PEER_IDENTITY')); ++ }); ++ } ++ ++ // Other spec events, unused by this implementation: ++ // - onconnectionstatechange ++ // - onicecandidateerror ++ // - onfingerprintfailure ++ // - onnegotiationneeded ++ ++ if (this.initiator || this.channelNegotiated) { ++ this._setupData({ ++ channel: this._pc.createDataChannel( ++ this.channelName, ++ this.channelConfig ++ ) ++ }); ++ } else { ++ this._pc.ondatachannel = event => { ++ this._setupData(event); ++ }; ++ } ++ ++ if (this.streams) { ++ this.streams.forEach(stream => { ++ this.addStream(stream); ++ }); ++ } ++ this._pc.ontrack = event => { ++ this._onTrack(event); ++ }; ++ ++ this._debug('initial negotiation'); ++ this._needsNegotiation(); ++ } ++ ++ get bufferSize () { ++ return (this._channel && this._channel.bufferedAmount) || 0 ++ } ++ ++ // HACK: it's possible channel.readyState is "closing" before peer.destroy() fires ++ // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 ++ get connected () { ++ return this._connected && this._channel.readyState === 'open' ++ } ++ ++ address () { ++ return { ++ port: this.localPort, ++ family: this.localFamily, ++ address: this.localAddress ++ } ++ } ++ ++ signal (data) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_DESTROYED') ++ if (typeof data === 'string') { ++ try { ++ data = JSON.parse(data); ++ } catch (err) { ++ data = {}; ++ } ++ } ++ this._debug('signal()'); ++ ++ if (data.renegotiate && this.initiator) { ++ this._debug('got request to renegotiate'); ++ this._needsNegotiation(); ++ } ++ if (data.transceiverRequest && this.initiator) { ++ this._debug('got request for transceiver'); ++ this.addTransceiver( ++ data.transceiverRequest.kind, ++ data.transceiverRequest.init ++ ); ++ } ++ if (data.candidate) { ++ if (this._pc.remoteDescription && this._pc.remoteDescription.type) { ++ this._addIceCandidate(data.candidate); ++ } else { ++ this._pendingCandidates.push(data.candidate); ++ } ++ } ++ if (data.sdp) { ++ this._pc ++ .setRemoteDescription(new this._wrtc.RTCSessionDescription(data)) ++ .then(() => { ++ if (this.destroyed) return ++ ++ this._pendingCandidates.forEach(candidate => { ++ this._addIceCandidate(candidate); ++ }); ++ this._pendingCandidates = []; ++ ++ if (this._pc.remoteDescription.type === 'offer') this._createAnswer(); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_SET_REMOTE_DESCRIPTION')); ++ }); ++ } ++ if ( ++ !data.sdp && ++ !data.candidate && ++ !data.renegotiate && ++ !data.transceiverRequest ++ ) { ++ this.destroy( ++ errCode( ++ new Error('signal() called with invalid signal data'), ++ 'ERR_SIGNALING' ++ ) ++ ); ++ } ++ } ++ ++ _addIceCandidate (candidate) { ++ const iceCandidateObj = new this._wrtc.RTCIceCandidate(candidate); ++ this._pc.addIceCandidate(iceCandidateObj).catch(err => { ++ if ( ++ !iceCandidateObj.address || ++ iceCandidateObj.address.endsWith('.local') ++ ) { ++ warn('Ignoring unsupported ICE candidate.'); ++ } else { ++ this.destroy(errCode(err, 'ERR_ADD_ICE_CANDIDATE')); ++ } ++ }); ++ } ++ ++ /** ++ * Send text/binary data to the remote peer. ++ * @param {ArrayBufferView|ArrayBuffer|string|Blob} chunk ++ */ ++ send (chunk) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot send after peer is destroyed'), 'ERR_DESTROYED') ++ this._channel.send(chunk); ++ } ++ ++ /** ++ * Add a Transceiver to the connection. ++ * @param {String} kind ++ * @param {Object} init ++ */ ++ addTransceiver (kind, init) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addTransceiver after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addTransceiver()'); ++ ++ if (this.initiator) { ++ try { ++ this._pc.addTransceiver(kind, init); ++ this._needsNegotiation(); ++ } catch (err) { ++ this.destroy(errCode(err, 'ERR_ADD_TRANSCEIVER')); ++ } ++ } else { ++ this.emit('signal', { ++ // request initiator to renegotiate ++ type: 'transceiverRequest', ++ transceiverRequest: { kind, init } ++ }); ++ } ++ } ++ ++ /** ++ * Add a MediaStream to the connection. ++ * @param {MediaStream} stream ++ */ ++ addStream (stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addStream after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addStream()'); ++ ++ stream.getTracks().forEach(track => { ++ this.addTrack(track, stream); ++ }); ++ } ++ ++ /** ++ * Add a MediaStreamTrack to the connection. ++ * @param {MediaStreamTrack} track ++ * @param {MediaStream} stream ++ */ ++ addTrack (track, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addTrack()'); ++ ++ const submap = this._senderMap.get(track) || new Map(); // nested Maps map [track, stream] to sender ++ let sender = submap.get(stream); ++ if (!sender) { ++ sender = this._pc.addTrack(track, stream); ++ submap.set(stream, sender); ++ this._senderMap.set(track, submap); ++ this._needsNegotiation(); ++ } else if (sender.removed) { ++ throw errCode( ++ new Error( ++ 'Track has been removed. You should enable/disable tracks that you want to re-add.' ++ ), ++ 'ERR_SENDER_REMOVED' ++ ) ++ } else { ++ throw errCode( ++ new Error('Track has already been added to that stream.'), ++ 'ERR_SENDER_ALREADY_ADDED' ++ ) ++ } ++ } ++ ++ /** ++ * Replace a MediaStreamTrack by another in the connection. ++ * @param {MediaStreamTrack} oldTrack ++ * @param {MediaStreamTrack} newTrack ++ * @param {MediaStream} stream ++ */ ++ replaceTrack (oldTrack, newTrack, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot replaceTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('replaceTrack()'); ++ ++ const submap = this._senderMap.get(oldTrack); ++ const sender = submap ? submap.get(stream) : null; ++ if (!sender) { ++ throw errCode( ++ new Error('Cannot replace track that was never added.'), ++ 'ERR_TRACK_NOT_ADDED' ++ ) ++ } ++ if (newTrack) this._senderMap.set(newTrack, submap); ++ ++ if (sender.replaceTrack != null) { ++ sender.replaceTrack(newTrack); ++ } else { ++ this.destroy( ++ errCode( ++ new Error('replaceTrack is not supported in this browser'), ++ 'ERR_UNSUPPORTED_REPLACETRACK' ++ ) ++ ); ++ } ++ } ++ ++ /** ++ * Remove a MediaStreamTrack from the connection. ++ * @param {MediaStreamTrack} track ++ * @param {MediaStream} stream ++ */ ++ removeTrack (track, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot removeTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('removeSender()'); ++ ++ const submap = this._senderMap.get(track); ++ const sender = submap ? submap.get(stream) : null; ++ if (!sender) { ++ throw errCode( ++ new Error('Cannot remove track that was never added.'), ++ 'ERR_TRACK_NOT_ADDED' ++ ) ++ } ++ try { ++ sender.removed = true; ++ this._pc.removeTrack(sender); ++ } catch (err) { ++ if (err.name === 'NS_ERROR_UNEXPECTED') { ++ this._sendersAwaitingStable.push(sender); // HACK: Firefox must wait until (signalingState === stable) https://bugzilla.mozilla.org/show_bug.cgi?id=1133874 ++ } else { ++ this.destroy(errCode(err, 'ERR_REMOVE_TRACK')); ++ } ++ } ++ this._needsNegotiation(); ++ } ++ ++ /** ++ * Remove a MediaStream from the connection. ++ * @param {MediaStream} stream ++ */ ++ removeStream (stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot removeStream after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('removeSenders()'); ++ ++ stream.getTracks().forEach(track => { ++ this.removeTrack(track, stream); ++ }); ++ } ++ ++ _needsNegotiation () { ++ this._debug('_needsNegotiation'); ++ if (this._batchedNegotiation) return // batch synchronous renegotiations ++ this._batchedNegotiation = true; ++ queueMicrotask(() => { ++ this._batchedNegotiation = false; ++ if (this.initiator || !this._firstNegotiation) { ++ this._debug('starting batched negotiation'); ++ this.negotiate(); ++ } else { ++ this._debug('non-initiator initial negotiation request discarded'); ++ } ++ this._firstNegotiation = false; ++ }); ++ } ++ ++ negotiate () { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot negotiate after peer is destroyed'), 'ERR_DESTROYED') ++ ++ if (this.initiator) { ++ if (this._isNegotiating) { ++ this._queuedNegotiation = true; ++ this._debug('already negotiating, queueing'); ++ } else { ++ this._debug('start negotiation'); ++ setTimeout(() => { ++ // HACK: Chrome crashes if we immediately call createOffer ++ this._createOffer(); ++ }, 0); ++ } ++ } else { ++ if (this._isNegotiating) { ++ this._queuedNegotiation = true; ++ this._debug('already negotiating, queueing'); ++ } else { ++ this._debug('requesting negotiation from initiator'); ++ this.emit('signal', { ++ // request initiator to renegotiate ++ type: 'renegotiate', ++ renegotiate: true ++ }); ++ } ++ } ++ this._isNegotiating = true; ++ } ++ ++ destroy (err) { ++ if (this.destroyed || this.destroying) return ++ this.destroying = true; ++ ++ this._debug('destroying (error: %s)', err && (err.message || err)); ++ ++ queueMicrotask(() => { ++ // allow events concurrent with the call to _destroy() to fire (see #692) ++ this.destroyed = true; ++ this.destroying = false; ++ ++ this._debug('destroy (error: %s)', err && (err.message || err)); ++ ++ this._connected = false; ++ this._pcReady = false; ++ this._channelReady = false; ++ this._remoteTracks = null; ++ this._remoteStreams = null; ++ this._senderMap = null; ++ ++ clearInterval(this._closingInterval); ++ this._closingInterval = null; ++ ++ clearInterval(this._interval); ++ this._interval = null; ++ this._chunk = null; ++ this._cb = null; ++ ++ if (this._channel) { ++ try { ++ this._channel.close(); ++ } catch (err) {} ++ ++ // allow events concurrent with destruction to be handled ++ this._channel.onmessage = null; ++ this._channel.onopen = null; ++ this._channel.onclose = null; ++ this._channel.onerror = null; ++ } ++ if (this._pc) { ++ try { ++ this._pc.close(); ++ } catch (err) {} ++ ++ // allow events concurrent with destruction to be handled ++ this._pc.oniceconnectionstatechange = null; ++ this._pc.onicegatheringstatechange = null; ++ this._pc.onsignalingstatechange = null; ++ this._pc.onicecandidate = null; ++ this._pc.ontrack = null; ++ this._pc.ondatachannel = null; ++ } ++ this._pc = null; ++ this._channel = null; ++ ++ if (err) this.emit('error', err); ++ this.emit('close'); ++ }); ++ } ++ ++ _setupData (event) { ++ if (!event.channel) { ++ // In some situations `pc.createDataChannel()` returns `undefined` (in wrtc), ++ // which is invalid behavior. Handle it gracefully. ++ // See: https://github.com/feross/simple-peer/issues/163 ++ return this.destroy( ++ errCode( ++ new Error('Data channel event is missing `channel` property'), ++ 'ERR_DATA_CHANNEL' ++ ) ++ ) ++ } ++ ++ this._channel = event.channel; ++ this._channel.binaryType = 'arraybuffer'; ++ ++ if (typeof this._channel.bufferedAmountLowThreshold === 'number') { ++ this._channel.bufferedAmountLowThreshold = MAX_BUFFERED_AMOUNT; ++ } ++ ++ this.channelName = this._channel.label; ++ ++ this._channel.onmessage = event => { ++ this._onChannelMessage(event); ++ }; ++ this._channel.onbufferedamountlow = () => { ++ this._onChannelBufferedAmountLow(); ++ }; ++ this._channel.onopen = () => { ++ this._onChannelOpen(); ++ }; ++ this._channel.onclose = () => { ++ this._onChannelClose(); ++ }; ++ this._channel.onerror = err => { ++ this.destroy(errCode(err, 'ERR_DATA_CHANNEL')); ++ }; ++ ++ // HACK: Chrome will sometimes get stuck in readyState "closing", let's check for this condition ++ // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 ++ let isClosing = false; ++ this._closingInterval = setInterval(() => { ++ // No "onclosing" event ++ if (this._channel && this._channel.readyState === 'closing') { ++ if (isClosing) this._onChannelClose(); // closing timed out: equivalent to onclose firing ++ isClosing = true; ++ } else { ++ isClosing = false; ++ } ++ }, CHANNEL_CLOSING_TIMEOUT); ++ } ++ ++ _startIceCompleteTimeout () { ++ if (this.destroyed) return ++ if (this._iceCompleteTimer) return ++ this._debug('started iceComplete timeout'); ++ this._iceCompleteTimer = setTimeout(() => { ++ if (!this._iceComplete) { ++ this._iceComplete = true; ++ this._debug('iceComplete timeout completed'); ++ this.emit('iceTimeout'); ++ this.emit('_iceComplete'); ++ } ++ }, this.iceCompleteTimeout); ++ } ++ ++ _createOffer () { ++ if (this.destroyed) return ++ ++ this._pc ++ .createOffer(this.offerOptions) ++ .then(offer => { ++ if (this.destroyed) return ++ if (!this.trickle && !this.allowHalfTrickle) { offer.sdp = filterTrickle(offer.sdp); } ++ offer.sdp = this.sdpTransform(offer.sdp); ++ ++ const sendOffer = () => { ++ if (this.destroyed) return ++ const signal = this._pc.localDescription || offer; ++ this._debug('signal'); ++ this.emit('signal', { ++ type: signal.type, ++ sdp: signal.sdp ++ }); ++ }; ++ ++ const onSuccess = () => { ++ this._debug('createOffer success'); ++ if (this.destroyed) return ++ if (this.trickle || this._iceComplete) sendOffer(); ++ else this.once('_iceComplete', sendOffer); // wait for candidates ++ }; ++ ++ const onError = err => { ++ this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION')); ++ }; ++ ++ this._pc.setLocalDescription(offer).then(onSuccess).catch(onError); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_CREATE_OFFER')); ++ }); ++ } ++ ++ _requestMissingTransceivers () { ++ if (this._pc.getTransceivers) { ++ this._pc.getTransceivers().forEach(transceiver => { ++ if ( ++ !transceiver.mid && ++ transceiver.sender.track && ++ !transceiver.requested ++ ) { ++ transceiver.requested = true; // HACK: Safari returns negotiated transceivers with a null mid ++ this.addTransceiver(transceiver.sender.track.kind); ++ } ++ }); ++ } ++ } ++ ++ _createAnswer () { ++ if (this.destroyed) return ++ ++ this._pc ++ .createAnswer(this.answerOptions) ++ .then(answer => { ++ if (this.destroyed) return ++ if (!this.trickle && !this.allowHalfTrickle) { answer.sdp = filterTrickle(answer.sdp); } ++ answer.sdp = this.sdpTransform(answer.sdp); ++ ++ const sendAnswer = () => { ++ if (this.destroyed) return ++ const signal = this._pc.localDescription || answer; ++ this._debug('signal'); ++ this.emit('signal', { ++ type: signal.type, ++ sdp: signal.sdp ++ }); ++ if (!this.initiator) this._requestMissingTransceivers(); ++ }; ++ ++ const onSuccess = () => { ++ if (this.destroyed) return ++ if (this.trickle || this._iceComplete) sendAnswer(); ++ else this.once('_iceComplete', sendAnswer); ++ }; ++ ++ const onError = err => { ++ this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION')); ++ }; ++ ++ this._pc.setLocalDescription(answer).then(onSuccess).catch(onError); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_CREATE_ANSWER')); ++ }); ++ } ++ ++ _onConnectionStateChange () { ++ if (this.destroyed) return ++ if (this._pc.connectionState === 'failed') { ++ this.destroy( ++ errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE') ++ ); ++ } ++ } ++ ++ _onIceStateChange () { ++ if (this.destroyed) return ++ const iceConnectionState = this._pc.iceConnectionState; ++ const iceGatheringState = this._pc.iceGatheringState; ++ ++ this._debug( ++ 'iceStateChange (connection: %s) (gathering: %s)', ++ iceConnectionState, ++ iceGatheringState ++ ); ++ this.emit('iceStateChange', iceConnectionState, iceGatheringState); ++ ++ if ( ++ iceConnectionState === 'connected' || ++ iceConnectionState === 'completed' ++ ) { ++ this._pcReady = true; ++ this._maybeReady(); ++ } ++ if (iceConnectionState === 'failed') { ++ this.destroy( ++ errCode( ++ new Error('Ice connection failed.'), ++ 'ERR_ICE_CONNECTION_FAILURE' ++ ) ++ ); ++ } ++ if (iceConnectionState === 'closed') { ++ this.destroy( ++ errCode( ++ new Error('Ice connection closed.'), ++ 'ERR_ICE_CONNECTION_CLOSED' ++ ) ++ ); ++ } ++ } ++ ++ getStats (cb) { ++ // statreports can come with a value array instead of properties ++ const flattenValues = report => { ++ if (Object.prototype.toString.call(report.values) === '[object Array]') { ++ report.values.forEach(value => { ++ Object.assign(report, value); ++ }); ++ } ++ return report ++ }; ++ ++ // Promise-based getStats() (standard) ++ if (this._pc.getStats.length === 0 || this._isReactNativeWebrtc) { ++ this._pc.getStats().then( ++ res => { ++ const reports = []; ++ res.forEach(report => { ++ reports.push(flattenValues(report)); ++ }); ++ cb(null, reports); ++ }, ++ err => cb(err) ++ ); ++ ++ // Single-parameter callback-based getStats() (non-standard) ++ } else if (this._pc.getStats.length > 0) { ++ this._pc.getStats( ++ res => { ++ // If we destroy connection in `connect` callback this code might happen to run when actual connection is already closed ++ if (this.destroyed) return ++ ++ const reports = []; ++ res.result().forEach(result => { ++ const report = {}; ++ result.names().forEach(name => { ++ report[name] = result.stat(name); ++ }); ++ report.id = result.id; ++ report.type = result.type; ++ report.timestamp = result.timestamp; ++ reports.push(flattenValues(report)); ++ }); ++ cb(null, reports); ++ }, ++ err => cb(err) ++ ); ++ ++ // Unknown browser, skip getStats() since it's anyone's guess which style of ++ // getStats() they implement. ++ } else { ++ cb(null, []); ++ } ++ } ++ ++ _maybeReady () { ++ this._debug( ++ 'maybeReady pc %s channel %s', ++ this._pcReady, ++ this._channelReady ++ ); ++ if ( ++ this._connected || ++ this._connecting || ++ !this._pcReady || ++ !this._channelReady ++ ) { return } ++ ++ this._connecting = true; ++ ++ // HACK: We can't rely on order here, for details see https://github.com/js-platform/node-webrtc/issues/339 ++ const findCandidatePair = () => { ++ if (this.destroyed) return ++ ++ this.getStats((err, items) => { ++ if (this.destroyed) return ++ ++ // Treat getStats error as non-fatal. It's not essential. ++ if (err) items = []; ++ ++ const remoteCandidates = {}; ++ const localCandidates = {}; ++ const candidatePairs = {}; ++ let foundSelectedCandidatePair = false; ++ ++ items.forEach(item => { ++ // TODO: Once all browsers support the hyphenated stats report types, remove ++ // the non-hypenated ones ++ if ( ++ item.type === 'remotecandidate' || ++ item.type === 'remote-candidate' ++ ) { ++ remoteCandidates[item.id] = item; ++ } ++ if ( ++ item.type === 'localcandidate' || ++ item.type === 'local-candidate' ++ ) { ++ localCandidates[item.id] = item; ++ } ++ if (item.type === 'candidatepair' || item.type === 'candidate-pair') { ++ candidatePairs[item.id] = item; ++ } ++ }); ++ ++ const setSelectedCandidatePair = selectedCandidatePair => { ++ foundSelectedCandidatePair = true; ++ ++ let local = localCandidates[selectedCandidatePair.localCandidateId]; ++ ++ if (local && (local.ip || local.address)) { ++ // Spec ++ this.localAddress = local.ip || local.address; ++ this.localPort = Number(local.port); ++ } else if (local && local.ipAddress) { ++ // Firefox ++ this.localAddress = local.ipAddress; ++ this.localPort = Number(local.portNumber); ++ } else if ( ++ typeof selectedCandidatePair.googLocalAddress === 'string' ++ ) { ++ // TODO: remove this once Chrome 58 is released ++ local = selectedCandidatePair.googLocalAddress.split(':'); ++ this.localAddress = local[0]; ++ this.localPort = Number(local[1]); ++ } ++ if (this.localAddress) { ++ this.localFamily = this.localAddress.includes(':') ++ ? 'IPv6' ++ : 'IPv4'; ++ } ++ ++ let remote = ++ remoteCandidates[selectedCandidatePair.remoteCandidateId]; ++ ++ if (remote && (remote.ip || remote.address)) { ++ // Spec ++ this.remoteAddress = remote.ip || remote.address; ++ this.remotePort = Number(remote.port); ++ } else if (remote && remote.ipAddress) { ++ // Firefox ++ this.remoteAddress = remote.ipAddress; ++ this.remotePort = Number(remote.portNumber); ++ } else if ( ++ typeof selectedCandidatePair.googRemoteAddress === 'string' ++ ) { ++ // TODO: remove this once Chrome 58 is released ++ remote = selectedCandidatePair.googRemoteAddress.split(':'); ++ this.remoteAddress = remote[0]; ++ this.remotePort = Number(remote[1]); ++ } ++ if (this.remoteAddress) { ++ this.remoteFamily = this.remoteAddress.includes(':') ++ ? 'IPv6' ++ : 'IPv4'; ++ } ++ ++ this._debug( ++ 'connect local: %s:%s remote: %s:%s', ++ this.localAddress, ++ this.localPort, ++ this.remoteAddress, ++ this.remotePort ++ ); ++ }; ++ ++ items.forEach(item => { ++ // Spec-compliant ++ if (item.type === 'transport' && item.selectedCandidatePairId) { ++ setSelectedCandidatePair( ++ candidatePairs[item.selectedCandidatePairId] ++ ); ++ } ++ ++ // Old implementations ++ if ( ++ (item.type === 'googCandidatePair' && ++ item.googActiveConnection === 'true') || ++ ((item.type === 'candidatepair' || ++ item.type === 'candidate-pair') && ++ item.selected) ++ ) { ++ setSelectedCandidatePair(item); ++ } ++ }); ++ ++ // Ignore candidate pair selection in browsers like Safari 11 that do not have any local or remote candidates ++ // But wait until at least 1 candidate pair is available ++ if ( ++ !foundSelectedCandidatePair && ++ (!Object.keys(candidatePairs).length || ++ Object.keys(localCandidates).length) ++ ) { ++ setTimeout(findCandidatePair, 100); ++ return ++ } else { ++ this._connecting = false; ++ this._connected = true; ++ } ++ ++ if (this._chunk) { ++ try { ++ this.send(this._chunk); ++ } catch (err) { ++ return this.destroy(errCode(err, 'ERR_DATA_CHANNEL')) ++ } ++ this._chunk = null; ++ this._debug('sent chunk from "write before connect"'); ++ ++ const cb = this._cb; ++ this._cb = null; ++ cb(null); ++ } ++ ++ // If `bufferedAmountLowThreshold` and 'onbufferedamountlow' are unsupported, ++ // fallback to using setInterval to implement backpressure. ++ if (typeof this._channel.bufferedAmountLowThreshold !== 'number') { ++ this._interval = setInterval(() => this._onInterval(), 150); ++ if (this._interval.unref) this._interval.unref(); ++ } ++ ++ this._debug('connect'); ++ this.emit('connect'); ++ }); ++ }; ++ findCandidatePair(); ++ } ++ ++ _onInterval () { ++ if ( ++ !this._cb || ++ !this._channel || ++ this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT ++ ) { ++ return ++ } ++ this._onChannelBufferedAmountLow(); ++ } ++ ++ _onSignalingStateChange () { ++ if (this.destroyed) return ++ ++ if (this._pc.signalingState === 'stable') { ++ this._isNegotiating = false; ++ ++ // HACK: Firefox doesn't yet support removing tracks when signalingState !== 'stable' ++ this._debug('flushing sender queue', this._sendersAwaitingStable); ++ this._sendersAwaitingStable.forEach(sender => { ++ this._pc.removeTrack(sender); ++ this._queuedNegotiation = true; ++ }); ++ this._sendersAwaitingStable = []; ++ ++ if (this._queuedNegotiation) { ++ this._debug('flushing negotiation queue'); ++ this._queuedNegotiation = false; ++ this._needsNegotiation(); // negotiate again ++ } else { ++ this._debug('negotiated'); ++ this.emit('negotiated'); ++ } ++ } ++ ++ this._debug('signalingStateChange %s', this._pc.signalingState); ++ this.emit('signalingStateChange', this._pc.signalingState); ++ } ++ ++ _onIceCandidate (event) { ++ if (this.destroyed) return ++ if (event.candidate && this.trickle) { ++ this.emit('signal', { ++ type: 'candidate', ++ candidate: { ++ candidate: event.candidate.candidate, ++ sdpMLineIndex: event.candidate.sdpMLineIndex, ++ sdpMid: event.candidate.sdpMid ++ } ++ }); ++ } else if (!event.candidate && !this._iceComplete) { ++ this._iceComplete = true; ++ this.emit('_iceComplete'); ++ } ++ // as soon as we've received one valid candidate start timeout ++ if (event.candidate) { ++ this._startIceCompleteTimeout(); ++ } ++ } ++ ++ _onChannelMessage (event) { ++ if (this.destroyed) return ++ let data = event.data; ++ if (data instanceof ArrayBuffer) data = new Uint8Array(data); ++ this.emit('data', data); ++ } ++ ++ _onChannelBufferedAmountLow () { ++ if (this.destroyed || !this._cb) return ++ this._debug( ++ 'ending backpressure: bufferedAmount %d', ++ this._channel.bufferedAmount ++ ); ++ const cb = this._cb; ++ this._cb = null; ++ cb(null); ++ } ++ ++ _onChannelOpen () { ++ if (this._connected || this.destroyed) return ++ this._debug('on channel open'); ++ this._channelReady = true; ++ this._maybeReady(); ++ } ++ ++ _onChannelClose () { ++ if (this.destroyed) return ++ this._debug('on channel close'); ++ this.destroy(); ++ } ++ ++ _onTrack (event) { ++ if (this.destroyed) return ++ ++ event.streams.forEach(eventStream => { ++ this._debug('on track'); ++ this.emit('track', event.track, eventStream); ++ ++ this._remoteTracks.push({ ++ track: event.track, ++ stream: eventStream ++ }); ++ ++ if ( ++ this._remoteStreams.some(remoteStream => { ++ return remoteStream.id === eventStream.id ++ }) ++ ) { return } // Only fire one 'stream' event, even though there may be multiple tracks per stream ++ ++ this._remoteStreams.push(eventStream); ++ queueMicrotask(() => { ++ this._debug('on stream'); ++ this.emit('stream', eventStream); // ensure all tracks have been added ++ }); ++ }); ++ } ++ ++ _debug (...args) { ++ if (!this._doDebug) return ++ args[0] = '[' + this._id + '] ' + args[0]; ++ console.log(...args); ++ } ++ ++ // event emitter ++ on (key, listener) { ++ const map = this._map; ++ if (!map.has(key)) map.set(key, new Set()); ++ map.get(key).add(listener); ++ } ++ ++ off (key, listener) { ++ const map = this._map; ++ const listeners = map.get(key); ++ if (!listeners) return ++ listeners.delete(listener); ++ if (listeners.size === 0) map.delete(key); ++ } ++ ++ once (key, listener) { ++ const listener_ = (...args) => { ++ this.off(key, listener_); ++ listener(...args); ++ }; ++ this.on(key, listener_); ++ } ++ ++ emit (key, ...args) { ++ const map = this._map; ++ if (!map.has(key)) return ++ for (const listener of map.get(key)) { ++ try { ++ listener(...args); ++ } catch (err) { ++ console.error(err); ++ } ++ } ++ } ++ } ++ ++ Peer.WEBRTC_SUPPORT = !!getBrowserRTC(); ++ ++ /** ++ * Expose peer and data channel config for overriding all Peer ++ * instances. Otherwise, just set opts.config or opts.channelConfig ++ * when constructing a Peer. ++ */ ++ Peer.config = { ++ iceServers: [ ++ { ++ urls: [ ++ 'stun:stun.l.google.com:19302', ++ 'stun:global.stun.twilio.com:3478' ++ ] ++ } ++ ], ++ sdpSemantics: 'unified-plan' ++ }; ++ ++ Peer.channelConfig = {}; ++ ++ class RRWebPluginCanvasWebRTCReplay { ++ constructor({ ++ canvasFoundCallback, ++ signalSendCallback ++ }) { ++ this.peer = null; ++ this.streamNodeMap = /* @__PURE__ */ new Map(); ++ this.streams = /* @__PURE__ */ new Set(); ++ this.runningStreams = /* @__PURE__ */ new WeakSet(); ++ this.canvasFoundCallback = canvasFoundCallback; ++ this.signalSendCallback = signalSendCallback; ++ } ++ initPlugin() { ++ return { ++ onBuild: (node, context) => { ++ if (node.nodeName === "CANVAS") { ++ this.canvasFoundCallback(node, context); ++ } ++ }, ++ getMirror: (options) => { ++ this.mirror = options.nodeMirror; ++ } ++ }; ++ } ++ startStream(target, stream) { ++ if (this.runningStreams.has(stream)) ++ return; ++ if (target.tagName === "VIDEO") { ++ const remoteVideo = target; ++ remoteVideo.srcObject = stream; ++ void remoteVideo.play(); ++ this.runningStreams.add(stream); ++ return; ++ } ++ if ("MediaStreamTrackProcessor" in window) { ++ const canvas = target; ++ const ctx = canvas.getContext("2d"); ++ if (!ctx) ++ throw new Error(`startStream: Could not get 2d canvas context for ${canvas.outerHTML}`); ++ const track = stream.getVideoTracks()[0]; ++ const processor = new MediaStreamTrackProcessor({ track }); ++ const reader = processor.readable.getReader(); ++ const readChunk = function() { ++ void reader.read().then(({ done, value }) => { ++ if (!value) ++ return; ++ if (canvas.width !== value.displayWidth || canvas.height !== value.displayHeight) { ++ canvas.width = value.displayWidth; ++ canvas.height = value.displayHeight; ++ } ++ ctx.clearRect(0, 0, canvas.width, canvas.height); ++ ctx.drawImage(value, 0, 0); ++ value.close(); ++ if (!done) { ++ readChunk(); ++ } ++ }); ++ }; ++ readChunk(); ++ this.runningStreams.add(stream); ++ } else { ++ const remoteVideo = document.createElement("video"); ++ remoteVideo.setAttribute("autoplay", "true"); ++ remoteVideo.setAttribute("playsinline", "true"); ++ remoteVideo.setAttribute("width", target.width.toString()); ++ remoteVideo.setAttribute("height", target.height.toString()); ++ target.replaceWith(remoteVideo); ++ this.startStream(remoteVideo, stream); ++ } ++ } ++ signalReceive(msg) { ++ if (!this.peer) { ++ this.peer = new Peer({ ++ initiator: false ++ }); ++ this.peer.on("error", (err) => { ++ this.peer = null; ++ console.log("error", err); ++ }); ++ this.peer.on("close", () => { ++ this.peer = null; ++ console.log("closing"); ++ }); ++ this.peer.on("signal", (data) => { ++ this.signalSendCallback(data); ++ }); ++ this.peer.on("connect", () => { ++ }); ++ this.peer.on("data", (data) => { ++ try { ++ const json = JSON.parse(data); ++ this.streamNodeMap.set(json.streamId, json.nodeId); ++ } catch (error) { ++ console.error("Could not parse data", error); ++ } ++ this.flushStreams(); ++ }); ++ this.peer.on("stream", (stream) => { ++ this.streams.add(stream); ++ this.flushStreams(); ++ }); ++ } ++ this.peer.signal(msg); ++ } ++ flushStreams() { ++ this.streams.forEach((stream) => { ++ const nodeId = this.streamNodeMap.get(stream.id); ++ if (!nodeId) ++ return; ++ const target = this.mirror.getNode(nodeId); ++ if (target) ++ this.startStream(target, stream); ++ }); ++ } ++ } ++ ++ exports.RRWebPluginCanvasWebRTCReplay = RRWebPluginCanvasWebRTCReplay; ++ ++ Object.defineProperty(exports, '__esModule', { value: true }); ++ ++ return exports; ++ ++})({}); +diff --git a/node_modules/rrweb/dist/plugins/canvas-webrtc-replay.min.js b/node_modules/rrweb/dist/plugins/canvas-webrtc-replay.min.js +new file mode 100755 +index 0000000..818750a +--- /dev/null ++++ b/node_modules/rrweb/dist/plugins/canvas-webrtc-replay.min.js +@@ -0,0 +1,2 @@ ++var rrwebCanvasWebRTCReplay=function(g){"use strict";/*! simple-peer. MIT License. Feross Aboukhadijeh */function f(h){const e=new Uint8Array(h);for(let t=0;t"u")return null;const h={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return h.RTCPeerConnection?h:null}function r(h,e){return Object.defineProperty(h,"code",{value:e,enumerable:!0,configurable:!0}),h}function m(h){return h.replace(/a=ice-options:trickle\s\n/g,"")}function y(h){console.warn(h)}class _{constructor(e={}){if(this._map=new Map,this._id=f(4).toString("hex").slice(0,7),this._doDebug=e.debug,this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||f(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||_.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},_.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(t=>t),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=e.trickle!==void 0?e.trickle:!0,this.allowHalfTrickle=e.allowHalfTrickle!==void 0?e.allowHalfTrickle:!1,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&typeof e.wrtc=="object"?e.wrtc:p(),!this._wrtc)throw r(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(t){this.destroy(r(t,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(t=>{this.destroy(r(t,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this.streams&&this.streams.forEach(t=>{this.addStream(t)}),this._pc.ontrack=t=>{this._onTrack(t)},this._debug("initial negotiation"),this._needsNegotiation()}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof e=="string")try{e=JSON.parse(e)}catch{e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(t=>{this.destroy(r(t,"ERR_SET_REMOTE_DESCRIPTION"))}),!e.sdp&&!e.candidate&&!e.renegotiate&&!e.transceiverRequest&&this.destroy(r(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch(i=>{!t.address||t.address.endsWith(".local")?y("Ignoring unsupported ICE candidate."):this.destroy(r(i,"ERR_ADD_ICE_CANDIDATE"))})}send(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(i){this.destroy(r(i,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach(t=>{this.addTrack(t,e)})}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const i=this._senderMap.get(e)||new Map;let s=i.get(t);if(!s)s=this._pc.addTrack(e,t),i.set(t,s),this._senderMap.set(e,i),this._needsNegotiation();else throw s.removed?r(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):r(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(e,t,i){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const s=this._senderMap.get(e),a=s?s.get(i):null;if(!a)throw r(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,s),a.replaceTrack!=null?a.replaceTrack(t):this.destroy(r(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const i=this._senderMap.get(e),s=i?i.get(t):null;if(!s)throw r(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{s.removed=!0,this._pc.removeTrack(s)}catch(a){a.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(s):this.destroy(r(a,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach(t=>{this.removeTrack(t,e)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close")}))}_setupData(e){if(!e.channel)return this.destroy(r(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=65536),this.channelName=this._channel.label,this._channel.onmessage=i=>{this._onChannelMessage(i)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=i=>{this.destroy(r(i,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(t&&this._onChannelClose(),t=!0):t=!1},5e3)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=m(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const a=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:a.type,sdp:a.sdp})},i=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},s=a=>{this.destroy(r(a,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(i).catch(s)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(e=>{!e.mid&&e.sender.track&&!e.requested&&(e.requested=!0,this.addTransceiver(e.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=m(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const a=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:a.type,sdp:a.sdp}),this.initiator||this._requestMissingTransceivers()},i=()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},s=a=>{this.destroy(r(a,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(i).catch(s)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(r(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),(e==="connected"||e==="completed")&&(this._pcReady=!0,this._maybeReady()),e==="failed"&&this.destroy(r(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),e==="closed"&&this.destroy(r(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=i=>(Object.prototype.toString.call(i.values)==="[object Array]"&&i.values.forEach(s=>{Object.assign(i,s)}),i);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(i=>{const s=[];i.forEach(a=>{s.push(t(a))}),e(null,s)},i=>e(i)):this._pc.getStats.length>0?this._pc.getStats(i=>{if(this.destroyed)return;const s=[];i.result().forEach(a=>{const c={};a.names().forEach(l=>{c[l]=a.stat(l)}),c.id=a.id,c.type=a.type,c.timestamp=a.timestamp,s.push(t(c))}),e(null,s)},i=>e(i)):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats((t,i)=>{if(this.destroyed)return;t&&(i=[]);const s={},a={},c={};let l=!1;i.forEach(n=>{(n.type==="remotecandidate"||n.type==="remote-candidate")&&(s[n.id]=n),(n.type==="localcandidate"||n.type==="local-candidate")&&(a[n.id]=n),(n.type==="candidatepair"||n.type==="candidate-pair")&&(c[n.id]=n)});const u=n=>{l=!0;let o=a[n.localCandidateId];o&&(o.ip||o.address)?(this.localAddress=o.ip||o.address,this.localPort=Number(o.port)):o&&o.ipAddress?(this.localAddress=o.ipAddress,this.localPort=Number(o.portNumber)):typeof n.googLocalAddress=="string"&&(o=n.googLocalAddress.split(":"),this.localAddress=o[0],this.localPort=Number(o[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let d=s[n.remoteCandidateId];d&&(d.ip||d.address)?(this.remoteAddress=d.ip||d.address,this.remotePort=Number(d.port)):d&&d.ipAddress?(this.remoteAddress=d.ipAddress,this.remotePort=Number(d.portNumber)):typeof n.googRemoteAddress=="string"&&(d=n.googRemoteAddress.split(":"),this.remoteAddress=d[0],this.remotePort=Number(d[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(i.forEach(n=>{n.type==="transport"&&n.selectedCandidatePairId&&u(c[n.selectedCandidatePairId]),(n.type==="googCandidatePair"&&n.googActiveConnection==="true"||(n.type==="candidatepair"||n.type==="candidate-pair")&&n.selected)&&u(n)}),!l&&(!Object.keys(c).length||Object.keys(a).length)){setTimeout(e,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(o){return this.destroy(r(o,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const n=this._cb;this._cb=null,n(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.emit("data",t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach(t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),!this._remoteStreams.some(i=>i.id===t.id)&&(this._remoteStreams.push(t),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",t)}))})}_debug(...e){!this._doDebug||(e[0]="["+this._id+"] "+e[0],console.log(...e))}on(e,t){const i=this._map;i.has(e)||i.set(e,new Set),i.get(e).add(t)}off(e,t){const i=this._map,s=i.get(e);!s||(s.delete(t),s.size===0&&i.delete(e))}once(e,t){const i=(...s)=>{this.off(e,i),t(...s)};this.on(e,i)}emit(e,...t){const i=this._map;if(!!i.has(e))for(const s of i.get(e))try{s(...t)}catch(a){console.error(a)}}}_.WEBRTC_SUPPORT=!!p(),_.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},_.channelConfig={};class R{constructor({canvasFoundCallback:e,signalSendCallback:t}){this.peer=null,this.streamNodeMap=new Map,this.streams=new Set,this.runningStreams=new WeakSet,this.canvasFoundCallback=e,this.signalSendCallback=t}initPlugin(){return{onBuild:(e,t)=>{e.nodeName==="CANVAS"&&this.canvasFoundCallback(e,t)},getMirror:e=>{this.mirror=e.nodeMirror}}}startStream(e,t){if(!this.runningStreams.has(t)){if(e.tagName==="VIDEO"){const i=e;i.srcObject=t,i.play(),this.runningStreams.add(t);return}if("MediaStreamTrackProcessor"in window){const i=e,s=i.getContext("2d");if(!s)throw new Error(`startStream: Could not get 2d canvas context for ${i.outerHTML}`);const a=t.getVideoTracks()[0],c=new MediaStreamTrackProcessor({track:a}).readable.getReader(),l=function(){c.read().then(({done:u,value:n})=>{!n||((i.width!==n.displayWidth||i.height!==n.displayHeight)&&(i.width=n.displayWidth,i.height=n.displayHeight),s.clearRect(0,0,i.width,i.height),s.drawImage(n,0,0),n.close(),u||l())})};l(),this.runningStreams.add(t)}else{const i=document.createElement("video");i.setAttribute("autoplay","true"),i.setAttribute("playsinline","true"),i.setAttribute("width",e.width.toString()),i.setAttribute("height",e.height.toString()),e.replaceWith(i),this.startStream(i,t)}}}signalReceive(e){this.peer||(this.peer=new _({initiator:!1}),this.peer.on("error",t=>{this.peer=null,console.log("error",t)}),this.peer.on("close",()=>{this.peer=null,console.log("closing")}),this.peer.on("signal",t=>{this.signalSendCallback(t)}),this.peer.on("connect",()=>{}),this.peer.on("data",t=>{try{const i=JSON.parse(t);this.streamNodeMap.set(i.streamId,i.nodeId)}catch(i){console.error("Could not parse data",i)}this.flushStreams()}),this.peer.on("stream",t=>{this.streams.add(t),this.flushStreams()})),this.peer.signal(e)}flushStreams(){this.streams.forEach(e=>{const t=this.streamNodeMap.get(e.id);if(!t)return;const i=this.mirror.getNode(t);i&&this.startStream(i,e)})}}return g.RRWebPluginCanvasWebRTCReplay=R,Object.defineProperty(g,"__esModule",{value:!0}),g}({}); ++//# sourceMappingURL=canvas-webrtc-replay.min.js.map +diff --git a/node_modules/rrweb/dist/plugins/canvas-webrtc-replay.min.js.map b/node_modules/rrweb/dist/plugins/canvas-webrtc-replay.min.js.map +new file mode 100755 +index 0000000..a66c68d +--- /dev/null ++++ b/node_modules/rrweb/dist/plugins/canvas-webrtc-replay.min.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"canvas-webrtc-replay.min.js","sources":["../../../../node_modules/simple-peer-light/index.js","../../src/plugins/canvas-webrtc/replay/index.ts"],"sourcesContent":["/*! simple-peer. MIT License. Feross Aboukhadijeh */\nconst MAX_BUFFERED_AMOUNT = 64 * 1024\nconst ICECOMPLETE_TIMEOUT = 5 * 1000\nconst CHANNEL_CLOSING_TIMEOUT = 5 * 1000\n\nfunction randombytes (size) {\n const array = new Uint8Array(size)\n for (let i = 0; i < size; i++) {\n array[i] = (Math.random() * 256) | 0\n }\n return array\n}\n\nfunction getBrowserRTC () {\n if (typeof globalThis === 'undefined') return null\n const wrtc = {\n RTCPeerConnection:\n globalThis.RTCPeerConnection ||\n globalThis.mozRTCPeerConnection ||\n globalThis.webkitRTCPeerConnection,\n RTCSessionDescription:\n globalThis.RTCSessionDescription ||\n globalThis.mozRTCSessionDescription ||\n globalThis.webkitRTCSessionDescription,\n RTCIceCandidate:\n globalThis.RTCIceCandidate ||\n globalThis.mozRTCIceCandidate ||\n globalThis.webkitRTCIceCandidate\n }\n if (!wrtc.RTCPeerConnection) return null\n return wrtc\n}\n\nfunction errCode (err, code) {\n Object.defineProperty(err, 'code', {\n value: code,\n enumerable: true,\n configurable: true\n })\n return err\n}\n\n// HACK: Filter trickle lines when trickle is disabled #354\nfunction filterTrickle (sdp) {\n return sdp.replace(/a=ice-options:trickle\\s\\n/g, '')\n}\n\nfunction warn (message) {\n console.warn(message)\n}\n\n/**\n * WebRTC peer connection.\n * @param {Object} opts\n */\nclass Peer {\n constructor (opts = {}) {\n this._map = new Map() // for event emitter\n\n this._id = randombytes(4).toString('hex').slice(0, 7)\n this._doDebug = opts.debug\n this._debug('new peer %o', opts)\n\n this.channelName = opts.initiator\n ? opts.channelName || randombytes(20).toString('hex')\n : null\n\n this.initiator = opts.initiator || false\n this.channelConfig = opts.channelConfig || Peer.channelConfig\n this.channelNegotiated = this.channelConfig.negotiated\n this.config = Object.assign({}, Peer.config, opts.config)\n this.offerOptions = opts.offerOptions || {}\n this.answerOptions = opts.answerOptions || {}\n this.sdpTransform = opts.sdpTransform || (sdp => sdp)\n this.streams = opts.streams || (opts.stream ? [opts.stream] : []) // support old \"stream\" option\n this.trickle = opts.trickle !== undefined ? opts.trickle : true\n this.allowHalfTrickle =\n opts.allowHalfTrickle !== undefined ? opts.allowHalfTrickle : false\n this.iceCompleteTimeout = opts.iceCompleteTimeout || ICECOMPLETE_TIMEOUT\n\n this.destroyed = false\n this.destroying = false\n this._connected = false\n\n this.remoteAddress = undefined\n this.remoteFamily = undefined\n this.remotePort = undefined\n this.localAddress = undefined\n this.localFamily = undefined\n this.localPort = undefined\n\n this._wrtc =\n opts.wrtc && typeof opts.wrtc === 'object' ? opts.wrtc : getBrowserRTC()\n\n if (!this._wrtc) {\n if (typeof window === 'undefined') {\n throw errCode(\n new Error(\n 'No WebRTC support: Specify `opts.wrtc` option in this environment'\n ),\n 'ERR_WEBRTC_SUPPORT'\n )\n } else {\n throw errCode(\n new Error('No WebRTC support: Not a supported browser'),\n 'ERR_WEBRTC_SUPPORT'\n )\n }\n }\n\n this._pcReady = false\n this._channelReady = false\n this._iceComplete = false // ice candidate trickle done (got null candidate)\n this._iceCompleteTimer = null // send an offer/answer anyway after some timeout\n this._channel = null\n this._pendingCandidates = []\n\n this._isNegotiating = false // is this peer waiting for negotiation to complete?\n this._firstNegotiation = true\n this._batchedNegotiation = false // batch synchronous negotiations\n this._queuedNegotiation = false // is there a queued negotiation request?\n this._sendersAwaitingStable = []\n this._senderMap = new Map()\n this._closingInterval = null\n\n this._remoteTracks = []\n this._remoteStreams = []\n\n this._chunk = null\n this._cb = null\n this._interval = null\n\n try {\n this._pc = new this._wrtc.RTCPeerConnection(this.config)\n } catch (err) {\n this.destroy(errCode(err, 'ERR_PC_CONSTRUCTOR'))\n return\n }\n\n // We prefer feature detection whenever possible, but sometimes that's not\n // possible for certain implementations.\n this._isReactNativeWebrtc = typeof this._pc._peerConnectionId === 'number'\n\n this._pc.oniceconnectionstatechange = () => {\n this._onIceStateChange()\n }\n this._pc.onicegatheringstatechange = () => {\n this._onIceStateChange()\n }\n this._pc.onconnectionstatechange = () => {\n this._onConnectionStateChange()\n }\n this._pc.onsignalingstatechange = () => {\n this._onSignalingStateChange()\n }\n this._pc.onicecandidate = event => {\n this._onIceCandidate(event)\n }\n\n // HACK: Fix for odd Firefox behavior, see: https://github.com/feross/simple-peer/pull/783\n if (typeof this._pc.peerIdentity === 'object') {\n this._pc.peerIdentity.catch(err => {\n this.destroy(errCode(err, 'ERR_PC_PEER_IDENTITY'))\n })\n }\n\n // Other spec events, unused by this implementation:\n // - onconnectionstatechange\n // - onicecandidateerror\n // - onfingerprintfailure\n // - onnegotiationneeded\n\n if (this.initiator || this.channelNegotiated) {\n this._setupData({\n channel: this._pc.createDataChannel(\n this.channelName,\n this.channelConfig\n )\n })\n } else {\n this._pc.ondatachannel = event => {\n this._setupData(event)\n }\n }\n\n if (this.streams) {\n this.streams.forEach(stream => {\n this.addStream(stream)\n })\n }\n this._pc.ontrack = event => {\n this._onTrack(event)\n }\n\n this._debug('initial negotiation')\n this._needsNegotiation()\n }\n\n get bufferSize () {\n return (this._channel && this._channel.bufferedAmount) || 0\n }\n\n // HACK: it's possible channel.readyState is \"closing\" before peer.destroy() fires\n // https://bugs.chromium.org/p/chromium/issues/detail?id=882743\n get connected () {\n return this._connected && this._channel.readyState === 'open'\n }\n\n address () {\n return {\n port: this.localPort,\n family: this.localFamily,\n address: this.localAddress\n }\n }\n\n signal (data) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_DESTROYED')\n if (typeof data === 'string') {\n try {\n data = JSON.parse(data)\n } catch (err) {\n data = {}\n }\n }\n this._debug('signal()')\n\n if (data.renegotiate && this.initiator) {\n this._debug('got request to renegotiate')\n this._needsNegotiation()\n }\n if (data.transceiverRequest && this.initiator) {\n this._debug('got request for transceiver')\n this.addTransceiver(\n data.transceiverRequest.kind,\n data.transceiverRequest.init\n )\n }\n if (data.candidate) {\n if (this._pc.remoteDescription && this._pc.remoteDescription.type) {\n this._addIceCandidate(data.candidate)\n } else {\n this._pendingCandidates.push(data.candidate)\n }\n }\n if (data.sdp) {\n this._pc\n .setRemoteDescription(new this._wrtc.RTCSessionDescription(data))\n .then(() => {\n if (this.destroyed) return\n\n this._pendingCandidates.forEach(candidate => {\n this._addIceCandidate(candidate)\n })\n this._pendingCandidates = []\n\n if (this._pc.remoteDescription.type === 'offer') this._createAnswer()\n })\n .catch(err => {\n this.destroy(errCode(err, 'ERR_SET_REMOTE_DESCRIPTION'))\n })\n }\n if (\n !data.sdp &&\n !data.candidate &&\n !data.renegotiate &&\n !data.transceiverRequest\n ) {\n this.destroy(\n errCode(\n new Error('signal() called with invalid signal data'),\n 'ERR_SIGNALING'\n )\n )\n }\n }\n\n _addIceCandidate (candidate) {\n const iceCandidateObj = new this._wrtc.RTCIceCandidate(candidate)\n this._pc.addIceCandidate(iceCandidateObj).catch(err => {\n if (\n !iceCandidateObj.address ||\n iceCandidateObj.address.endsWith('.local')\n ) {\n warn('Ignoring unsupported ICE candidate.')\n } else {\n this.destroy(errCode(err, 'ERR_ADD_ICE_CANDIDATE'))\n }\n })\n }\n\n /**\n * Send text/binary data to the remote peer.\n * @param {ArrayBufferView|ArrayBuffer|string|Blob} chunk\n */\n send (chunk) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot send after peer is destroyed'), 'ERR_DESTROYED')\n this._channel.send(chunk)\n }\n\n /**\n * Add a Transceiver to the connection.\n * @param {String} kind\n * @param {Object} init\n */\n addTransceiver (kind, init) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot addTransceiver after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('addTransceiver()')\n\n if (this.initiator) {\n try {\n this._pc.addTransceiver(kind, init)\n this._needsNegotiation()\n } catch (err) {\n this.destroy(errCode(err, 'ERR_ADD_TRANSCEIVER'))\n }\n } else {\n this.emit('signal', {\n // request initiator to renegotiate\n type: 'transceiverRequest',\n transceiverRequest: { kind, init }\n })\n }\n }\n\n /**\n * Add a MediaStream to the connection.\n * @param {MediaStream} stream\n */\n addStream (stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot addStream after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('addStream()')\n\n stream.getTracks().forEach(track => {\n this.addTrack(track, stream)\n })\n }\n\n /**\n * Add a MediaStreamTrack to the connection.\n * @param {MediaStreamTrack} track\n * @param {MediaStream} stream\n */\n addTrack (track, stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot addTrack after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('addTrack()')\n\n const submap = this._senderMap.get(track) || new Map() // nested Maps map [track, stream] to sender\n let sender = submap.get(stream)\n if (!sender) {\n sender = this._pc.addTrack(track, stream)\n submap.set(stream, sender)\n this._senderMap.set(track, submap)\n this._needsNegotiation()\n } else if (sender.removed) {\n throw errCode(\n new Error(\n 'Track has been removed. You should enable/disable tracks that you want to re-add.'\n ),\n 'ERR_SENDER_REMOVED'\n )\n } else {\n throw errCode(\n new Error('Track has already been added to that stream.'),\n 'ERR_SENDER_ALREADY_ADDED'\n )\n }\n }\n\n /**\n * Replace a MediaStreamTrack by another in the connection.\n * @param {MediaStreamTrack} oldTrack\n * @param {MediaStreamTrack} newTrack\n * @param {MediaStream} stream\n */\n replaceTrack (oldTrack, newTrack, stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot replaceTrack after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('replaceTrack()')\n\n const submap = this._senderMap.get(oldTrack)\n const sender = submap ? submap.get(stream) : null\n if (!sender) {\n throw errCode(\n new Error('Cannot replace track that was never added.'),\n 'ERR_TRACK_NOT_ADDED'\n )\n }\n if (newTrack) this._senderMap.set(newTrack, submap)\n\n if (sender.replaceTrack != null) {\n sender.replaceTrack(newTrack)\n } else {\n this.destroy(\n errCode(\n new Error('replaceTrack is not supported in this browser'),\n 'ERR_UNSUPPORTED_REPLACETRACK'\n )\n )\n }\n }\n\n /**\n * Remove a MediaStreamTrack from the connection.\n * @param {MediaStreamTrack} track\n * @param {MediaStream} stream\n */\n removeTrack (track, stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot removeTrack after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('removeSender()')\n\n const submap = this._senderMap.get(track)\n const sender = submap ? submap.get(stream) : null\n if (!sender) {\n throw errCode(\n new Error('Cannot remove track that was never added.'),\n 'ERR_TRACK_NOT_ADDED'\n )\n }\n try {\n sender.removed = true\n this._pc.removeTrack(sender)\n } catch (err) {\n if (err.name === 'NS_ERROR_UNEXPECTED') {\n this._sendersAwaitingStable.push(sender) // HACK: Firefox must wait until (signalingState === stable) https://bugzilla.mozilla.org/show_bug.cgi?id=1133874\n } else {\n this.destroy(errCode(err, 'ERR_REMOVE_TRACK'))\n }\n }\n this._needsNegotiation()\n }\n\n /**\n * Remove a MediaStream from the connection.\n * @param {MediaStream} stream\n */\n removeStream (stream) {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot removeStream after peer is destroyed'), 'ERR_DESTROYED')\n this._debug('removeSenders()')\n\n stream.getTracks().forEach(track => {\n this.removeTrack(track, stream)\n })\n }\n\n _needsNegotiation () {\n this._debug('_needsNegotiation')\n if (this._batchedNegotiation) return // batch synchronous renegotiations\n this._batchedNegotiation = true\n queueMicrotask(() => {\n this._batchedNegotiation = false\n if (this.initiator || !this._firstNegotiation) {\n this._debug('starting batched negotiation')\n this.negotiate()\n } else {\n this._debug('non-initiator initial negotiation request discarded')\n }\n this._firstNegotiation = false\n })\n }\n\n negotiate () {\n if (this.destroying) return\n if (this.destroyed) throw errCode(new Error('cannot negotiate after peer is destroyed'), 'ERR_DESTROYED')\n\n if (this.initiator) {\n if (this._isNegotiating) {\n this._queuedNegotiation = true\n this._debug('already negotiating, queueing')\n } else {\n this._debug('start negotiation')\n setTimeout(() => {\n // HACK: Chrome crashes if we immediately call createOffer\n this._createOffer()\n }, 0)\n }\n } else {\n if (this._isNegotiating) {\n this._queuedNegotiation = true\n this._debug('already negotiating, queueing')\n } else {\n this._debug('requesting negotiation from initiator')\n this.emit('signal', {\n // request initiator to renegotiate\n type: 'renegotiate',\n renegotiate: true\n })\n }\n }\n this._isNegotiating = true\n }\n\n destroy (err) {\n if (this.destroyed || this.destroying) return\n this.destroying = true\n\n this._debug('destroying (error: %s)', err && (err.message || err))\n\n queueMicrotask(() => {\n // allow events concurrent with the call to _destroy() to fire (see #692)\n this.destroyed = true\n this.destroying = false\n\n this._debug('destroy (error: %s)', err && (err.message || err))\n\n this._connected = false\n this._pcReady = false\n this._channelReady = false\n this._remoteTracks = null\n this._remoteStreams = null\n this._senderMap = null\n\n clearInterval(this._closingInterval)\n this._closingInterval = null\n\n clearInterval(this._interval)\n this._interval = null\n this._chunk = null\n this._cb = null\n\n if (this._channel) {\n try {\n this._channel.close()\n } catch (err) {}\n\n // allow events concurrent with destruction to be handled\n this._channel.onmessage = null\n this._channel.onopen = null\n this._channel.onclose = null\n this._channel.onerror = null\n }\n if (this._pc) {\n try {\n this._pc.close()\n } catch (err) {}\n\n // allow events concurrent with destruction to be handled\n this._pc.oniceconnectionstatechange = null\n this._pc.onicegatheringstatechange = null\n this._pc.onsignalingstatechange = null\n this._pc.onicecandidate = null\n this._pc.ontrack = null\n this._pc.ondatachannel = null\n }\n this._pc = null\n this._channel = null\n\n if (err) this.emit('error', err)\n this.emit('close')\n })\n }\n\n _setupData (event) {\n if (!event.channel) {\n // In some situations `pc.createDataChannel()` returns `undefined` (in wrtc),\n // which is invalid behavior. Handle it gracefully.\n // See: https://github.com/feross/simple-peer/issues/163\n return this.destroy(\n errCode(\n new Error('Data channel event is missing `channel` property'),\n 'ERR_DATA_CHANNEL'\n )\n )\n }\n\n this._channel = event.channel\n this._channel.binaryType = 'arraybuffer'\n\n if (typeof this._channel.bufferedAmountLowThreshold === 'number') {\n this._channel.bufferedAmountLowThreshold = MAX_BUFFERED_AMOUNT\n }\n\n this.channelName = this._channel.label\n\n this._channel.onmessage = event => {\n this._onChannelMessage(event)\n }\n this._channel.onbufferedamountlow = () => {\n this._onChannelBufferedAmountLow()\n }\n this._channel.onopen = () => {\n this._onChannelOpen()\n }\n this._channel.onclose = () => {\n this._onChannelClose()\n }\n this._channel.onerror = err => {\n this.destroy(errCode(err, 'ERR_DATA_CHANNEL'))\n }\n\n // HACK: Chrome will sometimes get stuck in readyState \"closing\", let's check for this condition\n // https://bugs.chromium.org/p/chromium/issues/detail?id=882743\n let isClosing = false\n this._closingInterval = setInterval(() => {\n // No \"onclosing\" event\n if (this._channel && this._channel.readyState === 'closing') {\n if (isClosing) this._onChannelClose() // closing timed out: equivalent to onclose firing\n isClosing = true\n } else {\n isClosing = false\n }\n }, CHANNEL_CLOSING_TIMEOUT)\n }\n\n _startIceCompleteTimeout () {\n if (this.destroyed) return\n if (this._iceCompleteTimer) return\n this._debug('started iceComplete timeout')\n this._iceCompleteTimer = setTimeout(() => {\n if (!this._iceComplete) {\n this._iceComplete = true\n this._debug('iceComplete timeout completed')\n this.emit('iceTimeout')\n this.emit('_iceComplete')\n }\n }, this.iceCompleteTimeout)\n }\n\n _createOffer () {\n if (this.destroyed) return\n\n this._pc\n .createOffer(this.offerOptions)\n .then(offer => {\n if (this.destroyed) return\n if (!this.trickle && !this.allowHalfTrickle) { offer.sdp = filterTrickle(offer.sdp) }\n offer.sdp = this.sdpTransform(offer.sdp)\n\n const sendOffer = () => {\n if (this.destroyed) return\n const signal = this._pc.localDescription || offer\n this._debug('signal')\n this.emit('signal', {\n type: signal.type,\n sdp: signal.sdp\n })\n }\n\n const onSuccess = () => {\n this._debug('createOffer success')\n if (this.destroyed) return\n if (this.trickle || this._iceComplete) sendOffer()\n else this.once('_iceComplete', sendOffer) // wait for candidates\n }\n\n const onError = err => {\n this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION'))\n }\n\n this._pc.setLocalDescription(offer).then(onSuccess).catch(onError)\n })\n .catch(err => {\n this.destroy(errCode(err, 'ERR_CREATE_OFFER'))\n })\n }\n\n _requestMissingTransceivers () {\n if (this._pc.getTransceivers) {\n this._pc.getTransceivers().forEach(transceiver => {\n if (\n !transceiver.mid &&\n transceiver.sender.track &&\n !transceiver.requested\n ) {\n transceiver.requested = true // HACK: Safari returns negotiated transceivers with a null mid\n this.addTransceiver(transceiver.sender.track.kind)\n }\n })\n }\n }\n\n _createAnswer () {\n if (this.destroyed) return\n\n this._pc\n .createAnswer(this.answerOptions)\n .then(answer => {\n if (this.destroyed) return\n if (!this.trickle && !this.allowHalfTrickle) { answer.sdp = filterTrickle(answer.sdp) }\n answer.sdp = this.sdpTransform(answer.sdp)\n\n const sendAnswer = () => {\n if (this.destroyed) return\n const signal = this._pc.localDescription || answer\n this._debug('signal')\n this.emit('signal', {\n type: signal.type,\n sdp: signal.sdp\n })\n if (!this.initiator) this._requestMissingTransceivers()\n }\n\n const onSuccess = () => {\n if (this.destroyed) return\n if (this.trickle || this._iceComplete) sendAnswer()\n else this.once('_iceComplete', sendAnswer)\n }\n\n const onError = err => {\n this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION'))\n }\n\n this._pc.setLocalDescription(answer).then(onSuccess).catch(onError)\n })\n .catch(err => {\n this.destroy(errCode(err, 'ERR_CREATE_ANSWER'))\n })\n }\n\n _onConnectionStateChange () {\n if (this.destroyed) return\n if (this._pc.connectionState === 'failed') {\n this.destroy(\n errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE')\n )\n }\n }\n\n _onIceStateChange () {\n if (this.destroyed) return\n const iceConnectionState = this._pc.iceConnectionState\n const iceGatheringState = this._pc.iceGatheringState\n\n this._debug(\n 'iceStateChange (connection: %s) (gathering: %s)',\n iceConnectionState,\n iceGatheringState\n )\n this.emit('iceStateChange', iceConnectionState, iceGatheringState)\n\n if (\n iceConnectionState === 'connected' ||\n iceConnectionState === 'completed'\n ) {\n this._pcReady = true\n this._maybeReady()\n }\n if (iceConnectionState === 'failed') {\n this.destroy(\n errCode(\n new Error('Ice connection failed.'),\n 'ERR_ICE_CONNECTION_FAILURE'\n )\n )\n }\n if (iceConnectionState === 'closed') {\n this.destroy(\n errCode(\n new Error('Ice connection closed.'),\n 'ERR_ICE_CONNECTION_CLOSED'\n )\n )\n }\n }\n\n getStats (cb) {\n // statreports can come with a value array instead of properties\n const flattenValues = report => {\n if (Object.prototype.toString.call(report.values) === '[object Array]') {\n report.values.forEach(value => {\n Object.assign(report, value)\n })\n }\n return report\n }\n\n // Promise-based getStats() (standard)\n if (this._pc.getStats.length === 0 || this._isReactNativeWebrtc) {\n this._pc.getStats().then(\n res => {\n const reports = []\n res.forEach(report => {\n reports.push(flattenValues(report))\n })\n cb(null, reports)\n },\n err => cb(err)\n )\n\n // Single-parameter callback-based getStats() (non-standard)\n } else if (this._pc.getStats.length > 0) {\n this._pc.getStats(\n res => {\n // If we destroy connection in `connect` callback this code might happen to run when actual connection is already closed\n if (this.destroyed) return\n\n const reports = []\n res.result().forEach(result => {\n const report = {}\n result.names().forEach(name => {\n report[name] = result.stat(name)\n })\n report.id = result.id\n report.type = result.type\n report.timestamp = result.timestamp\n reports.push(flattenValues(report))\n })\n cb(null, reports)\n },\n err => cb(err)\n )\n\n // Unknown browser, skip getStats() since it's anyone's guess which style of\n // getStats() they implement.\n } else {\n cb(null, [])\n }\n }\n\n _maybeReady () {\n this._debug(\n 'maybeReady pc %s channel %s',\n this._pcReady,\n this._channelReady\n )\n if (\n this._connected ||\n this._connecting ||\n !this._pcReady ||\n !this._channelReady\n ) { return }\n\n this._connecting = true\n\n // HACK: We can't rely on order here, for details see https://github.com/js-platform/node-webrtc/issues/339\n const findCandidatePair = () => {\n if (this.destroyed) return\n\n this.getStats((err, items) => {\n if (this.destroyed) return\n\n // Treat getStats error as non-fatal. It's not essential.\n if (err) items = []\n\n const remoteCandidates = {}\n const localCandidates = {}\n const candidatePairs = {}\n let foundSelectedCandidatePair = false\n\n items.forEach(item => {\n // TODO: Once all browsers support the hyphenated stats report types, remove\n // the non-hypenated ones\n if (\n item.type === 'remotecandidate' ||\n item.type === 'remote-candidate'\n ) {\n remoteCandidates[item.id] = item\n }\n if (\n item.type === 'localcandidate' ||\n item.type === 'local-candidate'\n ) {\n localCandidates[item.id] = item\n }\n if (item.type === 'candidatepair' || item.type === 'candidate-pair') {\n candidatePairs[item.id] = item\n }\n })\n\n const setSelectedCandidatePair = selectedCandidatePair => {\n foundSelectedCandidatePair = true\n\n let local = localCandidates[selectedCandidatePair.localCandidateId]\n\n if (local && (local.ip || local.address)) {\n // Spec\n this.localAddress = local.ip || local.address\n this.localPort = Number(local.port)\n } else if (local && local.ipAddress) {\n // Firefox\n this.localAddress = local.ipAddress\n this.localPort = Number(local.portNumber)\n } else if (\n typeof selectedCandidatePair.googLocalAddress === 'string'\n ) {\n // TODO: remove this once Chrome 58 is released\n local = selectedCandidatePair.googLocalAddress.split(':')\n this.localAddress = local[0]\n this.localPort = Number(local[1])\n }\n if (this.localAddress) {\n this.localFamily = this.localAddress.includes(':')\n ? 'IPv6'\n : 'IPv4'\n }\n\n let remote =\n remoteCandidates[selectedCandidatePair.remoteCandidateId]\n\n if (remote && (remote.ip || remote.address)) {\n // Spec\n this.remoteAddress = remote.ip || remote.address\n this.remotePort = Number(remote.port)\n } else if (remote && remote.ipAddress) {\n // Firefox\n this.remoteAddress = remote.ipAddress\n this.remotePort = Number(remote.portNumber)\n } else if (\n typeof selectedCandidatePair.googRemoteAddress === 'string'\n ) {\n // TODO: remove this once Chrome 58 is released\n remote = selectedCandidatePair.googRemoteAddress.split(':')\n this.remoteAddress = remote[0]\n this.remotePort = Number(remote[1])\n }\n if (this.remoteAddress) {\n this.remoteFamily = this.remoteAddress.includes(':')\n ? 'IPv6'\n : 'IPv4'\n }\n\n this._debug(\n 'connect local: %s:%s remote: %s:%s',\n this.localAddress,\n this.localPort,\n this.remoteAddress,\n this.remotePort\n )\n }\n\n items.forEach(item => {\n // Spec-compliant\n if (item.type === 'transport' && item.selectedCandidatePairId) {\n setSelectedCandidatePair(\n candidatePairs[item.selectedCandidatePairId]\n )\n }\n\n // Old implementations\n if (\n (item.type === 'googCandidatePair' &&\n item.googActiveConnection === 'true') ||\n ((item.type === 'candidatepair' ||\n item.type === 'candidate-pair') &&\n item.selected)\n ) {\n setSelectedCandidatePair(item)\n }\n })\n\n // Ignore candidate pair selection in browsers like Safari 11 that do not have any local or remote candidates\n // But wait until at least 1 candidate pair is available\n if (\n !foundSelectedCandidatePair &&\n (!Object.keys(candidatePairs).length ||\n Object.keys(localCandidates).length)\n ) {\n setTimeout(findCandidatePair, 100)\n return\n } else {\n this._connecting = false\n this._connected = true\n }\n\n if (this._chunk) {\n try {\n this.send(this._chunk)\n } catch (err) {\n return this.destroy(errCode(err, 'ERR_DATA_CHANNEL'))\n }\n this._chunk = null\n this._debug('sent chunk from \"write before connect\"')\n\n const cb = this._cb\n this._cb = null\n cb(null)\n }\n\n // If `bufferedAmountLowThreshold` and 'onbufferedamountlow' are unsupported,\n // fallback to using setInterval to implement backpressure.\n if (typeof this._channel.bufferedAmountLowThreshold !== 'number') {\n this._interval = setInterval(() => this._onInterval(), 150)\n if (this._interval.unref) this._interval.unref()\n }\n\n this._debug('connect')\n this.emit('connect')\n })\n }\n findCandidatePair()\n }\n\n _onInterval () {\n if (\n !this._cb ||\n !this._channel ||\n this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT\n ) {\n return\n }\n this._onChannelBufferedAmountLow()\n }\n\n _onSignalingStateChange () {\n if (this.destroyed) return\n\n if (this._pc.signalingState === 'stable') {\n this._isNegotiating = false\n\n // HACK: Firefox doesn't yet support removing tracks when signalingState !== 'stable'\n this._debug('flushing sender queue', this._sendersAwaitingStable)\n this._sendersAwaitingStable.forEach(sender => {\n this._pc.removeTrack(sender)\n this._queuedNegotiation = true\n })\n this._sendersAwaitingStable = []\n\n if (this._queuedNegotiation) {\n this._debug('flushing negotiation queue')\n this._queuedNegotiation = false\n this._needsNegotiation() // negotiate again\n } else {\n this._debug('negotiated')\n this.emit('negotiated')\n }\n }\n\n this._debug('signalingStateChange %s', this._pc.signalingState)\n this.emit('signalingStateChange', this._pc.signalingState)\n }\n\n _onIceCandidate (event) {\n if (this.destroyed) return\n if (event.candidate && this.trickle) {\n this.emit('signal', {\n type: 'candidate',\n candidate: {\n candidate: event.candidate.candidate,\n sdpMLineIndex: event.candidate.sdpMLineIndex,\n sdpMid: event.candidate.sdpMid\n }\n })\n } else if (!event.candidate && !this._iceComplete) {\n this._iceComplete = true\n this.emit('_iceComplete')\n }\n // as soon as we've received one valid candidate start timeout\n if (event.candidate) {\n this._startIceCompleteTimeout()\n }\n }\n\n _onChannelMessage (event) {\n if (this.destroyed) return\n let data = event.data\n if (data instanceof ArrayBuffer) data = new Uint8Array(data)\n this.emit('data', data)\n }\n\n _onChannelBufferedAmountLow () {\n if (this.destroyed || !this._cb) return\n this._debug(\n 'ending backpressure: bufferedAmount %d',\n this._channel.bufferedAmount\n )\n const cb = this._cb\n this._cb = null\n cb(null)\n }\n\n _onChannelOpen () {\n if (this._connected || this.destroyed) return\n this._debug('on channel open')\n this._channelReady = true\n this._maybeReady()\n }\n\n _onChannelClose () {\n if (this.destroyed) return\n this._debug('on channel close')\n this.destroy()\n }\n\n _onTrack (event) {\n if (this.destroyed) return\n\n event.streams.forEach(eventStream => {\n this._debug('on track')\n this.emit('track', event.track, eventStream)\n\n this._remoteTracks.push({\n track: event.track,\n stream: eventStream\n })\n\n if (\n this._remoteStreams.some(remoteStream => {\n return remoteStream.id === eventStream.id\n })\n ) { return } // Only fire one 'stream' event, even though there may be multiple tracks per stream\n\n this._remoteStreams.push(eventStream)\n queueMicrotask(() => {\n this._debug('on stream')\n this.emit('stream', eventStream) // ensure all tracks have been added\n })\n })\n }\n\n _debug (...args) {\n if (!this._doDebug) return\n args[0] = '[' + this._id + '] ' + args[0]\n console.log(...args)\n }\n\n // event emitter\n on (key, listener) {\n const map = this._map\n if (!map.has(key)) map.set(key, new Set())\n map.get(key).add(listener)\n }\n\n off (key, listener) {\n const map = this._map\n const listeners = map.get(key)\n if (!listeners) return\n listeners.delete(listener)\n if (listeners.size === 0) map.delete(key)\n }\n\n once (key, listener) {\n const listener_ = (...args) => {\n this.off(key, listener_)\n listener(...args)\n }\n this.on(key, listener_)\n }\n\n emit (key, ...args) {\n const map = this._map\n if (!map.has(key)) return\n for (const listener of map.get(key)) {\n try {\n listener(...args)\n } catch (err) {\n console.error(err)\n }\n }\n }\n}\n\nPeer.WEBRTC_SUPPORT = !!getBrowserRTC()\n\n/**\n * Expose peer and data channel config for overriding all Peer\n * instances. Otherwise, just set opts.config or opts.channelConfig\n * when constructing a Peer.\n */\nPeer.config = {\n iceServers: [\n {\n urls: [\n 'stun:stun.l.google.com:19302',\n 'stun:global.stun.twilio.com:3478'\n ]\n }\n ],\n sdpSemantics: 'unified-plan'\n}\n\nPeer.channelConfig = {}\n\n// module.exports = Peer\nexport default Peer\n","import type { RRNode } from 'rrdom';\nimport type { Mirror } from 'rrweb-snapshot';\nimport SimplePeer from 'simple-peer-light';\nimport type { Replayer } from '../../../replay';\nimport type { ReplayPlugin } from '../../../types';\nimport type { WebRTCDataChannel } from '../types';\n\n// TODO: restrict callback to real nodes only, or make sure callback gets called when real node gets added to dom as well\n\nexport class RRWebPluginCanvasWebRTCReplay {\n private canvasFoundCallback: (\n node: Node | RRNode,\n context: { id: number; replayer: Replayer },\n ) => void;\n private signalSendCallback: (signal: RTCSessionDescriptionInit) => void;\n private mirror: Mirror;\n\n constructor({\n canvasFoundCallback,\n signalSendCallback,\n }: {\n canvasFoundCallback: RRWebPluginCanvasWebRTCReplay['canvasFoundCallback'];\n signalSendCallback: RRWebPluginCanvasWebRTCReplay['signalSendCallback'];\n }) {\n this.canvasFoundCallback = canvasFoundCallback;\n this.signalSendCallback = signalSendCallback;\n }\n\n public initPlugin(): ReplayPlugin {\n return {\n onBuild: (\n node: Node | RRNode,\n context: { id: number; replayer: Replayer },\n ) => {\n if (node.nodeName === 'CANVAS') {\n this.canvasFoundCallback(node, context);\n }\n },\n getMirror: (options) => {\n this.mirror = options.nodeMirror;\n },\n };\n }\n\n private startStream(\n target: HTMLCanvasElement | HTMLVideoElement,\n stream: MediaStream,\n ) {\n if (this.runningStreams.has(stream)) return;\n\n if (target.tagName === 'VIDEO') {\n const remoteVideo = target as HTMLVideoElement;\n remoteVideo.srcObject = stream;\n void remoteVideo.play();\n this.runningStreams.add(stream);\n return;\n }\n\n if ('MediaStreamTrackProcessor' in window) {\n const canvas = target as HTMLCanvasElement;\n const ctx = canvas.getContext('2d');\n if (!ctx)\n throw new Error(\n `startStream: Could not get 2d canvas context for ${canvas.outerHTML}`,\n );\n const track = stream.getVideoTracks()[0]; // MediaStream.getVideoTracks()[0]\n const processor = new MediaStreamTrackProcessor({ track: track });\n const reader = processor.readable.getReader();\n const readChunk = function () {\n void reader.read().then(({ done, value }) => {\n if (!value) return;\n // the MediaStream video can have dynamic size based on bandwidth available\n if (\n canvas.width !== value.displayWidth ||\n canvas.height !== value.displayHeight\n ) {\n canvas.width = value.displayWidth;\n canvas.height = value.displayHeight;\n }\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n // value is a VideoFrame\n ctx.drawImage(value, 0, 0);\n value.close(); // close the VideoFrame when we're done with it\n if (!done) {\n readChunk();\n }\n });\n };\n readChunk();\n this.runningStreams.add(stream);\n } else {\n // Fallback for non-Chromium browsers.\n // Replaces the canvas element with a video element.\n\n const remoteVideo = document.createElement('video');\n remoteVideo.setAttribute('autoplay', 'true');\n remoteVideo.setAttribute('playsinline', 'true');\n\n // const { id } = mutation;\n remoteVideo.setAttribute('width', target.width.toString());\n remoteVideo.setAttribute('height', target.height.toString());\n target.replaceWith(remoteVideo);\n\n this.startStream(remoteVideo, stream);\n }\n }\n\n private peer: SimplePeer.Instance | null = null;\n private streamNodeMap = new Map();\n private streams = new Set();\n private runningStreams = new WeakSet();\n public signalReceive(msg: RTCSessionDescriptionInit) {\n if (!this.peer) {\n this.peer = new SimplePeer({\n initiator: false,\n // trickle: false,\n });\n\n this.peer.on('error', (err: Error) => {\n this.peer = null;\n console.log('error', err);\n });\n\n this.peer.on('close', () => {\n this.peer = null;\n console.log('closing');\n });\n\n this.peer.on('signal', (data: RTCSessionDescriptionInit) => {\n this.signalSendCallback(data);\n });\n\n this.peer.on('connect', () => {\n // connected!\n });\n\n this.peer.on('data', (data: SimplePeer.SimplePeerData) => {\n try {\n const json = JSON.parse(data as string) as WebRTCDataChannel;\n this.streamNodeMap.set(json.streamId, json.nodeId);\n } catch (error) {\n console.error('Could not parse data', error);\n }\n this.flushStreams();\n });\n\n this.peer.on('stream', (stream: MediaStream) => {\n this.streams.add(stream);\n this.flushStreams();\n });\n }\n this.peer.signal(msg);\n }\n\n private flushStreams() {\n this.streams.forEach((stream) => {\n const nodeId = this.streamNodeMap.get(stream.id);\n if (!nodeId) return;\n const target = this.mirror.getNode(nodeId) as\n | HTMLCanvasElement\n | HTMLVideoElement\n | null;\n // got remote video stream, now let's show it in a video or canvas element\n if (target) this.startStream(target, stream);\n });\n }\n}\n"],"names":["d"],"mappings":";;;EAAA;EACA,MAAM,mBAAmB,GAAG,EAAE,GAAG,KAAI;EACrC,MAAM,mBAAmB,GAAG,CAAC,GAAG,KAAI;EACpC,MAAM,uBAAuB,GAAG,CAAC,GAAG,KAAI;AACxC;EACA,SAAS,WAAW,EAAE,IAAI,EAAE;EAC5B,EAAE,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,EAAC;EACpC,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;EACjC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,EAAC;EACxC,GAAG;EACH,EAAE,OAAO,KAAK;EACd,CAAC;AACD;EACA,SAAS,aAAa,IAAI;EAC1B,EAAE,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE,OAAO,IAAI;EACpD,EAAE,MAAM,IAAI,GAAG;EACf,IAAI,iBAAiB;EACrB,MAAM,UAAU,CAAC,iBAAiB;EAClC,MAAM,UAAU,CAAC,oBAAoB;EACrC,MAAM,UAAU,CAAC,u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C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC;;;;;;;;;;;;"} +\ No newline at end of file +diff --git a/node_modules/rrweb/dist/plugins/console-record.js b/node_modules/rrweb/dist/plugins/console-record.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/plugins/console-record.min.js b/node_modules/rrweb/dist/plugins/console-record.min.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/plugins/console-record.min.js.map b/node_modules/rrweb/dist/plugins/console-record.min.js.map +old mode 100644 +new mode 100755 +index 57dde7a..5eb3e3a +--- a/node_modules/rrweb/dist/plugins/console-record.min.js.map ++++ b/node_modules/rrweb/dist/plugins/console-record.min.js.map +@@ -1 +1 @@ +-{"version":3,"file":"console-record.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../src/types.ts","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../src/utils.ts","../../../src/plugins/console/record/error-stack-parser.ts","../../../src/plugins/console/record/stringify.ts","../../../src/plugins/console/record/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n ignoreClass?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n ignoreClass: string;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type]) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector) {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","// tslint:disable\n/**\n * Class StackFrame is a fork of https://github.com/stacktracejs/stackframe/blob/master/stackframe.js\n * I fork it because:\n * 1. There are some build issues when importing this package.\n * 2. Rewrites into typescript give us a better type interface.\n * 3. StackFrame contains some functions we don't need.\n */\nexport class StackFrame {\n private fileName: string;\n private functionName: string;\n private lineNumber?: number;\n private columnNumber?: number;\n\n constructor(obj: {\n fileName?: string;\n functionName?: string;\n lineNumber?: number;\n columnNumber?: number;\n }) {\n this.fileName = obj.fileName || '';\n this.functionName = obj.functionName || '';\n this.lineNumber = obj.lineNumber;\n this.columnNumber = obj.columnNumber;\n }\n\n toString() {\n const lineNumber = this.lineNumber || '';\n const columnNumber = this.columnNumber || '';\n if (this.functionName) {\n return (\n this.functionName +\n ' (' +\n this.fileName +\n ':' +\n lineNumber +\n ':' +\n columnNumber +\n ')'\n );\n }\n return this.fileName + ':' + lineNumber + ':' + columnNumber;\n }\n}\n\n/**\n * ErrorStackParser is a fork of https://github.com/stacktracejs/error-stack-parser/blob/master/error-stack-parser.js\n * I fork it because:\n * 1. There are some build issues when importing this package.\n * 2. Rewrites into typescript give us a better type interface.\n */\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/;\nconst CHROME_IE_STACK_REGEXP = /^\\s*at .*(\\S+:\\d+|\\(native\\))/m;\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code])?$/;\nexport const ErrorStackParser = {\n /**\n * Given an Error object, extract the most information from it.\n *\n * @param {Error} error object\n * @return {Array} of StackFrames\n */\n parse: function (error: Error): StackFrame[] {\n // https://github.com/rrweb-io/rrweb/issues/782\n if (!error) {\n return [];\n }\n if (\n // @ts-ignore\n typeof error.stacktrace !== 'undefined' ||\n // @ts-ignore\n typeof error['opera#sourceloc'] !== 'undefined'\n ) {\n return this.parseOpera(\n error as {\n stacktrace?: string;\n message: string;\n stack?: string;\n },\n );\n } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {\n return this.parseV8OrIE(error as { stack: string });\n } else if (error.stack) {\n return this.parseFFOrSafari(error as { stack: string });\n } else {\n throw new Error('Cannot parse given Error object');\n }\n },\n // Separate line and column numbers from a string of the form: (URI:Line:Column)\n extractLocation: function (urlLike: string) {\n // Fail-fast but return locations like \"(native)\"\n if (urlLike.indexOf(':') === -1) {\n return [urlLike];\n }\n\n const regExp = /(.+?)(?::(\\d+))?(?::(\\d+))?$/;\n const parts = regExp.exec(urlLike.replace(/[()]/g, ''));\n if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);\n return [parts[1], parts[2] || undefined, parts[3] || undefined];\n },\n parseV8OrIE: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return !!line.match(CHROME_IE_STACK_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n if (line.indexOf('(eval ') > -1) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n line = line\n .replace(/eval code/g, 'eval')\n .replace(/(\\(eval at [^()]*)|(\\),.*$)/g, '');\n }\n let sanitizedLine = line.replace(/^\\s+/, '').replace(/\\(eval code/g, '(');\n\n // capture and preseve the parenthesized location \"(/foo/my bar.js:12:87)\" in\n // case it has spaces in it, as the string is split on \\s+ later on\n const location = sanitizedLine.match(/ (\\((.+):(\\d+):(\\d+)\\)$)/);\n\n // remove the parenthesized location from the line, if it was matched\n sanitizedLine = location\n ? sanitizedLine.replace(location[0], '')\n : sanitizedLine;\n\n const tokens = sanitizedLine.split(/\\s+/).slice(1);\n // if a location was matched, pass it to extractLocation() otherwise pop the last token\n const locationParts = this.extractLocation(\n location ? location[1] : tokens.pop(),\n );\n const functionName = tokens.join(' ') || undefined;\n const fileName =\n ['eval', ''].indexOf(locationParts[0]) > -1\n ? undefined\n : locationParts[0];\n\n return new StackFrame({\n functionName,\n fileName,\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }, this);\n },\n parseFFOrSafari: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return !line.match(SAFARI_NATIVE_CODE_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n if (line.indexOf(' > eval') > -1) {\n line = line.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n ':$1',\n );\n }\n\n if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {\n // Safari eval frames only have function names and nothing else\n return new StackFrame({\n functionName: line,\n });\n } else {\n const functionNameRegex = /((.*\".+\"[^@]*)?[^@]*)(?:@)/;\n const matches = line.match(functionNameRegex);\n const functionName = matches && matches[1] ? matches[1] : undefined;\n const locationParts = this.extractLocation(\n line.replace(functionNameRegex, ''),\n );\n\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }\n }, this);\n },\n parseOpera: function (e: {\n stacktrace?: string;\n message: string;\n stack?: string;\n }): StackFrame[] {\n if (\n !e.stacktrace ||\n (e.message.indexOf('\\n') > -1 &&\n e.message.split('\\n').length > e.stacktrace.split('\\n').length)\n ) {\n return this.parseOpera9(e as { message: string });\n } else if (!e.stack) {\n return this.parseOpera10(e as { stacktrace: string });\n } else {\n return this.parseOpera11(e as { stack: string });\n }\n },\n parseOpera9: function (e: { message: string }) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)/i;\n const lines = e.message.split('\\n');\n const result = [];\n\n for (let i = 2, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n fileName: match[2],\n lineNumber: parseFloat(match[1]),\n }),\n );\n }\n }\n\n return result;\n },\n parseOpera10: function (e: { stacktrace: string }) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)(?:: In function (\\S+))?$/i;\n const lines = e.stacktrace.split('\\n');\n const result = [];\n\n for (let i = 0, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n functionName: match[3] || undefined,\n fileName: match[2],\n lineNumber: parseFloat(match[1]),\n }),\n );\n }\n }\n\n return result;\n },\n // Opera 10.65+ Error.stack very similar to FF/Safari\n parseOpera11: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return (\n !!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&\n !line.match(/^Error created at/)\n );\n }, this);\n\n return filtered.map(function (line: string) {\n const tokens = line.split('@');\n const locationParts = this.extractLocation(tokens.pop());\n const functionCall = tokens.shift() || '';\n const functionName =\n functionCall\n .replace(//, '$2')\n .replace(/\\([^)]*\\)/g, '') || undefined;\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }, this);\n },\n};\n","// tslint:disable:no-any no-bitwise forin\n/**\n * this file is used to serialize log message to string\n *\n */\n\nimport { StringifyOptions } from './index';\n\n/**\n * transfer the node path in Event to string\n * @param node the first node in a node path array\n */\nfunction pathToSelector(node: HTMLElement): string | '' {\n if (!node || !node.outerHTML) {\n return '';\n }\n\n let path = '';\n while (node.parentElement) {\n let name = node.localName;\n if (!name) {\n break;\n }\n name = name.toLowerCase();\n let parent = node.parentElement;\n\n let domSiblings = [];\n\n if (parent.children && parent.children.length > 0) {\n // tslint:disable-next-line:prefer-for-of\n for (let i = 0; i < parent.children.length; i++) {\n let sibling = parent.children[i];\n if (sibling.localName && sibling.localName.toLowerCase) {\n if (sibling.localName.toLowerCase() === name) {\n domSiblings.push(sibling);\n }\n }\n }\n }\n\n if (domSiblings.length > 1) {\n name += ':eq(' + domSiblings.indexOf(node) + ')';\n }\n path = name + (path ? '>' + path : '');\n node = parent;\n }\n\n return path;\n}\n\n/**\n * judge is object\n */\nfunction isObject(obj: any): boolean {\n return Object.prototype.toString.call(obj) === '[object Object]';\n}\n\n/**\n * judge the object's depth\n */\nfunction isObjTooDeep(obj: any, limit: number): boolean {\n if (limit === 0) {\n return true;\n }\n\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * stringify any js object\n * @param obj the object to stringify\n */\nexport function stringify(\n obj: any,\n stringifyOptions?: StringifyOptions,\n): string {\n const options: StringifyOptions = {\n numOfKeysLimit: 50,\n depthOfLimit: 4,\n };\n Object.assign(options, stringifyOptions);\n const stack: any[] = [];\n const keys: any[] = [];\n return JSON.stringify(obj, function (key, value) {\n /**\n * forked from https://github.com/moll/json-stringify-safe/blob/master/stringify.js\n * to deCycle the object\n */\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);\n if (~stack.indexOf(value)) {\n if (stack[0] === value) {\n value = '[Circular ~]';\n } else {\n value =\n '[Circular ~.' +\n keys.slice(0, stack.indexOf(value)).join('.') +\n ']';\n }\n }\n } else {\n stack.push(value);\n }\n /* END of the FORK */\n\n if (value === null || value === undefined) {\n return value;\n }\n if (shouldIgnore(value)) {\n return toString(value);\n }\n if (value instanceof Event) {\n const eventResult: any = {};\n for (const eventKey in value) {\n const eventValue = (value as any)[eventKey];\n if (Array.isArray(eventValue)) {\n eventResult[eventKey] = pathToSelector(\n eventValue.length ? eventValue[0] : null,\n );\n } else {\n eventResult[eventKey] = eventValue;\n }\n }\n return eventResult;\n } else if (value instanceof Node) {\n if (value instanceof HTMLElement) {\n return value ? value.outerHTML : '';\n }\n return value.nodeName;\n } else if (value instanceof Error) {\n return value.stack\n ? value.stack + '\\nEnd of stack for Error object'\n : value.name + ': ' + value.message;\n }\n return value;\n });\n\n /**\n * whether we should ignore obj's info and call toString() function instead\n */\n function shouldIgnore(_obj: object): boolean {\n // outof keys limit\n if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {\n return true;\n }\n\n // is function\n if (typeof _obj === 'function') {\n return true;\n }\n\n /**\n * judge object's depth to avoid browser's OOM\n *\n * issues: https://github.com/rrweb-io/rrweb/issues/653\n */\n if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * limit the toString() result according to option\n */\n function toString(_obj: object): string {\n let str = _obj.toString();\n if (options.stringLengthLimit && str.length > options.stringLengthLimit) {\n str = `${str.slice(0, options.stringLengthLimit)}...`;\n }\n return str;\n }\n}\n","import { listenerHandler, RecordPlugin, IWindow } from '../../../types';\nimport { patch } from '../../../utils';\nimport { ErrorStackParser, StackFrame } from './error-stack-parser';\nimport { stringify } from './stringify';\n\nexport type StringifyOptions = {\n // limit of string length\n stringLengthLimit?: number;\n /**\n * limit of number of keys in an object\n * if an object contains more keys than this limit, we would call its toString function directly\n */\n numOfKeysLimit: number;\n /**\n * limit number of depth in an object\n * if an object is too deep, toString process may cause browser OOM\n */\n depthOfLimit: number;\n};\n\ntype LogRecordOptions = {\n level?: LogLevel[];\n lengthThreshold?: number;\n stringifyOptions?: StringifyOptions;\n logger?: Logger | 'console';\n};\n\nconst defaultLogOptions: LogRecordOptions = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n lengthThreshold: 1000,\n logger: 'console',\n};\n\nexport type LogData = {\n level: LogLevel;\n trace: string[];\n payload: string[];\n};\n\ntype logCallback = (p: LogData) => void;\n\nexport type LogLevel =\n | 'assert'\n | 'clear'\n | 'count'\n | 'countReset'\n | 'debug'\n | 'dir'\n | 'dirxml'\n | 'error'\n | 'group'\n | 'groupCollapsed'\n | 'groupEnd'\n | 'info'\n | 'log'\n | 'table'\n | 'time'\n | 'timeEnd'\n | 'timeLog'\n | 'trace'\n | 'warn';\n\n/* fork from interface Console */\n// all kinds of console functions\nexport type Logger = {\n assert?: typeof console.assert;\n clear?: typeof console.clear;\n count?: typeof console.count;\n countReset?: typeof console.countReset;\n debug?: typeof console.debug;\n dir?: typeof console.dir;\n dirxml?: typeof console.dirxml;\n error?: typeof console.error;\n group?: typeof console.group;\n groupCollapsed?: typeof console.groupCollapsed;\n groupEnd?: () => void;\n info?: typeof console.info;\n log?: typeof console.log;\n table?: typeof console.table;\n time?: typeof console.time;\n timeEnd?: typeof console.timeEnd;\n timeLog?: typeof console.timeLog;\n trace?: typeof console.trace;\n warn?: typeof console.warn;\n};\n\nfunction initLogObserver(\n cb: logCallback,\n win: IWindow, // top window or in an iframe\n logOptions: LogRecordOptions,\n): listenerHandler {\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {};\n }\n let logger: Logger;\n if (typeof loggerType === 'string') {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n const cancelHandlers: listenerHandler[] = [];\n // add listener to thrown errors\n if (logOptions.level!.includes('error')) {\n if (window) {\n const errorHandler = (event: ErrorEvent) => {\n const { message, error } = event;\n const trace: string[] = ErrorStackParser.parse(\n error,\n ).map((stackFrame: StackFrame) => stackFrame.toString());\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: 'error',\n trace,\n payload,\n });\n };\n window.addEventListener('error', errorHandler);\n cancelHandlers.push(() => {\n if (window) window.removeEventListener('error', errorHandler);\n });\n }\n }\n for (const levelType of logOptions.level!) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n\n /**\n * replace the original console function and record logs\n * @param logger the logger object such as Console\n * @param level the name of log function to be replaced\n */\n function replace(_logger: Logger, level: LogLevel) {\n if (!_logger[level]) {\n return () => {};\n }\n // replace the logger.{level}. return a restore function\n return patch(_logger, level, (original) => {\n return (...args: Array) => {\n original.apply(this, args);\n try {\n const trace = ErrorStackParser.parse(new Error())\n .map((stackFrame: StackFrame) => stackFrame.toString())\n .splice(1); // splice(1) to omit the hijacked log function\n const payload = args.map((s) =>\n stringify(s, logOptions.stringifyOptions),\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold!) {\n cb({\n level,\n trace,\n payload,\n });\n } else if (logCount === logOptions.lengthThreshold) {\n // notify the user\n cb({\n level: 'warn',\n trace: [],\n payload: [\n stringify('The number of log records reached the threshold.'),\n ],\n });\n }\n } catch (error) {\n original('rrweb logger error:', error, ...args);\n }\n };\n });\n }\n}\n\nexport const PLUGIN_NAME = 'rrweb/console@1';\n\nexport const getRecordConsolePlugin: (\n options?: LogRecordOptions,\n) => RecordPlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options: options\n ? Object.assign({}, defaultLogOptions, options)\n : defaultLogOptions,\n});\n"],"names":["__values","o","s","Symbol","iterator","m","i","call","length","next","value","done","TypeError","__read","n","r","e","ar","push","error","__spreadArray","to","from","pack","arguments","l","Array","prototype","slice","concat","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","NodeType","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","map","getId","console","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","get","target","prop","receiver","obj","this","fileName","functionName","lineNumber","columnNumber","StackFrame","FIREFOX_SAFARI_STACK_REGEXP","CHROME_IE_STACK_REGEXP","SAFARI_NATIVE_CODE_REGEXP","ErrorStackParser","parse","stacktrace","parseOpera","stack","match","parseV8OrIE","parseFFOrSafari","Error","extractLocation","urlLike","indexOf","parts","exec","replace","undefined","split","filter","line","sanitizedLine","location","tokens","locationParts","pop","join","functionNameRegex","matches","message","parseOpera9","parseOpera11","parseOpera10","lineRE","lines","result","len","parseFloat","shift","pathToSelector","node","outerHTML","path","parentElement","name_1","localName","toLowerCase","parent_1","domSiblings","children","sibling","isObject","Object","toString","isObjTooDeep","limit","keys","keys_1","key","stringify","stringifyOptions","options","numOfKeysLimit","depthOfLimit","assign","JSON","thisPos","splice","Infinity","_obj","shouldIgnore","str","stringLengthLimit","Event","eventResult","eventKey","eventValue","isArray","Node","HTMLElement","nodeName","name","defaultLogOptions","level","lengthThreshold","logger","initLogObserver","cb","win","logOptions","loggerType","logCount","cancelHandlers","includes","errorHandler_1","event","trace","stackFrame","payload","addEventListener","removeEventListener","_b","levelType","forEach","h","_logger","source","replacement","original_1","wrapped","defineProperties","__rrweb_original__","enumerable","patch","original","_i","args","apply","_this","PLUGIN_NAME","observer"],"mappings":";;;;;;;;;;;;;;oFAuHO,SAASA,EAASC,GACrB,IAAIC,EAAsB,mBAAXC,QAAyBA,O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C,GACxB,OAAAsH,EAAUtH,EAAGoJ,EAAW7B,uBAE1B+B,EACeF,EAAWL,gBACxBG,EAAG,CACDJ,QACAa,QACAE,YAEOP,IAAaF,EAAWL,iBAEjCG,EAAG,CACDJ,MAAO,OACPa,MAAO,GACPE,QAAS,CACPvC,EAAU,uDAIhB,MAAOrG,GACP4J,kBAAS,sBAAuB5J,KAAU8J,aA/BvC,kBAsCAG,EAAc,kEAIP,SAAC1D,GAAY,OAC/BoB,KAAMsC,EACNC,SAAUlC,EACVzB,QAASA,EACLT,OAAOY,OAAO,GAAIkB,EAAmBrB,GACrCqB"} +\ No newline at end of file ++{"version":3,"file":"console-record.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../src/types.ts","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../src/utils.ts","../../../src/plugins/console/record/error-stack-parser.ts","../../../src/plugins/console/record/stringify.ts","../../../src/plugins/console/record/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n unblockSelector?: string;\n ignoreClass?: string;\n ignoreSelector?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputSelector?: string;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n unmaskTextSelector?: string;\n unmaskInputSelector?: string;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n unblockSelector: string | null;\n ignoreClass: string;\n ignoreSelector: string | null;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'unblockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'unmaskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputSelector'\n | 'unmaskInputSelector'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type] ||\n (maskInputSelector && input.matches(maskInputSelector))) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) {\n return false;\n }\n }\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n input: n,\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","// tslint:disable\n/**\n * Class StackFrame is a fork of https://github.com/stacktracejs/stackframe/blob/master/stackframe.js\n * I fork it because:\n * 1. There are some build issues when importing this package.\n * 2. Rewrites into typescript give us a better type interface.\n * 3. StackFrame contains some functions we don't need.\n */\nexport class StackFrame {\n private fileName: string;\n private functionName: string;\n private lineNumber?: number;\n private columnNumber?: number;\n\n constructor(obj: {\n fileName?: string;\n functionName?: string;\n lineNumber?: number;\n columnNumber?: number;\n }) {\n this.fileName = obj.fileName || '';\n this.functionName = obj.functionName || '';\n this.lineNumber = obj.lineNumber;\n this.columnNumber = obj.columnNumber;\n }\n\n toString() {\n const lineNumber = this.lineNumber || '';\n const columnNumber = this.columnNumber || '';\n if (this.functionName) {\n return (\n this.functionName +\n ' (' +\n this.fileName +\n ':' +\n lineNumber +\n ':' +\n columnNumber +\n ')'\n );\n }\n return this.fileName + ':' + lineNumber + ':' + columnNumber;\n }\n}\n\n/**\n * ErrorStackParser is a fork of https://github.com/stacktracejs/error-stack-parser/blob/master/error-stack-parser.js\n * I fork it because:\n * 1. There are some build issues when importing this package.\n * 2. Rewrites into typescript give us a better type interface.\n */\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/;\nconst CHROME_IE_STACK_REGEXP = /^\\s*at .*(\\S+:\\d+|\\(native\\))/m;\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code])?$/;\nexport const ErrorStackParser = {\n /**\n * Given an Error object, extract the most information from it.\n *\n * @param {Error} error object\n * @return {Array} of StackFrames\n */\n parse: function (error: Error): StackFrame[] {\n // https://github.com/rrweb-io/rrweb/issues/782\n if (!error) {\n return [];\n }\n if (\n // @ts-ignore\n typeof error.stacktrace !== 'undefined' ||\n // @ts-ignore\n typeof error['opera#sourceloc'] !== 'undefined'\n ) {\n return this.parseOpera(\n error as {\n stacktrace?: string;\n message: string;\n stack?: string;\n },\n );\n } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {\n return this.parseV8OrIE(error as { stack: string });\n } else if (error.stack) {\n return this.parseFFOrSafari(error as { stack: string });\n } else {\n throw new Error('Cannot parse given Error object');\n }\n },\n // Separate line and column numbers from a string of the form: (URI:Line:Column)\n extractLocation: function (urlLike: string) {\n // Fail-fast but return locations like \"(native)\"\n if (urlLike.indexOf(':') === -1) {\n return [urlLike];\n }\n\n const regExp = /(.+?)(?::(\\d+))?(?::(\\d+))?$/;\n const parts = regExp.exec(urlLike.replace(/[()]/g, ''));\n if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);\n return [parts[1], parts[2] || undefined, parts[3] || undefined];\n },\n parseV8OrIE: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return !!line.match(CHROME_IE_STACK_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n if (line.indexOf('(eval ') > -1) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n line = line\n .replace(/eval code/g, 'eval')\n .replace(/(\\(eval at [^()]*)|(\\),.*$)/g, '');\n }\n let sanitizedLine = line.replace(/^\\s+/, '').replace(/\\(eval code/g, '(');\n\n // capture and preseve the parenthesized location \"(/foo/my bar.js:12:87)\" in\n // case it has spaces in it, as the string is split on \\s+ later on\n const location = sanitizedLine.match(/ (\\((.+):(\\d+):(\\d+)\\)$)/);\n\n // remove the parenthesized location from the line, if it was matched\n sanitizedLine = location\n ? sanitizedLine.replace(location[0], '')\n : sanitizedLine;\n\n const tokens = sanitizedLine.split(/\\s+/).slice(1);\n // if a location was matched, pass it to extractLocation() otherwise pop the last token\n const locationParts = this.extractLocation(\n location ? location[1] : tokens.pop(),\n );\n const functionName = tokens.join(' ') || undefined;\n const fileName =\n ['eval', ''].indexOf(locationParts[0]) > -1\n ? undefined\n : locationParts[0];\n\n return new StackFrame({\n functionName,\n fileName,\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }, this);\n },\n parseFFOrSafari: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return !line.match(SAFARI_NATIVE_CODE_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n if (line.indexOf(' > eval') > -1) {\n line = line.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n ':$1',\n );\n }\n\n if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {\n // Safari eval frames only have function names and nothing else\n return new StackFrame({\n functionName: line,\n });\n } else {\n const functionNameRegex = /((.*\".+\"[^@]*)?[^@]*)(?:@)/;\n const matches = line.match(functionNameRegex);\n const functionName = matches && matches[1] ? matches[1] : undefined;\n const locationParts = this.extractLocation(\n line.replace(functionNameRegex, ''),\n );\n\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }\n }, this);\n },\n parseOpera: function (e: {\n stacktrace?: string;\n message: string;\n stack?: string;\n }): StackFrame[] {\n if (\n !e.stacktrace ||\n (e.message.indexOf('\\n') > -1 &&\n e.message.split('\\n').length > e.stacktrace.split('\\n').length)\n ) {\n return this.parseOpera9(e as { message: string });\n } else if (!e.stack) {\n return this.parseOpera10(e as { stacktrace: string });\n } else {\n return this.parseOpera11(e as { stack: string });\n }\n },\n parseOpera9: function (e: { message: string }) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)/i;\n const lines = e.message.split('\\n');\n const result = [];\n\n for (let i = 2, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n fileName: match[2],\n lineNumber: parseFloat(match[1]),\n }),\n );\n }\n }\n\n return result;\n },\n parseOpera10: function (e: { stacktrace: string }) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)(?:: In function (\\S+))?$/i;\n const lines = e.stacktrace.split('\\n');\n const result = [];\n\n for (let i = 0, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n functionName: match[3] || undefined,\n fileName: match[2],\n lineNumber: parseFloat(match[1]),\n }),\n );\n }\n }\n\n return result;\n },\n // Opera 10.65+ Error.stack very similar to FF/Safari\n parseOpera11: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return (\n !!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&\n !line.match(/^Error created at/)\n );\n }, this);\n\n return filtered.map(function (line: string) {\n const tokens = line.split('@');\n const locationParts = this.extractLocation(tokens.pop());\n const functionCall = tokens.shift() || '';\n const functionName =\n functionCall\n .replace(//, '$2')\n .replace(/\\([^)]*\\)/g, '') || undefined;\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }, this);\n },\n};\n","// tslint:disable:no-any no-bitwise forin\n/**\n * this file is used to serialize log message to string\n *\n */\n\nimport { StringifyOptions } from './index';\n\n/**\n * transfer the node path in Event to string\n * @param node the first node in a node path array\n */\nfunction pathToSelector(node: HTMLElement): string | '' {\n if (!node || !node.outerHTML) {\n return '';\n }\n\n let path = '';\n while (node.parentElement) {\n let name = node.localName;\n if (!name) {\n break;\n }\n name = name.toLowerCase();\n let parent = node.parentElement;\n\n let domSiblings = [];\n\n if (parent.children && parent.children.length > 0) {\n // tslint:disable-next-line:prefer-for-of\n for (let i = 0; i < parent.children.length; i++) {\n let sibling = parent.children[i];\n if (sibling.localName && sibling.localName.toLowerCase) {\n if (sibling.localName.toLowerCase() === name) {\n domSiblings.push(sibling);\n }\n }\n }\n }\n\n if (domSiblings.length > 1) {\n name += ':eq(' + domSiblings.indexOf(node) + ')';\n }\n path = name + (path ? '>' + path : '');\n node = parent;\n }\n\n return path;\n}\n\n/**\n * judge is object\n */\nfunction isObject(obj: any): boolean {\n return Object.prototype.toString.call(obj) === '[object Object]';\n}\n\n/**\n * judge the object's depth\n */\nfunction isObjTooDeep(obj: any, limit: number): boolean {\n if (limit === 0) {\n return true;\n }\n\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * stringify any js object\n * @param obj the object to stringify\n */\nexport function stringify(\n obj: any,\n stringifyOptions?: StringifyOptions,\n): string {\n const options: StringifyOptions = {\n numOfKeysLimit: 50,\n depthOfLimit: 4,\n };\n Object.assign(options, stringifyOptions);\n const stack: any[] = [];\n const keys: any[] = [];\n return JSON.stringify(obj, function (key, value) {\n /**\n * forked from https://github.com/moll/json-stringify-safe/blob/master/stringify.js\n * to deCycle the object\n */\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);\n if (~stack.indexOf(value)) {\n if (stack[0] === value) {\n value = '[Circular ~]';\n } else {\n value =\n '[Circular ~.' +\n keys.slice(0, stack.indexOf(value)).join('.') +\n ']';\n }\n }\n } else {\n stack.push(value);\n }\n /* END of the FORK */\n\n if (value === null || value === undefined) {\n return value;\n }\n if (shouldIgnore(value)) {\n return toString(value);\n }\n if (value instanceof Event) {\n const eventResult: any = {};\n for (const eventKey in value) {\n const eventValue = (value as any)[eventKey];\n if (Array.isArray(eventValue)) {\n eventResult[eventKey] = pathToSelector(\n eventValue.length ? eventValue[0] : null,\n );\n } else {\n eventResult[eventKey] = eventValue;\n }\n }\n return eventResult;\n } else if (value instanceof Node) {\n if (value instanceof HTMLElement) {\n return value ? value.outerHTML : '';\n }\n return value.nodeName;\n } else if (value instanceof Error) {\n return value.stack\n ? value.stack + '\\nEnd of stack for Error object'\n : value.name + ': ' + value.message;\n }\n return value;\n });\n\n /**\n * whether we should ignore obj's info and call toString() function instead\n */\n function shouldIgnore(_obj: object): boolean {\n // outof keys limit\n if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {\n return true;\n }\n\n // is function\n if (typeof _obj === 'function') {\n return true;\n }\n\n /**\n * judge object's depth to avoid browser's OOM\n *\n * issues: https://github.com/rrweb-io/rrweb/issues/653\n */\n if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * limit the toString() result according to option\n */\n function toString(_obj: object): string {\n let str = _obj.toString();\n if (options.stringLengthLimit && str.length > options.stringLengthLimit) {\n str = `${str.slice(0, options.stringLengthLimit)}...`;\n }\n return str;\n }\n}\n","import { listenerHandler, RecordPlugin, IWindow } from '../../../types';\nimport { patch } from '../../../utils';\nimport { ErrorStackParser, StackFrame } from './error-stack-parser';\nimport { stringify } from './stringify';\n\nexport type StringifyOptions = {\n // limit of string length\n stringLengthLimit?: number;\n /**\n * limit of number of keys in an object\n * if an object contains more keys than this limit, we would call its toString function directly\n */\n numOfKeysLimit: number;\n /**\n * limit number of depth in an object\n * if an object is too deep, toString process may cause browser OOM\n */\n depthOfLimit: number;\n};\n\ntype LogRecordOptions = {\n level?: LogLevel[];\n lengthThreshold?: number;\n stringifyOptions?: StringifyOptions;\n logger?: Logger | 'console';\n};\n\nconst defaultLogOptions: LogRecordOptions = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n lengthThreshold: 1000,\n logger: 'console',\n};\n\nexport type LogData = {\n level: LogLevel;\n trace: string[];\n payload: string[];\n};\n\ntype logCallback = (p: LogData) => void;\n\nexport type LogLevel =\n | 'assert'\n | 'clear'\n | 'count'\n | 'countReset'\n | 'debug'\n | 'dir'\n | 'dirxml'\n | 'error'\n | 'group'\n | 'groupCollapsed'\n | 'groupEnd'\n | 'info'\n | 'log'\n | 'table'\n | 'time'\n | 'timeEnd'\n | 'timeLog'\n | 'trace'\n | 'warn';\n\n/* fork from interface Console */\n// all kinds of console functions\nexport type Logger = {\n assert?: typeof console.assert;\n clear?: typeof console.clear;\n count?: typeof console.count;\n countReset?: typeof console.countReset;\n debug?: typeof console.debug;\n dir?: typeof console.dir;\n dirxml?: typeof console.dirxml;\n error?: typeof console.error;\n group?: typeof console.group;\n groupCollapsed?: typeof console.groupCollapsed;\n groupEnd?: () => void;\n info?: typeof console.info;\n log?: typeof console.log;\n table?: typeof console.table;\n time?: typeof console.time;\n timeEnd?: typeof console.timeEnd;\n timeLog?: typeof console.timeLog;\n trace?: typeof console.trace;\n warn?: typeof console.warn;\n};\n\nfunction initLogObserver(\n cb: logCallback,\n win: IWindow, // top window or in an iframe\n logOptions: LogRecordOptions,\n): listenerHandler {\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {};\n }\n let logger: Logger;\n if (typeof loggerType === 'string') {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n const cancelHandlers: listenerHandler[] = [];\n // add listener to thrown errors\n if (logOptions.level!.includes('error')) {\n if (window) {\n const errorHandler = (event: ErrorEvent) => {\n const { message, error } = event;\n const trace: string[] = ErrorStackParser.parse(\n error,\n ).map((stackFrame: StackFrame) => stackFrame.toString());\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: 'error',\n trace,\n payload,\n });\n };\n window.addEventListener('error', errorHandler);\n cancelHandlers.push(() => {\n if (window) window.removeEventListener('error', errorHandler);\n });\n }\n }\n for (const levelType of logOptions.level!) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n\n /**\n * replace the original console function and record logs\n * @param logger the logger object such as Console\n * @param level the name of log function to be replaced\n */\n function replace(_logger: Logger, level: LogLevel) {\n if (!_logger[level]) {\n return () => {};\n }\n // replace the logger.{level}. return a restore function\n return patch(_logger, level, (original) => {\n return (...args: Array) => {\n original.apply(this, args);\n try {\n const trace = ErrorStackParser.parse(new Error())\n .map((stackFrame: StackFrame) => stackFrame.toString())\n .splice(1); // splice(1) to omit the hijacked log function\n const payload = args.map((s) =>\n stringify(s, logOptions.stringifyOptions),\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold!) {\n cb({\n level,\n trace,\n payload,\n });\n } else if (logCount === logOptions.lengthThreshold) {\n // notify the user\n cb({\n level: 'warn',\n trace: [],\n payload: [\n stringify('The number of log records reached the threshold.'),\n ],\n });\n }\n } catch (error) {\n original('rrweb logger error:', error, ...args);\n }\n };\n });\n }\n}\n\nexport const PLUGIN_NAME = 'rrweb/console@1';\n\nexport const getRecordConsolePlugin: (\n options?: LogRecordOptions,\n) => RecordPlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options: options\n ? Object.assign({}, defaultLogOptions, options)\n : defaultLogOptions,\n});\n"],"names":["__values","o","s","Symbol","iterator","m","i","call","length","next","value","done","TypeError","__read","n","r","e","ar","push","error","__spreadArray","to","from","pack","arguments","l","Array","prototype","slice","concat","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","NodeType","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","map","getId","console","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","get","target","prop","receiver","obj","this","fileName","functionName","lineNumber","columnNumber","StackFrame","FIREFOX_SAFARI_STACK_REGEXP","CHROME_IE_STACK_REGEXP","SAFARI_NATIVE_CODE_REGEXP","ErrorStackParser","parse","stacktrace","parseOpera","stack","match","parseV8OrIE","parseFFOrSafari","Error","extractLocation","urlLike","indexOf","parts","exec","replace","undefined","split","filter","line","sanitizedLine","location","tokens","locationParts","pop","join","functionNameRegex","matches","message","parseOpera9","parseOpera11","parseOpera10","lineRE","lines","result","len","parseFloat","shift","pathToSelector","node","outerHTML","path","parentElement","name_1","localName","toLowerCase","parent_1","domSiblings","children","sibling","isObject","Object","toString","isObjTooDeep","limit","keys","keys_1","key","stringify","stringifyOptions","options","numOfKeysLimit","depthOfLimit","assign","JSON","thisPos","splice","Infinity","_obj","shouldIgnore","str","stringLengthLimit","Event","eventResult","eventKey","eventValue","isArray","Node","HTMLElement","nodeName","name","defaultLogOptions","level","lengthThreshold","logger","initLogObserver","cb","win","logOptions","loggerType","logCount","cancelHandlers","includes","errorHandler_1","event","trace","stackFrame","payload","addEventListener","removeEventListener","_b","levelType","forEach","h","_logger","source","replacement","original_1","wrapped","defineProperties","__rrweb_original__","enumerable","patch","original","_i","args","apply","_this","PLUGIN_NAME","observer"],"mappings":";;;;;;;;;;;;;;oFAuHO,SAASA,EAASC,GACrB,IAAIC,EAAsB,mBAAXC,QAAyBA,OAAOC,SAAUC,E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H,EAAUtH,EAAGoJ,EAAW7B,uBAE1B+B,EACeF,EAAWL,gBACxBG,EAAG,CACDJ,QACAa,QACAE,YAEOP,IAAaF,EAAWL,iBAEjCG,EAAG,CACDJ,MAAO,OACPa,MAAO,GACPE,QAAS,CACPvC,EAAU,uDAIhB,MAAOrG,GACP4J,kBAAS,sBAAuB5J,KAAU8J,aA/BvC,kBAsCAG,EAAc,kEAIP,SAAC1D,GAAY,OAC/BoB,KAAMsC,EACNC,SAAUlC,EACVzB,QAASA,EACLT,OAAOY,OAAO,GAAIkB,EAAmBrB,GACrCqB"} +\ No newline at end of file +diff --git a/node_modules/rrweb/dist/plugins/console-replay.js b/node_modules/rrweb/dist/plugins/console-replay.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/plugins/console-replay.min.js b/node_modules/rrweb/dist/plugins/console-replay.min.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/plugins/console-replay.min.js.map b/node_modules/rrweb/dist/plugins/console-replay.min.js.map +old mode 100644 +new mode 100755 +index 9fb2e60..1181439 +--- a/node_modules/rrweb/dist/plugins/console-replay.min.js.map ++++ b/node_modules/rrweb/dist/plugins/console-replay.min.js.map +@@ -1 +1 @@ +-{"version":3,"file":"console-replay.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../src/types.ts","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../src/utils.ts","../../../src/plugins/console/record/index.ts","../../../src/plugins/console/replay/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n ignoreClass?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n ignoreClass: string;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type]) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector) {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","import { listenerHandler, RecordPlugin, IWindow } from '../../../types';\nimport { patch } from '../../../utils';\nimport { ErrorStackParser, StackFrame } from './error-stack-parser';\nimport { stringify } from './stringify';\n\nexport type StringifyOptions = {\n // limit of string length\n stringLengthLimit?: number;\n /**\n * limit of number of keys in an object\n * if an object contains more keys than this limit, we would call its toString function directly\n */\n numOfKeysLimit: number;\n /**\n * limit number of depth in an object\n * if an object is too deep, toString process may cause browser OOM\n */\n depthOfLimit: number;\n};\n\ntype LogRecordOptions = {\n level?: LogLevel[];\n lengthThreshold?: number;\n stringifyOptions?: StringifyOptions;\n logger?: Logger | 'console';\n};\n\nconst defaultLogOptions: LogRecordOptions = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n lengthThreshold: 1000,\n logger: 'console',\n};\n\nexport type LogData = {\n level: LogLevel;\n trace: string[];\n payload: string[];\n};\n\ntype logCallback = (p: LogData) => void;\n\nexport type LogLevel =\n | 'assert'\n | 'clear'\n | 'count'\n | 'countReset'\n | 'debug'\n | 'dir'\n | 'dirxml'\n | 'error'\n | 'group'\n | 'groupCollapsed'\n | 'groupEnd'\n | 'info'\n | 'log'\n | 'table'\n | 'time'\n | 'timeEnd'\n | 'timeLog'\n | 'trace'\n | 'warn';\n\n/* fork from interface Console */\n// all kinds of console functions\nexport type Logger = {\n assert?: typeof console.assert;\n clear?: typeof console.clear;\n count?: typeof console.count;\n countReset?: typeof console.countReset;\n debug?: typeof console.debug;\n dir?: typeof console.dir;\n dirxml?: typeof console.dirxml;\n error?: typeof console.error;\n group?: typeof console.group;\n groupCollapsed?: typeof console.groupCollapsed;\n groupEnd?: () => void;\n info?: typeof console.info;\n log?: typeof console.log;\n table?: typeof console.table;\n time?: typeof console.time;\n timeEnd?: typeof console.timeEnd;\n timeLog?: typeof console.timeLog;\n trace?: typeof console.trace;\n warn?: typeof console.warn;\n};\n\nfunction initLogObserver(\n cb: logCallback,\n win: IWindow, // top window or in an iframe\n logOptions: LogRecordOptions,\n): listenerHandler {\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {};\n }\n let logger: Logger;\n if (typeof loggerType === 'string') {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n const cancelHandlers: listenerHandler[] = [];\n // add listener to thrown errors\n if (logOptions.level!.includes('error')) {\n if (window) {\n const errorHandler = (event: ErrorEvent) => {\n const { message, error } = event;\n const trace: string[] = ErrorStackParser.parse(\n error,\n ).map((stackFrame: StackFrame) => stackFrame.toString());\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: 'error',\n trace,\n payload,\n });\n };\n window.addEventListener('error', errorHandler);\n cancelHandlers.push(() => {\n if (window) window.removeEventListener('error', errorHandler);\n });\n }\n }\n for (const levelType of logOptions.level!) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n\n /**\n * replace the original console function and record logs\n * @param logger the logger object such as Console\n * @param level the name of log function to be replaced\n */\n function replace(_logger: Logger, level: LogLevel) {\n if (!_logger[level]) {\n return () => {};\n }\n // replace the logger.{level}. return a restore function\n return patch(_logger, level, (original) => {\n return (...args: Array) => {\n original.apply(this, args);\n try {\n const trace = ErrorStackParser.parse(new Error())\n .map((stackFrame: StackFrame) => stackFrame.toString())\n .splice(1); // splice(1) to omit the hijacked log function\n const payload = args.map((s) =>\n stringify(s, logOptions.stringifyOptions),\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold!) {\n cb({\n level,\n trace,\n payload,\n });\n } else if (logCount === logOptions.lengthThreshold) {\n // notify the user\n cb({\n level: 'warn',\n trace: [],\n payload: [\n stringify('The number of log records reached the threshold.'),\n ],\n });\n }\n } catch (error) {\n original('rrweb logger error:', error, ...args);\n }\n };\n });\n }\n}\n\nexport const PLUGIN_NAME = 'rrweb/console@1';\n\nexport const getRecordConsolePlugin: (\n options?: LogRecordOptions,\n) => RecordPlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options: options\n ? Object.assign({}, defaultLogOptions, options)\n : defaultLogOptions,\n});\n","import { LogLevel, LogData, PLUGIN_NAME } from '../record';\nimport {\n eventWithTime,\n EventType,\n IncrementalSource,\n ReplayPlugin,\n} from '../../../types';\n\n/**\n * define an interface to replay log records\n * (data: logData) => void> function to display the log data\n */\ntype ReplayLogger = Partial void>>;\n\ntype LogReplayConfig = {\n level?: LogLevel[];\n replayLogger?: ReplayLogger;\n};\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedConsoleLog = {\n [ORIGINAL_ATTRIBUTE_NAME]: typeof console.log;\n};\n\nconst defaultLogConfig: LogReplayConfig = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n replayLogger: undefined,\n};\n\nclass LogReplayPlugin {\n private config: LogReplayConfig;\n\n constructor(config?: LogReplayConfig) {\n this.config = Object.assign(defaultLogConfig, config);\n }\n\n /**\n * generate a console log replayer which implement the interface ReplayLogger\n */\n public getConsoleLogger(): ReplayLogger {\n const replayLogger: ReplayLogger = {};\n for (const level of this.config.level!) {\n if (level === 'trace') {\n replayLogger[level] = (data: LogData) => {\n const logger = ((console.log as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? ((console.log as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console.log;\n logger(\n ...data.payload.map((s) => JSON.parse(s)),\n this.formatMessage(data),\n );\n };\n } else {\n replayLogger[level] = (data: LogData) => {\n const logger = ((console[level] as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? ((console[level] as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console[level];\n logger(\n ...data.payload.map((s) => JSON.parse(s)),\n this.formatMessage(data),\n );\n };\n }\n }\n return replayLogger;\n }\n\n /**\n * format the trace data to a string\n * @param data the log data\n */\n private formatMessage(data: LogData): string {\n if (data.trace.length === 0) {\n return '';\n }\n const stackPrefix = '\\n\\tat ';\n let result = stackPrefix;\n result += data.trace.join(stackPrefix);\n return result;\n }\n}\n\nexport const getReplayConsolePlugin: (\n options?: LogReplayConfig,\n) => ReplayPlugin = (options) => {\n const replayLogger =\n options?.replayLogger || new LogReplayPlugin(options).getConsoleLogger();\n\n return {\n handler(event: eventWithTime, _isSync, context) {\n let logData: LogData | null = null;\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === (IncrementalSource.Log as IncrementalSource)\n ) {\n logData = (event.data as unknown) as LogData;\n } else if (\n event.type === EventType.Plugin &&\n event.data.plugin === PLUGIN_NAME\n ) {\n logData = event.data.payload as LogData;\n }\n if (logData) {\n try {\n if (typeof replayLogger[logData.level] === 'function') {\n replayLogger[logData.level]!(logData);\n }\n } catch (error) {\n if (context.replayer.config.showWarning) {\n console.warn(error);\n }\n }\n }\n },\n };\n};\n"],"names":["__read","o","n","m","Symbol","iterator","r","e","i","call","ar","next","done","push","value","error","__spreadArray","to","from","pack","arguments","length","l","Array","prototype","slice","concat","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","NodeType","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","map","getId","console","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","get","target","prop","receiver","defaultLogConfig","level","replayLogger","undefined","config","this","Object","assign","LogReplayPlugin","data","log","payload","s","JSON","parse","_this","formatMessage","_b","TypeError","__values","trace","stackPrefix","result","join","options","getConsoleLogger","handler","event","_isSync","context","logData","type","IncrementalSnapshot","source","Log","Plugin","plugin","replayer","showWarning","warn"],"mappings":";;;;;;;;;;;;;;oFAmIO,SAASA,EAAOC,EAAGC,GACtB,IAAIC,EAAsB,mBAAXC,QAA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AOkC,aAC1BlD,QAAQmD,KAAK1E"} +\ No newline at end of file ++{"version":3,"file":"console-replay.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../src/types.ts","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../src/utils.ts","../../../src/plugins/console/record/index.ts","../../../src/plugins/console/replay/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n unblockSelector?: string;\n ignoreClass?: string;\n ignoreSelector?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputSelector?: string;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n unmaskTextSelector?: string;\n unmaskInputSelector?: string;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n unblockSelector: string | null;\n ignoreClass: string;\n ignoreSelector: string | null;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'unblockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'unmaskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputSelector'\n | 'unmaskInputSelector'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type] ||\n (maskInputSelector && input.matches(maskInputSelector))) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) {\n return false;\n }\n }\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n input: n,\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","import { listenerHandler, RecordPlugin, IWindow } from '../../../types';\nimport { patch } from '../../../utils';\nimport { ErrorStackParser, StackFrame } from './error-stack-parser';\nimport { stringify } from './stringify';\n\nexport type StringifyOptions = {\n // limit of string length\n stringLengthLimit?: number;\n /**\n * limit of number of keys in an object\n * if an object contains more keys than this limit, we would call its toString function directly\n */\n numOfKeysLimit: number;\n /**\n * limit number of depth in an object\n * if an object is too deep, toString process may cause browser OOM\n */\n depthOfLimit: number;\n};\n\ntype LogRecordOptions = {\n level?: LogLevel[];\n lengthThreshold?: number;\n stringifyOptions?: StringifyOptions;\n logger?: Logger | 'console';\n};\n\nconst defaultLogOptions: LogRecordOptions = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n lengthThreshold: 1000,\n logger: 'console',\n};\n\nexport type LogData = {\n level: LogLevel;\n trace: string[];\n payload: string[];\n};\n\ntype logCallback = (p: LogData) => void;\n\nexport type LogLevel =\n | 'assert'\n | 'clear'\n | 'count'\n | 'countReset'\n | 'debug'\n | 'dir'\n | 'dirxml'\n | 'error'\n | 'group'\n | 'groupCollapsed'\n | 'groupEnd'\n | 'info'\n | 'log'\n | 'table'\n | 'time'\n | 'timeEnd'\n | 'timeLog'\n | 'trace'\n | 'warn';\n\n/* fork from interface Console */\n// all kinds of console functions\nexport type Logger = {\n assert?: typeof console.assert;\n clear?: typeof console.clear;\n count?: typeof console.count;\n countReset?: typeof console.countReset;\n debug?: typeof console.debug;\n dir?: typeof console.dir;\n dirxml?: typeof console.dirxml;\n error?: typeof console.error;\n group?: typeof console.group;\n groupCollapsed?: typeof console.groupCollapsed;\n groupEnd?: () => void;\n info?: typeof console.info;\n log?: typeof console.log;\n table?: typeof console.table;\n time?: typeof console.time;\n timeEnd?: typeof console.timeEnd;\n timeLog?: typeof console.timeLog;\n trace?: typeof console.trace;\n warn?: typeof console.warn;\n};\n\nfunction initLogObserver(\n cb: logCallback,\n win: IWindow, // top window or in an iframe\n logOptions: LogRecordOptions,\n): listenerHandler {\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {};\n }\n let logger: Logger;\n if (typeof loggerType === 'string') {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n const cancelHandlers: listenerHandler[] = [];\n // add listener to thrown errors\n if (logOptions.level!.includes('error')) {\n if (window) {\n const errorHandler = (event: ErrorEvent) => {\n const { message, error } = event;\n const trace: string[] = ErrorStackParser.parse(\n error,\n ).map((stackFrame: StackFrame) => stackFrame.toString());\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: 'error',\n trace,\n payload,\n });\n };\n window.addEventListener('error', errorHandler);\n cancelHandlers.push(() => {\n if (window) window.removeEventListener('error', errorHandler);\n });\n }\n }\n for (const levelType of logOptions.level!) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n\n /**\n * replace the original console function and record logs\n * @param logger the logger object such as Console\n * @param level the name of log function to be replaced\n */\n function replace(_logger: Logger, level: LogLevel) {\n if (!_logger[level]) {\n return () => {};\n }\n // replace the logger.{level}. return a restore function\n return patch(_logger, level, (original) => {\n return (...args: Array) => {\n original.apply(this, args);\n try {\n const trace = ErrorStackParser.parse(new Error())\n .map((stackFrame: StackFrame) => stackFrame.toString())\n .splice(1); // splice(1) to omit the hijacked log function\n const payload = args.map((s) =>\n stringify(s, logOptions.stringifyOptions),\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold!) {\n cb({\n level,\n trace,\n payload,\n });\n } else if (logCount === logOptions.lengthThreshold) {\n // notify the user\n cb({\n level: 'warn',\n trace: [],\n payload: [\n stringify('The number of log records reached the threshold.'),\n ],\n });\n }\n } catch (error) {\n original('rrweb logger error:', error, ...args);\n }\n };\n });\n }\n}\n\nexport const PLUGIN_NAME = 'rrweb/console@1';\n\nexport const getRecordConsolePlugin: (\n options?: LogRecordOptions,\n) => RecordPlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options: options\n ? Object.assign({}, defaultLogOptions, options)\n : defaultLogOptions,\n});\n","import { LogLevel, LogData, PLUGIN_NAME } from '../record';\nimport {\n eventWithTime,\n EventType,\n IncrementalSource,\n ReplayPlugin,\n} from '../../../types';\n\n/**\n * define an interface to replay log records\n * (data: logData) => void> function to display the log data\n */\ntype ReplayLogger = Partial void>>;\n\ntype LogReplayConfig = {\n level?: LogLevel[];\n replayLogger?: ReplayLogger;\n};\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedConsoleLog = {\n [ORIGINAL_ATTRIBUTE_NAME]: typeof console.log;\n};\n\nconst defaultLogConfig: LogReplayConfig = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n replayLogger: undefined,\n};\n\nclass LogReplayPlugin {\n private config: LogReplayConfig;\n\n constructor(config?: LogReplayConfig) {\n this.config = Object.assign(defaultLogConfig, config);\n }\n\n /**\n * generate a console log replayer which implement the interface ReplayLogger\n */\n public getConsoleLogger(): ReplayLogger {\n const replayLogger: ReplayLogger = {};\n for (const level of this.config.level!) {\n if (level === 'trace') {\n replayLogger[level] = (data: LogData) => {\n const logger = ((console.log as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? ((console.log as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console.log;\n logger(\n ...data.payload.map((s) => JSON.parse(s)),\n this.formatMessage(data),\n );\n };\n } else {\n replayLogger[level] = (data: LogData) => {\n const logger = ((console[level] as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? ((console[level] as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console[level];\n logger(\n ...data.payload.map((s) => JSON.parse(s)),\n this.formatMessage(data),\n );\n };\n }\n }\n return replayLogger;\n }\n\n /**\n * format the trace data to a string\n * @param data the log data\n */\n private formatMessage(data: LogData): string {\n if (data.trace.length === 0) {\n return '';\n }\n const stackPrefix = '\\n\\tat ';\n let result = stackPrefix;\n result += data.trace.join(stackPrefix);\n return result;\n }\n}\n\nexport const getReplayConsolePlugin: (\n options?: LogReplayConfig,\n) => ReplayPlugin = (options) => {\n const replayLogger =\n options?.replayLogger || new LogReplayPlugin(options).getConsoleLogger();\n\n return {\n handler(event: eventWithTime, _isSync, context) {\n let logData: LogData | null = null;\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === (IncrementalSource.Log as IncrementalSource)\n ) {\n logData = (event.data as unknown) as LogData;\n } else if (\n event.type === EventType.Plugin &&\n event.data.plugin === PLUGIN_NAME\n ) {\n logData = event.data.payload as LogData;\n }\n if (logData) {\n try {\n if (typeof replayLogger[logData.level] === 'function') {\n replayLogger[logData.level]!(logData);\n }\n } catch (error) {\n if (context.replayer.config.showWarning) {\n console.warn(error);\n }\n }\n }\n },\n };\n};\n"],"names":["__read","o","n","m","Symbol","iterator","r","e","i","call","ar","next","done","push","value","error","__spreadArray","to","from","pack","arguments","length","l","Array","prototype","slice","concat","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","NodeType","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","map","getId","console","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","get","target","prop","receiver","defaultLogConfig","level","replayLogger","undefined","config","this","Object","assign","LogReplayPlugin","data","log","payload","s","JSON","parse","_this","formatMessage","_b","TypeError","__values","trace","stackPrefix","result","join","options","getConsoleLogger","handler","event","_isSync","context","logData","type","IncrementalSnapshot","source","Log","Plugin","plugin","replayer","showWarning","warn"],"mappings":";;;;;;;;;;;;;;oFAmIO,SAASA,EAAOC,EAAGC,GACtB,IAAIC,EAAsB,mBAAXC,QAAyBH,EAAEG,OAAOC,UACjD,IAAKF,EAAG,OAAOF,EACf,IAAmBK,EAAYC,EAA3BC,EAAIL,EAAEM,KAAKR,GAAOS,EAAK,GAC3B,IACI,WAAc,IAANR,GAAgBA,KAAM,MAAQI,EAAIE,EAAEG,QAAQC,MAAMF,EAAGG,KAAKP,EAAEQ,OAExE,MAAOC,GAASR,EAAI,CAAEQ,MAAOA,WAEzB,IACQT,IAAMA,EAAEM,OAAST,EAAIK,EAAU,SAAIL,EAAEM,KAAKD,WAExC,GAAID,EAAG,MAAMA,EAAEQ,OAE7B,OAAOL,EAmBJ,SAASM,EAAcC,EAAIC,EAAMC,GACpC,GAAIA,GAA6B,IAArBC,UAAUC,OAAc,IAAK,IAA4BX,EAAxBF,EAAI,EAAGc,EAAIJ,EAAKG,OAAYb,EAAIc,EAAGd,KACxEE,GAAQF,KAAKU,IACRR,IAAIA,EAAKa,MAAMC,UAAUC,MAAMhB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,OAAOH,mJA+BhC,OAAOC,GAODM,0BAAR,SAAsBC,GACpB,GAA0B,IAAtBA,EAAKW,MAAMjD,OACb,MAAO,GAET,IAAMkD,EAAc,UAChBC,EAASD,EAEb,OADAC,GAAUb,EAAKW,MAAMG,KAAKF,yCAOV,SAACG,GACnB,IAAMtB,GACJsB,MAAAA,SAAAA,EAAStB,eAAgB,IAAIM,EAAgBgB,GAASC,mBAExD,MAAO,CACLC,QAAA,SAAQC,EAAsBC,EAASC,GACrC,IAAIC,EAA0B,KAY9B,GAVEH,EAAMI,OAAStD,EAAUuD,qBACzBL,EAAMlB,KAAKwB,SAAYvD,EAAkBwD,IAEzCJ,EAAWH,EAAMlB,KAEjBkB,EAAMI,OAAStD,EAAU0D,QDuEN,oBCtEnBR,EAAMlB,KAAK2B,SAEXN,EAAUH,EAAMlB,KAAKE,SAEnBmB,EACF,IAC6C,mBAAhC5B,EAAa4B,EAAQ7B,QAC9BC,EAAa4B,EAAQ7B,OAAQ6B,GAE/B,MAAOjE,GACHgE,EAAQQ,SAASjC,OAAOkC,aAC1BlD,QAAQmD,KAAK1E"} +\ No newline at end of file +diff --git a/node_modules/rrweb/dist/plugins/sequential-id-record.js b/node_modules/rrweb/dist/plugins/sequential-id-record.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/plugins/sequential-id-record.min.js b/node_modules/rrweb/dist/plugins/sequential-id-record.min.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/plugins/sequential-id-record.min.js.map b/node_modules/rrweb/dist/plugins/sequential-id-record.min.js.map +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/plugins/sequential-id-replay.js b/node_modules/rrweb/dist/plugins/sequential-id-replay.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/plugins/sequential-id-replay.min.js b/node_modules/rrweb/dist/plugins/sequential-id-replay.min.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/plugins/sequential-id-replay.min.js.map b/node_modules/rrweb/dist/plugins/sequential-id-replay.min.js.map +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/record/rrweb-record-pack.js b/node_modules/rrweb/dist/record/rrweb-record-pack.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/record/rrweb-record-pack.min.js b/node_modules/rrweb/dist/record/rrweb-record-pack.min.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/record/rrweb-record-pack.min.js.map b/node_modules/rrweb/dist/record/rrweb-record-pack.min.js.map +old mode 100644 +new mode 100755 +index 1c25f6f..80f1482 +--- a/node_modules/rrweb/dist/record/rrweb-record-pack.min.js.map ++++ b/node_modules/rrweb/dist/record/rrweb-record-pack.min.js.map +@@ -1 +1 @@ +-{"version":3,"file":"rrweb-record-pack.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../src/types.ts","../../../src/utils.ts","../../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../../../node_modules/fflate/esm/browser.js","../../../src/packer/pack.ts","../../../src/packer/base.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type]) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector) {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n ignoreClass?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n ignoreClass: string;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Much of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// Many optimizations have been made, so the bundle size is ultimately smaller but performance is similar.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var u = ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([c], { type: 'text/javascript' })));\n var w = new Worker(u);\n w.onerror = function (e) { return cb(e.error, null); };\n w.onmessage = function (e) { return cb(null, e.data); };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;\n// fixed length extra bits\nvar fleb = new u8([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, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\n// see fleb note\nvar fdeb = new u8([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, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new u32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return [b, r];\n};\nvar _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b[0], revfd = _b[1];\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >>> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >>> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >>> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >>> 8) | ((x & 0x00FF) << 8)) >>> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i)\n ++l[cd[i] - 1];\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 0; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >>> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i)\n co[i] = rev[le[cd[i] - 1]++] >>> (15 - cd[i]);\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8)) >>> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >>> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p / 8) >> 0) + (p & 7 && 1); };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n var n = new (v instanceof u16 ? u16 : v instanceof u32 ? u32 : u8)(e - s);\n n.set(v.subarray(s, e));\n return n;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, buf, st) {\n // source length\n var sl = dat.length;\n // have to estimate size\n var noBuf = !buf || st;\n // no state\n var noSt = !st || st.i;\n if (!st)\n st = {};\n // Assumes roughly 33% compression ratio average\n if (!buf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n st.f = final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n throw 'unexpected EOF';\n break;\n }\n // ensure size\n if (noBuf)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n if (!noSt && pos + tl * (clb + 7) > tbts)\n break;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >>> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n throw 'invalid block type';\n if (pos > tbts)\n throw 'unexpected EOF';\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17;\n if (noBuf)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var mxa = lbt + dbt + 18;\n while (noSt || pos + mxa < tbts) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;\n pos += c & 15;\n if (pos > tbts)\n throw 'unexpected EOF';\n if (!c)\n throw 'invalid length/literal';\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;\n if (!d)\n throw 'invalid distance';\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & ((1 << b) - 1), pos += b;\n }\n if (pos > tbts)\n throw 'unexpected EOF';\n if (noBuf)\n cbuf(bt + 131072);\n var end = bt + add;\n for (; bt < end; bt += 4) {\n buf[bt] = buf[bt - dt];\n buf[bt + 1] = buf[bt + 1 - dt];\n buf[bt + 2] = buf[bt + 2 - dt];\n buf[bt + 3] = buf[bt + 3 - dt];\n }\n bt = end;\n }\n }\n st.l = lm, st.p = pos, st.b = bt;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n return bt == buf.length ? buf : slc(buf, 0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n d[o + 2] |= v >>> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return [new u8(0), 0];\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return [v, 1];\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return [new u8(tr), mbt];\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return [cl.subarray(0, cli), s];\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >>> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a[0], mlb = _a[1];\n var _b = hTree(df, 15), ddt = _b[0], mdb = _b[1];\n var _c = lc(dlt), lclt = _c[0], nlc = _c[1];\n var _d = lc(ddt), lcdt = _d[0], ndc = _d[1];\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n lcfreq[lclt[i] & 31]++;\n for (var i = 0; i < lcdt.length; ++i)\n lcfreq[lcdt[i] & 31]++;\n var _e = hTree(lcfreq, 7), lct = _e[0], mlcb = _e[1];\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);\n if (flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >>> 5) & 127), p += clct[i] >>> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n if (syms[i] > 255) {\n var len = (syms[i] >>> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (syms[i] >>> 23) & 31), p += fleb[len];\n var dst = syms[i] & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (syms[i] >>> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new u32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, lst) {\n var s = dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.floor(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var pos = 0;\n if (!lvl || s < 8) {\n for (var i = 0; i <= s; i += 65535) {\n // end\n var e = i + 65535;\n if (e < s) {\n // write full block\n pos = wfblk(w, pos, dat.subarray(i, e));\n }\n else {\n // write final block\n w[i] = lst;\n pos = wfblk(w, pos, dat.subarray(i, s));\n }\n }\n }\n else {\n var opt = deo[lvl - 1];\n var n = opt >>> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = new u16(32768), head = new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new u32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx bitpos\n var lc_1 = 0, eb = 0, i = 0, li = 0, wi = 0, bs = 0;\n for (; i < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768\n var imod = i & 32767;\n // previous index with this value\n var pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && rem > 423) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = (imod - pimod) & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = (i - dif + j + 32768) & 32767;\n var pti = prev[ti];\n var cd = (ti - pti + 32768) & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += (imod - pimod + 32768) & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one Uint32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n // this is the easiest way to avoid needing to maintain state\n if (!lst)\n pos = wfblk(w, pos, et);\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new u32(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && 0xEDB88320) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = 0xFFFFFFFF;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return c ^ 0xFFFFFFFF; }\n };\n};\n// Alder32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 5552, l);\n for (; i < e; ++i)\n n += d[i], m += n;\n n %= 65521, m %= 65521;\n }\n a = n, b = m;\n },\n d: function () { return ((a >>> 8) << 16 | (b & 255) << 8 | (b >>> 8)) + ((a & 255) << 23) * 2; }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post, !st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/ /g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return [fnStr, td];\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k] instanceof u8 || v[k] instanceof u16 || v[k] instanceof u32)\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n var _a;\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n _a = wcln(fns[i], fnStr, td_1), fnStr = _a[0], td_1 = _a[1];\n ch[id] = wcln(fns[m], fnStr, td_1);\n }\n var td = mrg({}, ch[id][1]);\n return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, hMap, max, bits, bits16, shft, slc, inflt, inflateSync, pbf, gu8]; };\nvar bDflt = function () { return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zlv]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get u8\nvar gu8 = function (o) { return o && o.size && new u8(o.size); };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n if (!opts.consume)\n dat = new u8(dat);\n w.postMessage([dat, opts], [dat.buffer]);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) { return strm.push(ev.data[0], ev.data[1]); };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.push = function (d, f) {\n if (t)\n throw 'stream finished';\n if (!strm.ondata)\n throw 'no stream handler';\n w.postMessage([d, t = f], [d.buffer]);\n };\n strm.terminate = function () { w.terminate(); };\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16)) + (d[b + 3] << 23) * 2; };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n throw 'invalid gzip data';\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += d[10] | (d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16) + (2 * (d[l - 1] << 23));\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + ((o.filename && (o.filename.length + 1)) || 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (fl ? (32 - 2 * fl) : 1);\n};\n// zlib valid\nvar zlv = function (d) {\n if ((d[0] & 15) != 8 || (d[0] >>> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n throw 'invalid zlib data';\n if (d[1] & 32)\n throw 'invalid zlib data: preset dictionaries not supported';\n};\nfunction AsyncCmpStrm(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n// zlib footer: -4 to -0 is Adler32\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, !f), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n this.d = final;\n this.p(chunk, final || false);\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n return dopt(data, opts, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n /**\n * Creates an inflation stream\n * @param cb The callback to call whenever data is inflated\n */\n function Inflate(cb) {\n this.s = {};\n this.p = new u8(0);\n this.ondata = cb;\n }\n Inflate.prototype.e = function (c) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n var l = this.p.length;\n var n = new u8(l + c.length);\n n.set(this.p), n.set(c, l), this.p = n;\n };\n Inflate.prototype.c = function (final) {\n this.d = this.s.i = final || false;\n var bts = this.s.b;\n var dt = inflt(this.p, this.o, this.s);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) >> 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous inflation stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncInflate(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, 0, function () {\n var strm = new Inflate();\n onmessage = astrm(strm);\n }, 7);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gu8(ev.data[1]))); }, 1, cb);\n}\n/**\n * Expands DEFLATE data with no wrapper\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function inflateSync(data, out) {\n return inflt(data, out);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n this.c.p(c);\n this.l += c.length;\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, !f);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n /**\n * Creates a GUNZIP stream\n * @param cb The callback to call whenever data is inflated\n */\n function Gunzip(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n var s = gzs(this.p);\n if (s >= this.p.length && !final)\n return;\n this.p = this.p.subarray(s), this.v = 0;\n }\n if (final) {\n if (this.p.length < 8)\n throw 'invalid gzip stream';\n this.p = this.p.subarray(0, -8);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous GUNZIP stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncGunzip(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, 0, function () {\n var strm = new Gunzip();\n onmessage = astrm(strm);\n }, 9);\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0])); }, 3, cb);\n}\n/**\n * Expands GZIP data\n * @param data The data to decompress\n * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.\n * @returns The decompressed version of the data\n */\nexport function gunzipSync(data, out) {\n return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n this.c.p(c);\n var raw = dopt(c, this.o, this.v && 2, f && 4, !f);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n /**\n * Creates a Zlib decompression stream\n * @param cb The callback to call whenever data is inflated\n */\n function Unzlib(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 2 && !final)\n return;\n this.p = this.p.subarray(2), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n throw 'invalid zlib stream';\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous Zlib decompression stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncUnzlib(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, 0, function () {\n var strm = new Unzlib();\n onmessage = astrm(strm);\n }, 11);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gu8(ev.data[1]))); }, 5, cb);\n}\n/**\n * Expands Zlib data\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function unzlibSync(data, out) {\n return inflt((zlv(data), data.subarray(2, -4)), out);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n /**\n * Creates a decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function Decompress(cb) {\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n throw 'no stream handler';\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n var _this_1 = this;\n var cb = function () { _this_1.ondata.apply(_this_1, arguments); };\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(cb)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(cb)\n : new this.Z(cb);\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function AsyncDecompress(cb) {\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, out) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, out)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, out)\n : unzlibSync(data, out);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k;\n if (val instanceof u8)\n t[n] = [val, o];\n else if (Array.isArray(val))\n t[n] = [val[0], mrg(o, val[1])];\n else\n fltn(val, n + '/', t, o);\n }\n};\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n var l = str.length;\n if (!latin1 && typeof TextEncoder != 'undefined')\n return new TextEncoder().encode(str);\n var ar = new u8(str.length + (str.length >>> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >>> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >>> 18)), w(128 | ((c >>> 12) & 63)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >>> 12)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n var r = '';\n if (!latin1 && typeof TextDecoder != 'undefined')\n return new TextDecoder().decode(dat);\n for (var i = 0; i < dat.length;) {\n var c = dat[i++];\n if (c < 128 || latin1)\n r += String.fromCharCode(c);\n else if (c < 224)\n r += String.fromCharCode((c & 31) << 6 | (dat[i++] & 63));\n else if (c < 240)\n r += String.fromCharCode((c & 15) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63));\n else\n c = ((c & 15) << 18 | (dat[i++] & 63) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n return r;\n}\n;\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;\n var _a = z ? z64e(d, es) : [b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];\n};\n// read zip64 extra field\nvar z64e = function (d, b) {\n for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))\n ;\n return [b4(d, b + 12), b4(d, b + 4), b4(d, b + 20)];\n};\n// write zip header\nvar wzh = function (d, b, c, cmp, su, fn, u, o, ce, t) {\n var fl = fn.length, l = cmp.length;\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b] = 20, b += 2;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (t == 8 && (o.level == 1 ? 6 : o.level < 6 ? 4 : o.level == 9 ? 2 : 0)), d[b++] = u && 8;\n d[b] = t, b += 2;\n var dt = new Date(o.mtime || Date.now()), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n throw 'date not in range 1980-2099';\n wbytes(d, b, ((y << 24) * 2) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >>> 1));\n b += 4;\n wbytes(d, b, c);\n wbytes(d, b + 4, l);\n wbytes(d, b + 8, su);\n wbytes(d, b + 12, fl), b += 16; // skip extra field, comment\n if (ce != null)\n wbytes(d, b += 10, ce), b += 4;\n d.set(fn, b);\n b += fl;\n if (ce == null)\n d.set(cmp, b);\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n wzh(out, tot, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, tot, f.t), o += 46 + f.n.length, tot += 30 + f.n.length + f.d.length;\n }\n catch (e) {\n return cb(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cb(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), m = file.length;\n c.p(file);\n var n = strToU8(fn), s = n.length;\n var t = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n var l = d.length;\n files[i] = {\n t: t,\n d: d,\n m: m,\n c: c.d(),\n u: fn.length != l,\n n: n,\n p: p\n };\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n if (!--lft)\n cbf();\n }\n };\n if (n.length > 65535)\n cbl('filename too long', null);\n if (!t)\n cbl(null, file);\n else if (m < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var t = p.level == 0 ? 0 : 8;\n var n = strToU8(fn), s = n.length;\n if (n.length > 65535)\n throw 'filename too long';\n var d = t ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push({\n t: t,\n d: d,\n m: file.length,\n c: c.d(),\n u: fn.length != s,\n n: n,\n o: o,\n p: p\n });\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, f.o, f.t), o += 46 + f.n.length;\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Asynchronously decompresses a ZIP archive\n * @param data The raw compressed ZIP file\n * @param cb The callback to call with the decompressed files\n * @returns A function that can be used to immediately terminate the unzipping\n */\nexport function unzip(data, cb) {\n if (typeof cb != 'function')\n throw 'no callback';\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cb('invalid zip file', null);\n return;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (!lft)\n cb(null, {});\n var c = lft;\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = lft = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n var _loop_2 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n files[fn] = d;\n if (!--lft)\n cb(null, files);\n }\n };\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n if (sc < 320000) {\n try {\n cbl(null, inflateSync(infl, new u8(su)));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl('unknown compression type ' + c_1, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_2(i);\n }\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @returns The decompressed files\n */\nexport function unzipSync(data) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n throw 'invalid zip file';\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));\n else\n throw 'unknown compression type ' + c_2;\n }\n return files;\n}\n","import { strFromU8, strToU8, zlibSync } from 'fflate';\nimport { PackFn, MARK, eventWithTimeAndPacker } from './base';\n\nexport const pack: PackFn = (event) => {\n const _e: eventWithTimeAndPacker = {\n ...event,\n v: MARK,\n };\n return strFromU8(zlibSync(strToU8(JSON.stringify(_e))), true);\n};\n","import { eventWithTime } from '../types';\n\nexport type PackFn = (event: eventWithTime) => string;\nexport type UnpackFn = (raw: string) => eventWithTime;\n\nexport type eventWithTimeAndPacker = eventWithTime & {\n v: string;\n};\n\nexport const MARK = 'v1';\n"],"names":["NodeType","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","map","getId","console","error","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","get","target","prop","receiver","chars","lookup","Uint8Array","charCodeAt","u8","u16","Uint16Array","u32","Uint32Array","fleb","fdeb","clim","freb","eb","start","b","r","j","_a","fl","revfl","revfd","rev","x","hMap","cd","mb","l","co","le","rvb","sv","r_1","v","m","flt","fdt","flm","fdm","shft","slc","e","set","subarray","wbits","d","o","wbits16","hTree","push","f","t2","slice","sort","a","i0","i1","i2","maxSym","tr","mbt","ln","dt","lft","cst","i2_1","i2_2","i2_3","Math","max","lc","c","cl","cli","cln","cls","w","clen","cf","wfblk","out","pos","dat","wblk","final","syms","lf","df","li","bs","bl","dlt","mlb","_b","ddt","mdb","_c","lclt","nlc","_d","lcdt","ndc","lcfreq","_e","lct","mlcb","nlcc","lm","ll","dm","dl","flen","ftlen","dtlen","llm","lcts","it","clct","len","dst","deo","et","dopt","opt","pre","post","st","lvl","plvl","lst","floor","msk_1","prev","head","bs1_1","ceil","bs2_1","hsh","lc_1","wi","hv","imod","pimod","rem","ch_1","dif","maxn","min","maxd","ml","nl","mmd","md","ti","lin","din","dflt","level","mem","log","zlibSync","data","opts","adler","lv","zlh","wbytes","event","latin1","TextDecoder","decode","String","fromCharCode","strFromU8","str","TextEncoder","encode","ar","ai","strToU8","JSON","stringify"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ECeQC,EA+DAC,EAgUAC,EAcAC,EAuIMC,EA2GNC,EF/mBDC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAe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IAAMK,EAAE,IAAW,GAAJL,IAEjE,OAAO/B,EAAIyI,EAAI,EAAGC,GCx8CMC,CAAQC,KAAKC,UAAU9E,MAAO"} +\ No newline at end of file ++{"version":3,"file":"rrweb-record-pack.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../src/types.ts","../../../src/utils.ts","../../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../../../node_modules/fflate/esm/browser.js","../../../src/packer/pack.ts","../../../src/packer/base.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type] ||\n (maskInputSelector && input.matches(maskInputSelector))) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) {\n return false;\n }\n }\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n input: n,\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n unblockSelector?: string;\n ignoreClass?: string;\n ignoreSelector?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputSelector?: string;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n unmaskTextSelector?: string;\n unmaskInputSelector?: string;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n unblockSelector: string | null;\n ignoreClass: string;\n ignoreSelector: string | null;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'unblockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'unmaskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputSelector'\n | 'unmaskInputSelector'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Much of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// Many optimizations have been made, so the bundle size is ultimately smaller but performance is similar.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var u = ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([c], { type: 'text/javascript' })));\n var w = new Worker(u);\n w.onerror = function (e) { return cb(e.error, null); };\n w.onmessage = function (e) { return cb(null, e.data); };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;\n// fixed length extra bits\nvar fleb = new u8([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, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\n// see fleb note\nvar fdeb = new u8([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, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new u32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return [b, r];\n};\nvar _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b[0], revfd = _b[1];\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >>> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >>> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >>> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >>> 8) | ((x & 0x00FF) << 8)) >>> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i)\n ++l[cd[i] - 1];\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 0; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >>> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i)\n co[i] = rev[le[cd[i] - 1]++] >>> (15 - cd[i]);\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8)) >>> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >>> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p / 8) >> 0) + (p & 7 && 1); };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n var n = new (v instanceof u16 ? u16 : v instanceof u32 ? u32 : u8)(e - s);\n n.set(v.subarray(s, e));\n return n;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, buf, st) {\n // source length\n var sl = dat.length;\n // have to estimate size\n var noBuf = !buf || st;\n // no state\n var noSt = !st || st.i;\n if (!st)\n st = {};\n // Assumes roughly 33% compression ratio average\n if (!buf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n st.f = final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n throw 'unexpected EOF';\n break;\n }\n // ensure size\n if (noBuf)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n if (!noSt && pos + tl * (clb + 7) > tbts)\n break;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >>> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n throw 'invalid block type';\n if (pos > tbts)\n throw 'unexpected EOF';\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17;\n if (noBuf)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var mxa = lbt + dbt + 18;\n while (noSt || pos + mxa < tbts) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;\n pos += c & 15;\n if (pos > tbts)\n throw 'unexpected EOF';\n if (!c)\n throw 'invalid length/literal';\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;\n if (!d)\n throw 'invalid distance';\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & ((1 << b) - 1), pos += b;\n }\n if (pos > tbts)\n throw 'unexpected EOF';\n if (noBuf)\n cbuf(bt + 131072);\n var end = bt + add;\n for (; bt < end; bt += 4) {\n buf[bt] = buf[bt - dt];\n buf[bt + 1] = buf[bt + 1 - dt];\n buf[bt + 2] = buf[bt + 2 - dt];\n buf[bt + 3] = buf[bt + 3 - dt];\n }\n bt = end;\n }\n }\n st.l = lm, st.p = pos, st.b = bt;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n return bt == buf.length ? buf : slc(buf, 0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n d[o + 2] |= v >>> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return [new u8(0), 0];\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return [v, 1];\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return [new u8(tr), mbt];\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return [cl.subarray(0, cli), s];\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >>> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a[0], mlb = _a[1];\n var _b = hTree(df, 15), ddt = _b[0], mdb = _b[1];\n var _c = lc(dlt), lclt = _c[0], nlc = _c[1];\n var _d = lc(ddt), lcdt = _d[0], ndc = _d[1];\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n lcfreq[lclt[i] & 31]++;\n for (var i = 0; i < lcdt.length; ++i)\n lcfreq[lcdt[i] & 31]++;\n var _e = hTree(lcfreq, 7), lct = _e[0], mlcb = _e[1];\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);\n if (flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >>> 5) & 127), p += clct[i] >>> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n if (syms[i] > 255) {\n var len = (syms[i] >>> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (syms[i] >>> 23) & 31), p += fleb[len];\n var dst = syms[i] & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (syms[i] >>> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new u32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, lst) {\n var s = dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.floor(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var pos = 0;\n if (!lvl || s < 8) {\n for (var i = 0; i <= s; i += 65535) {\n // end\n var e = i + 65535;\n if (e < s) {\n // write full block\n pos = wfblk(w, pos, dat.subarray(i, e));\n }\n else {\n // write final block\n w[i] = lst;\n pos = wfblk(w, pos, dat.subarray(i, s));\n }\n }\n }\n else {\n var opt = deo[lvl - 1];\n var n = opt >>> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = new u16(32768), head = new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new u32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx bitpos\n var lc_1 = 0, eb = 0, i = 0, li = 0, wi = 0, bs = 0;\n for (; i < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768\n var imod = i & 32767;\n // previous index with this value\n var pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && rem > 423) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = (imod - pimod) & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = (i - dif + j + 32768) & 32767;\n var pti = prev[ti];\n var cd = (ti - pti + 32768) & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += (imod - pimod + 32768) & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one Uint32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n // this is the easiest way to avoid needing to maintain state\n if (!lst)\n pos = wfblk(w, pos, et);\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new u32(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && 0xEDB88320) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = 0xFFFFFFFF;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return c ^ 0xFFFFFFFF; }\n };\n};\n// Alder32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 5552, l);\n for (; i < e; ++i)\n n += d[i], m += n;\n n %= 65521, m %= 65521;\n }\n a = n, b = m;\n },\n d: function () { return ((a >>> 8) << 16 | (b & 255) << 8 | (b >>> 8)) + ((a & 255) << 23) * 2; }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post, !st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/ /g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return [fnStr, td];\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k] instanceof u8 || v[k] instanceof u16 || v[k] instanceof u32)\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n var _a;\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n _a = wcln(fns[i], fnStr, td_1), fnStr = _a[0], td_1 = _a[1];\n ch[id] = wcln(fns[m], fnStr, td_1);\n }\n var td = mrg({}, ch[id][1]);\n return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, hMap, max, bits, bits16, shft, slc, inflt, inflateSync, pbf, gu8]; };\nvar bDflt = function () { return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zlv]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get u8\nvar gu8 = function (o) { return o && o.size && new u8(o.size); };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n if (!opts.consume)\n dat = new u8(dat);\n w.postMessage([dat, opts], [dat.buffer]);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) { return strm.push(ev.data[0], ev.data[1]); };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.push = function (d, f) {\n if (t)\n throw 'stream finished';\n if (!strm.ondata)\n throw 'no stream handler';\n w.postMessage([d, t = f], [d.buffer]);\n };\n strm.terminate = function () { w.terminate(); };\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16)) + (d[b + 3] << 23) * 2; };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n throw 'invalid gzip data';\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += d[10] | (d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16) + (2 * (d[l - 1] << 23));\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + ((o.filename && (o.filename.length + 1)) || 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (fl ? (32 - 2 * fl) : 1);\n};\n// zlib valid\nvar zlv = function (d) {\n if ((d[0] & 15) != 8 || (d[0] >>> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n throw 'invalid zlib data';\n if (d[1] & 32)\n throw 'invalid zlib data: preset dictionaries not supported';\n};\nfunction AsyncCmpStrm(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n// zlib footer: -4 to -0 is Adler32\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, !f), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n this.d = final;\n this.p(chunk, final || false);\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n return dopt(data, opts, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n /**\n * Creates an inflation stream\n * @param cb The callback to call whenever data is inflated\n */\n function Inflate(cb) {\n this.s = {};\n this.p = new u8(0);\n this.ondata = cb;\n }\n Inflate.prototype.e = function (c) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n var l = this.p.length;\n var n = new u8(l + c.length);\n n.set(this.p), n.set(c, l), this.p = n;\n };\n Inflate.prototype.c = function (final) {\n this.d = this.s.i = final || false;\n var bts = this.s.b;\n var dt = inflt(this.p, this.o, this.s);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) >> 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous inflation stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncInflate(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, 0, function () {\n var strm = new Inflate();\n onmessage = astrm(strm);\n }, 7);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gu8(ev.data[1]))); }, 1, cb);\n}\n/**\n * Expands DEFLATE data with no wrapper\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function inflateSync(data, out) {\n return inflt(data, out);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n this.c.p(c);\n this.l += c.length;\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, !f);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n /**\n * Creates a GUNZIP stream\n * @param cb The callback to call whenever data is inflated\n */\n function Gunzip(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n var s = gzs(this.p);\n if (s >= this.p.length && !final)\n return;\n this.p = this.p.subarray(s), this.v = 0;\n }\n if (final) {\n if (this.p.length < 8)\n throw 'invalid gzip stream';\n this.p = this.p.subarray(0, -8);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous GUNZIP stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncGunzip(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, 0, function () {\n var strm = new Gunzip();\n onmessage = astrm(strm);\n }, 9);\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0])); }, 3, cb);\n}\n/**\n * Expands GZIP data\n * @param data The data to decompress\n * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.\n * @returns The decompressed version of the data\n */\nexport function gunzipSync(data, out) {\n return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n this.c.p(c);\n var raw = dopt(c, this.o, this.v && 2, f && 4, !f);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n /**\n * Creates a Zlib decompression stream\n * @param cb The callback to call whenever data is inflated\n */\n function Unzlib(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 2 && !final)\n return;\n this.p = this.p.subarray(2), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n throw 'invalid zlib stream';\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous Zlib decompression stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncUnzlib(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, 0, function () {\n var strm = new Unzlib();\n onmessage = astrm(strm);\n }, 11);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gu8(ev.data[1]))); }, 5, cb);\n}\n/**\n * Expands Zlib data\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function unzlibSync(data, out) {\n return inflt((zlv(data), data.subarray(2, -4)), out);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n /**\n * Creates a decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function Decompress(cb) {\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n throw 'no stream handler';\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n var _this_1 = this;\n var cb = function () { _this_1.ondata.apply(_this_1, arguments); };\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(cb)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(cb)\n : new this.Z(cb);\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function AsyncDecompress(cb) {\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, out) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, out)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, out)\n : unzlibSync(data, out);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k;\n if (val instanceof u8)\n t[n] = [val, o];\n else if (Array.isArray(val))\n t[n] = [val[0], mrg(o, val[1])];\n else\n fltn(val, n + '/', t, o);\n }\n};\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n var l = str.length;\n if (!latin1 && typeof TextEncoder != 'undefined')\n return new TextEncoder().encode(str);\n var ar = new u8(str.length + (str.length >>> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >>> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >>> 18)), w(128 | ((c >>> 12) & 63)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >>> 12)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n var r = '';\n if (!latin1 && typeof TextDecoder != 'undefined')\n return new TextDecoder().decode(dat);\n for (var i = 0; i < dat.length;) {\n var c = dat[i++];\n if (c < 128 || latin1)\n r += String.fromCharCode(c);\n else if (c < 224)\n r += String.fromCharCode((c & 31) << 6 | (dat[i++] & 63));\n else if (c < 240)\n r += String.fromCharCode((c & 15) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63));\n else\n c = ((c & 15) << 18 | (dat[i++] & 63) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n return r;\n}\n;\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;\n var _a = z ? z64e(d, es) : [b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];\n};\n// read zip64 extra field\nvar z64e = function (d, b) {\n for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))\n ;\n return [b4(d, b + 12), b4(d, b + 4), b4(d, b + 20)];\n};\n// write zip header\nvar wzh = function (d, b, c, cmp, su, fn, u, o, ce, t) {\n var fl = fn.length, l = cmp.length;\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b] = 20, b += 2;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (t == 8 && (o.level == 1 ? 6 : o.level < 6 ? 4 : o.level == 9 ? 2 : 0)), d[b++] = u && 8;\n d[b] = t, b += 2;\n var dt = new Date(o.mtime || Date.now()), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n throw 'date not in range 1980-2099';\n wbytes(d, b, ((y << 24) * 2) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >>> 1));\n b += 4;\n wbytes(d, b, c);\n wbytes(d, b + 4, l);\n wbytes(d, b + 8, su);\n wbytes(d, b + 12, fl), b += 16; // skip extra field, comment\n if (ce != null)\n wbytes(d, b += 10, ce), b += 4;\n d.set(fn, b);\n b += fl;\n if (ce == null)\n d.set(cmp, b);\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n wzh(out, tot, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, tot, f.t), o += 46 + f.n.length, tot += 30 + f.n.length + f.d.length;\n }\n catch (e) {\n return cb(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cb(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), m = file.length;\n c.p(file);\n var n = strToU8(fn), s = n.length;\n var t = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n var l = d.length;\n files[i] = {\n t: t,\n d: d,\n m: m,\n c: c.d(),\n u: fn.length != l,\n n: n,\n p: p\n };\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n if (!--lft)\n cbf();\n }\n };\n if (n.length > 65535)\n cbl('filename too long', null);\n if (!t)\n cbl(null, file);\n else if (m < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var t = p.level == 0 ? 0 : 8;\n var n = strToU8(fn), s = n.length;\n if (n.length > 65535)\n throw 'filename too long';\n var d = t ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push({\n t: t,\n d: d,\n m: file.length,\n c: c.d(),\n u: fn.length != s,\n n: n,\n o: o,\n p: p\n });\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, f.o, f.t), o += 46 + f.n.length;\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Asynchronously decompresses a ZIP archive\n * @param data The raw compressed ZIP file\n * @param cb The callback to call with the decompressed files\n * @returns A function that can be used to immediately terminate the unzipping\n */\nexport function unzip(data, cb) {\n if (typeof cb != 'function')\n throw 'no callback';\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cb('invalid zip file', null);\n return;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (!lft)\n cb(null, {});\n var c = lft;\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = lft = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n var _loop_2 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n files[fn] = d;\n if (!--lft)\n cb(null, files);\n }\n };\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n if (sc < 320000) {\n try {\n cbl(null, inflateSync(infl, new u8(su)));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl('unknown compression type ' + c_1, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_2(i);\n }\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @returns The decompressed files\n */\nexport function unzipSync(data) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n throw 'invalid zip file';\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));\n else\n throw 'unknown compression type ' + c_2;\n }\n return files;\n}\n","import { strFromU8, strToU8, zlibSync } from 'fflate';\nimport { PackFn, MARK, eventWithTimeAndPacker } from './base';\n\nexport const pack: PackFn = (event) => {\n const _e: eventWithTimeAndPacker = {\n ...event,\n v: MARK,\n };\n return strFromU8(zlibSync(strToU8(JSON.stringify(_e))), true);\n};\n","import { eventWithTime } from '../types';\n\nexport type PackFn = (event: eventWithTime) => string;\nexport type UnpackFn = (raw: string) => eventWithTime;\n\nexport type eventWithTimeAndPacker = eventWithTime & {\n v: string;\n};\n\nexport const MARK = 'v1';\n"],"names":["NodeType","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","map","getId","console","error","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","get","target","prop","receiver","chars","lookup","Uint8Array","charCodeAt","u8","u16","Uint16Array","u32","Uint32Array","fleb","fdeb","clim","freb","eb","start","b","r","j","_a","fl","revfl","revfd","rev","x","hMap","cd","mb","l","co","le","rvb","sv","r_1","v","m","flt","fdt","flm","fdm","shft","slc","e","set","subarray","wbits","d","o","wbits16","hTree","push","f","t2","slice","sort","a","i0","i1","i2","maxSym","tr","mbt","ln","dt","lft","cst","i2_1","i2_2","i2_3","Math","max","lc","c","cl","cli","cln","cls","w","clen","cf","wfblk","out","pos","dat","wblk","final","syms","lf","df","li","bs","bl","dlt","mlb","_b","ddt","mdb","_c","lclt","nlc","_d","lcdt","ndc","lcfreq","_e","lct","mlcb","nlcc","lm","ll","dm","dl","flen","ftlen","dtlen","llm","lcts","it","clct","len","dst","deo","et","dopt","opt","pre","post","st","lvl","plvl","lst","floor","msk_1","prev","head","bs1_1","ceil","bs2_1","hsh","lc_1","wi","hv","imod","pimod","rem","ch_1","dif","maxn","min","maxd","ml","nl","mmd","md","ti","lin","din","dflt","level","mem","log","zlibSync","data","opts","adler","lv","zlh","wbytes","event","latin1","TextDecoder","decode","String","fromCharCode","strFromU8","str","TextEncoder","encode","ar","ai","strToU8","JSON","stringify"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ECeQC,EA+DAC,EA8UAC,EAcAC,EAuIMC,EA2GNC,EF7nBDC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,aCtChC,SAAWd,GACPA,EAASA,EAAmB,SAAI,GAAK,WACrCA,EAASA,EAAuB,aAAI,GAAK,eACzCA,EAASA,EAAkB,QAAI,GAAK,UACpCA,EAASA,EAAe,KAAI,GAAK,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AI7G,OAAc,IAAiB,GAAX6G,EAAI7G,OAAc,EAAgB,GAAX6G,EAAI7G,MAAc,MACpF2C,GAAK2J,OAAOC,aAAa,MAASrG,GAAK,GAAK,MAAa,KAAJA,IAEjE,OAAOvD,ECj+CF6J,CAAUb,EDg7CZ,SAAiBc,EAAKN,GACzB,IAAI7I,EAAImJ,EAAItM,OACZ,IAAKgM,GAAgC,oBAAfO,YAClB,OAAO,IAAIA,aAAcC,OAAOF,GAIpC,IAHA,IAAIG,EAAK,IAAI7K,EAAG0K,EAAItM,QAAUsM,EAAItM,SAAW,IACzC0M,EAAK,EACLtG,EAAI,SAAU3C,GAAKgJ,EAAGC,KAAQjJ,GACzB5D,EAAI,EAAGA,EAAIsD,IAAKtD,EAAG,CACxB,GAAI6M,EAAK,EAAID,EAAGzM,OAAQ,CACpB,IAAIF,EAAI,IAAI8B,EAAG8K,EAAK,GAAMvJ,EAAItD,GAAM,IACpCC,EAAEoE,IAAIuI,GACNA,EAAK3M,EAET,IAAIiG,EAAIuG,EAAI3K,WAAW9B,GACnBkG,EAAI,KAAOiG,EACX5F,EAAEL,GACGA,EAAI,MACTK,EAAE,IAAOL,IAAM,GAAKK,EAAE,IAAW,GAAJL,IACxBA,EAAI,OAASA,EAAI,OAElBK,EAAE,KADNL,EAAI,OAAa,QAAJA,GAAyC,KAAtBuG,EAAI3K,aAAa9B,MAC9B,IAAMuG,EAAE,IAAQL,IAAM,GAAM,IAAMK,EAAE,IAAQL,IAAM,EAAK,IAAMK,EAAE,IAAW,GAAJL,KAEzFK,EAAE,IAAOL,IAAM,IAAMK,EAAE,IAAQL,IAAM,EAAK,IAAMK,EAAE,IAAW,GAAJL,IAEjE,OAAO/B,EAAIyI,EAAI,EAAGC,GCx8CMC,CAAQC,KAAKC,UAAU9E,MAAO"} +\ No newline at end of file +diff --git a/node_modules/rrweb/dist/record/rrweb-record.js b/node_modules/rrweb/dist/record/rrweb-record.js +old mode 100644 +new mode 100755 +index 2ad77a4..296ec85 +--- a/node_modules/rrweb/dist/record/rrweb-record.js ++++ b/node_modules/rrweb/dist/record/rrweb-record.js +@@ -97,10 +97,14 @@ var rrwebRecord = (function () { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -327,7 +331,10 @@ var rrwebRecord = (function () { + return value; + } + } +- function _isBlockedElement(element, blockClass, blockSelector) { ++ function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -346,11 +353,16 @@ var rrwebRecord = (function () { + } + return false; + } +- function needMaskingText(node, maskTextClass, maskTextSelector) { ++ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -369,12 +381,12 @@ var rrwebRecord = (function () { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -414,7 +426,7 @@ var rrwebRecord = (function () { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -446,7 +458,7 @@ var rrwebRecord = (function () { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -487,9 +499,12 @@ var rrwebRecord = (function () { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -608,7 +623,7 @@ var rrwebRecord = (function () { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -716,15 +731,19 @@ var rrwebRecord = (function () { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -780,10 +799,14 @@ var rrwebRecord = (function () { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -828,10 +851,14 @@ var rrwebRecord = (function () { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -854,7 +881,7 @@ var rrwebRecord = (function () { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -903,10 +930,14 @@ var rrwebRecord = (function () { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -1382,8 +1413,12 @@ var rrwebRecord = (function () { + map: _this.mirror.map, + blockClass: _this.blockClass, + blockSelector: _this.blockSelector, ++ unblockSelector: _this.unblockSelector, + maskTextClass: _this.maskTextClass, + maskTextSelector: _this.maskTextSelector, ++ unmaskTextSelector: _this.unmaskTextSelector, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + skipChild: true, + inlineStylesheet: _this.inlineStylesheet, + maskInputOptions: _this.maskInputOptions, +@@ -1529,7 +1564,7 @@ var rrwebRecord = (function () { + var value = m.target.textContent; + if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) { + _this.texts.push({ +- value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector) && value ++ value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, _this.unmaskTextSelector) && value + ? _this.maskTextFn + ? _this.maskTextFn(value) + : value.replace(/[\S]/g, '*') +@@ -1544,6 +1579,9 @@ var rrwebRecord = (function () { + var value = m.target.getAttribute(m.attributeName); + if (m.attributeName === 'value') { + value = maskInputValue({ ++ input: target, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + maskInputOptions: _this.maskInputOptions, + tagName: m.target.tagName, + type: m.target.getAttribute('type'), +@@ -1680,8 +1718,12 @@ var rrwebRecord = (function () { + 'mutationCb', + 'blockClass', + 'blockSelector', ++ 'unblockSelector', + 'maskTextClass', + 'maskTextSelector', ++ 'unmaskTextSelector', ++ 'maskInputSelector', ++ 'unmaskInputSelector', + 'inlineStylesheet', + 'maskInputOptions', + 'maskTextFn', +@@ -1945,7 +1987,7 @@ var rrwebRecord = (function () { + var INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT']; + var lastInputValueMap = new WeakMap(); + function initInputObserver(_a) { +- var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; ++ var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; + function eventHandler(event) { + var target = getEventTarget(event); + var userTriggered = event.isTrusted; +@@ -1958,7 +2000,7 @@ var rrwebRecord = (function () { + return; + } + var type = target.type; +- if (target.classList.contains(ignoreClass)) { ++ if (target.classList.contains(ignoreClass) || (ignoreSelector && target.matches(ignoreSelector))) { + return; + } + var text = target.value; +@@ -1969,7 +2011,10 @@ var rrwebRecord = (function () { + else if (maskInputOptions[target.tagName.toLowerCase()] || + maskInputOptions[type]) { + text = maskInputValue({ ++ input: target, + maskInputOptions: maskInputOptions, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + tagName: target.tagName, + type: type, + value: text, +@@ -2053,6 +2098,9 @@ var rrwebRecord = (function () { + function initStyleSheetObserver(_a, _b) { + var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror; + var win = _b.win; ++ if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) { ++ return function () { }; ++ } + var insertRule = win.CSSStyleSheet.prototype.insertRule; + win.CSSStyleSheet.prototype.insertRule = function (rule, index) { + var id = mirror.getId(this.ownerNode); +@@ -2885,7 +2933,7 @@ var rrwebRecord = (function () { + var mirror = createMirror(); + function record(options) { + if (options === void 0) { options = {}; } +- var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.ignoreClass, ignoreClass = _c === void 0 ? 'rr-ignore' : _c, _d = options.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = options.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = options.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _g = options.sampling, sampling = _g === void 0 ? {} : _g, mousemoveWait = options.mousemoveWait, _h = options.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = options.userTriggeredOnInput, userTriggeredOnInput = _j === void 0 ? false : _j, _k = options.collectFonts, collectFonts = _k === void 0 ? false : _k, _l = options.inlineImages, inlineImages = _l === void 0 ? false : _l, plugins = options.plugins, _m = options.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m; ++ var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s; + if (!emit) { + throw new Error('emit function is required'); + } +@@ -3016,8 +3064,12 @@ var rrwebRecord = (function () { + bypassOptions: { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, +@@ -3046,8 +3098,12 @@ var rrwebRecord = (function () { + var _e = __read(snapshot(document, { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskAllInputs: maskInputOptions, + maskTextFn: maskTextFn, +@@ -3161,8 +3217,12 @@ var rrwebRecord = (function () { + }, + blockClass: blockClass, + ignoreClass: ignoreClass, ++ ignoreSelector: ignoreSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + inlineStylesheet: inlineStylesheet, + sampling: sampling, +@@ -3174,6 +3234,7 @@ var rrwebRecord = (function () { + maskInputFn: maskInputFn, + maskTextFn: maskTextFn, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + slimDOMOptions: slimDOMOptions, + mirror: mirror, + iframeManager: iframeManager, +@@ -3195,7 +3256,12 @@ var rrwebRecord = (function () { + }, hooks); + }; + iframeManager.addLoadListener(function (iframeEl) { +- handlers_1.push(observe_1(iframeEl.contentDocument)); ++ try { ++ handlers_1.push(observe_1(iframeEl.contentDocument)); ++ } ++ catch (error) { ++ console.warn(error); ++ } + }); + var init_1 = function () { + takeFullSnapshot(); +diff --git a/node_modules/rrweb/dist/record/rrweb-record.min.js b/node_modules/rrweb/dist/record/rrweb-record.min.js +old mode 100644 +new mode 100755 +index 9aa9ebb..c396d18 +--- a/node_modules/rrweb/dist/record/rrweb-record.min.js ++++ b/node_modules/rrweb/dist/record/rrweb-record.min.js +@@ -12,5 +12,5 @@ var rrwebRecord=function(){"use strict"; + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. +- ***************************************************************************** */var e,t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function r(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}function o(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+u)+l+")";var c=t.split("/"),d=u.split("/");c.pop();for(var p=0,f=d;p=t.length);){var a=r(I);if(","===a.slice(-1))a=M(e,a.substring(0,a.length-1)),o.push(a);else{var i="";a=M(e,a);for(var s=!1;;){var u=t.charAt(n);if(""===u){o.push((a+i).trim());break}if(s)")"===u&&(s=!1);else{if(","===u){n+=1,o.push((a+i).trim());break}"("===u&&(s=!0)}i+=u,n+=1}}}return o.join(", ")}(e,r):"style"===n&&r?y(r,T()):"object"===t&&"data"===n&&r?M(e,r):r:M(e,r)}function O(e,t,n){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=0;rt?(r&&(clearTimeout(r),r=null),o=i,e.apply(u,l)):r||!1===n.trailing||(r=setTimeout((function(){o=!1===n.leading?0:Date.now(),r=null,e.apply(u,l)}),s))}}function P(e,t,n,r,o){void 0===o&&(o=window);var a=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set:function(e){var t=this;setTimeout((function(){n.set.call(t,e)}),0),a&&a.set&&a.set.call(this,e)}}),function(){return P(e,t,a||{},!0)}}function z(e,t,n){try{if(!(t in e))return function(){};var r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,function(){e[t]=r}}catch(e){return function(){}}}function W(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function U(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function j(e,t){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){var n=!1;if("string"==typeof t){if(void 0!==e.closest)return null!==e.closest("."+t);n=e.classList.contains(t)}else e.classList.forEach((function(e){t.test(e)&&(n=!0)}));return n||j(e.parentNode,t)}return e.nodeType,e.TEXT_NODE,j(e.parentNode,t)}function G(e){return"__sn"in e&&-2===e.__sn.id}function V(e,t){if(a(e))return!1;var n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||V(e.parentNode,t))}function H(e){return Boolean(e.changedTouches)}function q(t){return"__sn"in t&&(t.__sn.type===e.Element&&"iframe"===t.__sn.tagName)}function B(e){return Boolean(null==e?void 0:e.shadowRoot)}function X(e){return"__ln"in e}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(F=new Proxy(F,{get:function(e,t,n){return"map"===t&&console.error(D),Reflect.get(e,t,n)}}));var Y=function(){function e(){this.length=0,this.head=null}return e.prototype.get=function(e){if(e>=this.length)throw new Error("Position outside of list range");for(var t=this.head,n=0;n=0;S--){var C=u.get(S);if(C){g=e.mirror.getId(C.value.parentNode),b=l(C.value);if(-1!==g&&-1!==b){y=C;break}}}if(!y){for(;u.head;)u.removeNode(u.head.value);break}v=y.previous,u.removeNode(y.value),c(y.value)}var k={texts:e.texts.map((function(t){return{id:e.mirror.getId(t.node),value:t.value}})).filter((function(t){return e.mirror.has(t.id)})),attributes:e.attributes.map((function(t){return{id:e.mirror.getId(t.node),attributes:t.attributes}})).filter((function(t){return e.mirror.has(t.id)})),removes:e.removes,adds:s};(k.texts.length||k.attributes.length||k.removes.length||k.adds.length)&&(e.texts=[],e.attributes=[],e.removes=[],e.addedSet=new Set,e.movedSet=new Set,e.droppedSet=new Set,e.movedMap={},e.mutationCb(k))}},this.processMutation=function(t){var r,o,s,u;if(!G(t.target))switch(t.type){case"characterData":var l=t.target.textContent;j(t.target,e.blockClass)||l===t.oldValue||e.texts.push({value:O(t.target,e.maskTextClass,e.maskTextSelector)&&l?e.maskTextFn?e.maskTextFn(l):l.replace(/[\S]/g,"*"):l,node:t.target});break;case"attributes":var c=t.target;l=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(l=i({maskInputOptions:e.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:l,maskInputFn:e.maskInputFn})),j(t.target,e.blockClass)||l===t.oldValue)return;var d=e.attributes.find((function(e){return e.node===t.target}));if(d||(d={node:t.target,attributes:{}},e.attributes.push(d)),"style"===t.attributeName){var p=e.doc.createElement("span");t.oldValue&&p.setAttribute("style",t.oldValue),void 0!==d.attributes.style&&null!==d.attributes.style||(d.attributes.style={});var f=d.attributes.style;try{for(var m=n(Array.from(c.style)),h=m.next();!h.done;h=m.next()){var v=h.value,y=c.style.getPropertyValue(v),g=c.style.getPropertyPriority(v);y===p.style.getPropertyValue(v)&&g===p.style.getPropertyPriority(v)||(f[v]=""===g?y:[y,g])}}catch(e){r={error:e}}finally{try{h&&!h.done&&(o=m.return)&&o.call(m)}finally{if(r)throw r.error}}try{for(var b=n(Array.from(p.style)),S=b.next();!S.done;S=b.next()){v=S.value;""===c.style.getPropertyValue(v)&&(f[v]=!1)}}catch(e){s={error:e}}finally{try{S&&!S.done&&(u=b.return)&&u.call(b)}finally{if(s)throw s.error}}}else d.attributes[t.attributeName]=E(e.doc,t.target.tagName,t.attributeName,l);break;case"childList":t.addedNodes.forEach((function(n){return e.genAdds(n,t.target)})),t.removedNodes.forEach((function(n){var r=e.mirror.getId(n),o=a(t.target)?e.mirror.getId(t.target.host):e.mirror.getId(t.target);j(t.target,e.blockClass)||G(n)||(e.addedSet.has(n)?($(e.addedSet,n),e.droppedSet.add(n)):e.addedSet.has(t.target)&&-1===r||V(t.target,e.mirror)||(e.movedSet.has(n)&&e.movedMap[K(r,o)]?$(e.movedSet,n):e.removes.push({parentId:o,id:r,isShadow:!!a(t.target)||void 0})),e.mapRemoves.push(n))}))}},this.genAdds=function(t,n){if(!n||!j(n,e.blockClass)){if(J(t)){if(G(t))return;e.movedSet.add(t);var r=null;n&&J(n)&&(r=n.__sn.id),r&&(e.movedMap[K(t.__sn.id,r)]=!0)}else e.addedSet.add(t),e.droppedSet.delete(t);j(t,e.blockClass)||t.childNodes.forEach((function(t){return e.genAdds(t)}))}}}return e.prototype.init=function(e){var t=this;["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","recordCanvas","inlineImages","slimDOMOptions","doc","mirror","iframeManager","shadowDomManager","canvasManager"].forEach((function(n){t[n]=e[n]}))},e.prototype.freeze=function(){this.frozen=!0,this.canvasManager.freeze()},e.prototype.unfreeze=function(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()},e.prototype.isFrozen=function(){return this.frozen},e.prototype.lock=function(){this.locked=!0,this.canvasManager.lock()},e.prototype.unlock=function(){this.locked=!1,this.canvasManager.unlock(),this.emit()},e.prototype.reset=function(){this.shadowDomManager.reset(),this.canvasManager.reset()},e}();function $(e,t){e.delete(t),t.childNodes.forEach((function(t){return $(e,t)}))}function Q(e,t,n){var r=t.parentNode;if(!r)return!1;var o=n.getId(r);return!!e.some((function(e){return e.id===o}))||Q(e,r,n)}function ee(e,t){var n=t.parentNode;return!!n&&(!!e.has(n)||ee(e,n))}var te=[],ne="undefined"!=typeof CSSGroupingRule,re="undefined"!=typeof CSSMediaRule,oe="undefined"!=typeof CSSSupportsRule,ae="undefined"!=typeof CSSConditionRule;function ie(e){try{if("composedPath"in e){var t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function se(e,t){var n,r,o=new Z;te.push(o),o.init(e);var a=window.MutationObserver||window.__rrMutationObserver,i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(a=window[i]);var s=new a(o.processMutations.bind(o));return s.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),s}function ue(e){var t=e.mouseInteractionCb,n=e.doc,r=e.mirror,o=e.blockClass,a=e.sampling;if(!1===a.mouseInteraction)return function(){};var i=!0===a.mouseInteraction||void 0===a.mouseInteraction?{}:a.mouseInteraction,s=[];return Object.keys(S).filter((function(e){return Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e]})).forEach((function(e){var a=e.toLowerCase(),i=function(e){return function(n){var a=ie(n);if(!j(a,o)){var i=H(n)?n.changedTouches[0]:n;if(i){var s=r.getId(a),u=i.clientX,l=i.clientY;t({type:S[e],id:s,x:u,y:l})}}}}(e);s.push(L(a,i,n))})),function(){s.forEach((function(e){return e()}))}}function le(e){var t=e.scrollCb,n=e.doc,r=e.mirror,o=e.blockClass;return L("scroll",A((function(e){var a=ie(e);if(a&&!j(a,o)){var i=r.getId(a);if(a===n){var s=n.scrollingElement||n.documentElement;t({id:i,x:s.scrollLeft,y:s.scrollTop})}else t({id:i,x:a.scrollLeft,y:a.scrollTop})}}),e.sampling.scroll||100),n)}function ce(e,n){var r=t({},e);return n||delete r.userTriggered,r}var de=["INPUT","TEXTAREA","SELECT"],pe=new WeakMap;function fe(e){return function(e,t){if(ne&&e.parentRule instanceof CSSGroupingRule||re&&e.parentRule instanceof CSSMediaRule||oe&&e.parentRule instanceof CSSSupportsRule||ae&&e.parentRule instanceof CSSConditionRule){var n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else{n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function me(e,a){var s,u;void 0===a&&(a={});var l=e.doc.defaultView;if(!l)return function(){};!function(e,t){var n=e.mutationCb,a=e.mousemoveCb,i=e.mouseInteractionCb,s=e.scrollCb,u=e.viewportResizeCb,l=e.inputCb,c=e.mediaInteractionCb,d=e.styleSheetRuleCb,p=e.styleDeclarationCb,f=e.canvasMutationCb,m=e.fontCb;e.mutationCb=function(){for(var e=[],a=0;a>2],o+=ye[(3&n[t])<<4|n[t+1]>>4],o+=ye[(15&n[t+1])<<2|n[t+2]>>6],o+=ye[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)}:e instanceof DataView?{rr_type:e.constructor.name,args:[ke(e.buffer,t,n),e.byteOffset,e.byteLength]}:e instanceof HTMLImageElement?{rr_type:e.constructor.name,src:e.src}:e instanceof ImageData?{rr_type:e.constructor.name,args:[ke(e.data,t,n),e.width,e.height]}:Ie(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Ce(e,t,n)}:e}var we=function(e,t,n){return o([],r(e),!1).map((function(e){return ke(e,t,n)}))},Ie=function(e,t){var n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((function(e){return"function"==typeof t[e]}));return Boolean(n.find((function(n){return e instanceof t[n]})))};function xe(e,t,a,i,s,u){var l,c,d=[],p=Object.getOwnPropertyNames(e),f=function(n){try{if("function"!=typeof e[n])return"continue";var l=z(e,n,(function(l){return function(){for(var c=[],d=0;d=i,u=a&&e.timestamp-K.timestamp>a;(s||u)&&Te(!0)}};var Q=function(e){Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.Mutation},e)}))},ee=function(e){return Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.Scroll},e)}))},ne=function(e){return Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.CanvasMutation},e)}))},re=new he({mutationCb:Q}),oe=new Ee({recordCanvas:D,mutationCb:ne,win:window,blockClass:u,mirror:Re}),ae=new ve({mutationCb:Q,scrollCb:ee,bypassOptions:{blockClass:u,blockSelector:c,maskTextClass:m,maskTextSelector:v,inlineStylesheet:S,maskInputOptions:J,maskTextFn:x,maskInputFn:I,recordCanvas:D,inlineImages:G,sampling:O,slimDOMOptions:Z,iframeManager:re,canvasManager:oe},mirror:Re});Te=function(e){var t,n,o,a;void 0===e&&(e=!1),Me(Oe({type:g.Meta,data:{href:window.location.href,width:U(),height:W()}}),e),te.forEach((function(e){return e.lock()}));var i=r(function(e,t){var n=t||{},r=n.blockClass,o=void 0===r?"rr-block":r,a=n.blockSelector,i=void 0===a?null:a,s=n.maskTextClass,u=void 0===s?"rr-mask":s,l=n.maskTextSelector,c=void 0===l?null:l,d=n.inlineStylesheet,p=void 0===d||d,f=n.inlineImages,m=void 0!==f&&f,h=n.recordCanvas,v=void 0!==h&&h,y=n.maskAllInputs,g=void 0!==y&&y,b=n.maskTextFn,S=n.maskInputFn,C=n.slimDOM,k=void 0!==C&&C,w=n.dataURLOptions,I=n.preserveWhiteSpace,x=n.onSerialize,M=n.onIframeLoad,T=n.iframeLoadTimeout,E=n.keepIframeSrcFn,O={};return[_(e,{doc:e,map:O,blockClass:o,blockSelector:i,maskTextClass:u,maskTextSelector:c,skipChild:!1,inlineStylesheet:p,maskInputOptions:!0===g?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===g?{password:!0}:g,maskTextFn:b,maskInputFn:S,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:w,inlineImages:m,recordCanvas:v,preserveWhiteSpace:I,onSerialize:x,onIframeLoad:M,iframeLoadTimeout:T,keepIframeSrcFn:void 0===E?function(){return!1}:E}),O]}(document,{blockClass:u,blockSelector:c,maskTextClass:m,maskTextSelector:v,inlineStylesheet:S,maskAllInputs:J,maskTextFn:x,slimDOM:Z,recordCanvas:D,inlineImages:G,onSerialize:function(e){q(e)&&re.addIframe(e),B(e)&&ae.addShadowRoot(e.shadowRoot,document)},onIframeLoad:function(e,t){re.attachIframe(e,t),ae.observeAttachShadow(e)},keepIframeSrcFn:X}),2),s=i[0],l=i[1];if(!s)return console.warn("Failed to snapshot the document");Re.map=l,Me(Oe({type:g.FullSnapshot,data:{node:s,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===document||void 0===document?void 0:document.body.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(a=null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.parentElement)||void 0===a?void 0:a.scrollTop)||(null===document||void 0===document?void 0:document.body.scrollTop)||0}}})),te.forEach((function(e){return e.unlock()}))};try{var ie=[];ie.push(L("DOMContentLoaded",(function(){Me(Oe({type:g.DomContentLoaded,data:{}}))})));var se=function(e){var n;return me({mutationCb:Q,mousemoveCb:function(e,t){return Me(Oe({type:g.IncrementalSnapshot,data:{source:t,positions:e}}))},mouseInteractionCb:function(e){return Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.MouseInteraction},e)}))},scrollCb:ee,viewportResizeCb:function(e){return Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.ViewportResize},e)}))},inputCb:function(e){return Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.Input},e)}))},mediaInteractionCb:function(e){return Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.MediaInteraction},e)}))},styleSheetRuleCb:function(e){return Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.StyleSheetRule},e)}))},styleDeclarationCb:function(e){return Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.StyleDeclaration},e)}))},canvasMutationCb:ne,fontCb:function(e){return Me(Oe({type:g.IncrementalSnapshot,data:t({source:b.Font},e)}))},blockClass:u,ignoreClass:p,maskTextClass:m,maskTextSelector:v,maskInputOptions:J,inlineStylesheet:S,sampling:O,recordCanvas:D,inlineImages:G,userTriggeredOnInput:A,collectFonts:z,doc:e,maskInputFn:I,maskTextFn:x,blockSelector:c,slimDOMOptions:Z,mirror:Re,iframeManager:re,shadowDomManager:ae,canvasManager:oe,plugins:(null===(n=null==V?void 0:V.filter((function(e){return e.observer})))||void 0===n?void 0:n.map((function(e){return{observer:e.observer,options:e.options,callback:function(t){return Me(Oe({type:g.Plugin,data:{plugin:e.name,payload:t}}))}}})))||[]},M)};re.addLoadListener((function(e){ie.push(se(e.contentDocument))}));var ue=function(){Te(),ie.push(se(document))};return"interactive"===document.readyState||"complete"===document.readyState?ue():ie.push(L("load",(function(){Me(Oe({type:g.Load,data:{}})),ue()}),window)),function(){ie.forEach((function(e){return e()}))}}catch(e){console.warn(e)}}return Ne.addCustomEvent=function(e,t){if(!Me)throw new Error("please add custom event after start recording");Me(Oe({type:g.Custom,data:{tag:e,payload:t}}))},Ne.freezePage=function(){te.forEach((function(e){return e.freeze()}))},Ne.takeFullSnapshot=function(e){if(!Te)throw new Error("please take full snapshot after start recording");Te(e)},Ne.mirror=Re,Ne}(); ++ ***************************************************************************** */var e,t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function r(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}function o(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+u)+l+")";var c=t.split("/"),d=u.split("/");c.pop();for(var p=0,f=d;p=t.length);){var a=r(w);if(","===a.slice(-1))a=T(e,a.substring(0,a.length-1)),o.push(a);else{var i="";a=T(e,a);for(var s=!1;;){var u=t.charAt(n);if(""===u){o.push((a+i).trim());break}if(s)")"===u&&(s=!1);else{if(","===u){n+=1,o.push((a+i).trim());break}"("===u&&(s=!0)}i+=u,n+=1}}}return o.join(", ")}(e,r):"style"===n&&r?y(r,M()):"object"===t&&"data"===n&&r?T(e,r):r:T(e,r)}function O(e,t,n,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if(r&&(e.matches(r)||e.closest(r)))return!1;if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=0;ot?(r&&(clearTimeout(r),r=null),o=i,e.apply(u,l)):r||!1===n.trailing||(r=setTimeout((function(){o=!1===n.leading?0:Date.now(),r=null,e.apply(u,l)}),s))}}function P(e,t,n,r,o){void 0===o&&(o=window);var a=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set:function(e){var t=this;setTimeout((function(){n.set.call(t,e)}),0),a&&a.set&&a.set.call(this,e)}}),function(){return P(e,t,a||{},!0)}}function z(e,t,n){try{if(!(t in e))return function(){};var r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,function(){e[t]=r}}catch(e){return function(){}}}function W(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function U(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function j(e,t){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){var n=!1;if("string"==typeof t){if(void 0!==e.closest)return null!==e.closest("."+t);n=e.classList.contains(t)}else e.classList.forEach((function(e){t.test(e)&&(n=!0)}));return n||j(e.parentNode,t)}return e.nodeType,e.TEXT_NODE,j(e.parentNode,t)}function G(e){return"__sn"in e&&-2===e.__sn.id}function V(e,t){if(a(e))return!1;var n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||V(e.parentNode,t))}function H(e){return Boolean(e.changedTouches)}function q(t){return"__sn"in t&&(t.__sn.type===e.Element&&"iframe"===t.__sn.tagName)}function B(e){return Boolean(null==e?void 0:e.shadowRoot)}function X(e){return"__ln"in e}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(F=new Proxy(F,{get:function(e,t,n){return"map"===t&&console.error(D),Reflect.get(e,t,n)}}));var Y=function(){function e(){this.length=0,this.head=null}return e.prototype.get=function(e){if(e>=this.length)throw new Error("Position outside of list range");for(var t=this.head,n=0;n=0;b--){var k=u.get(b);if(k){S=e.mirror.getId(k.value.parentNode),g=l(k.value);if(-1!==S&&-1!==g){y=k;break}}}if(!y){for(;u.head;)u.removeNode(u.head.value);break}v=y.previous,u.removeNode(y.value),c(y.value)}var C={texts:e.texts.map((function(t){return{id:e.mirror.getId(t.node),value:t.value}})).filter((function(t){return e.mirror.has(t.id)})),attributes:e.attributes.map((function(t){return{id:e.mirror.getId(t.node),attributes:t.attributes}})).filter((function(t){return e.mirror.has(t.id)})),removes:e.removes,adds:s};(C.texts.length||C.attributes.length||C.removes.length||C.adds.length)&&(e.texts=[],e.attributes=[],e.removes=[],e.addedSet=new Set,e.movedSet=new Set,e.droppedSet=new Set,e.movedMap={},e.mutationCb(C))}},this.processMutation=function(t){var r,o,s,u;if(!G(t.target))switch(t.type){case"characterData":var l=t.target.textContent;j(t.target,e.blockClass)||l===t.oldValue||e.texts.push({value:O(t.target,e.maskTextClass,e.maskTextSelector,e.unmaskTextSelector)&&l?e.maskTextFn?e.maskTextFn(l):l.replace(/[\S]/g,"*"):l,node:t.target});break;case"attributes":var c=t.target;l=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(l=i({input:c,maskInputSelector:e.maskInputSelector,unmaskInputSelector:e.unmaskInputSelector,maskInputOptions:e.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:l,maskInputFn:e.maskInputFn})),j(t.target,e.blockClass)||l===t.oldValue)return;var d=e.attributes.find((function(e){return e.node===t.target}));if(d||(d={node:t.target,attributes:{}},e.attributes.push(d)),"style"===t.attributeName){var p=e.doc.createElement("span");t.oldValue&&p.setAttribute("style",t.oldValue),void 0!==d.attributes.style&&null!==d.attributes.style||(d.attributes.style={});var f=d.attributes.style;try{for(var m=n(Array.from(c.style)),h=m.next();!h.done;h=m.next()){var v=h.value,y=c.style.getPropertyValue(v),S=c.style.getPropertyPriority(v);y===p.style.getPropertyValue(v)&&S===p.style.getPropertyPriority(v)||(f[v]=""===S?y:[y,S])}}catch(e){r={error:e}}finally{try{h&&!h.done&&(o=m.return)&&o.call(m)}finally{if(r)throw r.error}}try{for(var g=n(Array.from(p.style)),b=g.next();!b.done;b=g.next()){v=b.value;""===c.style.getPropertyValue(v)&&(f[v]=!1)}}catch(e){s={error:e}}finally{try{b&&!b.done&&(u=g.return)&&u.call(g)}finally{if(s)throw s.error}}}else d.attributes[t.attributeName]=E(e.doc,t.target.tagName,t.attributeName,l);break;case"childList":t.addedNodes.forEach((function(n){return e.genAdds(n,t.target)})),t.removedNodes.forEach((function(n){var r=e.mirror.getId(n),o=a(t.target)?e.mirror.getId(t.target.host):e.mirror.getId(t.target);j(t.target,e.blockClass)||G(n)||(e.addedSet.has(n)?($(e.addedSet,n),e.droppedSet.add(n)):e.addedSet.has(t.target)&&-1===r||V(t.target,e.mirror)||(e.movedSet.has(n)&&e.movedMap[K(r,o)]?$(e.movedSet,n):e.removes.push({parentId:o,id:r,isShadow:!!a(t.target)||void 0})),e.mapRemoves.push(n))}))}},this.genAdds=function(t,n){if(!n||!j(n,e.blockClass)){if(J(t)){if(G(t))return;e.movedSet.add(t);var r=null;n&&J(n)&&(r=n.__sn.id),r&&(e.movedMap[K(t.__sn.id,r)]=!0)}else e.addedSet.add(t),e.droppedSet.delete(t);j(t,e.blockClass)||t.childNodes.forEach((function(t){return e.genAdds(t)}))}}}return e.prototype.init=function(e){var t=this;["mutationCb","blockClass","blockSelector","unblockSelector","maskTextClass","maskTextSelector","unmaskTextSelector","maskInputSelector","unmaskInputSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","recordCanvas","inlineImages","slimDOMOptions","doc","mirror","iframeManager","shadowDomManager","canvasManager"].forEach((function(n){t[n]=e[n]}))},e.prototype.freeze=function(){this.frozen=!0,this.canvasManager.freeze()},e.prototype.unfreeze=function(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()},e.prototype.isFrozen=function(){return this.frozen},e.prototype.lock=function(){this.locked=!0,this.canvasManager.lock()},e.prototype.unlock=function(){this.locked=!1,this.canvasManager.unlock(),this.emit()},e.prototype.reset=function(){this.shadowDomManager.reset(),this.canvasManager.reset()},e}();function $(e,t){e.delete(t),t.childNodes.forEach((function(t){return $(e,t)}))}function Q(e,t,n){var r=t.parentNode;if(!r)return!1;var o=n.getId(r);return!!e.some((function(e){return e.id===o}))||Q(e,r,n)}function ee(e,t){var n=t.parentNode;return!!n&&(!!e.has(n)||ee(e,n))}var te=[],ne="undefined"!=typeof CSSGroupingRule,re="undefined"!=typeof CSSMediaRule,oe="undefined"!=typeof CSSSupportsRule,ae="undefined"!=typeof CSSConditionRule;function ie(e){try{if("composedPath"in e){var t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function se(e,t){var n,r,o=new Z;te.push(o),o.init(e);var a=window.MutationObserver||window.__rrMutationObserver,i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(a=window[i]);var s=new a(o.processMutations.bind(o));return s.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),s}function ue(e){var t=e.mouseInteractionCb,n=e.doc,r=e.mirror,o=e.blockClass,a=e.sampling;if(!1===a.mouseInteraction)return function(){};var i=!0===a.mouseInteraction||void 0===a.mouseInteraction?{}:a.mouseInteraction,s=[];return Object.keys(b).filter((function(e){return Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e]})).forEach((function(e){var a=e.toLowerCase(),i=function(e){return function(n){var a=ie(n);if(!j(a,o)){var i=H(n)?n.changedTouches[0]:n;if(i){var s=r.getId(a),u=i.clientX,l=i.clientY;t({type:b[e],id:s,x:u,y:l})}}}}(e);s.push(L(a,i,n))})),function(){s.forEach((function(e){return e()}))}}function le(e){var t=e.scrollCb,n=e.doc,r=e.mirror,o=e.blockClass;return L("scroll",A((function(e){var a=ie(e);if(a&&!j(a,o)){var i=r.getId(a);if(a===n){var s=n.scrollingElement||n.documentElement;t({id:i,x:s.scrollLeft,y:s.scrollTop})}else t({id:i,x:a.scrollLeft,y:a.scrollTop})}}),e.sampling.scroll||100),n)}function ce(e,n){var r=t({},e);return n||delete r.userTriggered,r}var de=["INPUT","TEXTAREA","SELECT"],pe=new WeakMap;function fe(e){return function(e,t){if(ne&&e.parentRule instanceof CSSGroupingRule||re&&e.parentRule instanceof CSSMediaRule||oe&&e.parentRule instanceof CSSSupportsRule||ae&&e.parentRule instanceof CSSConditionRule){var n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else{n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function me(e,a){var s,u;void 0===a&&(a={});var l=e.doc.defaultView;if(!l)return function(){};!function(e,t){var n=e.mutationCb,a=e.mousemoveCb,i=e.mouseInteractionCb,s=e.scrollCb,u=e.viewportResizeCb,l=e.inputCb,c=e.mediaInteractionCb,d=e.styleSheetRuleCb,p=e.styleDeclarationCb,f=e.canvasMutationCb,m=e.fontCb;e.mutationCb=function(){for(var e=[],a=0;a>2],o+=ye[(3&n[t])<<4|n[t+1]>>4],o+=ye[(15&n[t+1])<<2|n[t+2]>>6],o+=ye[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)}:e instanceof DataView?{rr_type:e.constructor.name,args:[Ce(e.buffer,t,n),e.byteOffset,e.byteLength]}:e instanceof HTMLImageElement?{rr_type:e.constructor.name,src:e.src}:e instanceof ImageData?{rr_type:e.constructor.name,args:[Ce(e.data,t,n),e.width,e.height]}:we(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:ke(e,t,n)}:e}var Ie=function(e,t,n){return o([],r(e),!1).map((function(e){return Ce(e,t,n)}))},we=function(e,t){var n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((function(e){return"function"==typeof t[e]}));return Boolean(n.find((function(n){return e instanceof t[n]})))};function xe(e,t,a,i,s,u){var l,c,d=[],p=Object.getOwnPropertyNames(e),f=function(n){try{if("function"!=typeof e[n])return"continue";var l=z(e,n,(function(l){return function(){for(var c=[],d=0;d=i,u=a&&e.timestamp-ie.timestamp>a;(s||u)&&Me(!0)}};var ce=function(e){Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.Mutation},e)}))},de=function(e){return Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.Scroll},e)}))},pe=function(e){return Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.CanvasMutation},e)}))},fe=new he({mutationCb:ce}),ye=new Ee({recordCanvas:Y,mutationCb:pe,win:window,blockClass:u,mirror:Re}),Se=new ve({mutationCb:ce,scrollCb:de,bypassOptions:{blockClass:u,blockSelector:c,unblockSelector:p,maskTextClass:b,maskTextSelector:C,unmaskTextSelector:T,maskInputSelector:w,unmaskInputSelector:E,inlineStylesheet:R,maskInputOptions:se,maskTextFn:P,maskInputFn:A,recordCanvas:Y,inlineImages:ee,sampling:V,slimDOMOptions:ue,iframeManager:fe,canvasManager:ye},mirror:Re});Me=function(e){var t,n,o,a;void 0===e&&(e=!1),Te(Oe({type:S.Meta,data:{href:window.location.href,width:U(),height:W()}}),e),te.forEach((function(e){return e.lock()}));var i=r(function(e,t){var n=t||{},r=n.blockClass,o=void 0===r?"rr-block":r,a=n.blockSelector,i=void 0===a?null:a,s=n.unblockSelector,u=void 0===s?null:s,l=n.maskTextClass,c=void 0===l?"rr-mask":l,d=n.maskTextSelector,p=void 0===d?null:d,f=n.unmaskTextSelector,m=void 0===f?null:f,h=n.inlineStylesheet,v=void 0===h||h,y=n.inlineImages,S=void 0!==y&&y,g=n.recordCanvas,b=void 0!==g&&g,k=n.maskInputSelector,C=void 0===k?null:k,I=n.unmaskInputSelector,w=void 0===I?null:I,x=n.maskAllInputs,T=void 0!==x&&x,M=n.maskTextFn,E=n.maskInputFn,O=n.slimDOM,R=void 0!==O&&O,N=n.dataURLOptions,L=n.preserveWhiteSpace,D=n.onSerialize,F=n.onIframeLoad,A=n.iframeLoadTimeout,P=n.keepIframeSrcFn,z={};return[_(e,{doc:e,map:z,blockClass:o,blockSelector:i,unblockSelector:u,maskTextClass:c,maskTextSelector:p,unmaskTextSelector:m,skipChild:!1,inlineStylesheet:v,maskInputSelector:C,unmaskInputSelector:w,maskInputOptions:!0===T?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===T?{password:!0}:T,maskTextFn:M,maskInputFn:E,slimDOMOptions:!0===R||"all"===R?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===R,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===R?{}:R,dataURLOptions:N,inlineImages:S,recordCanvas:b,preserveWhiteSpace:L,onSerialize:D,onIframeLoad:F,iframeLoadTimeout:A,keepIframeSrcFn:void 0===P?function(){return!1}:P}),z]}(document,{blockClass:u,blockSelector:c,unblockSelector:p,maskTextClass:b,maskTextSelector:C,unmaskTextSelector:T,maskInputSelector:w,unmaskInputSelector:E,inlineStylesheet:R,maskAllInputs:se,maskTextFn:P,slimDOM:ue,recordCanvas:Y,inlineImages:ee,onSerialize:function(e){q(e)&&fe.addIframe(e),B(e)&&Se.addShadowRoot(e.shadowRoot,document)},onIframeLoad:function(e,t){fe.attachIframe(e,t),Se.observeAttachShadow(e)},keepIframeSrcFn:oe}),2),s=i[0],l=i[1];if(!s)return console.warn("Failed to snapshot the document");Re.map=l,Te(Oe({type:S.FullSnapshot,data:{node:s,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===document||void 0===document?void 0:document.body.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(a=null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.parentElement)||void 0===a?void 0:a.scrollTop)||(null===document||void 0===document?void 0:document.body.scrollTop)||0}}})),te.forEach((function(e){return e.unlock()}))};try{var ge=[];ge.push(L("DOMContentLoaded",(function(){Te(Oe({type:S.DomContentLoaded,data:{}}))})));var be=function(e){var n;return me({mutationCb:ce,mousemoveCb:function(e,t){return Te(Oe({type:S.IncrementalSnapshot,data:{source:t,positions:e}}))},mouseInteractionCb:function(e){return Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.MouseInteraction},e)}))},scrollCb:de,viewportResizeCb:function(e){return Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.ViewportResize},e)}))},inputCb:function(e){return Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.Input},e)}))},mediaInteractionCb:function(e){return Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.MediaInteraction},e)}))},styleSheetRuleCb:function(e){return Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.StyleSheetRule},e)}))},styleDeclarationCb:function(e){return Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.StyleDeclaration},e)}))},canvasMutationCb:pe,fontCb:function(e){return Te(Oe({type:S.IncrementalSnapshot,data:t({source:g.Font},e)}))},blockClass:u,ignoreClass:m,ignoreSelector:v,maskTextClass:b,maskTextSelector:C,unmaskTextSelector:T,maskInputSelector:w,unmaskInputSelector:E,maskInputOptions:se,inlineStylesheet:R,sampling:V,recordCanvas:Y,inlineImages:ee,userTriggeredOnInput:J,collectFonts:$,doc:e,maskInputFn:A,maskTextFn:P,blockSelector:c,unblockSelector:p,slimDOMOptions:ue,mirror:Re,iframeManager:fe,shadowDomManager:Se,canvasManager:ye,plugins:(null===(n=null==ne?void 0:ne.filter((function(e){return e.observer})))||void 0===n?void 0:n.map((function(e){return{observer:e.observer,options:e.options,callback:function(t){return Te(Oe({type:S.Plugin,data:{plugin:e.name,payload:t}}))}}})))||[]},z)};fe.addLoadListener((function(e){try{ge.push(be(e.contentDocument))}catch(e){console.warn(e)}}));var ke=function(){Me(),ge.push(be(document))};return"interactive"===document.readyState||"complete"===document.readyState?ke():ge.push(L("load",(function(){Te(Oe({type:S.Load,data:{}})),ke()}),window)),function(){ge.forEach((function(e){return e()}))}}catch(e){console.warn(e)}}return Ne.addCustomEvent=function(e,t){if(!Te)throw new Error("please add custom event after start recording");Te(Oe({type:S.Custom,data:{tag:e,payload:t}}))},Ne.freezePage=function(){te.forEach((function(e){return e.freeze()}))},Ne.takeFullSnapshot=function(e){if(!Me)throw new Error("please take full snapshot after start recording");Me(e)},Ne.mirror=Re,Ne}(); + //# sourceMappingURL=rrweb-record.min.js.map +diff --git a/node_modules/rrweb/dist/record/rrweb-record.min.js.map b/node_modules/rrweb/dist/record/rrweb-record.min.js.map +old mode 100644 +new mode 100755 +index 2262a48..cda0572 +--- a/node_modules/rrweb/dist/record/rrweb-record.min.js.map ++++ b/node_modules/rrweb/dist/record/rrweb-record.min.js.map +@@ -1 +1 @@ +-{"version":3,"file":"rrweb-record.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../src/types.ts","../../../src/utils.ts","../../../src/record/mutation.ts","../../../src/record/observer.ts","../../../src/record/iframe-manager.ts","../../../src/record/shadow-dom-manager.ts","../../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../../src/record/observers/canvas/serialize-args.ts","../../../src/record/observers/canvas/webgl.ts","../../../src/record/observers/canvas/canvas-manager.ts","../../../src/record/index.ts","../../../src/record/observers/canvas/canvas.ts","../../../src/record/observers/canvas/2d.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type]) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector) {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n ignoreClass?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n ignoreClass: string;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","import {\n INode,\n serializeNodeWithId,\n transformAttribute,\n IGNORED_NODE,\n isShadowRoot,\n needMaskingText,\n maskInputValue,\n} from 'rrweb-snapshot';\nimport {\n mutationRecord,\n textCursor,\n attributeCursor,\n removedNodeMutation,\n addedNodeMutation,\n Mirror,\n styleAttributeValue,\n observerParam,\n MutationBufferParam,\n Optional,\n} from '../types';\nimport {\n isBlocked,\n isAncestorRemoved,\n isIgnored,\n isIframeINode,\n hasShadowRoot,\n} from '../utils';\n\ntype DoubleLinkedListNode = {\n previous: DoubleLinkedListNode | null;\n next: DoubleLinkedListNode | null;\n value: NodeInLinkedList;\n};\ntype NodeInLinkedList = Node & {\n __ln: DoubleLinkedListNode;\n};\n\nfunction isNodeInLinkedList(n: Node | NodeInLinkedList): n is NodeInLinkedList {\n return '__ln' in n;\n}\nclass DoubleLinkedList {\n public length = 0;\n public head: DoubleLinkedListNode | null = null;\n\n public get(position: number) {\n if (position >= this.length) {\n throw new Error('Position outside of list range');\n }\n\n let current = this.head;\n for (let index = 0; index < position; index++) {\n current = current?.next || null;\n }\n return current;\n }\n\n public addNode(n: Node) {\n const node: DoubleLinkedListNode = {\n value: n as NodeInLinkedList,\n previous: null,\n next: null,\n };\n (n as NodeInLinkedList).__ln = node;\n if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {\n const current = n.previousSibling.__ln.next;\n node.next = current;\n node.previous = n.previousSibling.__ln;\n n.previousSibling.__ln.next = node;\n if (current) {\n current.previous = node;\n }\n } else if (\n n.nextSibling &&\n isNodeInLinkedList(n.nextSibling) &&\n n.nextSibling.__ln.previous\n ) {\n const current = n.nextSibling.__ln.previous;\n node.previous = current;\n node.next = n.nextSibling.__ln;\n n.nextSibling.__ln.previous = node;\n if (current) {\n current.next = node;\n }\n } else {\n if (this.head) {\n this.head.previous = node;\n }\n node.next = this.head;\n this.head = node;\n }\n this.length++;\n }\n\n public removeNode(n: NodeInLinkedList) {\n const current = n.__ln;\n if (!this.head) {\n return;\n }\n\n if (!current.previous) {\n this.head = current.next;\n if (this.head) {\n this.head.previous = null;\n }\n } else {\n current.previous.next = current.next;\n if (current.next) {\n current.next.previous = current.previous;\n }\n }\n if (n.__ln) {\n delete (n as Optional).__ln;\n }\n this.length--;\n }\n}\n\nconst moveKey = (id: number, parentId: number) => `${id}@${parentId}`;\nfunction isINode(n: Node | INode): n is INode {\n return '__sn' in n;\n}\n\n/**\n * controls behaviour of a MutationObserver\n */\nexport default class MutationBuffer {\n private frozen: boolean = false;\n private locked: boolean = false;\n\n private texts: textCursor[] = [];\n private attributes: attributeCursor[] = [];\n private removes: removedNodeMutation[] = [];\n private mapRemoves: Node[] = [];\n\n private movedMap: Record = {};\n\n /**\n * the browser MutationObserver emits multiple mutations after\n * a delay for performance reasons, making tracing added nodes hard\n * in our `processMutations` callback function.\n * For example, if we append an element el_1 into body, and then append\n * another element el_2 into el_1, these two mutations may be passed to the\n * callback function together when the two operations were done.\n * Generally we need to trace child nodes of newly added nodes, but in this\n * case if we count el_2 as el_1's child node in the first mutation record,\n * then we will count el_2 again in the second mutation record which was\n * duplicated.\n * To avoid of duplicate counting added nodes, we use a Set to store\n * added nodes and its child nodes during iterate mutation records. Then\n * collect added nodes from the Set which have no duplicate copy. But\n * this also causes newly added nodes will not be serialized with id ASAP,\n * which means all the id related calculation should be lazy too.\n */\n private addedSet = new Set();\n private movedSet = new Set();\n private droppedSet = new Set();\n\n private mutationCb: observerParam['mutationCb'];\n private blockClass: observerParam['blockClass'];\n private blockSelector: observerParam['blockSelector'];\n private maskTextClass: observerParam['maskTextClass'];\n private maskTextSelector: observerParam['maskTextSelector'];\n private inlineStylesheet: observerParam['inlineStylesheet'];\n private maskInputOptions: observerParam['maskInputOptions'];\n private maskTextFn: observerParam['maskTextFn'];\n private maskInputFn: observerParam['maskInputFn'];\n private recordCanvas: observerParam['recordCanvas'];\n private inlineImages: observerParam['inlineImages'];\n private slimDOMOptions: observerParam['slimDOMOptions'];\n private doc: observerParam['doc'];\n private mirror: observerParam['mirror'];\n private iframeManager: observerParam['iframeManager'];\n private shadowDomManager: observerParam['shadowDomManager'];\n private canvasManager: observerParam['canvasManager'];\n\n public init(options: MutationBufferParam) {\n ([\n 'mutationCb',\n 'blockClass',\n 'blockSelector',\n 'maskTextClass',\n 'maskTextSelector',\n 'inlineStylesheet',\n 'maskInputOptions',\n 'maskTextFn',\n 'maskInputFn',\n 'recordCanvas',\n 'inlineImages',\n 'slimDOMOptions',\n 'doc',\n 'mirror',\n 'iframeManager',\n 'shadowDomManager',\n 'canvasManager',\n ] as const).forEach((key) => {\n // just a type trick, the runtime result is correct\n this[key] = options[key] as never;\n });\n }\n\n public freeze() {\n this.frozen = true;\n this.canvasManager.freeze();\n }\n\n public unfreeze() {\n this.frozen = false;\n this.canvasManager.unfreeze();\n this.emit();\n }\n\n public isFrozen() {\n return this.frozen;\n }\n\n public lock() {\n this.locked = true;\n this.canvasManager.lock();\n }\n\n public unlock() {\n this.locked = false;\n this.canvasManager.unlock();\n this.emit();\n }\n\n public reset() {\n this.shadowDomManager.reset();\n this.canvasManager.reset();\n }\n\n public processMutations = (mutations: mutationRecord[]) => {\n mutations.forEach(this.processMutation); // adds mutations to the buffer\n this.emit(); // clears buffer if not locked/frozen\n };\n\n public emit = () => {\n if (this.frozen || this.locked) {\n return;\n }\n\n // delay any modification of the mirror until this function\n // so that the mirror for takeFullSnapshot doesn't get mutated while it's event is being processed\n\n const adds: addedNodeMutation[] = [];\n\n /**\n * Sometimes child node may be pushed before its newly added\n * parent, so we init a queue to store these nodes.\n */\n const addList = new DoubleLinkedList();\n const getNextId = (n: Node): number | null => {\n let ns: Node | null = n;\n let nextId: number | null = IGNORED_NODE; // slimDOM: ignored\n while (nextId === IGNORED_NODE) {\n ns = ns && ns.nextSibling;\n nextId = ns && this.mirror.getId((ns as unknown) as INode);\n }\n return nextId;\n };\n const pushAdd = (n: Node) => {\n const shadowHost: Element | null = n.getRootNode\n ? (n.getRootNode() as ShadowRoot)?.host\n : null;\n // If n is in a nested shadow dom.\n let rootShadowHost = shadowHost;\n while ((rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host)\n rootShadowHost =\n (rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host ||\n null;\n // ensure shadowHost is a Node, or doc.contains will throw an error\n const notInDoc =\n !this.doc.contains(n) &&\n (rootShadowHost === null || !this.doc.contains(rootShadowHost));\n if (!n.parentNode || notInDoc) {\n return;\n }\n const parentId = isShadowRoot(n.parentNode)\n ? this.mirror.getId((shadowHost as unknown) as INode)\n : this.mirror.getId((n.parentNode as Node) as INode);\n const nextId = getNextId(n);\n if (parentId === -1 || nextId === -1) {\n return addList.addNode(n);\n }\n let sn = serializeNodeWithId(n, {\n doc: this.doc,\n map: this.mirror.map,\n blockClass: this.blockClass,\n blockSelector: this.blockSelector,\n maskTextClass: this.maskTextClass,\n maskTextSelector: this.maskTextSelector,\n skipChild: true,\n inlineStylesheet: this.inlineStylesheet,\n maskInputOptions: this.maskInputOptions,\n maskTextFn: this.maskTextFn,\n maskInputFn: this.maskInputFn,\n slimDOMOptions: this.slimDOMOptions,\n recordCanvas: this.recordCanvas,\n inlineImages: this.inlineImages,\n onSerialize: (currentN) => {\n if (isIframeINode(currentN)) {\n this.iframeManager.addIframe(currentN);\n }\n if (hasShadowRoot(n)) {\n this.shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n this.iframeManager.attachIframe(iframe, childSn);\n this.shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n });\n if (sn) {\n adds.push({\n parentId,\n nextId,\n node: sn,\n });\n }\n };\n\n while (this.mapRemoves.length) {\n this.mirror.removeNodeFromMap(this.mapRemoves.shift() as INode);\n }\n\n for (const n of this.movedSet) {\n if (\n isParentRemoved(this.removes, n, this.mirror) &&\n !this.movedSet.has(n.parentNode!)\n ) {\n continue;\n }\n pushAdd(n);\n }\n\n for (const n of this.addedSet) {\n if (\n !isAncestorInSet(this.droppedSet, n) &&\n !isParentRemoved(this.removes, n, this.mirror)\n ) {\n pushAdd(n);\n } else if (isAncestorInSet(this.movedSet, n)) {\n pushAdd(n);\n } else {\n this.droppedSet.add(n);\n }\n }\n\n let candidate: DoubleLinkedListNode | null = null;\n while (addList.length) {\n let node: DoubleLinkedListNode | null = null;\n if (candidate) {\n const parentId = this.mirror.getId(\n (candidate.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(candidate.value);\n if (parentId !== -1 && nextId !== -1) {\n node = candidate;\n }\n }\n if (!node) {\n for (let index = addList.length - 1; index >= 0; index--) {\n const _node = addList.get(index)!;\n // ensure _node is defined before attempting to find value\n if (_node) {\n const parentId = this.mirror.getId(\n (_node.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(_node.value);\n if (parentId !== -1 && nextId !== -1) {\n node = _node;\n break;\n }\n }\n }\n }\n if (!node) {\n /**\n * If all nodes in queue could not find a serialized parent,\n * it may be a bug or corner case. We need to escape the\n * dead while loop at once.\n */\n while (addList.head) {\n addList.removeNode(addList.head.value);\n }\n break;\n }\n candidate = node.previous;\n addList.removeNode(node.value);\n pushAdd(node.value);\n }\n\n const payload = {\n texts: this.texts\n .map((text) => ({\n id: this.mirror.getId(text.node as INode),\n value: text.value,\n }))\n // text mutation's id was not in the mirror map means the target node has been removed\n .filter((text) => this.mirror.has(text.id)),\n attributes: this.attributes\n .map((attribute) => ({\n id: this.mirror.getId(attribute.node as INode),\n attributes: attribute.attributes,\n }))\n // attribute mutation's id was not in the mirror map means the target node has been removed\n .filter((attribute) => this.mirror.has(attribute.id)),\n removes: this.removes,\n adds,\n };\n // payload may be empty if the mutations happened in some blocked elements\n if (\n !payload.texts.length &&\n !payload.attributes.length &&\n !payload.removes.length &&\n !payload.adds.length\n ) {\n return;\n }\n\n // reset\n this.texts = [];\n this.attributes = [];\n this.removes = [];\n this.addedSet = new Set();\n this.movedSet = new Set();\n this.droppedSet = new Set();\n this.movedMap = {};\n\n this.mutationCb(payload);\n };\n\n private processMutation = (m: mutationRecord) => {\n if (isIgnored(m.target)) {\n return;\n }\n switch (m.type) {\n case 'characterData': {\n const value = m.target.textContent;\n if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {\n this.texts.push({\n value:\n needMaskingText(\n m.target,\n this.maskTextClass,\n this.maskTextSelector,\n ) && value\n ? this.maskTextFn\n ? this.maskTextFn(value)\n : value.replace(/[\\S]/g, '*')\n : value,\n node: m.target,\n });\n }\n break;\n }\n case 'attributes': {\n const target = m.target as HTMLElement;\n let value = (m.target as HTMLElement).getAttribute(m.attributeName!);\n if (m.attributeName === 'value') {\n value = maskInputValue({\n maskInputOptions: this.maskInputOptions,\n tagName: (m.target as HTMLElement).tagName,\n type: (m.target as HTMLElement).getAttribute('type'),\n value,\n maskInputFn: this.maskInputFn,\n });\n }\n if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {\n return;\n }\n let item: attributeCursor | undefined = this.attributes.find(\n (a) => a.node === m.target,\n );\n if (!item) {\n item = {\n node: m.target,\n attributes: {},\n };\n this.attributes.push(item);\n }\n if (m.attributeName === 'style') {\n const old = this.doc.createElement('span');\n if (m.oldValue) {\n old.setAttribute('style', m.oldValue);\n }\n if (\n item.attributes.style === undefined ||\n item.attributes.style === null\n ) {\n item.attributes.style = {};\n }\n const styleObj = item.attributes.style as styleAttributeValue;\n for (const pname of Array.from(target.style)) {\n const newValue = target.style.getPropertyValue(pname);\n const newPriority = target.style.getPropertyPriority(pname);\n if (\n newValue !== old.style.getPropertyValue(pname) ||\n newPriority !== old.style.getPropertyPriority(pname)\n ) {\n if (newPriority === '') {\n styleObj[pname] = newValue;\n } else {\n styleObj[pname] = [newValue, newPriority];\n }\n }\n }\n for (const pname of Array.from(old.style)) {\n if (target.style.getPropertyValue(pname) === '') {\n // \"if not set, returns the empty string\"\n styleObj[pname] = false; // delete\n }\n }\n } else {\n // overwrite attribute if the mutations was triggered in same time\n item.attributes[m.attributeName!] = transformAttribute(\n this.doc,\n (m.target as HTMLElement).tagName,\n m.attributeName!,\n value!,\n );\n }\n break;\n }\n case 'childList': {\n m.addedNodes.forEach((n) => this.genAdds(n, m.target));\n m.removedNodes.forEach((n) => {\n const nodeId = this.mirror.getId(n as INode);\n const parentId = isShadowRoot(m.target)\n ? this.mirror.getId((m.target.host as unknown) as INode)\n : this.mirror.getId(m.target as INode);\n if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {\n return;\n }\n // removed node has not been serialized yet, just remove it from the Set\n if (this.addedSet.has(n)) {\n deepDelete(this.addedSet, n);\n this.droppedSet.add(n);\n } else if (this.addedSet.has(m.target) && nodeId === -1) {\n /**\n * If target was newly added and removed child node was\n * not serialized, it means the child node has been removed\n * before callback fired, so we can ignore it because\n * newly added node will be serialized without child nodes.\n * TODO: verify this\n */\n } else if (isAncestorRemoved(m.target as INode, this.mirror)) {\n /**\n * If parent id was not in the mirror map any more, it\n * means the parent node has already been removed. So\n * the node is also removed which we do not need to track\n * and replay.\n */\n } else if (\n this.movedSet.has(n) &&\n this.movedMap[moveKey(nodeId, parentId)]\n ) {\n deepDelete(this.movedSet, n);\n } else {\n this.removes.push({\n parentId,\n id: nodeId,\n isShadow: isShadowRoot(m.target) ? true : undefined,\n });\n }\n this.mapRemoves.push(n);\n });\n break;\n }\n default:\n break;\n }\n };\n\n private genAdds = (n: Node | INode, target?: Node | INode) => {\n // parent was blocked, so we can ignore this node\n if (target && isBlocked(target, this.blockClass)) {\n return;\n }\n if (isINode(n)) {\n if (isIgnored(n)) {\n return;\n }\n this.movedSet.add(n);\n let targetId: number | null = null;\n if (target && isINode(target)) {\n targetId = target.__sn.id;\n }\n if (targetId) {\n this.movedMap[moveKey(n.__sn.id, targetId)] = true;\n }\n } else {\n this.addedSet.add(n);\n this.droppedSet.delete(n);\n }\n\n // if this node is blocked `serializeNode` will turn it into a placeholder element\n // but we have to remove it's children otherwise they will be added as placeholders too\n if (!isBlocked(n, this.blockClass))\n n.childNodes.forEach((childN) => this.genAdds(childN));\n };\n}\n\n/**\n * Some utils to handle the mutation observer DOM records.\n * It should be more clear to extend the native data structure\n * like Set and Map, but currently Typescript does not support\n * that.\n */\nfunction deepDelete(addsSet: Set, n: Node) {\n addsSet.delete(n);\n n.childNodes.forEach((childN) => deepDelete(addsSet, childN));\n}\n\nfunction isParentRemoved(\n removes: removedNodeMutation[],\n n: Node,\n mirror: Mirror,\n): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n const parentId = mirror.getId((parentNode as Node) as INode);\n if (removes.some((r) => r.id === parentId)) {\n return true;\n }\n return isParentRemoved(removes, parentNode, mirror);\n}\n\nfunction isAncestorInSet(set: Set, n: Node): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n if (set.has(parentNode)) {\n return true;\n }\n return isAncestorInSet(set, parentNode);\n}\n","import { INode, MaskInputOptions, maskInputValue } from 'rrweb-snapshot';\nimport { FontFaceSet } from 'css-font-loading-module';\nimport {\n throttle,\n on,\n hookSetter,\n getWindowHeight,\n getWindowWidth,\n isBlocked,\n isTouchEvent,\n patch,\n} from '../utils';\nimport {\n mutationCallBack,\n observerParam,\n mousemoveCallBack,\n mousePosition,\n mouseInteractionCallBack,\n MouseInteractions,\n listenerHandler,\n scrollCallback,\n styleSheetRuleCallback,\n viewportResizeCallback,\n inputValue,\n inputCallback,\n hookResetter,\n IncrementalSource,\n hooksParam,\n Arguments,\n mediaInteractionCallback,\n MediaInteractions,\n canvasMutationCallback,\n fontCallback,\n fontParam,\n styleDeclarationCallback,\n IWindow,\n MutationBufferParam,\n} from '../types';\nimport MutationBuffer from './mutation';\n\ntype WindowWithStoredMutationObserver = IWindow & {\n __rrMutationObserver?: MutationObserver;\n};\ntype WindowWithAngularZone = IWindow & {\n Zone?: {\n __symbol__?: (key: string) => string;\n };\n};\n\nexport const mutationBuffers: MutationBuffer[] = [];\n\nconst isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';\nconst isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';\nconst isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';\nconst isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';\n\n// Event.path is non-standard and used in some older browsers\ntype NonStandardEvent = Omit & {\n path: EventTarget[];\n};\n\nfunction getEventTarget(event: Event | NonStandardEvent): EventTarget | null {\n try {\n if ('composedPath' in event) {\n const path = event.composedPath();\n if (path.length) {\n return path[0];\n }\n } else if ('path' in event && event.path.length) {\n return event.path[0];\n }\n return event.target;\n } catch {\n return event.target;\n }\n}\n\nexport function initMutationObserver(\n options: MutationBufferParam,\n rootEl: Node,\n): MutationObserver {\n const mutationBuffer = new MutationBuffer();\n mutationBuffers.push(mutationBuffer);\n // see mutation.ts for details\n mutationBuffer.init(options);\n let mutationObserverCtor =\n window.MutationObserver ||\n /**\n * Some websites may disable MutationObserver by removing it from the window object.\n * If someone is using rrweb to build a browser extention or things like it, they\n * could not change the website's code but can have an opportunity to inject some\n * code before the website executing its JS logic.\n * Then they can do this to store the native MutationObserver:\n * window.__rrMutationObserver = MutationObserver\n */\n (window as WindowWithStoredMutationObserver).__rrMutationObserver;\n const angularZoneSymbol = (window as WindowWithAngularZone)?.Zone?.__symbol__?.(\n 'MutationObserver',\n );\n if (\n angularZoneSymbol &&\n ((window as unknown) as Record)[\n angularZoneSymbol\n ]\n ) {\n mutationObserverCtor = ((window as unknown) as Record<\n string,\n typeof MutationObserver\n >)[angularZoneSymbol];\n }\n const observer = new mutationObserverCtor(\n mutationBuffer.processMutations.bind(mutationBuffer),\n );\n observer.observe(rootEl, {\n attributes: true,\n attributeOldValue: true,\n characterData: true,\n characterDataOldValue: true,\n childList: true,\n subtree: true,\n });\n return observer;\n}\n\nfunction initMoveObserver({\n mousemoveCb,\n sampling,\n doc,\n mirror,\n}: observerParam): listenerHandler {\n if (sampling.mousemove === false) {\n return () => {};\n }\n\n const threshold =\n typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;\n const callbackThreshold =\n typeof sampling.mousemoveCallback === 'number'\n ? sampling.mousemoveCallback\n : 500;\n\n let positions: mousePosition[] = [];\n let timeBaseline: number | null;\n const wrappedCb = throttle(\n (\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n ) => {\n const totalOffset = Date.now() - timeBaseline!;\n mousemoveCb(\n positions.map((p) => {\n p.timeOffset -= totalOffset;\n return p;\n }),\n source,\n );\n positions = [];\n timeBaseline = null;\n },\n callbackThreshold,\n );\n const updatePosition = throttle(\n (evt) => {\n const target = getEventTarget(evt);\n const { clientX, clientY } = isTouchEvent(evt)\n ? evt.changedTouches[0]\n : evt;\n if (!timeBaseline) {\n timeBaseline = Date.now();\n }\n positions.push({\n x: clientX,\n y: clientY,\n id: mirror.getId(target as INode),\n timeOffset: Date.now() - timeBaseline,\n });\n // it is possible DragEvent is undefined even on devices\n // that support event 'drag'\n wrappedCb(\n typeof DragEvent !== 'undefined' && evt instanceof DragEvent\n ? IncrementalSource.Drag\n : evt instanceof MouseEvent\n ? IncrementalSource.MouseMove\n : IncrementalSource.TouchMove,\n );\n },\n threshold,\n {\n trailing: false,\n },\n );\n const handlers = [\n on('mousemove', updatePosition, doc),\n on('touchmove', updatePosition, doc),\n on('drag', updatePosition, doc),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initMouseInteractionObserver({\n mouseInteractionCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: observerParam): listenerHandler {\n if (sampling.mouseInteraction === false) {\n return () => {};\n }\n const disableMap: Record =\n sampling.mouseInteraction === true ||\n sampling.mouseInteraction === undefined\n ? {}\n : sampling.mouseInteraction;\n\n const handlers: listenerHandler[] = [];\n const getHandler = (eventKey: keyof typeof MouseInteractions) => {\n return (event: MouseEvent | TouchEvent) => {\n const target = getEventTarget(event) as Node;\n if (isBlocked(target as Node, blockClass)) {\n return;\n }\n const e = isTouchEvent(event) ? event.changedTouches[0] : event;\n if (!e) {\n return;\n }\n const id = mirror.getId(target as INode);\n const { clientX, clientY } = e;\n mouseInteractionCb({\n type: MouseInteractions[eventKey],\n id,\n x: clientX,\n y: clientY,\n });\n };\n };\n Object.keys(MouseInteractions)\n .filter(\n (key) =>\n Number.isNaN(Number(key)) &&\n !key.endsWith('_Departed') &&\n disableMap[key] !== false,\n )\n .forEach((eventKey: keyof typeof MouseInteractions) => {\n const eventName = eventKey.toLowerCase();\n const handler = getHandler(eventKey);\n handlers.push(on(eventName, handler, doc));\n });\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nexport function initScrollObserver({\n scrollCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: Pick<\n observerParam,\n 'scrollCb' | 'doc' | 'mirror' | 'blockClass' | 'sampling'\n>): listenerHandler {\n const updatePosition = throttle((evt) => {\n const target = getEventTarget(evt);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const id = mirror.getId(target as INode);\n if (target === doc) {\n const scrollEl = (doc.scrollingElement || doc.documentElement)!;\n scrollCb({\n id,\n x: scrollEl.scrollLeft,\n y: scrollEl.scrollTop,\n });\n } else {\n scrollCb({\n id,\n x: (target as HTMLElement).scrollLeft,\n y: (target as HTMLElement).scrollTop,\n });\n }\n }, sampling.scroll || 100);\n return on('scroll', updatePosition, doc);\n}\n\nfunction initViewportResizeObserver({\n viewportResizeCb,\n}: observerParam): listenerHandler {\n let lastH = -1;\n let lastW = -1;\n const updateDimension = throttle(() => {\n const height = getWindowHeight();\n const width = getWindowWidth();\n if (lastH !== height || lastW !== width) {\n viewportResizeCb({\n width: Number(width),\n height: Number(height),\n });\n lastH = height;\n lastW = width;\n }\n }, 200);\n return on('resize', updateDimension, window);\n}\n\nfunction wrapEventWithUserTriggeredFlag(\n v: inputValue,\n enable: boolean,\n): inputValue {\n const value = { ...v };\n if (!enable) delete value.userTriggered;\n return value;\n}\n\nexport const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];\nconst lastInputValueMap: WeakMap = new WeakMap();\nfunction initInputObserver({\n inputCb,\n doc,\n mirror,\n blockClass,\n ignoreClass,\n maskInputOptions,\n maskInputFn,\n sampling,\n userTriggeredOnInput,\n}: observerParam): listenerHandler {\n function eventHandler(event: Event) {\n let target = getEventTarget(event);\n const userTriggered = event.isTrusted;\n /**\n * If a site changes the value 'selected' of an option element, the value of its parent element, usually a select element, will be changed as well.\n * We can treat this change as a value change of the select element the current target belongs to.\n */\n if (target && (target as Element).tagName === 'OPTION')\n target = (target as Element).parentElement;\n if (\n !target ||\n !(target as Element).tagName ||\n INPUT_TAGS.indexOf((target as Element).tagName) < 0 ||\n isBlocked(target as Node, blockClass)\n ) {\n return;\n }\n const type: string | undefined = (target as HTMLInputElement).type;\n if ((target as HTMLElement).classList.contains(ignoreClass)) {\n return;\n }\n let text = (target as HTMLInputElement).value;\n let isChecked = false;\n if (type === 'radio' || type === 'checkbox') {\n isChecked = (target as HTMLInputElement).checked;\n } else if (\n maskInputOptions[\n (target as Element).tagName.toLowerCase() as keyof MaskInputOptions\n ] ||\n maskInputOptions[type as keyof MaskInputOptions]\n ) {\n text = maskInputValue({\n maskInputOptions,\n tagName: (target as HTMLElement).tagName,\n type,\n value: text,\n maskInputFn,\n });\n }\n cbWithDedup(\n target,\n wrapEventWithUserTriggeredFlag(\n { text, isChecked, userTriggered },\n userTriggeredOnInput,\n ),\n );\n // if a radio was checked\n // the other radios with the same name attribute will be unchecked.\n const name: string | undefined = (target as HTMLInputElement).name;\n if (type === 'radio' && name && isChecked) {\n doc\n .querySelectorAll(`input[type=\"radio\"][name=\"${name}\"]`)\n .forEach((el) => {\n if (el !== target) {\n cbWithDedup(\n el,\n wrapEventWithUserTriggeredFlag(\n {\n text: (el as HTMLInputElement).value,\n isChecked: !isChecked,\n userTriggered: false,\n },\n userTriggeredOnInput,\n ),\n );\n }\n });\n }\n }\n function cbWithDedup(target: EventTarget, v: inputValue) {\n const lastInputValue = lastInputValueMap.get(target);\n if (\n !lastInputValue ||\n lastInputValue.text !== v.text ||\n lastInputValue.isChecked !== v.isChecked\n ) {\n lastInputValueMap.set(target, v);\n const id = mirror.getId(target as INode);\n inputCb({\n ...v,\n id,\n });\n }\n }\n const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];\n const handlers: Array<\n listenerHandler | hookResetter\n > = events.map((eventName) => on(eventName, eventHandler, doc));\n const propertyDescriptor = Object.getOwnPropertyDescriptor(\n HTMLInputElement.prototype,\n 'value',\n );\n const hookProperties: Array<[HTMLElement, string]> = [\n [HTMLInputElement.prototype, 'value'],\n [HTMLInputElement.prototype, 'checked'],\n [HTMLSelectElement.prototype, 'value'],\n [HTMLTextAreaElement.prototype, 'value'],\n // Some UI library use selectedIndex to set select value\n [HTMLSelectElement.prototype, 'selectedIndex'],\n [HTMLOptionElement.prototype, 'selected'],\n ];\n if (propertyDescriptor && propertyDescriptor.set) {\n handlers.push(\n ...hookProperties.map((p) =>\n hookSetter(p[0], p[1], {\n set() {\n // mock to a normal event\n eventHandler({ target: this } as Event);\n },\n }),\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\ntype GroupingCSSRule =\n | CSSGroupingRule\n | CSSMediaRule\n | CSSSupportsRule\n | CSSConditionRule;\ntype GroupingCSSRuleTypes =\n | typeof CSSGroupingRule\n | typeof CSSMediaRule\n | typeof CSSSupportsRule\n | typeof CSSConditionRule;\n\nfunction getNestedCSSRulePositions(rule: CSSRule): number[] {\n const positions: number[] = [];\n function recurse(childRule: CSSRule, pos: number[]) {\n if (\n (isCSSGroupingRuleSupported &&\n childRule.parentRule instanceof CSSGroupingRule) ||\n (isCSSMediaRuleSupported &&\n childRule.parentRule instanceof CSSMediaRule) ||\n (isCSSSupportsRuleSupported &&\n childRule.parentRule instanceof CSSSupportsRule) ||\n (isCSSConditionRuleSupported &&\n childRule.parentRule instanceof CSSConditionRule)\n ) {\n const rules = Array.from(\n (childRule.parentRule as GroupingCSSRule).cssRules,\n );\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n } else {\n const rules = Array.from(childRule.parentStyleSheet!.cssRules);\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n }\n return pos;\n }\n return recurse(rule, positions);\n}\n\nfunction initStyleSheetObserver(\n { styleSheetRuleCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n const insertRule = win.CSSStyleSheet.prototype.insertRule;\n win.CSSStyleSheet.prototype.insertRule = function (\n rule: string,\n index?: number,\n ) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [{ rule, index }],\n });\n }\n return insertRule.apply(this, arguments);\n };\n\n const deleteRule = win.CSSStyleSheet.prototype.deleteRule;\n win.CSSStyleSheet.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index }],\n });\n }\n return deleteRule.apply(this, arguments);\n };\n\n const supportedNestedCSSRuleTypes: {\n [key: string]: GroupingCSSRuleTypes;\n } = {};\n if (isCSSGroupingRuleSupported) {\n supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;\n } else {\n // Some browsers (Safari) don't support CSSGroupingRule\n // https://caniuse.com/?search=cssgroupingrule\n // fall back to monkey patching classes that would have inherited from CSSGroupingRule\n\n if (isCSSMediaRuleSupported) {\n supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;\n }\n if (isCSSConditionRuleSupported) {\n supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;\n }\n if (isCSSSupportsRuleSupported) {\n supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;\n }\n }\n\n const unmodifiedFunctions: {\n [key: string]: {\n insertRule: (rule: string, index?: number) => number;\n deleteRule: (index: number) => void;\n };\n } = {};\n\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n unmodifiedFunctions[typeKey] = {\n insertRule: (type as GroupingCSSRuleTypes).prototype.insertRule,\n deleteRule: (type as GroupingCSSRuleTypes).prototype.deleteRule,\n };\n\n type.prototype.insertRule = function (rule: string, index?: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [\n {\n rule,\n index: [\n ...getNestedCSSRulePositions(this),\n index || 0, // defaults to 0\n ],\n },\n ],\n });\n }\n return unmodifiedFunctions[typeKey].insertRule.apply(this, arguments);\n };\n\n type.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index: [...getNestedCSSRulePositions(this), index] }],\n });\n }\n return unmodifiedFunctions[typeKey].deleteRule.apply(this, arguments);\n };\n });\n\n return () => {\n win.CSSStyleSheet.prototype.insertRule = insertRule;\n win.CSSStyleSheet.prototype.deleteRule = deleteRule;\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;\n type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;\n });\n };\n}\n\nfunction initStyleDeclarationObserver(\n { styleDeclarationCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n const setProperty = win.CSSStyleDeclaration.prototype.setProperty;\n win.CSSStyleDeclaration.prototype.setProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n value: string,\n priority: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n set: {\n property,\n value,\n priority,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return setProperty.apply(this, arguments);\n };\n\n const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n remove: {\n property,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return removeProperty.apply(this, arguments);\n };\n\n return () => {\n win.CSSStyleDeclaration.prototype.setProperty = setProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;\n };\n}\n\nfunction initMediaInteractionObserver({\n mediaInteractionCb,\n blockClass,\n mirror,\n sampling,\n}: observerParam): listenerHandler {\n const handler = (type: MediaInteractions) =>\n throttle((event: Event) => {\n const target = getEventTarget(event);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const { currentTime, volume, muted } = target as HTMLMediaElement;\n mediaInteractionCb({\n type,\n id: mirror.getId(target as INode),\n currentTime,\n volume,\n muted,\n });\n }, sampling.media || 500);\n const handlers = [\n on('play', handler(MediaInteractions.Play)),\n on('pause', handler(MediaInteractions.Pause)),\n on('seeked', handler(MediaInteractions.Seeked)),\n on('volumechange', handler(MediaInteractions.VolumeChange)),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initFontObserver({ fontCb, doc }: observerParam): listenerHandler {\n const win = doc.defaultView as IWindow;\n if (!win) {\n return () => {};\n }\n\n const handlers: listenerHandler[] = [];\n\n const fontMap = new WeakMap();\n\n const originalFontFace = win.FontFace;\n win.FontFace = (function FontFace(\n family: string,\n source: string | ArrayBufferView,\n descriptors?: FontFaceDescriptors,\n ) {\n const fontFace = new originalFontFace(family, source, descriptors);\n fontMap.set(fontFace, {\n family,\n buffer: typeof source !== 'string',\n descriptors,\n fontSource:\n typeof source === 'string'\n ? source\n : // tslint:disable-next-line: no-any\n JSON.stringify(Array.from(new Uint8Array(source as any))),\n });\n return fontFace;\n } as unknown) as typeof FontFace;\n\n const restoreHandler = patch(doc.fonts, 'add', function (original) {\n return function (this: FontFaceSet, fontFace: FontFace) {\n setTimeout(() => {\n const p = fontMap.get(fontFace);\n if (p) {\n fontCb(p);\n fontMap.delete(fontFace);\n }\n }, 0);\n return original.apply(this, [fontFace]);\n };\n });\n\n handlers.push(() => {\n win.FontFace = originalFontFace;\n });\n handlers.push(restoreHandler);\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction mergeHooks(o: observerParam, hooks: hooksParam) {\n const {\n mutationCb,\n mousemoveCb,\n mouseInteractionCb,\n scrollCb,\n viewportResizeCb,\n inputCb,\n mediaInteractionCb,\n styleSheetRuleCb,\n styleDeclarationCb,\n canvasMutationCb,\n fontCb,\n } = o;\n o.mutationCb = (...p: Arguments) => {\n if (hooks.mutation) {\n hooks.mutation(...p);\n }\n mutationCb(...p);\n };\n o.mousemoveCb = (...p: Arguments) => {\n if (hooks.mousemove) {\n hooks.mousemove(...p);\n }\n mousemoveCb(...p);\n };\n o.mouseInteractionCb = (...p: Arguments) => {\n if (hooks.mouseInteraction) {\n hooks.mouseInteraction(...p);\n }\n mouseInteractionCb(...p);\n };\n o.scrollCb = (...p: Arguments) => {\n if (hooks.scroll) {\n hooks.scroll(...p);\n }\n scrollCb(...p);\n };\n o.viewportResizeCb = (...p: Arguments) => {\n if (hooks.viewportResize) {\n hooks.viewportResize(...p);\n }\n viewportResizeCb(...p);\n };\n o.inputCb = (...p: Arguments) => {\n if (hooks.input) {\n hooks.input(...p);\n }\n inputCb(...p);\n };\n o.mediaInteractionCb = (...p: Arguments) => {\n if (hooks.mediaInteaction) {\n hooks.mediaInteaction(...p);\n }\n mediaInteractionCb(...p);\n };\n o.styleSheetRuleCb = (...p: Arguments) => {\n if (hooks.styleSheetRule) {\n hooks.styleSheetRule(...p);\n }\n styleSheetRuleCb(...p);\n };\n o.styleDeclarationCb = (...p: Arguments) => {\n if (hooks.styleDeclaration) {\n hooks.styleDeclaration(...p);\n }\n styleDeclarationCb(...p);\n };\n o.canvasMutationCb = (...p: Arguments) => {\n if (hooks.canvasMutation) {\n hooks.canvasMutation(...p);\n }\n canvasMutationCb(...p);\n };\n o.fontCb = (...p: Arguments) => {\n if (hooks.font) {\n hooks.font(...p);\n }\n fontCb(...p);\n };\n}\n\nexport function initObservers(\n o: observerParam,\n hooks: hooksParam = {},\n): listenerHandler {\n const currentWindow = o.doc.defaultView; // basically document.window\n if (!currentWindow) {\n return () => {};\n }\n\n mergeHooks(o, hooks);\n const mutationObserver = initMutationObserver(o, o.doc);\n const mousemoveHandler = initMoveObserver(o);\n const mouseInteractionHandler = initMouseInteractionObserver(o);\n const scrollHandler = initScrollObserver(o);\n const viewportResizeHandler = initViewportResizeObserver(o);\n const inputHandler = initInputObserver(o);\n const mediaInteractionHandler = initMediaInteractionObserver(o);\n\n const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });\n const styleDeclarationObserver = initStyleDeclarationObserver(o, {\n win: currentWindow,\n });\n const fontObserver = o.collectFonts ? initFontObserver(o) : () => {};\n // plugins\n const pluginHandlers: listenerHandler[] = [];\n for (const plugin of o.plugins) {\n pluginHandlers.push(\n plugin.observer(plugin.callback, currentWindow, plugin.options),\n );\n }\n\n return () => {\n mutationBuffers.forEach((b) => b.reset());\n mutationObserver.disconnect();\n mousemoveHandler();\n mouseInteractionHandler();\n scrollHandler();\n viewportResizeHandler();\n inputHandler();\n mediaInteractionHandler();\n styleSheetObserver();\n styleDeclarationObserver();\n fontObserver();\n pluginHandlers.forEach((h) => h());\n };\n}\n","import { serializedNodeWithId, INode } from 'rrweb-snapshot';\nimport { mutationCallBack } from '../types';\n\nexport class IframeManager {\n private iframes: WeakMap = new WeakMap();\n private mutationCb: mutationCallBack;\n private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;\n\n constructor(options: { mutationCb: mutationCallBack }) {\n this.mutationCb = options.mutationCb;\n }\n\n public addIframe(iframeEl: HTMLIFrameElement) {\n this.iframes.set(iframeEl, true);\n }\n\n public addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown) {\n this.loadListener = cb;\n }\n\n public attachIframe(iframeEl: INode, childSn: serializedNodeWithId) {\n this.mutationCb({\n adds: [\n {\n parentId: iframeEl.__sn.id,\n nextId: null,\n node: childSn,\n },\n ],\n removes: [],\n texts: [],\n attributes: [],\n isAttachIframe: true,\n });\n this.loadListener?.((iframeEl as unknown) as HTMLIFrameElement);\n }\n}\n","import {\n mutationCallBack,\n Mirror,\n scrollCallback,\n MutationBufferParam,\n SamplingStrategy,\n} from '../types';\nimport { initMutationObserver, initScrollObserver } from './observer';\nimport { patch } from '../utils';\n\ntype BypassOptions = Omit<\n MutationBufferParam,\n 'doc' | 'mutationCb' | 'mirror' | 'shadowDomManager'\n> & {\n sampling: SamplingStrategy;\n};\n\nexport class ShadowDomManager {\n private mutationCb: mutationCallBack;\n private scrollCb: scrollCallback;\n private bypassOptions: BypassOptions;\n private mirror: Mirror;\n private restorePatches: (() => void)[] = [];\n\n constructor(options: {\n mutationCb: mutationCallBack;\n scrollCb: scrollCallback;\n bypassOptions: BypassOptions;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.scrollCb = options.scrollCb;\n this.bypassOptions = options.bypassOptions;\n this.mirror = options.mirror;\n\n // Patch 'attachShadow' to observe newly added shadow doms.\n const manager = this;\n this.restorePatches.push(\n patch(HTMLElement.prototype, 'attachShadow', function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(this.shadowRoot, this.ownerDocument);\n return shadowRoot;\n };\n }),\n );\n }\n\n public addShadowRoot(shadowRoot: ShadowRoot, doc: Document) {\n initMutationObserver(\n {\n ...this.bypassOptions,\n doc,\n mutationCb: this.mutationCb,\n mirror: this.mirror,\n shadowDomManager: this,\n },\n shadowRoot,\n );\n initScrollObserver({\n ...this.bypassOptions,\n scrollCb: this.scrollCb,\n // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813\n // scroll is not allowed to pass the boundary, so we need to listen the shadow document\n doc: (shadowRoot as unknown) as Document,\n mirror: this.mirror,\n });\n }\n\n /**\n * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.\n */\n public observeAttachShadow(iframeElement: HTMLIFrameElement) {\n if (iframeElement.contentWindow) {\n const manager = this;\n this.restorePatches.push(\n patch(\n (iframeElement.contentWindow as Window & {\n HTMLElement: { prototype: HTMLElement };\n }).HTMLElement.prototype,\n 'attachShadow',\n function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(\n this.shadowRoot,\n iframeElement.contentDocument as Document,\n );\n return shadowRoot;\n };\n },\n ),\n );\n }\n }\n\n public reset() {\n this.restorePatches.forEach((restorePatch) => restorePatch());\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { encode } from 'base64-arraybuffer';\nimport { IWindow, SerializedWebGlArg } from '../../../types';\n\n// TODO: unify with `replay/webgl.ts`\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nexport const saveWebGLVar = (\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): number | void => {\n if (\n !value ||\n !(isInstanceOfWebGLObject(value, win) || typeof value === 'object')\n )\n return;\n\n const name = value.constructor.name;\n const list = variableListFor(ctx, name);\n let index = list.indexOf(value);\n\n if (index === -1) {\n index = list.length;\n list.push(value);\n }\n return index;\n};\n\n// from webgl-recorder: https://github.com/evanw/webgl-recorder/blob/bef0e65596e981ee382126587e2dcbe0fc7748e2/webgl-recorder.js#L50-L77\nexport function serializeArg(\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): SerializedWebGlArg {\n if (value instanceof Array) {\n return value.map((arg) => serializeArg(arg, win, ctx));\n } else if (value === null) {\n return value;\n } else if (\n value instanceof Float32Array ||\n value instanceof Float64Array ||\n value instanceof Int32Array ||\n value instanceof Uint32Array ||\n value instanceof Uint8Array ||\n value instanceof Uint16Array ||\n value instanceof Int16Array ||\n value instanceof Int8Array ||\n value instanceof Uint8ClampedArray\n ) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [Object.values(value)],\n };\n } else if (\n // SharedArrayBuffer disabled on most browsers due to spectre.\n // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer\n // value instanceof SharedArrayBuffer ||\n value instanceof ArrayBuffer\n ) {\n const name = value.constructor.name as 'ArrayBuffer';\n const base64 = encode(value);\n\n return {\n rr_type: name,\n base64,\n };\n } else if (value instanceof DataView) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [\n serializeArg(value.buffer, win, ctx),\n value.byteOffset,\n value.byteLength,\n ],\n };\n } else if (value instanceof HTMLImageElement) {\n const name = value.constructor.name;\n const { src } = value;\n return {\n rr_type: name,\n src,\n };\n } else if (value instanceof ImageData) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [serializeArg(value.data, win, ctx), value.width, value.height],\n };\n } else if (isInstanceOfWebGLObject(value, win) || typeof value === 'object') {\n const name = value.constructor.name;\n const index = saveWebGLVar(value, win, ctx) as number;\n\n return {\n rr_type: name,\n index: index,\n };\n }\n\n return value;\n}\n\nexport const serializeArgs = (\n args: Array,\n win: IWindow,\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n) => {\n return [...args].map((arg) => serializeArg(arg, win, ctx));\n};\n\nexport const isInstanceOfWebGLObject = (\n value: any,\n win: IWindow,\n): value is\n | WebGLActiveInfo\n | WebGLBuffer\n | WebGLFramebuffer\n | WebGLProgram\n | WebGLRenderbuffer\n | WebGLShader\n | WebGLShaderPrecisionFormat\n | WebGLTexture\n | WebGLUniformLocation\n | WebGLVertexArrayObject => {\n const webGLConstructorNames: string[] = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.\n 'WebGLVertexArrayObjectOES',\n ];\n const supportedWebGLConstructorNames = webGLConstructorNames.filter(\n (name: string) => typeof win[name as keyof Window] === 'function',\n );\n return Boolean(\n supportedWebGLConstructorNames.find(\n (name: string) => value instanceof win[name as keyof Window],\n ),\n );\n};\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\nimport { saveWebGLVar, serializeArgs } from './serialize-args';\n\nfunction patchGLPrototype(\n prototype: WebGLRenderingContext | WebGL2RenderingContext,\n type: CanvasContext,\n cb: canvasManagerMutationCallback,\n blockClass: blockClass,\n mirror: Mirror,\n win: IWindow,\n): listenerHandler[] {\n const handlers: listenerHandler[] = [];\n\n const props = Object.getOwnPropertyNames(prototype);\n\n for (const prop of props) {\n try {\n if (typeof prototype[prop as keyof typeof prototype] !== 'function') {\n continue;\n }\n const restoreHandler = patch(prototype, prop, function (original) {\n return function (this: typeof prototype, ...args: Array) {\n const result = original.apply(this, args);\n saveWebGLVar(result, win, prototype);\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n const id = mirror.getId((this.canvas as unknown) as INode);\n\n const recordArgs = serializeArgs([...args], win, prototype);\n const mutation: canvasMutationWithType = {\n type,\n property: prop,\n args: recordArgs,\n };\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, mutation);\n }\n\n return result;\n };\n });\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(prototype, prop, {\n set(v) {\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, {\n type,\n property: prop,\n args: [v],\n setter: true,\n });\n },\n });\n handlers.push(hookHandler);\n }\n }\n\n return handlers;\n}\n\nexport default function initCanvasWebGLMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n\n handlers.push(\n ...patchGLPrototype(\n win.WebGLRenderingContext.prototype,\n CanvasContext.WebGL,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n\n if (typeof win.WebGL2RenderingContext !== 'undefined') {\n handlers.push(\n ...patchGLPrototype(\n win.WebGL2RenderingContext.prototype,\n CanvasContext.WebGL2,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n }\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n canvasManagerMutationCallback,\n canvasMutationCallback,\n canvasMutationCommand,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport initCanvas2DMutationObserver from './2d';\nimport initCanvasContextObserver from './canvas';\nimport initCanvasWebGLMutationObserver from './webgl';\n\nexport type RafStamps = { latestId: number; invokeId: number | null };\n\ntype pendingCanvasMutationsMap = Map<\n HTMLCanvasElement,\n canvasMutationWithType[]\n>;\n\nexport class CanvasManager {\n private pendingCanvasMutations: pendingCanvasMutationsMap = new Map();\n private rafStamps: RafStamps = { latestId: 0, invokeId: null };\n private mirror: Mirror;\n\n private mutationCb: canvasMutationCallback;\n private resetObservers?: listenerHandler;\n private frozen: boolean = false;\n private locked: boolean = false;\n\n public reset() {\n this.pendingCanvasMutations.clear();\n this.resetObservers && this.resetObservers();\n }\n\n public freeze() {\n this.frozen = true;\n }\n\n public unfreeze() {\n this.frozen = false;\n }\n\n public lock() {\n this.locked = true;\n }\n\n public unlock() {\n this.locked = false;\n }\n\n constructor(options: {\n recordCanvas: boolean | number;\n mutationCb: canvasMutationCallback;\n win: IWindow;\n blockClass: blockClass;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.mirror = options.mirror;\n\n if (options.recordCanvas === true)\n this.initCanvasMutationObserver(options.win, options.blockClass);\n }\n\n private processMutation: canvasManagerMutationCallback = function (\n target,\n mutation,\n ) {\n const newFrame =\n this.rafStamps.invokeId &&\n this.rafStamps.latestId !== this.rafStamps.invokeId;\n if (newFrame || !this.rafStamps.invokeId)\n this.rafStamps.invokeId = this.rafStamps.latestId;\n\n if (!this.pendingCanvasMutations.has(target)) {\n this.pendingCanvasMutations.set(target, []);\n }\n\n this.pendingCanvasMutations.get(target)!.push(mutation);\n };\n\n private initCanvasMutationObserver(\n win: IWindow,\n blockClass: blockClass,\n ): void {\n this.startRAFTimestamping();\n this.startPendingCanvasMutationFlusher();\n\n const canvasContextReset = initCanvasContextObserver(win, blockClass);\n const canvas2DReset = initCanvas2DMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n this.resetObservers = () => {\n canvasContextReset();\n canvas2DReset();\n canvasWebGL1and2Reset();\n };\n }\n\n private startPendingCanvasMutationFlusher() {\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n private startRAFTimestamping() {\n const setLatestRAFTimestamp = (timestamp: DOMHighResTimeStamp) => {\n this.rafStamps.latestId = timestamp;\n requestAnimationFrame(setLatestRAFTimestamp);\n };\n requestAnimationFrame(setLatestRAFTimestamp);\n }\n\n flushPendingCanvasMutations() {\n this.pendingCanvasMutations.forEach(\n (values: canvasMutationCommand[], canvas: HTMLCanvasElement) => {\n const id = this.mirror.getId((canvas as unknown) as INode);\n this.flushPendingCanvasMutationFor(canvas, id);\n },\n );\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n flushPendingCanvasMutationFor(canvas: HTMLCanvasElement, id: number) {\n if (this.frozen || this.locked) {\n return;\n }\n\n const valuesWithType = this.pendingCanvasMutations.get(canvas);\n if (!valuesWithType || id === -1) return;\n\n const values = valuesWithType.map((value) => {\n const { type, ...rest } = value;\n return rest;\n });\n const { type } = valuesWithType[0];\n\n this.mutationCb({ id, type, commands: values });\n\n this.pendingCanvasMutations.delete(canvas);\n }\n}\n","import { snapshot, MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';\nimport { initObservers, mutationBuffers } from './observer';\nimport {\n on,\n getWindowWidth,\n getWindowHeight,\n polyfill,\n isIframeINode,\n hasShadowRoot,\n createMirror,\n} from '../utils';\nimport {\n EventType,\n event,\n eventWithTime,\n recordOptions,\n IncrementalSource,\n listenerHandler,\n mutationCallbackParam,\n scrollCallback,\n canvasMutationParam,\n} from '../types';\nimport { IframeManager } from './iframe-manager';\nimport { ShadowDomManager } from './shadow-dom-manager';\nimport { CanvasManager } from './observers/canvas/canvas-manager';\n\nfunction wrapEvent(e: event): eventWithTime {\n return {\n ...e,\n timestamp: Date.now(),\n };\n}\n\nlet wrappedEmit!: (e: eventWithTime, isCheckout?: boolean) => void;\n\nlet takeFullSnapshot!: (isCheckout?: boolean) => void;\n\nconst mirror = createMirror();\nfunction record(\n options: recordOptions = {},\n): listenerHandler | undefined {\n const {\n emit,\n checkoutEveryNms,\n checkoutEveryNth,\n blockClass = 'rr-block',\n blockSelector = null,\n ignoreClass = 'rr-ignore',\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n inlineStylesheet = true,\n maskAllInputs,\n maskInputOptions: _maskInputOptions,\n slimDOMOptions: _slimDOMOptions,\n maskInputFn,\n maskTextFn,\n hooks,\n packFn,\n sampling = {},\n mousemoveWait,\n recordCanvas = false,\n userTriggeredOnInput = false,\n collectFonts = false,\n inlineImages = false,\n plugins,\n keepIframeSrcFn = () => false,\n } = options;\n // runtime checks for user options\n if (!emit) {\n throw new Error('emit function is required');\n }\n // move departed options to new options\n if (mousemoveWait !== undefined && sampling.mousemove === undefined) {\n sampling.mousemove = mousemoveWait;\n }\n\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : _maskInputOptions !== undefined\n ? _maskInputOptions\n : { password: true };\n\n const slimDOMOptions: SlimDOMOptions =\n _slimDOMOptions === true || _slimDOMOptions === 'all'\n ? {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaVerification: true,\n // the following are off for slimDOMOptions === true,\n // as they destroy some (hidden) info:\n headMetaAuthorship: _slimDOMOptions === 'all',\n headMetaDescKeywords: _slimDOMOptions === 'all',\n }\n : _slimDOMOptions\n ? _slimDOMOptions\n : {};\n\n polyfill();\n\n let lastFullSnapshotEvent: eventWithTime;\n let incrementalSnapshotCount = 0;\n const eventProcessor = (e: eventWithTime): T => {\n for (const plugin of plugins || []) {\n if (plugin.eventProcessor) {\n e = plugin.eventProcessor(e);\n }\n }\n if (packFn) {\n e = (packFn(e) as unknown) as eventWithTime;\n }\n return (e as unknown) as T;\n };\n wrappedEmit = (e: eventWithTime, isCheckout?: boolean) => {\n if (\n mutationBuffers[0]?.isFrozen() &&\n e.type !== EventType.FullSnapshot &&\n !(\n e.type === EventType.IncrementalSnapshot &&\n e.data.source === IncrementalSource.Mutation\n )\n ) {\n // we've got a user initiated event so first we need to apply\n // all DOM changes that have been buffering during paused state\n mutationBuffers.forEach((buf) => buf.unfreeze());\n }\n\n emit(eventProcessor(e), isCheckout);\n if (e.type === EventType.FullSnapshot) {\n lastFullSnapshotEvent = e;\n incrementalSnapshotCount = 0;\n } else if (e.type === EventType.IncrementalSnapshot) {\n // attach iframe should be considered as full snapshot\n if (\n e.data.source === IncrementalSource.Mutation &&\n e.data.isAttachIframe\n ) {\n return;\n }\n\n incrementalSnapshotCount++;\n const exceedCount =\n checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;\n const exceedTime =\n checkoutEveryNms &&\n e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;\n if (exceedCount || exceedTime) {\n takeFullSnapshot(true);\n }\n }\n };\n\n const wrappedMutationEmit = (m: mutationCallbackParam) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Mutation,\n ...m,\n },\n }),\n );\n };\n const wrappedScrollEmit: scrollCallback = (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Scroll,\n ...p,\n },\n }),\n );\n const wrappedCanvasMutationEmit = (p: canvasMutationParam) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.CanvasMutation,\n ...p,\n },\n }),\n );\n\n const iframeManager = new IframeManager({\n mutationCb: wrappedMutationEmit,\n });\n\n const canvasManager = new CanvasManager({\n recordCanvas,\n mutationCb: wrappedCanvasMutationEmit,\n win: window,\n blockClass,\n mirror,\n });\n\n const shadowDomManager = new ShadowDomManager({\n mutationCb: wrappedMutationEmit,\n scrollCb: wrappedScrollEmit,\n bypassOptions: {\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n recordCanvas,\n inlineImages,\n sampling,\n slimDOMOptions,\n iframeManager,\n canvasManager,\n },\n mirror,\n });\n\n takeFullSnapshot = (isCheckout = false) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Meta,\n data: {\n href: window.location.href,\n width: getWindowWidth(),\n height: getWindowHeight(),\n },\n }),\n isCheckout,\n );\n\n mutationBuffers.forEach((buf) => buf.lock()); // don't allow any mirror modifications during snapshotting\n const [node, idNodeMap] = snapshot(document, {\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskAllInputs: maskInputOptions,\n maskTextFn,\n slimDOM: slimDOMOptions,\n recordCanvas,\n inlineImages,\n onSerialize: (n) => {\n if (isIframeINode(n)) {\n iframeManager.addIframe(n);\n }\n if (hasShadowRoot(n)) {\n shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n iframeManager.attachIframe(iframe, childSn);\n shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n keepIframeSrcFn,\n });\n\n if (!node) {\n return console.warn('Failed to snapshot the document');\n }\n\n mirror.map = idNodeMap;\n wrappedEmit(\n wrapEvent({\n type: EventType.FullSnapshot,\n data: {\n node,\n initialOffset: {\n left:\n window.pageXOffset !== undefined\n ? window.pageXOffset\n : document?.documentElement.scrollLeft ||\n document?.body?.parentElement?.scrollLeft ||\n document?.body.scrollLeft ||\n 0,\n top:\n window.pageYOffset !== undefined\n ? window.pageYOffset\n : document?.documentElement.scrollTop ||\n document?.body?.parentElement?.scrollTop ||\n document?.body.scrollTop ||\n 0,\n },\n },\n }),\n );\n mutationBuffers.forEach((buf) => buf.unlock()); // generate & emit any mutations that happened during snapshotting, as can now apply against the newly built mirror\n };\n\n try {\n const handlers: listenerHandler[] = [];\n handlers.push(\n on('DOMContentLoaded', () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.DomContentLoaded,\n data: {},\n }),\n );\n }),\n );\n\n const observe = (doc: Document) => {\n return initObservers(\n {\n mutationCb: wrappedMutationEmit,\n mousemoveCb: (positions, source) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source,\n positions,\n },\n }),\n ),\n mouseInteractionCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MouseInteraction,\n ...d,\n },\n }),\n ),\n scrollCb: wrappedScrollEmit,\n viewportResizeCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.ViewportResize,\n ...d,\n },\n }),\n ),\n inputCb: (v) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Input,\n ...v,\n },\n }),\n ),\n mediaInteractionCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MediaInteraction,\n ...p,\n },\n }),\n ),\n styleSheetRuleCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleSheetRule,\n ...r,\n },\n }),\n ),\n styleDeclarationCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleDeclaration,\n ...r,\n },\n }),\n ),\n canvasMutationCb: wrappedCanvasMutationEmit,\n fontCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Font,\n ...p,\n },\n }),\n ),\n blockClass,\n ignoreClass,\n maskTextClass,\n maskTextSelector,\n maskInputOptions,\n inlineStylesheet,\n sampling,\n recordCanvas,\n inlineImages,\n userTriggeredOnInput,\n collectFonts,\n doc,\n maskInputFn,\n maskTextFn,\n blockSelector,\n slimDOMOptions,\n mirror,\n iframeManager,\n shadowDomManager,\n canvasManager,\n plugins:\n plugins\n ?.filter((p) => p.observer)\n ?.map((p) => ({\n observer: p.observer!,\n options: p.options,\n callback: (payload: object) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.Plugin,\n data: {\n plugin: p.name,\n payload,\n },\n }),\n ),\n })) || [],\n },\n hooks,\n );\n };\n\n iframeManager.addLoadListener((iframeEl) => {\n handlers.push(observe(iframeEl.contentDocument!));\n });\n\n const init = () => {\n takeFullSnapshot();\n handlers.push(observe(document));\n };\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n init();\n } else {\n handlers.push(\n on(\n 'load',\n () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Load,\n data: {},\n }),\n );\n init();\n },\n window,\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n } catch (error) {\n // TODO: handle internal error\n console.warn(error);\n }\n}\n\nrecord.addCustomEvent = (tag: string, payload: T) => {\n if (!wrappedEmit) {\n throw new Error('please add custom event after start recording');\n }\n wrappedEmit(\n wrapEvent({\n type: EventType.Custom,\n data: {\n tag,\n payload,\n },\n }),\n );\n};\n\nrecord.freezePage = () => {\n mutationBuffers.forEach((buf) => buf.freeze());\n};\n\nrecord.takeFullSnapshot = (isCheckout?: boolean) => {\n if (!takeFullSnapshot) {\n throw new Error('please take full snapshot after start recording');\n }\n takeFullSnapshot(isCheckout);\n};\n\nrecord.mirror = mirror;\n\nexport default record;\n","import { INode, ICanvas } from 'rrweb-snapshot';\nimport { blockClass, IWindow, listenerHandler } from '../../../types';\nimport { isBlocked, patch } from '../../../utils';\n\nexport default function initCanvasContextObserver(\n win: IWindow,\n blockClass: blockClass,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n try {\n const restoreHandler = patch(\n win.HTMLCanvasElement.prototype,\n 'getContext',\n function (original) {\n return function (\n this: ICanvas,\n contextType: string,\n ...args: Array\n ) {\n if (!isBlocked((this as unknown) as INode, blockClass)) {\n if (!('__context' in this))\n (this as ICanvas).__context = contextType;\n }\n return original.apply(this, [contextType, ...args]);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n console.error('failed to patch HTMLCanvasElement.prototype.getContext');\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\n\nexport default function initCanvas2DMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n const props2D = Object.getOwnPropertyNames(\n win.CanvasRenderingContext2D.prototype,\n );\n for (const prop of props2D) {\n try {\n if (\n typeof win.CanvasRenderingContext2D.prototype[\n prop as keyof CanvasRenderingContext2D\n ] !== 'function'\n ) {\n continue;\n }\n const restoreHandler = patch(\n win.CanvasRenderingContext2D.prototype,\n prop,\n function (original) {\n return function (\n this: CanvasRenderingContext2D,\n ...args: Array\n ) {\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n // Using setTimeout as getImageData + JSON.stringify can be heavy\n // and we'd rather not block the main thread\n setTimeout(() => {\n const recordArgs = [...args];\n if (prop === 'drawImage') {\n if (\n recordArgs[0] &&\n recordArgs[0] instanceof HTMLCanvasElement\n ) {\n const canvas = recordArgs[0];\n const ctx = canvas.getContext('2d');\n let imgd = ctx?.getImageData(\n 0,\n 0,\n canvas.width,\n canvas.height,\n );\n let pix = imgd?.data;\n recordArgs[0] = JSON.stringify(pix);\n }\n }\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: recordArgs,\n });\n }, 0);\n }\n return original.apply(this, args);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(\n win.CanvasRenderingContext2D.prototype,\n prop,\n {\n set(v) {\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: [v],\n setter: true,\n });\n },\n },\n );\n handlers.push(hookHandler);\n }\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isShadowRoot","_a","host","Boolean","shadowRoot","maskInputValue","maskInputOptions","tagName","type","maskInputFn","text","toLowerCase","repeat","ORIGINAL_ATTRIBUTE_NAME","canvasService","canvasCtx","_id","tagNameRegex","RegExp","getCssRulesString","rules","cssRules","map","getCssRuleString","join","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","stack","parts","pop","_i","parts_1","part","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","nodeType","ELEMENT_NODE","classList","contains","eIndex","className","matches","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","Math","min","data","buffer","some","pixel","is2DCanvasBlank","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","isElement","_l","_m","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","on","fn","target","capture","passive","removeEventListener","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","getId","getNode","removeNodeFromMap","has","reset","throttle","func","wait","timeout","previous","arg","now","Date","leading","remaining","context","args","trailing","hookSetter","key","d","isRevoked","original","getOwnPropertyDescriptor","defineProperty","set","_this","patch","source","replacement","original_1","wrapped","defineProperties","__rrweb_original__","enumerable","getWindowHeight","window","innerHeight","documentElement","clientHeight","body","getWindowWidth","innerWidth","clientWidth","isBlocked","needBlock_1","closest","forEach","isIgnored","isAncestorRemoved","mirror","isTouchEvent","event","changedTouches","isIframeINode","hasShadowRoot","isNodeInLinkedList","Proxy","Reflect","get","prop","receiver","DoubleLinkedList","position","Error","current","head","index","__ln","moveKey","parentId","isINode","Set","mutations","processMutation","emit","frozen","locked","adds","addList","getNextId","ns","nextId","pushAdd","shadowHost","getRootNode","rootShadowHost","notInDoc","addNode","currentN","iframeManager","addIframe","shadowDomManager","addShadowRoot","iframe","childSn","attachIframe","observeAttachShadow","mapRemoves","shift","movedSet","isParentRemoved","removes","addedSet","isAncestorInSet","droppedSet","add","candidate","_node","removeNode","payload","texts","filter","attribute","movedMap","mutationCb","oldValue","getAttribute","attributeName","item","old","setAttribute","style","styleObj","pname","newValue","getPropertyValue","newPriority","getPropertyPriority","addedNodes","genAdds","removedNodes","nodeId","deepDelete","targetId","delete","childN","MutationBuffer","canvasManager","freeze","unfreeze","lock","unlock","addsSet","mutationBuffers","isCSSGroupingRuleSupported","CSSGroupingRule","isCSSMediaRuleSupported","CSSMediaRule","isCSSSupportsRuleSupported","CSSSupportsRule","isCSSConditionRuleSupported","CSSConditionRule","getEventTarget","path","composedPath","initMutationObserver","rootEl","mutationBuffer","init","mutationObserverCtor","MutationObserver","__rrMutationObserver","angularZoneSymbol","Zone","__symbol__","observer","processMutations","bind","observe","attributeOldValue","characterData","characterDataOldValue","childList","subtree","initMouseInteractionObserver","mouseInteractionCb","sampling","mouseInteraction","disableMap","handlers","keys","Number","isNaN","eventKey","eventName","handler","clientX","clientY","getHandler","h","initScrollObserver","scrollCb","evt","scrollEl","scrollingElement","scroll","wrapEventWithUserTriggeredFlag","v","enable","userTriggered","INPUT_TAGS","lastInputValueMap","WeakMap","getNestedCSSRulePositions","childRule","parentRule","unshift","parentStyleSheet","recurse","initObservers","hooks","currentWindow","defaultView","mousemoveCb","viewportResizeCb","inputCb","mediaInteractionCb","styleSheetRuleCb","styleDeclarationCb","canvasMutationCb","fontCb","mutation","mousemove","viewportResize","input","mediaInteaction","styleSheetRule","styleDeclaration","canvasMutation","font","mergeHooks","mutationObserver","mousemoveHandler","timeBaseline","threshold","callbackThreshold","mousemoveCallback","positions","wrappedCb","totalOffset","timeOffset","updatePosition","DragEvent","Drag","MouseEvent","MouseMove","TouchMove","initMoveObserver","mouseInteractionHandler","scrollHandler","viewportResizeHandler","lastH","lastW","initViewportResizeObserver","inputHandler","ignoreClass","userTriggeredOnInput","eventHandler","isTrusted","parentElement","isChecked","cbWithDedup","querySelectorAll","lastInputValue","propertyDescriptor","HTMLInputElement","hookProperties","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement","initInputObserver","mediaInteractionHandler","volume","muted","media","initMediaInteractionObserver","styleSheetObserver","insertRule","CSSStyleSheet","ownerNode","deleteRule","supportedNestedCSSRuleTypes","unmodifiedFunctions","entries","typeKey","initStyleSheetObserver","styleDeclarationObserver","setProperty","CSSStyleDeclaration","priority","removeProperty","remove","initStyleDeclarationObserver","fontObserver","collectFonts","fontMap","originalFontFace","FontFace","family","descriptors","fontFace","fontSource","JSON","stringify","Uint8Array","restoreHandler","fonts","initFontObserver","pluginHandlers","plugins","plugin","callback","b","disconnect","IframeManager","iframes","cb","loadListener","isAttachIframe","manager","restorePatches","HTMLElement","ownerDocument","ShadowDomManager","iframeElement","manager_1","restorePatch","lookup","charCodeAt","webGLVarMap","Map","saveWebGLVar","isInstanceOfWebGLObject","list","ctor","contextMap","variableListFor","constructor","serializeArg","Float32Array","Float64Array","Int32Array","Uint16Array","Int16Array","Int8Array","Uint8ClampedArray","rr_type","values","ArrayBuffer","base64","arraybuffer","bytes","len","encode","DataView","byteOffset","byteLength","HTMLImageElement","ImageData","serializeArgs","supportedWebGLConstructorNames","patchGLPrototype","props","getOwnPropertyNames","result","recordArgs","hookHandler","setter","props_1","wrappedEmit","takeFullSnapshot","latestId","invokeId","rafStamps","pendingCanvasMutations","initCanvasMutationObserver","CanvasManager","clear","resetObservers","startRAFTimestamping","startPendingCanvasMutationFlusher","canvasContextReset","HTMLCanvasElement","contextType","initCanvasContextObserver","canvas2DReset","props2D","CanvasRenderingContext2D","imgd","pix","props2D_1","initCanvas2DMutationObserver","canvasWebGL1and2Reset","WebGLRenderingContext","WebGL","WebGL2RenderingContext","WebGL2","initCanvasWebGLMutationObserver","requestAnimationFrame","flushPendingCanvasMutations","setLatestRAFTimestamp","timestamp","flushPendingCanvasMutationFor","valuesWithType","getOwnPropertySymbols","propertyIsEnumerable","commands","wrapEvent","child","record","checkoutEveryNms","checkoutEveryNth","maskAllInputs","_maskInputOptions","_slimDOMOptions","packFn","mousemoveWait","lastFullSnapshotEvent","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","NodeList","DOMTokenList","Node","incrementalSnapshotCount","isCheckout","isFrozen","FullSnapshot","IncrementalSnapshot","Mutation","buf","eventProcessor","exceedCount","exceedTime","wrappedMutationEmit","wrappedScrollEmit","Scroll","wrappedCanvasMutationEmit","CanvasMutation","Meta","slimDOM","idNodeMap","snapshot","initialOffset","left","pageXOffset","top","pageYOffset","handlers_1","DomContentLoaded","observe_1","MouseInteraction","ViewportResize","Input","MediaInteraction","StyleSheetRule","StyleDeclaration","Font","Plugin","addLoadListener","init_1","Load","addCustomEvent","tag","Custom","freezePage"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ED+BOC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR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B,IAAKjE,GACH,MAAM,IAAInT,MAAM,mDAElBmT,GAAiBiE,IAGnB1B,GAAOxW,OAASA"} +\ No newline at end of file ++{"version":3,"file":"rrweb-record.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../src/types.ts","../../../src/utils.ts","../../../src/record/mutation.ts","../../../src/record/observer.ts","../../../src/record/iframe-manager.ts","../../../src/record/shadow-dom-manager.ts","../../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../../src/record/observers/canvas/serialize-args.ts","../../../src/record/observers/canvas/webgl.ts","../../../src/record/observers/canvas/canvas-manager.ts","../../../src/record/index.ts","../../../src/record/observers/canvas/canvas.ts","../../../src/record/observers/canvas/2d.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type] ||\n (maskInputSelector && input.matches(maskInputSelector))) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) {\n return false;\n }\n }\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n input: n,\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n unblockSelector?: string;\n ignoreClass?: string;\n ignoreSelector?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputSelector?: string;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n unmaskTextSelector?: string;\n unmaskInputSelector?: string;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n unblockSelector: string | null;\n ignoreClass: string;\n ignoreSelector: string | null;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'unblockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'unmaskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputSelector'\n | 'unmaskInputSelector'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","import {\n INode,\n serializeNodeWithId,\n transformAttribute,\n IGNORED_NODE,\n isShadowRoot,\n needMaskingText,\n maskInputValue,\n} from 'rrweb-snapshot';\nimport {\n mutationRecord,\n textCursor,\n attributeCursor,\n removedNodeMutation,\n addedNodeMutation,\n Mirror,\n styleAttributeValue,\n observerParam,\n MutationBufferParam,\n Optional,\n} from '../types';\nimport {\n isBlocked,\n isAncestorRemoved,\n isIgnored,\n isIframeINode,\n hasShadowRoot,\n} from '../utils';\n\ntype DoubleLinkedListNode = {\n previous: DoubleLinkedListNode | null;\n next: DoubleLinkedListNode | null;\n value: NodeInLinkedList;\n};\ntype NodeInLinkedList = Node & {\n __ln: DoubleLinkedListNode;\n};\n\nfunction isNodeInLinkedList(n: Node | NodeInLinkedList): n is NodeInLinkedList {\n return '__ln' in n;\n}\nclass DoubleLinkedList {\n public length = 0;\n public head: DoubleLinkedListNode | null = null;\n\n public get(position: number) {\n if (position >= this.length) {\n throw new Error('Position outside of list range');\n }\n\n let current = this.head;\n for (let index = 0; index < position; index++) {\n current = current?.next || null;\n }\n return current;\n }\n\n public addNode(n: Node) {\n const node: DoubleLinkedListNode = {\n value: n as NodeInLinkedList,\n previous: null,\n next: null,\n };\n (n as NodeInLinkedList).__ln = node;\n if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {\n const current = n.previousSibling.__ln.next;\n node.next = current;\n node.previous = n.previousSibling.__ln;\n n.previousSibling.__ln.next = node;\n if (current) {\n current.previous = node;\n }\n } else if (\n n.nextSibling &&\n isNodeInLinkedList(n.nextSibling) &&\n n.nextSibling.__ln.previous\n ) {\n const current = n.nextSibling.__ln.previous;\n node.previous = current;\n node.next = n.nextSibling.__ln;\n n.nextSibling.__ln.previous = node;\n if (current) {\n current.next = node;\n }\n } else {\n if (this.head) {\n this.head.previous = node;\n }\n node.next = this.head;\n this.head = node;\n }\n this.length++;\n }\n\n public removeNode(n: NodeInLinkedList) {\n const current = n.__ln;\n if (!this.head) {\n return;\n }\n\n if (!current.previous) {\n this.head = current.next;\n if (this.head) {\n this.head.previous = null;\n }\n } else {\n current.previous.next = current.next;\n if (current.next) {\n current.next.previous = current.previous;\n }\n }\n if (n.__ln) {\n delete (n as Optional).__ln;\n }\n this.length--;\n }\n}\n\nconst moveKey = (id: number, parentId: number) => `${id}@${parentId}`;\nfunction isINode(n: Node | INode): n is INode {\n return '__sn' in n;\n}\n\n/**\n * controls behaviour of a MutationObserver\n */\nexport default class MutationBuffer {\n private frozen: boolean = false;\n private locked: boolean = false;\n\n private texts: textCursor[] = [];\n private attributes: attributeCursor[] = [];\n private removes: removedNodeMutation[] = [];\n private mapRemoves: Node[] = [];\n\n private movedMap: Record = {};\n\n /**\n * the browser MutationObserver emits multiple mutations after\n * a delay for performance reasons, making tracing added nodes hard\n * in our `processMutations` callback function.\n * For example, if we append an element el_1 into body, and then append\n * another element el_2 into el_1, these two mutations may be passed to the\n * callback function together when the two operations were done.\n * Generally we need to trace child nodes of newly added nodes, but in this\n * case if we count el_2 as el_1's child node in the first mutation record,\n * then we will count el_2 again in the second mutation record which was\n * duplicated.\n * To avoid of duplicate counting added nodes, we use a Set to store\n * added nodes and its child nodes during iterate mutation records. Then\n * collect added nodes from the Set which have no duplicate copy. But\n * this also causes newly added nodes will not be serialized with id ASAP,\n * which means all the id related calculation should be lazy too.\n */\n private addedSet = new Set();\n private movedSet = new Set();\n private droppedSet = new Set();\n\n private mutationCb: observerParam['mutationCb'];\n private blockClass: observerParam['blockClass'];\n private blockSelector: observerParam['blockSelector'];\n private unblockSelector: observerParam['unblockSelector'];\n private maskTextClass: observerParam['maskTextClass'];\n private maskTextSelector: observerParam['maskTextSelector'];\n private unmaskTextSelector: observerParam['unmaskTextSelector'];\n private maskInputSelector: observerParam['maskInputSelector'];\n private unmaskInputSelector: observerParam['unmaskInputSelector'];\n private inlineStylesheet: observerParam['inlineStylesheet'];\n private maskInputOptions: observerParam['maskInputOptions'];\n private maskTextFn: observerParam['maskTextFn'];\n private maskInputFn: observerParam['maskInputFn'];\n private recordCanvas: observerParam['recordCanvas'];\n private inlineImages: observerParam['inlineImages'];\n private slimDOMOptions: observerParam['slimDOMOptions'];\n private doc: observerParam['doc'];\n private mirror: observerParam['mirror'];\n private iframeManager: observerParam['iframeManager'];\n private shadowDomManager: observerParam['shadowDomManager'];\n private canvasManager: observerParam['canvasManager'];\n\n public init(options: MutationBufferParam) {\n ([\n 'mutationCb',\n 'blockClass',\n 'blockSelector',\n 'unblockSelector',\n 'maskTextClass',\n 'maskTextSelector',\n 'unmaskTextSelector',\n 'maskInputSelector',\n 'unmaskInputSelector',\n 'inlineStylesheet',\n 'maskInputOptions',\n 'maskTextFn',\n 'maskInputFn',\n 'recordCanvas',\n 'inlineImages',\n 'slimDOMOptions',\n 'doc',\n 'mirror',\n 'iframeManager',\n 'shadowDomManager',\n 'canvasManager',\n ] as const).forEach((key) => {\n // just a type trick, the runtime result is correct\n this[key] = options[key] as never;\n });\n }\n\n public freeze() {\n this.frozen = true;\n this.canvasManager.freeze();\n }\n\n public unfreeze() {\n this.frozen = false;\n this.canvasManager.unfreeze();\n this.emit();\n }\n\n public isFrozen() {\n return this.frozen;\n }\n\n public lock() {\n this.locked = true;\n this.canvasManager.lock();\n }\n\n public unlock() {\n this.locked = false;\n this.canvasManager.unlock();\n this.emit();\n }\n\n public reset() {\n this.shadowDomManager.reset();\n this.canvasManager.reset();\n }\n\n public processMutations = (mutations: mutationRecord[]) => {\n mutations.forEach(this.processMutation); // adds mutations to the buffer\n this.emit(); // clears buffer if not locked/frozen\n };\n\n public emit = () => {\n if (this.frozen || this.locked) {\n return;\n }\n\n // delay any modification of the mirror until this function\n // so that the mirror for takeFullSnapshot doesn't get mutated while it's event is being processed\n\n const adds: addedNodeMutation[] = [];\n\n /**\n * Sometimes child node may be pushed before its newly added\n * parent, so we init a queue to store these nodes.\n */\n const addList = new DoubleLinkedList();\n const getNextId = (n: Node): number | null => {\n let ns: Node | null = n;\n let nextId: number | null = IGNORED_NODE; // slimDOM: ignored\n while (nextId === IGNORED_NODE) {\n ns = ns && ns.nextSibling;\n nextId = ns && this.mirror.getId((ns as unknown) as INode);\n }\n return nextId;\n };\n const pushAdd = (n: Node) => {\n const shadowHost: Element | null = n.getRootNode\n ? (n.getRootNode() as ShadowRoot)?.host\n : null;\n // If n is in a nested shadow dom.\n let rootShadowHost = shadowHost;\n while ((rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host)\n rootShadowHost =\n (rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host ||\n null;\n // ensure shadowHost is a Node, or doc.contains will throw an error\n const notInDoc =\n !this.doc.contains(n) &&\n (rootShadowHost === null || !this.doc.contains(rootShadowHost));\n if (!n.parentNode || notInDoc) {\n return;\n }\n const parentId = isShadowRoot(n.parentNode)\n ? this.mirror.getId((shadowHost as unknown) as INode)\n : this.mirror.getId((n.parentNode as Node) as INode);\n const nextId = getNextId(n);\n if (parentId === -1 || nextId === -1) {\n return addList.addNode(n);\n }\n let sn = serializeNodeWithId(n, {\n doc: this.doc,\n map: this.mirror.map,\n blockClass: this.blockClass,\n blockSelector: this.blockSelector,\n unblockSelector: this.unblockSelector,\n maskTextClass: this.maskTextClass,\n maskTextSelector: this.maskTextSelector,\n unmaskTextSelector: this.unmaskTextSelector,\n maskInputSelector: this.maskInputSelector,\n unmaskInputSelector: this.unmaskInputSelector,\n skipChild: true,\n inlineStylesheet: this.inlineStylesheet,\n maskInputOptions: this.maskInputOptions,\n maskTextFn: this.maskTextFn,\n maskInputFn: this.maskInputFn,\n slimDOMOptions: this.slimDOMOptions,\n recordCanvas: this.recordCanvas,\n inlineImages: this.inlineImages,\n onSerialize: (currentN) => {\n if (isIframeINode(currentN)) {\n this.iframeManager.addIframe(currentN);\n }\n if (hasShadowRoot(n)) {\n this.shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n this.iframeManager.attachIframe(iframe, childSn);\n this.shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n });\n if (sn) {\n adds.push({\n parentId,\n nextId,\n node: sn,\n });\n }\n };\n\n while (this.mapRemoves.length) {\n this.mirror.removeNodeFromMap(this.mapRemoves.shift() as INode);\n }\n\n for (const n of this.movedSet) {\n if (\n isParentRemoved(this.removes, n, this.mirror) &&\n !this.movedSet.has(n.parentNode!)\n ) {\n continue;\n }\n pushAdd(n);\n }\n\n for (const n of this.addedSet) {\n if (\n !isAncestorInSet(this.droppedSet, n) &&\n !isParentRemoved(this.removes, n, this.mirror)\n ) {\n pushAdd(n);\n } else if (isAncestorInSet(this.movedSet, n)) {\n pushAdd(n);\n } else {\n this.droppedSet.add(n);\n }\n }\n\n let candidate: DoubleLinkedListNode | null = null;\n while (addList.length) {\n let node: DoubleLinkedListNode | null = null;\n if (candidate) {\n const parentId = this.mirror.getId(\n (candidate.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(candidate.value);\n if (parentId !== -1 && nextId !== -1) {\n node = candidate;\n }\n }\n if (!node) {\n for (let index = addList.length - 1; index >= 0; index--) {\n const _node = addList.get(index)!;\n // ensure _node is defined before attempting to find value\n if (_node) {\n const parentId = this.mirror.getId(\n (_node.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(_node.value);\n if (parentId !== -1 && nextId !== -1) {\n node = _node;\n break;\n }\n }\n }\n }\n if (!node) {\n /**\n * If all nodes in queue could not find a serialized parent,\n * it may be a bug or corner case. We need to escape the\n * dead while loop at once.\n */\n while (addList.head) {\n addList.removeNode(addList.head.value);\n }\n break;\n }\n candidate = node.previous;\n addList.removeNode(node.value);\n pushAdd(node.value);\n }\n\n const payload = {\n texts: this.texts\n .map((text) => ({\n id: this.mirror.getId(text.node as INode),\n value: text.value,\n }))\n // text mutation's id was not in the mirror map means the target node has been removed\n .filter((text) => this.mirror.has(text.id)),\n attributes: this.attributes\n .map((attribute) => ({\n id: this.mirror.getId(attribute.node as INode),\n attributes: attribute.attributes,\n }))\n // attribute mutation's id was not in the mirror map means the target node has been removed\n .filter((attribute) => this.mirror.has(attribute.id)),\n removes: this.removes,\n adds,\n };\n // payload may be empty if the mutations happened in some blocked elements\n if (\n !payload.texts.length &&\n !payload.attributes.length &&\n !payload.removes.length &&\n !payload.adds.length\n ) {\n return;\n }\n\n // reset\n this.texts = [];\n this.attributes = [];\n this.removes = [];\n this.addedSet = new Set();\n this.movedSet = new Set();\n this.droppedSet = new Set();\n this.movedMap = {};\n\n this.mutationCb(payload);\n };\n\n private processMutation = (m: mutationRecord) => {\n if (isIgnored(m.target)) {\n return;\n }\n switch (m.type) {\n case 'characterData': {\n const value = m.target.textContent;\n if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {\n this.texts.push({\n value:\n needMaskingText(\n m.target,\n this.maskTextClass,\n this.maskTextSelector,\n this.unmaskTextSelector\n ) && value\n ? this.maskTextFn\n ? this.maskTextFn(value)\n : value.replace(/[\\S]/g, '*')\n : value,\n node: m.target,\n });\n }\n break;\n }\n case 'attributes': {\n const target = m.target as HTMLElement;\n let value = (m.target as HTMLElement).getAttribute(m.attributeName!);\n if (m.attributeName === 'value') {\n value = maskInputValue({\n input: target,\n maskInputSelector: this.maskInputSelector,\n unmaskInputSelector: this.unmaskInputSelector,\n maskInputOptions: this.maskInputOptions,\n tagName: (m.target as HTMLElement).tagName,\n type: (m.target as HTMLElement).getAttribute('type'),\n value,\n maskInputFn: this.maskInputFn,\n });\n }\n if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {\n return;\n }\n let item: attributeCursor | undefined = this.attributes.find(\n (a) => a.node === m.target,\n );\n if (!item) {\n item = {\n node: m.target,\n attributes: {},\n };\n this.attributes.push(item);\n }\n if (m.attributeName === 'style') {\n const old = this.doc.createElement('span');\n if (m.oldValue) {\n old.setAttribute('style', m.oldValue);\n }\n if (\n item.attributes.style === undefined ||\n item.attributes.style === null\n ) {\n item.attributes.style = {};\n }\n const styleObj = item.attributes.style as styleAttributeValue;\n for (const pname of Array.from(target.style)) {\n const newValue = target.style.getPropertyValue(pname);\n const newPriority = target.style.getPropertyPriority(pname);\n if (\n newValue !== old.style.getPropertyValue(pname) ||\n newPriority !== old.style.getPropertyPriority(pname)\n ) {\n if (newPriority === '') {\n styleObj[pname] = newValue;\n } else {\n styleObj[pname] = [newValue, newPriority];\n }\n }\n }\n for (const pname of Array.from(old.style)) {\n if (target.style.getPropertyValue(pname) === '') {\n // \"if not set, returns the empty string\"\n styleObj[pname] = false; // delete\n }\n }\n } else {\n // overwrite attribute if the mutations was triggered in same time\n item.attributes[m.attributeName!] = transformAttribute(\n this.doc,\n (m.target as HTMLElement).tagName,\n m.attributeName!,\n value!,\n );\n }\n break;\n }\n case 'childList': {\n m.addedNodes.forEach((n) => this.genAdds(n, m.target));\n m.removedNodes.forEach((n) => {\n const nodeId = this.mirror.getId(n as INode);\n const parentId = isShadowRoot(m.target)\n ? this.mirror.getId((m.target.host as unknown) as INode)\n : this.mirror.getId(m.target as INode);\n if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {\n return;\n }\n // removed node has not been serialized yet, just remove it from the Set\n if (this.addedSet.has(n)) {\n deepDelete(this.addedSet, n);\n this.droppedSet.add(n);\n } else if (this.addedSet.has(m.target) && nodeId === -1) {\n /**\n * If target was newly added and removed child node was\n * not serialized, it means the child node has been removed\n * before callback fired, so we can ignore it because\n * newly added node will be serialized without child nodes.\n * TODO: verify this\n */\n } else if (isAncestorRemoved(m.target as INode, this.mirror)) {\n /**\n * If parent id was not in the mirror map any more, it\n * means the parent node has already been removed. So\n * the node is also removed which we do not need to track\n * and replay.\n */\n } else if (\n this.movedSet.has(n) &&\n this.movedMap[moveKey(nodeId, parentId)]\n ) {\n deepDelete(this.movedSet, n);\n } else {\n this.removes.push({\n parentId,\n id: nodeId,\n isShadow: isShadowRoot(m.target) ? true : undefined,\n });\n }\n this.mapRemoves.push(n);\n });\n break;\n }\n default:\n break;\n }\n };\n\n private genAdds = (n: Node | INode, target?: Node | INode) => {\n // parent was blocked, so we can ignore this node\n if (target && isBlocked(target, this.blockClass)) {\n return;\n }\n if (isINode(n)) {\n if (isIgnored(n)) {\n return;\n }\n this.movedSet.add(n);\n let targetId: number | null = null;\n if (target && isINode(target)) {\n targetId = target.__sn.id;\n }\n if (targetId) {\n this.movedMap[moveKey(n.__sn.id, targetId)] = true;\n }\n } else {\n this.addedSet.add(n);\n this.droppedSet.delete(n);\n }\n\n // if this node is blocked `serializeNode` will turn it into a placeholder element\n // but we have to remove it's children otherwise they will be added as placeholders too\n if (!isBlocked(n, this.blockClass))\n n.childNodes.forEach((childN) => this.genAdds(childN));\n };\n}\n\n/**\n * Some utils to handle the mutation observer DOM records.\n * It should be more clear to extend the native data structure\n * like Set and Map, but currently Typescript does not support\n * that.\n */\nfunction deepDelete(addsSet: Set, n: Node) {\n addsSet.delete(n);\n n.childNodes.forEach((childN) => deepDelete(addsSet, childN));\n}\n\nfunction isParentRemoved(\n removes: removedNodeMutation[],\n n: Node,\n mirror: Mirror,\n): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n const parentId = mirror.getId((parentNode as Node) as INode);\n if (removes.some((r) => r.id === parentId)) {\n return true;\n }\n return isParentRemoved(removes, parentNode, mirror);\n}\n\nfunction isAncestorInSet(set: Set, n: Node): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n if (set.has(parentNode)) {\n return true;\n }\n return isAncestorInSet(set, parentNode);\n}\n","import { INode, MaskInputOptions, maskInputValue } from 'rrweb-snapshot';\nimport { FontFaceSet } from 'css-font-loading-module';\nimport {\n throttle,\n on,\n hookSetter,\n getWindowHeight,\n getWindowWidth,\n isBlocked,\n isTouchEvent,\n patch,\n} from '../utils';\nimport {\n mutationCallBack,\n observerParam,\n mousemoveCallBack,\n mousePosition,\n mouseInteractionCallBack,\n MouseInteractions,\n listenerHandler,\n scrollCallback,\n styleSheetRuleCallback,\n viewportResizeCallback,\n inputValue,\n inputCallback,\n hookResetter,\n IncrementalSource,\n hooksParam,\n Arguments,\n mediaInteractionCallback,\n MediaInteractions,\n canvasMutationCallback,\n fontCallback,\n fontParam,\n styleDeclarationCallback,\n IWindow,\n MutationBufferParam,\n} from '../types';\nimport MutationBuffer from './mutation';\n\ntype WindowWithStoredMutationObserver = IWindow & {\n __rrMutationObserver?: MutationObserver;\n};\ntype WindowWithAngularZone = IWindow & {\n Zone?: {\n __symbol__?: (key: string) => string;\n };\n};\n\nexport const mutationBuffers: MutationBuffer[] = [];\n\nconst isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';\nconst isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';\nconst isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';\nconst isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';\n\n// Event.path is non-standard and used in some older browsers\ntype NonStandardEvent = Omit & {\n path: EventTarget[];\n};\n\nfunction getEventTarget(event: Event | NonStandardEvent): EventTarget | null {\n try {\n if ('composedPath' in event) {\n const path = event.composedPath();\n if (path.length) {\n return path[0];\n }\n } else if ('path' in event && event.path.length) {\n return event.path[0];\n }\n return event.target;\n } catch {\n return event.target;\n }\n}\n\nexport function initMutationObserver(\n options: MutationBufferParam,\n rootEl: Node,\n): MutationObserver {\n const mutationBuffer = new MutationBuffer();\n mutationBuffers.push(mutationBuffer);\n // see mutation.ts for details\n mutationBuffer.init(options);\n let mutationObserverCtor =\n window.MutationObserver ||\n /**\n * Some websites may disable MutationObserver by removing it from the window object.\n * If someone is using rrweb to build a browser extention or things like it, they\n * could not change the website's code but can have an opportunity to inject some\n * code before the website executing its JS logic.\n * Then they can do this to store the native MutationObserver:\n * window.__rrMutationObserver = MutationObserver\n */\n (window as WindowWithStoredMutationObserver).__rrMutationObserver;\n const angularZoneSymbol = (window as WindowWithAngularZone)?.Zone?.__symbol__?.(\n 'MutationObserver',\n );\n if (\n angularZoneSymbol &&\n ((window as unknown) as Record)[\n angularZoneSymbol\n ]\n ) {\n mutationObserverCtor = ((window as unknown) as Record<\n string,\n typeof MutationObserver\n >)[angularZoneSymbol];\n }\n const observer = new mutationObserverCtor(\n mutationBuffer.processMutations.bind(mutationBuffer),\n );\n observer.observe(rootEl, {\n attributes: true,\n attributeOldValue: true,\n characterData: true,\n characterDataOldValue: true,\n childList: true,\n subtree: true,\n });\n return observer;\n}\n\nfunction initMoveObserver({\n mousemoveCb,\n sampling,\n doc,\n mirror,\n}: observerParam): listenerHandler {\n if (sampling.mousemove === false) {\n return () => {};\n }\n\n const threshold =\n typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;\n const callbackThreshold =\n typeof sampling.mousemoveCallback === 'number'\n ? sampling.mousemoveCallback\n : 500;\n\n let positions: mousePosition[] = [];\n let timeBaseline: number | null;\n const wrappedCb = throttle(\n (\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n ) => {\n const totalOffset = Date.now() - timeBaseline!;\n mousemoveCb(\n positions.map((p) => {\n p.timeOffset -= totalOffset;\n return p;\n }),\n source,\n );\n positions = [];\n timeBaseline = null;\n },\n callbackThreshold,\n );\n const updatePosition = throttle(\n (evt) => {\n const target = getEventTarget(evt);\n const { clientX, clientY } = isTouchEvent(evt)\n ? evt.changedTouches[0]\n : evt;\n if (!timeBaseline) {\n timeBaseline = Date.now();\n }\n positions.push({\n x: clientX,\n y: clientY,\n id: mirror.getId(target as INode),\n timeOffset: Date.now() - timeBaseline,\n });\n // it is possible DragEvent is undefined even on devices\n // that support event 'drag'\n wrappedCb(\n typeof DragEvent !== 'undefined' && evt instanceof DragEvent\n ? IncrementalSource.Drag\n : evt instanceof MouseEvent\n ? IncrementalSource.MouseMove\n : IncrementalSource.TouchMove,\n );\n },\n threshold,\n {\n trailing: false,\n },\n );\n const handlers = [\n on('mousemove', updatePosition, doc),\n on('touchmove', updatePosition, doc),\n on('drag', updatePosition, doc),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initMouseInteractionObserver({\n mouseInteractionCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: observerParam): listenerHandler {\n if (sampling.mouseInteraction === false) {\n return () => {};\n }\n const disableMap: Record =\n sampling.mouseInteraction === true ||\n sampling.mouseInteraction === undefined\n ? {}\n : sampling.mouseInteraction;\n\n const handlers: listenerHandler[] = [];\n const getHandler = (eventKey: keyof typeof MouseInteractions) => {\n return (event: MouseEvent | TouchEvent) => {\n const target = getEventTarget(event) as Node;\n if (isBlocked(target as Node, blockClass)) {\n return;\n }\n const e = isTouchEvent(event) ? event.changedTouches[0] : event;\n if (!e) {\n return;\n }\n const id = mirror.getId(target as INode);\n const { clientX, clientY } = e;\n mouseInteractionCb({\n type: MouseInteractions[eventKey],\n id,\n x: clientX,\n y: clientY,\n });\n };\n };\n Object.keys(MouseInteractions)\n .filter(\n (key) =>\n Number.isNaN(Number(key)) &&\n !key.endsWith('_Departed') &&\n disableMap[key] !== false,\n )\n .forEach((eventKey: keyof typeof MouseInteractions) => {\n const eventName = eventKey.toLowerCase();\n const handler = getHandler(eventKey);\n handlers.push(on(eventName, handler, doc));\n });\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nexport function initScrollObserver({\n scrollCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: Pick<\n observerParam,\n 'scrollCb' | 'doc' | 'mirror' | 'blockClass' | 'sampling'\n>): listenerHandler {\n const updatePosition = throttle((evt) => {\n const target = getEventTarget(evt);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const id = mirror.getId(target as INode);\n if (target === doc) {\n const scrollEl = (doc.scrollingElement || doc.documentElement)!;\n scrollCb({\n id,\n x: scrollEl.scrollLeft,\n y: scrollEl.scrollTop,\n });\n } else {\n scrollCb({\n id,\n x: (target as HTMLElement).scrollLeft,\n y: (target as HTMLElement).scrollTop,\n });\n }\n }, sampling.scroll || 100);\n return on('scroll', updatePosition, doc);\n}\n\nfunction initViewportResizeObserver({\n viewportResizeCb,\n}: observerParam): listenerHandler {\n let lastH = -1;\n let lastW = -1;\n const updateDimension = throttle(() => {\n const height = getWindowHeight();\n const width = getWindowWidth();\n if (lastH !== height || lastW !== width) {\n viewportResizeCb({\n width: Number(width),\n height: Number(height),\n });\n lastH = height;\n lastW = width;\n }\n }, 200);\n return on('resize', updateDimension, window);\n}\n\nfunction wrapEventWithUserTriggeredFlag(\n v: inputValue,\n enable: boolean,\n): inputValue {\n const value = { ...v };\n if (!enable) delete value.userTriggered;\n return value;\n}\n\nexport const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];\nconst lastInputValueMap: WeakMap = new WeakMap();\nfunction initInputObserver({\n inputCb,\n doc,\n mirror,\n blockClass,\n ignoreClass,\n ignoreSelector,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskInputFn,\n sampling,\n userTriggeredOnInput,\n}: observerParam): listenerHandler {\n function eventHandler(event: Event) {\n let target = getEventTarget(event);\n const userTriggered = event.isTrusted;\n /**\n * If a site changes the value 'selected' of an option element, the value of its parent element, usually a select element, will be changed as well.\n * We can treat this change as a value change of the select element the current target belongs to.\n */\n if (target && (target as Element).tagName === 'OPTION')\n target = (target as Element).parentElement;\n if (\n !target ||\n !(target as Element).tagName ||\n INPUT_TAGS.indexOf((target as Element).tagName) < 0 ||\n isBlocked(target as Node, blockClass)\n ) {\n return;\n }\n const type: string | undefined = (target as HTMLInputElement).type;\n if ((target as HTMLElement).classList.contains(ignoreClass) || (ignoreSelector && (target as HTMLElement).matches(ignoreSelector))) {\n return;\n }\n let text = (target as HTMLInputElement).value;\n let isChecked = false;\n if (type === 'radio' || type === 'checkbox') {\n isChecked = (target as HTMLInputElement).checked;\n } else if (\n maskInputOptions[\n (target as Element).tagName.toLowerCase() as keyof MaskInputOptions\n ] ||\n maskInputOptions[type as keyof MaskInputOptions]\n ) {\n text = maskInputValue({\n input: (target as HTMLElement),\n maskInputOptions,\n maskInputSelector,\n unmaskInputSelector,\n tagName: (target as HTMLElement).tagName,\n type,\n value: text,\n maskInputFn,\n });\n }\n cbWithDedup(\n target,\n wrapEventWithUserTriggeredFlag(\n { text, isChecked, userTriggered },\n userTriggeredOnInput,\n ),\n );\n // if a radio was checked\n // the other radios with the same name attribute will be unchecked.\n const name: string | undefined = (target as HTMLInputElement).name;\n if (type === 'radio' && name && isChecked) {\n doc\n .querySelectorAll(`input[type=\"radio\"][name=\"${name}\"]`)\n .forEach((el) => {\n if (el !== target) {\n cbWithDedup(\n el,\n wrapEventWithUserTriggeredFlag(\n {\n text: (el as HTMLInputElement).value,\n isChecked: !isChecked,\n userTriggered: false,\n },\n userTriggeredOnInput,\n ),\n );\n }\n });\n }\n }\n function cbWithDedup(target: EventTarget, v: inputValue) {\n const lastInputValue = lastInputValueMap.get(target);\n if (\n !lastInputValue ||\n lastInputValue.text !== v.text ||\n lastInputValue.isChecked !== v.isChecked\n ) {\n lastInputValueMap.set(target, v);\n const id = mirror.getId(target as INode);\n inputCb({\n ...v,\n id,\n });\n }\n }\n const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];\n const handlers: Array<\n listenerHandler | hookResetter\n > = events.map((eventName) => on(eventName, eventHandler, doc));\n const propertyDescriptor = Object.getOwnPropertyDescriptor(\n HTMLInputElement.prototype,\n 'value',\n );\n const hookProperties: Array<[HTMLElement, string]> = [\n [HTMLInputElement.prototype, 'value'],\n [HTMLInputElement.prototype, 'checked'],\n [HTMLSelectElement.prototype, 'value'],\n [HTMLTextAreaElement.prototype, 'value'],\n // Some UI library use selectedIndex to set select value\n [HTMLSelectElement.prototype, 'selectedIndex'],\n [HTMLOptionElement.prototype, 'selected'],\n ];\n if (propertyDescriptor && propertyDescriptor.set) {\n handlers.push(\n ...hookProperties.map((p) =>\n hookSetter(p[0], p[1], {\n set() {\n // mock to a normal event\n eventHandler({ target: this } as Event);\n },\n }),\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\ntype GroupingCSSRule =\n | CSSGroupingRule\n | CSSMediaRule\n | CSSSupportsRule\n | CSSConditionRule;\ntype GroupingCSSRuleTypes =\n | typeof CSSGroupingRule\n | typeof CSSMediaRule\n | typeof CSSSupportsRule\n | typeof CSSConditionRule;\n\nfunction getNestedCSSRulePositions(rule: CSSRule): number[] {\n const positions: number[] = [];\n function recurse(childRule: CSSRule, pos: number[]) {\n if (\n (isCSSGroupingRuleSupported &&\n childRule.parentRule instanceof CSSGroupingRule) ||\n (isCSSMediaRuleSupported &&\n childRule.parentRule instanceof CSSMediaRule) ||\n (isCSSSupportsRuleSupported &&\n childRule.parentRule instanceof CSSSupportsRule) ||\n (isCSSConditionRuleSupported &&\n childRule.parentRule instanceof CSSConditionRule)\n ) {\n const rules = Array.from(\n (childRule.parentRule as GroupingCSSRule).cssRules,\n );\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n } else {\n const rules = Array.from(childRule.parentStyleSheet!.cssRules);\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n }\n return pos;\n }\n return recurse(rule, positions);\n}\n\nfunction initStyleSheetObserver(\n { styleSheetRuleCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {\n // If, for whatever reason, CSSStyleSheet is not available, we skip the observation of stylesheets.\n return () => {};\n }\n\n const insertRule = win.CSSStyleSheet.prototype.insertRule;\n win.CSSStyleSheet.prototype.insertRule = function (\n rule: string,\n index?: number,\n ) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [{ rule, index }],\n });\n }\n return insertRule.apply(this, arguments);\n };\n\n const deleteRule = win.CSSStyleSheet.prototype.deleteRule;\n win.CSSStyleSheet.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index }],\n });\n }\n return deleteRule.apply(this, arguments);\n };\n\n const supportedNestedCSSRuleTypes: {\n [key: string]: GroupingCSSRuleTypes;\n } = {};\n if (isCSSGroupingRuleSupported) {\n supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;\n } else {\n // Some browsers (Safari) don't support CSSGroupingRule\n // https://caniuse.com/?search=cssgroupingrule\n // fall back to monkey patching classes that would have inherited from CSSGroupingRule\n\n if (isCSSMediaRuleSupported) {\n supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;\n }\n if (isCSSConditionRuleSupported) {\n supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;\n }\n if (isCSSSupportsRuleSupported) {\n supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;\n }\n }\n\n const unmodifiedFunctions: {\n [key: string]: {\n insertRule: (rule: string, index?: number) => number;\n deleteRule: (index: number) => void;\n };\n } = {};\n\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n unmodifiedFunctions[typeKey] = {\n insertRule: (type as GroupingCSSRuleTypes).prototype.insertRule,\n deleteRule: (type as GroupingCSSRuleTypes).prototype.deleteRule,\n };\n\n type.prototype.insertRule = function (rule: string, index?: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [\n {\n rule,\n index: [\n ...getNestedCSSRulePositions(this),\n index || 0, // defaults to 0\n ],\n },\n ],\n });\n }\n return unmodifiedFunctions[typeKey].insertRule.apply(this, arguments);\n };\n\n type.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index: [...getNestedCSSRulePositions(this), index] }],\n });\n }\n return unmodifiedFunctions[typeKey].deleteRule.apply(this, arguments);\n };\n });\n\n return () => {\n win.CSSStyleSheet.prototype.insertRule = insertRule;\n win.CSSStyleSheet.prototype.deleteRule = deleteRule;\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;\n type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;\n });\n };\n}\n\nfunction initStyleDeclarationObserver(\n { styleDeclarationCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n const setProperty = win.CSSStyleDeclaration.prototype.setProperty;\n win.CSSStyleDeclaration.prototype.setProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n value: string,\n priority: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n set: {\n property,\n value,\n priority,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return setProperty.apply(this, arguments);\n };\n\n const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n remove: {\n property,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return removeProperty.apply(this, arguments);\n };\n\n return () => {\n win.CSSStyleDeclaration.prototype.setProperty = setProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;\n };\n}\n\nfunction initMediaInteractionObserver({\n mediaInteractionCb,\n blockClass,\n mirror,\n sampling,\n}: observerParam): listenerHandler {\n const handler = (type: MediaInteractions) =>\n throttle((event: Event) => {\n const target = getEventTarget(event);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const { currentTime, volume, muted } = target as HTMLMediaElement;\n mediaInteractionCb({\n type,\n id: mirror.getId(target as INode),\n currentTime,\n volume,\n muted,\n });\n }, sampling.media || 500);\n const handlers = [\n on('play', handler(MediaInteractions.Play)),\n on('pause', handler(MediaInteractions.Pause)),\n on('seeked', handler(MediaInteractions.Seeked)),\n on('volumechange', handler(MediaInteractions.VolumeChange)),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initFontObserver({ fontCb, doc }: observerParam): listenerHandler {\n const win = doc.defaultView as IWindow;\n if (!win) {\n return () => {};\n }\n\n const handlers: listenerHandler[] = [];\n\n const fontMap = new WeakMap();\n\n const originalFontFace = win.FontFace;\n win.FontFace = (function FontFace(\n family: string,\n source: string | ArrayBufferView,\n descriptors?: FontFaceDescriptors,\n ) {\n const fontFace = new originalFontFace(family, source, descriptors);\n fontMap.set(fontFace, {\n family,\n buffer: typeof source !== 'string',\n descriptors,\n fontSource:\n typeof source === 'string'\n ? source\n : // tslint:disable-next-line: no-any\n JSON.stringify(Array.from(new Uint8Array(source as any))),\n });\n return fontFace;\n } as unknown) as typeof FontFace;\n\n const restoreHandler = patch(doc.fonts, 'add', function (original) {\n return function (this: FontFaceSet, fontFace: FontFace) {\n setTimeout(() => {\n const p = fontMap.get(fontFace);\n if (p) {\n fontCb(p);\n fontMap.delete(fontFace);\n }\n }, 0);\n return original.apply(this, [fontFace]);\n };\n });\n\n handlers.push(() => {\n win.FontFace = originalFontFace;\n });\n handlers.push(restoreHandler);\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction mergeHooks(o: observerParam, hooks: hooksParam) {\n const {\n mutationCb,\n mousemoveCb,\n mouseInteractionCb,\n scrollCb,\n viewportResizeCb,\n inputCb,\n mediaInteractionCb,\n styleSheetRuleCb,\n styleDeclarationCb,\n canvasMutationCb,\n fontCb,\n } = o;\n o.mutationCb = (...p: Arguments) => {\n if (hooks.mutation) {\n hooks.mutation(...p);\n }\n mutationCb(...p);\n };\n o.mousemoveCb = (...p: Arguments) => {\n if (hooks.mousemove) {\n hooks.mousemove(...p);\n }\n mousemoveCb(...p);\n };\n o.mouseInteractionCb = (...p: Arguments) => {\n if (hooks.mouseInteraction) {\n hooks.mouseInteraction(...p);\n }\n mouseInteractionCb(...p);\n };\n o.scrollCb = (...p: Arguments) => {\n if (hooks.scroll) {\n hooks.scroll(...p);\n }\n scrollCb(...p);\n };\n o.viewportResizeCb = (...p: Arguments) => {\n if (hooks.viewportResize) {\n hooks.viewportResize(...p);\n }\n viewportResizeCb(...p);\n };\n o.inputCb = (...p: Arguments) => {\n if (hooks.input) {\n hooks.input(...p);\n }\n inputCb(...p);\n };\n o.mediaInteractionCb = (...p: Arguments) => {\n if (hooks.mediaInteaction) {\n hooks.mediaInteaction(...p);\n }\n mediaInteractionCb(...p);\n };\n o.styleSheetRuleCb = (...p: Arguments) => {\n if (hooks.styleSheetRule) {\n hooks.styleSheetRule(...p);\n }\n styleSheetRuleCb(...p);\n };\n o.styleDeclarationCb = (...p: Arguments) => {\n if (hooks.styleDeclaration) {\n hooks.styleDeclaration(...p);\n }\n styleDeclarationCb(...p);\n };\n o.canvasMutationCb = (...p: Arguments) => {\n if (hooks.canvasMutation) {\n hooks.canvasMutation(...p);\n }\n canvasMutationCb(...p);\n };\n o.fontCb = (...p: Arguments) => {\n if (hooks.font) {\n hooks.font(...p);\n }\n fontCb(...p);\n };\n}\n\nexport function initObservers(\n o: observerParam,\n hooks: hooksParam = {},\n): listenerHandler {\n const currentWindow = o.doc.defaultView; // basically document.window\n if (!currentWindow) {\n return () => {};\n }\n\n mergeHooks(o, hooks);\n const mutationObserver = initMutationObserver(o, o.doc);\n const mousemoveHandler = initMoveObserver(o);\n const mouseInteractionHandler = initMouseInteractionObserver(o);\n const scrollHandler = initScrollObserver(o);\n const viewportResizeHandler = initViewportResizeObserver(o);\n const inputHandler = initInputObserver(o);\n const mediaInteractionHandler = initMediaInteractionObserver(o);\n\n const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });\n const styleDeclarationObserver = initStyleDeclarationObserver(o, {\n win: currentWindow,\n });\n const fontObserver = o.collectFonts ? initFontObserver(o) : () => {};\n // plugins\n const pluginHandlers: listenerHandler[] = [];\n for (const plugin of o.plugins) {\n pluginHandlers.push(\n plugin.observer(plugin.callback, currentWindow, plugin.options),\n );\n }\n\n return () => {\n mutationBuffers.forEach((b) => b.reset());\n mutationObserver.disconnect();\n mousemoveHandler();\n mouseInteractionHandler();\n scrollHandler();\n viewportResizeHandler();\n inputHandler();\n mediaInteractionHandler();\n styleSheetObserver();\n styleDeclarationObserver();\n fontObserver();\n pluginHandlers.forEach((h) => h());\n };\n}\n","import { serializedNodeWithId, INode } from 'rrweb-snapshot';\nimport { mutationCallBack } from '../types';\n\nexport class IframeManager {\n private iframes: WeakMap = new WeakMap();\n private mutationCb: mutationCallBack;\n private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;\n\n constructor(options: { mutationCb: mutationCallBack }) {\n this.mutationCb = options.mutationCb;\n }\n\n public addIframe(iframeEl: HTMLIFrameElement) {\n this.iframes.set(iframeEl, true);\n }\n\n public addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown) {\n this.loadListener = cb;\n }\n\n public attachIframe(iframeEl: INode, childSn: serializedNodeWithId) {\n this.mutationCb({\n adds: [\n {\n parentId: iframeEl.__sn.id,\n nextId: null,\n node: childSn,\n },\n ],\n removes: [],\n texts: [],\n attributes: [],\n isAttachIframe: true,\n });\n this.loadListener?.((iframeEl as unknown) as HTMLIFrameElement);\n }\n}\n","import {\n mutationCallBack,\n Mirror,\n scrollCallback,\n MutationBufferParam,\n SamplingStrategy,\n} from '../types';\nimport { initMutationObserver, initScrollObserver } from './observer';\nimport { patch } from '../utils';\n\ntype BypassOptions = Omit<\n MutationBufferParam,\n 'doc' | 'mutationCb' | 'mirror' | 'shadowDomManager'\n> & {\n sampling: SamplingStrategy;\n};\n\nexport class ShadowDomManager {\n private mutationCb: mutationCallBack;\n private scrollCb: scrollCallback;\n private bypassOptions: BypassOptions;\n private mirror: Mirror;\n private restorePatches: (() => void)[] = [];\n\n constructor(options: {\n mutationCb: mutationCallBack;\n scrollCb: scrollCallback;\n bypassOptions: BypassOptions;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.scrollCb = options.scrollCb;\n this.bypassOptions = options.bypassOptions;\n this.mirror = options.mirror;\n\n // Patch 'attachShadow' to observe newly added shadow doms.\n const manager = this;\n this.restorePatches.push(\n patch(HTMLElement.prototype, 'attachShadow', function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(this.shadowRoot, this.ownerDocument);\n return shadowRoot;\n };\n }),\n );\n }\n\n public addShadowRoot(shadowRoot: ShadowRoot, doc: Document) {\n initMutationObserver(\n {\n ...this.bypassOptions,\n doc,\n mutationCb: this.mutationCb,\n mirror: this.mirror,\n shadowDomManager: this,\n },\n shadowRoot,\n );\n initScrollObserver({\n ...this.bypassOptions,\n scrollCb: this.scrollCb,\n // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813\n // scroll is not allowed to pass the boundary, so we need to listen the shadow document\n doc: (shadowRoot as unknown) as Document,\n mirror: this.mirror,\n });\n }\n\n /**\n * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.\n */\n public observeAttachShadow(iframeElement: HTMLIFrameElement) {\n if (iframeElement.contentWindow) {\n const manager = this;\n this.restorePatches.push(\n patch(\n (iframeElement.contentWindow as Window & {\n HTMLElement: { prototype: HTMLElement };\n }).HTMLElement.prototype,\n 'attachShadow',\n function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(\n this.shadowRoot,\n iframeElement.contentDocument as Document,\n );\n return shadowRoot;\n };\n },\n ),\n );\n }\n }\n\n public reset() {\n this.restorePatches.forEach((restorePatch) => restorePatch());\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { encode } from 'base64-arraybuffer';\nimport { IWindow, SerializedWebGlArg } from '../../../types';\n\n// TODO: unify with `replay/webgl.ts`\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nexport const saveWebGLVar = (\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): number | void => {\n if (\n !value ||\n !(isInstanceOfWebGLObject(value, win) || typeof value === 'object')\n )\n return;\n\n const name = value.constructor.name;\n const list = variableListFor(ctx, name);\n let index = list.indexOf(value);\n\n if (index === -1) {\n index = list.length;\n list.push(value);\n }\n return index;\n};\n\n// from webgl-recorder: https://github.com/evanw/webgl-recorder/blob/bef0e65596e981ee382126587e2dcbe0fc7748e2/webgl-recorder.js#L50-L77\nexport function serializeArg(\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): SerializedWebGlArg {\n if (value instanceof Array) {\n return value.map((arg) => serializeArg(arg, win, ctx));\n } else if (value === null) {\n return value;\n } else if (\n value instanceof Float32Array ||\n value instanceof Float64Array ||\n value instanceof Int32Array ||\n value instanceof Uint32Array ||\n value instanceof Uint8Array ||\n value instanceof Uint16Array ||\n value instanceof Int16Array ||\n value instanceof Int8Array ||\n value instanceof Uint8ClampedArray\n ) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [Object.values(value)],\n };\n } else if (\n // SharedArrayBuffer disabled on most browsers due to spectre.\n // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer\n // value instanceof SharedArrayBuffer ||\n value instanceof ArrayBuffer\n ) {\n const name = value.constructor.name as 'ArrayBuffer';\n const base64 = encode(value);\n\n return {\n rr_type: name,\n base64,\n };\n } else if (value instanceof DataView) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [\n serializeArg(value.buffer, win, ctx),\n value.byteOffset,\n value.byteLength,\n ],\n };\n } else if (value instanceof HTMLImageElement) {\n const name = value.constructor.name;\n const { src } = value;\n return {\n rr_type: name,\n src,\n };\n } else if (value instanceof ImageData) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [serializeArg(value.data, win, ctx), value.width, value.height],\n };\n } else if (isInstanceOfWebGLObject(value, win) || typeof value === 'object') {\n const name = value.constructor.name;\n const index = saveWebGLVar(value, win, ctx) as number;\n\n return {\n rr_type: name,\n index: index,\n };\n }\n\n return value;\n}\n\nexport const serializeArgs = (\n args: Array,\n win: IWindow,\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n) => {\n return [...args].map((arg) => serializeArg(arg, win, ctx));\n};\n\nexport const isInstanceOfWebGLObject = (\n value: any,\n win: IWindow,\n): value is\n | WebGLActiveInfo\n | WebGLBuffer\n | WebGLFramebuffer\n | WebGLProgram\n | WebGLRenderbuffer\n | WebGLShader\n | WebGLShaderPrecisionFormat\n | WebGLTexture\n | WebGLUniformLocation\n | WebGLVertexArrayObject => {\n const webGLConstructorNames: string[] = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.\n 'WebGLVertexArrayObjectOES',\n ];\n const supportedWebGLConstructorNames = webGLConstructorNames.filter(\n (name: string) => typeof win[name as keyof Window] === 'function',\n );\n return Boolean(\n supportedWebGLConstructorNames.find(\n (name: string) => value instanceof win[name as keyof Window],\n ),\n );\n};\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\nimport { saveWebGLVar, serializeArgs } from './serialize-args';\n\nfunction patchGLPrototype(\n prototype: WebGLRenderingContext | WebGL2RenderingContext,\n type: CanvasContext,\n cb: canvasManagerMutationCallback,\n blockClass: blockClass,\n mirror: Mirror,\n win: IWindow,\n): listenerHandler[] {\n const handlers: listenerHandler[] = [];\n\n const props = Object.getOwnPropertyNames(prototype);\n\n for (const prop of props) {\n try {\n if (typeof prototype[prop as keyof typeof prototype] !== 'function') {\n continue;\n }\n const restoreHandler = patch(prototype, prop, function (original) {\n return function (this: typeof prototype, ...args: Array) {\n const result = original.apply(this, args);\n saveWebGLVar(result, win, prototype);\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n const id = mirror.getId((this.canvas as unknown) as INode);\n\n const recordArgs = serializeArgs([...args], win, prototype);\n const mutation: canvasMutationWithType = {\n type,\n property: prop,\n args: recordArgs,\n };\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, mutation);\n }\n\n return result;\n };\n });\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(prototype, prop, {\n set(v) {\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, {\n type,\n property: prop,\n args: [v],\n setter: true,\n });\n },\n });\n handlers.push(hookHandler);\n }\n }\n\n return handlers;\n}\n\nexport default function initCanvasWebGLMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n\n handlers.push(\n ...patchGLPrototype(\n win.WebGLRenderingContext.prototype,\n CanvasContext.WebGL,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n\n if (typeof win.WebGL2RenderingContext !== 'undefined') {\n handlers.push(\n ...patchGLPrototype(\n win.WebGL2RenderingContext.prototype,\n CanvasContext.WebGL2,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n }\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n canvasManagerMutationCallback,\n canvasMutationCallback,\n canvasMutationCommand,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport initCanvas2DMutationObserver from './2d';\nimport initCanvasContextObserver from './canvas';\nimport initCanvasWebGLMutationObserver from './webgl';\n\nexport type RafStamps = { latestId: number; invokeId: number | null };\n\ntype pendingCanvasMutationsMap = Map<\n HTMLCanvasElement,\n canvasMutationWithType[]\n>;\n\nexport class CanvasManager {\n private pendingCanvasMutations: pendingCanvasMutationsMap = new Map();\n private rafStamps: RafStamps = { latestId: 0, invokeId: null };\n private mirror: Mirror;\n\n private mutationCb: canvasMutationCallback;\n private resetObservers?: listenerHandler;\n private frozen: boolean = false;\n private locked: boolean = false;\n\n public reset() {\n this.pendingCanvasMutations.clear();\n this.resetObservers && this.resetObservers();\n }\n\n public freeze() {\n this.frozen = true;\n }\n\n public unfreeze() {\n this.frozen = false;\n }\n\n public lock() {\n this.locked = true;\n }\n\n public unlock() {\n this.locked = false;\n }\n\n constructor(options: {\n recordCanvas: boolean | number;\n mutationCb: canvasMutationCallback;\n win: IWindow;\n blockClass: blockClass;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.mirror = options.mirror;\n\n if (options.recordCanvas === true)\n this.initCanvasMutationObserver(options.win, options.blockClass);\n }\n\n private processMutation: canvasManagerMutationCallback = function (\n target,\n mutation,\n ) {\n const newFrame =\n this.rafStamps.invokeId &&\n this.rafStamps.latestId !== this.rafStamps.invokeId;\n if (newFrame || !this.rafStamps.invokeId)\n this.rafStamps.invokeId = this.rafStamps.latestId;\n\n if (!this.pendingCanvasMutations.has(target)) {\n this.pendingCanvasMutations.set(target, []);\n }\n\n this.pendingCanvasMutations.get(target)!.push(mutation);\n };\n\n private initCanvasMutationObserver(\n win: IWindow,\n blockClass: blockClass,\n ): void {\n this.startRAFTimestamping();\n this.startPendingCanvasMutationFlusher();\n\n const canvasContextReset = initCanvasContextObserver(win, blockClass);\n const canvas2DReset = initCanvas2DMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n this.resetObservers = () => {\n canvasContextReset();\n canvas2DReset();\n canvasWebGL1and2Reset();\n };\n }\n\n private startPendingCanvasMutationFlusher() {\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n private startRAFTimestamping() {\n const setLatestRAFTimestamp = (timestamp: DOMHighResTimeStamp) => {\n this.rafStamps.latestId = timestamp;\n requestAnimationFrame(setLatestRAFTimestamp);\n };\n requestAnimationFrame(setLatestRAFTimestamp);\n }\n\n flushPendingCanvasMutations() {\n this.pendingCanvasMutations.forEach(\n (values: canvasMutationCommand[], canvas: HTMLCanvasElement) => {\n const id = this.mirror.getId((canvas as unknown) as INode);\n this.flushPendingCanvasMutationFor(canvas, id);\n },\n );\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n flushPendingCanvasMutationFor(canvas: HTMLCanvasElement, id: number) {\n if (this.frozen || this.locked) {\n return;\n }\n\n const valuesWithType = this.pendingCanvasMutations.get(canvas);\n if (!valuesWithType || id === -1) return;\n\n const values = valuesWithType.map((value) => {\n const { type, ...rest } = value;\n return rest;\n });\n const { type } = valuesWithType[0];\n\n this.mutationCb({ id, type, commands: values });\n\n this.pendingCanvasMutations.delete(canvas);\n }\n}\n","import { snapshot, MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';\nimport { initObservers, mutationBuffers } from './observer';\nimport {\n on,\n getWindowWidth,\n getWindowHeight,\n polyfill,\n isIframeINode,\n hasShadowRoot,\n createMirror,\n} from '../utils';\nimport {\n EventType,\n event,\n eventWithTime,\n recordOptions,\n IncrementalSource,\n listenerHandler,\n mutationCallbackParam,\n scrollCallback,\n canvasMutationParam,\n} from '../types';\nimport { IframeManager } from './iframe-manager';\nimport { ShadowDomManager } from './shadow-dom-manager';\nimport { CanvasManager } from './observers/canvas/canvas-manager';\n\nfunction wrapEvent(e: event): eventWithTime {\n return {\n ...e,\n timestamp: Date.now(),\n };\n}\n\nlet wrappedEmit!: (e: eventWithTime, isCheckout?: boolean) => void;\n\nlet takeFullSnapshot!: (isCheckout?: boolean) => void;\n\nconst mirror = createMirror();\nfunction record(\n options: recordOptions = {},\n): listenerHandler | undefined {\n const {\n emit,\n checkoutEveryNms,\n checkoutEveryNth,\n blockClass = 'rr-block',\n blockSelector = null,\n unblockSelector = null,\n ignoreClass = 'rr-ignore',\n ignoreSelector =null,\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n maskInputSelector = null,\n unmaskTextSelector = null,\n unmaskInputSelector = null,\n inlineStylesheet = true,\n maskAllInputs,\n maskInputOptions: _maskInputOptions,\n slimDOMOptions: _slimDOMOptions,\n maskInputFn,\n maskTextFn,\n hooks,\n packFn,\n sampling = {},\n mousemoveWait,\n recordCanvas = false,\n userTriggeredOnInput = false,\n collectFonts = false,\n inlineImages = false,\n plugins,\n keepIframeSrcFn = () => false,\n } = options;\n // runtime checks for user options\n if (!emit) {\n throw new Error('emit function is required');\n }\n // move departed options to new options\n if (mousemoveWait !== undefined && sampling.mousemove === undefined) {\n sampling.mousemove = mousemoveWait;\n }\n\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : _maskInputOptions !== undefined\n ? _maskInputOptions\n : { password: true };\n\n const slimDOMOptions: SlimDOMOptions =\n _slimDOMOptions === true || _slimDOMOptions === 'all'\n ? {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaVerification: true,\n // the following are off for slimDOMOptions === true,\n // as they destroy some (hidden) info:\n headMetaAuthorship: _slimDOMOptions === 'all',\n headMetaDescKeywords: _slimDOMOptions === 'all',\n }\n : _slimDOMOptions\n ? _slimDOMOptions\n : {};\n\n polyfill();\n\n let lastFullSnapshotEvent: eventWithTime;\n let incrementalSnapshotCount = 0;\n const eventProcessor = (e: eventWithTime): T => {\n for (const plugin of plugins || []) {\n if (plugin.eventProcessor) {\n e = plugin.eventProcessor(e);\n }\n }\n if (packFn) {\n e = (packFn(e) as unknown) as eventWithTime;\n }\n return (e as unknown) as T;\n };\n wrappedEmit = (e: eventWithTime, isCheckout?: boolean) => {\n if (\n mutationBuffers[0]?.isFrozen() &&\n e.type !== EventType.FullSnapshot &&\n !(\n e.type === EventType.IncrementalSnapshot &&\n e.data.source === IncrementalSource.Mutation\n )\n ) {\n // we've got a user initiated event so first we need to apply\n // all DOM changes that have been buffering during paused state\n mutationBuffers.forEach((buf) => buf.unfreeze());\n }\n\n emit(eventProcessor(e), isCheckout);\n if (e.type === EventType.FullSnapshot) {\n lastFullSnapshotEvent = e;\n incrementalSnapshotCount = 0;\n } else if (e.type === EventType.IncrementalSnapshot) {\n // attach iframe should be considered as full snapshot\n if (\n e.data.source === IncrementalSource.Mutation &&\n e.data.isAttachIframe\n ) {\n return;\n }\n\n incrementalSnapshotCount++;\n const exceedCount =\n checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;\n const exceedTime =\n checkoutEveryNms &&\n e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;\n if (exceedCount || exceedTime) {\n takeFullSnapshot(true);\n }\n }\n };\n\n const wrappedMutationEmit = (m: mutationCallbackParam) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Mutation,\n ...m,\n },\n }),\n );\n };\n const wrappedScrollEmit: scrollCallback = (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Scroll,\n ...p,\n },\n }),\n );\n const wrappedCanvasMutationEmit = (p: canvasMutationParam) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.CanvasMutation,\n ...p,\n },\n }),\n );\n\n const iframeManager = new IframeManager({\n mutationCb: wrappedMutationEmit,\n });\n\n const canvasManager = new CanvasManager({\n recordCanvas,\n mutationCb: wrappedCanvasMutationEmit,\n win: window,\n blockClass,\n mirror,\n });\n\n const shadowDomManager = new ShadowDomManager({\n mutationCb: wrappedMutationEmit,\n scrollCb: wrappedScrollEmit,\n bypassOptions: {\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n maskInputSelector,\n unmaskInputSelector,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n recordCanvas,\n inlineImages,\n sampling,\n slimDOMOptions,\n iframeManager,\n canvasManager,\n },\n mirror,\n });\n\n takeFullSnapshot = (isCheckout = false) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Meta,\n data: {\n href: window.location.href,\n width: getWindowWidth(),\n height: getWindowHeight(),\n },\n }),\n isCheckout,\n );\n\n mutationBuffers.forEach((buf) => buf.lock()); // don't allow any mirror modifications during snapshotting\n const [node, idNodeMap] = snapshot(document, {\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n maskInputSelector,\n unmaskInputSelector,\n inlineStylesheet,\n maskAllInputs: maskInputOptions,\n maskTextFn,\n slimDOM: slimDOMOptions,\n recordCanvas,\n inlineImages,\n onSerialize: (n) => {\n if (isIframeINode(n)) {\n iframeManager.addIframe(n);\n }\n if (hasShadowRoot(n)) {\n shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n iframeManager.attachIframe(iframe, childSn);\n shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n keepIframeSrcFn,\n });\n\n if (!node) {\n return console.warn('Failed to snapshot the document');\n }\n\n mirror.map = idNodeMap;\n wrappedEmit(\n wrapEvent({\n type: EventType.FullSnapshot,\n data: {\n node,\n initialOffset: {\n left:\n window.pageXOffset !== undefined\n ? window.pageXOffset\n : document?.documentElement.scrollLeft ||\n document?.body?.parentElement?.scrollLeft ||\n document?.body.scrollLeft ||\n 0,\n top:\n window.pageYOffset !== undefined\n ? window.pageYOffset\n : document?.documentElement.scrollTop ||\n document?.body?.parentElement?.scrollTop ||\n document?.body.scrollTop ||\n 0,\n },\n },\n }),\n );\n mutationBuffers.forEach((buf) => buf.unlock()); // generate & emit any mutations that happened during snapshotting, as can now apply against the newly built mirror\n };\n\n try {\n const handlers: listenerHandler[] = [];\n handlers.push(\n on('DOMContentLoaded', () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.DomContentLoaded,\n data: {},\n }),\n );\n }),\n );\n\n const observe = (doc: Document) => {\n return initObservers(\n {\n mutationCb: wrappedMutationEmit,\n mousemoveCb: (positions, source) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source,\n positions,\n },\n }),\n ),\n mouseInteractionCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MouseInteraction,\n ...d,\n },\n }),\n ),\n scrollCb: wrappedScrollEmit,\n viewportResizeCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.ViewportResize,\n ...d,\n },\n }),\n ),\n inputCb: (v) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Input,\n ...v,\n },\n }),\n ),\n mediaInteractionCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MediaInteraction,\n ...p,\n },\n }),\n ),\n styleSheetRuleCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleSheetRule,\n ...r,\n },\n }),\n ),\n styleDeclarationCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleDeclaration,\n ...r,\n },\n }),\n ),\n canvasMutationCb: wrappedCanvasMutationEmit,\n fontCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Font,\n ...p,\n },\n }),\n ),\n blockClass,\n ignoreClass,\n ignoreSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n inlineStylesheet,\n sampling,\n recordCanvas,\n inlineImages,\n userTriggeredOnInput,\n collectFonts,\n doc,\n maskInputFn,\n maskTextFn,\n blockSelector,\n unblockSelector,\n slimDOMOptions,\n mirror,\n iframeManager,\n shadowDomManager,\n canvasManager,\n plugins:\n plugins\n ?.filter((p) => p.observer)\n ?.map((p) => ({\n observer: p.observer!,\n options: p.options,\n callback: (payload: object) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.Plugin,\n data: {\n plugin: p.name,\n payload,\n },\n }),\n ),\n })) || [],\n },\n hooks,\n );\n };\n\n iframeManager.addLoadListener((iframeEl) => {\n try {\n handlers.push(observe(iframeEl.contentDocument!));\n } catch (error) {\n // TODO: handle internal error\n console.warn(error);\n }\n });\n\n const init = () => {\n takeFullSnapshot();\n handlers.push(observe(document));\n };\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n init();\n } else {\n handlers.push(\n on(\n 'load',\n () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Load,\n data: {},\n }),\n );\n init();\n },\n window,\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n } catch (error) {\n // TODO: handle internal error\n console.warn(error);\n }\n}\n\nrecord.addCustomEvent = (tag: string, payload: T) => {\n if (!wrappedEmit) {\n throw new Error('please add custom event after start recording');\n }\n wrappedEmit(\n wrapEvent({\n type: EventType.Custom,\n data: {\n tag,\n payload,\n },\n }),\n );\n};\n\nrecord.freezePage = () => {\n mutationBuffers.forEach((buf) => buf.freeze());\n};\n\nrecord.takeFullSnapshot = (isCheckout?: boolean) => {\n if (!takeFullSnapshot) {\n throw new Error('please take full snapshot after start recording');\n }\n takeFullSnapshot(isCheckout);\n};\n\nrecord.mirror = mirror;\n\nexport default record;\n","import { INode, ICanvas } from 'rrweb-snapshot';\nimport { blockClass, IWindow, listenerHandler } from '../../../types';\nimport { isBlocked, patch } from '../../../utils';\n\nexport default function initCanvasContextObserver(\n win: IWindow,\n blockClass: blockClass,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n try {\n const restoreHandler = patch(\n win.HTMLCanvasElement.prototype,\n 'getContext',\n function (original) {\n return function (\n this: ICanvas,\n contextType: string,\n ...args: Array\n ) {\n if (!isBlocked((this as unknown) as INode, blockClass)) {\n if (!('__context' in this))\n (this as ICanvas).__context = contextType;\n }\n return original.apply(this, [contextType, ...args]);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n console.error('failed to patch HTMLCanvasElement.prototype.getContext');\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\n\nexport default function initCanvas2DMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n const props2D = Object.getOwnPropertyNames(\n win.CanvasRenderingContext2D.prototype,\n );\n for (const prop of props2D) {\n try {\n if (\n typeof win.CanvasRenderingContext2D.prototype[\n prop as keyof CanvasRenderingContext2D\n ] !== 'function'\n ) {\n continue;\n }\n const restoreHandler = patch(\n win.CanvasRenderingContext2D.prototype,\n prop,\n function (original) {\n return function (\n this: CanvasRenderingContext2D,\n ...args: Array\n ) {\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n // Using setTimeout as getImageData + JSON.stringify can be heavy\n // and we'd rather not block the main thread\n setTimeout(() => {\n const recordArgs = [...args];\n if (prop === 'drawImage') {\n if (\n recordArgs[0] &&\n recordArgs[0] instanceof HTMLCanvasElement\n ) {\n const canvas = recordArgs[0];\n const ctx = canvas.getContext('2d');\n let imgd = ctx?.getImageData(\n 0,\n 0,\n canvas.width,\n canvas.height,\n );\n let pix = imgd?.data;\n recordArgs[0] = JSON.stringify(pix);\n }\n }\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: recordArgs,\n });\n }, 0);\n }\n return original.apply(this, args);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(\n win.CanvasRenderingContext2D.prototype,\n prop,\n {\n set(v) {\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: [v],\n setter: true,\n });\n },\n },\n );\n handlers.push(hookHandler);\n }\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isShadowRoot","_a","host","Boolean","shadowRoot","maskInputValue","input","maskInputSelector","unmaskInputSelector","maskInputOptions","tagName","type","maskInputFn","text","matches","toLowerCase","repeat","ORIGINAL_ATTRIBUTE_NAME","canvasService","canvasCtx","_id","tagNameRegex","RegExp","getCssRulesString","rules","cssRules","map","getCssRuleString","join","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","stack","parts","pop","_i","parts_1","part","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","unmaskTextSelector","nodeType","ELEMENT_NODE","closest","classList","contains","eIndex","className","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","unblockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","Math","min","data","buffer","some","pixel","is2DCanvasBlank","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","isElement","_l","_m","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","on","fn","target","capture","passive","removeEventListener","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","getId","getNode","removeNodeFromMap","has","reset","throttle","func","wait","timeout","previous","arg","now","Date","leading","remaining","context","args","trailing","hookSetter","key","d","isRevoked","original","getOwnPropertyDescriptor","defineProperty","set","_this","patch","source","replacement","original_1","wrapped","defineProperties","__rrweb_original__","enumerable","getWindowHeight","window","innerHeight","documentElement","clientHeight","body","getWindowWidth","innerWidth","clientWidth","isBlocked","needBlock_1","forEach","isIgnored","isAncestorRemoved","mirror","isTouchEvent","event","changedTouches","isIframeINode","hasShadowRoot","isNodeInLinkedList","Proxy","Reflect","get","prop","receiver","DoubleLinkedList","position","Error","current","head","index","__ln","moveKey","parentId","isINode","Set","mutations","processMutation","emit","frozen","locked","adds","addList","getNextId","ns","nextId","pushAdd","shadowHost","getRootNode","rootShadowHost","notInDoc","addNode","currentN","iframeManager","addIframe","shadowDomManager","addShadowRoot","iframe","childSn","attachIframe","observeAttachShadow","mapRemoves","shift","movedSet","isParentRemoved","removes","addedSet","isAncestorInSet","droppedSet","add","candidate","_node","removeNode","payload","texts","filter","attribute","movedMap","mutationCb","oldValue","getAttribute","attributeName","item","old","setAttribute","style","styleObj","pname","newValue","getPropertyValue","newPriority","getPropertyPriority","addedNodes","genAdds","removedNodes","nodeId","deepDelete","targetId","delete","childN","MutationBuffer","canvasManager","freeze","unfreeze","lock","unlock","addsSet","mutationBuffers","isCSSGroupingRuleSupported","CSSGroupingRule","isCSSMediaRuleSupported","CSSMediaRule","isCSSSupportsRuleSupported","CSSSupportsRule","isCSSConditionRuleSupported","CSSConditionRule","getEventTarget","path","composedPath","initMutationObserver","rootEl","mutationBuffer","init","mutationObserverCtor","MutationObserver","__rrMutationObserver","angularZoneSymbol","Zone","__symbol__","observer","processMutations","bind","observe","attributeOldValue","characterData","characterDataOldValue","childList","subtree","initMouseInteractionObserver","mouseInteractionCb","sampling","mouseInteraction","disableMap","handlers","keys","Number","isNaN","eventKey","eventName","handler","clientX","clientY","getHandler","h","initScrollObserver","scrollCb","evt","scrollEl","scrollingElement","scroll","wrapEventWithUserTriggeredFlag","v","enable","userTriggered","INPUT_TAGS","lastInputValueMap","WeakMap","getNestedCSSRulePositions","childRule","parentRule","unshift","parentStyleSheet","recurse","initObservers","hooks","currentWindow","defaultView","mousemoveCb","viewportResizeCb","inputCb","mediaInteractionCb","styleSheetRuleCb","styleDeclarationCb","canvasMutationCb","fontCb","mutation","mousemove","viewportResize","mediaInteaction","styleSheetRule","styleDeclaration","canvasMutation","font","mergeHooks","mutationObserver","mousemoveHandler","timeBaseline","threshold","callbackThreshold","mousemoveCallback","positions","wrappedCb","totalOffset","timeOffset","updatePosition","DragEvent","Drag","MouseEvent","MouseMove","TouchMove","initMoveObserver","mouseInteractionHandler","scrollHandler","viewportResizeHandler","lastH","lastW","initViewportResizeObserver","inputHandler","ignoreClass","ignoreSelector","userTriggeredOnInput","eventHandler","isTrusted","parentElement","isChecked","cbWithDedup","querySelectorAll","lastInputValue","propertyDescriptor","HTMLInputElement","hookProperties","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement","initInputObserver","mediaInteractionHandler","volume","muted","media","initMediaInteractionObserver","styleSheetObserver","CSSStyleSheet","insertRule","ownerNode","deleteRule","supportedNestedCSSRuleTypes","unmodifiedFunctions","entries","typeKey","initStyleSheetObserver","styleDeclarationObserver","setProperty","CSSStyleDeclaration","priority","removeProperty","remove","initStyleDeclarationObserver","fontObserver","collectFonts","fontMap","originalFontFace","FontFace","family","descriptors","fontFace","fontSource","JSON","stringify","Uint8Array","restoreHandler","fonts","initFontObserver","pluginHandlers","plugins","plugin","callback","b","disconnect","IframeManager","iframes","cb","loadListener","isAttachIframe","manager","restorePatches","HTMLElement","ownerDocument","ShadowDomManager","iframeElement","manager_1","restorePatch","lookup","charCodeAt","webGLVarMap","Map","saveWebGLVar","isInstanceOfWebGLObject","list","ctor","contextMap","variableListFor","constructor","serializeArg","Float32Array","Float64Array","Int32Array","Uint16Array","Int16Array","Int8Array","Uint8ClampedArray","rr_type","values","ArrayBuffer","base64","arraybuffer","bytes","len","encode","DataView","byteOffset","byteLength","HTMLImageElement","ImageData","serializeArgs","supportedWebGLConstructorNames","patchGLPrototype","props","getOwnPropertyNames","result","recordArgs","hookHandler","setter","props_1","wrappedEmit","takeFullSnapshot","latestId","invokeId","rafStamps","pendingCanvasMutations","initCanvasMutationObserver","CanvasManager","clear","resetObservers","startRAFTimestamping","startPendingCanvasMutationFlusher","canvasContextReset","HTMLCanvasElement","contextType","initCanvasContextObserver","canvas2DReset","props2D","CanvasRenderingContext2D","imgd","pix","props2D_1","initCanvas2DMutationObserver","canvasWebGL1and2Reset","WebGLRenderingContext","WebGL","WebGL2RenderingContext","WebGL2","initCanvasWebGLMutationObserver","requestAnimationFrame","flushPendingCanvasMutations","setLatestRAFTimestamp","timestamp","flushPendingCanvasMutationFor","valuesWithType","getOwnPropertySymbols","propertyIsEnumerable","commands","wrapEvent","child","record","checkoutEveryNms","checkoutEveryNth","maskAllInputs","_maskInputOptions","_slimDOMOptions","packFn","mousemoveWait","_o","_p","_q","_r","_s","lastFullSnapshotEvent","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","NodeList","DOMTokenList","Node","incrementalSnapshotCount","isCheckout","isFrozen","FullSnapshot","IncrementalSnapshot","Mutation","buf","eventProcessor","exceedCount","exceedTime","wrappedMutationEmit","wrappedScrollEmit","Scroll","wrappedCanvasMutationEmit","CanvasMutation","Meta","slimDOM","idNodeMap","snapshot","initialOffset","left","pageXOffset","top","pageYOffset","handlers_1","DomContentLoaded","observe_1","MouseInteraction","ViewportResize","Input","MediaInteraction","StyleSheetRule","StyleDeclaration","Font","Plugin","addLoadListener","init_1","Load","addCustomEvent","tag","Custom","freezePage"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ED+BOC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,YAgFzB,SAASQ,EAASC,GACrB,IAAIZ,EAAsB,mBAAXa,QAAyBA,OAAOC,SAAUC,EAAIf,GAAKY,EAAEZ,GAAIC,EAAI,EAC5E,GAAIc,EAAG,OAAOA,EAAEP,KAAKI,GACrB,GAAIA,GAAyB,iBAAbA,EAAER,OAAqB,MAAO,CAC1CY,KAAM,WAEF,OADIJ,GAAKX,GAAKW,EAAER,SAAQQ,OAAI,GACrB,CAAEK,MAAOL,GAAKA,EAAEX,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lB,KAAM,CACJ+kB,MACAjX,eAMR4S,GAAOuE,WAAa,WAClBjV,GAAgBjG,SAAQ,SAAC+Y,GAAQ,OAAAA,EAAInT,aAGvC+Q,GAAOvC,iBAAmB,SAACsE,GACzB,IAAKtE,GACH,MAAM,IAAInT,MAAM,mDAElBmT,GAAiBsE,IAGnB/B,GAAOxW,OAASA"} +\ No newline at end of file +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay-unpack.css b/node_modules/rrweb/dist/replay/rrweb-replay-unpack.css +new file mode 100755 +index 0000000..b459e51 +--- /dev/null ++++ b/node_modules/rrweb/dist/replay/rrweb-replay-unpack.css +@@ -0,0 +1,79 @@ ++.replayer-wrapper { ++ position: relative; ++} ++.replayer-mouse { ++ position: absolute; ++ width: 20px; ++ height: 20px; ++ transition: left 0.05s linear, top 0.05s linear; ++ background-size: contain; ++ background-position: center center; ++ background-repeat: no-repeat; ++ background-image: url('data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzMwMHB4JyB3aWR0aD0nMzAwcHgnICBmaWxsPSIjMDAwMDAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGRhdGEtbmFtZT0iTGF5ZXIgMSIgdmlld0JveD0iMCAwIDUwIDUwIiB4PSIwcHgiIHk9IjBweCI+PHRpdGxlPkRlc2lnbl90bnA8L3RpdGxlPjxwYXRoIGQ9Ik00OC43MSw0Mi45MUwzNC4wOCwyOC4yOSw0NC4zMywxOEExLDEsMCwwLDAsNDQsMTYuMzlMMi4zNSwxLjA2QTEsMSwwLDAsMCwxLjA2LDIuMzVMMTYuMzksNDRhMSwxLDAsMCwwLDEuNjUuMzZMMjguMjksMzQuMDgsNDIuOTEsNDguNzFhMSwxLDAsMCwwLDEuNDEsMGw0LjM4LTQuMzhBMSwxLDAsMCwwLDQ4LjcxLDQyLjkxWm0tNS4wOSwzLjY3TDI5LDMyYTEsMSwwLDAsMC0xLjQxLDBsLTkuODUsOS44NUwzLjY5LDMuNjlsMzguMTIsMTRMMzIsMjcuNThBMSwxLDAsMCwwLDMyLDI5TDQ2LjU5LDQzLjYyWiI+PC9wYXRoPjwvc3ZnPg=='); ++ border-color: transparent; /* otherwise we transition from black when .touch-device class is added */ ++} ++.replayer-mouse::after { ++ content: ''; ++ display: inline-block; ++ width: 20px; ++ height: 20px; ++ background: rgb(73, 80, 246); ++ border-radius: 100%; ++ transform: translate(-50%, -50%); ++ opacity: 0.3; ++} ++.replayer-mouse.active::after { ++ animation: click 0.2s ease-in-out 1; ++} ++.replayer-mouse.touch-device { ++ background-image: none; /* there's no passive cursor on touch-only screens */ ++ width: 70px; ++ height: 70px; ++ border-width: 4px; ++ border-style: solid; ++ border-radius: 100%; ++ margin-left: -37px; ++ margin-top: -37px; ++ border-color: rgba(73, 80, 246, 0); ++ transition: left 0s linear, top 0s linear, border-color 0.2s ease-in-out; ++} ++.replayer-mouse.touch-device.touch-active { ++ border-color: rgba(73, 80, 246, 1); ++ transition: left 0.25s linear, top 0.25s linear, border-color 0.2s ease-in-out; ++} ++.replayer-mouse.touch-device::after { ++ opacity: 0; /* there's no passive cursor on touch-only screens */ ++} ++.replayer-mouse.touch-device.active::after { ++ animation: touch-click 0.2s ease-in-out 1; ++} ++.replayer-mouse-tail { ++ position: absolute; ++ pointer-events: none; ++} ++ ++@keyframes click { ++ 0% { ++ opacity: 0.3; ++ width: 20px; ++ height: 20px; ++ } ++ 50% { ++ opacity: 0.5; ++ width: 10px; ++ height: 10px; ++ } ++} ++ ++@keyframes touch-click { ++ 0% { ++ opacity: 0; ++ width: 20px; ++ height: 20px; ++ } ++ 50% { ++ opacity: 0.5; ++ width: 10px; ++ height: 10px; ++ } ++} +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay-unpack.js b/node_modules/rrweb/dist/replay/rrweb-replay-unpack.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.css b/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.css +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.css.map b/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.css.map +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.js b/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.js.map b/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.js.map +old mode 100644 +new mode 100755 +index 649285e..3cfa19b +--- a/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.js.map ++++ b/node_modules/rrweb/dist/replay/rrweb-replay-unpack.min.js.map +@@ -1 +1 @@ +-{"version":3,"file":"rrweb-replay-unpack.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../../node_modules/mitt/dist/mitt.es.js","../../../src/types.ts","../../../src/replay/smoothscroll.ts","../../../src/replay/timer.ts","../../../../node_modules/@xstate/fsm/es/index.js","../../../src/replay/machine.ts","../../../src/utils.ts","../../../src/replay/styles/inject-style.ts","../../../src/replay/virtual-styles.ts","../../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../../src/replay/canvas/webgl.ts","../../../src/replay/index.ts","../../../src/replay/canvas/index.ts","../../../src/replay/canvas/2d.ts","../../../../node_modules/fflate/esm/browser.js","../../../src/packer/unpack.ts","../../../src/packer/base.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type]) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector) {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","// \n// An event handler can take an optional event argument\n// and should not return a value\n \n \n\n// An array of all currently registered event handlers for a type\n \n \n// A map of event types and their corresponding event handlers.\n \n \n \n \n\n/** Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nfunction mitt(all ) {\n\tall = all || Object.create(null);\n\n\treturn {\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton: function on(type , handler ) {\n\t\t\t(all[type] || (all[type] = [])).push(handler);\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff: function off(type , handler ) {\n\t\t\tif (all[type]) {\n\t\t\t\tall[type].splice(all[type].indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * @param {String} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit: function emit(type , evt ) {\n\t\t\t(all[type] || []).slice().map(function (handler) { handler(evt); });\n\t\t\t(all['*'] || []).slice().map(function (handler) { handler(type, evt); });\n\t\t}\n\t};\n}\n\nexport default mitt;\n//# sourceMappingURL=mitt.es.js.map\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n ignoreClass?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n ignoreClass: string;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","/**\n * A fork version of https://github.com/iamdustan/smoothscroll\n * Add support of customize target window and document\n */\n\n// @ts-nocheck\n// tslint:disable\nexport function polyfill(w: Window = window, d = document) {\n // return if scroll behavior is supported and polyfill is not forced\n if (\n 'scrollBehavior' in d.documentElement.style &&\n w.__forceSmoothScrollPolyfill__ !== true\n ) {\n return;\n }\n\n // globals\n var Element = w.HTMLElement || w.Element;\n var SCROLL_TIME = 468;\n\n // object gathering original scroll methods\n var original = {\n scroll: w.scroll || w.scrollTo,\n scrollBy: w.scrollBy,\n elementScroll: Element.prototype.scroll || scrollElement,\n scrollIntoView: Element.prototype.scrollIntoView,\n };\n\n // define timing method\n var now =\n w.performance && w.performance.now\n ? w.performance.now.bind(w.performance)\n : Date.now;\n\n /**\n * indicates if a the current browser is made by Microsoft\n * @method isMicrosoftBrowser\n * @param {String} userAgent\n * @returns {Boolean}\n */\n function isMicrosoftBrowser(userAgent) {\n var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];\n\n return new RegExp(userAgentPatterns.join('|')).test(userAgent);\n }\n\n /*\n * IE has rounding bug rounding down clientHeight and clientWidth and\n * rounding up scrollHeight and scrollWidth causing false positives\n * on hasScrollableSpace\n */\n var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;\n\n /**\n * changes scroll position inside an element\n * @method scrollElement\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function scrollElement(x, y) {\n this.scrollLeft = x;\n this.scrollTop = y;\n }\n\n /**\n * returns result of applying ease math function to a number\n * @method ease\n * @param {Number} k\n * @returns {Number}\n */\n function ease(k) {\n return 0.5 * (1 - Math.cos(Math.PI * k));\n }\n\n /**\n * indicates if a smooth behavior should be applied\n * @method shouldBailOut\n * @param {Number|Object} firstArg\n * @returns {Boolean}\n */\n function shouldBailOut(firstArg) {\n if (\n firstArg === null ||\n typeof firstArg !== 'object' ||\n firstArg.behavior === undefined ||\n firstArg.behavior === 'auto' ||\n firstArg.behavior === 'instant'\n ) {\n // first argument is not an object/null\n // or behavior is auto, instant or undefined\n return true;\n }\n\n if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {\n // first argument is an object and behavior is smooth\n return false;\n }\n\n // throw error when behavior is not supported\n throw new TypeError(\n 'behavior member of ScrollOptions ' +\n firstArg.behavior +\n ' is not a valid value for enumeration ScrollBehavior.',\n );\n }\n\n /**\n * indicates if an element has scrollable space in the provided axis\n * @method hasScrollableSpace\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function hasScrollableSpace(el, axis) {\n if (axis === 'Y') {\n return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;\n }\n\n if (axis === 'X') {\n return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;\n }\n }\n\n /**\n * indicates if an element has a scrollable overflow property in the axis\n * @method canOverflow\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function canOverflow(el, axis) {\n var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];\n\n return overflowValue === 'auto' || overflowValue === 'scroll';\n }\n\n /**\n * indicates if an element can be scrolled in either axis\n * @method isScrollable\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function isScrollable(el) {\n var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');\n var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');\n\n return isScrollableY || isScrollableX;\n }\n\n /**\n * finds scrollable parent of an element\n * @method findScrollableParent\n * @param {Node} el\n * @returns {Node} el\n */\n function findScrollableParent(el) {\n while (el !== d.body && isScrollable(el) === false) {\n el = el.parentNode || el.host;\n }\n\n return el;\n }\n\n /**\n * self invoked function that, given a context, steps through scrolling\n * @method step\n * @param {Object} context\n * @returns {undefined}\n */\n function step(context) {\n var time = now();\n var value;\n var currentX;\n var currentY;\n var elapsed = (time - context.startTime) / SCROLL_TIME;\n\n // avoid elapsed times higher than one\n elapsed = elapsed > 1 ? 1 : elapsed;\n\n // apply easing to elapsed time\n value = ease(elapsed);\n\n currentX = context.startX + (context.x - context.startX) * value;\n currentY = context.startY + (context.y - context.startY) * value;\n\n context.method.call(context.scrollable, currentX, currentY);\n\n // scroll more if we have not reached our destination\n if (currentX !== context.x || currentY !== context.y) {\n w.requestAnimationFrame(step.bind(w, context));\n }\n }\n\n /**\n * scrolls window or element with a smooth behavior\n * @method smoothScroll\n * @param {Object|Node} el\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function smoothScroll(el, x, y) {\n var scrollable;\n var startX;\n var startY;\n var method;\n var startTime = now();\n\n // define scroll context\n if (el === d.body) {\n scrollable = w;\n startX = w.scrollX || w.pageXOffset;\n startY = w.scrollY || w.pageYOffset;\n method = original.scroll;\n } else {\n scrollable = el;\n startX = el.scrollLeft;\n startY = el.scrollTop;\n method = scrollElement;\n }\n\n // scroll looping over a frame\n step({\n scrollable: scrollable,\n method: method,\n startTime: startTime,\n startX: startX,\n startY: startY,\n x: x,\n y: y,\n });\n }\n\n // ORIGINAL METHODS OVERRIDES\n // w.scroll and w.scrollTo\n w.scroll = w.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scroll.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : w.scrollX || w.pageXOffset,\n // use top prop, second argument if present or fallback to scrollY\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : w.scrollY || w.pageYOffset,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : w.scrollX || w.pageXOffset,\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : w.scrollY || w.pageYOffset,\n );\n };\n\n // w.scrollBy\n w.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0])) {\n original.scrollBy.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : 0,\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : 0,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n ~~arguments[0].left + (w.scrollX || w.pageXOffset),\n ~~arguments[0].top + (w.scrollY || w.pageYOffset),\n );\n };\n\n // Element.prototype.scroll and Element.prototype.scrollTo\n Element.prototype.scroll = Element.prototype.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n // if one number is passed, throw error to match Firefox implementation\n if (typeof arguments[0] === 'number' && arguments[1] === undefined) {\n throw new SyntaxError('Value could not be converted');\n }\n\n original.elementScroll.call(\n this,\n // use left prop, first number argument or fallback to scrollLeft\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : typeof arguments[0] !== 'object'\n ? ~~arguments[0]\n : this.scrollLeft,\n // use top prop, second argument or fallback to scrollTop\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : arguments[1] !== undefined\n ? ~~arguments[1]\n : this.scrollTop,\n );\n\n return;\n }\n\n var left = arguments[0].left;\n var top = arguments[0].top;\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n this,\n this,\n typeof left === 'undefined' ? this.scrollLeft : ~~left,\n typeof top === 'undefined' ? this.scrollTop : ~~top,\n );\n };\n\n // Element.prototype.scrollBy\n Element.prototype.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.elementScroll.call(\n this,\n arguments[0].left !== undefined\n ? ~~arguments[0].left + this.scrollLeft\n : ~~arguments[0] + this.scrollLeft,\n arguments[0].top !== undefined\n ? ~~arguments[0].top + this.scrollTop\n : ~~arguments[1] + this.scrollTop,\n );\n\n return;\n }\n\n this.scroll({\n left: ~~arguments[0].left + this.scrollLeft,\n top: ~~arguments[0].top + this.scrollTop,\n behavior: arguments[0].behavior,\n });\n };\n\n // Element.prototype.scrollIntoView\n Element.prototype.scrollIntoView = function () {\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scrollIntoView.call(\n this,\n arguments[0] === undefined ? true : arguments[0],\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n var scrollableParent = findScrollableParent(this);\n var parentRects = scrollableParent.getBoundingClientRect();\n var clientRects = this.getBoundingClientRect();\n\n if (scrollableParent !== d.body) {\n // reveal element inside parent\n smoothScroll.call(\n this,\n scrollableParent,\n scrollableParent.scrollLeft + clientRects.left - parentRects.left,\n scrollableParent.scrollTop + clientRects.top - parentRects.top,\n );\n\n // reveal parent in viewport unless is fixed\n if (w.getComputedStyle(scrollableParent).position !== 'fixed') {\n w.scrollBy({\n left: parentRects.left,\n top: parentRects.top,\n behavior: 'smooth',\n });\n }\n } else {\n // reveal element in viewport\n w.scrollBy({\n left: clientRects.left,\n top: clientRects.top,\n behavior: 'smooth',\n });\n }\n };\n}\n","import {\n actionWithDelay,\n eventWithTime,\n EventType,\n IncrementalSource,\n} from '../types';\n\nexport class Timer {\n public timeOffset: number = 0;\n public speed: number;\n\n private actions: actionWithDelay[];\n private raf: number | null = null;\n private liveMode: boolean;\n\n constructor(actions: actionWithDelay[] = [], speed: number) {\n this.actions = actions;\n this.speed = speed;\n }\n /**\n * Add an action after the timer starts.\n * @param action\n */\n public addAction(action: actionWithDelay) {\n const index = this.findActionIndex(action);\n this.actions.splice(index, 0, action);\n }\n /**\n * Add all actions before the timer starts\n * @param actions\n */\n public addActions(actions: actionWithDelay[]) {\n this.actions = this.actions.concat(actions);\n }\n\n public start() {\n this.timeOffset = 0;\n let lastTimestamp = performance.now();\n const { actions } = this;\n const self = this;\n function check() {\n const time = performance.now();\n self.timeOffset += (time - lastTimestamp) * self.speed;\n lastTimestamp = time;\n while (actions.length) {\n const action = actions[0];\n\n if (self.timeOffset >= action.delay) {\n actions.shift();\n action.doAction();\n } else {\n break;\n }\n }\n if (actions.length > 0 || self.liveMode) {\n self.raf = requestAnimationFrame(check);\n }\n }\n this.raf = requestAnimationFrame(check);\n }\n\n public clear() {\n if (this.raf) {\n cancelAnimationFrame(this.raf);\n this.raf = null;\n }\n this.actions.length = 0;\n }\n\n public setSpeed(speed: number) {\n this.speed = speed;\n }\n\n public toggleLiveMode(mode: boolean) {\n this.liveMode = mode;\n }\n\n public isActive() {\n return this.raf !== null;\n }\n\n private findActionIndex(action: actionWithDelay): number {\n let start = 0;\n let end = this.actions.length - 1;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (this.actions[mid].delay < action.delay) {\n start = mid + 1;\n } else if (this.actions[mid].delay > action.delay) {\n end = mid - 1;\n } else {\n // already an action with same delay (timestamp)\n // the plus one will splice the new one after the existing one\n return mid + 1;\n }\n }\n return start;\n }\n}\n\n// TODO: add speed to mouse move timestamp calculation\nexport function addDelay(event: eventWithTime, baselineTime: number): number {\n // Mouse move events was recorded in a throttle function,\n // so we need to find the real timestamp by traverse the time offsets.\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove\n ) {\n const firstOffset = event.data.positions[0].timeOffset;\n // timeOffset is a negative offset to event.timestamp\n const firstTimestamp = event.timestamp + firstOffset;\n event.delay = firstTimestamp - baselineTime;\n return firstTimestamp - baselineTime;\n }\n\n event.delay = event.timestamp - baselineTime;\n return event.delay;\n}\n","/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return{type:\"xstate.assign\",assignment:t}}function i(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){o=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]=\"function\"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o]})),r=n,!1}return!0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})))},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u=\"object\"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}export{n as InterpreterStatus,o as assign,s as createMachine,v as interpret};\n","import { createMachine, interpret, assign, StateMachine } from '@xstate/fsm';\nimport {\n playerConfig,\n eventWithTime,\n actionWithDelay,\n ReplayerEvents,\n EventType,\n Emitter,\n IncrementalSource,\n} from '../types';\nimport { Timer, addDelay } from './timer';\n\nexport type PlayerContext = {\n events: eventWithTime[];\n timer: Timer;\n timeOffset: number;\n baselineTime: number;\n lastPlayedEvent: eventWithTime | null;\n};\nexport type PlayerEvent =\n | {\n type: 'PLAY';\n payload: {\n timeOffset: number;\n };\n }\n | {\n type: 'CAST_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | { type: 'PAUSE' }\n | { type: 'TO_LIVE'; payload: { baselineTime?: number } }\n | {\n type: 'ADD_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | {\n type: 'END';\n };\nexport type PlayerState =\n | {\n value: 'playing';\n context: PlayerContext;\n }\n | {\n value: 'paused';\n context: PlayerContext;\n }\n | {\n value: 'live';\n context: PlayerContext;\n };\n\n/**\n * If the array have multiple meta and fullsnapshot events,\n * return the events from last meta to the end.\n */\nexport function discardPriorSnapshots(\n events: eventWithTime[],\n baselineTime: number,\n): eventWithTime[] {\n for (let idx = events.length - 1; idx >= 0; idx--) {\n const event = events[idx];\n if (event.type === EventType.Meta) {\n if (event.timestamp <= baselineTime) {\n return events.slice(idx);\n }\n }\n }\n return events;\n}\n\ntype PlayerAssets = {\n emitter: Emitter;\n applyEventsSynchronously(events: Array): void;\n getCastFn(event: eventWithTime, isSync: boolean): () => void;\n};\nexport function createPlayerService(\n context: PlayerContext,\n { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets,\n) {\n const playerMachine = createMachine(\n {\n id: 'player',\n context,\n initial: 'paused',\n states: {\n playing: {\n on: {\n PAUSE: {\n target: 'paused',\n actions: ['pause'],\n },\n CAST_EVENT: {\n target: 'playing',\n actions: 'castEvent',\n },\n END: {\n target: 'paused',\n actions: ['resetLastPlayedEvent', 'pause'],\n },\n ADD_EVENT: {\n target: 'playing',\n actions: ['addEvent'],\n },\n },\n },\n paused: {\n on: {\n PLAY: {\n target: 'playing',\n actions: ['recordTimeOffset', 'play'],\n },\n CAST_EVENT: {\n target: 'paused',\n actions: 'castEvent',\n },\n TO_LIVE: {\n target: 'live',\n actions: ['startLive'],\n },\n ADD_EVENT: {\n target: 'paused',\n actions: ['addEvent'],\n },\n },\n },\n live: {\n on: {\n ADD_EVENT: {\n target: 'live',\n actions: ['addEvent'],\n },\n CAST_EVENT: {\n target: 'live',\n actions: ['castEvent'],\n },\n },\n },\n },\n },\n {\n actions: {\n castEvent: assign({\n lastPlayedEvent: (ctx, event) => {\n if (event.type === 'CAST_EVENT') {\n return event.payload.event;\n }\n return ctx.lastPlayedEvent;\n },\n }),\n recordTimeOffset: assign((ctx, event) => {\n let timeOffset = ctx.timeOffset;\n if ('payload' in event && 'timeOffset' in event.payload) {\n timeOffset = event.payload.timeOffset;\n }\n return {\n ...ctx,\n timeOffset,\n baselineTime: ctx.events[0].timestamp + timeOffset,\n };\n }),\n play(ctx) {\n const { timer, events, baselineTime, lastPlayedEvent } = ctx;\n timer.clear();\n\n for (const event of events) {\n // TODO: improve this API\n addDelay(event, baselineTime);\n }\n const neededEvents = discardPriorSnapshots(events, baselineTime);\n\n let lastPlayedTimestamp = lastPlayedEvent?.timestamp;\n if (\n lastPlayedEvent?.type === EventType.IncrementalSnapshot &&\n lastPlayedEvent.data.source === IncrementalSource.MouseMove\n ) {\n lastPlayedTimestamp =\n lastPlayedEvent.timestamp +\n lastPlayedEvent.data.positions[0]?.timeOffset;\n }\n if (baselineTime < (lastPlayedTimestamp || 0)) {\n emitter.emit(ReplayerEvents.PlayBack);\n }\n\n const syncEvents = new Array();\n const actions = new Array();\n for (const event of neededEvents) {\n if (\n lastPlayedTimestamp &&\n lastPlayedTimestamp < baselineTime &&\n (event.timestamp <= lastPlayedTimestamp ||\n event === lastPlayedEvent)\n ) {\n continue;\n }\n if (event.timestamp < baselineTime) {\n syncEvents.push(event);\n } else {\n const castFn = getCastFn(event, false);\n actions.push({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n applyEventsSynchronously(syncEvents);\n emitter.emit(ReplayerEvents.Flush);\n timer.addActions(actions);\n timer.start();\n },\n pause(ctx) {\n ctx.timer.clear();\n },\n resetLastPlayedEvent: assign((ctx) => {\n return {\n ...ctx,\n lastPlayedEvent: null,\n };\n }),\n startLive: assign({\n baselineTime: (ctx, event) => {\n ctx.timer.toggleLiveMode(true);\n ctx.timer.start();\n if (event.type === 'TO_LIVE' && event.payload.baselineTime) {\n return event.payload.baselineTime;\n }\n return Date.now();\n },\n }),\n addEvent: assign((ctx, machineEvent) => {\n const { baselineTime, timer, events } = ctx;\n if (machineEvent.type === 'ADD_EVENT') {\n const { event } = machineEvent.payload;\n addDelay(event, baselineTime);\n\n let end = events.length - 1;\n if (!events[end] || events[end].timestamp <= event.timestamp) {\n // fast track\n events.push(event);\n } else {\n let insertionIndex = -1;\n let start = 0;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (events[mid].timestamp <= event.timestamp) {\n start = mid + 1;\n } else {\n end = mid - 1;\n }\n }\n if (insertionIndex === -1) {\n insertionIndex = start;\n }\n events.splice(insertionIndex, 0, event);\n }\n\n const isSync = event.timestamp < baselineTime;\n const castFn = getCastFn(event, isSync);\n if (isSync) {\n castFn();\n } else if (timer.isActive()) {\n timer.addAction({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n return { ...ctx, events };\n }),\n },\n },\n );\n return interpret(playerMachine);\n}\n\nexport type SpeedContext = {\n normalSpeed: playerConfig['speed'];\n timer: Timer;\n};\n\nexport type SpeedEvent =\n | {\n type: 'FAST_FORWARD';\n payload: { speed: playerConfig['speed'] };\n }\n | {\n type: 'BACK_TO_NORMAL';\n }\n | {\n type: 'SET_SPEED';\n payload: { speed: playerConfig['speed'] };\n };\n\nexport type SpeedState =\n | {\n value: 'normal';\n context: SpeedContext;\n }\n | {\n value: 'skipping';\n context: SpeedContext;\n };\n\nexport function createSpeedService(context: SpeedContext) {\n const speedMachine = createMachine(\n {\n id: 'speed',\n context,\n initial: 'normal',\n states: {\n normal: {\n on: {\n FAST_FORWARD: {\n target: 'skipping',\n actions: ['recordSpeed', 'setSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n skipping: {\n on: {\n BACK_TO_NORMAL: {\n target: 'normal',\n actions: ['restoreSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n },\n },\n {\n actions: {\n setSpeed: (ctx, event) => {\n if ('payload' in event) {\n ctx.timer.setSpeed(event.payload.speed);\n }\n },\n recordSpeed: assign({\n normalSpeed: (ctx) => ctx.timer.speed,\n }),\n restoreSpeed: (ctx) => {\n ctx.timer.setSpeed(ctx.normalSpeed);\n },\n },\n },\n );\n\n return interpret(speedMachine);\n}\n\nexport type PlayerMachineState = StateMachine.State<\n PlayerContext,\n PlayerEvent,\n PlayerState\n>;\n\nexport type SpeedMachineState = StateMachine.State<\n SpeedContext,\n SpeedEvent,\n SpeedState\n>;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","const rules: (blockClass: string) => string[] = (blockClass: string) => [\n `.${blockClass} { background: currentColor }`,\n 'noscript { display: none !important; }',\n];\n\nexport default rules;\n","import { INode } from 'rrweb-snapshot';\n\nexport enum StyleRuleType {\n Insert,\n Remove,\n Snapshot,\n SetProperty,\n RemoveProperty,\n}\n\ntype InsertRule = {\n cssText: string;\n type: StyleRuleType.Insert;\n index?: number | number[];\n};\ntype RemoveRule = {\n type: StyleRuleType.Remove;\n index: number | number[];\n};\ntype SnapshotRule = {\n type: StyleRuleType.Snapshot;\n cssTexts: string[];\n};\ntype SetPropertyRule = {\n type: StyleRuleType.SetProperty;\n index: number[];\n property: string;\n value: string | null;\n priority: string | undefined;\n};\ntype RemovePropertyRule = {\n type: StyleRuleType.RemoveProperty;\n index: number[];\n property: string;\n};\n\nexport type VirtualStyleRules = Array<\n InsertRule | RemoveRule | SnapshotRule | SetPropertyRule | RemovePropertyRule\n>;\nexport type VirtualStyleRulesMap = Map;\n\nexport function getNestedRule(\n rules: CSSRuleList,\n position: number[],\n): CSSGroupingRule {\n const rule = rules[position[0]] as CSSGroupingRule;\n if (position.length === 1) {\n return rule;\n } else {\n return getNestedRule(\n ((rule as CSSGroupingRule).cssRules[position[1]] as CSSGroupingRule)\n .cssRules,\n position.slice(2),\n );\n }\n}\n\nexport function getPositionsAndIndex(nestedIndex: number[]) {\n const positions = [...nestedIndex];\n const index = positions.pop();\n return { positions, index };\n}\n\nexport function applyVirtualStyleRulesToNode(\n storedRules: VirtualStyleRules,\n styleNode: HTMLStyleElement,\n) {\n const { sheet } = styleNode;\n if (!sheet) {\n // styleNode without sheet means the DOM has been removed\n // so the rules no longer need to be applied\n return;\n }\n\n storedRules.forEach((rule) => {\n if (rule.type === StyleRuleType.Insert) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.insertRule(rule.cssText, index);\n } else {\n sheet.insertRule(rule.cssText, rule.index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n } else if (rule.type === StyleRuleType.Remove) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.deleteRule(index || 0);\n } else {\n sheet.deleteRule(rule.index);\n }\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else if (rule.type === StyleRuleType.Snapshot) {\n restoreSnapshotOfStyleRulesToNode(rule.cssTexts, styleNode);\n } else if (rule.type === StyleRuleType.SetProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.setProperty(rule.property, rule.value, rule.priority);\n } else if (rule.type === StyleRuleType.RemoveProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.removeProperty(rule.property);\n }\n });\n}\n\nfunction restoreSnapshotOfStyleRulesToNode(\n cssTexts: string[],\n styleNode: HTMLStyleElement,\n) {\n try {\n const existingRules = Array.from(styleNode.sheet?.cssRules || []).map(\n (rule) => rule.cssText,\n );\n const existingRulesReversed = Object.entries(existingRules).reverse();\n let lastMatch = existingRules.length;\n existingRulesReversed.forEach(([index, rule]) => {\n const indexOf = cssTexts.indexOf(rule);\n if (indexOf === -1 || indexOf > lastMatch) {\n try {\n styleNode.sheet?.deleteRule(Number(index));\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n }\n lastMatch = indexOf;\n });\n cssTexts.forEach((cssText, index) => {\n try {\n if (styleNode.sheet?.cssRules[index]?.cssText !== cssText) {\n styleNode.sheet?.insertRule(cssText, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n });\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n\nexport function storeCSSRules(\n parentElement: HTMLStyleElement,\n virtualStyleRulesMap: VirtualStyleRulesMap,\n) {\n try {\n const cssTexts = Array.from(\n (parentElement as HTMLStyleElement).sheet?.cssRules || [],\n ).map((rule) => rule.cssText);\n virtualStyleRulesMap.set((parentElement as unknown) as INode, [\n {\n type: StyleRuleType.Snapshot,\n cssTexts,\n },\n ]);\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { decode } from 'base64-arraybuffer';\nimport { Replayer } from '../';\nimport {\n CanvasContext,\n canvasMutationCommand,\n SerializedWebGlArg,\n} from '../../types';\n\n// TODO: add ability to wipe this list\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nfunction getContext(\n target: HTMLCanvasElement,\n type: CanvasContext,\n): WebGLRenderingContext | WebGL2RenderingContext | null {\n // Note to whomever is going to implement support for `contextAttributes`:\n // if `preserveDrawingBuffer` is set to true,\n // you might have to do `ctx.flush()` before every webgl canvas event\n try {\n if (type === CanvasContext.WebGL) {\n return (\n target.getContext('webgl')! || target.getContext('experimental-webgl')\n );\n }\n return target.getContext('webgl2')!;\n } catch (e) {\n return null;\n }\n}\n\nconst WebGLVariableConstructorsNames = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n];\n\nfunction saveToWebGLVarMap(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n result: any,\n) {\n if (!result?.constructor) return; // probably null or undefined\n\n const { name } = result.constructor;\n if (!WebGLVariableConstructorsNames.includes(name)) return; // not a WebGL variable\n\n const variables = variableListFor(ctx, name);\n if (!variables.includes(result)) variables.push(result);\n}\n\nexport function deserializeArg(\n imageMap: Replayer['imageMap'],\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n): (arg: SerializedWebGlArg) => any {\n return (arg: SerializedWebGlArg): any => {\n if (arg && typeof arg === 'object' && 'rr_type' in arg) {\n if ('index' in arg) {\n const { rr_type: name, index } = arg;\n return variableListFor(ctx, name)[index];\n } else if ('args' in arg) {\n const { rr_type: name, args } = arg;\n const ctor = window[name as keyof Window];\n\n return new ctor(...args.map(deserializeArg(imageMap, ctx)));\n } else if ('base64' in arg) {\n return decode(arg.base64);\n } else if ('src' in arg) {\n const image = imageMap.get(arg.src);\n if (image) {\n return image;\n } else {\n const image = new Image();\n image.src = arg.src;\n imageMap.set(arg.src, image);\n return image;\n }\n }\n } else if (Array.isArray(arg)) {\n return arg.map(deserializeArg(imageMap, ctx));\n }\n return arg;\n };\n}\n\nexport default function webglMutation({\n mutation,\n target,\n type,\n imageMap,\n errorHandler,\n}: {\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n type: CanvasContext;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = getContext(target, type);\n if (!ctx) return;\n\n // NOTE: if `preserveDrawingBuffer` is set to true,\n // we must flush the buffers on every new canvas event\n // if (mutation.newFrame) ctx.flush();\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n const args = mutation.args.map(deserializeArg(imageMap, ctx));\n const result = original.apply(ctx, args);\n saveToWebGLVarMap(ctx, result);\n\n // Slows down replay considerably, only use for debugging\n const debugMode = false;\n if (debugMode) {\n if (mutation.property === 'compileShader') {\n if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getShaderInfoLog(args[0]),\n );\n } else if (mutation.property === 'linkProgram') {\n ctx.validateProgram(args[0]);\n if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getProgramInfoLog(args[0]),\n );\n }\n const webglError = ctx.getError();\n if (webglError !== ctx.NO_ERROR) {\n console.warn(\n 'WEBGL ERROR',\n webglError,\n 'on command:',\n mutation.property,\n ...args,\n );\n }\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import {\n rebuild,\n buildNodeWithSN,\n INode,\n NodeType,\n BuildCache,\n createCache,\n} from 'rrweb-snapshot';\nimport * as mittProxy from 'mitt';\nimport { polyfill as smoothscrollPolyfill } from './smoothscroll';\nimport { Timer } from './timer';\nimport { createPlayerService, createSpeedService } from './machine';\nimport {\n EventType,\n IncrementalSource,\n fullSnapshotEvent,\n eventWithTime,\n MouseInteractions,\n playerConfig,\n playerMetaData,\n viewportResizeDimension,\n missingNodeMap,\n addedNodeMutation,\n missingNode,\n incrementalSnapshotEvent,\n incrementalData,\n ReplayerEvents,\n Handler,\n Emitter,\n MediaInteractions,\n metaEvent,\n mutationData,\n scrollData,\n inputData,\n canvasMutationData,\n Mirror,\n ElementState,\n styleAttributeValue,\n styleValueWithPriority,\n mouseMovePos,\n IWindow,\n canvasMutationCommand,\n textMutation,\n} from '../types';\nimport {\n createMirror,\n polyfill,\n TreeIndex,\n queueToResolveTrees,\n iterateResolveTree,\n AppendedIframe,\n isIframeINode,\n getBaseDimension,\n hasShadowRoot,\n} from '../utils';\nimport getInjectStyleRules from './styles/inject-style';\nimport './styles/style.css';\nimport {\n applyVirtualStyleRulesToNode,\n storeCSSRules,\n StyleRuleType,\n VirtualStyleRules,\n VirtualStyleRulesMap,\n getNestedRule,\n getPositionsAndIndex,\n} from './virtual-styles';\nimport canvasMutation from './canvas';\n\nconst SKIP_TIME_THRESHOLD = 10 * 1000;\nconst SKIP_TIME_INTERVAL = 5 * 1000;\n\n// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734\n// tslint:disable-next-line\nconst mitt = (mittProxy as any).default || mittProxy;\n\nconst REPLAY_CONSOLE_PREFIX = '[replayer]';\n\nconst defaultMouseTailConfig = {\n duration: 500,\n lineCap: 'round',\n lineWidth: 3,\n strokeStyle: 'red',\n} as const;\n\nfunction indicatesTouchDevice(e: eventWithTime) {\n return (\n e.type == EventType.IncrementalSnapshot &&\n (e.data.source == IncrementalSource.TouchMove ||\n (e.data.source == IncrementalSource.MouseInteraction &&\n e.data.type == MouseInteractions.TouchStart))\n );\n}\n\nexport class Replayer {\n public wrapper: HTMLDivElement;\n public iframe: HTMLIFrameElement;\n\n public service: ReturnType;\n public speedService: ReturnType;\n public get timer() {\n return this.service.state.context.timer;\n }\n\n public config: playerConfig;\n\n private mouse: HTMLDivElement;\n private mouseTail: HTMLCanvasElement | null = null;\n private tailPositions: Array<{ x: number; y: number }> = [];\n\n private emitter: Emitter = mitt();\n\n private nextUserInteractionEvent: eventWithTime | null;\n\n // tslint:disable-next-line: variable-name\n private legacy_missingNodeRetryMap: missingNodeMap = {};\n\n private treeIndex!: TreeIndex;\n private fragmentParentMap!: Map;\n private elementStateMap!: Map;\n // Hold the list of CSSRules for in-memory state restoration\n private virtualStyleRulesMap!: VirtualStyleRulesMap;\n\n // The replayer uses the cache to speed up replay and scrubbing.\n private cache: BuildCache = createCache();\n\n private imageMap: Map = new Map();\n\n private mirror: Mirror = createMirror();\n\n private firstFullSnapshot: eventWithTime | true | null = null;\n\n private newDocumentQueue: addedNodeMutation[] = [];\n\n private mousePos: mouseMovePos | null = null;\n private touchActive: boolean | null = null;\n\n constructor(\n events: Array,\n config?: Partial,\n ) {\n if (!config?.liveMode && events.length < 2) {\n throw new Error('Replayer need at least 2 events.');\n }\n const defaultConfig: playerConfig = {\n speed: 1,\n maxSpeed: 360,\n root: document.body,\n loadTimeout: 0,\n skipInactive: false,\n showWarning: true,\n showDebug: false,\n blockClass: 'rr-block',\n liveMode: false,\n insertStyleRules: [],\n triggerFocus: true,\n UNSAFE_replayCanvas: false,\n pauseAnimation: true,\n mouseTail: defaultMouseTailConfig,\n };\n this.config = Object.assign({}, defaultConfig, config);\n\n this.handleResize = this.handleResize.bind(this);\n this.getCastFn = this.getCastFn.bind(this);\n this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);\n this.emitter.on(ReplayerEvents.Resize, this.handleResize as Handler);\n\n this.setupDom();\n\n this.treeIndex = new TreeIndex();\n this.fragmentParentMap = new Map();\n this.elementStateMap = new Map();\n this.virtualStyleRulesMap = new Map();\n\n this.emitter.on(ReplayerEvents.Flush, () => {\n const { scrollMap, inputMap, mutationData } = this.treeIndex.flush();\n\n this.fragmentParentMap.forEach((parent, frag) =>\n this.restoreRealParent(frag, parent),\n );\n // apply text needs to happen before virtual style rules gets applied\n // as it can overwrite the contents of a stylesheet\n for (const d of mutationData.texts) {\n this.applyText(d, mutationData);\n }\n\n for (const node of this.virtualStyleRulesMap.keys()) {\n // restore css rules of style elements after they are mounted\n this.restoreNodeSheet(node);\n }\n this.fragmentParentMap.clear();\n this.elementStateMap.clear();\n this.virtualStyleRulesMap.clear();\n\n for (const d of scrollMap.values()) {\n this.applyScroll(d, true);\n }\n for (const d of inputMap.values()) {\n this.applyInput(d);\n }\n });\n this.emitter.on(ReplayerEvents.PlayBack, () => {\n this.firstFullSnapshot = null;\n this.mirror.reset();\n });\n\n const timer = new Timer([], config?.speed || defaultConfig.speed);\n this.service = createPlayerService(\n {\n events: events\n .map((e) => {\n if (config && config.unpackFn) {\n return config.unpackFn(e as string);\n }\n return e as eventWithTime;\n })\n .sort((a1, a2) => a1.timestamp - a2.timestamp),\n timer,\n timeOffset: 0,\n baselineTime: 0,\n lastPlayedEvent: null,\n },\n {\n getCastFn: this.getCastFn,\n applyEventsSynchronously: this.applyEventsSynchronously,\n emitter: this.emitter,\n },\n );\n this.service.start();\n this.service.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n player: state,\n });\n });\n this.speedService = createSpeedService({\n normalSpeed: -1,\n timer,\n });\n this.speedService.start();\n this.speedService.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n speed: state,\n });\n });\n\n // rebuild first full snapshot as the poster of the player\n // maybe we can cache it for performance optimization\n const firstMeta = this.service.state.context.events.find(\n (e) => e.type === EventType.Meta,\n );\n const firstFullsnapshot = this.service.state.context.events.find(\n (e) => e.type === EventType.FullSnapshot,\n );\n if (firstMeta) {\n const { width, height } = firstMeta.data as metaEvent['data'];\n setTimeout(() => {\n this.emitter.emit(ReplayerEvents.Resize, {\n width,\n height,\n });\n }, 0);\n }\n if (firstFullsnapshot) {\n setTimeout(() => {\n // when something has been played, there is no need to rebuild poster\n if (this.firstFullSnapshot) {\n // true if any other fullSnapshot has been executed by Timer already\n return;\n }\n this.firstFullSnapshot = firstFullsnapshot;\n this.rebuildFullSnapshot(\n firstFullsnapshot as fullSnapshotEvent & { timestamp: number },\n );\n this.iframe.contentWindow!.scrollTo(\n (firstFullsnapshot as fullSnapshotEvent).data.initialOffset,\n );\n }, 1);\n }\n if (this.service.state.context.events.find(indicatesTouchDevice)) {\n this.mouse.classList.add('touch-device');\n }\n }\n\n public on(event: string, handler: Handler) {\n this.emitter.on(event, handler);\n return this;\n }\n\n public off(event: string, handler: Handler) {\n this.emitter.off(event, handler);\n return this;\n }\n\n public setConfig(config: Partial) {\n Object.keys(config).forEach((key) => {\n // @ts-ignore\n this.config[key] = config[key];\n });\n if (!this.config.skipInactive) {\n this.backToNormal();\n }\n if (typeof config.speed !== 'undefined') {\n this.speedService.send({\n type: 'SET_SPEED',\n payload: {\n speed: config.speed!,\n },\n });\n }\n if (typeof config.mouseTail !== 'undefined') {\n if (config.mouseTail === false) {\n if (this.mouseTail) {\n this.mouseTail.style.display = 'none';\n }\n } else {\n if (!this.mouseTail) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.width = Number.parseFloat(this.iframe.width);\n this.mouseTail.height = Number.parseFloat(this.iframe.height);\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.wrapper.insertBefore(this.mouseTail, this.iframe);\n }\n this.mouseTail.style.display = 'inherit';\n }\n }\n }\n\n public getMetaData(): playerMetaData {\n const firstEvent = this.service.state.context.events[0];\n const lastEvent = this.service.state.context.events[\n this.service.state.context.events.length - 1\n ];\n return {\n startTime: firstEvent.timestamp,\n endTime: lastEvent.timestamp,\n totalTime: lastEvent.timestamp - firstEvent.timestamp,\n };\n }\n\n public getCurrentTime(): number {\n return this.timer.timeOffset + this.getTimeOffset();\n }\n\n public getTimeOffset(): number {\n const { baselineTime, events } = this.service.state.context;\n return baselineTime - events[0].timestamp;\n }\n\n public getMirror(): Mirror {\n return this.mirror;\n }\n\n /**\n * This API was designed to be used as play at any time offset.\n * Since we minimized the data collected from recorder, we do not\n * have the ability of undo an event.\n * So the implementation of play at any time offset will always iterate\n * all of the events, cast event before the offset synchronously\n * and cast event after the offset asynchronously with timer.\n * @param timeOffset number\n */\n public play(timeOffset = 0) {\n if (this.service.state.matches('paused')) {\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n } else {\n this.service.send({ type: 'PAUSE' });\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.remove('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Start);\n }\n\n public pause(timeOffset?: number) {\n if (timeOffset === undefined && this.service.state.matches('playing')) {\n this.service.send({ type: 'PAUSE' });\n }\n if (typeof timeOffset === 'number') {\n this.play(timeOffset);\n this.service.send({ type: 'PAUSE' });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Pause);\n }\n\n public resume(timeOffset = 0) {\n console.warn(\n `The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.`,\n );\n this.play(timeOffset);\n this.emitter.emit(ReplayerEvents.Resume);\n }\n\n public startLive(baselineTime?: number) {\n this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });\n }\n\n public addEvent(rawEvent: eventWithTime | string) {\n const event = this.config.unpackFn\n ? this.config.unpackFn(rawEvent as string)\n : (rawEvent as eventWithTime);\n if (indicatesTouchDevice(event)) {\n this.mouse.classList.add('touch-device');\n }\n Promise.resolve().then(() =>\n this.service.send({ type: 'ADD_EVENT', payload: { event } }),\n );\n }\n\n public enableInteract() {\n this.iframe.setAttribute('scrolling', 'auto');\n this.iframe.style.pointerEvents = 'auto';\n }\n\n public disableInteract() {\n this.iframe.setAttribute('scrolling', 'no');\n this.iframe.style.pointerEvents = 'none';\n }\n\n /**\n * Empties the replayer's cache and reclaims memory.\n * The replayer will use this cache to speed up the playback.\n */\n public resetCache() {\n this.cache = createCache();\n }\n\n private setupDom() {\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add('replayer-wrapper');\n this.config.root!.appendChild(this.wrapper);\n\n this.mouse = document.createElement('div');\n this.mouse.classList.add('replayer-mouse');\n this.wrapper.appendChild(this.mouse);\n\n if (this.config.mouseTail !== false) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.mouseTail.style.display = 'inherit';\n this.wrapper.appendChild(this.mouseTail);\n }\n\n this.iframe = document.createElement('iframe');\n const attributes = ['allow-same-origin'];\n if (this.config.UNSAFE_replayCanvas) {\n attributes.push('allow-scripts');\n }\n // hide iframe before first meta event\n this.iframe.style.display = 'none';\n this.iframe.setAttribute('sandbox', attributes.join(' '));\n this.disableInteract();\n this.wrapper.appendChild(this.iframe);\n if (this.iframe.contentWindow && this.iframe.contentDocument) {\n smoothscrollPolyfill(\n this.iframe.contentWindow,\n this.iframe.contentDocument,\n );\n\n polyfill(this.iframe.contentWindow as IWindow);\n }\n }\n\n private handleResize(dimension: viewportResizeDimension) {\n this.iframe.style.display = 'inherit';\n for (const el of [this.mouseTail, this.iframe]) {\n if (!el) {\n continue;\n }\n el.setAttribute('width', String(dimension.width));\n el.setAttribute('height', String(dimension.height));\n }\n }\n\n private applyEventsSynchronously(events: Array) {\n for (const event of events) {\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n case EventType.Custom:\n continue;\n case EventType.FullSnapshot:\n case EventType.Meta:\n case EventType.Plugin:\n break;\n case EventType.IncrementalSnapshot:\n switch (event.data.source) {\n case IncrementalSource.MediaInteraction:\n continue;\n default:\n break;\n }\n break;\n default:\n break;\n }\n const castFn = this.getCastFn(event, true);\n castFn();\n }\n if (this.mousePos) {\n this.moveAndHover(\n this.mousePos.x,\n this.mousePos.y,\n this.mousePos.id,\n true,\n this.mousePos.debugData,\n );\n }\n this.mousePos = null;\n if (this.touchActive === true) {\n this.mouse.classList.add('touch-active');\n } else if (this.touchActive === false) {\n this.mouse.classList.remove('touch-active');\n }\n this.touchActive = null;\n }\n\n private getCastFn(event: eventWithTime, isSync = false) {\n let castFn: undefined | (() => void);\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n break;\n case EventType.Custom:\n castFn = () => {\n /**\n * emit custom-event and pass the event object.\n *\n * This will add more value to the custom event and allows the client to react for custom-event.\n */\n this.emitter.emit(ReplayerEvents.CustomEvent, event);\n };\n break;\n case EventType.Meta:\n castFn = () =>\n this.emitter.emit(ReplayerEvents.Resize, {\n width: event.data.width,\n height: event.data.height,\n });\n break;\n case EventType.FullSnapshot:\n castFn = () => {\n if (this.firstFullSnapshot) {\n if (this.firstFullSnapshot === event) {\n // we've already built this exact FullSnapshot when the player was mounted, and haven't built any other FullSnapshot since\n this.firstFullSnapshot = true; // forget as we might need to re-execute this FullSnapshot later e.g. to rebuild after scrubbing\n return;\n }\n } else {\n // Timer (requestAnimationFrame) can be faster than setTimeout(..., 1)\n this.firstFullSnapshot = true;\n }\n this.rebuildFullSnapshot(event, isSync);\n this.iframe.contentWindow!.scrollTo(event.data.initialOffset);\n };\n break;\n case EventType.IncrementalSnapshot:\n castFn = () => {\n this.applyIncremental(event, isSync);\n if (isSync) {\n // do not check skip in sync\n return;\n }\n if (event === this.nextUserInteractionEvent) {\n this.nextUserInteractionEvent = null;\n this.backToNormal();\n }\n if (this.config.skipInactive && !this.nextUserInteractionEvent) {\n for (const _event of this.service.state.context.events) {\n if (_event.timestamp! <= event.timestamp!) {\n continue;\n }\n if (this.isUserInteraction(_event)) {\n if (\n _event.delay! - event.delay! >\n SKIP_TIME_THRESHOLD *\n this.speedService.state.context.timer.speed\n ) {\n this.nextUserInteractionEvent = _event;\n }\n break;\n }\n }\n if (this.nextUserInteractionEvent) {\n const skipTime =\n this.nextUserInteractionEvent.delay! - event.delay!;\n const payload = {\n speed: Math.min(\n Math.round(skipTime / SKIP_TIME_INTERVAL),\n this.config.maxSpeed,\n ),\n };\n this.speedService.send({ type: 'FAST_FORWARD', payload });\n this.emitter.emit(ReplayerEvents.SkipStart, payload);\n }\n }\n };\n break;\n default:\n }\n const wrappedCastFn = () => {\n if (castFn) {\n castFn();\n }\n\n for (const plugin of this.config.plugins || []) {\n plugin.handler(event, isSync, { replayer: this });\n }\n\n this.service.send({ type: 'CAST_EVENT', payload: { event } });\n\n // events are kept sorted by timestamp, check if this is the last event\n let last_index = this.service.state.context.events.length - 1;\n if (event === this.service.state.context.events[last_index]) {\n const finish = () => {\n if (last_index < this.service.state.context.events.length - 1) {\n // more events have been added since the setTimeout\n return;\n }\n this.backToNormal();\n this.service.send('END');\n this.emitter.emit(ReplayerEvents.Finish);\n };\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove &&\n event.data.positions.length\n ) {\n // defer finish event if the last event is a mouse move\n setTimeout(() => {\n finish();\n }, Math.max(0, -event.data.positions[0].timeOffset + 50)); // Add 50 to make sure the timer would check the last mousemove event. Otherwise, the timer may be stopped by the service before checking the last event.\n } else {\n finish();\n }\n }\n\n this.emitter.emit(ReplayerEvents.EventCast, event);\n };\n return wrappedCastFn;\n }\n\n private rebuildFullSnapshot(\n event: fullSnapshotEvent & { timestamp: number },\n isSync: boolean = false,\n ) {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n console.warn(\n 'Found unresolved missing node map',\n this.legacy_missingNodeRetryMap,\n );\n }\n this.legacy_missingNodeRetryMap = {};\n const collected: AppendedIframe[] = [];\n this.mirror.map = rebuild(event.data.node, {\n doc: this.iframe.contentDocument,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n },\n cache: this.cache,\n })[1];\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n const { documentElement, head } = this.iframe.contentDocument;\n this.insertStyleRules(documentElement, head);\n if (!this.service.state.matches('playing')) {\n this.iframe.contentDocument\n .getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n }\n this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);\n if (!isSync) {\n this.waitForStylesheetLoad();\n }\n if (this.config.UNSAFE_replayCanvas) {\n this.preloadAllImages();\n }\n }\n\n private insertStyleRules(\n documentElement: HTMLElement,\n head: HTMLHeadElement,\n ) {\n const styleEl = document.createElement('style');\n documentElement!.insertBefore(styleEl, head);\n const injectStylesRules = getInjectStyleRules(\n this.config.blockClass,\n ).concat(this.config.insertStyleRules);\n if (this.config.pauseAnimation) {\n injectStylesRules.push(\n 'html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }',\n );\n }\n for (let idx = 0; idx < injectStylesRules.length; idx++) {\n (styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);\n }\n }\n\n private attachDocumentToIframe(\n mutation: addedNodeMutation,\n iframeEl: HTMLIFrameElement,\n ) {\n const collected: AppendedIframe[] = [];\n // If iframeEl is detached from dom, iframeEl.contentDocument is null.\n if (!iframeEl.contentDocument) {\n let parent = iframeEl.parentNode;\n while (parent) {\n // The parent of iframeEl is virtual parent and we need to mount it on the dom.\n if (this.fragmentParentMap.has((parent as unknown) as INode)) {\n const frag = (parent as unknown) as INode;\n const realParent = this.fragmentParentMap.get(frag)!;\n this.restoreRealParent(frag, realParent);\n break;\n }\n parent = parent.parentNode;\n }\n }\n buildNodeWithSN(mutation.node, {\n doc: iframeEl.contentDocument!,\n map: this.mirror.map,\n hackCss: true,\n skipChild: false,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n if (\n builtNode.__sn.type === NodeType.Element &&\n builtNode.__sn.tagName.toUpperCase() === 'HTML'\n ) {\n const { documentElement, head } = iframeEl.contentDocument!;\n this.insertStyleRules(documentElement, head);\n }\n },\n cache: this.cache,\n });\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n private collectIframeAndAttachDocument(\n collected: AppendedIframe[],\n builtNode: INode,\n ) {\n if (isIframeINode(builtNode)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === builtNode.__sn.id,\n );\n if (mutationInQueue) {\n collected.push({ mutationInQueue, builtNode });\n }\n }\n }\n\n /**\n * pause when loading style sheet, resume when loaded all timeout exceed\n */\n private waitForStylesheetLoad() {\n const head = this.iframe.contentDocument?.head;\n if (head) {\n const unloadSheets: Set = new Set();\n let timer: ReturnType | -1;\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n const unsubscribe = () => {\n this.emitter.off(ReplayerEvents.Start, stateHandler);\n this.emitter.off(ReplayerEvents.Pause, stateHandler);\n };\n head\n .querySelectorAll('link[rel=\"stylesheet\"]')\n .forEach((css: HTMLLinkElement) => {\n if (!css.sheet) {\n unloadSheets.add(css);\n css.addEventListener('load', () => {\n unloadSheets.delete(css);\n // all loaded and timer not released yet\n if (unloadSheets.size === 0 && timer !== -1) {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);\n if (timer) {\n clearTimeout(timer);\n }\n unsubscribe();\n }\n });\n }\n });\n\n if (unloadSheets.size > 0) {\n // find some unload sheets after iterate\n this.service.send({ type: 'PAUSE' });\n this.emitter.emit(ReplayerEvents.LoadStylesheetStart);\n timer = setTimeout(() => {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n // mark timer was called\n timer = -1;\n unsubscribe();\n }, this.config.loadTimeout);\n }\n }\n }\n\n private hasImageArg(args: any[]): boolean {\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n if (this.hasImageArg(arg.args)) return true;\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n return true; // has image!\n } else if (arg instanceof Array) {\n if (this.hasImageArg(arg)) return true;\n }\n }\n return false;\n }\n\n private getImageArgs(args: any[]): string[] {\n const images: string[] = [];\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n images.push(...this.getImageArgs(arg.args));\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n images.push(arg.src);\n } else if (arg instanceof Array) {\n images.push(...this.getImageArgs(arg));\n }\n }\n return images;\n }\n\n /**\n * pause when there are some canvas drawImage args need to be loaded\n */\n private preloadAllImages() {\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n for (const event of this.service.state.context.events) {\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.CanvasMutation\n )\n if ('commands' in event.data) {\n event.data.commands.forEach((c) => this.preloadImages(c, event));\n } else {\n this.preloadImages(event.data, event);\n }\n }\n }\n\n private preloadImages(data: canvasMutationCommand, event: eventWithTime) {\n if (\n data.property === 'drawImage' &&\n typeof data.args[0] === 'string' &&\n !this.imageMap.has(event)\n ) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const imgd = ctx?.createImageData(canvas.width, canvas.height);\n let d = imgd?.data;\n d = JSON.parse(data.args[0]);\n ctx?.putImageData(imgd!, 0, 0);\n } else if (this.hasImageArg(data.args)) {\n this.getImageArgs(data.args).forEach((url) => {\n const image = new Image();\n image.src = url; // this preloads the image\n this.imageMap.set(url, image);\n });\n }\n }\n\n private applyIncremental(\n e: incrementalSnapshotEvent & { timestamp: number; delay?: number },\n isSync: boolean,\n ) {\n const { data: d } = e;\n switch (d.source) {\n case IncrementalSource.Mutation: {\n if (isSync) {\n d.adds.forEach((m) => this.treeIndex.add(m));\n d.texts.forEach((m) => {\n const target = this.mirror.getNode(m.id);\n const parent = (target?.parentNode as unknown) as INode | null;\n // remove any style rules that pending\n // for stylesheets where the contents get replaced\n if (parent && this.virtualStyleRulesMap.has(parent))\n this.virtualStyleRulesMap.delete(parent);\n\n this.treeIndex.text(m);\n });\n d.attributes.forEach((m) => this.treeIndex.attribute(m));\n d.removes.forEach((m) => this.treeIndex.remove(m, this.mirror));\n }\n try {\n this.applyMutation(d, isSync);\n } catch (error) {\n this.warn(`Exception in mutation ${error.message || error}`, d);\n }\n break;\n }\n case IncrementalSource.Drag:\n case IncrementalSource.TouchMove:\n case IncrementalSource.MouseMove:\n if (isSync) {\n const lastPosition = d.positions[d.positions.length - 1];\n this.mousePos = {\n x: lastPosition.x,\n y: lastPosition.y,\n id: lastPosition.id,\n debugData: d,\n };\n } else {\n d.positions.forEach((p) => {\n const action = {\n doAction: () => {\n this.moveAndHover(p.x, p.y, p.id, isSync, d);\n },\n delay:\n p.timeOffset +\n e.timestamp -\n this.service.state.context.baselineTime,\n };\n this.timer.addAction(action);\n });\n // add a dummy action to keep timer alive\n this.timer.addAction({\n doAction() {},\n delay: e.delay! - d.positions[0]?.timeOffset,\n });\n }\n break;\n case IncrementalSource.MouseInteraction: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n const event = new Event(MouseInteractions[d.type].toLowerCase());\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n this.emitter.emit(ReplayerEvents.MouseInteraction, {\n type: d.type,\n target,\n });\n const { triggerFocus } = this.config;\n switch (d.type) {\n case MouseInteractions.Blur:\n if ('blur' in ((target as Node) as HTMLElement)) {\n ((target as Node) as HTMLElement).blur();\n }\n break;\n case MouseInteractions.Focus:\n if (triggerFocus && ((target as Node) as HTMLElement).focus) {\n ((target as Node) as HTMLElement).focus({\n preventScroll: true,\n });\n }\n break;\n case MouseInteractions.Click:\n case MouseInteractions.TouchStart:\n case MouseInteractions.TouchEnd:\n if (isSync) {\n if (d.type === MouseInteractions.TouchStart) {\n this.touchActive = true;\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.touchActive = false;\n }\n this.mousePos = {\n x: d.x,\n y: d.y,\n id: d.id,\n debugData: d,\n };\n } else {\n if (d.type === MouseInteractions.TouchStart) {\n // don't draw a trail as user has lifted finger and is placing at a new point\n this.tailPositions.length = 0;\n }\n this.moveAndHover(d.x, d.y, d.id, isSync, d);\n if (d.type === MouseInteractions.Click) {\n /*\n * don't want target.click() here as could trigger an iframe navigation\n * instead any effects of the click should already be covered by mutations\n */\n /*\n * removal and addition of .active class (along with void line to trigger repaint)\n * triggers the 'click' css animation in styles/style.css\n */\n this.mouse.classList.remove('active');\n // tslint:disable-next-line\n void this.mouse.offsetWidth;\n this.mouse.classList.add('active');\n } else if (d.type === MouseInteractions.TouchStart) {\n void this.mouse.offsetWidth; // needed for the position update of moveAndHover to apply without the .touch-active transition\n this.mouse.classList.add('touch-active');\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.mouse.classList.remove('touch-active');\n }\n }\n break;\n case MouseInteractions.TouchCancel:\n if (isSync) {\n this.touchActive = false;\n } else {\n this.mouse.classList.remove('touch-active');\n }\n break;\n default:\n target.dispatchEvent(event);\n }\n break;\n }\n case IncrementalSource.Scroll: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.scroll(d);\n break;\n }\n this.applyScroll(d, false);\n break;\n }\n case IncrementalSource.ViewportResize:\n this.emitter.emit(ReplayerEvents.Resize, {\n width: d.width,\n height: d.height,\n });\n break;\n case IncrementalSource.Input: {\n /**\n * Input event on an unserialized node usually means the event\n * was synchrony triggered programmatically after the node was\n * created. This means there was not an user observable interaction\n * and we do not need to replay it.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.input(d);\n break;\n }\n this.applyInput(d);\n break;\n }\n case IncrementalSource.MediaInteraction: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n const mediaEl = (target as Node) as HTMLMediaElement;\n try {\n if (d.currentTime) {\n mediaEl.currentTime = d.currentTime;\n }\n if (d.volume) {\n mediaEl.volume = d.volume;\n }\n if (d.muted) {\n mediaEl.muted = d.muted;\n }\n if (d.type === MediaInteractions.Pause) {\n mediaEl.pause();\n }\n if (d.type === MediaInteractions.Play) {\n // remove listener for 'canplay' event because play() is async and returns a promise\n // i.e. media will evntualy start to play when data is loaded\n // 'canplay' event fires even when currentTime attribute changes which may lead to\n // unexpeted behavior\n mediaEl.play();\n }\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n `Failed to replay media interactions: ${error.message || error}`,\n );\n }\n }\n break;\n }\n case IncrementalSource.StyleSheetRule: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n /**\n * Always use existing DOM node, when it's there.\n * In in-memory replay, there is virtual node, but it's `sheet` is inaccessible.\n * Hence, we buffer all style changes in virtualStyleRulesMap.\n */\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules;\n\n if (!styleSheet) {\n /**\n * styleEl.sheet is only accessible if the styleEl is part of the\n * dom. This doesn't work on DocumentFragments so we have to add the\n * style mutations to the virtualStyleRulesMap.\n */\n\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.adds) {\n d.adds.forEach(({ rule, index: nestedIndex }) => {\n if (styleSheet) {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet.cssRules,\n positions,\n );\n nestedRule.insertRule(rule, index);\n } else {\n const index =\n nestedIndex === undefined\n ? undefined\n : Math.min(nestedIndex, styleSheet.cssRules.length);\n styleSheet.insertRule(rule, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else {\n rules?.push({\n cssText: rule,\n index: nestedIndex,\n type: StyleRuleType.Insert,\n });\n }\n });\n }\n\n if (d.removes) {\n d.removes.forEach(({ index: nestedIndex }) => {\n if (usingVirtualParent) {\n rules?.push({ index: nestedIndex, type: StyleRuleType.Remove });\n } else {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet!.cssRules,\n positions,\n );\n nestedRule.deleteRule(index || 0);\n } else {\n styleSheet?.deleteRule(nestedIndex);\n }\n } catch (e) {\n /**\n * same as insertRule\n */\n }\n }\n });\n }\n break;\n }\n case IncrementalSource.StyleDeclaration: {\n // same with StyleSheetRule\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules = [];\n\n if (!styleSheet) {\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.set) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.setProperty(d.set.property, d.set.value, d.set.priority);\n } else {\n rules.push({\n type: StyleRuleType.SetProperty,\n index: d.index,\n ...d.set,\n });\n }\n }\n\n if (d.remove) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.removeProperty(d.remove.property);\n } else {\n rules.push({\n type: StyleRuleType.RemoveProperty,\n index: d.index,\n ...d.remove,\n });\n }\n }\n break;\n }\n case IncrementalSource.CanvasMutation: {\n if (!this.config.UNSAFE_replayCanvas) {\n return;\n }\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n canvasMutation({\n event: e,\n mutation: d,\n target: (target as unknown) as HTMLCanvasElement,\n imageMap: this.imageMap,\n errorHandler: this.warnCanvasMutationFailed.bind(this),\n });\n\n break;\n }\n case IncrementalSource.Font: {\n try {\n const fontFace = new FontFace(\n d.family,\n d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource,\n d.descriptors,\n );\n this.iframe.contentDocument?.fonts.add(fontFace);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(error);\n }\n }\n break;\n }\n default:\n }\n }\n\n private applyMutation(d: mutationData, useVirtualParent: boolean) {\n d.removes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.parentId)) {\n // no need to warn, parent was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.virtualStyleRulesMap.has(target)) {\n this.virtualStyleRulesMap.delete(target);\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n return this.warnNodeNotFound(d, mutation.parentId);\n }\n if (mutation.isShadow && hasShadowRoot(parent)) {\n parent = parent.shadowRoot;\n }\n // target may be removed with its parents before\n this.mirror.removeNodeFromMap(target);\n if (parent) {\n let realTarget = null;\n const realParent =\n '__sn' in parent ? this.fragmentParentMap.get(parent) : undefined;\n if (realParent && realParent.contains(target)) {\n parent = realParent;\n } else if (this.fragmentParentMap.has(target)) {\n /**\n * the target itself is a fragment document and it's not in the dom\n * so we should remove the real target from its parent\n */\n realTarget = this.fragmentParentMap.get(target)!;\n this.fragmentParentMap.delete(target);\n target = realTarget;\n }\n try {\n parent.removeChild(target);\n } catch (error) {\n if (error instanceof DOMException) {\n this.warn(\n 'parent could not remove child in mutation',\n parent,\n realParent,\n target,\n realTarget,\n d,\n );\n } else {\n throw error;\n }\n }\n }\n });\n\n // tslint:disable-next-line: variable-name\n const legacy_missingNodeMap: missingNodeMap = {\n ...this.legacy_missingNodeRetryMap,\n };\n const queue: addedNodeMutation[] = [];\n\n // next not present at this moment\n const nextNotInDOM = (mutation: addedNodeMutation) => {\n let next: Node | null = null;\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n // next not present at this moment\n if (\n mutation.nextId !== null &&\n mutation.nextId !== undefined &&\n mutation.nextId !== -1 &&\n !next\n ) {\n return true;\n }\n return false;\n };\n\n const appendNode = (mutation: addedNodeMutation) => {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n if (mutation.node.type === NodeType.Document) {\n // is newly added document, maybe the document node of an iframe\n return this.newDocumentQueue.push(mutation);\n }\n return queue.push(mutation);\n }\n\n let parentInDocument = null;\n if (this.iframe.contentDocument.contains) {\n parentInDocument = this.iframe.contentDocument.contains(parent);\n } else if (this.iframe.contentDocument.body.contains) {\n // fix for IE\n // refer 'Internet Explorer notes' at https://developer.mozilla.org/zh-CN/docs/Web/API/Document\n parentInDocument = this.iframe.contentDocument.body.contains(parent);\n }\n\n const hasIframeChild =\n ((parent as unknown) as HTMLElement).getElementsByTagName?.('iframe')\n .length > 0;\n /**\n * Why !isIframeINode(parent)? If parent element is an iframe, iframe document can't be appended to virtual parent.\n * Why !hasIframeChild? If we move iframe elements from dom to fragment document, we will lose the contentDocument of iframe. So we need to disable the virtual dom optimization if a parent node contains iframe elements.\n */\n if (\n useVirtualParent &&\n parentInDocument &&\n !isIframeINode(parent) &&\n !hasIframeChild\n ) {\n const virtualParent = (document.createDocumentFragment() as unknown) as INode;\n this.mirror.map[mutation.parentId] = virtualParent;\n this.fragmentParentMap.set(virtualParent, parent);\n\n // store the state, like scroll position, of child nodes before they are unmounted from dom\n this.storeState(parent);\n\n while (parent.firstChild) {\n virtualParent.appendChild(parent.firstChild);\n }\n parent = virtualParent;\n }\n\n if (mutation.node.isShadow) {\n // If the parent is attached a shadow dom after it's created, it won't have a shadow root.\n if (!hasShadowRoot(parent)) {\n ((parent as Node) as HTMLElement).attachShadow({ mode: 'open' });\n parent = ((parent as Node) as HTMLElement).shadowRoot!;\n } else parent = parent.shadowRoot;\n }\n\n let previous: Node | null = null;\n let next: Node | null = null;\n if (mutation.previousId) {\n previous = this.mirror.getNode(mutation.previousId) as Node;\n }\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n if (nextNotInDOM(mutation)) {\n return queue.push(mutation);\n }\n\n if (mutation.node.rootId && !this.mirror.getNode(mutation.node.rootId)) {\n return;\n }\n\n const targetDoc = mutation.node.rootId\n ? this.mirror.getNode(mutation.node.rootId)\n : this.iframe.contentDocument;\n if (isIframeINode(parent)) {\n this.attachDocumentToIframe(mutation, parent);\n return;\n }\n const target = buildNodeWithSN(mutation.node, {\n doc: targetDoc as Document,\n map: this.mirror.map,\n skipChild: true,\n hackCss: true,\n cache: this.cache,\n }) as INode;\n\n // legacy data, we should not have -1 siblings any more\n if (mutation.previousId === -1 || mutation.nextId === -1) {\n legacy_missingNodeMap[mutation.node.id] = {\n node: target,\n mutation,\n };\n return;\n }\n\n if (\n '__sn' in parent &&\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n mutation.node.type === NodeType.Text\n ) {\n // https://github.com/rrweb-io/rrweb/issues/745\n // parent is textarea, will only keep one child node as the value\n for (const c of Array.from(parent.childNodes)) {\n if (c.nodeType === parent.TEXT_NODE) {\n parent.removeChild(c);\n }\n }\n }\n\n if (previous && previous.nextSibling && previous.nextSibling.parentNode) {\n parent.insertBefore(target, previous.nextSibling);\n } else if (next && next.parentNode) {\n // making sure the parent contains the reference nodes\n // before we insert target before next.\n parent.contains(next)\n ? parent.insertBefore(target, next)\n : parent.insertBefore(target, null);\n } else {\n /**\n * Sometimes the document changes and the MutationObserver is disconnected, so the removal of child elements can't be detected and recorded. After the change of document, we may get another mutation which adds a new html element, while the old html element still exists in the dom, and we need to remove the old html element first to avoid collision.\n */\n if (parent === targetDoc) {\n while (targetDoc.firstChild) {\n targetDoc.removeChild(targetDoc.firstChild);\n }\n }\n\n parent.appendChild(target);\n }\n\n if (isIframeINode(target)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === target.__sn.id,\n );\n if (mutationInQueue) {\n this.attachDocumentToIframe(mutationInQueue, target);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(\n legacy_missingNodeMap,\n parent,\n target,\n mutation,\n );\n }\n };\n\n d.adds.forEach((mutation) => {\n appendNode(mutation);\n });\n\n let startTime = Date.now();\n while (queue.length) {\n // transform queue to resolve tree\n const resolveTrees = queueToResolveTrees(queue);\n queue.length = 0;\n if (Date.now() - startTime > 500) {\n this.warn(\n 'Timeout in the loop, please check the resolve tree data:',\n resolveTrees,\n );\n break;\n }\n for (const tree of resolveTrees) {\n let parent = this.mirror.getNode(tree.value.parentId);\n if (!parent) {\n this.debug(\n 'Drop resolve tree since there is no parent for the root node.',\n tree,\n );\n } else {\n iterateResolveTree(tree, (mutation) => {\n appendNode(mutation);\n });\n }\n }\n }\n\n if (Object.keys(legacy_missingNodeMap).length) {\n Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);\n }\n\n d.texts.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n /**\n * apply text content to real parent directly\n */\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n target.textContent = mutation.value;\n });\n d.attributes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n for (const attributeName in mutation.attributes) {\n if (typeof attributeName === 'string') {\n const value = mutation.attributes[attributeName];\n if (value === null) {\n ((target as Node) as Element).removeAttribute(attributeName);\n } else if (typeof value === 'string') {\n try {\n ((target as Node) as Element).setAttribute(attributeName, value);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n 'An error occurred may due to the checkout feature.',\n error,\n );\n }\n }\n } else if (attributeName === 'style') {\n let styleValues = value as styleAttributeValue;\n const targetEl = (target as Node) as HTMLElement;\n for (var s in styleValues) {\n if (styleValues[s] === false) {\n targetEl.style.removeProperty(s);\n } else if (styleValues[s] instanceof Array) {\n const svp = styleValues[s] as styleValueWithPriority;\n targetEl.style.setProperty(s, svp[0], svp[1]);\n } else {\n const svs = styleValues[s] as string;\n targetEl.style.setProperty(s, svs);\n }\n }\n }\n }\n }\n });\n }\n\n /**\n * Apply the scroll data on real elements.\n * If the replayer is in sync mode, smooth scroll behavior should be disabled.\n * @param d the scroll data\n * @param isSync whether the replayer is in sync mode(fast-forward)\n */\n private applyScroll(d: scrollData, isSync: boolean) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n if ((target as Node) === this.iframe.contentDocument) {\n this.iframe.contentWindow!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else if (target.__sn.type === NodeType.Document) {\n // nest iframe content document\n ((target as unknown) as Document).defaultView!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else {\n try {\n ((target as Node) as Element).scrollTop = d.y;\n ((target as Node) as Element).scrollLeft = d.x;\n } catch (error) {\n /**\n * Seldomly we may found scroll target was removed before\n * its last scroll event.\n */\n }\n }\n }\n\n private applyInput(d: inputData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n try {\n ((target as Node) as HTMLInputElement).checked = d.isChecked;\n ((target as Node) as HTMLInputElement).value = d.text;\n } catch (error) {\n // for safe\n }\n }\n\n private applyText(d: textMutation, mutation: mutationData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(mutation, d.id);\n }\n try {\n ((target as Node) as HTMLElement).textContent = d.value;\n } catch (error) {\n // for safe\n }\n }\n\n private legacy_resolveMissingNode(\n map: missingNodeMap,\n parent: Node,\n target: Node,\n targetMutation: addedNodeMutation,\n ) {\n const { previousId, nextId } = targetMutation;\n const previousInMap = previousId && map[previousId];\n const nextInMap = nextId && map[nextId];\n if (previousInMap) {\n const { node, mutation } = previousInMap as missingNode;\n parent.insertBefore(node, target);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n if (nextInMap) {\n const { node, mutation } = nextInMap as missingNode;\n parent.insertBefore(node, target.nextSibling);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n }\n\n private moveAndHover(\n x: number,\n y: number,\n id: number,\n isSync: boolean,\n debugData: incrementalData,\n ) {\n const target = this.mirror.getNode(id);\n if (!target) {\n return this.debugNodeNotFound(debugData, id);\n }\n\n const base = getBaseDimension(target, this.iframe);\n const _x = x * base.absoluteScale + base.x;\n const _y = y * base.absoluteScale + base.y;\n\n this.mouse.style.left = `${_x}px`;\n this.mouse.style.top = `${_y}px`;\n if (!isSync) {\n this.drawMouseTail({ x: _x, y: _y });\n }\n this.hoverElements((target as Node) as Element);\n }\n\n private drawMouseTail(position: { x: number; y: number }) {\n if (!this.mouseTail) {\n return;\n }\n\n const { lineCap, lineWidth, strokeStyle, duration } =\n this.config.mouseTail === true\n ? defaultMouseTailConfig\n : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);\n\n const draw = () => {\n if (!this.mouseTail) {\n return;\n }\n const ctx = this.mouseTail.getContext('2d');\n if (!ctx || !this.tailPositions.length) {\n return;\n }\n ctx.clearRect(0, 0, this.mouseTail.width, this.mouseTail.height);\n ctx.beginPath();\n ctx.lineWidth = lineWidth;\n ctx.lineCap = lineCap;\n ctx.strokeStyle = strokeStyle;\n ctx.moveTo(this.tailPositions[0].x, this.tailPositions[0].y);\n this.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));\n ctx.stroke();\n };\n\n this.tailPositions.push(position);\n draw();\n setTimeout(() => {\n this.tailPositions = this.tailPositions.filter((p) => p !== position);\n draw();\n }, duration / this.speedService.state.context.timer.speed);\n }\n\n private hoverElements(el: Element) {\n this.iframe.contentDocument\n ?.querySelectorAll('.\\\\:hover')\n .forEach((hoveredEl) => {\n hoveredEl.classList.remove(':hover');\n });\n let currentEl: Element | null = el;\n while (currentEl) {\n if (currentEl.classList) {\n currentEl.classList.add(':hover');\n }\n currentEl = currentEl.parentElement;\n }\n }\n\n private isUserInteraction(event: eventWithTime): boolean {\n if (event.type !== EventType.IncrementalSnapshot) {\n return false;\n }\n return (\n event.data.source > IncrementalSource.Mutation &&\n event.data.source <= IncrementalSource.Input\n );\n }\n\n private backToNormal() {\n this.nextUserInteractionEvent = null;\n if (this.speedService.state.matches('normal')) {\n return;\n }\n this.speedService.send({ type: 'BACK_TO_NORMAL' });\n this.emitter.emit(ReplayerEvents.SkipEnd, {\n speed: this.speedService.state.context.normalSpeed,\n });\n }\n\n /**\n * Replace the virtual parent with the real parent.\n * @param frag fragment document, the virtual parent\n * @param parent real parent element\n */\n private restoreRealParent(frag: INode, parent: INode) {\n this.mirror.map[parent.__sn.id] = parent;\n /**\n * If we have already set value attribute on textarea,\n * then we could not apply text content as default value any more.\n */\n if (\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n frag.textContent\n ) {\n ((parent as unknown) as HTMLTextAreaElement).value = frag.textContent;\n }\n parent.appendChild(frag);\n // restore state of elements after they are mounted\n this.restoreState(parent);\n }\n\n /**\n * store state of elements before unmounted from dom recursively\n * the state should be restored in the handler of event ReplayerEvents.Flush\n * e.g. browser would lose scroll position after the process that we add children of parent node to Fragment Document as virtual dom\n */\n private storeState(parent: INode) {\n if (parent) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (parentElement.scrollLeft || parentElement.scrollTop) {\n // store scroll position state\n this.elementStateMap.set(parent, {\n scroll: [parentElement.scrollLeft, parentElement.scrollTop],\n });\n }\n if (parentElement.tagName === 'STYLE')\n storeCSSRules(\n parentElement as HTMLStyleElement,\n this.virtualStyleRulesMap,\n );\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.storeState((child as unknown) as INode);\n }\n }\n }\n }\n\n /**\n * restore the state of elements recursively, which was stored before elements were unmounted from dom in virtual parent mode\n * this function corresponds to function storeState\n */\n private restoreState(parent: INode) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (this.elementStateMap.has(parent)) {\n const storedState = this.elementStateMap.get(parent)!;\n // restore scroll position\n if (storedState.scroll) {\n parentElement.scrollLeft = storedState.scroll[0];\n parentElement.scrollTop = storedState.scroll[1];\n }\n this.elementStateMap.delete(parent);\n }\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.restoreState((child as unknown) as INode);\n }\n }\n }\n\n private restoreNodeSheet(node: INode) {\n const storedRules = this.virtualStyleRulesMap.get(node);\n if (node.nodeName !== 'STYLE') {\n return;\n }\n\n if (!storedRules) {\n return;\n }\n\n const styleNode = (node as unknown) as HTMLStyleElement;\n\n applyVirtualStyleRulesToNode(storedRules, styleNode);\n }\n\n private warnNodeNotFound(d: incrementalData, id: number) {\n if (this.treeIndex.idRemoved(id)) {\n this.warn(`Node with id '${id}' was previously removed. `, d);\n } else {\n this.warn(`Node with id '${id}' not found. `, d);\n }\n }\n\n private warnCanvasMutationFailed(\n d: canvasMutationData | canvasMutationCommand,\n error: unknown,\n ) {\n this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);\n }\n\n private debugNodeNotFound(d: incrementalData, id: number) {\n /**\n * There maybe some valid scenes of node not being found.\n * Because DOM events are macrotask and MutationObserver callback\n * is microtask, so events fired on a removed DOM may emit\n * snapshots in the reverse order.\n */\n if (this.treeIndex.idRemoved(id)) {\n this.debug(\n REPLAY_CONSOLE_PREFIX,\n `Node with id '${id}' was previously removed. `,\n d,\n );\n } else {\n this.debug(REPLAY_CONSOLE_PREFIX, `Node with id '${id}' not found. `, d);\n }\n }\n\n private warn(...args: Parameters) {\n if (!this.config.showWarning) {\n return;\n }\n console.warn(REPLAY_CONSOLE_PREFIX, ...args);\n }\n\n private debug(...args: Parameters) {\n if (!this.config.showDebug) {\n return;\n }\n // tslint:disable-next-line: no-console\n console.log(REPLAY_CONSOLE_PREFIX, ...args);\n }\n}\n","import { Replayer } from '..';\nimport {\n CanvasContext,\n canvasMutationCommand,\n canvasMutationData,\n} from '../../types';\nimport webglMutation from './webgl';\nimport canvas2DMutation from './2d';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationData;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const mutations: canvasMutationCommand[] =\n 'commands' in mutation ? mutation.commands : [mutation];\n\n if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {\n return mutations.forEach((command) => {\n webglMutation({\n mutation: command,\n type: mutation.type,\n target,\n imageMap,\n errorHandler,\n });\n });\n }\n // default is '2d' for backwards compatibility (rrweb below 1.1.x)\n return mutations.forEach((command) => {\n canvas2DMutation({\n event,\n mutation: command,\n target,\n imageMap,\n errorHandler,\n });\n });\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import { Replayer } from '../';\nimport { canvasMutationCommand } from '../../types';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = ((target as unknown) as HTMLCanvasElement).getContext('2d')!;\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n /**\n * We have serialized the image source into base64 string during recording,\n * which has been preloaded before replay.\n * So we can get call drawImage SYNCHRONOUSLY which avoid some fragile cast.\n */\n if (\n mutation.property === 'drawImage' &&\n typeof mutation.args[0] === 'string'\n ) {\n const image = imageMap.get(event);\n mutation.args[0] = image;\n original.apply(ctx, mutation.args);\n } else {\n original.apply(ctx, mutation.args);\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Much of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// Many optimizations have been made, so the bundle size is ultimately smaller but performance is similar.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var u = ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([c], { type: 'text/javascript' })));\n var w = new Worker(u);\n w.onerror = function (e) { return cb(e.error, null); };\n w.onmessage = function (e) { return cb(null, e.data); };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;\n// fixed length extra bits\nvar fleb = new u8([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, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\n// see fleb note\nvar fdeb = new u8([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, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new u32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return [b, r];\n};\nvar _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b[0], revfd = _b[1];\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >>> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >>> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >>> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >>> 8) | ((x & 0x00FF) << 8)) >>> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i)\n ++l[cd[i] - 1];\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 0; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >>> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i)\n co[i] = rev[le[cd[i] - 1]++] >>> (15 - cd[i]);\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8)) >>> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >>> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p / 8) >> 0) + (p & 7 && 1); };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n var n = new (v instanceof u16 ? u16 : v instanceof u32 ? u32 : u8)(e - s);\n n.set(v.subarray(s, e));\n return n;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, buf, st) {\n // source length\n var sl = dat.length;\n // have to estimate size\n var noBuf = !buf || st;\n // no state\n var noSt = !st || st.i;\n if (!st)\n st = {};\n // Assumes roughly 33% compression ratio average\n if (!buf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n st.f = final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n throw 'unexpected EOF';\n break;\n }\n // ensure size\n if (noBuf)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n if (!noSt && pos + tl * (clb + 7) > tbts)\n break;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >>> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n throw 'invalid block type';\n if (pos > tbts)\n throw 'unexpected EOF';\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17;\n if (noBuf)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var mxa = lbt + dbt + 18;\n while (noSt || pos + mxa < tbts) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;\n pos += c & 15;\n if (pos > tbts)\n throw 'unexpected EOF';\n if (!c)\n throw 'invalid length/literal';\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;\n if (!d)\n throw 'invalid distance';\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & ((1 << b) - 1), pos += b;\n }\n if (pos > tbts)\n throw 'unexpected EOF';\n if (noBuf)\n cbuf(bt + 131072);\n var end = bt + add;\n for (; bt < end; bt += 4) {\n buf[bt] = buf[bt - dt];\n buf[bt + 1] = buf[bt + 1 - dt];\n buf[bt + 2] = buf[bt + 2 - dt];\n buf[bt + 3] = buf[bt + 3 - dt];\n }\n bt = end;\n }\n }\n st.l = lm, st.p = pos, st.b = bt;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n return bt == buf.length ? buf : slc(buf, 0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n d[o + 2] |= v >>> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return [new u8(0), 0];\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return [v, 1];\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return [new u8(tr), mbt];\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return [cl.subarray(0, cli), s];\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >>> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a[0], mlb = _a[1];\n var _b = hTree(df, 15), ddt = _b[0], mdb = _b[1];\n var _c = lc(dlt), lclt = _c[0], nlc = _c[1];\n var _d = lc(ddt), lcdt = _d[0], ndc = _d[1];\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n lcfreq[lclt[i] & 31]++;\n for (var i = 0; i < lcdt.length; ++i)\n lcfreq[lcdt[i] & 31]++;\n var _e = hTree(lcfreq, 7), lct = _e[0], mlcb = _e[1];\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);\n if (flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >>> 5) & 127), p += clct[i] >>> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n if (syms[i] > 255) {\n var len = (syms[i] >>> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (syms[i] >>> 23) & 31), p += fleb[len];\n var dst = syms[i] & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (syms[i] >>> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new u32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, lst) {\n var s = dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.floor(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var pos = 0;\n if (!lvl || s < 8) {\n for (var i = 0; i <= s; i += 65535) {\n // end\n var e = i + 65535;\n if (e < s) {\n // write full block\n pos = wfblk(w, pos, dat.subarray(i, e));\n }\n else {\n // write final block\n w[i] = lst;\n pos = wfblk(w, pos, dat.subarray(i, s));\n }\n }\n }\n else {\n var opt = deo[lvl - 1];\n var n = opt >>> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = new u16(32768), head = new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new u32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx bitpos\n var lc_1 = 0, eb = 0, i = 0, li = 0, wi = 0, bs = 0;\n for (; i < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768\n var imod = i & 32767;\n // previous index with this value\n var pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && rem > 423) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = (imod - pimod) & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = (i - dif + j + 32768) & 32767;\n var pti = prev[ti];\n var cd = (ti - pti + 32768) & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += (imod - pimod + 32768) & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one Uint32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n // this is the easiest way to avoid needing to maintain state\n if (!lst)\n pos = wfblk(w, pos, et);\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new u32(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && 0xEDB88320) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = 0xFFFFFFFF;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return c ^ 0xFFFFFFFF; }\n };\n};\n// Alder32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 5552, l);\n for (; i < e; ++i)\n n += d[i], m += n;\n n %= 65521, m %= 65521;\n }\n a = n, b = m;\n },\n d: function () { return ((a >>> 8) << 16 | (b & 255) << 8 | (b >>> 8)) + ((a & 255) << 23) * 2; }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post, !st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/ /g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return [fnStr, td];\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k] instanceof u8 || v[k] instanceof u16 || v[k] instanceof u32)\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n var _a;\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n _a = wcln(fns[i], fnStr, td_1), fnStr = _a[0], td_1 = _a[1];\n ch[id] = wcln(fns[m], fnStr, td_1);\n }\n var td = mrg({}, ch[id][1]);\n return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, hMap, max, bits, bits16, shft, slc, inflt, inflateSync, pbf, gu8]; };\nvar bDflt = function () { return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zlv]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get u8\nvar gu8 = function (o) { return o && o.size && new u8(o.size); };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n if (!opts.consume)\n dat = new u8(dat);\n w.postMessage([dat, opts], [dat.buffer]);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) { return strm.push(ev.data[0], ev.data[1]); };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.push = function (d, f) {\n if (t)\n throw 'stream finished';\n if (!strm.ondata)\n throw 'no stream handler';\n w.postMessage([d, t = f], [d.buffer]);\n };\n strm.terminate = function () { w.terminate(); };\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16)) + (d[b + 3] << 23) * 2; };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n throw 'invalid gzip data';\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += d[10] | (d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16) + (2 * (d[l - 1] << 23));\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + ((o.filename && (o.filename.length + 1)) || 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (fl ? (32 - 2 * fl) : 1);\n};\n// zlib valid\nvar zlv = function (d) {\n if ((d[0] & 15) != 8 || (d[0] >>> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n throw 'invalid zlib data';\n if (d[1] & 32)\n throw 'invalid zlib data: preset dictionaries not supported';\n};\nfunction AsyncCmpStrm(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n// zlib footer: -4 to -0 is Adler32\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, !f), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n this.d = final;\n this.p(chunk, final || false);\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n return dopt(data, opts, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n /**\n * Creates an inflation stream\n * @param cb The callback to call whenever data is inflated\n */\n function Inflate(cb) {\n this.s = {};\n this.p = new u8(0);\n this.ondata = cb;\n }\n Inflate.prototype.e = function (c) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n var l = this.p.length;\n var n = new u8(l + c.length);\n n.set(this.p), n.set(c, l), this.p = n;\n };\n Inflate.prototype.c = function (final) {\n this.d = this.s.i = final || false;\n var bts = this.s.b;\n var dt = inflt(this.p, this.o, this.s);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) >> 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous inflation stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncInflate(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, 0, function () {\n var strm = new Inflate();\n onmessage = astrm(strm);\n }, 7);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gu8(ev.data[1]))); }, 1, cb);\n}\n/**\n * Expands DEFLATE data with no wrapper\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function inflateSync(data, out) {\n return inflt(data, out);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n this.c.p(c);\n this.l += c.length;\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, !f);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n /**\n * Creates a GUNZIP stream\n * @param cb The callback to call whenever data is inflated\n */\n function Gunzip(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n var s = gzs(this.p);\n if (s >= this.p.length && !final)\n return;\n this.p = this.p.subarray(s), this.v = 0;\n }\n if (final) {\n if (this.p.length < 8)\n throw 'invalid gzip stream';\n this.p = this.p.subarray(0, -8);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous GUNZIP stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncGunzip(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, 0, function () {\n var strm = new Gunzip();\n onmessage = astrm(strm);\n }, 9);\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0])); }, 3, cb);\n}\n/**\n * Expands GZIP data\n * @param data The data to decompress\n * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.\n * @returns The decompressed version of the data\n */\nexport function gunzipSync(data, out) {\n return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n this.c.p(c);\n var raw = dopt(c, this.o, this.v && 2, f && 4, !f);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n /**\n * Creates a Zlib decompression stream\n * @param cb The callback to call whenever data is inflated\n */\n function Unzlib(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 2 && !final)\n return;\n this.p = this.p.subarray(2), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n throw 'invalid zlib stream';\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous Zlib decompression stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncUnzlib(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, 0, function () {\n var strm = new Unzlib();\n onmessage = astrm(strm);\n }, 11);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gu8(ev.data[1]))); }, 5, cb);\n}\n/**\n * Expands Zlib data\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function unzlibSync(data, out) {\n return inflt((zlv(data), data.subarray(2, -4)), out);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n /**\n * Creates a decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function Decompress(cb) {\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n throw 'no stream handler';\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n var _this_1 = this;\n var cb = function () { _this_1.ondata.apply(_this_1, arguments); };\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(cb)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(cb)\n : new this.Z(cb);\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function AsyncDecompress(cb) {\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, out) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, out)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, out)\n : unzlibSync(data, out);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k;\n if (val instanceof u8)\n t[n] = [val, o];\n else if (Array.isArray(val))\n t[n] = [val[0], mrg(o, val[1])];\n else\n fltn(val, n + '/', t, o);\n }\n};\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n var l = str.length;\n if (!latin1 && typeof TextEncoder != 'undefined')\n return new TextEncoder().encode(str);\n var ar = new u8(str.length + (str.length >>> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >>> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >>> 18)), w(128 | ((c >>> 12) & 63)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >>> 12)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n var r = '';\n if (!latin1 && typeof TextDecoder != 'undefined')\n return new TextDecoder().decode(dat);\n for (var i = 0; i < dat.length;) {\n var c = dat[i++];\n if (c < 128 || latin1)\n r += String.fromCharCode(c);\n else if (c < 224)\n r += String.fromCharCode((c & 31) << 6 | (dat[i++] & 63));\n else if (c < 240)\n r += String.fromCharCode((c & 15) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63));\n else\n c = ((c & 15) << 18 | (dat[i++] & 63) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n return r;\n}\n;\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;\n var _a = z ? z64e(d, es) : [b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];\n};\n// read zip64 extra field\nvar z64e = function (d, b) {\n for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))\n ;\n return [b4(d, b + 12), b4(d, b + 4), b4(d, b + 20)];\n};\n// write zip header\nvar wzh = function (d, b, c, cmp, su, fn, u, o, ce, t) {\n var fl = fn.length, l = cmp.length;\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b] = 20, b += 2;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (t == 8 && (o.level == 1 ? 6 : o.level < 6 ? 4 : o.level == 9 ? 2 : 0)), d[b++] = u && 8;\n d[b] = t, b += 2;\n var dt = new Date(o.mtime || Date.now()), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n throw 'date not in range 1980-2099';\n wbytes(d, b, ((y << 24) * 2) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >>> 1));\n b += 4;\n wbytes(d, b, c);\n wbytes(d, b + 4, l);\n wbytes(d, b + 8, su);\n wbytes(d, b + 12, fl), b += 16; // skip extra field, comment\n if (ce != null)\n wbytes(d, b += 10, ce), b += 4;\n d.set(fn, b);\n b += fl;\n if (ce == null)\n d.set(cmp, b);\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n wzh(out, tot, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, tot, f.t), o += 46 + f.n.length, tot += 30 + f.n.length + f.d.length;\n }\n catch (e) {\n return cb(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cb(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), m = file.length;\n c.p(file);\n var n = strToU8(fn), s = n.length;\n var t = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n var l = d.length;\n files[i] = {\n t: t,\n d: d,\n m: m,\n c: c.d(),\n u: fn.length != l,\n n: n,\n p: p\n };\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n if (!--lft)\n cbf();\n }\n };\n if (n.length > 65535)\n cbl('filename too long', null);\n if (!t)\n cbl(null, file);\n else if (m < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var t = p.level == 0 ? 0 : 8;\n var n = strToU8(fn), s = n.length;\n if (n.length > 65535)\n throw 'filename too long';\n var d = t ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push({\n t: t,\n d: d,\n m: file.length,\n c: c.d(),\n u: fn.length != s,\n n: n,\n o: o,\n p: p\n });\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, f.o, f.t), o += 46 + f.n.length;\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Asynchronously decompresses a ZIP archive\n * @param data The raw compressed ZIP file\n * @param cb The callback to call with the decompressed files\n * @returns A function that can be used to immediately terminate the unzipping\n */\nexport function unzip(data, cb) {\n if (typeof cb != 'function')\n throw 'no callback';\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cb('invalid zip file', null);\n return;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (!lft)\n cb(null, {});\n var c = lft;\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = lft = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n var _loop_2 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n files[fn] = d;\n if (!--lft)\n cb(null, files);\n }\n };\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n if (sc < 320000) {\n try {\n cbl(null, inflateSync(infl, new u8(su)));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl('unknown compression type ' + c_1, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_2(i);\n }\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @returns The decompressed files\n */\nexport function unzipSync(data) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n throw 'invalid zip file';\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));\n else\n throw 'unknown compression type ' + c_2;\n }\n return files;\n}\n","import { strFromU8, strToU8, unzlibSync } from 'fflate';\nimport { UnpackFn, eventWithTimeAndPacker, MARK } from './base';\nimport { eventWithTime } from '../types';\n\nexport const unpack: UnpackFn = (raw: string) => {\n if (typeof raw !== 'string') {\n return raw;\n }\n try {\n const e: eventWithTime = JSON.parse(raw);\n if (e.timestamp) {\n return e;\n }\n } catch (error) {\n // ignore and continue\n }\n try {\n const e: eventWithTimeAndPacker = JSON.parse(\n strFromU8(unzlibSync(strToU8(raw, true)))\n );\n if (e.v === MARK) {\n return e;\n }\n throw new Error(\n `These events were packed with packer ${e.v} which is incompatible with current packer ${MARK}.`,\n );\n } catch (error) {\n console.error(error);\n throw new Error('Unknown data format.');\n }\n};\n","import { eventWithTime } from '../types';\n\nexport type PackFn = (event: eventWithTime) => string;\nexport type UnpackFn = (raw: string) => eventWithTime;\n\nexport type eventWithTimeAndPacker = eventWithTime & {\n v: string;\n};\n\nexport const MARK = 'v1';\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isElement","nodeType","ELEMENT_NODE","commentre","parse","css","options","lineno","column","updatePosition","str","lines","match","lastIndexOf","position","start","line","node","Position","whitespace","end","source","content","errorsList","msg","err","Error","reason","filename","silent","open","close","rules","comments","charAt","atrule","rule","re","exec","c","comment","pos","type","selector","trim","replace","split","map","declaration","propMatch","prop","val","ret","property","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","name","RegExp","vendor","frame","frames","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","doc","document","atdocument","sel","selectors","atpage","athost","atfontface","addParent","stylesheet","parsingErrors","obj","parent","isNode","childParent","_i","_a","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","script","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cssText","cache","cachedStyle","stylesWithHoverClass","get","ast","test","selectorMatcher","filter","index","indexOf","sort","a","b","join","result","newSelector","set","createCache","Map","buildNode","hackCss","Document","implementation","createDocument","DocumentType","createDocumentType","publicId","systemId","Element","node_1","tagName","attributes","_cssText","getTagName","isSVG","createElementNS","createElement","_loop_1","name_1","startsWith","image_1","src","onload","ctx","getContext","drawImage","width","height","image","currentSrc","setAttribute","currentTime","rr_mediaCurrentTime","play","console","warn","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","childNodes","TEXT_NODE","removeChild","appendChild","setAttributeNS","substring","rel","as","href","endsWith","srcset","rr_dataURL","isShadowHost","shadowRoot","firstChild","attachShadow","mode","Text","isStyle","textContent","CDATA","createCDATASection","Comment","createComment","buildNodeWithSN","skipChild","_b","afterAppend","rootId","assert","compatMode","xmlns","write","__sn","id","_c","childN","childNode","isShadow","rebuild","onVisit","idNodeMap","key","visit","visitedNode","el","name_2","scrollLeft","scrollTop","handleScroll","mitt","all","create","on","handler","off","splice","emit","evt","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","polyfill","w","d","documentElement","__forceSmoothScrollPolyfill__","userAgent","HTMLElement","original","scroll","scrollTo","scrollBy","elementScroll","scrollElement","scrollIntoView","now","performance","bind","Date","ROUNDING_TOLERANCE","navigator","undefined","shouldBailOut","smoothScroll","body","left","scrollX","pageXOffset","top","scrollY","pageYOffset","SyntaxError","behavior","scrollableParent","findScrollableParent","parentRects","getBoundingClientRect","clientRects","getComputedStyle","x","y","firstArg","hasScrollableSpace","axis","clientHeight","scrollHeight","clientWidth","scrollWidth","canOverflow","overflowValue","isScrollable","isScrollableY","isScrollableX","parentNode","host","step","context","currentX","currentY","k","elapsed","startTime","Math","cos","PI","startX","startY","method","scrollable","requestAnimationFrame","actions","speed","Timer","action","findActionIndex","timeOffset","lastTimestamp","self","raf","check","time","delay","shift","doAction","liveMode","cancelAnimationFrame","mid","floor","addDelay","event","baselineTime","IncrementalSnapshot","data","MouseMove","firstOffset","positions","firstTimestamp","timestamp","return","NotStarted","Running","Stopped","assignment","u","changed","matches","f","states","initial","entry","config","_options","initialState","transition","g","h","S","target","j","E","R","N","cond","O","_","T","q","exit","z","A","B","C","Set","_machine","send","subscribe","add","unsubscribe","delete","stop","clear","state","status","createPlayerService","getCastFn","applyEventsSynchronously","emitter","interpret","createMachine","playing","PAUSE","CAST_EVENT","END","ADD_EVENT","paused","PLAY","TO_LIVE","live","castEvent","lastPlayedEvent","payload","recordTimeOffset","events","timer","events_1","neededEvents","idx","event_1","Meta","discardPriorSnapshots","lastPlayedTimestamp","PlayBack","syncEvents","event_3","castFn_1","neededEvents_1","Flush","addActions","resetLastPlayedEvent","startLive","toggleLiveMode","addEvent","machineEvent","event_4","insertionIndex","isSync","castFn_2","isActive","addAction","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","getId","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","receiver","TreeIndex","mutation","parentTreeNode","indexes","parentId","treeNode","children","texts","tree","mirror","deepRemoveFromMirror","_this","removeIdSet","deepRemoveFromTreeIndex","_treeNode","_parentTreeNode","removeNodeMutations","textMutations","attributeMutations","scrollMap","inputMap","batchMutationData","Mutation","removes","adds","walk","removed","_d","_f","mutationData","queueToResolveTrees","queue","queueNodeMap","putIntoMap","nodeInTree","queueNodeTrees","queue_1","nextId","nextInTree","parentInTree","iterateResolveTree","cb","isIframeINode","getBaseDimension","rootIframe","frameElement","ownerDocument","defaultView","relativeScale","absoluteScale","frameDimension","frameBaseDimension","hasShadowRoot","Boolean","StyleRuleType","getNestedRule","cssRules","getPositionsAndIndex","nestedIndex","pop","applyVirtualStyleRulesToNode","storedRules","styleNode","sheet","Insert","insertRule","Remove","deleteRule","Snapshot","cssTexts","existingRules","existingRulesReversed","entries","reverse","lastMatch_1","Number","restoreSnapshotOfStyleRulesToNode","SetProperty","setProperty","priority","RemoveProperty","removeProperty","chars","lookup","Uint8Array","charCodeAt","webGLVarMap","variableListFor","ctor","contextMap","WebGLVariableConstructorsNames","deserializeArg","imageMap","arg","args","base64","encoded1","encoded2","encoded3","encoded4","bufferLength","len","arraybuffer","ArrayBuffer","bytes","decode","Image","webglMutation","errorHandler","WebGL","setter","constructor","includes","variables","saveToWebGLVarMap","mittProxy.default","mittProxy","REPLAY_CONSOLE_PREFIX","defaultMouseTailConfig","duration","lineCap","lineWidth","strokeStyle","indicatesTouchDevice","TouchMove","MouseInteraction","TouchStart","defaultConfig","maxSpeed","root","loadTimeout","skipInactive","showWarning","showDebug","blockClass","insertStyleRules","triggerFocus","UNSAFE_replayCanvas","pauseAnimation","mouseTail","handleResize","Resize","setupDom","treeIndex","fragmentParentMap","elementStateMap","virtualStyleRulesMap","_e","flush","frag","restoreRealParent","applyText","_h","restoreNodeSheet","_k","applyScroll","_m","applyInput","firstFullSnapshot","service","unpackFn","a1","a2","StateChange","player","speedService","normalSpeed","normal","FAST_FORWARD","SET_SPEED","skipping","BACK_TO_NORMAL","setSpeed","recordSpeed","restoreSpeed","firstMeta","find","firstFullsnapshot","FullSnapshot","width_1","height_1","setTimeout","rebuildFullSnapshot","iframe","contentWindow","initialOffset","mouse","classList","Replayer","backToNormal","display","parseFloat","wrapper","insertBefore","firstEvent","lastEvent","endTime","totalTime","getTimeOffset","contentDocument","getElementsByTagName","remove","Start","Pause","Resume","rawEvent","Promise","resolve","then","pointerEvents","win","disableInteract","smoothscrollPolyfill","NodeList","DOMTokenList","Node","contains","dimension","String","DomContentLoaded","Load","Custom","Plugin","MediaInteraction","castFn","mousePos","moveAndHover","debugData","touchActive","CustomEvent","applyIncremental","nextUserInteractionEvent","_event","isUserInteraction","skipTime","min","round","SkipStart","plugins","replayer","last_index","finish_1","Finish","max","EventCast","legacy_missingNodeRetryMap","collected","builtNode","collectIframeAndAttachDocument","mutationInQueue","this_1","attachDocumentToIframe","newDocumentQueue","collected_1","head","FullsnapshotRebuilded","waitForStylesheetLoad","preloadAllImages","styleEl","injectStylesRules","iframeEl","parent_1","realParent","toUpperCase","this_2","collected_2","timer_1","unloadSheets_1","beforeLoadState_1","stateHandler_1","unsubscribe_1","querySelectorAll","addEventListener","size","getCurrentTime","LoadStylesheetEnd","clearTimeout","LoadStylesheetStart","args_1","hasImageArg","rr_type","images","args_2","getImageArgs","stateHandler","event_2","CanvasMutation","commands","preloadImages","this_3","url","canvas","imgd","createImageData","JSON","putImageData","text","attribute","applyMutation","message","Drag","lastPosition","Event","toLowerCase","debugNodeNotFound","Blur","blur","Focus","focus","preventScroll","Click","TouchEnd","tailPositions","offsetWidth","TouchCancel","dispatchEvent","Scroll","ViewportResize","Input","input","mediaEl","volume","muted","StyleSheetRule","rules_1","parent_2","usingVirtualParent_1","styleSheet_1","StyleDeclaration","parent_3","styleSheet","mutations","WebGL2","command","canvas2DMutation","canvasMutation","warnCanvasMutationFailed","Font","fontFace","FontFace","family","buffer","fontSource","descriptors","fonts","useVirtualParent","warnNodeNotFound","realTarget","DOMException","legacy_missingNodeMap","appendNode","parentInDocument","hasIframeChild","virtualParent","createDocumentFragment","storeState","previous","previousId","nextNotInDOM","targetDoc","nextSibling","mutationInQueue_1","legacy_resolveMissingNode","resolveTrees","resolveTrees_1","debug","attributeName","removeAttribute","styleValues","targetEl","svp","svs","checked","isChecked","targetMutation","previousInMap","nextInMap","base","_x","_y","drawMouseTail","hoverElements","draw","clearRect","beginPath","moveTo","lineTo","stroke","hoveredEl","currentEl","parentElement","SkipEnd","restoreState","storeCSSRules","storedState","nodeName","idRemoved","log","u8","u16","Uint16Array","u32","Uint32Array","fleb","fdeb","clim","freb","eb","fl","revfl","fd","rev","hMap","cd","mb","co","le","rvb","sv","r_1","flt","fdt","flrm","fdrm","bits","bits16","slc","subarray","unzlibSync","out","dat","buf","st","sl","noBuf","noSt","cbuf","bl","nbuf","final","bt","lm","dm","lbt","dbt","tbts","hLit","hcLen","tl","ldt","clt","clb","clbmsk","clm","lt","dt","lms","dms","mxa","sym","dsym","inflt","zlv","raw","latin1","TextDecoder","fromCharCode","strFromU8","TextEncoder","encode","ai","strToU8"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ED+BOC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MA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.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../../node_modules/mitt/dist/mitt.es.js","../../../src/types.ts","../../../src/replay/smoothscroll.ts","../../../src/replay/timer.ts","../../../../node_modules/@xstate/fsm/es/index.js","../../../src/replay/machine.ts","../../../src/utils.ts","../../../src/replay/styles/inject-style.ts","../../../src/replay/virtual-styles.ts","../../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../../src/replay/canvas/webgl.ts","../../../src/replay/index.ts","../../../src/replay/canvas/index.ts","../../../src/replay/canvas/2d.ts","../../../../node_modules/fflate/esm/browser.js","../../../src/packer/unpack.ts","../../../src/packer/base.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type] ||\n (maskInputSelector && input.matches(maskInputSelector))) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) {\n return false;\n }\n }\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n input: n,\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","// \n// An event handler can take an optional event argument\n// and should not return a value\n \n \n\n// An array of all currently registered event handlers for a type\n \n \n// A map of event types and their corresponding event handlers.\n \n \n \n \n\n/** Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nfunction mitt(all ) {\n\tall = all || Object.create(null);\n\n\treturn {\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton: function on(type , handler ) {\n\t\t\t(all[type] || (all[type] = [])).push(handler);\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff: function off(type , handler ) {\n\t\t\tif (all[type]) {\n\t\t\t\tall[type].splice(all[type].indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * @param {String} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit: function emit(type , evt ) {\n\t\t\t(all[type] || []).slice().map(function (handler) { handler(evt); });\n\t\t\t(all['*'] || []).slice().map(function (handler) { handler(type, evt); });\n\t\t}\n\t};\n}\n\nexport default mitt;\n//# sourceMappingURL=mitt.es.js.map\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n unblockSelector?: string;\n ignoreClass?: string;\n ignoreSelector?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputSelector?: string;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n unmaskTextSelector?: string;\n unmaskInputSelector?: string;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n unblockSelector: string | null;\n ignoreClass: string;\n ignoreSelector: string | null;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'unblockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'unmaskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputSelector'\n | 'unmaskInputSelector'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","/**\n * A fork version of https://github.com/iamdustan/smoothscroll\n * Add support of customize target window and document\n */\n\n// @ts-nocheck\n// tslint:disable\nexport function polyfill(w: Window = window, d = document) {\n // return if scroll behavior is supported and polyfill is not forced\n if (\n 'scrollBehavior' in d.documentElement.style &&\n w.__forceSmoothScrollPolyfill__ !== true\n ) {\n return;\n }\n\n // globals\n var Element = w.HTMLElement || w.Element;\n var SCROLL_TIME = 468;\n\n // object gathering original scroll methods\n var original = {\n scroll: w.scroll || w.scrollTo,\n scrollBy: w.scrollBy,\n elementScroll: Element.prototype.scroll || scrollElement,\n scrollIntoView: Element.prototype.scrollIntoView,\n };\n\n // define timing method\n var now =\n w.performance && w.performance.now\n ? w.performance.now.bind(w.performance)\n : Date.now;\n\n /**\n * indicates if a the current browser is made by Microsoft\n * @method isMicrosoftBrowser\n * @param {String} userAgent\n * @returns {Boolean}\n */\n function isMicrosoftBrowser(userAgent) {\n var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];\n\n return new RegExp(userAgentPatterns.join('|')).test(userAgent);\n }\n\n /*\n * IE has rounding bug rounding down clientHeight and clientWidth and\n * rounding up scrollHeight and scrollWidth causing false positives\n * on hasScrollableSpace\n */\n var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;\n\n /**\n * changes scroll position inside an element\n * @method scrollElement\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function scrollElement(x, y) {\n this.scrollLeft = x;\n this.scrollTop = y;\n }\n\n /**\n * returns result of applying ease math function to a number\n * @method ease\n * @param {Number} k\n * @returns {Number}\n */\n function ease(k) {\n return 0.5 * (1 - Math.cos(Math.PI * k));\n }\n\n /**\n * indicates if a smooth behavior should be applied\n * @method shouldBailOut\n * @param {Number|Object} firstArg\n * @returns {Boolean}\n */\n function shouldBailOut(firstArg) {\n if (\n firstArg === null ||\n typeof firstArg !== 'object' ||\n firstArg.behavior === undefined ||\n firstArg.behavior === 'auto' ||\n firstArg.behavior === 'instant'\n ) {\n // first argument is not an object/null\n // or behavior is auto, instant or undefined\n return true;\n }\n\n if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {\n // first argument is an object and behavior is smooth\n return false;\n }\n\n // throw error when behavior is not supported\n throw new TypeError(\n 'behavior member of ScrollOptions ' +\n firstArg.behavior +\n ' is not a valid value for enumeration ScrollBehavior.',\n );\n }\n\n /**\n * indicates if an element has scrollable space in the provided axis\n * @method hasScrollableSpace\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function hasScrollableSpace(el, axis) {\n if (axis === 'Y') {\n return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;\n }\n\n if (axis === 'X') {\n return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;\n }\n }\n\n /**\n * indicates if an element has a scrollable overflow property in the axis\n * @method canOverflow\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function canOverflow(el, axis) {\n var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];\n\n return overflowValue === 'auto' || overflowValue === 'scroll';\n }\n\n /**\n * indicates if an element can be scrolled in either axis\n * @method isScrollable\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function isScrollable(el) {\n var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');\n var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');\n\n return isScrollableY || isScrollableX;\n }\n\n /**\n * finds scrollable parent of an element\n * @method findScrollableParent\n * @param {Node} el\n * @returns {Node} el\n */\n function findScrollableParent(el) {\n while (el !== d.body && isScrollable(el) === false) {\n el = el.parentNode || el.host;\n }\n\n return el;\n }\n\n /**\n * self invoked function that, given a context, steps through scrolling\n * @method step\n * @param {Object} context\n * @returns {undefined}\n */\n function step(context) {\n var time = now();\n var value;\n var currentX;\n var currentY;\n var elapsed = (time - context.startTime) / SCROLL_TIME;\n\n // avoid elapsed times higher than one\n elapsed = elapsed > 1 ? 1 : elapsed;\n\n // apply easing to elapsed time\n value = ease(elapsed);\n\n currentX = context.startX + (context.x - context.startX) * value;\n currentY = context.startY + (context.y - context.startY) * value;\n\n context.method.call(context.scrollable, currentX, currentY);\n\n // scroll more if we have not reached our destination\n if (currentX !== context.x || currentY !== context.y) {\n w.requestAnimationFrame(step.bind(w, context));\n }\n }\n\n /**\n * scrolls window or element with a smooth behavior\n * @method smoothScroll\n * @param {Object|Node} el\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function smoothScroll(el, x, y) {\n var scrollable;\n var startX;\n var startY;\n var method;\n var startTime = now();\n\n // define scroll context\n if (el === d.body) {\n scrollable = w;\n startX = w.scrollX || w.pageXOffset;\n startY = w.scrollY || w.pageYOffset;\n method = original.scroll;\n } else {\n scrollable = el;\n startX = el.scrollLeft;\n startY = el.scrollTop;\n method = scrollElement;\n }\n\n // scroll looping over a frame\n step({\n scrollable: scrollable,\n method: method,\n startTime: startTime,\n startX: startX,\n startY: startY,\n x: x,\n y: y,\n });\n }\n\n // ORIGINAL METHODS OVERRIDES\n // w.scroll and w.scrollTo\n w.scroll = w.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scroll.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : w.scrollX || w.pageXOffset,\n // use top prop, second argument if present or fallback to scrollY\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : w.scrollY || w.pageYOffset,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : w.scrollX || w.pageXOffset,\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : w.scrollY || w.pageYOffset,\n );\n };\n\n // w.scrollBy\n w.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0])) {\n original.scrollBy.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : 0,\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : 0,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n ~~arguments[0].left + (w.scrollX || w.pageXOffset),\n ~~arguments[0].top + (w.scrollY || w.pageYOffset),\n );\n };\n\n // Element.prototype.scroll and Element.prototype.scrollTo\n Element.prototype.scroll = Element.prototype.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n // if one number is passed, throw error to match Firefox implementation\n if (typeof arguments[0] === 'number' && arguments[1] === undefined) {\n throw new SyntaxError('Value could not be converted');\n }\n\n original.elementScroll.call(\n this,\n // use left prop, first number argument or fallback to scrollLeft\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : typeof arguments[0] !== 'object'\n ? ~~arguments[0]\n : this.scrollLeft,\n // use top prop, second argument or fallback to scrollTop\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : arguments[1] !== undefined\n ? ~~arguments[1]\n : this.scrollTop,\n );\n\n return;\n }\n\n var left = arguments[0].left;\n var top = arguments[0].top;\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n this,\n this,\n typeof left === 'undefined' ? this.scrollLeft : ~~left,\n typeof top === 'undefined' ? this.scrollTop : ~~top,\n );\n };\n\n // Element.prototype.scrollBy\n Element.prototype.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.elementScroll.call(\n this,\n arguments[0].left !== undefined\n ? ~~arguments[0].left + this.scrollLeft\n : ~~arguments[0] + this.scrollLeft,\n arguments[0].top !== undefined\n ? ~~arguments[0].top + this.scrollTop\n : ~~arguments[1] + this.scrollTop,\n );\n\n return;\n }\n\n this.scroll({\n left: ~~arguments[0].left + this.scrollLeft,\n top: ~~arguments[0].top + this.scrollTop,\n behavior: arguments[0].behavior,\n });\n };\n\n // Element.prototype.scrollIntoView\n Element.prototype.scrollIntoView = function () {\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scrollIntoView.call(\n this,\n arguments[0] === undefined ? true : arguments[0],\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n var scrollableParent = findScrollableParent(this);\n var parentRects = scrollableParent.getBoundingClientRect();\n var clientRects = this.getBoundingClientRect();\n\n if (scrollableParent !== d.body) {\n // reveal element inside parent\n smoothScroll.call(\n this,\n scrollableParent,\n scrollableParent.scrollLeft + clientRects.left - parentRects.left,\n scrollableParent.scrollTop + clientRects.top - parentRects.top,\n );\n\n // reveal parent in viewport unless is fixed\n if (w.getComputedStyle(scrollableParent).position !== 'fixed') {\n w.scrollBy({\n left: parentRects.left,\n top: parentRects.top,\n behavior: 'smooth',\n });\n }\n } else {\n // reveal element in viewport\n w.scrollBy({\n left: clientRects.left,\n top: clientRects.top,\n behavior: 'smooth',\n });\n }\n };\n}\n","import {\n actionWithDelay,\n eventWithTime,\n EventType,\n IncrementalSource,\n} from '../types';\n\nexport class Timer {\n public timeOffset: number = 0;\n public speed: number;\n\n private actions: actionWithDelay[];\n private raf: number | null = null;\n private liveMode: boolean;\n\n constructor(actions: actionWithDelay[] = [], speed: number) {\n this.actions = actions;\n this.speed = speed;\n }\n /**\n * Add an action after the timer starts.\n * @param action\n */\n public addAction(action: actionWithDelay) {\n const index = this.findActionIndex(action);\n this.actions.splice(index, 0, action);\n }\n /**\n * Add all actions before the timer starts\n * @param actions\n */\n public addActions(actions: actionWithDelay[]) {\n this.actions = this.actions.concat(actions);\n }\n\n public start() {\n this.timeOffset = 0;\n let lastTimestamp = performance.now();\n const { actions } = this;\n const self = this;\n function check() {\n const time = performance.now();\n self.timeOffset += (time - lastTimestamp) * self.speed;\n lastTimestamp = time;\n while (actions.length) {\n const action = actions[0];\n\n if (self.timeOffset >= action.delay) {\n actions.shift();\n action.doAction();\n } else {\n break;\n }\n }\n if (actions.length > 0 || self.liveMode) {\n self.raf = requestAnimationFrame(check);\n }\n }\n this.raf = requestAnimationFrame(check);\n }\n\n public clear() {\n if (this.raf) {\n cancelAnimationFrame(this.raf);\n this.raf = null;\n }\n this.actions.length = 0;\n }\n\n public setSpeed(speed: number) {\n this.speed = speed;\n }\n\n public toggleLiveMode(mode: boolean) {\n this.liveMode = mode;\n }\n\n public isActive() {\n return this.raf !== null;\n }\n\n private findActionIndex(action: actionWithDelay): number {\n let start = 0;\n let end = this.actions.length - 1;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (this.actions[mid].delay < action.delay) {\n start = mid + 1;\n } else if (this.actions[mid].delay > action.delay) {\n end = mid - 1;\n } else {\n // already an action with same delay (timestamp)\n // the plus one will splice the new one after the existing one\n return mid + 1;\n }\n }\n return start;\n }\n}\n\n// TODO: add speed to mouse move timestamp calculation\nexport function addDelay(event: eventWithTime, baselineTime: number): number {\n // Mouse move events was recorded in a throttle function,\n // so we need to find the real timestamp by traverse the time offsets.\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove\n ) {\n const firstOffset = event.data.positions[0].timeOffset;\n // timeOffset is a negative offset to event.timestamp\n const firstTimestamp = event.timestamp + firstOffset;\n event.delay = firstTimestamp - baselineTime;\n return firstTimestamp - baselineTime;\n }\n\n event.delay = event.timestamp - baselineTime;\n return event.delay;\n}\n","/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return{type:\"xstate.assign\",assignment:t}}function i(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){o=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]=\"function\"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o]})),r=n,!1}return!0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})))},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u=\"object\"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}export{n as InterpreterStatus,o as assign,s as createMachine,v as interpret};\n","import { createMachine, interpret, assign, StateMachine } from '@xstate/fsm';\nimport {\n playerConfig,\n eventWithTime,\n actionWithDelay,\n ReplayerEvents,\n EventType,\n Emitter,\n IncrementalSource,\n} from '../types';\nimport { Timer, addDelay } from './timer';\n\nexport type PlayerContext = {\n events: eventWithTime[];\n timer: Timer;\n timeOffset: number;\n baselineTime: number;\n lastPlayedEvent: eventWithTime | null;\n};\nexport type PlayerEvent =\n | {\n type: 'PLAY';\n payload: {\n timeOffset: number;\n };\n }\n | {\n type: 'CAST_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | { type: 'PAUSE' }\n | { type: 'TO_LIVE'; payload: { baselineTime?: number } }\n | {\n type: 'ADD_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | {\n type: 'END';\n };\nexport type PlayerState =\n | {\n value: 'playing';\n context: PlayerContext;\n }\n | {\n value: 'paused';\n context: PlayerContext;\n }\n | {\n value: 'live';\n context: PlayerContext;\n };\n\n/**\n * If the array have multiple meta and fullsnapshot events,\n * return the events from last meta to the end.\n */\nexport function discardPriorSnapshots(\n events: eventWithTime[],\n baselineTime: number,\n): eventWithTime[] {\n for (let idx = events.length - 1; idx >= 0; idx--) {\n const event = events[idx];\n if (event.type === EventType.Meta) {\n if (event.timestamp <= baselineTime) {\n return events.slice(idx);\n }\n }\n }\n return events;\n}\n\ntype PlayerAssets = {\n emitter: Emitter;\n applyEventsSynchronously(events: Array): void;\n getCastFn(event: eventWithTime, isSync: boolean): () => void;\n};\nexport function createPlayerService(\n context: PlayerContext,\n { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets,\n) {\n const playerMachine = createMachine(\n {\n id: 'player',\n context,\n initial: 'paused',\n states: {\n playing: {\n on: {\n PAUSE: {\n target: 'paused',\n actions: ['pause'],\n },\n CAST_EVENT: {\n target: 'playing',\n actions: 'castEvent',\n },\n END: {\n target: 'paused',\n actions: ['resetLastPlayedEvent', 'pause'],\n },\n ADD_EVENT: {\n target: 'playing',\n actions: ['addEvent'],\n },\n },\n },\n paused: {\n on: {\n PLAY: {\n target: 'playing',\n actions: ['recordTimeOffset', 'play'],\n },\n CAST_EVENT: {\n target: 'paused',\n actions: 'castEvent',\n },\n TO_LIVE: {\n target: 'live',\n actions: ['startLive'],\n },\n ADD_EVENT: {\n target: 'paused',\n actions: ['addEvent'],\n },\n },\n },\n live: {\n on: {\n ADD_EVENT: {\n target: 'live',\n actions: ['addEvent'],\n },\n CAST_EVENT: {\n target: 'live',\n actions: ['castEvent'],\n },\n },\n },\n },\n },\n {\n actions: {\n castEvent: assign({\n lastPlayedEvent: (ctx, event) => {\n if (event.type === 'CAST_EVENT') {\n return event.payload.event;\n }\n return ctx.lastPlayedEvent;\n },\n }),\n recordTimeOffset: assign((ctx, event) => {\n let timeOffset = ctx.timeOffset;\n if ('payload' in event && 'timeOffset' in event.payload) {\n timeOffset = event.payload.timeOffset;\n }\n return {\n ...ctx,\n timeOffset,\n baselineTime: ctx.events[0].timestamp + timeOffset,\n };\n }),\n play(ctx) {\n const { timer, events, baselineTime, lastPlayedEvent } = ctx;\n timer.clear();\n\n for (const event of events) {\n // TODO: improve this API\n addDelay(event, baselineTime);\n }\n const neededEvents = discardPriorSnapshots(events, baselineTime);\n\n let lastPlayedTimestamp = lastPlayedEvent?.timestamp;\n if (\n lastPlayedEvent?.type === EventType.IncrementalSnapshot &&\n lastPlayedEvent.data.source === IncrementalSource.MouseMove\n ) {\n lastPlayedTimestamp =\n lastPlayedEvent.timestamp +\n lastPlayedEvent.data.positions[0]?.timeOffset;\n }\n if (baselineTime < (lastPlayedTimestamp || 0)) {\n emitter.emit(ReplayerEvents.PlayBack);\n }\n\n const syncEvents = new Array();\n const actions = new Array();\n for (const event of neededEvents) {\n if (\n lastPlayedTimestamp &&\n lastPlayedTimestamp < baselineTime &&\n (event.timestamp <= lastPlayedTimestamp ||\n event === lastPlayedEvent)\n ) {\n continue;\n }\n if (event.timestamp < baselineTime) {\n syncEvents.push(event);\n } else {\n const castFn = getCastFn(event, false);\n actions.push({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n applyEventsSynchronously(syncEvents);\n emitter.emit(ReplayerEvents.Flush);\n timer.addActions(actions);\n timer.start();\n },\n pause(ctx) {\n ctx.timer.clear();\n },\n resetLastPlayedEvent: assign((ctx) => {\n return {\n ...ctx,\n lastPlayedEvent: null,\n };\n }),\n startLive: assign({\n baselineTime: (ctx, event) => {\n ctx.timer.toggleLiveMode(true);\n ctx.timer.start();\n if (event.type === 'TO_LIVE' && event.payload.baselineTime) {\n return event.payload.baselineTime;\n }\n return Date.now();\n },\n }),\n addEvent: assign((ctx, machineEvent) => {\n const { baselineTime, timer, events } = ctx;\n if (machineEvent.type === 'ADD_EVENT') {\n const { event } = machineEvent.payload;\n addDelay(event, baselineTime);\n\n let end = events.length - 1;\n if (!events[end] || events[end].timestamp <= event.timestamp) {\n // fast track\n events.push(event);\n } else {\n let insertionIndex = -1;\n let start = 0;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (events[mid].timestamp <= event.timestamp) {\n start = mid + 1;\n } else {\n end = mid - 1;\n }\n }\n if (insertionIndex === -1) {\n insertionIndex = start;\n }\n events.splice(insertionIndex, 0, event);\n }\n\n const isSync = event.timestamp < baselineTime;\n const castFn = getCastFn(event, isSync);\n if (isSync) {\n castFn();\n } else if (timer.isActive()) {\n timer.addAction({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n return { ...ctx, events };\n }),\n },\n },\n );\n return interpret(playerMachine);\n}\n\nexport type SpeedContext = {\n normalSpeed: playerConfig['speed'];\n timer: Timer;\n};\n\nexport type SpeedEvent =\n | {\n type: 'FAST_FORWARD';\n payload: { speed: playerConfig['speed'] };\n }\n | {\n type: 'BACK_TO_NORMAL';\n }\n | {\n type: 'SET_SPEED';\n payload: { speed: playerConfig['speed'] };\n };\n\nexport type SpeedState =\n | {\n value: 'normal';\n context: SpeedContext;\n }\n | {\n value: 'skipping';\n context: SpeedContext;\n };\n\nexport function createSpeedService(context: SpeedContext) {\n const speedMachine = createMachine(\n {\n id: 'speed',\n context,\n initial: 'normal',\n states: {\n normal: {\n on: {\n FAST_FORWARD: {\n target: 'skipping',\n actions: ['recordSpeed', 'setSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n skipping: {\n on: {\n BACK_TO_NORMAL: {\n target: 'normal',\n actions: ['restoreSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n },\n },\n {\n actions: {\n setSpeed: (ctx, event) => {\n if ('payload' in event) {\n ctx.timer.setSpeed(event.payload.speed);\n }\n },\n recordSpeed: assign({\n normalSpeed: (ctx) => ctx.timer.speed,\n }),\n restoreSpeed: (ctx) => {\n ctx.timer.setSpeed(ctx.normalSpeed);\n },\n },\n },\n );\n\n return interpret(speedMachine);\n}\n\nexport type PlayerMachineState = StateMachine.State<\n PlayerContext,\n PlayerEvent,\n PlayerState\n>;\n\nexport type SpeedMachineState = StateMachine.State<\n SpeedContext,\n SpeedEvent,\n SpeedState\n>;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","const rules: (blockClass: string) => string[] = (blockClass: string) => [\n `.${blockClass} { background: currentColor }`,\n 'noscript { display: none !important; }',\n];\n\nexport default rules;\n","import { INode } from 'rrweb-snapshot';\n\nexport enum StyleRuleType {\n Insert,\n Remove,\n Snapshot,\n SetProperty,\n RemoveProperty,\n}\n\ntype InsertRule = {\n cssText: string;\n type: StyleRuleType.Insert;\n index?: number | number[];\n};\ntype RemoveRule = {\n type: StyleRuleType.Remove;\n index: number | number[];\n};\ntype SnapshotRule = {\n type: StyleRuleType.Snapshot;\n cssTexts: string[];\n};\ntype SetPropertyRule = {\n type: StyleRuleType.SetProperty;\n index: number[];\n property: string;\n value: string | null;\n priority: string | undefined;\n};\ntype RemovePropertyRule = {\n type: StyleRuleType.RemoveProperty;\n index: number[];\n property: string;\n};\n\nexport type VirtualStyleRules = Array<\n InsertRule | RemoveRule | SnapshotRule | SetPropertyRule | RemovePropertyRule\n>;\nexport type VirtualStyleRulesMap = Map;\n\nexport function getNestedRule(\n rules: CSSRuleList,\n position: number[],\n): CSSGroupingRule {\n const rule = rules[position[0]] as CSSGroupingRule;\n if (position.length === 1) {\n return rule;\n } else {\n return getNestedRule(\n ((rule as CSSGroupingRule).cssRules[position[1]] as CSSGroupingRule)\n .cssRules,\n position.slice(2),\n );\n }\n}\n\nexport function getPositionsAndIndex(nestedIndex: number[]) {\n const positions = [...nestedIndex];\n const index = positions.pop();\n return { positions, index };\n}\n\nexport function applyVirtualStyleRulesToNode(\n storedRules: VirtualStyleRules,\n styleNode: HTMLStyleElement,\n) {\n const { sheet } = styleNode;\n if (!sheet) {\n // styleNode without sheet means the DOM has been removed\n // so the rules no longer need to be applied\n return;\n }\n\n storedRules.forEach((rule) => {\n if (rule.type === StyleRuleType.Insert) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.insertRule(rule.cssText, index);\n } else {\n sheet.insertRule(rule.cssText, rule.index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n } else if (rule.type === StyleRuleType.Remove) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.deleteRule(index || 0);\n } else {\n sheet.deleteRule(rule.index);\n }\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else if (rule.type === StyleRuleType.Snapshot) {\n restoreSnapshotOfStyleRulesToNode(rule.cssTexts, styleNode);\n } else if (rule.type === StyleRuleType.SetProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.setProperty(rule.property, rule.value, rule.priority);\n } else if (rule.type === StyleRuleType.RemoveProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.removeProperty(rule.property);\n }\n });\n}\n\nfunction restoreSnapshotOfStyleRulesToNode(\n cssTexts: string[],\n styleNode: HTMLStyleElement,\n) {\n try {\n const existingRules = Array.from(styleNode.sheet?.cssRules || []).map(\n (rule) => rule.cssText,\n );\n const existingRulesReversed = Object.entries(existingRules).reverse();\n let lastMatch = existingRules.length;\n existingRulesReversed.forEach(([index, rule]) => {\n const indexOf = cssTexts.indexOf(rule);\n if (indexOf === -1 || indexOf > lastMatch) {\n try {\n styleNode.sheet?.deleteRule(Number(index));\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n }\n lastMatch = indexOf;\n });\n cssTexts.forEach((cssText, index) => {\n try {\n if (styleNode.sheet?.cssRules[index]?.cssText !== cssText) {\n styleNode.sheet?.insertRule(cssText, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n });\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n\nexport function storeCSSRules(\n parentElement: HTMLStyleElement,\n virtualStyleRulesMap: VirtualStyleRulesMap,\n) {\n try {\n const cssTexts = Array.from(\n (parentElement as HTMLStyleElement).sheet?.cssRules || [],\n ).map((rule) => rule.cssText);\n virtualStyleRulesMap.set((parentElement as unknown) as INode, [\n {\n type: StyleRuleType.Snapshot,\n cssTexts,\n },\n ]);\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { decode } from 'base64-arraybuffer';\nimport { Replayer } from '../';\nimport {\n CanvasContext,\n canvasMutationCommand,\n SerializedWebGlArg,\n} from '../../types';\n\n// TODO: add ability to wipe this list\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nfunction getContext(\n target: HTMLCanvasElement,\n type: CanvasContext,\n): WebGLRenderingContext | WebGL2RenderingContext | null {\n // Note to whomever is going to implement support for `contextAttributes`:\n // if `preserveDrawingBuffer` is set to true,\n // you might have to do `ctx.flush()` before every webgl canvas event\n try {\n if (type === CanvasContext.WebGL) {\n return (\n target.getContext('webgl')! || target.getContext('experimental-webgl')\n );\n }\n return target.getContext('webgl2')!;\n } catch (e) {\n return null;\n }\n}\n\nconst WebGLVariableConstructorsNames = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n];\n\nfunction saveToWebGLVarMap(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n result: any,\n) {\n if (!result?.constructor) return; // probably null or undefined\n\n const { name } = result.constructor;\n if (!WebGLVariableConstructorsNames.includes(name)) return; // not a WebGL variable\n\n const variables = variableListFor(ctx, name);\n if (!variables.includes(result)) variables.push(result);\n}\n\nexport function deserializeArg(\n imageMap: Replayer['imageMap'],\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n): (arg: SerializedWebGlArg) => any {\n return (arg: SerializedWebGlArg): any => {\n if (arg && typeof arg === 'object' && 'rr_type' in arg) {\n if ('index' in arg) {\n const { rr_type: name, index } = arg;\n return variableListFor(ctx, name)[index];\n } else if ('args' in arg) {\n const { rr_type: name, args } = arg;\n const ctor = window[name as keyof Window];\n\n return new ctor(...args.map(deserializeArg(imageMap, ctx)));\n } else if ('base64' in arg) {\n return decode(arg.base64);\n } else if ('src' in arg) {\n const image = imageMap.get(arg.src);\n if (image) {\n return image;\n } else {\n const image = new Image();\n image.src = arg.src;\n imageMap.set(arg.src, image);\n return image;\n }\n }\n } else if (Array.isArray(arg)) {\n return arg.map(deserializeArg(imageMap, ctx));\n }\n return arg;\n };\n}\n\nexport default function webglMutation({\n mutation,\n target,\n type,\n imageMap,\n errorHandler,\n}: {\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n type: CanvasContext;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = getContext(target, type);\n if (!ctx) return;\n\n // NOTE: if `preserveDrawingBuffer` is set to true,\n // we must flush the buffers on every new canvas event\n // if (mutation.newFrame) ctx.flush();\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n const args = mutation.args.map(deserializeArg(imageMap, ctx));\n const result = original.apply(ctx, args);\n saveToWebGLVarMap(ctx, result);\n\n // Slows down replay considerably, only use for debugging\n const debugMode = false;\n if (debugMode) {\n if (mutation.property === 'compileShader') {\n if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getShaderInfoLog(args[0]),\n );\n } else if (mutation.property === 'linkProgram') {\n ctx.validateProgram(args[0]);\n if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getProgramInfoLog(args[0]),\n );\n }\n const webglError = ctx.getError();\n if (webglError !== ctx.NO_ERROR) {\n console.warn(\n 'WEBGL ERROR',\n webglError,\n 'on command:',\n mutation.property,\n ...args,\n );\n }\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import {\n rebuild,\n buildNodeWithSN,\n INode,\n NodeType,\n BuildCache,\n createCache,\n} from 'rrweb-snapshot';\nimport * as mittProxy from 'mitt';\nimport { polyfill as smoothscrollPolyfill } from './smoothscroll';\nimport { Timer } from './timer';\nimport { createPlayerService, createSpeedService } from './machine';\nimport {\n EventType,\n IncrementalSource,\n fullSnapshotEvent,\n eventWithTime,\n MouseInteractions,\n playerConfig,\n playerMetaData,\n viewportResizeDimension,\n missingNodeMap,\n addedNodeMutation,\n missingNode,\n incrementalSnapshotEvent,\n incrementalData,\n ReplayerEvents,\n Handler,\n Emitter,\n MediaInteractions,\n metaEvent,\n mutationData,\n scrollData,\n inputData,\n canvasMutationData,\n Mirror,\n ElementState,\n styleAttributeValue,\n styleValueWithPriority,\n mouseMovePos,\n IWindow,\n canvasMutationCommand,\n textMutation,\n} from '../types';\nimport {\n createMirror,\n polyfill,\n TreeIndex,\n queueToResolveTrees,\n iterateResolveTree,\n AppendedIframe,\n isIframeINode,\n getBaseDimension,\n hasShadowRoot,\n} from '../utils';\nimport getInjectStyleRules from './styles/inject-style';\nimport './styles/style.css';\nimport {\n applyVirtualStyleRulesToNode,\n storeCSSRules,\n StyleRuleType,\n VirtualStyleRules,\n VirtualStyleRulesMap,\n getNestedRule,\n getPositionsAndIndex,\n} from './virtual-styles';\nimport canvasMutation from './canvas';\n\nconst SKIP_TIME_THRESHOLD = 10 * 1000;\nconst SKIP_TIME_INTERVAL = 5 * 1000;\n\n// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734\n// tslint:disable-next-line\nconst mitt = (mittProxy as any).default || mittProxy;\n\nconst REPLAY_CONSOLE_PREFIX = '[replayer]';\n\nconst defaultMouseTailConfig = {\n duration: 500,\n lineCap: 'round',\n lineWidth: 3,\n strokeStyle: 'red',\n} as const;\n\nfunction indicatesTouchDevice(e: eventWithTime) {\n return (\n e.type == EventType.IncrementalSnapshot &&\n (e.data.source == IncrementalSource.TouchMove ||\n (e.data.source == IncrementalSource.MouseInteraction &&\n e.data.type == MouseInteractions.TouchStart))\n );\n}\n\nexport class Replayer {\n public wrapper: HTMLDivElement;\n public iframe: HTMLIFrameElement;\n\n public service: ReturnType;\n public speedService: ReturnType;\n public get timer() {\n return this.service.state.context.timer;\n }\n\n public config: playerConfig;\n\n private mouse: HTMLDivElement;\n private mouseTail: HTMLCanvasElement | null = null;\n private tailPositions: Array<{ x: number; y: number }> = [];\n\n private emitter: Emitter = mitt();\n\n private nextUserInteractionEvent: eventWithTime | null;\n\n // tslint:disable-next-line: variable-name\n private legacy_missingNodeRetryMap: missingNodeMap = {};\n\n private treeIndex!: TreeIndex;\n private fragmentParentMap!: Map;\n private elementStateMap!: Map;\n // Hold the list of CSSRules for in-memory state restoration\n private virtualStyleRulesMap!: VirtualStyleRulesMap;\n\n // The replayer uses the cache to speed up replay and scrubbing.\n private cache: BuildCache = createCache();\n\n private imageMap: Map = new Map();\n\n private mirror: Mirror = createMirror();\n\n private firstFullSnapshot: eventWithTime | true | null = null;\n\n private newDocumentQueue: addedNodeMutation[] = [];\n\n private mousePos: mouseMovePos | null = null;\n private touchActive: boolean | null = null;\n\n constructor(\n events: Array,\n config?: Partial,\n ) {\n if (!config?.liveMode && events.length < 2) {\n throw new Error('Replayer need at least 2 events.');\n }\n const defaultConfig: playerConfig = {\n speed: 1,\n maxSpeed: 360,\n root: document.body,\n loadTimeout: 0,\n skipInactive: false,\n showWarning: true,\n showDebug: false,\n blockClass: 'rr-block',\n liveMode: false,\n insertStyleRules: [],\n triggerFocus: true,\n UNSAFE_replayCanvas: false,\n pauseAnimation: true,\n mouseTail: defaultMouseTailConfig,\n };\n this.config = Object.assign({}, defaultConfig, config);\n\n this.handleResize = this.handleResize.bind(this);\n this.getCastFn = this.getCastFn.bind(this);\n this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);\n this.emitter.on(ReplayerEvents.Resize, this.handleResize as Handler);\n\n this.setupDom();\n\n this.treeIndex = new TreeIndex();\n this.fragmentParentMap = new Map();\n this.elementStateMap = new Map();\n this.virtualStyleRulesMap = new Map();\n\n this.emitter.on(ReplayerEvents.Flush, () => {\n const { scrollMap, inputMap, mutationData } = this.treeIndex.flush();\n\n this.fragmentParentMap.forEach((parent, frag) =>\n this.restoreRealParent(frag, parent),\n );\n // apply text needs to happen before virtual style rules gets applied\n // as it can overwrite the contents of a stylesheet\n for (const d of mutationData.texts) {\n this.applyText(d, mutationData);\n }\n\n for (const node of this.virtualStyleRulesMap.keys()) {\n // restore css rules of style elements after they are mounted\n this.restoreNodeSheet(node);\n }\n this.fragmentParentMap.clear();\n this.elementStateMap.clear();\n this.virtualStyleRulesMap.clear();\n\n for (const d of scrollMap.values()) {\n this.applyScroll(d, true);\n }\n for (const d of inputMap.values()) {\n this.applyInput(d);\n }\n });\n this.emitter.on(ReplayerEvents.PlayBack, () => {\n this.firstFullSnapshot = null;\n this.mirror.reset();\n });\n\n const timer = new Timer([], config?.speed || defaultConfig.speed);\n this.service = createPlayerService(\n {\n events: events\n .map((e) => {\n if (config && config.unpackFn) {\n return config.unpackFn(e as string);\n }\n return e as eventWithTime;\n })\n .sort((a1, a2) => a1.timestamp - a2.timestamp),\n timer,\n timeOffset: 0,\n baselineTime: 0,\n lastPlayedEvent: null,\n },\n {\n getCastFn: this.getCastFn,\n applyEventsSynchronously: this.applyEventsSynchronously,\n emitter: this.emitter,\n },\n );\n this.service.start();\n this.service.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n player: state,\n });\n });\n this.speedService = createSpeedService({\n normalSpeed: -1,\n timer,\n });\n this.speedService.start();\n this.speedService.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n speed: state,\n });\n });\n\n // rebuild first full snapshot as the poster of the player\n // maybe we can cache it for performance optimization\n const firstMeta = this.service.state.context.events.find(\n (e) => e.type === EventType.Meta,\n );\n const firstFullsnapshot = this.service.state.context.events.find(\n (e) => e.type === EventType.FullSnapshot,\n );\n if (firstMeta) {\n const { width, height } = firstMeta.data as metaEvent['data'];\n setTimeout(() => {\n this.emitter.emit(ReplayerEvents.Resize, {\n width,\n height,\n });\n }, 0);\n }\n if (firstFullsnapshot) {\n setTimeout(() => {\n // when something has been played, there is no need to rebuild poster\n if (this.firstFullSnapshot) {\n // true if any other fullSnapshot has been executed by Timer already\n return;\n }\n this.firstFullSnapshot = firstFullsnapshot;\n this.rebuildFullSnapshot(\n firstFullsnapshot as fullSnapshotEvent & { timestamp: number },\n );\n this.iframe.contentWindow!.scrollTo(\n (firstFullsnapshot as fullSnapshotEvent).data.initialOffset,\n );\n }, 1);\n }\n if (this.service.state.context.events.find(indicatesTouchDevice)) {\n this.mouse.classList.add('touch-device');\n }\n }\n\n public on(event: string, handler: Handler) {\n this.emitter.on(event, handler);\n return this;\n }\n\n public off(event: string, handler: Handler) {\n this.emitter.off(event, handler);\n return this;\n }\n\n public setConfig(config: Partial) {\n Object.keys(config).forEach((key) => {\n // @ts-ignore\n this.config[key] = config[key];\n });\n if (!this.config.skipInactive) {\n this.backToNormal();\n }\n if (typeof config.speed !== 'undefined') {\n this.speedService.send({\n type: 'SET_SPEED',\n payload: {\n speed: config.speed!,\n },\n });\n }\n if (typeof config.mouseTail !== 'undefined') {\n if (config.mouseTail === false) {\n if (this.mouseTail) {\n this.mouseTail.style.display = 'none';\n }\n } else {\n if (!this.mouseTail) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.width = Number.parseFloat(this.iframe.width);\n this.mouseTail.height = Number.parseFloat(this.iframe.height);\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.wrapper.insertBefore(this.mouseTail, this.iframe);\n }\n this.mouseTail.style.display = 'inherit';\n }\n }\n }\n\n public getMetaData(): playerMetaData {\n const firstEvent = this.service.state.context.events[0];\n const lastEvent = this.service.state.context.events[\n this.service.state.context.events.length - 1\n ];\n return {\n startTime: firstEvent.timestamp,\n endTime: lastEvent.timestamp,\n totalTime: lastEvent.timestamp - firstEvent.timestamp,\n };\n }\n\n public getCurrentTime(): number {\n return this.timer.timeOffset + this.getTimeOffset();\n }\n\n public getTimeOffset(): number {\n const { baselineTime, events } = this.service.state.context;\n return baselineTime - events[0].timestamp;\n }\n\n public getMirror(): Mirror {\n return this.mirror;\n }\n\n /**\n * This API was designed to be used as play at any time offset.\n * Since we minimized the data collected from recorder, we do not\n * have the ability of undo an event.\n * So the implementation of play at any time offset will always iterate\n * all of the events, cast event before the offset synchronously\n * and cast event after the offset asynchronously with timer.\n * @param timeOffset number\n */\n public play(timeOffset = 0) {\n if (this.service.state.matches('paused')) {\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n } else {\n this.service.send({ type: 'PAUSE' });\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.remove('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Start);\n }\n\n public pause(timeOffset?: number) {\n if (timeOffset === undefined && this.service.state.matches('playing')) {\n this.service.send({ type: 'PAUSE' });\n }\n if (typeof timeOffset === 'number') {\n this.play(timeOffset);\n this.service.send({ type: 'PAUSE' });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Pause);\n }\n\n public resume(timeOffset = 0) {\n console.warn(\n `The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.`,\n );\n this.play(timeOffset);\n this.emitter.emit(ReplayerEvents.Resume);\n }\n\n public startLive(baselineTime?: number) {\n this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });\n }\n\n public addEvent(rawEvent: eventWithTime | string) {\n const event = this.config.unpackFn\n ? this.config.unpackFn(rawEvent as string)\n : (rawEvent as eventWithTime);\n if (indicatesTouchDevice(event)) {\n this.mouse.classList.add('touch-device');\n }\n Promise.resolve().then(() =>\n this.service.send({ type: 'ADD_EVENT', payload: { event } }),\n );\n }\n\n public enableInteract() {\n this.iframe.setAttribute('scrolling', 'auto');\n this.iframe.style.pointerEvents = 'auto';\n }\n\n public disableInteract() {\n this.iframe.setAttribute('scrolling', 'no');\n this.iframe.style.pointerEvents = 'none';\n }\n\n /**\n * Empties the replayer's cache and reclaims memory.\n * The replayer will use this cache to speed up the playback.\n */\n public resetCache() {\n this.cache = createCache();\n }\n\n private setupDom() {\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add('replayer-wrapper');\n this.config.root!.appendChild(this.wrapper);\n\n this.mouse = document.createElement('div');\n this.mouse.classList.add('replayer-mouse');\n this.wrapper.appendChild(this.mouse);\n\n if (this.config.mouseTail !== false) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.mouseTail.style.display = 'inherit';\n this.wrapper.appendChild(this.mouseTail);\n }\n\n this.iframe = document.createElement('iframe');\n const attributes = ['allow-same-origin'];\n if (this.config.UNSAFE_replayCanvas) {\n attributes.push('allow-scripts');\n }\n // hide iframe before first meta event\n this.iframe.style.display = 'none';\n this.iframe.setAttribute('sandbox', attributes.join(' '));\n this.disableInteract();\n this.wrapper.appendChild(this.iframe);\n if (this.iframe.contentWindow && this.iframe.contentDocument) {\n smoothscrollPolyfill(\n this.iframe.contentWindow,\n this.iframe.contentDocument,\n );\n\n polyfill(this.iframe.contentWindow as IWindow);\n }\n }\n\n private handleResize(dimension: viewportResizeDimension) {\n this.iframe.style.display = 'inherit';\n for (const el of [this.mouseTail, this.iframe]) {\n if (!el) {\n continue;\n }\n el.setAttribute('width', String(dimension.width));\n el.setAttribute('height', String(dimension.height));\n }\n }\n\n private applyEventsSynchronously(events: Array) {\n for (const event of events) {\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n case EventType.Custom:\n continue;\n case EventType.FullSnapshot:\n case EventType.Meta:\n case EventType.Plugin:\n break;\n case EventType.IncrementalSnapshot:\n switch (event.data.source) {\n case IncrementalSource.MediaInteraction:\n continue;\n default:\n break;\n }\n break;\n default:\n break;\n }\n const castFn = this.getCastFn(event, true);\n castFn();\n }\n if (this.mousePos) {\n this.moveAndHover(\n this.mousePos.x,\n this.mousePos.y,\n this.mousePos.id,\n true,\n this.mousePos.debugData,\n );\n }\n this.mousePos = null;\n if (this.touchActive === true) {\n this.mouse.classList.add('touch-active');\n } else if (this.touchActive === false) {\n this.mouse.classList.remove('touch-active');\n }\n this.touchActive = null;\n }\n\n private getCastFn(event: eventWithTime, isSync = false) {\n let castFn: undefined | (() => void);\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n break;\n case EventType.Custom:\n castFn = () => {\n /**\n * emit custom-event and pass the event object.\n *\n * This will add more value to the custom event and allows the client to react for custom-event.\n */\n this.emitter.emit(ReplayerEvents.CustomEvent, event);\n };\n break;\n case EventType.Meta:\n castFn = () =>\n this.emitter.emit(ReplayerEvents.Resize, {\n width: event.data.width,\n height: event.data.height,\n });\n break;\n case EventType.FullSnapshot:\n castFn = () => {\n if (this.firstFullSnapshot) {\n if (this.firstFullSnapshot === event) {\n // we've already built this exact FullSnapshot when the player was mounted, and haven't built any other FullSnapshot since\n this.firstFullSnapshot = true; // forget as we might need to re-execute this FullSnapshot later e.g. to rebuild after scrubbing\n return;\n }\n } else {\n // Timer (requestAnimationFrame) can be faster than setTimeout(..., 1)\n this.firstFullSnapshot = true;\n }\n this.rebuildFullSnapshot(event, isSync);\n this.iframe.contentWindow!.scrollTo(event.data.initialOffset);\n };\n break;\n case EventType.IncrementalSnapshot:\n castFn = () => {\n this.applyIncremental(event, isSync);\n if (isSync) {\n // do not check skip in sync\n return;\n }\n if (event === this.nextUserInteractionEvent) {\n this.nextUserInteractionEvent = null;\n this.backToNormal();\n }\n if (this.config.skipInactive && !this.nextUserInteractionEvent) {\n for (const _event of this.service.state.context.events) {\n if (_event.timestamp! <= event.timestamp!) {\n continue;\n }\n if (this.isUserInteraction(_event)) {\n if (\n _event.delay! - event.delay! >\n SKIP_TIME_THRESHOLD *\n this.speedService.state.context.timer.speed\n ) {\n this.nextUserInteractionEvent = _event;\n }\n break;\n }\n }\n if (this.nextUserInteractionEvent) {\n const skipTime =\n this.nextUserInteractionEvent.delay! - event.delay!;\n const payload = {\n speed: Math.min(\n Math.round(skipTime / SKIP_TIME_INTERVAL),\n this.config.maxSpeed,\n ),\n };\n this.speedService.send({ type: 'FAST_FORWARD', payload });\n this.emitter.emit(ReplayerEvents.SkipStart, payload);\n }\n }\n };\n break;\n default:\n }\n const wrappedCastFn = () => {\n if (castFn) {\n castFn();\n }\n\n for (const plugin of this.config.plugins || []) {\n plugin.handler(event, isSync, { replayer: this });\n }\n\n this.service.send({ type: 'CAST_EVENT', payload: { event } });\n\n // events are kept sorted by timestamp, check if this is the last event\n let last_index = this.service.state.context.events.length - 1;\n if (event === this.service.state.context.events[last_index]) {\n const finish = () => {\n if (last_index < this.service.state.context.events.length - 1) {\n // more events have been added since the setTimeout\n return;\n }\n this.backToNormal();\n this.service.send('END');\n this.emitter.emit(ReplayerEvents.Finish);\n };\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove &&\n event.data.positions.length\n ) {\n // defer finish event if the last event is a mouse move\n setTimeout(() => {\n finish();\n }, Math.max(0, -event.data.positions[0].timeOffset + 50)); // Add 50 to make sure the timer would check the last mousemove event. Otherwise, the timer may be stopped by the service before checking the last event.\n } else {\n finish();\n }\n }\n\n this.emitter.emit(ReplayerEvents.EventCast, event);\n };\n return wrappedCastFn;\n }\n\n private rebuildFullSnapshot(\n event: fullSnapshotEvent & { timestamp: number },\n isSync: boolean = false,\n ) {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n console.warn(\n 'Found unresolved missing node map',\n this.legacy_missingNodeRetryMap,\n );\n }\n this.legacy_missingNodeRetryMap = {};\n const collected: AppendedIframe[] = [];\n this.mirror.map = rebuild(event.data.node, {\n doc: this.iframe.contentDocument,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n },\n cache: this.cache,\n })[1];\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n const { documentElement, head } = this.iframe.contentDocument;\n this.insertStyleRules(documentElement, head);\n if (!this.service.state.matches('playing')) {\n this.iframe.contentDocument\n .getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n }\n this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);\n if (!isSync) {\n this.waitForStylesheetLoad();\n }\n if (this.config.UNSAFE_replayCanvas) {\n this.preloadAllImages();\n }\n }\n\n private insertStyleRules(\n documentElement: HTMLElement,\n head: HTMLHeadElement,\n ) {\n const styleEl = document.createElement('style');\n documentElement!.insertBefore(styleEl, head);\n const injectStylesRules = getInjectStyleRules(\n this.config.blockClass,\n ).concat(this.config.insertStyleRules);\n if (this.config.pauseAnimation) {\n injectStylesRules.push(\n 'html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }',\n );\n }\n for (let idx = 0; idx < injectStylesRules.length; idx++) {\n (styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);\n }\n }\n\n private attachDocumentToIframe(\n mutation: addedNodeMutation,\n iframeEl: HTMLIFrameElement,\n ) {\n const collected: AppendedIframe[] = [];\n // If iframeEl is detached from dom, iframeEl.contentDocument is null.\n if (!iframeEl.contentDocument) {\n let parent = iframeEl.parentNode;\n while (parent) {\n // The parent of iframeEl is virtual parent and we need to mount it on the dom.\n if (this.fragmentParentMap.has((parent as unknown) as INode)) {\n const frag = (parent as unknown) as INode;\n const realParent = this.fragmentParentMap.get(frag)!;\n this.restoreRealParent(frag, realParent);\n break;\n }\n parent = parent.parentNode;\n }\n }\n buildNodeWithSN(mutation.node, {\n doc: iframeEl.contentDocument!,\n map: this.mirror.map,\n hackCss: true,\n skipChild: false,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n if (\n builtNode.__sn.type === NodeType.Element &&\n builtNode.__sn.tagName.toUpperCase() === 'HTML'\n ) {\n const { documentElement, head } = iframeEl.contentDocument!;\n this.insertStyleRules(documentElement, head);\n }\n },\n cache: this.cache,\n });\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n private collectIframeAndAttachDocument(\n collected: AppendedIframe[],\n builtNode: INode,\n ) {\n if (isIframeINode(builtNode)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === builtNode.__sn.id,\n );\n if (mutationInQueue) {\n collected.push({ mutationInQueue, builtNode });\n }\n }\n }\n\n /**\n * pause when loading style sheet, resume when loaded all timeout exceed\n */\n private waitForStylesheetLoad() {\n const head = this.iframe.contentDocument?.head;\n if (head) {\n const unloadSheets: Set = new Set();\n let timer: ReturnType | -1;\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n const unsubscribe = () => {\n this.emitter.off(ReplayerEvents.Start, stateHandler);\n this.emitter.off(ReplayerEvents.Pause, stateHandler);\n };\n head\n .querySelectorAll('link[rel=\"stylesheet\"]')\n .forEach((css: HTMLLinkElement) => {\n if (!css.sheet) {\n unloadSheets.add(css);\n css.addEventListener('load', () => {\n unloadSheets.delete(css);\n // all loaded and timer not released yet\n if (unloadSheets.size === 0 && timer !== -1) {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);\n if (timer) {\n clearTimeout(timer);\n }\n unsubscribe();\n }\n });\n }\n });\n\n if (unloadSheets.size > 0) {\n // find some unload sheets after iterate\n this.service.send({ type: 'PAUSE' });\n this.emitter.emit(ReplayerEvents.LoadStylesheetStart);\n timer = setTimeout(() => {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n // mark timer was called\n timer = -1;\n unsubscribe();\n }, this.config.loadTimeout);\n }\n }\n }\n\n private hasImageArg(args: any[]): boolean {\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n if (this.hasImageArg(arg.args)) return true;\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n return true; // has image!\n } else if (arg instanceof Array) {\n if (this.hasImageArg(arg)) return true;\n }\n }\n return false;\n }\n\n private getImageArgs(args: any[]): string[] {\n const images: string[] = [];\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n images.push(...this.getImageArgs(arg.args));\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n images.push(arg.src);\n } else if (arg instanceof Array) {\n images.push(...this.getImageArgs(arg));\n }\n }\n return images;\n }\n\n /**\n * pause when there are some canvas drawImage args need to be loaded\n */\n private preloadAllImages() {\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n for (const event of this.service.state.context.events) {\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.CanvasMutation\n )\n if ('commands' in event.data) {\n event.data.commands.forEach((c) => this.preloadImages(c, event));\n } else {\n this.preloadImages(event.data, event);\n }\n }\n }\n\n private preloadImages(data: canvasMutationCommand, event: eventWithTime) {\n if (\n data.property === 'drawImage' &&\n typeof data.args[0] === 'string' &&\n !this.imageMap.has(event)\n ) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const imgd = ctx?.createImageData(canvas.width, canvas.height);\n let d = imgd?.data;\n d = JSON.parse(data.args[0]);\n ctx?.putImageData(imgd!, 0, 0);\n } else if (this.hasImageArg(data.args)) {\n this.getImageArgs(data.args).forEach((url) => {\n const image = new Image();\n image.src = url; // this preloads the image\n this.imageMap.set(url, image);\n });\n }\n }\n\n private applyIncremental(\n e: incrementalSnapshotEvent & { timestamp: number; delay?: number },\n isSync: boolean,\n ) {\n const { data: d } = e;\n switch (d.source) {\n case IncrementalSource.Mutation: {\n if (isSync) {\n d.adds.forEach((m) => this.treeIndex.add(m));\n d.texts.forEach((m) => {\n const target = this.mirror.getNode(m.id);\n const parent = (target?.parentNode as unknown) as INode | null;\n // remove any style rules that pending\n // for stylesheets where the contents get replaced\n if (parent && this.virtualStyleRulesMap.has(parent))\n this.virtualStyleRulesMap.delete(parent);\n\n this.treeIndex.text(m);\n });\n d.attributes.forEach((m) => this.treeIndex.attribute(m));\n d.removes.forEach((m) => this.treeIndex.remove(m, this.mirror));\n }\n try {\n this.applyMutation(d, isSync);\n } catch (error) {\n this.warn(`Exception in mutation ${error.message || error}`, d);\n }\n break;\n }\n case IncrementalSource.Drag:\n case IncrementalSource.TouchMove:\n case IncrementalSource.MouseMove:\n if (isSync) {\n const lastPosition = d.positions[d.positions.length - 1];\n this.mousePos = {\n x: lastPosition.x,\n y: lastPosition.y,\n id: lastPosition.id,\n debugData: d,\n };\n } else {\n d.positions.forEach((p) => {\n const action = {\n doAction: () => {\n this.moveAndHover(p.x, p.y, p.id, isSync, d);\n },\n delay:\n p.timeOffset +\n e.timestamp -\n this.service.state.context.baselineTime,\n };\n this.timer.addAction(action);\n });\n // add a dummy action to keep timer alive\n this.timer.addAction({\n doAction() {},\n delay: e.delay! - d.positions[0]?.timeOffset,\n });\n }\n break;\n case IncrementalSource.MouseInteraction: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n const event = new Event(MouseInteractions[d.type].toLowerCase());\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n this.emitter.emit(ReplayerEvents.MouseInteraction, {\n type: d.type,\n target,\n });\n const { triggerFocus } = this.config;\n switch (d.type) {\n case MouseInteractions.Blur:\n if ('blur' in ((target as Node) as HTMLElement)) {\n ((target as Node) as HTMLElement).blur();\n }\n break;\n case MouseInteractions.Focus:\n if (triggerFocus && ((target as Node) as HTMLElement).focus) {\n ((target as Node) as HTMLElement).focus({\n preventScroll: true,\n });\n }\n break;\n case MouseInteractions.Click:\n case MouseInteractions.TouchStart:\n case MouseInteractions.TouchEnd:\n if (isSync) {\n if (d.type === MouseInteractions.TouchStart) {\n this.touchActive = true;\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.touchActive = false;\n }\n this.mousePos = {\n x: d.x,\n y: d.y,\n id: d.id,\n debugData: d,\n };\n } else {\n if (d.type === MouseInteractions.TouchStart) {\n // don't draw a trail as user has lifted finger and is placing at a new point\n this.tailPositions.length = 0;\n }\n this.moveAndHover(d.x, d.y, d.id, isSync, d);\n if (d.type === MouseInteractions.Click) {\n /*\n * don't want target.click() here as could trigger an iframe navigation\n * instead any effects of the click should already be covered by mutations\n */\n /*\n * removal and addition of .active class (along with void line to trigger repaint)\n * triggers the 'click' css animation in styles/style.css\n */\n this.mouse.classList.remove('active');\n // tslint:disable-next-line\n void this.mouse.offsetWidth;\n this.mouse.classList.add('active');\n } else if (d.type === MouseInteractions.TouchStart) {\n void this.mouse.offsetWidth; // needed for the position update of moveAndHover to apply without the .touch-active transition\n this.mouse.classList.add('touch-active');\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.mouse.classList.remove('touch-active');\n }\n }\n break;\n case MouseInteractions.TouchCancel:\n if (isSync) {\n this.touchActive = false;\n } else {\n this.mouse.classList.remove('touch-active');\n }\n break;\n default:\n target.dispatchEvent(event);\n }\n break;\n }\n case IncrementalSource.Scroll: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.scroll(d);\n break;\n }\n this.applyScroll(d, false);\n break;\n }\n case IncrementalSource.ViewportResize:\n this.emitter.emit(ReplayerEvents.Resize, {\n width: d.width,\n height: d.height,\n });\n break;\n case IncrementalSource.Input: {\n /**\n * Input event on an unserialized node usually means the event\n * was synchrony triggered programmatically after the node was\n * created. This means there was not an user observable interaction\n * and we do not need to replay it.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.input(d);\n break;\n }\n this.applyInput(d);\n break;\n }\n case IncrementalSource.MediaInteraction: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n const mediaEl = (target as Node) as HTMLMediaElement;\n try {\n if (d.currentTime) {\n mediaEl.currentTime = d.currentTime;\n }\n if (d.volume) {\n mediaEl.volume = d.volume;\n }\n if (d.muted) {\n mediaEl.muted = d.muted;\n }\n if (d.type === MediaInteractions.Pause) {\n mediaEl.pause();\n }\n if (d.type === MediaInteractions.Play) {\n // remove listener for 'canplay' event because play() is async and returns a promise\n // i.e. media will evntualy start to play when data is loaded\n // 'canplay' event fires even when currentTime attribute changes which may lead to\n // unexpeted behavior\n mediaEl.play();\n }\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n `Failed to replay media interactions: ${error.message || error}`,\n );\n }\n }\n break;\n }\n case IncrementalSource.StyleSheetRule: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n /**\n * Always use existing DOM node, when it's there.\n * In in-memory replay, there is virtual node, but it's `sheet` is inaccessible.\n * Hence, we buffer all style changes in virtualStyleRulesMap.\n */\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules;\n\n if (!styleSheet) {\n /**\n * styleEl.sheet is only accessible if the styleEl is part of the\n * dom. This doesn't work on DocumentFragments so we have to add the\n * style mutations to the virtualStyleRulesMap.\n */\n\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.adds) {\n d.adds.forEach(({ rule, index: nestedIndex }) => {\n if (styleSheet) {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet.cssRules,\n positions,\n );\n nestedRule.insertRule(rule, index);\n } else {\n const index =\n nestedIndex === undefined\n ? undefined\n : Math.min(nestedIndex, styleSheet.cssRules.length);\n styleSheet.insertRule(rule, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else {\n rules?.push({\n cssText: rule,\n index: nestedIndex,\n type: StyleRuleType.Insert,\n });\n }\n });\n }\n\n if (d.removes) {\n d.removes.forEach(({ index: nestedIndex }) => {\n if (usingVirtualParent) {\n rules?.push({ index: nestedIndex, type: StyleRuleType.Remove });\n } else {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet!.cssRules,\n positions,\n );\n nestedRule.deleteRule(index || 0);\n } else {\n styleSheet?.deleteRule(nestedIndex);\n }\n } catch (e) {\n /**\n * same as insertRule\n */\n }\n }\n });\n }\n break;\n }\n case IncrementalSource.StyleDeclaration: {\n // same with StyleSheetRule\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules = [];\n\n if (!styleSheet) {\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.set) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.setProperty(d.set.property, d.set.value, d.set.priority);\n } else {\n rules.push({\n type: StyleRuleType.SetProperty,\n index: d.index,\n ...d.set,\n });\n }\n }\n\n if (d.remove) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.removeProperty(d.remove.property);\n } else {\n rules.push({\n type: StyleRuleType.RemoveProperty,\n index: d.index,\n ...d.remove,\n });\n }\n }\n break;\n }\n case IncrementalSource.CanvasMutation: {\n if (!this.config.UNSAFE_replayCanvas) {\n return;\n }\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n canvasMutation({\n event: e,\n mutation: d,\n target: (target as unknown) as HTMLCanvasElement,\n imageMap: this.imageMap,\n errorHandler: this.warnCanvasMutationFailed.bind(this),\n });\n\n break;\n }\n case IncrementalSource.Font: {\n try {\n const fontFace = new FontFace(\n d.family,\n d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource,\n d.descriptors,\n );\n this.iframe.contentDocument?.fonts.add(fontFace);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(error);\n }\n }\n break;\n }\n default:\n }\n }\n\n private applyMutation(d: mutationData, useVirtualParent: boolean) {\n d.removes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.parentId)) {\n // no need to warn, parent was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.virtualStyleRulesMap.has(target)) {\n this.virtualStyleRulesMap.delete(target);\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n return this.warnNodeNotFound(d, mutation.parentId);\n }\n if (mutation.isShadow && hasShadowRoot(parent)) {\n parent = parent.shadowRoot;\n }\n // target may be removed with its parents before\n this.mirror.removeNodeFromMap(target);\n if (parent) {\n let realTarget = null;\n const realParent =\n '__sn' in parent ? this.fragmentParentMap.get(parent) : undefined;\n if (realParent && realParent.contains(target)) {\n parent = realParent;\n } else if (this.fragmentParentMap.has(target)) {\n /**\n * the target itself is a fragment document and it's not in the dom\n * so we should remove the real target from its parent\n */\n realTarget = this.fragmentParentMap.get(target)!;\n this.fragmentParentMap.delete(target);\n target = realTarget;\n }\n try {\n parent.removeChild(target);\n } catch (error) {\n if (error instanceof DOMException) {\n this.warn(\n 'parent could not remove child in mutation',\n parent,\n realParent,\n target,\n realTarget,\n d,\n );\n } else {\n throw error;\n }\n }\n }\n });\n\n // tslint:disable-next-line: variable-name\n const legacy_missingNodeMap: missingNodeMap = {\n ...this.legacy_missingNodeRetryMap,\n };\n const queue: addedNodeMutation[] = [];\n\n // next not present at this moment\n const nextNotInDOM = (mutation: addedNodeMutation) => {\n let next: Node | null = null;\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n // next not present at this moment\n if (\n mutation.nextId !== null &&\n mutation.nextId !== undefined &&\n mutation.nextId !== -1 &&\n !next\n ) {\n return true;\n }\n return false;\n };\n\n const appendNode = (mutation: addedNodeMutation) => {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n if (mutation.node.type === NodeType.Document) {\n // is newly added document, maybe the document node of an iframe\n return this.newDocumentQueue.push(mutation);\n }\n return queue.push(mutation);\n }\n\n let parentInDocument = null;\n if (this.iframe.contentDocument.contains) {\n parentInDocument = this.iframe.contentDocument.contains(parent);\n } else if (this.iframe.contentDocument.body.contains) {\n // fix for IE\n // refer 'Internet Explorer notes' at https://developer.mozilla.org/zh-CN/docs/Web/API/Document\n parentInDocument = this.iframe.contentDocument.body.contains(parent);\n }\n\n const hasIframeChild =\n ((parent as unknown) as HTMLElement).getElementsByTagName?.('iframe')\n .length > 0;\n /**\n * Why !isIframeINode(parent)? If parent element is an iframe, iframe document can't be appended to virtual parent.\n * Why !hasIframeChild? If we move iframe elements from dom to fragment document, we will lose the contentDocument of iframe. So we need to disable the virtual dom optimization if a parent node contains iframe elements.\n */\n if (\n useVirtualParent &&\n parentInDocument &&\n !isIframeINode(parent) &&\n !hasIframeChild\n ) {\n const virtualParent = (document.createDocumentFragment() as unknown) as INode;\n this.mirror.map[mutation.parentId] = virtualParent;\n this.fragmentParentMap.set(virtualParent, parent);\n\n // store the state, like scroll position, of child nodes before they are unmounted from dom\n this.storeState(parent);\n\n while (parent.firstChild) {\n virtualParent.appendChild(parent.firstChild);\n }\n parent = virtualParent;\n }\n\n if (mutation.node.isShadow) {\n // If the parent is attached a shadow dom after it's created, it won't have a shadow root.\n if (!hasShadowRoot(parent)) {\n ((parent as Node) as HTMLElement).attachShadow({ mode: 'open' });\n parent = ((parent as Node) as HTMLElement).shadowRoot!;\n } else parent = parent.shadowRoot;\n }\n\n let previous: Node | null = null;\n let next: Node | null = null;\n if (mutation.previousId) {\n previous = this.mirror.getNode(mutation.previousId) as Node;\n }\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n if (nextNotInDOM(mutation)) {\n return queue.push(mutation);\n }\n\n if (mutation.node.rootId && !this.mirror.getNode(mutation.node.rootId)) {\n return;\n }\n\n const targetDoc = mutation.node.rootId\n ? this.mirror.getNode(mutation.node.rootId)\n : this.iframe.contentDocument;\n if (isIframeINode(parent)) {\n this.attachDocumentToIframe(mutation, parent);\n return;\n }\n const target = buildNodeWithSN(mutation.node, {\n doc: targetDoc as Document,\n map: this.mirror.map,\n skipChild: true,\n hackCss: true,\n cache: this.cache,\n }) as INode;\n\n // legacy data, we should not have -1 siblings any more\n if (mutation.previousId === -1 || mutation.nextId === -1) {\n legacy_missingNodeMap[mutation.node.id] = {\n node: target,\n mutation,\n };\n return;\n }\n\n if (\n '__sn' in parent &&\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n mutation.node.type === NodeType.Text\n ) {\n // https://github.com/rrweb-io/rrweb/issues/745\n // parent is textarea, will only keep one child node as the value\n for (const c of Array.from(parent.childNodes)) {\n if (c.nodeType === parent.TEXT_NODE) {\n parent.removeChild(c);\n }\n }\n }\n\n if (previous && previous.nextSibling && previous.nextSibling.parentNode) {\n parent.insertBefore(target, previous.nextSibling);\n } else if (next && next.parentNode) {\n // making sure the parent contains the reference nodes\n // before we insert target before next.\n parent.contains(next)\n ? parent.insertBefore(target, next)\n : parent.insertBefore(target, null);\n } else {\n /**\n * Sometimes the document changes and the MutationObserver is disconnected, so the removal of child elements can't be detected and recorded. After the change of document, we may get another mutation which adds a new html element, while the old html element still exists in the dom, and we need to remove the old html element first to avoid collision.\n */\n if (parent === targetDoc) {\n while (targetDoc.firstChild) {\n targetDoc.removeChild(targetDoc.firstChild);\n }\n }\n\n parent.appendChild(target);\n }\n\n if (isIframeINode(target)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === target.__sn.id,\n );\n if (mutationInQueue) {\n this.attachDocumentToIframe(mutationInQueue, target);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(\n legacy_missingNodeMap,\n parent,\n target,\n mutation,\n );\n }\n };\n\n d.adds.forEach((mutation) => {\n appendNode(mutation);\n });\n\n let startTime = Date.now();\n while (queue.length) {\n // transform queue to resolve tree\n const resolveTrees = queueToResolveTrees(queue);\n queue.length = 0;\n if (Date.now() - startTime > 500) {\n this.warn(\n 'Timeout in the loop, please check the resolve tree data:',\n resolveTrees,\n );\n break;\n }\n for (const tree of resolveTrees) {\n let parent = this.mirror.getNode(tree.value.parentId);\n if (!parent) {\n this.debug(\n 'Drop resolve tree since there is no parent for the root node.',\n tree,\n );\n } else {\n iterateResolveTree(tree, (mutation) => {\n appendNode(mutation);\n });\n }\n }\n }\n\n if (Object.keys(legacy_missingNodeMap).length) {\n Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);\n }\n\n d.texts.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n /**\n * apply text content to real parent directly\n */\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n target.textContent = mutation.value;\n });\n d.attributes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n for (const attributeName in mutation.attributes) {\n if (typeof attributeName === 'string') {\n const value = mutation.attributes[attributeName];\n if (value === null) {\n ((target as Node) as Element).removeAttribute(attributeName);\n } else if (typeof value === 'string') {\n try {\n ((target as Node) as Element).setAttribute(attributeName, value);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n 'An error occurred may due to the checkout feature.',\n error,\n );\n }\n }\n } else if (attributeName === 'style') {\n let styleValues = value as styleAttributeValue;\n const targetEl = (target as Node) as HTMLElement;\n for (var s in styleValues) {\n if (styleValues[s] === false) {\n targetEl.style.removeProperty(s);\n } else if (styleValues[s] instanceof Array) {\n const svp = styleValues[s] as styleValueWithPriority;\n targetEl.style.setProperty(s, svp[0], svp[1]);\n } else {\n const svs = styleValues[s] as string;\n targetEl.style.setProperty(s, svs);\n }\n }\n }\n }\n }\n });\n }\n\n /**\n * Apply the scroll data on real elements.\n * If the replayer is in sync mode, smooth scroll behavior should be disabled.\n * @param d the scroll data\n * @param isSync whether the replayer is in sync mode(fast-forward)\n */\n private applyScroll(d: scrollData, isSync: boolean) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n if ((target as Node) === this.iframe.contentDocument) {\n this.iframe.contentWindow!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else if (target.__sn.type === NodeType.Document) {\n // nest iframe content document\n ((target as unknown) as Document).defaultView!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else {\n try {\n ((target as Node) as Element).scrollTop = d.y;\n ((target as Node) as Element).scrollLeft = d.x;\n } catch (error) {\n /**\n * Seldomly we may found scroll target was removed before\n * its last scroll event.\n */\n }\n }\n }\n\n private applyInput(d: inputData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n try {\n ((target as Node) as HTMLInputElement).checked = d.isChecked;\n ((target as Node) as HTMLInputElement).value = d.text;\n } catch (error) {\n // for safe\n }\n }\n\n private applyText(d: textMutation, mutation: mutationData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(mutation, d.id);\n }\n try {\n ((target as Node) as HTMLElement).textContent = d.value;\n } catch (error) {\n // for safe\n }\n }\n\n private legacy_resolveMissingNode(\n map: missingNodeMap,\n parent: Node,\n target: Node,\n targetMutation: addedNodeMutation,\n ) {\n const { previousId, nextId } = targetMutation;\n const previousInMap = previousId && map[previousId];\n const nextInMap = nextId && map[nextId];\n if (previousInMap) {\n const { node, mutation } = previousInMap as missingNode;\n parent.insertBefore(node, target);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n if (nextInMap) {\n const { node, mutation } = nextInMap as missingNode;\n parent.insertBefore(node, target.nextSibling);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n }\n\n private moveAndHover(\n x: number,\n y: number,\n id: number,\n isSync: boolean,\n debugData: incrementalData,\n ) {\n const target = this.mirror.getNode(id);\n if (!target) {\n return this.debugNodeNotFound(debugData, id);\n }\n\n const base = getBaseDimension(target, this.iframe);\n const _x = x * base.absoluteScale + base.x;\n const _y = y * base.absoluteScale + base.y;\n\n this.mouse.style.left = `${_x}px`;\n this.mouse.style.top = `${_y}px`;\n if (!isSync) {\n this.drawMouseTail({ x: _x, y: _y });\n }\n this.hoverElements((target as Node) as Element);\n }\n\n private drawMouseTail(position: { x: number; y: number }) {\n if (!this.mouseTail) {\n return;\n }\n\n const { lineCap, lineWidth, strokeStyle, duration } =\n this.config.mouseTail === true\n ? defaultMouseTailConfig\n : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);\n\n const draw = () => {\n if (!this.mouseTail) {\n return;\n }\n const ctx = this.mouseTail.getContext('2d');\n if (!ctx || !this.tailPositions.length) {\n return;\n }\n ctx.clearRect(0, 0, this.mouseTail.width, this.mouseTail.height);\n ctx.beginPath();\n ctx.lineWidth = lineWidth;\n ctx.lineCap = lineCap;\n ctx.strokeStyle = strokeStyle;\n ctx.moveTo(this.tailPositions[0].x, this.tailPositions[0].y);\n this.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));\n ctx.stroke();\n };\n\n this.tailPositions.push(position);\n draw();\n setTimeout(() => {\n this.tailPositions = this.tailPositions.filter((p) => p !== position);\n draw();\n }, duration / this.speedService.state.context.timer.speed);\n }\n\n private hoverElements(el: Element) {\n this.iframe.contentDocument\n ?.querySelectorAll('.\\\\:hover')\n .forEach((hoveredEl) => {\n hoveredEl.classList.remove(':hover');\n });\n let currentEl: Element | null = el;\n while (currentEl) {\n if (currentEl.classList) {\n currentEl.classList.add(':hover');\n }\n currentEl = currentEl.parentElement;\n }\n }\n\n private isUserInteraction(event: eventWithTime): boolean {\n if (event.type !== EventType.IncrementalSnapshot) {\n return false;\n }\n return (\n event.data.source > IncrementalSource.Mutation &&\n event.data.source <= IncrementalSource.Input\n );\n }\n\n private backToNormal() {\n this.nextUserInteractionEvent = null;\n if (this.speedService.state.matches('normal')) {\n return;\n }\n this.speedService.send({ type: 'BACK_TO_NORMAL' });\n this.emitter.emit(ReplayerEvents.SkipEnd, {\n speed: this.speedService.state.context.normalSpeed,\n });\n }\n\n /**\n * Replace the virtual parent with the real parent.\n * @param frag fragment document, the virtual parent\n * @param parent real parent element\n */\n private restoreRealParent(frag: INode, parent: INode) {\n this.mirror.map[parent.__sn.id] = parent;\n /**\n * If we have already set value attribute on textarea,\n * then we could not apply text content as default value any more.\n */\n if (\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n frag.textContent\n ) {\n ((parent as unknown) as HTMLTextAreaElement).value = frag.textContent;\n }\n parent.appendChild(frag);\n // restore state of elements after they are mounted\n this.restoreState(parent);\n }\n\n /**\n * store state of elements before unmounted from dom recursively\n * the state should be restored in the handler of event ReplayerEvents.Flush\n * e.g. browser would lose scroll position after the process that we add children of parent node to Fragment Document as virtual dom\n */\n private storeState(parent: INode) {\n if (parent) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (parentElement.scrollLeft || parentElement.scrollTop) {\n // store scroll position state\n this.elementStateMap.set(parent, {\n scroll: [parentElement.scrollLeft, parentElement.scrollTop],\n });\n }\n if (parentElement.tagName === 'STYLE')\n storeCSSRules(\n parentElement as HTMLStyleElement,\n this.virtualStyleRulesMap,\n );\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.storeState((child as unknown) as INode);\n }\n }\n }\n }\n\n /**\n * restore the state of elements recursively, which was stored before elements were unmounted from dom in virtual parent mode\n * this function corresponds to function storeState\n */\n private restoreState(parent: INode) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (this.elementStateMap.has(parent)) {\n const storedState = this.elementStateMap.get(parent)!;\n // restore scroll position\n if (storedState.scroll) {\n parentElement.scrollLeft = storedState.scroll[0];\n parentElement.scrollTop = storedState.scroll[1];\n }\n this.elementStateMap.delete(parent);\n }\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.restoreState((child as unknown) as INode);\n }\n }\n }\n\n private restoreNodeSheet(node: INode) {\n const storedRules = this.virtualStyleRulesMap.get(node);\n if (node.nodeName !== 'STYLE') {\n return;\n }\n\n if (!storedRules) {\n return;\n }\n\n const styleNode = (node as unknown) as HTMLStyleElement;\n\n applyVirtualStyleRulesToNode(storedRules, styleNode);\n }\n\n private warnNodeNotFound(d: incrementalData, id: number) {\n if (this.treeIndex.idRemoved(id)) {\n this.warn(`Node with id '${id}' was previously removed. `, d);\n } else {\n this.warn(`Node with id '${id}' not found. `, d);\n }\n }\n\n private warnCanvasMutationFailed(\n d: canvasMutationData | canvasMutationCommand,\n error: unknown,\n ) {\n this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);\n }\n\n private debugNodeNotFound(d: incrementalData, id: number) {\n /**\n * There maybe some valid scenes of node not being found.\n * Because DOM events are macrotask and MutationObserver callback\n * is microtask, so events fired on a removed DOM may emit\n * snapshots in the reverse order.\n */\n if (this.treeIndex.idRemoved(id)) {\n this.debug(\n REPLAY_CONSOLE_PREFIX,\n `Node with id '${id}' was previously removed. `,\n d,\n );\n } else {\n this.debug(REPLAY_CONSOLE_PREFIX, `Node with id '${id}' not found. `, d);\n }\n }\n\n private warn(...args: Parameters) {\n if (!this.config.showWarning) {\n return;\n }\n console.warn(REPLAY_CONSOLE_PREFIX, ...args);\n }\n\n private debug(...args: Parameters) {\n if (!this.config.showDebug) {\n return;\n }\n // tslint:disable-next-line: no-console\n console.log(REPLAY_CONSOLE_PREFIX, ...args);\n }\n}\n","import { Replayer } from '..';\nimport {\n CanvasContext,\n canvasMutationCommand,\n canvasMutationData,\n} from '../../types';\nimport webglMutation from './webgl';\nimport canvas2DMutation from './2d';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationData;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const mutations: canvasMutationCommand[] =\n 'commands' in mutation ? mutation.commands : [mutation];\n\n if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {\n return mutations.forEach((command) => {\n webglMutation({\n mutation: command,\n type: mutation.type,\n target,\n imageMap,\n errorHandler,\n });\n });\n }\n // default is '2d' for backwards compatibility (rrweb below 1.1.x)\n return mutations.forEach((command) => {\n canvas2DMutation({\n event,\n mutation: command,\n target,\n imageMap,\n errorHandler,\n });\n });\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import { Replayer } from '../';\nimport { canvasMutationCommand } from '../../types';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = ((target as unknown) as HTMLCanvasElement).getContext('2d')!;\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n /**\n * We have serialized the image source into base64 string during recording,\n * which has been preloaded before replay.\n * So we can get call drawImage SYNCHRONOUSLY which avoid some fragile cast.\n */\n if (\n mutation.property === 'drawImage' &&\n typeof mutation.args[0] === 'string'\n ) {\n const image = imageMap.get(event);\n mutation.args[0] = image;\n original.apply(ctx, mutation.args);\n } else {\n original.apply(ctx, mutation.args);\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Much of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// Many optimizations have been made, so the bundle size is ultimately smaller but performance is similar.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var u = ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([c], { type: 'text/javascript' })));\n var w = new Worker(u);\n w.onerror = function (e) { return cb(e.error, null); };\n w.onmessage = function (e) { return cb(null, e.data); };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;\n// fixed length extra bits\nvar fleb = new u8([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, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\n// see fleb note\nvar fdeb = new u8([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, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new u32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return [b, r];\n};\nvar _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b[0], revfd = _b[1];\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >>> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >>> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >>> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >>> 8) | ((x & 0x00FF) << 8)) >>> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i)\n ++l[cd[i] - 1];\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 0; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >>> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i)\n co[i] = rev[le[cd[i] - 1]++] >>> (15 - cd[i]);\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8)) >>> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >>> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p / 8) >> 0) + (p & 7 && 1); };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n var n = new (v instanceof u16 ? u16 : v instanceof u32 ? u32 : u8)(e - s);\n n.set(v.subarray(s, e));\n return n;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, buf, st) {\n // source length\n var sl = dat.length;\n // have to estimate size\n var noBuf = !buf || st;\n // no state\n var noSt = !st || st.i;\n if (!st)\n st = {};\n // Assumes roughly 33% compression ratio average\n if (!buf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n st.f = final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n throw 'unexpected EOF';\n break;\n }\n // ensure size\n if (noBuf)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n if (!noSt && pos + tl * (clb + 7) > tbts)\n break;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >>> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n throw 'invalid block type';\n if (pos > tbts)\n throw 'unexpected EOF';\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17;\n if (noBuf)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var mxa = lbt + dbt + 18;\n while (noSt || pos + mxa < tbts) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;\n pos += c & 15;\n if (pos > tbts)\n throw 'unexpected EOF';\n if (!c)\n throw 'invalid length/literal';\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;\n if (!d)\n throw 'invalid distance';\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & ((1 << b) - 1), pos += b;\n }\n if (pos > tbts)\n throw 'unexpected EOF';\n if (noBuf)\n cbuf(bt + 131072);\n var end = bt + add;\n for (; bt < end; bt += 4) {\n buf[bt] = buf[bt - dt];\n buf[bt + 1] = buf[bt + 1 - dt];\n buf[bt + 2] = buf[bt + 2 - dt];\n buf[bt + 3] = buf[bt + 3 - dt];\n }\n bt = end;\n }\n }\n st.l = lm, st.p = pos, st.b = bt;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n return bt == buf.length ? buf : slc(buf, 0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n d[o + 2] |= v >>> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return [new u8(0), 0];\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return [v, 1];\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return [new u8(tr), mbt];\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return [cl.subarray(0, cli), s];\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >>> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a[0], mlb = _a[1];\n var _b = hTree(df, 15), ddt = _b[0], mdb = _b[1];\n var _c = lc(dlt), lclt = _c[0], nlc = _c[1];\n var _d = lc(ddt), lcdt = _d[0], ndc = _d[1];\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n lcfreq[lclt[i] & 31]++;\n for (var i = 0; i < lcdt.length; ++i)\n lcfreq[lcdt[i] & 31]++;\n var _e = hTree(lcfreq, 7), lct = _e[0], mlcb = _e[1];\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);\n if (flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >>> 5) & 127), p += clct[i] >>> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n if (syms[i] > 255) {\n var len = (syms[i] >>> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (syms[i] >>> 23) & 31), p += fleb[len];\n var dst = syms[i] & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (syms[i] >>> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new u32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, lst) {\n var s = dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.floor(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var pos = 0;\n if (!lvl || s < 8) {\n for (var i = 0; i <= s; i += 65535) {\n // end\n var e = i + 65535;\n if (e < s) {\n // write full block\n pos = wfblk(w, pos, dat.subarray(i, e));\n }\n else {\n // write final block\n w[i] = lst;\n pos = wfblk(w, pos, dat.subarray(i, s));\n }\n }\n }\n else {\n var opt = deo[lvl - 1];\n var n = opt >>> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = new u16(32768), head = new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new u32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx bitpos\n var lc_1 = 0, eb = 0, i = 0, li = 0, wi = 0, bs = 0;\n for (; i < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768\n var imod = i & 32767;\n // previous index with this value\n var pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && rem > 423) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = (imod - pimod) & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = (i - dif + j + 32768) & 32767;\n var pti = prev[ti];\n var cd = (ti - pti + 32768) & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += (imod - pimod + 32768) & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one Uint32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n // this is the easiest way to avoid needing to maintain state\n if (!lst)\n pos = wfblk(w, pos, et);\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new u32(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && 0xEDB88320) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = 0xFFFFFFFF;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return c ^ 0xFFFFFFFF; }\n };\n};\n// Alder32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 5552, l);\n for (; i < e; ++i)\n n += d[i], m += n;\n n %= 65521, m %= 65521;\n }\n a = n, b = m;\n },\n d: function () { return ((a >>> 8) << 16 | (b & 255) << 8 | (b >>> 8)) + ((a & 255) << 23) * 2; }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post, !st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/ /g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return [fnStr, td];\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k] instanceof u8 || v[k] instanceof u16 || v[k] instanceof u32)\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n var _a;\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n _a = wcln(fns[i], fnStr, td_1), fnStr = _a[0], td_1 = _a[1];\n ch[id] = wcln(fns[m], fnStr, td_1);\n }\n var td = mrg({}, ch[id][1]);\n return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, hMap, max, bits, bits16, shft, slc, inflt, inflateSync, pbf, gu8]; };\nvar bDflt = function () { return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zlv]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get u8\nvar gu8 = function (o) { return o && o.size && new u8(o.size); };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n if (!opts.consume)\n dat = new u8(dat);\n w.postMessage([dat, opts], [dat.buffer]);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) { return strm.push(ev.data[0], ev.data[1]); };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.push = function (d, f) {\n if (t)\n throw 'stream finished';\n if (!strm.ondata)\n throw 'no stream handler';\n w.postMessage([d, t = f], [d.buffer]);\n };\n strm.terminate = function () { w.terminate(); };\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16)) + (d[b + 3] << 23) * 2; };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n throw 'invalid gzip data';\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += d[10] | (d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16) + (2 * (d[l - 1] << 23));\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + ((o.filename && (o.filename.length + 1)) || 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (fl ? (32 - 2 * fl) : 1);\n};\n// zlib valid\nvar zlv = function (d) {\n if ((d[0] & 15) != 8 || (d[0] >>> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n throw 'invalid zlib data';\n if (d[1] & 32)\n throw 'invalid zlib data: preset dictionaries not supported';\n};\nfunction AsyncCmpStrm(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n// zlib footer: -4 to -0 is Adler32\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, !f), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n this.d = final;\n this.p(chunk, final || false);\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n return dopt(data, opts, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n /**\n * Creates an inflation stream\n * @param cb The callback to call whenever data is inflated\n */\n function Inflate(cb) {\n this.s = {};\n this.p = new u8(0);\n this.ondata = cb;\n }\n Inflate.prototype.e = function (c) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n var l = this.p.length;\n var n = new u8(l + c.length);\n n.set(this.p), n.set(c, l), this.p = n;\n };\n Inflate.prototype.c = function (final) {\n this.d = this.s.i = final || false;\n var bts = this.s.b;\n var dt = inflt(this.p, this.o, this.s);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) >> 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous inflation stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncInflate(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, 0, function () {\n var strm = new Inflate();\n onmessage = astrm(strm);\n }, 7);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gu8(ev.data[1]))); }, 1, cb);\n}\n/**\n * Expands DEFLATE data with no wrapper\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function inflateSync(data, out) {\n return inflt(data, out);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n this.c.p(c);\n this.l += c.length;\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, !f);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n /**\n * Creates a GUNZIP stream\n * @param cb The callback to call whenever data is inflated\n */\n function Gunzip(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n var s = gzs(this.p);\n if (s >= this.p.length && !final)\n return;\n this.p = this.p.subarray(s), this.v = 0;\n }\n if (final) {\n if (this.p.length < 8)\n throw 'invalid gzip stream';\n this.p = this.p.subarray(0, -8);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous GUNZIP stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncGunzip(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, 0, function () {\n var strm = new Gunzip();\n onmessage = astrm(strm);\n }, 9);\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0])); }, 3, cb);\n}\n/**\n * Expands GZIP data\n * @param data The data to decompress\n * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.\n * @returns The decompressed version of the data\n */\nexport function gunzipSync(data, out) {\n return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n this.c.p(c);\n var raw = dopt(c, this.o, this.v && 2, f && 4, !f);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n /**\n * Creates a Zlib decompression stream\n * @param cb The callback to call whenever data is inflated\n */\n function Unzlib(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 2 && !final)\n return;\n this.p = this.p.subarray(2), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n throw 'invalid zlib stream';\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous Zlib decompression stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncUnzlib(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, 0, function () {\n var strm = new Unzlib();\n onmessage = astrm(strm);\n }, 11);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gu8(ev.data[1]))); }, 5, cb);\n}\n/**\n * Expands Zlib data\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function unzlibSync(data, out) {\n return inflt((zlv(data), data.subarray(2, -4)), out);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n /**\n * Creates a decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function Decompress(cb) {\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n throw 'no stream handler';\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n var _this_1 = this;\n var cb = function () { _this_1.ondata.apply(_this_1, arguments); };\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(cb)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(cb)\n : new this.Z(cb);\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function AsyncDecompress(cb) {\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, out) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, out)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, out)\n : unzlibSync(data, out);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k;\n if (val instanceof u8)\n t[n] = [val, o];\n else if (Array.isArray(val))\n t[n] = [val[0], mrg(o, val[1])];\n else\n fltn(val, n + '/', t, o);\n }\n};\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n var l = str.length;\n if (!latin1 && typeof TextEncoder != 'undefined')\n return new TextEncoder().encode(str);\n var ar = new u8(str.length + (str.length >>> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >>> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >>> 18)), w(128 | ((c >>> 12) & 63)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >>> 12)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n var r = '';\n if (!latin1 && typeof TextDecoder != 'undefined')\n return new TextDecoder().decode(dat);\n for (var i = 0; i < dat.length;) {\n var c = dat[i++];\n if (c < 128 || latin1)\n r += String.fromCharCode(c);\n else if (c < 224)\n r += String.fromCharCode((c & 31) << 6 | (dat[i++] & 63));\n else if (c < 240)\n r += String.fromCharCode((c & 15) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63));\n else\n c = ((c & 15) << 18 | (dat[i++] & 63) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n return r;\n}\n;\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;\n var _a = z ? z64e(d, es) : [b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];\n};\n// read zip64 extra field\nvar z64e = function (d, b) {\n for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))\n ;\n return [b4(d, b + 12), b4(d, b + 4), b4(d, b + 20)];\n};\n// write zip header\nvar wzh = function (d, b, c, cmp, su, fn, u, o, ce, t) {\n var fl = fn.length, l = cmp.length;\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b] = 20, b += 2;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (t == 8 && (o.level == 1 ? 6 : o.level < 6 ? 4 : o.level == 9 ? 2 : 0)), d[b++] = u && 8;\n d[b] = t, b += 2;\n var dt = new Date(o.mtime || Date.now()), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n throw 'date not in range 1980-2099';\n wbytes(d, b, ((y << 24) * 2) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >>> 1));\n b += 4;\n wbytes(d, b, c);\n wbytes(d, b + 4, l);\n wbytes(d, b + 8, su);\n wbytes(d, b + 12, fl), b += 16; // skip extra field, comment\n if (ce != null)\n wbytes(d, b += 10, ce), b += 4;\n d.set(fn, b);\n b += fl;\n if (ce == null)\n d.set(cmp, b);\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n wzh(out, tot, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, tot, f.t), o += 46 + f.n.length, tot += 30 + f.n.length + f.d.length;\n }\n catch (e) {\n return cb(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cb(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), m = file.length;\n c.p(file);\n var n = strToU8(fn), s = n.length;\n var t = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n var l = d.length;\n files[i] = {\n t: t,\n d: d,\n m: m,\n c: c.d(),\n u: fn.length != l,\n n: n,\n p: p\n };\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n if (!--lft)\n cbf();\n }\n };\n if (n.length > 65535)\n cbl('filename too long', null);\n if (!t)\n cbl(null, file);\n else if (m < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var t = p.level == 0 ? 0 : 8;\n var n = strToU8(fn), s = n.length;\n if (n.length > 65535)\n throw 'filename too long';\n var d = t ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push({\n t: t,\n d: d,\n m: file.length,\n c: c.d(),\n u: fn.length != s,\n n: n,\n o: o,\n p: p\n });\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, f.o, f.t), o += 46 + f.n.length;\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Asynchronously decompresses a ZIP archive\n * @param data The raw compressed ZIP file\n * @param cb The callback to call with the decompressed files\n * @returns A function that can be used to immediately terminate the unzipping\n */\nexport function unzip(data, cb) {\n if (typeof cb != 'function')\n throw 'no callback';\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cb('invalid zip file', null);\n return;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (!lft)\n cb(null, {});\n var c = lft;\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = lft = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n var _loop_2 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n files[fn] = d;\n if (!--lft)\n cb(null, files);\n }\n };\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n if (sc < 320000) {\n try {\n cbl(null, inflateSync(infl, new u8(su)));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl('unknown compression type ' + c_1, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_2(i);\n }\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @returns The decompressed files\n */\nexport function unzipSync(data) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n throw 'invalid zip file';\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));\n else\n throw 'unknown compression type ' + c_2;\n }\n return files;\n}\n","import { strFromU8, strToU8, unzlibSync } from 'fflate';\nimport { UnpackFn, eventWithTimeAndPacker, MARK } from './base';\nimport { eventWithTime } from '../types';\n\nexport const unpack: UnpackFn = (raw: string) => {\n if (typeof raw !== 'string') {\n return raw;\n }\n try {\n const e: eventWithTime = JSON.parse(raw);\n if (e.timestamp) {\n return e;\n }\n } catch (error) {\n // ignore and continue\n }\n try {\n const e: eventWithTimeAndPacker = JSON.parse(\n strFromU8(unzlibSync(strToU8(raw, true)))\n );\n if (e.v === MARK) {\n return e;\n }\n throw new Error(\n `These events were packed with packer ${e.v} which is incompatible with current packer ${MARK}.`,\n );\n } catch (error) {\n console.error(error);\n throw new Error('Unknown data format.');\n }\n};\n","import { eventWithTime } from '../types';\n\nexport type PackFn = (event: eventWithTime) => string;\nexport type UnpackFn = (raw: string) => eventWithTime;\n\nexport type eventWithTimeAndPacker = eventWithTime & {\n v: string;\n};\n\nexport const MARK = 'v1';\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isElement","nodeType","ELEMENT_NODE","commentre","parse","css","options","lineno","column","updatePosition","str","lines","match","lastIndexOf","position","start","line","node","Position","whitespace","end","source","content","errorsList","msg","err","Error","reason","filename","silent","open","close","rules","comments","charAt","atrule","rule","re","exec","c","comment","pos","type","selector","trim","replace","split","map","declaration","propMatch","prop","val","ret","property","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","name","RegExp","vendor","frame","frames","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","doc","document","atdocument","sel","selectors","atpage","athost","atfontface","addParent","stylesheet","parsingErrors","obj","parent","isNode","childParent","_i","_a","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","script","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cssText","cache","cachedStyle","stylesWithHoverClass","get","ast","test","selectorMatcher","filter","index","indexOf","sort","a","b","join","result","newSelector","set","createCache","Map","buildNode","hackCss","Document","implementation","createDocument","DocumentType","createDocumentType","publicId","systemId","Element","node_1","tagName","attributes","_cssText","getTagName","isSVG","createElementNS","createElement","_loop_1","name_1","startsWith","image_1","src","onload","ctx","getContext","drawImage","width","height","image","currentSrc","setAttribute","currentTime","rr_mediaCurrentTime","play","console","warn","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","childNodes","TEXT_NODE","removeChild","appendChild","setAttributeNS","substring","rel","as","href","endsWith","srcset","rr_dataURL","isShadowHost","shadowRoot","firstChild","attachShadow","mode","Text","isStyle","textContent","CDATA","createCDATASection","Comment","createComment","buildNodeWithSN","skipChild","_b","afterAppend","rootId","assert","compatMode","xmlns","write","__sn","id","_c","childN","childNode","isShadow","rebuild","onVisit","idNodeMap","key","visit","visitedNode","el","name_2","scrollLeft","scrollTop","handleScroll","mitt","all","create","on","handler","off","splice","emit","evt","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","polyfill","w","d","documentElement","__forceSmoothScrollPolyfill__","userAgent","HTMLElement","original","scroll","scrollTo","scrollBy","elementScroll","scrollElement","scrollIntoView","now","performance","bind","Date","ROUNDING_TOLERANCE","navigator","undefined","shouldBailOut","smoothScroll","body","left","scrollX","pageXOffset","top","scrollY","pageYOffset","SyntaxError","behavior","scrollableParent","findScrollableParent","parentRects","getBoundingClientRect","clientRects","getComputedStyle","x","y","firstArg","hasScrollableSpace","axis","clientHeight","scrollHeight","clientWidth","scrollWidth","canOverflow","overflowValue","isScrollable","isScrollableY","isScrollableX","parentNode","host","step","context","currentX","currentY","k","elapsed","startTime","Math","cos","PI","startX","startY","method","scrollable","requestAnimationFrame","actions","speed","Timer","action","findActionIndex","timeOffset","lastTimestamp","self","raf","check","time","delay","shift","doAction","liveMode","cancelAnimationFrame","mid","floor","addDelay","event","baselineTime","IncrementalSnapshot","data","MouseMove","firstOffset","positions","firstTimestamp","timestamp","return","NotStarted","Running","Stopped","assignment","u","changed","matches","f","states","initial","entry","config","_options","initialState","transition","g","h","S","target","j","E","R","N","cond","O","_","T","q","exit","z","A","B","C","Set","_machine","send","subscribe","add","unsubscribe","delete","stop","clear","state","status","createPlayerService","getCastFn","applyEventsSynchronously","emitter","interpret","createMachine","playing","PAUSE","CAST_EVENT","END","ADD_EVENT","paused","PLAY","TO_LIVE","live","castEvent","lastPlayedEvent","payload","recordTimeOffset","events","timer","events_1","neededEvents","idx","event_1","Meta","discardPriorSnapshots","lastPlayedTimestamp","PlayBack","syncEvents","event_3","castFn_1","neededEvents_1","Flush","addActions","resetLastPlayedEvent","startLive","toggleLiveMode","addEvent","machineEvent","event_4","insertionIndex","isSync","castFn_2","isActive","addAction","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","getId","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","receiver","TreeIndex","mutation","parentTreeNode","indexes","parentId","treeNode","children","texts","tree","mirror","deepRemoveFromMirror","_this","removeIdSet","deepRemoveFromTreeIndex","_treeNode","_parentTreeNode","removeNodeMutations","textMutations","attributeMutations","scrollMap","inputMap","batchMutationData","Mutation","removes","adds","walk","removed","_d","_f","mutationData","queueToResolveTrees","queue","queueNodeMap","putIntoMap","nodeInTree","queueNodeTrees","queue_1","nextId","nextInTree","parentInTree","iterateResolveTree","cb","isIframeINode","getBaseDimension","rootIframe","frameElement","ownerDocument","defaultView","relativeScale","absoluteScale","frameDimension","frameBaseDimension","hasShadowRoot","Boolean","StyleRuleType","getNestedRule","cssRules","getPositionsAndIndex","nestedIndex","pop","applyVirtualStyleRulesToNode","storedRules","styleNode","sheet","Insert","insertRule","Remove","deleteRule","Snapshot","cssTexts","existingRules","existingRulesReversed","entries","reverse","lastMatch_1","Number","restoreSnapshotOfStyleRulesToNode","SetProperty","setProperty","priority","RemoveProperty","removeProperty","chars","lookup","Uint8Array","charCodeAt","webGLVarMap","variableListFor","ctor","contextMap","WebGLVariableConstructorsNames","deserializeArg","imageMap","arg","args","base64","encoded1","encoded2","encoded3","encoded4","bufferLength","len","arraybuffer","ArrayBuffer","bytes","decode","Image","webglMutation","errorHandler","WebGL","setter","constructor","includes","variables","saveToWebGLVarMap","mittProxy.default","mittProxy","REPLAY_CONSOLE_PREFIX","defaultMouseTailConfig","duration","lineCap","lineWidth","strokeStyle","indicatesTouchDevice","TouchMove","MouseInteraction","TouchStart","defaultConfig","maxSpeed","root","loadTimeout","skipInactive","showWarning","showDebug","blockClass","insertStyleRules","triggerFocus","UNSAFE_replayCanvas","pauseAnimation","mouseTail","handleResize","Resize","setupDom","treeIndex","fragmentParentMap","elementStateMap","virtualStyleRulesMap","_e","flush","frag","restoreRealParent","applyText","_h","restoreNodeSheet","_k","applyScroll","_m","applyInput","firstFullSnapshot","service","unpackFn","a1","a2","StateChange","player","speedService","normalSpeed","normal","FAST_FORWARD","SET_SPEED","skipping","BACK_TO_NORMAL","setSpeed","recordSpeed","restoreSpeed","firstMeta","find","firstFullsnapshot","FullSnapshot","width_1","height_1","setTimeout","rebuildFullSnapshot","iframe","contentWindow","initialOffset","mouse","classList","Replayer","backToNormal","display","parseFloat","wrapper","insertBefore","firstEvent","lastEvent","endTime","totalTime","getTimeOffset","contentDocument","getElementsByTagName","remove","Start","Pause","Resume","rawEvent","Promise","resolve","then","pointerEvents","win","disableInteract","smoothscrollPolyfill","NodeList","DOMTokenList","Node","contains","dimension","String","DomContentLoaded","Load","Custom","Plugin","MediaInteraction","castFn","mousePos","moveAndHover","debugData","touchActive","CustomEvent","applyIncremental","nextUserInteractionEvent","_event","isUserInteraction","skipTime","min","round","SkipStart","plugins","replayer","last_index","finish_1","Finish","max","EventCast","legacy_missingNodeRetryMap","collected","builtNode","collectIframeAndAttachDocument","mutationInQueue","this_1","attachDocumentToIframe","newDocumentQueue","collected_1","head","FullsnapshotRebuilded","waitForStylesheetLoad","preloadAllImages","styleEl","injectStylesRules","iframeEl","parent_1","realParent","toUpperCase","this_2","collected_2","timer_1","unloadSheets_1","beforeLoadState_1","stateHandler_1","unsubscribe_1","querySelectorAll","addEventListener","size","getCurrentTime","LoadStylesheetEnd","clearTimeout","LoadStylesheetStart","args_1","hasImageArg","rr_type","images","args_2","getImageArgs","stateHandler","event_2","CanvasMutation","commands","preloadImages","this_3","url","canvas","imgd","createImageData","JSON","putImageData","text","attribute","applyMutation","message","Drag","lastPosition","Event","toLowerCase","debugNodeNotFound","Blur","blur","Focus","focus","preventScroll","Click","TouchEnd","tailPositions","offsetWidth","TouchCancel","dispatchEvent","Scroll","ViewportResize","Input","input","mediaEl","volume","muted","StyleSheetRule","rules_1","parent_2","usingVirtualParent_1","styleSheet_1","StyleDeclaration","parent_3","styleSheet","mutations","WebGL2","command","canvas2DMutation","canvasMutation","warnCanvasMutationFailed","Font","fontFace","FontFace","family","buffer","fontSource","descriptors","fonts","useVirtualParent","warnNodeNotFound","realTarget","DOMException","legacy_missingNodeMap","appendNode","parentInDocument","hasIframeChild","virtualParent","createDocumentFragment","storeState","previous","previousId","nextNotInDOM","targetDoc","nextSibling","mutationInQueue_1","legacy_resolveMissingNode","resolveTrees","resolveTrees_1","debug","attributeName","removeAttribute","styleValues","targetEl","svp","svs","checked","isChecked","targetMutation","previousInMap","nextInMap","base","_x","_y","drawMouseTail","hoverElements","draw","clearRect","beginPath","moveTo","lineTo","stroke","hoveredEl","currentEl","parentElement","SkipEnd","restoreState","storeCSSRules","storedState","nodeName","idRemoved","log","u8","u16","Uint16Array","u32","Uint32Array","fleb","fdeb","clim","freb","eb","fl","revfl","fd","rev","hMap","cd","mb","co","le","rvb","sv","r_1","flt","fdt","flrm","fdrm","bits","bits16","slc","subarray","unzlibSync","out","dat","buf","st","sl","noBuf","noSt","cbuf","bl","nbuf","final","bt","lm","dm","lbt","dbt","tbts","hLit","hcLen","tl","ldt","clt","clb","clbmsk","clm","lt","dt","lms","dms","mxa","sym","dsym","inflt","zlv","raw","latin1","TextDecoder","fromCharCode","strFromU8","TextEncoder","encode","ai","strToU8"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ED+BOC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,YAgFzB,SAASQ,EAASC,GACrB,IAAIZ,EAAsB,mBAAXa,QAAyBA,OAAOC,SAAUC,EAAIf,GAAKY,EAAEZ,GAAIC,EAAI,EAC5E,GAAIc,EAAG,OAAOA,EAAEP,KAAKI,GACrB,GAAIA,GAAyB,iBAAbA,EAAER,OAAqB,MAAO,CAC1CY,KAAM,WAEF,OADIJ,GAAKX,GAAKW,EAAER,SAAQQ,OAAI,GACrB,CAAEK,MAAOL,GAAKA,EAAEX,KAAMiB,MAAON,KAG5C,MAAM,IAAIO,UAAUnB,EA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,EAAI6B,IAAK7B,EAAG,CACxB,GAAI68B,EAAK,EAAIv7B,EAAGnB,OAAQ,CACpB,IAAIF,EAAI,IAAIo4B,GAAGwE,EAAK,GAAMh7B,EAAI7B,GAAM,IACpCC,EAAEiM,IAAI5K,GACNA,EAAKrB,EAET,IAAIuE,EAAI7B,EAAIiiB,WAAW5kB,GACnBwE,EAAI,KAAO+3B,EACXtpB,EAAEzO,GACGA,EAAI,MACTyO,EAAE,IAAOzO,IAAM,GAAKyO,EAAE,IAAW,GAAJzO,IACxBA,EAAI,OAASA,EAAI,OAElByO,EAAE,KADNzO,EAAI,OAAa,QAAJA,GAAyC,KAAtB7B,EAAIiiB,aAAa5kB,MAC9B,IAAMiT,EAAE,IAAQzO,IAAM,GAAM,IAAMyO,EAAE,IAAQzO,IAAM,EAAK,IAAMyO,EAAE,IAAW,GAAJzO,KAEzFyO,EAAE,IAAOzO,IAAM,IAAMyO,EAAE,IAAQzO,IAAM,EAAK,IAAMyO,EAAE,IAAW,GAAJzO,IAEjE,OAAOy1B,GAAI34B,EAAI,EAAGu7B,GC97CKC,CAAQR,GAAK,OAE9Bn0B,EACJ,OAAO9G,EAET,MAAM,IAAIsC,MACR,+CAAwCtC,EAAE8G,wDCf5B,WDiBhB,MAAO3G,GAEP,MADAgN,QAAQhN,MAAMA,GACR,IAAImC,MAAM"} +\ No newline at end of file +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay.css b/node_modules/rrweb/dist/replay/rrweb-replay.css +new file mode 100755 +index 0000000..b459e51 +--- /dev/null ++++ b/node_modules/rrweb/dist/replay/rrweb-replay.css +@@ -0,0 +1,79 @@ ++.replayer-wrapper { ++ position: relative; ++} ++.replayer-mouse { ++ position: absolute; ++ width: 20px; ++ height: 20px; ++ transition: left 0.05s linear, top 0.05s linear; ++ background-size: contain; ++ background-position: center center; ++ background-repeat: no-repeat; ++ background-image: url('data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzMwMHB4JyB3aWR0aD0nMzAwcHgnICBmaWxsPSIjMDAwMDAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGRhdGEtbmFtZT0iTGF5ZXIgMSIgdmlld0JveD0iMCAwIDUwIDUwIiB4PSIwcHgiIHk9IjBweCI+PHRpdGxlPkRlc2lnbl90bnA8L3RpdGxlPjxwYXRoIGQ9Ik00OC43MSw0Mi45MUwzNC4wOCwyOC4yOSw0NC4zMywxOEExLDEsMCwwLDAsNDQsMTYuMzlMMi4zNSwxLjA2QTEsMSwwLDAsMCwxLjA2LDIuMzVMMTYuMzksNDRhMSwxLDAsMCwwLDEuNjUuMzZMMjguMjksMzQuMDgsNDIuOTEsNDguNzFhMSwxLDAsMCwwLDEuNDEsMGw0LjM4LTQuMzhBMSwxLDAsMCwwLDQ4LjcxLDQyLjkxWm0tNS4wOSwzLjY3TDI5LDMyYTEsMSwwLDAsMC0xLjQxLDBsLTkuODUsOS44NUwzLjY5LDMuNjlsMzguMTIsMTRMMzIsMjcuNThBMSwxLDAsMCwwLDMyLDI5TDQ2LjU5LDQzLjYyWiI+PC9wYXRoPjwvc3ZnPg=='); ++ border-color: transparent; /* otherwise we transition from black when .touch-device class is added */ ++} ++.replayer-mouse::after { ++ content: ''; ++ display: inline-block; ++ width: 20px; ++ height: 20px; ++ background: rgb(73, 80, 246); ++ border-radius: 100%; ++ transform: translate(-50%, -50%); ++ opacity: 0.3; ++} ++.replayer-mouse.active::after { ++ animation: click 0.2s ease-in-out 1; ++} ++.replayer-mouse.touch-device { ++ background-image: none; /* there's no passive cursor on touch-only screens */ ++ width: 70px; ++ height: 70px; ++ border-width: 4px; ++ border-style: solid; ++ border-radius: 100%; ++ margin-left: -37px; ++ margin-top: -37px; ++ border-color: rgba(73, 80, 246, 0); ++ transition: left 0s linear, top 0s linear, border-color 0.2s ease-in-out; ++} ++.replayer-mouse.touch-device.touch-active { ++ border-color: rgba(73, 80, 246, 1); ++ transition: left 0.25s linear, top 0.25s linear, border-color 0.2s ease-in-out; ++} ++.replayer-mouse.touch-device::after { ++ opacity: 0; /* there's no passive cursor on touch-only screens */ ++} ++.replayer-mouse.touch-device.active::after { ++ animation: touch-click 0.2s ease-in-out 1; ++} ++.replayer-mouse-tail { ++ position: absolute; ++ pointer-events: none; ++} ++ ++@keyframes click { ++ 0% { ++ opacity: 0.3; ++ width: 20px; ++ height: 20px; ++ } ++ 50% { ++ opacity: 0.5; ++ width: 10px; ++ height: 10px; ++ } ++} ++ ++@keyframes touch-click { ++ 0% { ++ opacity: 0; ++ width: 20px; ++ height: 20px; ++ } ++ 50% { ++ opacity: 0.5; ++ width: 10px; ++ height: 10px; ++ } ++} +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay.js b/node_modules/rrweb/dist/replay/rrweb-replay.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay.min.css b/node_modules/rrweb/dist/replay/rrweb-replay.min.css +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay.min.css.map b/node_modules/rrweb/dist/replay/rrweb-replay.min.css.map +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay.min.js b/node_modules/rrweb/dist/replay/rrweb-replay.min.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/replay/rrweb-replay.min.js.map b/node_modules/rrweb/dist/replay/rrweb-replay.min.js.map +old mode 100644 +new mode 100755 +index 22e3b26..dabb71a +--- a/node_modules/rrweb/dist/replay/rrweb-replay.min.js.map ++++ b/node_modules/rrweb/dist/replay/rrweb-replay.min.js.map +@@ -1 +1 @@ +-{"version":3,"file":"rrweb-replay.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../../node_modules/mitt/dist/mitt.es.js","../../../src/types.ts","../../../src/replay/smoothscroll.ts","../../../src/replay/timer.ts","../../../../node_modules/@xstate/fsm/es/index.js","../../../src/replay/machine.ts","../../../src/utils.ts","../../../src/replay/styles/inject-style.ts","../../../src/replay/virtual-styles.ts","../../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../../src/replay/canvas/webgl.ts","../../../src/replay/index.ts","../../../src/replay/canvas/index.ts","../../../src/replay/canvas/2d.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type]) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector) {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","// \n// An event handler can take an optional event argument\n// and should not return a value\n \n \n\n// An array of all currently registered event handlers for a type\n \n \n// A map of event types and their corresponding event handlers.\n \n \n \n \n\n/** Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nfunction mitt(all ) {\n\tall = all || Object.create(null);\n\n\treturn {\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton: function on(type , handler ) {\n\t\t\t(all[type] || (all[type] = [])).push(handler);\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff: function off(type , handler ) {\n\t\t\tif (all[type]) {\n\t\t\t\tall[type].splice(all[type].indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * @param {String} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit: function emit(type , evt ) {\n\t\t\t(all[type] || []).slice().map(function (handler) { handler(evt); });\n\t\t\t(all['*'] || []).slice().map(function (handler) { handler(type, evt); });\n\t\t}\n\t};\n}\n\nexport default mitt;\n//# sourceMappingURL=mitt.es.js.map\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n ignoreClass?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n ignoreClass: string;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","/**\n * A fork version of https://github.com/iamdustan/smoothscroll\n * Add support of customize target window and document\n */\n\n// @ts-nocheck\n// tslint:disable\nexport function polyfill(w: Window = window, d = document) {\n // return if scroll behavior is supported and polyfill is not forced\n if (\n 'scrollBehavior' in d.documentElement.style &&\n w.__forceSmoothScrollPolyfill__ !== true\n ) {\n return;\n }\n\n // globals\n var Element = w.HTMLElement || w.Element;\n var SCROLL_TIME = 468;\n\n // object gathering original scroll methods\n var original = {\n scroll: w.scroll || w.scrollTo,\n scrollBy: w.scrollBy,\n elementScroll: Element.prototype.scroll || scrollElement,\n scrollIntoView: Element.prototype.scrollIntoView,\n };\n\n // define timing method\n var now =\n w.performance && w.performance.now\n ? w.performance.now.bind(w.performance)\n : Date.now;\n\n /**\n * indicates if a the current browser is made by Microsoft\n * @method isMicrosoftBrowser\n * @param {String} userAgent\n * @returns {Boolean}\n */\n function isMicrosoftBrowser(userAgent) {\n var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];\n\n return new RegExp(userAgentPatterns.join('|')).test(userAgent);\n }\n\n /*\n * IE has rounding bug rounding down clientHeight and clientWidth and\n * rounding up scrollHeight and scrollWidth causing false positives\n * on hasScrollableSpace\n */\n var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;\n\n /**\n * changes scroll position inside an element\n * @method scrollElement\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function scrollElement(x, y) {\n this.scrollLeft = x;\n this.scrollTop = y;\n }\n\n /**\n * returns result of applying ease math function to a number\n * @method ease\n * @param {Number} k\n * @returns {Number}\n */\n function ease(k) {\n return 0.5 * (1 - Math.cos(Math.PI * k));\n }\n\n /**\n * indicates if a smooth behavior should be applied\n * @method shouldBailOut\n * @param {Number|Object} firstArg\n * @returns {Boolean}\n */\n function shouldBailOut(firstArg) {\n if (\n firstArg === null ||\n typeof firstArg !== 'object' ||\n firstArg.behavior === undefined ||\n firstArg.behavior === 'auto' ||\n firstArg.behavior === 'instant'\n ) {\n // first argument is not an object/null\n // or behavior is auto, instant or undefined\n return true;\n }\n\n if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {\n // first argument is an object and behavior is smooth\n return false;\n }\n\n // throw error when behavior is not supported\n throw new TypeError(\n 'behavior member of ScrollOptions ' +\n firstArg.behavior +\n ' is not a valid value for enumeration ScrollBehavior.',\n );\n }\n\n /**\n * indicates if an element has scrollable space in the provided axis\n * @method hasScrollableSpace\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function hasScrollableSpace(el, axis) {\n if (axis === 'Y') {\n return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;\n }\n\n if (axis === 'X') {\n return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;\n }\n }\n\n /**\n * indicates if an element has a scrollable overflow property in the axis\n * @method canOverflow\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function canOverflow(el, axis) {\n var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];\n\n return overflowValue === 'auto' || overflowValue === 'scroll';\n }\n\n /**\n * indicates if an element can be scrolled in either axis\n * @method isScrollable\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function isScrollable(el) {\n var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');\n var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');\n\n return isScrollableY || isScrollableX;\n }\n\n /**\n * finds scrollable parent of an element\n * @method findScrollableParent\n * @param {Node} el\n * @returns {Node} el\n */\n function findScrollableParent(el) {\n while (el !== d.body && isScrollable(el) === false) {\n el = el.parentNode || el.host;\n }\n\n return el;\n }\n\n /**\n * self invoked function that, given a context, steps through scrolling\n * @method step\n * @param {Object} context\n * @returns {undefined}\n */\n function step(context) {\n var time = now();\n var value;\n var currentX;\n var currentY;\n var elapsed = (time - context.startTime) / SCROLL_TIME;\n\n // avoid elapsed times higher than one\n elapsed = elapsed > 1 ? 1 : elapsed;\n\n // apply easing to elapsed time\n value = ease(elapsed);\n\n currentX = context.startX + (context.x - context.startX) * value;\n currentY = context.startY + (context.y - context.startY) * value;\n\n context.method.call(context.scrollable, currentX, currentY);\n\n // scroll more if we have not reached our destination\n if (currentX !== context.x || currentY !== context.y) {\n w.requestAnimationFrame(step.bind(w, context));\n }\n }\n\n /**\n * scrolls window or element with a smooth behavior\n * @method smoothScroll\n * @param {Object|Node} el\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function smoothScroll(el, x, y) {\n var scrollable;\n var startX;\n var startY;\n var method;\n var startTime = now();\n\n // define scroll context\n if (el === d.body) {\n scrollable = w;\n startX = w.scrollX || w.pageXOffset;\n startY = w.scrollY || w.pageYOffset;\n method = original.scroll;\n } else {\n scrollable = el;\n startX = el.scrollLeft;\n startY = el.scrollTop;\n method = scrollElement;\n }\n\n // scroll looping over a frame\n step({\n scrollable: scrollable,\n method: method,\n startTime: startTime,\n startX: startX,\n startY: startY,\n x: x,\n y: y,\n });\n }\n\n // ORIGINAL METHODS OVERRIDES\n // w.scroll and w.scrollTo\n w.scroll = w.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scroll.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : w.scrollX || w.pageXOffset,\n // use top prop, second argument if present or fallback to scrollY\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : w.scrollY || w.pageYOffset,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : w.scrollX || w.pageXOffset,\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : w.scrollY || w.pageYOffset,\n );\n };\n\n // w.scrollBy\n w.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0])) {\n original.scrollBy.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : 0,\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : 0,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n ~~arguments[0].left + (w.scrollX || w.pageXOffset),\n ~~arguments[0].top + (w.scrollY || w.pageYOffset),\n );\n };\n\n // Element.prototype.scroll and Element.prototype.scrollTo\n Element.prototype.scroll = Element.prototype.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n // if one number is passed, throw error to match Firefox implementation\n if (typeof arguments[0] === 'number' && arguments[1] === undefined) {\n throw new SyntaxError('Value could not be converted');\n }\n\n original.elementScroll.call(\n this,\n // use left prop, first number argument or fallback to scrollLeft\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : typeof arguments[0] !== 'object'\n ? ~~arguments[0]\n : this.scrollLeft,\n // use top prop, second argument or fallback to scrollTop\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : arguments[1] !== undefined\n ? ~~arguments[1]\n : this.scrollTop,\n );\n\n return;\n }\n\n var left = arguments[0].left;\n var top = arguments[0].top;\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n this,\n this,\n typeof left === 'undefined' ? this.scrollLeft : ~~left,\n typeof top === 'undefined' ? this.scrollTop : ~~top,\n );\n };\n\n // Element.prototype.scrollBy\n Element.prototype.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.elementScroll.call(\n this,\n arguments[0].left !== undefined\n ? ~~arguments[0].left + this.scrollLeft\n : ~~arguments[0] + this.scrollLeft,\n arguments[0].top !== undefined\n ? ~~arguments[0].top + this.scrollTop\n : ~~arguments[1] + this.scrollTop,\n );\n\n return;\n }\n\n this.scroll({\n left: ~~arguments[0].left + this.scrollLeft,\n top: ~~arguments[0].top + this.scrollTop,\n behavior: arguments[0].behavior,\n });\n };\n\n // Element.prototype.scrollIntoView\n Element.prototype.scrollIntoView = function () {\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scrollIntoView.call(\n this,\n arguments[0] === undefined ? true : arguments[0],\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n var scrollableParent = findScrollableParent(this);\n var parentRects = scrollableParent.getBoundingClientRect();\n var clientRects = this.getBoundingClientRect();\n\n if (scrollableParent !== d.body) {\n // reveal element inside parent\n smoothScroll.call(\n this,\n scrollableParent,\n scrollableParent.scrollLeft + clientRects.left - parentRects.left,\n scrollableParent.scrollTop + clientRects.top - parentRects.top,\n );\n\n // reveal parent in viewport unless is fixed\n if (w.getComputedStyle(scrollableParent).position !== 'fixed') {\n w.scrollBy({\n left: parentRects.left,\n top: parentRects.top,\n behavior: 'smooth',\n });\n }\n } else {\n // reveal element in viewport\n w.scrollBy({\n left: clientRects.left,\n top: clientRects.top,\n behavior: 'smooth',\n });\n }\n };\n}\n","import {\n actionWithDelay,\n eventWithTime,\n EventType,\n IncrementalSource,\n} from '../types';\n\nexport class Timer {\n public timeOffset: number = 0;\n public speed: number;\n\n private actions: actionWithDelay[];\n private raf: number | null = null;\n private liveMode: boolean;\n\n constructor(actions: actionWithDelay[] = [], speed: number) {\n this.actions = actions;\n this.speed = speed;\n }\n /**\n * Add an action after the timer starts.\n * @param action\n */\n public addAction(action: actionWithDelay) {\n const index = this.findActionIndex(action);\n this.actions.splice(index, 0, action);\n }\n /**\n * Add all actions before the timer starts\n * @param actions\n */\n public addActions(actions: actionWithDelay[]) {\n this.actions = this.actions.concat(actions);\n }\n\n public start() {\n this.timeOffset = 0;\n let lastTimestamp = performance.now();\n const { actions } = this;\n const self = this;\n function check() {\n const time = performance.now();\n self.timeOffset += (time - lastTimestamp) * self.speed;\n lastTimestamp = time;\n while (actions.length) {\n const action = actions[0];\n\n if (self.timeOffset >= action.delay) {\n actions.shift();\n action.doAction();\n } else {\n break;\n }\n }\n if (actions.length > 0 || self.liveMode) {\n self.raf = requestAnimationFrame(check);\n }\n }\n this.raf = requestAnimationFrame(check);\n }\n\n public clear() {\n if (this.raf) {\n cancelAnimationFrame(this.raf);\n this.raf = null;\n }\n this.actions.length = 0;\n }\n\n public setSpeed(speed: number) {\n this.speed = speed;\n }\n\n public toggleLiveMode(mode: boolean) {\n this.liveMode = mode;\n }\n\n public isActive() {\n return this.raf !== null;\n }\n\n private findActionIndex(action: actionWithDelay): number {\n let start = 0;\n let end = this.actions.length - 1;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (this.actions[mid].delay < action.delay) {\n start = mid + 1;\n } else if (this.actions[mid].delay > action.delay) {\n end = mid - 1;\n } else {\n // already an action with same delay (timestamp)\n // the plus one will splice the new one after the existing one\n return mid + 1;\n }\n }\n return start;\n }\n}\n\n// TODO: add speed to mouse move timestamp calculation\nexport function addDelay(event: eventWithTime, baselineTime: number): number {\n // Mouse move events was recorded in a throttle function,\n // so we need to find the real timestamp by traverse the time offsets.\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove\n ) {\n const firstOffset = event.data.positions[0].timeOffset;\n // timeOffset is a negative offset to event.timestamp\n const firstTimestamp = event.timestamp + firstOffset;\n event.delay = firstTimestamp - baselineTime;\n return firstTimestamp - baselineTime;\n }\n\n event.delay = event.timestamp - baselineTime;\n return event.delay;\n}\n","/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return{type:\"xstate.assign\",assignment:t}}function i(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){o=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]=\"function\"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o]})),r=n,!1}return!0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})))},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u=\"object\"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}export{n as InterpreterStatus,o as assign,s as createMachine,v as interpret};\n","import { createMachine, interpret, assign, StateMachine } from '@xstate/fsm';\nimport {\n playerConfig,\n eventWithTime,\n actionWithDelay,\n ReplayerEvents,\n EventType,\n Emitter,\n IncrementalSource,\n} from '../types';\nimport { Timer, addDelay } from './timer';\n\nexport type PlayerContext = {\n events: eventWithTime[];\n timer: Timer;\n timeOffset: number;\n baselineTime: number;\n lastPlayedEvent: eventWithTime | null;\n};\nexport type PlayerEvent =\n | {\n type: 'PLAY';\n payload: {\n timeOffset: number;\n };\n }\n | {\n type: 'CAST_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | { type: 'PAUSE' }\n | { type: 'TO_LIVE'; payload: { baselineTime?: number } }\n | {\n type: 'ADD_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | {\n type: 'END';\n };\nexport type PlayerState =\n | {\n value: 'playing';\n context: PlayerContext;\n }\n | {\n value: 'paused';\n context: PlayerContext;\n }\n | {\n value: 'live';\n context: PlayerContext;\n };\n\n/**\n * If the array have multiple meta and fullsnapshot events,\n * return the events from last meta to the end.\n */\nexport function discardPriorSnapshots(\n events: eventWithTime[],\n baselineTime: number,\n): eventWithTime[] {\n for (let idx = events.length - 1; idx >= 0; idx--) {\n const event = events[idx];\n if (event.type === EventType.Meta) {\n if (event.timestamp <= baselineTime) {\n return events.slice(idx);\n }\n }\n }\n return events;\n}\n\ntype PlayerAssets = {\n emitter: Emitter;\n applyEventsSynchronously(events: Array): void;\n getCastFn(event: eventWithTime, isSync: boolean): () => void;\n};\nexport function createPlayerService(\n context: PlayerContext,\n { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets,\n) {\n const playerMachine = createMachine(\n {\n id: 'player',\n context,\n initial: 'paused',\n states: {\n playing: {\n on: {\n PAUSE: {\n target: 'paused',\n actions: ['pause'],\n },\n CAST_EVENT: {\n target: 'playing',\n actions: 'castEvent',\n },\n END: {\n target: 'paused',\n actions: ['resetLastPlayedEvent', 'pause'],\n },\n ADD_EVENT: {\n target: 'playing',\n actions: ['addEvent'],\n },\n },\n },\n paused: {\n on: {\n PLAY: {\n target: 'playing',\n actions: ['recordTimeOffset', 'play'],\n },\n CAST_EVENT: {\n target: 'paused',\n actions: 'castEvent',\n },\n TO_LIVE: {\n target: 'live',\n actions: ['startLive'],\n },\n ADD_EVENT: {\n target: 'paused',\n actions: ['addEvent'],\n },\n },\n },\n live: {\n on: {\n ADD_EVENT: {\n target: 'live',\n actions: ['addEvent'],\n },\n CAST_EVENT: {\n target: 'live',\n actions: ['castEvent'],\n },\n },\n },\n },\n },\n {\n actions: {\n castEvent: assign({\n lastPlayedEvent: (ctx, event) => {\n if (event.type === 'CAST_EVENT') {\n return event.payload.event;\n }\n return ctx.lastPlayedEvent;\n },\n }),\n recordTimeOffset: assign((ctx, event) => {\n let timeOffset = ctx.timeOffset;\n if ('payload' in event && 'timeOffset' in event.payload) {\n timeOffset = event.payload.timeOffset;\n }\n return {\n ...ctx,\n timeOffset,\n baselineTime: ctx.events[0].timestamp + timeOffset,\n };\n }),\n play(ctx) {\n const { timer, events, baselineTime, lastPlayedEvent } = ctx;\n timer.clear();\n\n for (const event of events) {\n // TODO: improve this API\n addDelay(event, baselineTime);\n }\n const neededEvents = discardPriorSnapshots(events, baselineTime);\n\n let lastPlayedTimestamp = lastPlayedEvent?.timestamp;\n if (\n lastPlayedEvent?.type === EventType.IncrementalSnapshot &&\n lastPlayedEvent.data.source === IncrementalSource.MouseMove\n ) {\n lastPlayedTimestamp =\n lastPlayedEvent.timestamp +\n lastPlayedEvent.data.positions[0]?.timeOffset;\n }\n if (baselineTime < (lastPlayedTimestamp || 0)) {\n emitter.emit(ReplayerEvents.PlayBack);\n }\n\n const syncEvents = new Array();\n const actions = new Array();\n for (const event of neededEvents) {\n if (\n lastPlayedTimestamp &&\n lastPlayedTimestamp < baselineTime &&\n (event.timestamp <= lastPlayedTimestamp ||\n event === lastPlayedEvent)\n ) {\n continue;\n }\n if (event.timestamp < baselineTime) {\n syncEvents.push(event);\n } else {\n const castFn = getCastFn(event, false);\n actions.push({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n applyEventsSynchronously(syncEvents);\n emitter.emit(ReplayerEvents.Flush);\n timer.addActions(actions);\n timer.start();\n },\n pause(ctx) {\n ctx.timer.clear();\n },\n resetLastPlayedEvent: assign((ctx) => {\n return {\n ...ctx,\n lastPlayedEvent: null,\n };\n }),\n startLive: assign({\n baselineTime: (ctx, event) => {\n ctx.timer.toggleLiveMode(true);\n ctx.timer.start();\n if (event.type === 'TO_LIVE' && event.payload.baselineTime) {\n return event.payload.baselineTime;\n }\n return Date.now();\n },\n }),\n addEvent: assign((ctx, machineEvent) => {\n const { baselineTime, timer, events } = ctx;\n if (machineEvent.type === 'ADD_EVENT') {\n const { event } = machineEvent.payload;\n addDelay(event, baselineTime);\n\n let end = events.length - 1;\n if (!events[end] || events[end].timestamp <= event.timestamp) {\n // fast track\n events.push(event);\n } else {\n let insertionIndex = -1;\n let start = 0;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (events[mid].timestamp <= event.timestamp) {\n start = mid + 1;\n } else {\n end = mid - 1;\n }\n }\n if (insertionIndex === -1) {\n insertionIndex = start;\n }\n events.splice(insertionIndex, 0, event);\n }\n\n const isSync = event.timestamp < baselineTime;\n const castFn = getCastFn(event, isSync);\n if (isSync) {\n castFn();\n } else if (timer.isActive()) {\n timer.addAction({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n return { ...ctx, events };\n }),\n },\n },\n );\n return interpret(playerMachine);\n}\n\nexport type SpeedContext = {\n normalSpeed: playerConfig['speed'];\n timer: Timer;\n};\n\nexport type SpeedEvent =\n | {\n type: 'FAST_FORWARD';\n payload: { speed: playerConfig['speed'] };\n }\n | {\n type: 'BACK_TO_NORMAL';\n }\n | {\n type: 'SET_SPEED';\n payload: { speed: playerConfig['speed'] };\n };\n\nexport type SpeedState =\n | {\n value: 'normal';\n context: SpeedContext;\n }\n | {\n value: 'skipping';\n context: SpeedContext;\n };\n\nexport function createSpeedService(context: SpeedContext) {\n const speedMachine = createMachine(\n {\n id: 'speed',\n context,\n initial: 'normal',\n states: {\n normal: {\n on: {\n FAST_FORWARD: {\n target: 'skipping',\n actions: ['recordSpeed', 'setSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n skipping: {\n on: {\n BACK_TO_NORMAL: {\n target: 'normal',\n actions: ['restoreSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n },\n },\n {\n actions: {\n setSpeed: (ctx, event) => {\n if ('payload' in event) {\n ctx.timer.setSpeed(event.payload.speed);\n }\n },\n recordSpeed: assign({\n normalSpeed: (ctx) => ctx.timer.speed,\n }),\n restoreSpeed: (ctx) => {\n ctx.timer.setSpeed(ctx.normalSpeed);\n },\n },\n },\n );\n\n return interpret(speedMachine);\n}\n\nexport type PlayerMachineState = StateMachine.State<\n PlayerContext,\n PlayerEvent,\n PlayerState\n>;\n\nexport type SpeedMachineState = StateMachine.State<\n SpeedContext,\n SpeedEvent,\n SpeedState\n>;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","const rules: (blockClass: string) => string[] = (blockClass: string) => [\n `.${blockClass} { background: currentColor }`,\n 'noscript { display: none !important; }',\n];\n\nexport default rules;\n","import { INode } from 'rrweb-snapshot';\n\nexport enum StyleRuleType {\n Insert,\n Remove,\n Snapshot,\n SetProperty,\n RemoveProperty,\n}\n\ntype InsertRule = {\n cssText: string;\n type: StyleRuleType.Insert;\n index?: number | number[];\n};\ntype RemoveRule = {\n type: StyleRuleType.Remove;\n index: number | number[];\n};\ntype SnapshotRule = {\n type: StyleRuleType.Snapshot;\n cssTexts: string[];\n};\ntype SetPropertyRule = {\n type: StyleRuleType.SetProperty;\n index: number[];\n property: string;\n value: string | null;\n priority: string | undefined;\n};\ntype RemovePropertyRule = {\n type: StyleRuleType.RemoveProperty;\n index: number[];\n property: string;\n};\n\nexport type VirtualStyleRules = Array<\n InsertRule | RemoveRule | SnapshotRule | SetPropertyRule | RemovePropertyRule\n>;\nexport type VirtualStyleRulesMap = Map;\n\nexport function getNestedRule(\n rules: CSSRuleList,\n position: number[],\n): CSSGroupingRule {\n const rule = rules[position[0]] as CSSGroupingRule;\n if (position.length === 1) {\n return rule;\n } else {\n return getNestedRule(\n ((rule as CSSGroupingRule).cssRules[position[1]] as CSSGroupingRule)\n .cssRules,\n position.slice(2),\n );\n }\n}\n\nexport function getPositionsAndIndex(nestedIndex: number[]) {\n const positions = [...nestedIndex];\n const index = positions.pop();\n return { positions, index };\n}\n\nexport function applyVirtualStyleRulesToNode(\n storedRules: VirtualStyleRules,\n styleNode: HTMLStyleElement,\n) {\n const { sheet } = styleNode;\n if (!sheet) {\n // styleNode without sheet means the DOM has been removed\n // so the rules no longer need to be applied\n return;\n }\n\n storedRules.forEach((rule) => {\n if (rule.type === StyleRuleType.Insert) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.insertRule(rule.cssText, index);\n } else {\n sheet.insertRule(rule.cssText, rule.index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n } else if (rule.type === StyleRuleType.Remove) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.deleteRule(index || 0);\n } else {\n sheet.deleteRule(rule.index);\n }\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else if (rule.type === StyleRuleType.Snapshot) {\n restoreSnapshotOfStyleRulesToNode(rule.cssTexts, styleNode);\n } else if (rule.type === StyleRuleType.SetProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.setProperty(rule.property, rule.value, rule.priority);\n } else if (rule.type === StyleRuleType.RemoveProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.removeProperty(rule.property);\n }\n });\n}\n\nfunction restoreSnapshotOfStyleRulesToNode(\n cssTexts: string[],\n styleNode: HTMLStyleElement,\n) {\n try {\n const existingRules = Array.from(styleNode.sheet?.cssRules || []).map(\n (rule) => rule.cssText,\n );\n const existingRulesReversed = Object.entries(existingRules).reverse();\n let lastMatch = existingRules.length;\n existingRulesReversed.forEach(([index, rule]) => {\n const indexOf = cssTexts.indexOf(rule);\n if (indexOf === -1 || indexOf > lastMatch) {\n try {\n styleNode.sheet?.deleteRule(Number(index));\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n }\n lastMatch = indexOf;\n });\n cssTexts.forEach((cssText, index) => {\n try {\n if (styleNode.sheet?.cssRules[index]?.cssText !== cssText) {\n styleNode.sheet?.insertRule(cssText, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n });\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n\nexport function storeCSSRules(\n parentElement: HTMLStyleElement,\n virtualStyleRulesMap: VirtualStyleRulesMap,\n) {\n try {\n const cssTexts = Array.from(\n (parentElement as HTMLStyleElement).sheet?.cssRules || [],\n ).map((rule) => rule.cssText);\n virtualStyleRulesMap.set((parentElement as unknown) as INode, [\n {\n type: StyleRuleType.Snapshot,\n cssTexts,\n },\n ]);\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { decode } from 'base64-arraybuffer';\nimport { Replayer } from '../';\nimport {\n CanvasContext,\n canvasMutationCommand,\n SerializedWebGlArg,\n} from '../../types';\n\n// TODO: add ability to wipe this list\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nfunction getContext(\n target: HTMLCanvasElement,\n type: CanvasContext,\n): WebGLRenderingContext | WebGL2RenderingContext | null {\n // Note to whomever is going to implement support for `contextAttributes`:\n // if `preserveDrawingBuffer` is set to true,\n // you might have to do `ctx.flush()` before every webgl canvas event\n try {\n if (type === CanvasContext.WebGL) {\n return (\n target.getContext('webgl')! || target.getContext('experimental-webgl')\n );\n }\n return target.getContext('webgl2')!;\n } catch (e) {\n return null;\n }\n}\n\nconst WebGLVariableConstructorsNames = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n];\n\nfunction saveToWebGLVarMap(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n result: any,\n) {\n if (!result?.constructor) return; // probably null or undefined\n\n const { name } = result.constructor;\n if (!WebGLVariableConstructorsNames.includes(name)) return; // not a WebGL variable\n\n const variables = variableListFor(ctx, name);\n if (!variables.includes(result)) variables.push(result);\n}\n\nexport function deserializeArg(\n imageMap: Replayer['imageMap'],\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n): (arg: SerializedWebGlArg) => any {\n return (arg: SerializedWebGlArg): any => {\n if (arg && typeof arg === 'object' && 'rr_type' in arg) {\n if ('index' in arg) {\n const { rr_type: name, index } = arg;\n return variableListFor(ctx, name)[index];\n } else if ('args' in arg) {\n const { rr_type: name, args } = arg;\n const ctor = window[name as keyof Window];\n\n return new ctor(...args.map(deserializeArg(imageMap, ctx)));\n } else if ('base64' in arg) {\n return decode(arg.base64);\n } else if ('src' in arg) {\n const image = imageMap.get(arg.src);\n if (image) {\n return image;\n } else {\n const image = new Image();\n image.src = arg.src;\n imageMap.set(arg.src, image);\n return image;\n }\n }\n } else if (Array.isArray(arg)) {\n return arg.map(deserializeArg(imageMap, ctx));\n }\n return arg;\n };\n}\n\nexport default function webglMutation({\n mutation,\n target,\n type,\n imageMap,\n errorHandler,\n}: {\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n type: CanvasContext;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = getContext(target, type);\n if (!ctx) return;\n\n // NOTE: if `preserveDrawingBuffer` is set to true,\n // we must flush the buffers on every new canvas event\n // if (mutation.newFrame) ctx.flush();\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n const args = mutation.args.map(deserializeArg(imageMap, ctx));\n const result = original.apply(ctx, args);\n saveToWebGLVarMap(ctx, result);\n\n // Slows down replay considerably, only use for debugging\n const debugMode = false;\n if (debugMode) {\n if (mutation.property === 'compileShader') {\n if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getShaderInfoLog(args[0]),\n );\n } else if (mutation.property === 'linkProgram') {\n ctx.validateProgram(args[0]);\n if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getProgramInfoLog(args[0]),\n );\n }\n const webglError = ctx.getError();\n if (webglError !== ctx.NO_ERROR) {\n console.warn(\n 'WEBGL ERROR',\n webglError,\n 'on command:',\n mutation.property,\n ...args,\n );\n }\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import {\n rebuild,\n buildNodeWithSN,\n INode,\n NodeType,\n BuildCache,\n createCache,\n} from 'rrweb-snapshot';\nimport * as mittProxy from 'mitt';\nimport { polyfill as smoothscrollPolyfill } from './smoothscroll';\nimport { Timer } from './timer';\nimport { createPlayerService, createSpeedService } from './machine';\nimport {\n EventType,\n IncrementalSource,\n fullSnapshotEvent,\n eventWithTime,\n MouseInteractions,\n playerConfig,\n playerMetaData,\n viewportResizeDimension,\n missingNodeMap,\n addedNodeMutation,\n missingNode,\n incrementalSnapshotEvent,\n incrementalData,\n ReplayerEvents,\n Handler,\n Emitter,\n MediaInteractions,\n metaEvent,\n mutationData,\n scrollData,\n inputData,\n canvasMutationData,\n Mirror,\n ElementState,\n styleAttributeValue,\n styleValueWithPriority,\n mouseMovePos,\n IWindow,\n canvasMutationCommand,\n textMutation,\n} from '../types';\nimport {\n createMirror,\n polyfill,\n TreeIndex,\n queueToResolveTrees,\n iterateResolveTree,\n AppendedIframe,\n isIframeINode,\n getBaseDimension,\n hasShadowRoot,\n} from '../utils';\nimport getInjectStyleRules from './styles/inject-style';\nimport './styles/style.css';\nimport {\n applyVirtualStyleRulesToNode,\n storeCSSRules,\n StyleRuleType,\n VirtualStyleRules,\n VirtualStyleRulesMap,\n getNestedRule,\n getPositionsAndIndex,\n} from './virtual-styles';\nimport canvasMutation from './canvas';\n\nconst SKIP_TIME_THRESHOLD = 10 * 1000;\nconst SKIP_TIME_INTERVAL = 5 * 1000;\n\n// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734\n// tslint:disable-next-line\nconst mitt = (mittProxy as any).default || mittProxy;\n\nconst REPLAY_CONSOLE_PREFIX = '[replayer]';\n\nconst defaultMouseTailConfig = {\n duration: 500,\n lineCap: 'round',\n lineWidth: 3,\n strokeStyle: 'red',\n} as const;\n\nfunction indicatesTouchDevice(e: eventWithTime) {\n return (\n e.type == EventType.IncrementalSnapshot &&\n (e.data.source == IncrementalSource.TouchMove ||\n (e.data.source == IncrementalSource.MouseInteraction &&\n e.data.type == MouseInteractions.TouchStart))\n );\n}\n\nexport class Replayer {\n public wrapper: HTMLDivElement;\n public iframe: HTMLIFrameElement;\n\n public service: ReturnType;\n public speedService: ReturnType;\n public get timer() {\n return this.service.state.context.timer;\n }\n\n public config: playerConfig;\n\n private mouse: HTMLDivElement;\n private mouseTail: HTMLCanvasElement | null = null;\n private tailPositions: Array<{ x: number; y: number }> = [];\n\n private emitter: Emitter = mitt();\n\n private nextUserInteractionEvent: eventWithTime | null;\n\n // tslint:disable-next-line: variable-name\n private legacy_missingNodeRetryMap: missingNodeMap = {};\n\n private treeIndex!: TreeIndex;\n private fragmentParentMap!: Map;\n private elementStateMap!: Map;\n // Hold the list of CSSRules for in-memory state restoration\n private virtualStyleRulesMap!: VirtualStyleRulesMap;\n\n // The replayer uses the cache to speed up replay and scrubbing.\n private cache: BuildCache = createCache();\n\n private imageMap: Map = new Map();\n\n private mirror: Mirror = createMirror();\n\n private firstFullSnapshot: eventWithTime | true | null = null;\n\n private newDocumentQueue: addedNodeMutation[] = [];\n\n private mousePos: mouseMovePos | null = null;\n private touchActive: boolean | null = null;\n\n constructor(\n events: Array,\n config?: Partial,\n ) {\n if (!config?.liveMode && events.length < 2) {\n throw new Error('Replayer need at least 2 events.');\n }\n const defaultConfig: playerConfig = {\n speed: 1,\n maxSpeed: 360,\n root: document.body,\n loadTimeout: 0,\n skipInactive: false,\n showWarning: true,\n showDebug: false,\n blockClass: 'rr-block',\n liveMode: false,\n insertStyleRules: [],\n triggerFocus: true,\n UNSAFE_replayCanvas: false,\n pauseAnimation: true,\n mouseTail: defaultMouseTailConfig,\n };\n this.config = Object.assign({}, defaultConfig, config);\n\n this.handleResize = this.handleResize.bind(this);\n this.getCastFn = this.getCastFn.bind(this);\n this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);\n this.emitter.on(ReplayerEvents.Resize, this.handleResize as Handler);\n\n this.setupDom();\n\n this.treeIndex = new TreeIndex();\n this.fragmentParentMap = new Map();\n this.elementStateMap = new Map();\n this.virtualStyleRulesMap = new Map();\n\n this.emitter.on(ReplayerEvents.Flush, () => {\n const { scrollMap, inputMap, mutationData } = this.treeIndex.flush();\n\n this.fragmentParentMap.forEach((parent, frag) =>\n this.restoreRealParent(frag, parent),\n );\n // apply text needs to happen before virtual style rules gets applied\n // as it can overwrite the contents of a stylesheet\n for (const d of mutationData.texts) {\n this.applyText(d, mutationData);\n }\n\n for (const node of this.virtualStyleRulesMap.keys()) {\n // restore css rules of style elements after they are mounted\n this.restoreNodeSheet(node);\n }\n this.fragmentParentMap.clear();\n this.elementStateMap.clear();\n this.virtualStyleRulesMap.clear();\n\n for (const d of scrollMap.values()) {\n this.applyScroll(d, true);\n }\n for (const d of inputMap.values()) {\n this.applyInput(d);\n }\n });\n this.emitter.on(ReplayerEvents.PlayBack, () => {\n this.firstFullSnapshot = null;\n this.mirror.reset();\n });\n\n const timer = new Timer([], config?.speed || defaultConfig.speed);\n this.service = createPlayerService(\n {\n events: events\n .map((e) => {\n if (config && config.unpackFn) {\n return config.unpackFn(e as string);\n }\n return e as eventWithTime;\n })\n .sort((a1, a2) => a1.timestamp - a2.timestamp),\n timer,\n timeOffset: 0,\n baselineTime: 0,\n lastPlayedEvent: null,\n },\n {\n getCastFn: this.getCastFn,\n applyEventsSynchronously: this.applyEventsSynchronously,\n emitter: this.emitter,\n },\n );\n this.service.start();\n this.service.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n player: state,\n });\n });\n this.speedService = createSpeedService({\n normalSpeed: -1,\n timer,\n });\n this.speedService.start();\n this.speedService.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n speed: state,\n });\n });\n\n // rebuild first full snapshot as the poster of the player\n // maybe we can cache it for performance optimization\n const firstMeta = this.service.state.context.events.find(\n (e) => e.type === EventType.Meta,\n );\n const firstFullsnapshot = this.service.state.context.events.find(\n (e) => e.type === EventType.FullSnapshot,\n );\n if (firstMeta) {\n const { width, height } = firstMeta.data as metaEvent['data'];\n setTimeout(() => {\n this.emitter.emit(ReplayerEvents.Resize, {\n width,\n height,\n });\n }, 0);\n }\n if (firstFullsnapshot) {\n setTimeout(() => {\n // when something has been played, there is no need to rebuild poster\n if (this.firstFullSnapshot) {\n // true if any other fullSnapshot has been executed by Timer already\n return;\n }\n this.firstFullSnapshot = firstFullsnapshot;\n this.rebuildFullSnapshot(\n firstFullsnapshot as fullSnapshotEvent & { timestamp: number },\n );\n this.iframe.contentWindow!.scrollTo(\n (firstFullsnapshot as fullSnapshotEvent).data.initialOffset,\n );\n }, 1);\n }\n if (this.service.state.context.events.find(indicatesTouchDevice)) {\n this.mouse.classList.add('touch-device');\n }\n }\n\n public on(event: string, handler: Handler) {\n this.emitter.on(event, handler);\n return this;\n }\n\n public off(event: string, handler: Handler) {\n this.emitter.off(event, handler);\n return this;\n }\n\n public setConfig(config: Partial) {\n Object.keys(config).forEach((key) => {\n // @ts-ignore\n this.config[key] = config[key];\n });\n if (!this.config.skipInactive) {\n this.backToNormal();\n }\n if (typeof config.speed !== 'undefined') {\n this.speedService.send({\n type: 'SET_SPEED',\n payload: {\n speed: config.speed!,\n },\n });\n }\n if (typeof config.mouseTail !== 'undefined') {\n if (config.mouseTail === false) {\n if (this.mouseTail) {\n this.mouseTail.style.display = 'none';\n }\n } else {\n if (!this.mouseTail) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.width = Number.parseFloat(this.iframe.width);\n this.mouseTail.height = Number.parseFloat(this.iframe.height);\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.wrapper.insertBefore(this.mouseTail, this.iframe);\n }\n this.mouseTail.style.display = 'inherit';\n }\n }\n }\n\n public getMetaData(): playerMetaData {\n const firstEvent = this.service.state.context.events[0];\n const lastEvent = this.service.state.context.events[\n this.service.state.context.events.length - 1\n ];\n return {\n startTime: firstEvent.timestamp,\n endTime: lastEvent.timestamp,\n totalTime: lastEvent.timestamp - firstEvent.timestamp,\n };\n }\n\n public getCurrentTime(): number {\n return this.timer.timeOffset + this.getTimeOffset();\n }\n\n public getTimeOffset(): number {\n const { baselineTime, events } = this.service.state.context;\n return baselineTime - events[0].timestamp;\n }\n\n public getMirror(): Mirror {\n return this.mirror;\n }\n\n /**\n * This API was designed to be used as play at any time offset.\n * Since we minimized the data collected from recorder, we do not\n * have the ability of undo an event.\n * So the implementation of play at any time offset will always iterate\n * all of the events, cast event before the offset synchronously\n * and cast event after the offset asynchronously with timer.\n * @param timeOffset number\n */\n public play(timeOffset = 0) {\n if (this.service.state.matches('paused')) {\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n } else {\n this.service.send({ type: 'PAUSE' });\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.remove('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Start);\n }\n\n public pause(timeOffset?: number) {\n if (timeOffset === undefined && this.service.state.matches('playing')) {\n this.service.send({ type: 'PAUSE' });\n }\n if (typeof timeOffset === 'number') {\n this.play(timeOffset);\n this.service.send({ type: 'PAUSE' });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Pause);\n }\n\n public resume(timeOffset = 0) {\n console.warn(\n `The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.`,\n );\n this.play(timeOffset);\n this.emitter.emit(ReplayerEvents.Resume);\n }\n\n public startLive(baselineTime?: number) {\n this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });\n }\n\n public addEvent(rawEvent: eventWithTime | string) {\n const event = this.config.unpackFn\n ? this.config.unpackFn(rawEvent as string)\n : (rawEvent as eventWithTime);\n if (indicatesTouchDevice(event)) {\n this.mouse.classList.add('touch-device');\n }\n Promise.resolve().then(() =>\n this.service.send({ type: 'ADD_EVENT', payload: { event } }),\n );\n }\n\n public enableInteract() {\n this.iframe.setAttribute('scrolling', 'auto');\n this.iframe.style.pointerEvents = 'auto';\n }\n\n public disableInteract() {\n this.iframe.setAttribute('scrolling', 'no');\n this.iframe.style.pointerEvents = 'none';\n }\n\n /**\n * Empties the replayer's cache and reclaims memory.\n * The replayer will use this cache to speed up the playback.\n */\n public resetCache() {\n this.cache = createCache();\n }\n\n private setupDom() {\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add('replayer-wrapper');\n this.config.root!.appendChild(this.wrapper);\n\n this.mouse = document.createElement('div');\n this.mouse.classList.add('replayer-mouse');\n this.wrapper.appendChild(this.mouse);\n\n if (this.config.mouseTail !== false) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.mouseTail.style.display = 'inherit';\n this.wrapper.appendChild(this.mouseTail);\n }\n\n this.iframe = document.createElement('iframe');\n const attributes = ['allow-same-origin'];\n if (this.config.UNSAFE_replayCanvas) {\n attributes.push('allow-scripts');\n }\n // hide iframe before first meta event\n this.iframe.style.display = 'none';\n this.iframe.setAttribute('sandbox', attributes.join(' '));\n this.disableInteract();\n this.wrapper.appendChild(this.iframe);\n if (this.iframe.contentWindow && this.iframe.contentDocument) {\n smoothscrollPolyfill(\n this.iframe.contentWindow,\n this.iframe.contentDocument,\n );\n\n polyfill(this.iframe.contentWindow as IWindow);\n }\n }\n\n private handleResize(dimension: viewportResizeDimension) {\n this.iframe.style.display = 'inherit';\n for (const el of [this.mouseTail, this.iframe]) {\n if (!el) {\n continue;\n }\n el.setAttribute('width', String(dimension.width));\n el.setAttribute('height', String(dimension.height));\n }\n }\n\n private applyEventsSynchronously(events: Array) {\n for (const event of events) {\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n case EventType.Custom:\n continue;\n case EventType.FullSnapshot:\n case EventType.Meta:\n case EventType.Plugin:\n break;\n case EventType.IncrementalSnapshot:\n switch (event.data.source) {\n case IncrementalSource.MediaInteraction:\n continue;\n default:\n break;\n }\n break;\n default:\n break;\n }\n const castFn = this.getCastFn(event, true);\n castFn();\n }\n if (this.mousePos) {\n this.moveAndHover(\n this.mousePos.x,\n this.mousePos.y,\n this.mousePos.id,\n true,\n this.mousePos.debugData,\n );\n }\n this.mousePos = null;\n if (this.touchActive === true) {\n this.mouse.classList.add('touch-active');\n } else if (this.touchActive === false) {\n this.mouse.classList.remove('touch-active');\n }\n this.touchActive = null;\n }\n\n private getCastFn(event: eventWithTime, isSync = false) {\n let castFn: undefined | (() => void);\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n break;\n case EventType.Custom:\n castFn = () => {\n /**\n * emit custom-event and pass the event object.\n *\n * This will add more value to the custom event and allows the client to react for custom-event.\n */\n this.emitter.emit(ReplayerEvents.CustomEvent, event);\n };\n break;\n case EventType.Meta:\n castFn = () =>\n this.emitter.emit(ReplayerEvents.Resize, {\n width: event.data.width,\n height: event.data.height,\n });\n break;\n case EventType.FullSnapshot:\n castFn = () => {\n if (this.firstFullSnapshot) {\n if (this.firstFullSnapshot === event) {\n // we've already built this exact FullSnapshot when the player was mounted, and haven't built any other FullSnapshot since\n this.firstFullSnapshot = true; // forget as we might need to re-execute this FullSnapshot later e.g. to rebuild after scrubbing\n return;\n }\n } else {\n // Timer (requestAnimationFrame) can be faster than setTimeout(..., 1)\n this.firstFullSnapshot = true;\n }\n this.rebuildFullSnapshot(event, isSync);\n this.iframe.contentWindow!.scrollTo(event.data.initialOffset);\n };\n break;\n case EventType.IncrementalSnapshot:\n castFn = () => {\n this.applyIncremental(event, isSync);\n if (isSync) {\n // do not check skip in sync\n return;\n }\n if (event === this.nextUserInteractionEvent) {\n this.nextUserInteractionEvent = null;\n this.backToNormal();\n }\n if (this.config.skipInactive && !this.nextUserInteractionEvent) {\n for (const _event of this.service.state.context.events) {\n if (_event.timestamp! <= event.timestamp!) {\n continue;\n }\n if (this.isUserInteraction(_event)) {\n if (\n _event.delay! - event.delay! >\n SKIP_TIME_THRESHOLD *\n this.speedService.state.context.timer.speed\n ) {\n this.nextUserInteractionEvent = _event;\n }\n break;\n }\n }\n if (this.nextUserInteractionEvent) {\n const skipTime =\n this.nextUserInteractionEvent.delay! - event.delay!;\n const payload = {\n speed: Math.min(\n Math.round(skipTime / SKIP_TIME_INTERVAL),\n this.config.maxSpeed,\n ),\n };\n this.speedService.send({ type: 'FAST_FORWARD', payload });\n this.emitter.emit(ReplayerEvents.SkipStart, payload);\n }\n }\n };\n break;\n default:\n }\n const wrappedCastFn = () => {\n if (castFn) {\n castFn();\n }\n\n for (const plugin of this.config.plugins || []) {\n plugin.handler(event, isSync, { replayer: this });\n }\n\n this.service.send({ type: 'CAST_EVENT', payload: { event } });\n\n // events are kept sorted by timestamp, check if this is the last event\n let last_index = this.service.state.context.events.length - 1;\n if (event === this.service.state.context.events[last_index]) {\n const finish = () => {\n if (last_index < this.service.state.context.events.length - 1) {\n // more events have been added since the setTimeout\n return;\n }\n this.backToNormal();\n this.service.send('END');\n this.emitter.emit(ReplayerEvents.Finish);\n };\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove &&\n event.data.positions.length\n ) {\n // defer finish event if the last event is a mouse move\n setTimeout(() => {\n finish();\n }, Math.max(0, -event.data.positions[0].timeOffset + 50)); // Add 50 to make sure the timer would check the last mousemove event. Otherwise, the timer may be stopped by the service before checking the last event.\n } else {\n finish();\n }\n }\n\n this.emitter.emit(ReplayerEvents.EventCast, event);\n };\n return wrappedCastFn;\n }\n\n private rebuildFullSnapshot(\n event: fullSnapshotEvent & { timestamp: number },\n isSync: boolean = false,\n ) {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n console.warn(\n 'Found unresolved missing node map',\n this.legacy_missingNodeRetryMap,\n );\n }\n this.legacy_missingNodeRetryMap = {};\n const collected: AppendedIframe[] = [];\n this.mirror.map = rebuild(event.data.node, {\n doc: this.iframe.contentDocument,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n },\n cache: this.cache,\n })[1];\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n const { documentElement, head } = this.iframe.contentDocument;\n this.insertStyleRules(documentElement, head);\n if (!this.service.state.matches('playing')) {\n this.iframe.contentDocument\n .getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n }\n this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);\n if (!isSync) {\n this.waitForStylesheetLoad();\n }\n if (this.config.UNSAFE_replayCanvas) {\n this.preloadAllImages();\n }\n }\n\n private insertStyleRules(\n documentElement: HTMLElement,\n head: HTMLHeadElement,\n ) {\n const styleEl = document.createElement('style');\n documentElement!.insertBefore(styleEl, head);\n const injectStylesRules = getInjectStyleRules(\n this.config.blockClass,\n ).concat(this.config.insertStyleRules);\n if (this.config.pauseAnimation) {\n injectStylesRules.push(\n 'html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }',\n );\n }\n for (let idx = 0; idx < injectStylesRules.length; idx++) {\n (styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);\n }\n }\n\n private attachDocumentToIframe(\n mutation: addedNodeMutation,\n iframeEl: HTMLIFrameElement,\n ) {\n const collected: AppendedIframe[] = [];\n // If iframeEl is detached from dom, iframeEl.contentDocument is null.\n if (!iframeEl.contentDocument) {\n let parent = iframeEl.parentNode;\n while (parent) {\n // The parent of iframeEl is virtual parent and we need to mount it on the dom.\n if (this.fragmentParentMap.has((parent as unknown) as INode)) {\n const frag = (parent as unknown) as INode;\n const realParent = this.fragmentParentMap.get(frag)!;\n this.restoreRealParent(frag, realParent);\n break;\n }\n parent = parent.parentNode;\n }\n }\n buildNodeWithSN(mutation.node, {\n doc: iframeEl.contentDocument!,\n map: this.mirror.map,\n hackCss: true,\n skipChild: false,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n if (\n builtNode.__sn.type === NodeType.Element &&\n builtNode.__sn.tagName.toUpperCase() === 'HTML'\n ) {\n const { documentElement, head } = iframeEl.contentDocument!;\n this.insertStyleRules(documentElement, head);\n }\n },\n cache: this.cache,\n });\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n private collectIframeAndAttachDocument(\n collected: AppendedIframe[],\n builtNode: INode,\n ) {\n if (isIframeINode(builtNode)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === builtNode.__sn.id,\n );\n if (mutationInQueue) {\n collected.push({ mutationInQueue, builtNode });\n }\n }\n }\n\n /**\n * pause when loading style sheet, resume when loaded all timeout exceed\n */\n private waitForStylesheetLoad() {\n const head = this.iframe.contentDocument?.head;\n if (head) {\n const unloadSheets: Set = new Set();\n let timer: ReturnType | -1;\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n const unsubscribe = () => {\n this.emitter.off(ReplayerEvents.Start, stateHandler);\n this.emitter.off(ReplayerEvents.Pause, stateHandler);\n };\n head\n .querySelectorAll('link[rel=\"stylesheet\"]')\n .forEach((css: HTMLLinkElement) => {\n if (!css.sheet) {\n unloadSheets.add(css);\n css.addEventListener('load', () => {\n unloadSheets.delete(css);\n // all loaded and timer not released yet\n if (unloadSheets.size === 0 && timer !== -1) {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);\n if (timer) {\n clearTimeout(timer);\n }\n unsubscribe();\n }\n });\n }\n });\n\n if (unloadSheets.size > 0) {\n // find some unload sheets after iterate\n this.service.send({ type: 'PAUSE' });\n this.emitter.emit(ReplayerEvents.LoadStylesheetStart);\n timer = setTimeout(() => {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n // mark timer was called\n timer = -1;\n unsubscribe();\n }, this.config.loadTimeout);\n }\n }\n }\n\n private hasImageArg(args: any[]): boolean {\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n if (this.hasImageArg(arg.args)) return true;\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n return true; // has image!\n } else if (arg instanceof Array) {\n if (this.hasImageArg(arg)) return true;\n }\n }\n return false;\n }\n\n private getImageArgs(args: any[]): string[] {\n const images: string[] = [];\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n images.push(...this.getImageArgs(arg.args));\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n images.push(arg.src);\n } else if (arg instanceof Array) {\n images.push(...this.getImageArgs(arg));\n }\n }\n return images;\n }\n\n /**\n * pause when there are some canvas drawImage args need to be loaded\n */\n private preloadAllImages() {\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n for (const event of this.service.state.context.events) {\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.CanvasMutation\n )\n if ('commands' in event.data) {\n event.data.commands.forEach((c) => this.preloadImages(c, event));\n } else {\n this.preloadImages(event.data, event);\n }\n }\n }\n\n private preloadImages(data: canvasMutationCommand, event: eventWithTime) {\n if (\n data.property === 'drawImage' &&\n typeof data.args[0] === 'string' &&\n !this.imageMap.has(event)\n ) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const imgd = ctx?.createImageData(canvas.width, canvas.height);\n let d = imgd?.data;\n d = JSON.parse(data.args[0]);\n ctx?.putImageData(imgd!, 0, 0);\n } else if (this.hasImageArg(data.args)) {\n this.getImageArgs(data.args).forEach((url) => {\n const image = new Image();\n image.src = url; // this preloads the image\n this.imageMap.set(url, image);\n });\n }\n }\n\n private applyIncremental(\n e: incrementalSnapshotEvent & { timestamp: number; delay?: number },\n isSync: boolean,\n ) {\n const { data: d } = e;\n switch (d.source) {\n case IncrementalSource.Mutation: {\n if (isSync) {\n d.adds.forEach((m) => this.treeIndex.add(m));\n d.texts.forEach((m) => {\n const target = this.mirror.getNode(m.id);\n const parent = (target?.parentNode as unknown) as INode | null;\n // remove any style rules that pending\n // for stylesheets where the contents get replaced\n if (parent && this.virtualStyleRulesMap.has(parent))\n this.virtualStyleRulesMap.delete(parent);\n\n this.treeIndex.text(m);\n });\n d.attributes.forEach((m) => this.treeIndex.attribute(m));\n d.removes.forEach((m) => this.treeIndex.remove(m, this.mirror));\n }\n try {\n this.applyMutation(d, isSync);\n } catch (error) {\n this.warn(`Exception in mutation ${error.message || error}`, d);\n }\n break;\n }\n case IncrementalSource.Drag:\n case IncrementalSource.TouchMove:\n case IncrementalSource.MouseMove:\n if (isSync) {\n const lastPosition = d.positions[d.positions.length - 1];\n this.mousePos = {\n x: lastPosition.x,\n y: lastPosition.y,\n id: lastPosition.id,\n debugData: d,\n };\n } else {\n d.positions.forEach((p) => {\n const action = {\n doAction: () => {\n this.moveAndHover(p.x, p.y, p.id, isSync, d);\n },\n delay:\n p.timeOffset +\n e.timestamp -\n this.service.state.context.baselineTime,\n };\n this.timer.addAction(action);\n });\n // add a dummy action to keep timer alive\n this.timer.addAction({\n doAction() {},\n delay: e.delay! - d.positions[0]?.timeOffset,\n });\n }\n break;\n case IncrementalSource.MouseInteraction: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n const event = new Event(MouseInteractions[d.type].toLowerCase());\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n this.emitter.emit(ReplayerEvents.MouseInteraction, {\n type: d.type,\n target,\n });\n const { triggerFocus } = this.config;\n switch (d.type) {\n case MouseInteractions.Blur:\n if ('blur' in ((target as Node) as HTMLElement)) {\n ((target as Node) as HTMLElement).blur();\n }\n break;\n case MouseInteractions.Focus:\n if (triggerFocus && ((target as Node) as HTMLElement).focus) {\n ((target as Node) as HTMLElement).focus({\n preventScroll: true,\n });\n }\n break;\n case MouseInteractions.Click:\n case MouseInteractions.TouchStart:\n case MouseInteractions.TouchEnd:\n if (isSync) {\n if (d.type === MouseInteractions.TouchStart) {\n this.touchActive = true;\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.touchActive = false;\n }\n this.mousePos = {\n x: d.x,\n y: d.y,\n id: d.id,\n debugData: d,\n };\n } else {\n if (d.type === MouseInteractions.TouchStart) {\n // don't draw a trail as user has lifted finger and is placing at a new point\n this.tailPositions.length = 0;\n }\n this.moveAndHover(d.x, d.y, d.id, isSync, d);\n if (d.type === MouseInteractions.Click) {\n /*\n * don't want target.click() here as could trigger an iframe navigation\n * instead any effects of the click should already be covered by mutations\n */\n /*\n * removal and addition of .active class (along with void line to trigger repaint)\n * triggers the 'click' css animation in styles/style.css\n */\n this.mouse.classList.remove('active');\n // tslint:disable-next-line\n void this.mouse.offsetWidth;\n this.mouse.classList.add('active');\n } else if (d.type === MouseInteractions.TouchStart) {\n void this.mouse.offsetWidth; // needed for the position update of moveAndHover to apply without the .touch-active transition\n this.mouse.classList.add('touch-active');\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.mouse.classList.remove('touch-active');\n }\n }\n break;\n case MouseInteractions.TouchCancel:\n if (isSync) {\n this.touchActive = false;\n } else {\n this.mouse.classList.remove('touch-active');\n }\n break;\n default:\n target.dispatchEvent(event);\n }\n break;\n }\n case IncrementalSource.Scroll: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.scroll(d);\n break;\n }\n this.applyScroll(d, false);\n break;\n }\n case IncrementalSource.ViewportResize:\n this.emitter.emit(ReplayerEvents.Resize, {\n width: d.width,\n height: d.height,\n });\n break;\n case IncrementalSource.Input: {\n /**\n * Input event on an unserialized node usually means the event\n * was synchrony triggered programmatically after the node was\n * created. This means there was not an user observable interaction\n * and we do not need to replay it.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.input(d);\n break;\n }\n this.applyInput(d);\n break;\n }\n case IncrementalSource.MediaInteraction: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n const mediaEl = (target as Node) as HTMLMediaElement;\n try {\n if (d.currentTime) {\n mediaEl.currentTime = d.currentTime;\n }\n if (d.volume) {\n mediaEl.volume = d.volume;\n }\n if (d.muted) {\n mediaEl.muted = d.muted;\n }\n if (d.type === MediaInteractions.Pause) {\n mediaEl.pause();\n }\n if (d.type === MediaInteractions.Play) {\n // remove listener for 'canplay' event because play() is async and returns a promise\n // i.e. media will evntualy start to play when data is loaded\n // 'canplay' event fires even when currentTime attribute changes which may lead to\n // unexpeted behavior\n mediaEl.play();\n }\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n `Failed to replay media interactions: ${error.message || error}`,\n );\n }\n }\n break;\n }\n case IncrementalSource.StyleSheetRule: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n /**\n * Always use existing DOM node, when it's there.\n * In in-memory replay, there is virtual node, but it's `sheet` is inaccessible.\n * Hence, we buffer all style changes in virtualStyleRulesMap.\n */\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules;\n\n if (!styleSheet) {\n /**\n * styleEl.sheet is only accessible if the styleEl is part of the\n * dom. This doesn't work on DocumentFragments so we have to add the\n * style mutations to the virtualStyleRulesMap.\n */\n\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.adds) {\n d.adds.forEach(({ rule, index: nestedIndex }) => {\n if (styleSheet) {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet.cssRules,\n positions,\n );\n nestedRule.insertRule(rule, index);\n } else {\n const index =\n nestedIndex === undefined\n ? undefined\n : Math.min(nestedIndex, styleSheet.cssRules.length);\n styleSheet.insertRule(rule, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else {\n rules?.push({\n cssText: rule,\n index: nestedIndex,\n type: StyleRuleType.Insert,\n });\n }\n });\n }\n\n if (d.removes) {\n d.removes.forEach(({ index: nestedIndex }) => {\n if (usingVirtualParent) {\n rules?.push({ index: nestedIndex, type: StyleRuleType.Remove });\n } else {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet!.cssRules,\n positions,\n );\n nestedRule.deleteRule(index || 0);\n } else {\n styleSheet?.deleteRule(nestedIndex);\n }\n } catch (e) {\n /**\n * same as insertRule\n */\n }\n }\n });\n }\n break;\n }\n case IncrementalSource.StyleDeclaration: {\n // same with StyleSheetRule\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules = [];\n\n if (!styleSheet) {\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.set) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.setProperty(d.set.property, d.set.value, d.set.priority);\n } else {\n rules.push({\n type: StyleRuleType.SetProperty,\n index: d.index,\n ...d.set,\n });\n }\n }\n\n if (d.remove) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.removeProperty(d.remove.property);\n } else {\n rules.push({\n type: StyleRuleType.RemoveProperty,\n index: d.index,\n ...d.remove,\n });\n }\n }\n break;\n }\n case IncrementalSource.CanvasMutation: {\n if (!this.config.UNSAFE_replayCanvas) {\n return;\n }\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n canvasMutation({\n event: e,\n mutation: d,\n target: (target as unknown) as HTMLCanvasElement,\n imageMap: this.imageMap,\n errorHandler: this.warnCanvasMutationFailed.bind(this),\n });\n\n break;\n }\n case IncrementalSource.Font: {\n try {\n const fontFace = new FontFace(\n d.family,\n d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource,\n d.descriptors,\n );\n this.iframe.contentDocument?.fonts.add(fontFace);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(error);\n }\n }\n break;\n }\n default:\n }\n }\n\n private applyMutation(d: mutationData, useVirtualParent: boolean) {\n d.removes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.parentId)) {\n // no need to warn, parent was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.virtualStyleRulesMap.has(target)) {\n this.virtualStyleRulesMap.delete(target);\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n return this.warnNodeNotFound(d, mutation.parentId);\n }\n if (mutation.isShadow && hasShadowRoot(parent)) {\n parent = parent.shadowRoot;\n }\n // target may be removed with its parents before\n this.mirror.removeNodeFromMap(target);\n if (parent) {\n let realTarget = null;\n const realParent =\n '__sn' in parent ? this.fragmentParentMap.get(parent) : undefined;\n if (realParent && realParent.contains(target)) {\n parent = realParent;\n } else if (this.fragmentParentMap.has(target)) {\n /**\n * the target itself is a fragment document and it's not in the dom\n * so we should remove the real target from its parent\n */\n realTarget = this.fragmentParentMap.get(target)!;\n this.fragmentParentMap.delete(target);\n target = realTarget;\n }\n try {\n parent.removeChild(target);\n } catch (error) {\n if (error instanceof DOMException) {\n this.warn(\n 'parent could not remove child in mutation',\n parent,\n realParent,\n target,\n realTarget,\n d,\n );\n } else {\n throw error;\n }\n }\n }\n });\n\n // tslint:disable-next-line: variable-name\n const legacy_missingNodeMap: missingNodeMap = {\n ...this.legacy_missingNodeRetryMap,\n };\n const queue: addedNodeMutation[] = [];\n\n // next not present at this moment\n const nextNotInDOM = (mutation: addedNodeMutation) => {\n let next: Node | null = null;\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n // next not present at this moment\n if (\n mutation.nextId !== null &&\n mutation.nextId !== undefined &&\n mutation.nextId !== -1 &&\n !next\n ) {\n return true;\n }\n return false;\n };\n\n const appendNode = (mutation: addedNodeMutation) => {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n if (mutation.node.type === NodeType.Document) {\n // is newly added document, maybe the document node of an iframe\n return this.newDocumentQueue.push(mutation);\n }\n return queue.push(mutation);\n }\n\n let parentInDocument = null;\n if (this.iframe.contentDocument.contains) {\n parentInDocument = this.iframe.contentDocument.contains(parent);\n } else if (this.iframe.contentDocument.body.contains) {\n // fix for IE\n // refer 'Internet Explorer notes' at https://developer.mozilla.org/zh-CN/docs/Web/API/Document\n parentInDocument = this.iframe.contentDocument.body.contains(parent);\n }\n\n const hasIframeChild =\n ((parent as unknown) as HTMLElement).getElementsByTagName?.('iframe')\n .length > 0;\n /**\n * Why !isIframeINode(parent)? If parent element is an iframe, iframe document can't be appended to virtual parent.\n * Why !hasIframeChild? If we move iframe elements from dom to fragment document, we will lose the contentDocument of iframe. So we need to disable the virtual dom optimization if a parent node contains iframe elements.\n */\n if (\n useVirtualParent &&\n parentInDocument &&\n !isIframeINode(parent) &&\n !hasIframeChild\n ) {\n const virtualParent = (document.createDocumentFragment() as unknown) as INode;\n this.mirror.map[mutation.parentId] = virtualParent;\n this.fragmentParentMap.set(virtualParent, parent);\n\n // store the state, like scroll position, of child nodes before they are unmounted from dom\n this.storeState(parent);\n\n while (parent.firstChild) {\n virtualParent.appendChild(parent.firstChild);\n }\n parent = virtualParent;\n }\n\n if (mutation.node.isShadow) {\n // If the parent is attached a shadow dom after it's created, it won't have a shadow root.\n if (!hasShadowRoot(parent)) {\n ((parent as Node) as HTMLElement).attachShadow({ mode: 'open' });\n parent = ((parent as Node) as HTMLElement).shadowRoot!;\n } else parent = parent.shadowRoot;\n }\n\n let previous: Node | null = null;\n let next: Node | null = null;\n if (mutation.previousId) {\n previous = this.mirror.getNode(mutation.previousId) as Node;\n }\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n if (nextNotInDOM(mutation)) {\n return queue.push(mutation);\n }\n\n if (mutation.node.rootId && !this.mirror.getNode(mutation.node.rootId)) {\n return;\n }\n\n const targetDoc = mutation.node.rootId\n ? this.mirror.getNode(mutation.node.rootId)\n : this.iframe.contentDocument;\n if (isIframeINode(parent)) {\n this.attachDocumentToIframe(mutation, parent);\n return;\n }\n const target = buildNodeWithSN(mutation.node, {\n doc: targetDoc as Document,\n map: this.mirror.map,\n skipChild: true,\n hackCss: true,\n cache: this.cache,\n }) as INode;\n\n // legacy data, we should not have -1 siblings any more\n if (mutation.previousId === -1 || mutation.nextId === -1) {\n legacy_missingNodeMap[mutation.node.id] = {\n node: target,\n mutation,\n };\n return;\n }\n\n if (\n '__sn' in parent &&\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n mutation.node.type === NodeType.Text\n ) {\n // https://github.com/rrweb-io/rrweb/issues/745\n // parent is textarea, will only keep one child node as the value\n for (const c of Array.from(parent.childNodes)) {\n if (c.nodeType === parent.TEXT_NODE) {\n parent.removeChild(c);\n }\n }\n }\n\n if (previous && previous.nextSibling && previous.nextSibling.parentNode) {\n parent.insertBefore(target, previous.nextSibling);\n } else if (next && next.parentNode) {\n // making sure the parent contains the reference nodes\n // before we insert target before next.\n parent.contains(next)\n ? parent.insertBefore(target, next)\n : parent.insertBefore(target, null);\n } else {\n /**\n * Sometimes the document changes and the MutationObserver is disconnected, so the removal of child elements can't be detected and recorded. After the change of document, we may get another mutation which adds a new html element, while the old html element still exists in the dom, and we need to remove the old html element first to avoid collision.\n */\n if (parent === targetDoc) {\n while (targetDoc.firstChild) {\n targetDoc.removeChild(targetDoc.firstChild);\n }\n }\n\n parent.appendChild(target);\n }\n\n if (isIframeINode(target)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === target.__sn.id,\n );\n if (mutationInQueue) {\n this.attachDocumentToIframe(mutationInQueue, target);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(\n legacy_missingNodeMap,\n parent,\n target,\n mutation,\n );\n }\n };\n\n d.adds.forEach((mutation) => {\n appendNode(mutation);\n });\n\n let startTime = Date.now();\n while (queue.length) {\n // transform queue to resolve tree\n const resolveTrees = queueToResolveTrees(queue);\n queue.length = 0;\n if (Date.now() - startTime > 500) {\n this.warn(\n 'Timeout in the loop, please check the resolve tree data:',\n resolveTrees,\n );\n break;\n }\n for (const tree of resolveTrees) {\n let parent = this.mirror.getNode(tree.value.parentId);\n if (!parent) {\n this.debug(\n 'Drop resolve tree since there is no parent for the root node.',\n tree,\n );\n } else {\n iterateResolveTree(tree, (mutation) => {\n appendNode(mutation);\n });\n }\n }\n }\n\n if (Object.keys(legacy_missingNodeMap).length) {\n Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);\n }\n\n d.texts.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n /**\n * apply text content to real parent directly\n */\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n target.textContent = mutation.value;\n });\n d.attributes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n for (const attributeName in mutation.attributes) {\n if (typeof attributeName === 'string') {\n const value = mutation.attributes[attributeName];\n if (value === null) {\n ((target as Node) as Element).removeAttribute(attributeName);\n } else if (typeof value === 'string') {\n try {\n ((target as Node) as Element).setAttribute(attributeName, value);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n 'An error occurred may due to the checkout feature.',\n error,\n );\n }\n }\n } else if (attributeName === 'style') {\n let styleValues = value as styleAttributeValue;\n const targetEl = (target as Node) as HTMLElement;\n for (var s in styleValues) {\n if (styleValues[s] === false) {\n targetEl.style.removeProperty(s);\n } else if (styleValues[s] instanceof Array) {\n const svp = styleValues[s] as styleValueWithPriority;\n targetEl.style.setProperty(s, svp[0], svp[1]);\n } else {\n const svs = styleValues[s] as string;\n targetEl.style.setProperty(s, svs);\n }\n }\n }\n }\n }\n });\n }\n\n /**\n * Apply the scroll data on real elements.\n * If the replayer is in sync mode, smooth scroll behavior should be disabled.\n * @param d the scroll data\n * @param isSync whether the replayer is in sync mode(fast-forward)\n */\n private applyScroll(d: scrollData, isSync: boolean) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n if ((target as Node) === this.iframe.contentDocument) {\n this.iframe.contentWindow!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else if (target.__sn.type === NodeType.Document) {\n // nest iframe content document\n ((target as unknown) as Document).defaultView!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else {\n try {\n ((target as Node) as Element).scrollTop = d.y;\n ((target as Node) as Element).scrollLeft = d.x;\n } catch (error) {\n /**\n * Seldomly we may found scroll target was removed before\n * its last scroll event.\n */\n }\n }\n }\n\n private applyInput(d: inputData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n try {\n ((target as Node) as HTMLInputElement).checked = d.isChecked;\n ((target as Node) as HTMLInputElement).value = d.text;\n } catch (error) {\n // for safe\n }\n }\n\n private applyText(d: textMutation, mutation: mutationData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(mutation, d.id);\n }\n try {\n ((target as Node) as HTMLElement).textContent = d.value;\n } catch (error) {\n // for safe\n }\n }\n\n private legacy_resolveMissingNode(\n map: missingNodeMap,\n parent: Node,\n target: Node,\n targetMutation: addedNodeMutation,\n ) {\n const { previousId, nextId } = targetMutation;\n const previousInMap = previousId && map[previousId];\n const nextInMap = nextId && map[nextId];\n if (previousInMap) {\n const { node, mutation } = previousInMap as missingNode;\n parent.insertBefore(node, target);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n if (nextInMap) {\n const { node, mutation } = nextInMap as missingNode;\n parent.insertBefore(node, target.nextSibling);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n }\n\n private moveAndHover(\n x: number,\n y: number,\n id: number,\n isSync: boolean,\n debugData: incrementalData,\n ) {\n const target = this.mirror.getNode(id);\n if (!target) {\n return this.debugNodeNotFound(debugData, id);\n }\n\n const base = getBaseDimension(target, this.iframe);\n const _x = x * base.absoluteScale + base.x;\n const _y = y * base.absoluteScale + base.y;\n\n this.mouse.style.left = `${_x}px`;\n this.mouse.style.top = `${_y}px`;\n if (!isSync) {\n this.drawMouseTail({ x: _x, y: _y });\n }\n this.hoverElements((target as Node) as Element);\n }\n\n private drawMouseTail(position: { x: number; y: number }) {\n if (!this.mouseTail) {\n return;\n }\n\n const { lineCap, lineWidth, strokeStyle, duration } =\n this.config.mouseTail === true\n ? defaultMouseTailConfig\n : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);\n\n const draw = () => {\n if (!this.mouseTail) {\n return;\n }\n const ctx = this.mouseTail.getContext('2d');\n if (!ctx || !this.tailPositions.length) {\n return;\n }\n ctx.clearRect(0, 0, this.mouseTail.width, this.mouseTail.height);\n ctx.beginPath();\n ctx.lineWidth = lineWidth;\n ctx.lineCap = lineCap;\n ctx.strokeStyle = strokeStyle;\n ctx.moveTo(this.tailPositions[0].x, this.tailPositions[0].y);\n this.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));\n ctx.stroke();\n };\n\n this.tailPositions.push(position);\n draw();\n setTimeout(() => {\n this.tailPositions = this.tailPositions.filter((p) => p !== position);\n draw();\n }, duration / this.speedService.state.context.timer.speed);\n }\n\n private hoverElements(el: Element) {\n this.iframe.contentDocument\n ?.querySelectorAll('.\\\\:hover')\n .forEach((hoveredEl) => {\n hoveredEl.classList.remove(':hover');\n });\n let currentEl: Element | null = el;\n while (currentEl) {\n if (currentEl.classList) {\n currentEl.classList.add(':hover');\n }\n currentEl = currentEl.parentElement;\n }\n }\n\n private isUserInteraction(event: eventWithTime): boolean {\n if (event.type !== EventType.IncrementalSnapshot) {\n return false;\n }\n return (\n event.data.source > IncrementalSource.Mutation &&\n event.data.source <= IncrementalSource.Input\n );\n }\n\n private backToNormal() {\n this.nextUserInteractionEvent = null;\n if (this.speedService.state.matches('normal')) {\n return;\n }\n this.speedService.send({ type: 'BACK_TO_NORMAL' });\n this.emitter.emit(ReplayerEvents.SkipEnd, {\n speed: this.speedService.state.context.normalSpeed,\n });\n }\n\n /**\n * Replace the virtual parent with the real parent.\n * @param frag fragment document, the virtual parent\n * @param parent real parent element\n */\n private restoreRealParent(frag: INode, parent: INode) {\n this.mirror.map[parent.__sn.id] = parent;\n /**\n * If we have already set value attribute on textarea,\n * then we could not apply text content as default value any more.\n */\n if (\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n frag.textContent\n ) {\n ((parent as unknown) as HTMLTextAreaElement).value = frag.textContent;\n }\n parent.appendChild(frag);\n // restore state of elements after they are mounted\n this.restoreState(parent);\n }\n\n /**\n * store state of elements before unmounted from dom recursively\n * the state should be restored in the handler of event ReplayerEvents.Flush\n * e.g. browser would lose scroll position after the process that we add children of parent node to Fragment Document as virtual dom\n */\n private storeState(parent: INode) {\n if (parent) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (parentElement.scrollLeft || parentElement.scrollTop) {\n // store scroll position state\n this.elementStateMap.set(parent, {\n scroll: [parentElement.scrollLeft, parentElement.scrollTop],\n });\n }\n if (parentElement.tagName === 'STYLE')\n storeCSSRules(\n parentElement as HTMLStyleElement,\n this.virtualStyleRulesMap,\n );\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.storeState((child as unknown) as INode);\n }\n }\n }\n }\n\n /**\n * restore the state of elements recursively, which was stored before elements were unmounted from dom in virtual parent mode\n * this function corresponds to function storeState\n */\n private restoreState(parent: INode) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (this.elementStateMap.has(parent)) {\n const storedState = this.elementStateMap.get(parent)!;\n // restore scroll position\n if (storedState.scroll) {\n parentElement.scrollLeft = storedState.scroll[0];\n parentElement.scrollTop = storedState.scroll[1];\n }\n this.elementStateMap.delete(parent);\n }\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.restoreState((child as unknown) as INode);\n }\n }\n }\n\n private restoreNodeSheet(node: INode) {\n const storedRules = this.virtualStyleRulesMap.get(node);\n if (node.nodeName !== 'STYLE') {\n return;\n }\n\n if (!storedRules) {\n return;\n }\n\n const styleNode = (node as unknown) as HTMLStyleElement;\n\n applyVirtualStyleRulesToNode(storedRules, styleNode);\n }\n\n private warnNodeNotFound(d: incrementalData, id: number) {\n if (this.treeIndex.idRemoved(id)) {\n this.warn(`Node with id '${id}' was previously removed. `, d);\n } else {\n this.warn(`Node with id '${id}' not found. `, d);\n }\n }\n\n private warnCanvasMutationFailed(\n d: canvasMutationData | canvasMutationCommand,\n error: unknown,\n ) {\n this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);\n }\n\n private debugNodeNotFound(d: incrementalData, id: number) {\n /**\n * There maybe some valid scenes of node not being found.\n * Because DOM events are macrotask and MutationObserver callback\n * is microtask, so events fired on a removed DOM may emit\n * snapshots in the reverse order.\n */\n if (this.treeIndex.idRemoved(id)) {\n this.debug(\n REPLAY_CONSOLE_PREFIX,\n `Node with id '${id}' was previously removed. `,\n d,\n );\n } else {\n this.debug(REPLAY_CONSOLE_PREFIX, `Node with id '${id}' not found. `, d);\n }\n }\n\n private warn(...args: Parameters) {\n if (!this.config.showWarning) {\n return;\n }\n console.warn(REPLAY_CONSOLE_PREFIX, ...args);\n }\n\n private debug(...args: Parameters) {\n if (!this.config.showDebug) {\n return;\n }\n // tslint:disable-next-line: no-console\n console.log(REPLAY_CONSOLE_PREFIX, ...args);\n }\n}\n","import { Replayer } from '..';\nimport {\n CanvasContext,\n canvasMutationCommand,\n canvasMutationData,\n} from '../../types';\nimport webglMutation from './webgl';\nimport canvas2DMutation from './2d';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationData;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const mutations: canvasMutationCommand[] =\n 'commands' in mutation ? mutation.commands : [mutation];\n\n if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {\n return mutations.forEach((command) => {\n webglMutation({\n mutation: command,\n type: mutation.type,\n target,\n imageMap,\n errorHandler,\n });\n });\n }\n // default is '2d' for backwards compatibility (rrweb below 1.1.x)\n return mutations.forEach((command) => {\n canvas2DMutation({\n event,\n mutation: command,\n target,\n imageMap,\n errorHandler,\n });\n });\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import { Replayer } from '../';\nimport { canvasMutationCommand } from '../../types';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = ((target as unknown) as HTMLCanvasElement).getContext('2d')!;\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n /**\n * We have serialized the image source into base64 string during recording,\n * which has been preloaded before replay.\n * So we can get call drawImage SYNCHRONOUSLY which avoid some fragile cast.\n */\n if (\n mutation.property === 'drawImage' &&\n typeof mutation.args[0] === 'string'\n ) {\n const image = imageMap.get(event);\n mutation.args[0] = image;\n original.apply(ctx, mutation.args);\n } else {\n original.apply(ctx, mutation.args);\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isElement","nodeType","ELEMENT_NODE","commentre","parse","css","options","lineno","column","updatePosition","str","lines","match","lastIndexOf","position","start","line","node","Position","whitespace","end","source","content","errorsList","msg","err","Error","reason","filename","silent","open","close","rules","comments","charAt","atrule","rule","re","exec","c","comment","pos","type","selector","trim","replace","split","map","declaration","propMatch","prop","val","ret","property","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","name","RegExp","vendor","frame","frames","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","doc","document","atdocument","sel","selectors","atpage","athost","atfontface","addParent","stylesheet","parsingErrors","obj","parent","isNode","childParent","_i","_a","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","script","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cssText","cache","cachedStyle","stylesWithHoverClass","get","ast","test","selectorMatcher","filter","index","indexOf","sort","a","b","join","result","newSelector","set","createCache","Map","buildNode","hackCss","Document","implementation","createDocument","DocumentType","createDocumentType","publicId","systemId","Element","node_1","tagName","attributes","_cssText","getTagName","isSVG","createElementNS","createElement","_loop_1","name_1","startsWith","image_1","src","onload","ctx","getContext","drawImage","width","height","image","currentSrc","setAttribute","currentTime","rr_mediaCurrentTime","play","console","warn","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","childNodes","TEXT_NODE","removeChild","appendChild","setAttributeNS","substring","rel","as","href","endsWith","srcset","rr_dataURL","isShadowHost","shadowRoot","firstChild","attachShadow","mode","Text","isStyle","textContent","CDATA","createCDATASection","Comment","createComment","buildNodeWithSN","skipChild","_b","afterAppend","rootId","assert","compatMode","xmlns","write","__sn","id","_c","childN","childNode","isShadow","rebuild","onVisit","idNodeMap","key","visit","visitedNode","el","name_2","scrollLeft","scrollTop","handleScroll","mitt","all","create","on","handler","off","splice","emit","evt","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","polyfill","w","d","documentElement","__forceSmoothScrollPolyfill__","userAgent","HTMLElement","original","scroll","scrollTo","scrollBy","elementScroll","scrollElement","scrollIntoView","now","performance","bind","Date","ROUNDING_TOLERANCE","navigator","undefined","shouldBailOut","smoothScroll","body","left","scrollX","pageXOffset","top","scrollY","pageYOffset","SyntaxError","behavior","scrollableParent","findScrollableParent","parentRects","getBoundingClientRect","clientRects","getComputedStyle","x","y","firstArg","hasScrollableSpace","axis","clientHeight","scrollHeight","clientWidth","scrollWidth","canOverflow","overflowValue","isScrollable","isScrollableY","isScrollableX","parentNode","host","step","context","currentX","currentY","k","elapsed","startTime","Math","cos","PI","startX","startY","method","scrollable","requestAnimationFrame","actions","speed","Timer","action","findActionIndex","timeOffset","lastTimestamp","self","raf","check","time","delay","shift","doAction","liveMode","cancelAnimationFrame","mid","floor","addDelay","event","baselineTime","IncrementalSnapshot","data","MouseMove","firstOffset","positions","firstTimestamp","timestamp","return","NotStarted","Running","Stopped","assignment","u","changed","matches","f","states","initial","entry","config","_options","initialState","transition","g","h","S","target","j","E","R","N","cond","O","_","T","q","exit","z","A","B","C","Set","_machine","send","subscribe","add","unsubscribe","delete","stop","clear","state","status","createPlayerService","getCastFn","applyEventsSynchronously","emitter","interpret","createMachine","playing","PAUSE","CAST_EVENT","END","ADD_EVENT","paused","PLAY","TO_LIVE","live","castEvent","lastPlayedEvent","payload","recordTimeOffset","events","timer","events_1","neededEvents","idx","event_1","Meta","discardPriorSnapshots","lastPlayedTimestamp","PlayBack","syncEvents","event_3","castFn_1","neededEvents_1","Flush","addActions","resetLastPlayedEvent","startLive","toggleLiveMode","addEvent","machineEvent","event_4","insertionIndex","isSync","castFn_2","isActive","addAction","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","getId","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","receiver","TreeIndex","mutation","parentTreeNode","indexes","parentId","treeNode","children","texts","tree","mirror","deepRemoveFromMirror","_this","removeIdSet","deepRemoveFromTreeIndex","_treeNode","_parentTreeNode","removeNodeMutations","textMutations","attributeMutations","scrollMap","inputMap","batchMutationData","Mutation","removes","adds","walk","removed","_d","_f","mutationData","queueToResolveTrees","queue","queueNodeMap","putIntoMap","nodeInTree","queueNodeTrees","queue_1","nextId","nextInTree","parentInTree","iterateResolveTree","cb","isIframeINode","getBaseDimension","rootIframe","frameElement","ownerDocument","defaultView","relativeScale","absoluteScale","frameDimension","frameBaseDimension","hasShadowRoot","Boolean","StyleRuleType","getNestedRule","cssRules","getPositionsAndIndex","nestedIndex","pop","applyVirtualStyleRulesToNode","storedRules","styleNode","sheet","Insert","insertRule","Remove","deleteRule","Snapshot","cssTexts","existingRules","existingRulesReversed","entries","reverse","lastMatch_1","Number","restoreSnapshotOfStyleRulesToNode","SetProperty","setProperty","priority","RemoveProperty","removeProperty","chars","lookup","Uint8Array","charCodeAt","webGLVarMap","variableListFor","ctor","contextMap","WebGLVariableConstructorsNames","deserializeArg","imageMap","arg","args","base64","encoded1","encoded2","encoded3","encoded4","bufferLength","len","arraybuffer","ArrayBuffer","bytes","decode","Image","webglMutation","errorHandler","WebGL","setter","constructor","includes","variables","saveToWebGLVarMap","mittProxy.default","mittProxy","REPLAY_CONSOLE_PREFIX","defaultMouseTailConfig","duration","lineCap","lineWidth","strokeStyle","indicatesTouchDevice","TouchMove","MouseInteraction","TouchStart","defaultConfig","maxSpeed","root","loadTimeout","skipInactive","showWarning","showDebug","blockClass","insertStyleRules","triggerFocus","UNSAFE_replayCanvas","pauseAnimation","mouseTail","handleResize","Resize","setupDom","treeIndex","fragmentParentMap","elementStateMap","virtualStyleRulesMap","_e","flush","frag","restoreRealParent","applyText","_h","restoreNodeSheet","_k","applyScroll","_m","applyInput","firstFullSnapshot","service","unpackFn","a1","a2","StateChange","player","speedService","normalSpeed","normal","FAST_FORWARD","SET_SPEED","skipping","BACK_TO_NORMAL","setSpeed","recordSpeed","restoreSpeed","firstMeta","find","firstFullsnapshot","FullSnapshot","width_1","height_1","setTimeout","rebuildFullSnapshot","iframe","contentWindow","initialOffset","mouse","classList","Replayer","backToNormal","display","parseFloat","wrapper","insertBefore","firstEvent","lastEvent","endTime","totalTime","getTimeOffset","contentDocument","getElementsByTagName","remove","Start","Pause","Resume","rawEvent","Promise","resolve","then","pointerEvents","win","disableInteract","smoothscrollPolyfill","NodeList","DOMTokenList","Node","contains","dimension","String","DomContentLoaded","Load","Custom","Plugin","MediaInteraction","castFn","mousePos","moveAndHover","debugData","touchActive","CustomEvent","applyIncremental","nextUserInteractionEvent","_event","isUserInteraction","skipTime","min","round","SkipStart","plugins","replayer","last_index","finish_1","Finish","max","EventCast","legacy_missingNodeRetryMap","collected","builtNode","collectIframeAndAttachDocument","mutationInQueue","this_1","attachDocumentToIframe","newDocumentQueue","collected_1","head","FullsnapshotRebuilded","waitForStylesheetLoad","preloadAllImages","styleEl","injectStylesRules","iframeEl","parent_1","realParent","toUpperCase","this_2","collected_2","timer_1","unloadSheets_1","beforeLoadState_1","stateHandler_1","unsubscribe_1","querySelectorAll","addEventListener","size","getCurrentTime","LoadStylesheetEnd","clearTimeout","LoadStylesheetStart","args_1","hasImageArg","rr_type","images","args_2","getImageArgs","stateHandler","event_2","CanvasMutation","commands","preloadImages","this_3","url","canvas","imgd","createImageData","JSON","putImageData","text","attribute","applyMutation","message","Drag","lastPosition","Event","toLowerCase","debugNodeNotFound","Blur","blur","Focus","focus","preventScroll","Click","TouchEnd","tailPositions","offsetWidth","TouchCancel","dispatchEvent","Scroll","ViewportResize","Input","input","mediaEl","volume","muted","StyleSheetRule","rules_1","parent_2","usingVirtualParent_1","styleSheet_1","StyleDeclaration","parent_3","styleSheet","mutations","WebGL2","command","canvas2DMutation","canvasMutation","warnCanvasMutationFailed","Font","fontFace","FontFace","family","buffer","fontSource","descriptors","fonts","useVirtualParent","warnNodeNotFound","realTarget","DOMException","legacy_missingNodeMap","appendNode","parentInDocument","hasIframeChild","virtualParent","createDocumentFragment","storeState","previous","previousId","nextNotInDOM","targetDoc","nextSibling","mutationInQueue_1","legacy_resolveMissingNode","resolveTrees","resolveTrees_1","debug","attributeName","removeAttribute","styleValues","targetEl","svp","svs","checked","isChecked","targetMutation","previousInMap","nextInMap","base","_x","_y","drawMouseTail","hoverElements","draw","clearRect","beginPath","moveTo","lineTo","stroke","hoveredEl","currentEl","parentElement","SkipEnd","restoreState","storeCSSRules","storedState","nodeName","idRemoved","log"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ED+BOC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,YAgFzB,SAASQ,EAASC,GACrB,IAAIZ,EAAsB,mBAAXa,QAAyBA,OAAOC,SAAUC,EAAIf,GAAKY,EAAEZ,GAAIC,EAAI,EAC5E,GAAIc,EAAG,OAAOA,EAAEP,KAAKI,GACrB,GAAIA,GAAyB,iBAAbA,EAAER,OAAqB,MAAO,CAC1CY,KAAM,WAEF,OADIJ,GAAKX,GAAKW,EAAER,SAAQQ,OAAI,GACrB,CAAEK,MAAOL,GAAKA,EAAEX,KAAMiB,MAAON,KAG5C,MAAM,IAAIO,UAAUnB,EAAI,0BAA4B,mCAGjD,SAASoB,EAAOR,EAAGV,GACtB,IAAIa,EAAsB,mBAAXF,QAAyBD,EAAEC,OAAOC,UACjD,IAAKC,EAA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vCxQ,KAAK6nB,UAAU6P,UAAUlnB,GAC3BxQ,KAAKgO,KAAK,wBAAiBwC,gCAAgCiC,GAE3DzS,KAAKgO,KAAK,wBAAiBwC,mBAAmBiC,IAI1CiY,qCAAR,SACEjY,EACA1R,GAEAf,KAAKgO,KAAK,6BAA8BjN,EAAO,mBAAoB0R,IAG7DiY,8BAAR,SAA0BjY,EAAoBjC,GAOxCxQ,KAAK6nB,UAAU6P,UAAUlnB,GAC3BxQ,KAAK21B,MACHxP,GACA,wBAAiB3V,gCACjBiC,GAGFzS,KAAK21B,MAAMxP,GAAuB,wBAAiB3V,mBAAmBiC,IAIlEiY,iBAAR,eAAa,aAAArjB,mBAAAA,IAAAud,kBACN5kB,KAAKoZ,OAAO8N,aAGjBnZ,QAAQC,WAARD,WAAaoY,MAA0BvB,SAGjC8F,kBAAR,eAAc,aAAArjB,mBAAAA,IAAAud,kBACP5kB,KAAKoZ,OAAO+N,WAIjBpZ,QAAQ4pB,UAAR5pB,WAAYoY,MAA0BvB"} +\ No newline at end of file ++{"version":3,"file":"rrweb-replay.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../../rrweb-snapshot/es/rrweb-snapshot.js","../../../../node_modules/mitt/dist/mitt.es.js","../../../src/types.ts","../../../src/replay/smoothscroll.ts","../../../src/replay/timer.ts","../../../../node_modules/@xstate/fsm/es/index.js","../../../src/replay/machine.ts","../../../src/utils.ts","../../../src/replay/styles/inject-style.ts","../../../src/replay/virtual-styles.ts","../../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../../src/replay/canvas/webgl.ts","../../../src/replay/index.ts","../../../src/replay/canvas/index.ts","../../../src/replay/canvas/2d.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type] ||\n (maskInputSelector && input.matches(maskInputSelector))) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) {\n return false;\n }\n }\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n input: n,\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","// \n// An event handler can take an optional event argument\n// and should not return a value\n \n \n\n// An array of all currently registered event handlers for a type\n \n \n// A map of event types and their corresponding event handlers.\n \n \n \n \n\n/** Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nfunction mitt(all ) {\n\tall = all || Object.create(null);\n\n\treturn {\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton: function on(type , handler ) {\n\t\t\t(all[type] || (all[type] = [])).push(handler);\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff: function off(type , handler ) {\n\t\t\tif (all[type]) {\n\t\t\t\tall[type].splice(all[type].indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * @param {String} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit: function emit(type , evt ) {\n\t\t\t(all[type] || []).slice().map(function (handler) { handler(evt); });\n\t\t\t(all['*'] || []).slice().map(function (handler) { handler(type, evt); });\n\t\t}\n\t};\n}\n\nexport default mitt;\n//# sourceMappingURL=mitt.es.js.map\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n unblockSelector?: string;\n ignoreClass?: string;\n ignoreSelector?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputSelector?: string;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n unmaskTextSelector?: string;\n unmaskInputSelector?: string;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n unblockSelector: string | null;\n ignoreClass: string;\n ignoreSelector: string | null;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'unblockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'unmaskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputSelector'\n | 'unmaskInputSelector'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","/**\n * A fork version of https://github.com/iamdustan/smoothscroll\n * Add support of customize target window and document\n */\n\n// @ts-nocheck\n// tslint:disable\nexport function polyfill(w: Window = window, d = document) {\n // return if scroll behavior is supported and polyfill is not forced\n if (\n 'scrollBehavior' in d.documentElement.style &&\n w.__forceSmoothScrollPolyfill__ !== true\n ) {\n return;\n }\n\n // globals\n var Element = w.HTMLElement || w.Element;\n var SCROLL_TIME = 468;\n\n // object gathering original scroll methods\n var original = {\n scroll: w.scroll || w.scrollTo,\n scrollBy: w.scrollBy,\n elementScroll: Element.prototype.scroll || scrollElement,\n scrollIntoView: Element.prototype.scrollIntoView,\n };\n\n // define timing method\n var now =\n w.performance && w.performance.now\n ? w.performance.now.bind(w.performance)\n : Date.now;\n\n /**\n * indicates if a the current browser is made by Microsoft\n * @method isMicrosoftBrowser\n * @param {String} userAgent\n * @returns {Boolean}\n */\n function isMicrosoftBrowser(userAgent) {\n var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];\n\n return new RegExp(userAgentPatterns.join('|')).test(userAgent);\n }\n\n /*\n * IE has rounding bug rounding down clientHeight and clientWidth and\n * rounding up scrollHeight and scrollWidth causing false positives\n * on hasScrollableSpace\n */\n var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;\n\n /**\n * changes scroll position inside an element\n * @method scrollElement\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function scrollElement(x, y) {\n this.scrollLeft = x;\n this.scrollTop = y;\n }\n\n /**\n * returns result of applying ease math function to a number\n * @method ease\n * @param {Number} k\n * @returns {Number}\n */\n function ease(k) {\n return 0.5 * (1 - Math.cos(Math.PI * k));\n }\n\n /**\n * indicates if a smooth behavior should be applied\n * @method shouldBailOut\n * @param {Number|Object} firstArg\n * @returns {Boolean}\n */\n function shouldBailOut(firstArg) {\n if (\n firstArg === null ||\n typeof firstArg !== 'object' ||\n firstArg.behavior === undefined ||\n firstArg.behavior === 'auto' ||\n firstArg.behavior === 'instant'\n ) {\n // first argument is not an object/null\n // or behavior is auto, instant or undefined\n return true;\n }\n\n if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {\n // first argument is an object and behavior is smooth\n return false;\n }\n\n // throw error when behavior is not supported\n throw new TypeError(\n 'behavior member of ScrollOptions ' +\n firstArg.behavior +\n ' is not a valid value for enumeration ScrollBehavior.',\n );\n }\n\n /**\n * indicates if an element has scrollable space in the provided axis\n * @method hasScrollableSpace\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function hasScrollableSpace(el, axis) {\n if (axis === 'Y') {\n return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;\n }\n\n if (axis === 'X') {\n return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;\n }\n }\n\n /**\n * indicates if an element has a scrollable overflow property in the axis\n * @method canOverflow\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function canOverflow(el, axis) {\n var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];\n\n return overflowValue === 'auto' || overflowValue === 'scroll';\n }\n\n /**\n * indicates if an element can be scrolled in either axis\n * @method isScrollable\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function isScrollable(el) {\n var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');\n var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');\n\n return isScrollableY || isScrollableX;\n }\n\n /**\n * finds scrollable parent of an element\n * @method findScrollableParent\n * @param {Node} el\n * @returns {Node} el\n */\n function findScrollableParent(el) {\n while (el !== d.body && isScrollable(el) === false) {\n el = el.parentNode || el.host;\n }\n\n return el;\n }\n\n /**\n * self invoked function that, given a context, steps through scrolling\n * @method step\n * @param {Object} context\n * @returns {undefined}\n */\n function step(context) {\n var time = now();\n var value;\n var currentX;\n var currentY;\n var elapsed = (time - context.startTime) / SCROLL_TIME;\n\n // avoid elapsed times higher than one\n elapsed = elapsed > 1 ? 1 : elapsed;\n\n // apply easing to elapsed time\n value = ease(elapsed);\n\n currentX = context.startX + (context.x - context.startX) * value;\n currentY = context.startY + (context.y - context.startY) * value;\n\n context.method.call(context.scrollable, currentX, currentY);\n\n // scroll more if we have not reached our destination\n if (currentX !== context.x || currentY !== context.y) {\n w.requestAnimationFrame(step.bind(w, context));\n }\n }\n\n /**\n * scrolls window or element with a smooth behavior\n * @method smoothScroll\n * @param {Object|Node} el\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function smoothScroll(el, x, y) {\n var scrollable;\n var startX;\n var startY;\n var method;\n var startTime = now();\n\n // define scroll context\n if (el === d.body) {\n scrollable = w;\n startX = w.scrollX || w.pageXOffset;\n startY = w.scrollY || w.pageYOffset;\n method = original.scroll;\n } else {\n scrollable = el;\n startX = el.scrollLeft;\n startY = el.scrollTop;\n method = scrollElement;\n }\n\n // scroll looping over a frame\n step({\n scrollable: scrollable,\n method: method,\n startTime: startTime,\n startX: startX,\n startY: startY,\n x: x,\n y: y,\n });\n }\n\n // ORIGINAL METHODS OVERRIDES\n // w.scroll and w.scrollTo\n w.scroll = w.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scroll.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : w.scrollX || w.pageXOffset,\n // use top prop, second argument if present or fallback to scrollY\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : w.scrollY || w.pageYOffset,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : w.scrollX || w.pageXOffset,\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : w.scrollY || w.pageYOffset,\n );\n };\n\n // w.scrollBy\n w.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0])) {\n original.scrollBy.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : 0,\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : 0,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n ~~arguments[0].left + (w.scrollX || w.pageXOffset),\n ~~arguments[0].top + (w.scrollY || w.pageYOffset),\n );\n };\n\n // Element.prototype.scroll and Element.prototype.scrollTo\n Element.prototype.scroll = Element.prototype.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n // if one number is passed, throw error to match Firefox implementation\n if (typeof arguments[0] === 'number' && arguments[1] === undefined) {\n throw new SyntaxError('Value could not be converted');\n }\n\n original.elementScroll.call(\n this,\n // use left prop, first number argument or fallback to scrollLeft\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : typeof arguments[0] !== 'object'\n ? ~~arguments[0]\n : this.scrollLeft,\n // use top prop, second argument or fallback to scrollTop\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : arguments[1] !== undefined\n ? ~~arguments[1]\n : this.scrollTop,\n );\n\n return;\n }\n\n var left = arguments[0].left;\n var top = arguments[0].top;\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n this,\n this,\n typeof left === 'undefined' ? this.scrollLeft : ~~left,\n typeof top === 'undefined' ? this.scrollTop : ~~top,\n );\n };\n\n // Element.prototype.scrollBy\n Element.prototype.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.elementScroll.call(\n this,\n arguments[0].left !== undefined\n ? ~~arguments[0].left + this.scrollLeft\n : ~~arguments[0] + this.scrollLeft,\n arguments[0].top !== undefined\n ? ~~arguments[0].top + this.scrollTop\n : ~~arguments[1] + this.scrollTop,\n );\n\n return;\n }\n\n this.scroll({\n left: ~~arguments[0].left + this.scrollLeft,\n top: ~~arguments[0].top + this.scrollTop,\n behavior: arguments[0].behavior,\n });\n };\n\n // Element.prototype.scrollIntoView\n Element.prototype.scrollIntoView = function () {\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scrollIntoView.call(\n this,\n arguments[0] === undefined ? true : arguments[0],\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n var scrollableParent = findScrollableParent(this);\n var parentRects = scrollableParent.getBoundingClientRect();\n var clientRects = this.getBoundingClientRect();\n\n if (scrollableParent !== d.body) {\n // reveal element inside parent\n smoothScroll.call(\n this,\n scrollableParent,\n scrollableParent.scrollLeft + clientRects.left - parentRects.left,\n scrollableParent.scrollTop + clientRects.top - parentRects.top,\n );\n\n // reveal parent in viewport unless is fixed\n if (w.getComputedStyle(scrollableParent).position !== 'fixed') {\n w.scrollBy({\n left: parentRects.left,\n top: parentRects.top,\n behavior: 'smooth',\n });\n }\n } else {\n // reveal element in viewport\n w.scrollBy({\n left: clientRects.left,\n top: clientRects.top,\n behavior: 'smooth',\n });\n }\n };\n}\n","import {\n actionWithDelay,\n eventWithTime,\n EventType,\n IncrementalSource,\n} from '../types';\n\nexport class Timer {\n public timeOffset: number = 0;\n public speed: number;\n\n private actions: actionWithDelay[];\n private raf: number | null = null;\n private liveMode: boolean;\n\n constructor(actions: actionWithDelay[] = [], speed: number) {\n this.actions = actions;\n this.speed = speed;\n }\n /**\n * Add an action after the timer starts.\n * @param action\n */\n public addAction(action: actionWithDelay) {\n const index = this.findActionIndex(action);\n this.actions.splice(index, 0, action);\n }\n /**\n * Add all actions before the timer starts\n * @param actions\n */\n public addActions(actions: actionWithDelay[]) {\n this.actions = this.actions.concat(actions);\n }\n\n public start() {\n this.timeOffset = 0;\n let lastTimestamp = performance.now();\n const { actions } = this;\n const self = this;\n function check() {\n const time = performance.now();\n self.timeOffset += (time - lastTimestamp) * self.speed;\n lastTimestamp = time;\n while (actions.length) {\n const action = actions[0];\n\n if (self.timeOffset >= action.delay) {\n actions.shift();\n action.doAction();\n } else {\n break;\n }\n }\n if (actions.length > 0 || self.liveMode) {\n self.raf = requestAnimationFrame(check);\n }\n }\n this.raf = requestAnimationFrame(check);\n }\n\n public clear() {\n if (this.raf) {\n cancelAnimationFrame(this.raf);\n this.raf = null;\n }\n this.actions.length = 0;\n }\n\n public setSpeed(speed: number) {\n this.speed = speed;\n }\n\n public toggleLiveMode(mode: boolean) {\n this.liveMode = mode;\n }\n\n public isActive() {\n return this.raf !== null;\n }\n\n private findActionIndex(action: actionWithDelay): number {\n let start = 0;\n let end = this.actions.length - 1;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (this.actions[mid].delay < action.delay) {\n start = mid + 1;\n } else if (this.actions[mid].delay > action.delay) {\n end = mid - 1;\n } else {\n // already an action with same delay (timestamp)\n // the plus one will splice the new one after the existing one\n return mid + 1;\n }\n }\n return start;\n }\n}\n\n// TODO: add speed to mouse move timestamp calculation\nexport function addDelay(event: eventWithTime, baselineTime: number): number {\n // Mouse move events was recorded in a throttle function,\n // so we need to find the real timestamp by traverse the time offsets.\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove\n ) {\n const firstOffset = event.data.positions[0].timeOffset;\n // timeOffset is a negative offset to event.timestamp\n const firstTimestamp = event.timestamp + firstOffset;\n event.delay = firstTimestamp - baselineTime;\n return firstTimestamp - baselineTime;\n }\n\n event.delay = event.timestamp - baselineTime;\n return event.delay;\n}\n","/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return{type:\"xstate.assign\",assignment:t}}function i(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){o=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]=\"function\"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o]})),r=n,!1}return!0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})))},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u=\"object\"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}export{n as InterpreterStatus,o as assign,s as createMachine,v as interpret};\n","import { createMachine, interpret, assign, StateMachine } from '@xstate/fsm';\nimport {\n playerConfig,\n eventWithTime,\n actionWithDelay,\n ReplayerEvents,\n EventType,\n Emitter,\n IncrementalSource,\n} from '../types';\nimport { Timer, addDelay } from './timer';\n\nexport type PlayerContext = {\n events: eventWithTime[];\n timer: Timer;\n timeOffset: number;\n baselineTime: number;\n lastPlayedEvent: eventWithTime | null;\n};\nexport type PlayerEvent =\n | {\n type: 'PLAY';\n payload: {\n timeOffset: number;\n };\n }\n | {\n type: 'CAST_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | { type: 'PAUSE' }\n | { type: 'TO_LIVE'; payload: { baselineTime?: number } }\n | {\n type: 'ADD_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | {\n type: 'END';\n };\nexport type PlayerState =\n | {\n value: 'playing';\n context: PlayerContext;\n }\n | {\n value: 'paused';\n context: PlayerContext;\n }\n | {\n value: 'live';\n context: PlayerContext;\n };\n\n/**\n * If the array have multiple meta and fullsnapshot events,\n * return the events from last meta to the end.\n */\nexport function discardPriorSnapshots(\n events: eventWithTime[],\n baselineTime: number,\n): eventWithTime[] {\n for (let idx = events.length - 1; idx >= 0; idx--) {\n const event = events[idx];\n if (event.type === EventType.Meta) {\n if (event.timestamp <= baselineTime) {\n return events.slice(idx);\n }\n }\n }\n return events;\n}\n\ntype PlayerAssets = {\n emitter: Emitter;\n applyEventsSynchronously(events: Array): void;\n getCastFn(event: eventWithTime, isSync: boolean): () => void;\n};\nexport function createPlayerService(\n context: PlayerContext,\n { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets,\n) {\n const playerMachine = createMachine(\n {\n id: 'player',\n context,\n initial: 'paused',\n states: {\n playing: {\n on: {\n PAUSE: {\n target: 'paused',\n actions: ['pause'],\n },\n CAST_EVENT: {\n target: 'playing',\n actions: 'castEvent',\n },\n END: {\n target: 'paused',\n actions: ['resetLastPlayedEvent', 'pause'],\n },\n ADD_EVENT: {\n target: 'playing',\n actions: ['addEvent'],\n },\n },\n },\n paused: {\n on: {\n PLAY: {\n target: 'playing',\n actions: ['recordTimeOffset', 'play'],\n },\n CAST_EVENT: {\n target: 'paused',\n actions: 'castEvent',\n },\n TO_LIVE: {\n target: 'live',\n actions: ['startLive'],\n },\n ADD_EVENT: {\n target: 'paused',\n actions: ['addEvent'],\n },\n },\n },\n live: {\n on: {\n ADD_EVENT: {\n target: 'live',\n actions: ['addEvent'],\n },\n CAST_EVENT: {\n target: 'live',\n actions: ['castEvent'],\n },\n },\n },\n },\n },\n {\n actions: {\n castEvent: assign({\n lastPlayedEvent: (ctx, event) => {\n if (event.type === 'CAST_EVENT') {\n return event.payload.event;\n }\n return ctx.lastPlayedEvent;\n },\n }),\n recordTimeOffset: assign((ctx, event) => {\n let timeOffset = ctx.timeOffset;\n if ('payload' in event && 'timeOffset' in event.payload) {\n timeOffset = event.payload.timeOffset;\n }\n return {\n ...ctx,\n timeOffset,\n baselineTime: ctx.events[0].timestamp + timeOffset,\n };\n }),\n play(ctx) {\n const { timer, events, baselineTime, lastPlayedEvent } = ctx;\n timer.clear();\n\n for (const event of events) {\n // TODO: improve this API\n addDelay(event, baselineTime);\n }\n const neededEvents = discardPriorSnapshots(events, baselineTime);\n\n let lastPlayedTimestamp = lastPlayedEvent?.timestamp;\n if (\n lastPlayedEvent?.type === EventType.IncrementalSnapshot &&\n lastPlayedEvent.data.source === IncrementalSource.MouseMove\n ) {\n lastPlayedTimestamp =\n lastPlayedEvent.timestamp +\n lastPlayedEvent.data.positions[0]?.timeOffset;\n }\n if (baselineTime < (lastPlayedTimestamp || 0)) {\n emitter.emit(ReplayerEvents.PlayBack);\n }\n\n const syncEvents = new Array();\n const actions = new Array();\n for (const event of neededEvents) {\n if (\n lastPlayedTimestamp &&\n lastPlayedTimestamp < baselineTime &&\n (event.timestamp <= lastPlayedTimestamp ||\n event === lastPlayedEvent)\n ) {\n continue;\n }\n if (event.timestamp < baselineTime) {\n syncEvents.push(event);\n } else {\n const castFn = getCastFn(event, false);\n actions.push({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n applyEventsSynchronously(syncEvents);\n emitter.emit(ReplayerEvents.Flush);\n timer.addActions(actions);\n timer.start();\n },\n pause(ctx) {\n ctx.timer.clear();\n },\n resetLastPlayedEvent: assign((ctx) => {\n return {\n ...ctx,\n lastPlayedEvent: null,\n };\n }),\n startLive: assign({\n baselineTime: (ctx, event) => {\n ctx.timer.toggleLiveMode(true);\n ctx.timer.start();\n if (event.type === 'TO_LIVE' && event.payload.baselineTime) {\n return event.payload.baselineTime;\n }\n return Date.now();\n },\n }),\n addEvent: assign((ctx, machineEvent) => {\n const { baselineTime, timer, events } = ctx;\n if (machineEvent.type === 'ADD_EVENT') {\n const { event } = machineEvent.payload;\n addDelay(event, baselineTime);\n\n let end = events.length - 1;\n if (!events[end] || events[end].timestamp <= event.timestamp) {\n // fast track\n events.push(event);\n } else {\n let insertionIndex = -1;\n let start = 0;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (events[mid].timestamp <= event.timestamp) {\n start = mid + 1;\n } else {\n end = mid - 1;\n }\n }\n if (insertionIndex === -1) {\n insertionIndex = start;\n }\n events.splice(insertionIndex, 0, event);\n }\n\n const isSync = event.timestamp < baselineTime;\n const castFn = getCastFn(event, isSync);\n if (isSync) {\n castFn();\n } else if (timer.isActive()) {\n timer.addAction({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n return { ...ctx, events };\n }),\n },\n },\n );\n return interpret(playerMachine);\n}\n\nexport type SpeedContext = {\n normalSpeed: playerConfig['speed'];\n timer: Timer;\n};\n\nexport type SpeedEvent =\n | {\n type: 'FAST_FORWARD';\n payload: { speed: playerConfig['speed'] };\n }\n | {\n type: 'BACK_TO_NORMAL';\n }\n | {\n type: 'SET_SPEED';\n payload: { speed: playerConfig['speed'] };\n };\n\nexport type SpeedState =\n | {\n value: 'normal';\n context: SpeedContext;\n }\n | {\n value: 'skipping';\n context: SpeedContext;\n };\n\nexport function createSpeedService(context: SpeedContext) {\n const speedMachine = createMachine(\n {\n id: 'speed',\n context,\n initial: 'normal',\n states: {\n normal: {\n on: {\n FAST_FORWARD: {\n target: 'skipping',\n actions: ['recordSpeed', 'setSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n skipping: {\n on: {\n BACK_TO_NORMAL: {\n target: 'normal',\n actions: ['restoreSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n },\n },\n {\n actions: {\n setSpeed: (ctx, event) => {\n if ('payload' in event) {\n ctx.timer.setSpeed(event.payload.speed);\n }\n },\n recordSpeed: assign({\n normalSpeed: (ctx) => ctx.timer.speed,\n }),\n restoreSpeed: (ctx) => {\n ctx.timer.setSpeed(ctx.normalSpeed);\n },\n },\n },\n );\n\n return interpret(speedMachine);\n}\n\nexport type PlayerMachineState = StateMachine.State<\n PlayerContext,\n PlayerEvent,\n PlayerState\n>;\n\nexport type SpeedMachineState = StateMachine.State<\n SpeedContext,\n SpeedEvent,\n SpeedState\n>;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","const rules: (blockClass: string) => string[] = (blockClass: string) => [\n `.${blockClass} { background: currentColor }`,\n 'noscript { display: none !important; }',\n];\n\nexport default rules;\n","import { INode } from 'rrweb-snapshot';\n\nexport enum StyleRuleType {\n Insert,\n Remove,\n Snapshot,\n SetProperty,\n RemoveProperty,\n}\n\ntype InsertRule = {\n cssText: string;\n type: StyleRuleType.Insert;\n index?: number | number[];\n};\ntype RemoveRule = {\n type: StyleRuleType.Remove;\n index: number | number[];\n};\ntype SnapshotRule = {\n type: StyleRuleType.Snapshot;\n cssTexts: string[];\n};\ntype SetPropertyRule = {\n type: StyleRuleType.SetProperty;\n index: number[];\n property: string;\n value: string | null;\n priority: string | undefined;\n};\ntype RemovePropertyRule = {\n type: StyleRuleType.RemoveProperty;\n index: number[];\n property: string;\n};\n\nexport type VirtualStyleRules = Array<\n InsertRule | RemoveRule | SnapshotRule | SetPropertyRule | RemovePropertyRule\n>;\nexport type VirtualStyleRulesMap = Map;\n\nexport function getNestedRule(\n rules: CSSRuleList,\n position: number[],\n): CSSGroupingRule {\n const rule = rules[position[0]] as CSSGroupingRule;\n if (position.length === 1) {\n return rule;\n } else {\n return getNestedRule(\n ((rule as CSSGroupingRule).cssRules[position[1]] as CSSGroupingRule)\n .cssRules,\n position.slice(2),\n );\n }\n}\n\nexport function getPositionsAndIndex(nestedIndex: number[]) {\n const positions = [...nestedIndex];\n const index = positions.pop();\n return { positions, index };\n}\n\nexport function applyVirtualStyleRulesToNode(\n storedRules: VirtualStyleRules,\n styleNode: HTMLStyleElement,\n) {\n const { sheet } = styleNode;\n if (!sheet) {\n // styleNode without sheet means the DOM has been removed\n // so the rules no longer need to be applied\n return;\n }\n\n storedRules.forEach((rule) => {\n if (rule.type === StyleRuleType.Insert) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.insertRule(rule.cssText, index);\n } else {\n sheet.insertRule(rule.cssText, rule.index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n } else if (rule.type === StyleRuleType.Remove) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.deleteRule(index || 0);\n } else {\n sheet.deleteRule(rule.index);\n }\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else if (rule.type === StyleRuleType.Snapshot) {\n restoreSnapshotOfStyleRulesToNode(rule.cssTexts, styleNode);\n } else if (rule.type === StyleRuleType.SetProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.setProperty(rule.property, rule.value, rule.priority);\n } else if (rule.type === StyleRuleType.RemoveProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.removeProperty(rule.property);\n }\n });\n}\n\nfunction restoreSnapshotOfStyleRulesToNode(\n cssTexts: string[],\n styleNode: HTMLStyleElement,\n) {\n try {\n const existingRules = Array.from(styleNode.sheet?.cssRules || []).map(\n (rule) => rule.cssText,\n );\n const existingRulesReversed = Object.entries(existingRules).reverse();\n let lastMatch = existingRules.length;\n existingRulesReversed.forEach(([index, rule]) => {\n const indexOf = cssTexts.indexOf(rule);\n if (indexOf === -1 || indexOf > lastMatch) {\n try {\n styleNode.sheet?.deleteRule(Number(index));\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n }\n lastMatch = indexOf;\n });\n cssTexts.forEach((cssText, index) => {\n try {\n if (styleNode.sheet?.cssRules[index]?.cssText !== cssText) {\n styleNode.sheet?.insertRule(cssText, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n });\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n\nexport function storeCSSRules(\n parentElement: HTMLStyleElement,\n virtualStyleRulesMap: VirtualStyleRulesMap,\n) {\n try {\n const cssTexts = Array.from(\n (parentElement as HTMLStyleElement).sheet?.cssRules || [],\n ).map((rule) => rule.cssText);\n virtualStyleRulesMap.set((parentElement as unknown) as INode, [\n {\n type: StyleRuleType.Snapshot,\n cssTexts,\n },\n ]);\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { decode } from 'base64-arraybuffer';\nimport { Replayer } from '../';\nimport {\n CanvasContext,\n canvasMutationCommand,\n SerializedWebGlArg,\n} from '../../types';\n\n// TODO: add ability to wipe this list\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nfunction getContext(\n target: HTMLCanvasElement,\n type: CanvasContext,\n): WebGLRenderingContext | WebGL2RenderingContext | null {\n // Note to whomever is going to implement support for `contextAttributes`:\n // if `preserveDrawingBuffer` is set to true,\n // you might have to do `ctx.flush()` before every webgl canvas event\n try {\n if (type === CanvasContext.WebGL) {\n return (\n target.getContext('webgl')! || target.getContext('experimental-webgl')\n );\n }\n return target.getContext('webgl2')!;\n } catch (e) {\n return null;\n }\n}\n\nconst WebGLVariableConstructorsNames = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n];\n\nfunction saveToWebGLVarMap(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n result: any,\n) {\n if (!result?.constructor) return; // probably null or undefined\n\n const { name } = result.constructor;\n if (!WebGLVariableConstructorsNames.includes(name)) return; // not a WebGL variable\n\n const variables = variableListFor(ctx, name);\n if (!variables.includes(result)) variables.push(result);\n}\n\nexport function deserializeArg(\n imageMap: Replayer['imageMap'],\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n): (arg: SerializedWebGlArg) => any {\n return (arg: SerializedWebGlArg): any => {\n if (arg && typeof arg === 'object' && 'rr_type' in arg) {\n if ('index' in arg) {\n const { rr_type: name, index } = arg;\n return variableListFor(ctx, name)[index];\n } else if ('args' in arg) {\n const { rr_type: name, args } = arg;\n const ctor = window[name as keyof Window];\n\n return new ctor(...args.map(deserializeArg(imageMap, ctx)));\n } else if ('base64' in arg) {\n return decode(arg.base64);\n } else if ('src' in arg) {\n const image = imageMap.get(arg.src);\n if (image) {\n return image;\n } else {\n const image = new Image();\n image.src = arg.src;\n imageMap.set(arg.src, image);\n return image;\n }\n }\n } else if (Array.isArray(arg)) {\n return arg.map(deserializeArg(imageMap, ctx));\n }\n return arg;\n };\n}\n\nexport default function webglMutation({\n mutation,\n target,\n type,\n imageMap,\n errorHandler,\n}: {\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n type: CanvasContext;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = getContext(target, type);\n if (!ctx) return;\n\n // NOTE: if `preserveDrawingBuffer` is set to true,\n // we must flush the buffers on every new canvas event\n // if (mutation.newFrame) ctx.flush();\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n const args = mutation.args.map(deserializeArg(imageMap, ctx));\n const result = original.apply(ctx, args);\n saveToWebGLVarMap(ctx, result);\n\n // Slows down replay considerably, only use for debugging\n const debugMode = false;\n if (debugMode) {\n if (mutation.property === 'compileShader') {\n if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getShaderInfoLog(args[0]),\n );\n } else if (mutation.property === 'linkProgram') {\n ctx.validateProgram(args[0]);\n if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getProgramInfoLog(args[0]),\n );\n }\n const webglError = ctx.getError();\n if (webglError !== ctx.NO_ERROR) {\n console.warn(\n 'WEBGL ERROR',\n webglError,\n 'on command:',\n mutation.property,\n ...args,\n );\n }\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import {\n rebuild,\n buildNodeWithSN,\n INode,\n NodeType,\n BuildCache,\n createCache,\n} from 'rrweb-snapshot';\nimport * as mittProxy from 'mitt';\nimport { polyfill as smoothscrollPolyfill } from './smoothscroll';\nimport { Timer } from './timer';\nimport { createPlayerService, createSpeedService } from './machine';\nimport {\n EventType,\n IncrementalSource,\n fullSnapshotEvent,\n eventWithTime,\n MouseInteractions,\n playerConfig,\n playerMetaData,\n viewportResizeDimension,\n missingNodeMap,\n addedNodeMutation,\n missingNode,\n incrementalSnapshotEvent,\n incrementalData,\n ReplayerEvents,\n Handler,\n Emitter,\n MediaInteractions,\n metaEvent,\n mutationData,\n scrollData,\n inputData,\n canvasMutationData,\n Mirror,\n ElementState,\n styleAttributeValue,\n styleValueWithPriority,\n mouseMovePos,\n IWindow,\n canvasMutationCommand,\n textMutation,\n} from '../types';\nimport {\n createMirror,\n polyfill,\n TreeIndex,\n queueToResolveTrees,\n iterateResolveTree,\n AppendedIframe,\n isIframeINode,\n getBaseDimension,\n hasShadowRoot,\n} from '../utils';\nimport getInjectStyleRules from './styles/inject-style';\nimport './styles/style.css';\nimport {\n applyVirtualStyleRulesToNode,\n storeCSSRules,\n StyleRuleType,\n VirtualStyleRules,\n VirtualStyleRulesMap,\n getNestedRule,\n getPositionsAndIndex,\n} from './virtual-styles';\nimport canvasMutation from './canvas';\n\nconst SKIP_TIME_THRESHOLD = 10 * 1000;\nconst SKIP_TIME_INTERVAL = 5 * 1000;\n\n// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734\n// tslint:disable-next-line\nconst mitt = (mittProxy as any).default || mittProxy;\n\nconst REPLAY_CONSOLE_PREFIX = '[replayer]';\n\nconst defaultMouseTailConfig = {\n duration: 500,\n lineCap: 'round',\n lineWidth: 3,\n strokeStyle: 'red',\n} as const;\n\nfunction indicatesTouchDevice(e: eventWithTime) {\n return (\n e.type == EventType.IncrementalSnapshot &&\n (e.data.source == IncrementalSource.TouchMove ||\n (e.data.source == IncrementalSource.MouseInteraction &&\n e.data.type == MouseInteractions.TouchStart))\n );\n}\n\nexport class Replayer {\n public wrapper: HTMLDivElement;\n public iframe: HTMLIFrameElement;\n\n public service: ReturnType;\n public speedService: ReturnType;\n public get timer() {\n return this.service.state.context.timer;\n }\n\n public config: playerConfig;\n\n private mouse: HTMLDivElement;\n private mouseTail: HTMLCanvasElement | null = null;\n private tailPositions: Array<{ x: number; y: number }> = [];\n\n private emitter: Emitter = mitt();\n\n private nextUserInteractionEvent: eventWithTime | null;\n\n // tslint:disable-next-line: variable-name\n private legacy_missingNodeRetryMap: missingNodeMap = {};\n\n private treeIndex!: TreeIndex;\n private fragmentParentMap!: Map;\n private elementStateMap!: Map;\n // Hold the list of CSSRules for in-memory state restoration\n private virtualStyleRulesMap!: VirtualStyleRulesMap;\n\n // The replayer uses the cache to speed up replay and scrubbing.\n private cache: BuildCache = createCache();\n\n private imageMap: Map = new Map();\n\n private mirror: Mirror = createMirror();\n\n private firstFullSnapshot: eventWithTime | true | null = null;\n\n private newDocumentQueue: addedNodeMutation[] = [];\n\n private mousePos: mouseMovePos | null = null;\n private touchActive: boolean | null = null;\n\n constructor(\n events: Array,\n config?: Partial,\n ) {\n if (!config?.liveMode && events.length < 2) {\n throw new Error('Replayer need at least 2 events.');\n }\n const defaultConfig: playerConfig = {\n speed: 1,\n maxSpeed: 360,\n root: document.body,\n loadTimeout: 0,\n skipInactive: false,\n showWarning: true,\n showDebug: false,\n blockClass: 'rr-block',\n liveMode: false,\n insertStyleRules: [],\n triggerFocus: true,\n UNSAFE_replayCanvas: false,\n pauseAnimation: true,\n mouseTail: defaultMouseTailConfig,\n };\n this.config = Object.assign({}, defaultConfig, config);\n\n this.handleResize = this.handleResize.bind(this);\n this.getCastFn = this.getCastFn.bind(this);\n this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);\n this.emitter.on(ReplayerEvents.Resize, this.handleResize as Handler);\n\n this.setupDom();\n\n this.treeIndex = new TreeIndex();\n this.fragmentParentMap = new Map();\n this.elementStateMap = new Map();\n this.virtualStyleRulesMap = new Map();\n\n this.emitter.on(ReplayerEvents.Flush, () => {\n const { scrollMap, inputMap, mutationData } = this.treeIndex.flush();\n\n this.fragmentParentMap.forEach((parent, frag) =>\n this.restoreRealParent(frag, parent),\n );\n // apply text needs to happen before virtual style rules gets applied\n // as it can overwrite the contents of a stylesheet\n for (const d of mutationData.texts) {\n this.applyText(d, mutationData);\n }\n\n for (const node of this.virtualStyleRulesMap.keys()) {\n // restore css rules of style elements after they are mounted\n this.restoreNodeSheet(node);\n }\n this.fragmentParentMap.clear();\n this.elementStateMap.clear();\n this.virtualStyleRulesMap.clear();\n\n for (const d of scrollMap.values()) {\n this.applyScroll(d, true);\n }\n for (const d of inputMap.values()) {\n this.applyInput(d);\n }\n });\n this.emitter.on(ReplayerEvents.PlayBack, () => {\n this.firstFullSnapshot = null;\n this.mirror.reset();\n });\n\n const timer = new Timer([], config?.speed || defaultConfig.speed);\n this.service = createPlayerService(\n {\n events: events\n .map((e) => {\n if (config && config.unpackFn) {\n return config.unpackFn(e as string);\n }\n return e as eventWithTime;\n })\n .sort((a1, a2) => a1.timestamp - a2.timestamp),\n timer,\n timeOffset: 0,\n baselineTime: 0,\n lastPlayedEvent: null,\n },\n {\n getCastFn: this.getCastFn,\n applyEventsSynchronously: this.applyEventsSynchronously,\n emitter: this.emitter,\n },\n );\n this.service.start();\n this.service.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n player: state,\n });\n });\n this.speedService = createSpeedService({\n normalSpeed: -1,\n timer,\n });\n this.speedService.start();\n this.speedService.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n speed: state,\n });\n });\n\n // rebuild first full snapshot as the poster of the player\n // maybe we can cache it for performance optimization\n const firstMeta = this.service.state.context.events.find(\n (e) => e.type === EventType.Meta,\n );\n const firstFullsnapshot = this.service.state.context.events.find(\n (e) => e.type === EventType.FullSnapshot,\n );\n if (firstMeta) {\n const { width, height } = firstMeta.data as metaEvent['data'];\n setTimeout(() => {\n this.emitter.emit(ReplayerEvents.Resize, {\n width,\n height,\n });\n }, 0);\n }\n if (firstFullsnapshot) {\n setTimeout(() => {\n // when something has been played, there is no need to rebuild poster\n if (this.firstFullSnapshot) {\n // true if any other fullSnapshot has been executed by Timer already\n return;\n }\n this.firstFullSnapshot = firstFullsnapshot;\n this.rebuildFullSnapshot(\n firstFullsnapshot as fullSnapshotEvent & { timestamp: number },\n );\n this.iframe.contentWindow!.scrollTo(\n (firstFullsnapshot as fullSnapshotEvent).data.initialOffset,\n );\n }, 1);\n }\n if (this.service.state.context.events.find(indicatesTouchDevice)) {\n this.mouse.classList.add('touch-device');\n }\n }\n\n public on(event: string, handler: Handler) {\n this.emitter.on(event, handler);\n return this;\n }\n\n public off(event: string, handler: Handler) {\n this.emitter.off(event, handler);\n return this;\n }\n\n public setConfig(config: Partial) {\n Object.keys(config).forEach((key) => {\n // @ts-ignore\n this.config[key] = config[key];\n });\n if (!this.config.skipInactive) {\n this.backToNormal();\n }\n if (typeof config.speed !== 'undefined') {\n this.speedService.send({\n type: 'SET_SPEED',\n payload: {\n speed: config.speed!,\n },\n });\n }\n if (typeof config.mouseTail !== 'undefined') {\n if (config.mouseTail === false) {\n if (this.mouseTail) {\n this.mouseTail.style.display = 'none';\n }\n } else {\n if (!this.mouseTail) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.width = Number.parseFloat(this.iframe.width);\n this.mouseTail.height = Number.parseFloat(this.iframe.height);\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.wrapper.insertBefore(this.mouseTail, this.iframe);\n }\n this.mouseTail.style.display = 'inherit';\n }\n }\n }\n\n public getMetaData(): playerMetaData {\n const firstEvent = this.service.state.context.events[0];\n const lastEvent = this.service.state.context.events[\n this.service.state.context.events.length - 1\n ];\n return {\n startTime: firstEvent.timestamp,\n endTime: lastEvent.timestamp,\n totalTime: lastEvent.timestamp - firstEvent.timestamp,\n };\n }\n\n public getCurrentTime(): number {\n return this.timer.timeOffset + this.getTimeOffset();\n }\n\n public getTimeOffset(): number {\n const { baselineTime, events } = this.service.state.context;\n return baselineTime - events[0].timestamp;\n }\n\n public getMirror(): Mirror {\n return this.mirror;\n }\n\n /**\n * This API was designed to be used as play at any time offset.\n * Since we minimized the data collected from recorder, we do not\n * have the ability of undo an event.\n * So the implementation of play at any time offset will always iterate\n * all of the events, cast event before the offset synchronously\n * and cast event after the offset asynchronously with timer.\n * @param timeOffset number\n */\n public play(timeOffset = 0) {\n if (this.service.state.matches('paused')) {\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n } else {\n this.service.send({ type: 'PAUSE' });\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.remove('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Start);\n }\n\n public pause(timeOffset?: number) {\n if (timeOffset === undefined && this.service.state.matches('playing')) {\n this.service.send({ type: 'PAUSE' });\n }\n if (typeof timeOffset === 'number') {\n this.play(timeOffset);\n this.service.send({ type: 'PAUSE' });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Pause);\n }\n\n public resume(timeOffset = 0) {\n console.warn(\n `The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.`,\n );\n this.play(timeOffset);\n this.emitter.emit(ReplayerEvents.Resume);\n }\n\n public startLive(baselineTime?: number) {\n this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });\n }\n\n public addEvent(rawEvent: eventWithTime | string) {\n const event = this.config.unpackFn\n ? this.config.unpackFn(rawEvent as string)\n : (rawEvent as eventWithTime);\n if (indicatesTouchDevice(event)) {\n this.mouse.classList.add('touch-device');\n }\n Promise.resolve().then(() =>\n this.service.send({ type: 'ADD_EVENT', payload: { event } }),\n );\n }\n\n public enableInteract() {\n this.iframe.setAttribute('scrolling', 'auto');\n this.iframe.style.pointerEvents = 'auto';\n }\n\n public disableInteract() {\n this.iframe.setAttribute('scrolling', 'no');\n this.iframe.style.pointerEvents = 'none';\n }\n\n /**\n * Empties the replayer's cache and reclaims memory.\n * The replayer will use this cache to speed up the playback.\n */\n public resetCache() {\n this.cache = createCache();\n }\n\n private setupDom() {\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add('replayer-wrapper');\n this.config.root!.appendChild(this.wrapper);\n\n this.mouse = document.createElement('div');\n this.mouse.classList.add('replayer-mouse');\n this.wrapper.appendChild(this.mouse);\n\n if (this.config.mouseTail !== false) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.mouseTail.style.display = 'inherit';\n this.wrapper.appendChild(this.mouseTail);\n }\n\n this.iframe = document.createElement('iframe');\n const attributes = ['allow-same-origin'];\n if (this.config.UNSAFE_replayCanvas) {\n attributes.push('allow-scripts');\n }\n // hide iframe before first meta event\n this.iframe.style.display = 'none';\n this.iframe.setAttribute('sandbox', attributes.join(' '));\n this.disableInteract();\n this.wrapper.appendChild(this.iframe);\n if (this.iframe.contentWindow && this.iframe.contentDocument) {\n smoothscrollPolyfill(\n this.iframe.contentWindow,\n this.iframe.contentDocument,\n );\n\n polyfill(this.iframe.contentWindow as IWindow);\n }\n }\n\n private handleResize(dimension: viewportResizeDimension) {\n this.iframe.style.display = 'inherit';\n for (const el of [this.mouseTail, this.iframe]) {\n if (!el) {\n continue;\n }\n el.setAttribute('width', String(dimension.width));\n el.setAttribute('height', String(dimension.height));\n }\n }\n\n private applyEventsSynchronously(events: Array) {\n for (const event of events) {\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n case EventType.Custom:\n continue;\n case EventType.FullSnapshot:\n case EventType.Meta:\n case EventType.Plugin:\n break;\n case EventType.IncrementalSnapshot:\n switch (event.data.source) {\n case IncrementalSource.MediaInteraction:\n continue;\n default:\n break;\n }\n break;\n default:\n break;\n }\n const castFn = this.getCastFn(event, true);\n castFn();\n }\n if (this.mousePos) {\n this.moveAndHover(\n this.mousePos.x,\n this.mousePos.y,\n this.mousePos.id,\n true,\n this.mousePos.debugData,\n );\n }\n this.mousePos = null;\n if (this.touchActive === true) {\n this.mouse.classList.add('touch-active');\n } else if (this.touchActive === false) {\n this.mouse.classList.remove('touch-active');\n }\n this.touchActive = null;\n }\n\n private getCastFn(event: eventWithTime, isSync = false) {\n let castFn: undefined | (() => void);\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n break;\n case EventType.Custom:\n castFn = () => {\n /**\n * emit custom-event and pass the event object.\n *\n * This will add more value to the custom event and allows the client to react for custom-event.\n */\n this.emitter.emit(ReplayerEvents.CustomEvent, event);\n };\n break;\n case EventType.Meta:\n castFn = () =>\n this.emitter.emit(ReplayerEvents.Resize, {\n width: event.data.width,\n height: event.data.height,\n });\n break;\n case EventType.FullSnapshot:\n castFn = () => {\n if (this.firstFullSnapshot) {\n if (this.firstFullSnapshot === event) {\n // we've already built this exact FullSnapshot when the player was mounted, and haven't built any other FullSnapshot since\n this.firstFullSnapshot = true; // forget as we might need to re-execute this FullSnapshot later e.g. to rebuild after scrubbing\n return;\n }\n } else {\n // Timer (requestAnimationFrame) can be faster than setTimeout(..., 1)\n this.firstFullSnapshot = true;\n }\n this.rebuildFullSnapshot(event, isSync);\n this.iframe.contentWindow!.scrollTo(event.data.initialOffset);\n };\n break;\n case EventType.IncrementalSnapshot:\n castFn = () => {\n this.applyIncremental(event, isSync);\n if (isSync) {\n // do not check skip in sync\n return;\n }\n if (event === this.nextUserInteractionEvent) {\n this.nextUserInteractionEvent = null;\n this.backToNormal();\n }\n if (this.config.skipInactive && !this.nextUserInteractionEvent) {\n for (const _event of this.service.state.context.events) {\n if (_event.timestamp! <= event.timestamp!) {\n continue;\n }\n if (this.isUserInteraction(_event)) {\n if (\n _event.delay! - event.delay! >\n SKIP_TIME_THRESHOLD *\n this.speedService.state.context.timer.speed\n ) {\n this.nextUserInteractionEvent = _event;\n }\n break;\n }\n }\n if (this.nextUserInteractionEvent) {\n const skipTime =\n this.nextUserInteractionEvent.delay! - event.delay!;\n const payload = {\n speed: Math.min(\n Math.round(skipTime / SKIP_TIME_INTERVAL),\n this.config.maxSpeed,\n ),\n };\n this.speedService.send({ type: 'FAST_FORWARD', payload });\n this.emitter.emit(ReplayerEvents.SkipStart, payload);\n }\n }\n };\n break;\n default:\n }\n const wrappedCastFn = () => {\n if (castFn) {\n castFn();\n }\n\n for (const plugin of this.config.plugins || []) {\n plugin.handler(event, isSync, { replayer: this });\n }\n\n this.service.send({ type: 'CAST_EVENT', payload: { event } });\n\n // events are kept sorted by timestamp, check if this is the last event\n let last_index = this.service.state.context.events.length - 1;\n if (event === this.service.state.context.events[last_index]) {\n const finish = () => {\n if (last_index < this.service.state.context.events.length - 1) {\n // more events have been added since the setTimeout\n return;\n }\n this.backToNormal();\n this.service.send('END');\n this.emitter.emit(ReplayerEvents.Finish);\n };\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove &&\n event.data.positions.length\n ) {\n // defer finish event if the last event is a mouse move\n setTimeout(() => {\n finish();\n }, Math.max(0, -event.data.positions[0].timeOffset + 50)); // Add 50 to make sure the timer would check the last mousemove event. Otherwise, the timer may be stopped by the service before checking the last event.\n } else {\n finish();\n }\n }\n\n this.emitter.emit(ReplayerEvents.EventCast, event);\n };\n return wrappedCastFn;\n }\n\n private rebuildFullSnapshot(\n event: fullSnapshotEvent & { timestamp: number },\n isSync: boolean = false,\n ) {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n console.warn(\n 'Found unresolved missing node map',\n this.legacy_missingNodeRetryMap,\n );\n }\n this.legacy_missingNodeRetryMap = {};\n const collected: AppendedIframe[] = [];\n this.mirror.map = rebuild(event.data.node, {\n doc: this.iframe.contentDocument,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n },\n cache: this.cache,\n })[1];\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n const { documentElement, head } = this.iframe.contentDocument;\n this.insertStyleRules(documentElement, head);\n if (!this.service.state.matches('playing')) {\n this.iframe.contentDocument\n .getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n }\n this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);\n if (!isSync) {\n this.waitForStylesheetLoad();\n }\n if (this.config.UNSAFE_replayCanvas) {\n this.preloadAllImages();\n }\n }\n\n private insertStyleRules(\n documentElement: HTMLElement,\n head: HTMLHeadElement,\n ) {\n const styleEl = document.createElement('style');\n documentElement!.insertBefore(styleEl, head);\n const injectStylesRules = getInjectStyleRules(\n this.config.blockClass,\n ).concat(this.config.insertStyleRules);\n if (this.config.pauseAnimation) {\n injectStylesRules.push(\n 'html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }',\n );\n }\n for (let idx = 0; idx < injectStylesRules.length; idx++) {\n (styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);\n }\n }\n\n private attachDocumentToIframe(\n mutation: addedNodeMutation,\n iframeEl: HTMLIFrameElement,\n ) {\n const collected: AppendedIframe[] = [];\n // If iframeEl is detached from dom, iframeEl.contentDocument is null.\n if (!iframeEl.contentDocument) {\n let parent = iframeEl.parentNode;\n while (parent) {\n // The parent of iframeEl is virtual parent and we need to mount it on the dom.\n if (this.fragmentParentMap.has((parent as unknown) as INode)) {\n const frag = (parent as unknown) as INode;\n const realParent = this.fragmentParentMap.get(frag)!;\n this.restoreRealParent(frag, realParent);\n break;\n }\n parent = parent.parentNode;\n }\n }\n buildNodeWithSN(mutation.node, {\n doc: iframeEl.contentDocument!,\n map: this.mirror.map,\n hackCss: true,\n skipChild: false,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n if (\n builtNode.__sn.type === NodeType.Element &&\n builtNode.__sn.tagName.toUpperCase() === 'HTML'\n ) {\n const { documentElement, head } = iframeEl.contentDocument!;\n this.insertStyleRules(documentElement, head);\n }\n },\n cache: this.cache,\n });\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n private collectIframeAndAttachDocument(\n collected: AppendedIframe[],\n builtNode: INode,\n ) {\n if (isIframeINode(builtNode)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === builtNode.__sn.id,\n );\n if (mutationInQueue) {\n collected.push({ mutationInQueue, builtNode });\n }\n }\n }\n\n /**\n * pause when loading style sheet, resume when loaded all timeout exceed\n */\n private waitForStylesheetLoad() {\n const head = this.iframe.contentDocument?.head;\n if (head) {\n const unloadSheets: Set = new Set();\n let timer: ReturnType | -1;\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n const unsubscribe = () => {\n this.emitter.off(ReplayerEvents.Start, stateHandler);\n this.emitter.off(ReplayerEvents.Pause, stateHandler);\n };\n head\n .querySelectorAll('link[rel=\"stylesheet\"]')\n .forEach((css: HTMLLinkElement) => {\n if (!css.sheet) {\n unloadSheets.add(css);\n css.addEventListener('load', () => {\n unloadSheets.delete(css);\n // all loaded and timer not released yet\n if (unloadSheets.size === 0 && timer !== -1) {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);\n if (timer) {\n clearTimeout(timer);\n }\n unsubscribe();\n }\n });\n }\n });\n\n if (unloadSheets.size > 0) {\n // find some unload sheets after iterate\n this.service.send({ type: 'PAUSE' });\n this.emitter.emit(ReplayerEvents.LoadStylesheetStart);\n timer = setTimeout(() => {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n // mark timer was called\n timer = -1;\n unsubscribe();\n }, this.config.loadTimeout);\n }\n }\n }\n\n private hasImageArg(args: any[]): boolean {\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n if (this.hasImageArg(arg.args)) return true;\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n return true; // has image!\n } else if (arg instanceof Array) {\n if (this.hasImageArg(arg)) return true;\n }\n }\n return false;\n }\n\n private getImageArgs(args: any[]): string[] {\n const images: string[] = [];\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n images.push(...this.getImageArgs(arg.args));\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n images.push(arg.src);\n } else if (arg instanceof Array) {\n images.push(...this.getImageArgs(arg));\n }\n }\n return images;\n }\n\n /**\n * pause when there are some canvas drawImage args need to be loaded\n */\n private preloadAllImages() {\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n for (const event of this.service.state.context.events) {\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.CanvasMutation\n )\n if ('commands' in event.data) {\n event.data.commands.forEach((c) => this.preloadImages(c, event));\n } else {\n this.preloadImages(event.data, event);\n }\n }\n }\n\n private preloadImages(data: canvasMutationCommand, event: eventWithTime) {\n if (\n data.property === 'drawImage' &&\n typeof data.args[0] === 'string' &&\n !this.imageMap.has(event)\n ) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const imgd = ctx?.createImageData(canvas.width, canvas.height);\n let d = imgd?.data;\n d = JSON.parse(data.args[0]);\n ctx?.putImageData(imgd!, 0, 0);\n } else if (this.hasImageArg(data.args)) {\n this.getImageArgs(data.args).forEach((url) => {\n const image = new Image();\n image.src = url; // this preloads the image\n this.imageMap.set(url, image);\n });\n }\n }\n\n private applyIncremental(\n e: incrementalSnapshotEvent & { timestamp: number; delay?: number },\n isSync: boolean,\n ) {\n const { data: d } = e;\n switch (d.source) {\n case IncrementalSource.Mutation: {\n if (isSync) {\n d.adds.forEach((m) => this.treeIndex.add(m));\n d.texts.forEach((m) => {\n const target = this.mirror.getNode(m.id);\n const parent = (target?.parentNode as unknown) as INode | null;\n // remove any style rules that pending\n // for stylesheets where the contents get replaced\n if (parent && this.virtualStyleRulesMap.has(parent))\n this.virtualStyleRulesMap.delete(parent);\n\n this.treeIndex.text(m);\n });\n d.attributes.forEach((m) => this.treeIndex.attribute(m));\n d.removes.forEach((m) => this.treeIndex.remove(m, this.mirror));\n }\n try {\n this.applyMutation(d, isSync);\n } catch (error) {\n this.warn(`Exception in mutation ${error.message || error}`, d);\n }\n break;\n }\n case IncrementalSource.Drag:\n case IncrementalSource.TouchMove:\n case IncrementalSource.MouseMove:\n if (isSync) {\n const lastPosition = d.positions[d.positions.length - 1];\n this.mousePos = {\n x: lastPosition.x,\n y: lastPosition.y,\n id: lastPosition.id,\n debugData: d,\n };\n } else {\n d.positions.forEach((p) => {\n const action = {\n doAction: () => {\n this.moveAndHover(p.x, p.y, p.id, isSync, d);\n },\n delay:\n p.timeOffset +\n e.timestamp -\n this.service.state.context.baselineTime,\n };\n this.timer.addAction(action);\n });\n // add a dummy action to keep timer alive\n this.timer.addAction({\n doAction() {},\n delay: e.delay! - d.positions[0]?.timeOffset,\n });\n }\n break;\n case IncrementalSource.MouseInteraction: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n const event = new Event(MouseInteractions[d.type].toLowerCase());\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n this.emitter.emit(ReplayerEvents.MouseInteraction, {\n type: d.type,\n target,\n });\n const { triggerFocus } = this.config;\n switch (d.type) {\n case MouseInteractions.Blur:\n if ('blur' in ((target as Node) as HTMLElement)) {\n ((target as Node) as HTMLElement).blur();\n }\n break;\n case MouseInteractions.Focus:\n if (triggerFocus && ((target as Node) as HTMLElement).focus) {\n ((target as Node) as HTMLElement).focus({\n preventScroll: true,\n });\n }\n break;\n case MouseInteractions.Click:\n case MouseInteractions.TouchStart:\n case MouseInteractions.TouchEnd:\n if (isSync) {\n if (d.type === MouseInteractions.TouchStart) {\n this.touchActive = true;\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.touchActive = false;\n }\n this.mousePos = {\n x: d.x,\n y: d.y,\n id: d.id,\n debugData: d,\n };\n } else {\n if (d.type === MouseInteractions.TouchStart) {\n // don't draw a trail as user has lifted finger and is placing at a new point\n this.tailPositions.length = 0;\n }\n this.moveAndHover(d.x, d.y, d.id, isSync, d);\n if (d.type === MouseInteractions.Click) {\n /*\n * don't want target.click() here as could trigger an iframe navigation\n * instead any effects of the click should already be covered by mutations\n */\n /*\n * removal and addition of .active class (along with void line to trigger repaint)\n * triggers the 'click' css animation in styles/style.css\n */\n this.mouse.classList.remove('active');\n // tslint:disable-next-line\n void this.mouse.offsetWidth;\n this.mouse.classList.add('active');\n } else if (d.type === MouseInteractions.TouchStart) {\n void this.mouse.offsetWidth; // needed for the position update of moveAndHover to apply without the .touch-active transition\n this.mouse.classList.add('touch-active');\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.mouse.classList.remove('touch-active');\n }\n }\n break;\n case MouseInteractions.TouchCancel:\n if (isSync) {\n this.touchActive = false;\n } else {\n this.mouse.classList.remove('touch-active');\n }\n break;\n default:\n target.dispatchEvent(event);\n }\n break;\n }\n case IncrementalSource.Scroll: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.scroll(d);\n break;\n }\n this.applyScroll(d, false);\n break;\n }\n case IncrementalSource.ViewportResize:\n this.emitter.emit(ReplayerEvents.Resize, {\n width: d.width,\n height: d.height,\n });\n break;\n case IncrementalSource.Input: {\n /**\n * Input event on an unserialized node usually means the event\n * was synchrony triggered programmatically after the node was\n * created. This means there was not an user observable interaction\n * and we do not need to replay it.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.input(d);\n break;\n }\n this.applyInput(d);\n break;\n }\n case IncrementalSource.MediaInteraction: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n const mediaEl = (target as Node) as HTMLMediaElement;\n try {\n if (d.currentTime) {\n mediaEl.currentTime = d.currentTime;\n }\n if (d.volume) {\n mediaEl.volume = d.volume;\n }\n if (d.muted) {\n mediaEl.muted = d.muted;\n }\n if (d.type === MediaInteractions.Pause) {\n mediaEl.pause();\n }\n if (d.type === MediaInteractions.Play) {\n // remove listener for 'canplay' event because play() is async and returns a promise\n // i.e. media will evntualy start to play when data is loaded\n // 'canplay' event fires even when currentTime attribute changes which may lead to\n // unexpeted behavior\n mediaEl.play();\n }\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n `Failed to replay media interactions: ${error.message || error}`,\n );\n }\n }\n break;\n }\n case IncrementalSource.StyleSheetRule: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n /**\n * Always use existing DOM node, when it's there.\n * In in-memory replay, there is virtual node, but it's `sheet` is inaccessible.\n * Hence, we buffer all style changes in virtualStyleRulesMap.\n */\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules;\n\n if (!styleSheet) {\n /**\n * styleEl.sheet is only accessible if the styleEl is part of the\n * dom. This doesn't work on DocumentFragments so we have to add the\n * style mutations to the virtualStyleRulesMap.\n */\n\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.adds) {\n d.adds.forEach(({ rule, index: nestedIndex }) => {\n if (styleSheet) {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet.cssRules,\n positions,\n );\n nestedRule.insertRule(rule, index);\n } else {\n const index =\n nestedIndex === undefined\n ? undefined\n : Math.min(nestedIndex, styleSheet.cssRules.length);\n styleSheet.insertRule(rule, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else {\n rules?.push({\n cssText: rule,\n index: nestedIndex,\n type: StyleRuleType.Insert,\n });\n }\n });\n }\n\n if (d.removes) {\n d.removes.forEach(({ index: nestedIndex }) => {\n if (usingVirtualParent) {\n rules?.push({ index: nestedIndex, type: StyleRuleType.Remove });\n } else {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet!.cssRules,\n positions,\n );\n nestedRule.deleteRule(index || 0);\n } else {\n styleSheet?.deleteRule(nestedIndex);\n }\n } catch (e) {\n /**\n * same as insertRule\n */\n }\n }\n });\n }\n break;\n }\n case IncrementalSource.StyleDeclaration: {\n // same with StyleSheetRule\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules = [];\n\n if (!styleSheet) {\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.set) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.setProperty(d.set.property, d.set.value, d.set.priority);\n } else {\n rules.push({\n type: StyleRuleType.SetProperty,\n index: d.index,\n ...d.set,\n });\n }\n }\n\n if (d.remove) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.removeProperty(d.remove.property);\n } else {\n rules.push({\n type: StyleRuleType.RemoveProperty,\n index: d.index,\n ...d.remove,\n });\n }\n }\n break;\n }\n case IncrementalSource.CanvasMutation: {\n if (!this.config.UNSAFE_replayCanvas) {\n return;\n }\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n canvasMutation({\n event: e,\n mutation: d,\n target: (target as unknown) as HTMLCanvasElement,\n imageMap: this.imageMap,\n errorHandler: this.warnCanvasMutationFailed.bind(this),\n });\n\n break;\n }\n case IncrementalSource.Font: {\n try {\n const fontFace = new FontFace(\n d.family,\n d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource,\n d.descriptors,\n );\n this.iframe.contentDocument?.fonts.add(fontFace);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(error);\n }\n }\n break;\n }\n default:\n }\n }\n\n private applyMutation(d: mutationData, useVirtualParent: boolean) {\n d.removes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.parentId)) {\n // no need to warn, parent was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.virtualStyleRulesMap.has(target)) {\n this.virtualStyleRulesMap.delete(target);\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n return this.warnNodeNotFound(d, mutation.parentId);\n }\n if (mutation.isShadow && hasShadowRoot(parent)) {\n parent = parent.shadowRoot;\n }\n // target may be removed with its parents before\n this.mirror.removeNodeFromMap(target);\n if (parent) {\n let realTarget = null;\n const realParent =\n '__sn' in parent ? this.fragmentParentMap.get(parent) : undefined;\n if (realParent && realParent.contains(target)) {\n parent = realParent;\n } else if (this.fragmentParentMap.has(target)) {\n /**\n * the target itself is a fragment document and it's not in the dom\n * so we should remove the real target from its parent\n */\n realTarget = this.fragmentParentMap.get(target)!;\n this.fragmentParentMap.delete(target);\n target = realTarget;\n }\n try {\n parent.removeChild(target);\n } catch (error) {\n if (error instanceof DOMException) {\n this.warn(\n 'parent could not remove child in mutation',\n parent,\n realParent,\n target,\n realTarget,\n d,\n );\n } else {\n throw error;\n }\n }\n }\n });\n\n // tslint:disable-next-line: variable-name\n const legacy_missingNodeMap: missingNodeMap = {\n ...this.legacy_missingNodeRetryMap,\n };\n const queue: addedNodeMutation[] = [];\n\n // next not present at this moment\n const nextNotInDOM = (mutation: addedNodeMutation) => {\n let next: Node | null = null;\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n // next not present at this moment\n if (\n mutation.nextId !== null &&\n mutation.nextId !== undefined &&\n mutation.nextId !== -1 &&\n !next\n ) {\n return true;\n }\n return false;\n };\n\n const appendNode = (mutation: addedNodeMutation) => {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n if (mutation.node.type === NodeType.Document) {\n // is newly added document, maybe the document node of an iframe\n return this.newDocumentQueue.push(mutation);\n }\n return queue.push(mutation);\n }\n\n let parentInDocument = null;\n if (this.iframe.contentDocument.contains) {\n parentInDocument = this.iframe.contentDocument.contains(parent);\n } else if (this.iframe.contentDocument.body.contains) {\n // fix for IE\n // refer 'Internet Explorer notes' at https://developer.mozilla.org/zh-CN/docs/Web/API/Document\n parentInDocument = this.iframe.contentDocument.body.contains(parent);\n }\n\n const hasIframeChild =\n ((parent as unknown) as HTMLElement).getElementsByTagName?.('iframe')\n .length > 0;\n /**\n * Why !isIframeINode(parent)? If parent element is an iframe, iframe document can't be appended to virtual parent.\n * Why !hasIframeChild? If we move iframe elements from dom to fragment document, we will lose the contentDocument of iframe. So we need to disable the virtual dom optimization if a parent node contains iframe elements.\n */\n if (\n useVirtualParent &&\n parentInDocument &&\n !isIframeINode(parent) &&\n !hasIframeChild\n ) {\n const virtualParent = (document.createDocumentFragment() as unknown) as INode;\n this.mirror.map[mutation.parentId] = virtualParent;\n this.fragmentParentMap.set(virtualParent, parent);\n\n // store the state, like scroll position, of child nodes before they are unmounted from dom\n this.storeState(parent);\n\n while (parent.firstChild) {\n virtualParent.appendChild(parent.firstChild);\n }\n parent = virtualParent;\n }\n\n if (mutation.node.isShadow) {\n // If the parent is attached a shadow dom after it's created, it won't have a shadow root.\n if (!hasShadowRoot(parent)) {\n ((parent as Node) as HTMLElement).attachShadow({ mode: 'open' });\n parent = ((parent as Node) as HTMLElement).shadowRoot!;\n } else parent = parent.shadowRoot;\n }\n\n let previous: Node | null = null;\n let next: Node | null = null;\n if (mutation.previousId) {\n previous = this.mirror.getNode(mutation.previousId) as Node;\n }\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n if (nextNotInDOM(mutation)) {\n return queue.push(mutation);\n }\n\n if (mutation.node.rootId && !this.mirror.getNode(mutation.node.rootId)) {\n return;\n }\n\n const targetDoc = mutation.node.rootId\n ? this.mirror.getNode(mutation.node.rootId)\n : this.iframe.contentDocument;\n if (isIframeINode(parent)) {\n this.attachDocumentToIframe(mutation, parent);\n return;\n }\n const target = buildNodeWithSN(mutation.node, {\n doc: targetDoc as Document,\n map: this.mirror.map,\n skipChild: true,\n hackCss: true,\n cache: this.cache,\n }) as INode;\n\n // legacy data, we should not have -1 siblings any more\n if (mutation.previousId === -1 || mutation.nextId === -1) {\n legacy_missingNodeMap[mutation.node.id] = {\n node: target,\n mutation,\n };\n return;\n }\n\n if (\n '__sn' in parent &&\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n mutation.node.type === NodeType.Text\n ) {\n // https://github.com/rrweb-io/rrweb/issues/745\n // parent is textarea, will only keep one child node as the value\n for (const c of Array.from(parent.childNodes)) {\n if (c.nodeType === parent.TEXT_NODE) {\n parent.removeChild(c);\n }\n }\n }\n\n if (previous && previous.nextSibling && previous.nextSibling.parentNode) {\n parent.insertBefore(target, previous.nextSibling);\n } else if (next && next.parentNode) {\n // making sure the parent contains the reference nodes\n // before we insert target before next.\n parent.contains(next)\n ? parent.insertBefore(target, next)\n : parent.insertBefore(target, null);\n } else {\n /**\n * Sometimes the document changes and the MutationObserver is disconnected, so the removal of child elements can't be detected and recorded. After the change of document, we may get another mutation which adds a new html element, while the old html element still exists in the dom, and we need to remove the old html element first to avoid collision.\n */\n if (parent === targetDoc) {\n while (targetDoc.firstChild) {\n targetDoc.removeChild(targetDoc.firstChild);\n }\n }\n\n parent.appendChild(target);\n }\n\n if (isIframeINode(target)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === target.__sn.id,\n );\n if (mutationInQueue) {\n this.attachDocumentToIframe(mutationInQueue, target);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(\n legacy_missingNodeMap,\n parent,\n target,\n mutation,\n );\n }\n };\n\n d.adds.forEach((mutation) => {\n appendNode(mutation);\n });\n\n let startTime = Date.now();\n while (queue.length) {\n // transform queue to resolve tree\n const resolveTrees = queueToResolveTrees(queue);\n queue.length = 0;\n if (Date.now() - startTime > 500) {\n this.warn(\n 'Timeout in the loop, please check the resolve tree data:',\n resolveTrees,\n );\n break;\n }\n for (const tree of resolveTrees) {\n let parent = this.mirror.getNode(tree.value.parentId);\n if (!parent) {\n this.debug(\n 'Drop resolve tree since there is no parent for the root node.',\n tree,\n );\n } else {\n iterateResolveTree(tree, (mutation) => {\n appendNode(mutation);\n });\n }\n }\n }\n\n if (Object.keys(legacy_missingNodeMap).length) {\n Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);\n }\n\n d.texts.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n /**\n * apply text content to real parent directly\n */\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n target.textContent = mutation.value;\n });\n d.attributes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n for (const attributeName in mutation.attributes) {\n if (typeof attributeName === 'string') {\n const value = mutation.attributes[attributeName];\n if (value === null) {\n ((target as Node) as Element).removeAttribute(attributeName);\n } else if (typeof value === 'string') {\n try {\n ((target as Node) as Element).setAttribute(attributeName, value);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n 'An error occurred may due to the checkout feature.',\n error,\n );\n }\n }\n } else if (attributeName === 'style') {\n let styleValues = value as styleAttributeValue;\n const targetEl = (target as Node) as HTMLElement;\n for (var s in styleValues) {\n if (styleValues[s] === false) {\n targetEl.style.removeProperty(s);\n } else if (styleValues[s] instanceof Array) {\n const svp = styleValues[s] as styleValueWithPriority;\n targetEl.style.setProperty(s, svp[0], svp[1]);\n } else {\n const svs = styleValues[s] as string;\n targetEl.style.setProperty(s, svs);\n }\n }\n }\n }\n }\n });\n }\n\n /**\n * Apply the scroll data on real elements.\n * If the replayer is in sync mode, smooth scroll behavior should be disabled.\n * @param d the scroll data\n * @param isSync whether the replayer is in sync mode(fast-forward)\n */\n private applyScroll(d: scrollData, isSync: boolean) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n if ((target as Node) === this.iframe.contentDocument) {\n this.iframe.contentWindow!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else if (target.__sn.type === NodeType.Document) {\n // nest iframe content document\n ((target as unknown) as Document).defaultView!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else {\n try {\n ((target as Node) as Element).scrollTop = d.y;\n ((target as Node) as Element).scrollLeft = d.x;\n } catch (error) {\n /**\n * Seldomly we may found scroll target was removed before\n * its last scroll event.\n */\n }\n }\n }\n\n private applyInput(d: inputData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n try {\n ((target as Node) as HTMLInputElement).checked = d.isChecked;\n ((target as Node) as HTMLInputElement).value = d.text;\n } catch (error) {\n // for safe\n }\n }\n\n private applyText(d: textMutation, mutation: mutationData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(mutation, d.id);\n }\n try {\n ((target as Node) as HTMLElement).textContent = d.value;\n } catch (error) {\n // for safe\n }\n }\n\n private legacy_resolveMissingNode(\n map: missingNodeMap,\n parent: Node,\n target: Node,\n targetMutation: addedNodeMutation,\n ) {\n const { previousId, nextId } = targetMutation;\n const previousInMap = previousId && map[previousId];\n const nextInMap = nextId && map[nextId];\n if (previousInMap) {\n const { node, mutation } = previousInMap as missingNode;\n parent.insertBefore(node, target);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n if (nextInMap) {\n const { node, mutation } = nextInMap as missingNode;\n parent.insertBefore(node, target.nextSibling);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n }\n\n private moveAndHover(\n x: number,\n y: number,\n id: number,\n isSync: boolean,\n debugData: incrementalData,\n ) {\n const target = this.mirror.getNode(id);\n if (!target) {\n return this.debugNodeNotFound(debugData, id);\n }\n\n const base = getBaseDimension(target, this.iframe);\n const _x = x * base.absoluteScale + base.x;\n const _y = y * base.absoluteScale + base.y;\n\n this.mouse.style.left = `${_x}px`;\n this.mouse.style.top = `${_y}px`;\n if (!isSync) {\n this.drawMouseTail({ x: _x, y: _y });\n }\n this.hoverElements((target as Node) as Element);\n }\n\n private drawMouseTail(position: { x: number; y: number }) {\n if (!this.mouseTail) {\n return;\n }\n\n const { lineCap, lineWidth, strokeStyle, duration } =\n this.config.mouseTail === true\n ? defaultMouseTailConfig\n : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);\n\n const draw = () => {\n if (!this.mouseTail) {\n return;\n }\n const ctx = this.mouseTail.getContext('2d');\n if (!ctx || !this.tailPositions.length) {\n return;\n }\n ctx.clearRect(0, 0, this.mouseTail.width, this.mouseTail.height);\n ctx.beginPath();\n ctx.lineWidth = lineWidth;\n ctx.lineCap = lineCap;\n ctx.strokeStyle = strokeStyle;\n ctx.moveTo(this.tailPositions[0].x, this.tailPositions[0].y);\n this.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));\n ctx.stroke();\n };\n\n this.tailPositions.push(position);\n draw();\n setTimeout(() => {\n this.tailPositions = this.tailPositions.filter((p) => p !== position);\n draw();\n }, duration / this.speedService.state.context.timer.speed);\n }\n\n private hoverElements(el: Element) {\n this.iframe.contentDocument\n ?.querySelectorAll('.\\\\:hover')\n .forEach((hoveredEl) => {\n hoveredEl.classList.remove(':hover');\n });\n let currentEl: Element | null = el;\n while (currentEl) {\n if (currentEl.classList) {\n currentEl.classList.add(':hover');\n }\n currentEl = currentEl.parentElement;\n }\n }\n\n private isUserInteraction(event: eventWithTime): boolean {\n if (event.type !== EventType.IncrementalSnapshot) {\n return false;\n }\n return (\n event.data.source > IncrementalSource.Mutation &&\n event.data.source <= IncrementalSource.Input\n );\n }\n\n private backToNormal() {\n this.nextUserInteractionEvent = null;\n if (this.speedService.state.matches('normal')) {\n return;\n }\n this.speedService.send({ type: 'BACK_TO_NORMAL' });\n this.emitter.emit(ReplayerEvents.SkipEnd, {\n speed: this.speedService.state.context.normalSpeed,\n });\n }\n\n /**\n * Replace the virtual parent with the real parent.\n * @param frag fragment document, the virtual parent\n * @param parent real parent element\n */\n private restoreRealParent(frag: INode, parent: INode) {\n this.mirror.map[parent.__sn.id] = parent;\n /**\n * If we have already set value attribute on textarea,\n * then we could not apply text content as default value any more.\n */\n if (\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n frag.textContent\n ) {\n ((parent as unknown) as HTMLTextAreaElement).value = frag.textContent;\n }\n parent.appendChild(frag);\n // restore state of elements after they are mounted\n this.restoreState(parent);\n }\n\n /**\n * store state of elements before unmounted from dom recursively\n * the state should be restored in the handler of event ReplayerEvents.Flush\n * e.g. browser would lose scroll position after the process that we add children of parent node to Fragment Document as virtual dom\n */\n private storeState(parent: INode) {\n if (parent) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (parentElement.scrollLeft || parentElement.scrollTop) {\n // store scroll position state\n this.elementStateMap.set(parent, {\n scroll: [parentElement.scrollLeft, parentElement.scrollTop],\n });\n }\n if (parentElement.tagName === 'STYLE')\n storeCSSRules(\n parentElement as HTMLStyleElement,\n this.virtualStyleRulesMap,\n );\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.storeState((child as unknown) as INode);\n }\n }\n }\n }\n\n /**\n * restore the state of elements recursively, which was stored before elements were unmounted from dom in virtual parent mode\n * this function corresponds to function storeState\n */\n private restoreState(parent: INode) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (this.elementStateMap.has(parent)) {\n const storedState = this.elementStateMap.get(parent)!;\n // restore scroll position\n if (storedState.scroll) {\n parentElement.scrollLeft = storedState.scroll[0];\n parentElement.scrollTop = storedState.scroll[1];\n }\n this.elementStateMap.delete(parent);\n }\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.restoreState((child as unknown) as INode);\n }\n }\n }\n\n private restoreNodeSheet(node: INode) {\n const storedRules = this.virtualStyleRulesMap.get(node);\n if (node.nodeName !== 'STYLE') {\n return;\n }\n\n if (!storedRules) {\n return;\n }\n\n const styleNode = (node as unknown) as HTMLStyleElement;\n\n applyVirtualStyleRulesToNode(storedRules, styleNode);\n }\n\n private warnNodeNotFound(d: incrementalData, id: number) {\n if (this.treeIndex.idRemoved(id)) {\n this.warn(`Node with id '${id}' was previously removed. `, d);\n } else {\n this.warn(`Node with id '${id}' not found. `, d);\n }\n }\n\n private warnCanvasMutationFailed(\n d: canvasMutationData | canvasMutationCommand,\n error: unknown,\n ) {\n this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);\n }\n\n private debugNodeNotFound(d: incrementalData, id: number) {\n /**\n * There maybe some valid scenes of node not being found.\n * Because DOM events are macrotask and MutationObserver callback\n * is microtask, so events fired on a removed DOM may emit\n * snapshots in the reverse order.\n */\n if (this.treeIndex.idRemoved(id)) {\n this.debug(\n REPLAY_CONSOLE_PREFIX,\n `Node with id '${id}' was previously removed. `,\n d,\n );\n } else {\n this.debug(REPLAY_CONSOLE_PREFIX, `Node with id '${id}' not found. `, d);\n }\n }\n\n private warn(...args: Parameters) {\n if (!this.config.showWarning) {\n return;\n }\n console.warn(REPLAY_CONSOLE_PREFIX, ...args);\n }\n\n private debug(...args: Parameters) {\n if (!this.config.showDebug) {\n return;\n }\n // tslint:disable-next-line: no-console\n console.log(REPLAY_CONSOLE_PREFIX, ...args);\n }\n}\n","import { Replayer } from '..';\nimport {\n CanvasContext,\n canvasMutationCommand,\n canvasMutationData,\n} from '../../types';\nimport webglMutation from './webgl';\nimport canvas2DMutation from './2d';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationData;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const mutations: canvasMutationCommand[] =\n 'commands' in mutation ? mutation.commands : [mutation];\n\n if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {\n return mutations.forEach((command) => {\n webglMutation({\n mutation: command,\n type: mutation.type,\n target,\n imageMap,\n errorHandler,\n });\n });\n }\n // default is '2d' for backwards compatibility (rrweb below 1.1.x)\n return mutations.forEach((command) => {\n canvas2DMutation({\n event,\n mutation: command,\n target,\n imageMap,\n errorHandler,\n });\n });\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import { Replayer } from '../';\nimport { canvasMutationCommand } from '../../types';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = ((target as unknown) as HTMLCanvasElement).getContext('2d')!;\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n /**\n * We have serialized the image source into base64 string during recording,\n * which has been preloaded before replay.\n * So we can get call drawImage SYNCHRONOUSLY which avoid some fragile cast.\n */\n if (\n mutation.property === 'drawImage' &&\n typeof mutation.args[0] === 'string'\n ) {\n const image = imageMap.get(event);\n mutation.args[0] = image;\n original.apply(ctx, mutation.args);\n } else {\n original.apply(ctx, mutation.args);\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isElement","nodeType","ELEMENT_NODE","commentre","parse","css","options","lineno","column","updatePosition","str","lines","match","lastIndexOf","position","start","line","node","Position","whitespace","end","source","content","errorsList","msg","err","Error","reason","filename","silent","open","close","rules","comments","charAt","atrule","rule","re","exec","c","comment","pos","type","selector","trim","replace","split","map","declaration","propMatch","prop","val","ret","property","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","name","RegExp","vendor","frame","frames","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","doc","document","atdocument","sel","selectors","atpage","athost","atfontface","addParent","stylesheet","parsingErrors","obj","parent","isNode","childParent","_i","_a","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","script","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cssText","cache","cachedStyle","stylesWithHoverClass","get","ast","test","selectorMatcher","filter","index","indexOf","sort","a","b","join","result","newSelector","set","createCache","Map","buildNode","hackCss","Document","implementation","createDocument","DocumentType","createDocumentType","publicId","systemId","Element","node_1","tagName","attributes","_cssText","getTagName","isSVG","createElementNS","createElement","_loop_1","name_1","startsWith","image_1","src","onload","ctx","getContext","drawImage","width","height","image","currentSrc","setAttribute","currentTime","rr_mediaCurrentTime","play","console","warn","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","childNodes","TEXT_NODE","removeChild","appendChild","setAttributeNS","substring","rel","as","href","endsWith","srcset","rr_dataURL","isShadowHost","shadowRoot","firstChild","attachShadow","mode","Text","isStyle","textContent","CDATA","createCDATASection","Comment","createComment","buildNodeWithSN","skipChild","_b","afterAppend","rootId","assert","compatMode","xmlns","write","__sn","id","_c","childN","childNode","isShadow","rebuild","onVisit","idNodeMap","key","visit","visitedNode","el","name_2","scrollLeft","scrollTop","handleScroll","mitt","all","create","on","handler","off","splice","emit","evt","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","polyfill","w","d","documentElement","__forceSmoothScrollPolyfill__","userAgent","HTMLElement","original","scroll","scrollTo","scrollBy","elementScroll","scrollElement","scrollIntoView","now","performance","bind","Date","ROUNDING_TOLERANCE","navigator","undefined","shouldBailOut","smoothScroll","body","left","scrollX","pageXOffset","top","scrollY","pageYOffset","SyntaxError","behavior","scrollableParent","findScrollableParent","parentRects","getBoundingClientRect","clientRects","getComputedStyle","x","y","firstArg","hasScrollableSpace","axis","clientHeight","scrollHeight","clientWidth","scrollWidth","canOverflow","overflowValue","isScrollable","isScrollableY","isScrollableX","parentNode","host","step","context","currentX","currentY","k","elapsed","startTime","Math","cos","PI","startX","startY","method","scrollable","requestAnimationFrame","actions","speed","Timer","action","findActionIndex","timeOffset","lastTimestamp","self","raf","check","time","delay","shift","doAction","liveMode","cancelAnimationFrame","mid","floor","addDelay","event","baselineTime","IncrementalSnapshot","data","MouseMove","firstOffset","positions","firstTimestamp","timestamp","return","NotStarted","Running","Stopped","assignment","u","changed","matches","f","states","initial","entry","config","_options","initialState","transition","g","h","S","target","j","E","R","N","cond","O","_","T","q","exit","z","A","B","C","Set","_machine","send","subscribe","add","unsubscribe","delete","stop","clear","state","status","createPlayerService","getCastFn","applyEventsSynchronously","emitter","interpret","createMachine","playing","PAUSE","CAST_EVENT","END","ADD_EVENT","paused","PLAY","TO_LIVE","live","castEvent","lastPlayedEvent","payload","recordTimeOffset","events","timer","events_1","neededEvents","idx","event_1","Meta","discardPriorSnapshots","lastPlayedTimestamp","PlayBack","syncEvents","event_3","castFn_1","neededEvents_1","Flush","addActions","resetLastPlayedEvent","startLive","toggleLiveMode","addEvent","machineEvent","event_4","insertionIndex","isSync","castFn_2","isActive","addAction","DEPARTED_MIRROR_ACCESS_WARNING","_mirror","getId","getNode","removeNodeFromMap","has","reset","window","Proxy","Reflect","receiver","TreeIndex","mutation","parentTreeNode","indexes","parentId","treeNode","children","texts","tree","mirror","deepRemoveFromMirror","_this","removeIdSet","deepRemoveFromTreeIndex","_treeNode","_parentTreeNode","removeNodeMutations","textMutations","attributeMutations","scrollMap","inputMap","batchMutationData","Mutation","removes","adds","walk","removed","_d","_f","mutationData","queueToResolveTrees","queue","queueNodeMap","putIntoMap","nodeInTree","queueNodeTrees","queue_1","nextId","nextInTree","parentInTree","iterateResolveTree","cb","isIframeINode","getBaseDimension","rootIframe","frameElement","ownerDocument","defaultView","relativeScale","absoluteScale","frameDimension","frameBaseDimension","hasShadowRoot","Boolean","StyleRuleType","getNestedRule","cssRules","getPositionsAndIndex","nestedIndex","pop","applyVirtualStyleRulesToNode","storedRules","styleNode","sheet","Insert","insertRule","Remove","deleteRule","Snapshot","cssTexts","existingRules","existingRulesReversed","entries","reverse","lastMatch_1","Number","restoreSnapshotOfStyleRulesToNode","SetProperty","setProperty","priority","RemoveProperty","removeProperty","chars","lookup","Uint8Array","charCodeAt","webGLVarMap","variableListFor","ctor","contextMap","WebGLVariableConstructorsNames","deserializeArg","imageMap","arg","args","base64","encoded1","encoded2","encoded3","encoded4","bufferLength","len","arraybuffer","ArrayBuffer","bytes","decode","Image","webglMutation","errorHandler","WebGL","setter","constructor","includes","variables","saveToWebGLVarMap","mittProxy.default","mittProxy","REPLAY_CONSOLE_PREFIX","defaultMouseTailConfig","duration","lineCap","lineWidth","strokeStyle","indicatesTouchDevice","TouchMove","MouseInteraction","TouchStart","defaultConfig","maxSpeed","root","loadTimeout","skipInactive","showWarning","showDebug","blockClass","insertStyleRules","triggerFocus","UNSAFE_replayCanvas","pauseAnimation","mouseTail","handleResize","Resize","setupDom","treeIndex","fragmentParentMap","elementStateMap","virtualStyleRulesMap","_e","flush","frag","restoreRealParent","applyText","_h","restoreNodeSheet","_k","applyScroll","_m","applyInput","firstFullSnapshot","service","unpackFn","a1","a2","StateChange","player","speedService","normalSpeed","normal","FAST_FORWARD","SET_SPEED","skipping","BACK_TO_NORMAL","setSpeed","recordSpeed","restoreSpeed","firstMeta","find","firstFullsnapshot","FullSnapshot","width_1","height_1","setTimeout","rebuildFullSnapshot","iframe","contentWindow","initialOffset","mouse","classList","Replayer","backToNormal","display","parseFloat","wrapper","insertBefore","firstEvent","lastEvent","endTime","totalTime","getTimeOffset","contentDocument","getElementsByTagName","remove","Start","Pause","Resume","rawEvent","Promise","resolve","then","pointerEvents","win","disableInteract","smoothscrollPolyfill","NodeList","DOMTokenList","Node","contains","dimension","String","DomContentLoaded","Load","Custom","Plugin","MediaInteraction","castFn","mousePos","moveAndHover","debugData","touchActive","CustomEvent","applyIncremental","nextUserInteractionEvent","_event","isUserInteraction","skipTime","min","round","SkipStart","plugins","replayer","last_index","finish_1","Finish","max","EventCast","legacy_missingNodeRetryMap","collected","builtNode","collectIframeAndAttachDocument","mutationInQueue","this_1","attachDocumentToIframe","newDocumentQueue","collected_1","head","FullsnapshotRebuilded","waitForStylesheetLoad","preloadAllImages","styleEl","injectStylesRules","iframeEl","parent_1","realParent","toUpperCase","this_2","collected_2","timer_1","unloadSheets_1","beforeLoadState_1","stateHandler_1","unsubscribe_1","querySelectorAll","addEventListener","size","getCurrentTime","LoadStylesheetEnd","clearTimeout","LoadStylesheetStart","args_1","hasImageArg","rr_type","images","args_2","getImageArgs","stateHandler","event_2","CanvasMutation","commands","preloadImages","this_3","url","canvas","imgd","createImageData","JSON","putImageData","text","attribute","applyMutation","message","Drag","lastPosition","Event","toLowerCase","debugNodeNotFound","Blur","blur","Focus","focus","preventScroll","Click","TouchEnd","tailPositions","offsetWidth","TouchCancel","dispatchEvent","Scroll","ViewportResize","Input","input","mediaEl","volume","muted","StyleSheetRule","rules_1","parent_2","usingVirtualParent_1","styleSheet_1","StyleDeclaration","parent_3","styleSheet","mutations","WebGL2","command","canvas2DMutation","canvasMutation","warnCanvasMutationFailed","Font","fontFace","FontFace","family","buffer","fontSource","descriptors","fonts","useVirtualParent","warnNodeNotFound","realTarget","DOMException","legacy_missingNodeMap","appendNode","parentInDocument","hasIframeChild","virtualParent","createDocumentFragment","storeState","previous","previousId","nextNotInDOM","targetDoc","nextSibling","mutationInQueue_1","legacy_resolveMissingNode","resolveTrees","resolveTrees_1","debug","attributeName","removeAttribute","styleValues","targetEl","svp","svs","checked","isChecked","targetMutation","previousInMap","nextInMap","base","_x","_y","drawMouseTail","hoverElements","draw","clearRect","beginPath","moveTo","lineTo","stroke","hoveredEl","currentEl","parentElement","SkipEnd","restoreState","storeCSSRules","storedState","nodeName","idRemoved","log"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ED+BOC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,YAgFzB,SAASQ,EAASC,GACrB,IAAIZ,EAAsB,mBAAXa,QAAyBA,OAAOC,SAAUC,EAAIf,GAAKY,EAAEZ,GAAIC,EAAI,EAC5E,GAAIc,EAAG,OAAOA,EAAEP,KAAKI,GACrB,GAAIA,GAAyB,iBAAbA,EAAER,OAAqB,MAAO,CAC1CY,KAAM,WAEF,OADIJ,GAAKX,GAAKW,EAAER,SAAQQ,OAAI,GACrB,CAAEK,MAAOL,GAAKA,EAAEX,KAAMiB,MAAON,KAG5C,MAAM,IAAIO,UAAUnB,EAAI,0BAA4B,mCAGjD,SAASoB,EAAOR,EAAGV,GACtB,IAAIa,EAAsB,mBAAXF,QAAyBD,EAAEC,OAAOC,UACjD,IAAKC,EAAG,OAAOH,EACf,IAAmBS,EAAYC,EAA3BrB,EAAIc,EAAEP,KAAKI,GAAOW,EAAK,GAC3B,IACI,WAAc,IAANrB,GAAgBA,KAAM,MAAQmB,EAAIpB,EAAEe,QAAQE,MAAMK,EAAGC,KAAKH,EAAEJ,OAExE,MAAOQ,GAASH,EAAI,CAAEG,MAAOA,WAEz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R,SAA0BjY,EAAoBjC,GAOxCxQ,KAAK6nB,UAAU6P,UAAUlnB,GAC3BxQ,KAAK21B,MACHxP,GACA,wBAAiB3V,gCACjBiC,GAGFzS,KAAK21B,MAAMxP,GAAuB,wBAAiB3V,mBAAmBiC,IAIlEiY,iBAAR,eAAa,aAAArjB,mBAAAA,IAAAud,kBACN5kB,KAAKoZ,OAAO8N,aAGjBnZ,QAAQC,WAARD,WAAaoY,MAA0BvB,SAGjC8F,kBAAR,eAAc,aAAArjB,mBAAAA,IAAAud,kBACP5kB,KAAKoZ,OAAO+N,WAIjBpZ,QAAQ4pB,UAAR5pB,WAAYoY,MAA0BvB"} +\ No newline at end of file +diff --git a/node_modules/rrweb/dist/rrweb-all.css b/node_modules/rrweb/dist/rrweb-all.css +new file mode 100755 +index 0000000..b459e51 +--- /dev/null ++++ b/node_modules/rrweb/dist/rrweb-all.css +@@ -0,0 +1,79 @@ ++.replayer-wrapper { ++ position: relative; ++} ++.replayer-mouse { ++ position: absolute; ++ width: 20px; ++ height: 20px; ++ transition: left 0.05s linear, top 0.05s linear; ++ background-size: contain; ++ background-position: center center; ++ background-repeat: no-repeat; ++ background-image: url('data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzMwMHB4JyB3aWR0aD0nMzAwcHgnICBmaWxsPSIjMDAwMDAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGRhdGEtbmFtZT0iTGF5ZXIgMSIgdmlld0JveD0iMCAwIDUwIDUwIiB4PSIwcHgiIHk9IjBweCI+PHRpdGxlPkRlc2lnbl90bnA8L3RpdGxlPjxwYXRoIGQ9Ik00OC43MSw0Mi45MUwzNC4wOCwyOC4yOSw0NC4zMywxOEExLDEsMCwwLDAsNDQsMTYuMzlMMi4zNSwxLjA2QTEsMSwwLDAsMCwxLjA2LDIuMzVMMTYuMzksNDRhMSwxLDAsMCwwLDEuNjUuMzZMMjguMjksMzQuMDgsNDIuOTEsNDguNzFhMSwxLDAsMCwwLDEuNDEsMGw0LjM4LTQuMzhBMSwxLDAsMCwwLDQ4LjcxLDQyLjkxWm0tNS4wOSwzLjY3TDI5LDMyYTEsMSwwLDAsMC0xLjQxLDBsLTkuODUsOS44NUwzLjY5LDMuNjlsMzguMTIsMTRMMzIsMjcuNThBMSwxLDAsMCwwLDMyLDI5TDQ2LjU5LDQzLjYyWiI+PC9wYXRoPjwvc3ZnPg=='); ++ border-color: transparent; /* otherwise we transition from black when .touch-device class is added */ ++} ++.replayer-mouse::after { ++ content: ''; ++ display: inline-block; ++ width: 20px; ++ height: 20px; ++ background: rgb(73, 80, 246); ++ border-radius: 100%; ++ transform: translate(-50%, -50%); ++ opacity: 0.3; ++} ++.replayer-mouse.active::after { ++ animation: click 0.2s ease-in-out 1; ++} ++.replayer-mouse.touch-device { ++ background-image: none; /* there's no passive cursor on touch-only screens */ ++ width: 70px; ++ height: 70px; ++ border-width: 4px; ++ border-style: solid; ++ border-radius: 100%; ++ margin-left: -37px; ++ margin-top: -37px; ++ border-color: rgba(73, 80, 246, 0); ++ transition: left 0s linear, top 0s linear, border-color 0.2s ease-in-out; ++} ++.replayer-mouse.touch-device.touch-active { ++ border-color: rgba(73, 80, 246, 1); ++ transition: left 0.25s linear, top 0.25s linear, border-color 0.2s ease-in-out; ++} ++.replayer-mouse.touch-device::after { ++ opacity: 0; /* there's no passive cursor on touch-only screens */ ++} ++.replayer-mouse.touch-device.active::after { ++ animation: touch-click 0.2s ease-in-out 1; ++} ++.replayer-mouse-tail { ++ position: absolute; ++ pointer-events: none; ++} ++ ++@keyframes click { ++ 0% { ++ opacity: 0.3; ++ width: 20px; ++ height: 20px; ++ } ++ 50% { ++ opacity: 0.5; ++ width: 10px; ++ height: 10px; ++ } ++} ++ ++@keyframes touch-click { ++ 0% { ++ opacity: 0; ++ width: 20px; ++ height: 20px; ++ } ++ 50% { ++ opacity: 0.5; ++ width: 10px; ++ height: 10px; ++ } ++} +diff --git a/node_modules/rrweb/dist/rrweb-all.js b/node_modules/rrweb/dist/rrweb-all.js +old mode 100644 +new mode 100755 +index cf12dce..364b390 +--- a/node_modules/rrweb/dist/rrweb-all.js ++++ b/node_modules/rrweb/dist/rrweb-all.js +@@ -97,10 +97,14 @@ var rrweb = (function (exports) { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -327,7 +331,10 @@ var rrweb = (function (exports) { + return value; + } + } +- function _isBlockedElement(element, blockClass, blockSelector) { ++ function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -346,11 +353,16 @@ var rrweb = (function (exports) { + } + return false; + } +- function needMaskingText(node, maskTextClass, maskTextSelector) { ++ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -369,12 +381,12 @@ var rrweb = (function (exports) { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -414,7 +426,7 @@ var rrweb = (function (exports) { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -446,7 +458,7 @@ var rrweb = (function (exports) { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -487,9 +499,12 @@ var rrweb = (function (exports) { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -608,7 +623,7 @@ var rrweb = (function (exports) { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -716,15 +731,19 @@ var rrweb = (function (exports) { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -780,10 +799,14 @@ var rrweb = (function (exports) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -828,10 +851,14 @@ var rrweb = (function (exports) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -854,7 +881,7 @@ var rrweb = (function (exports) { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -903,10 +930,14 @@ var rrweb = (function (exports) { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -2442,8 +2473,12 @@ var rrweb = (function (exports) { + map: _this.mirror.map, + blockClass: _this.blockClass, + blockSelector: _this.blockSelector, ++ unblockSelector: _this.unblockSelector, + maskTextClass: _this.maskTextClass, + maskTextSelector: _this.maskTextSelector, ++ unmaskTextSelector: _this.unmaskTextSelector, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + skipChild: true, + inlineStylesheet: _this.inlineStylesheet, + maskInputOptions: _this.maskInputOptions, +@@ -2589,7 +2624,7 @@ var rrweb = (function (exports) { + var value = m.target.textContent; + if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) { + _this.texts.push({ +- value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector) && value ++ value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, _this.unmaskTextSelector) && value + ? _this.maskTextFn + ? _this.maskTextFn(value) + : value.replace(/[\S]/g, '*') +@@ -2604,6 +2639,9 @@ var rrweb = (function (exports) { + var value = m.target.getAttribute(m.attributeName); + if (m.attributeName === 'value') { + value = maskInputValue({ ++ input: target, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + maskInputOptions: _this.maskInputOptions, + tagName: m.target.tagName, + type: m.target.getAttribute('type'), +@@ -2740,8 +2778,12 @@ var rrweb = (function (exports) { + 'mutationCb', + 'blockClass', + 'blockSelector', ++ 'unblockSelector', + 'maskTextClass', + 'maskTextSelector', ++ 'unmaskTextSelector', ++ 'maskInputSelector', ++ 'unmaskInputSelector', + 'inlineStylesheet', + 'maskInputOptions', + 'maskTextFn', +@@ -3005,7 +3047,7 @@ var rrweb = (function (exports) { + var INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT']; + var lastInputValueMap = new WeakMap(); + function initInputObserver(_a) { +- var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; ++ var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; + function eventHandler(event) { + var target = getEventTarget(event); + var userTriggered = event.isTrusted; +@@ -3018,7 +3060,7 @@ var rrweb = (function (exports) { + return; + } + var type = target.type; +- if (target.classList.contains(ignoreClass)) { ++ if (target.classList.contains(ignoreClass) || (ignoreSelector && target.matches(ignoreSelector))) { + return; + } + var text = target.value; +@@ -3029,7 +3071,10 @@ var rrweb = (function (exports) { + else if (maskInputOptions[target.tagName.toLowerCase()] || + maskInputOptions[type]) { + text = maskInputValue({ ++ input: target, + maskInputOptions: maskInputOptions, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + tagName: target.tagName, + type: type, + value: text, +@@ -3113,6 +3158,9 @@ var rrweb = (function (exports) { + function initStyleSheetObserver(_a, _b) { + var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror; + var win = _b.win; ++ if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) { ++ return function () { }; ++ } + var insertRule = win.CSSStyleSheet.prototype.insertRule; + win.CSSStyleSheet.prototype.insertRule = function (rule, index) { + var id = mirror.getId(this.ownerNode); +@@ -3965,7 +4013,7 @@ var rrweb = (function (exports) { + var mirror = createMirror(); + function record(options) { + if (options === void 0) { options = {}; } +- var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.ignoreClass, ignoreClass = _c === void 0 ? 'rr-ignore' : _c, _d = options.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = options.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = options.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _g = options.sampling, sampling = _g === void 0 ? {} : _g, mousemoveWait = options.mousemoveWait, _h = options.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = options.userTriggeredOnInput, userTriggeredOnInput = _j === void 0 ? false : _j, _k = options.collectFonts, collectFonts = _k === void 0 ? false : _k, _l = options.inlineImages, inlineImages = _l === void 0 ? false : _l, plugins = options.plugins, _m = options.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m; ++ var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s; + if (!emit) { + throw new Error('emit function is required'); + } +@@ -4096,8 +4144,12 @@ var rrweb = (function (exports) { + bypassOptions: { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, +@@ -4126,8 +4178,12 @@ var rrweb = (function (exports) { + var _e = __read(snapshot(document, { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskAllInputs: maskInputOptions, + maskTextFn: maskTextFn, +@@ -4241,8 +4297,12 @@ var rrweb = (function (exports) { + }, + blockClass: blockClass, + ignoreClass: ignoreClass, ++ ignoreSelector: ignoreSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + inlineStylesheet: inlineStylesheet, + sampling: sampling, +@@ -4254,6 +4314,7 @@ var rrweb = (function (exports) { + maskInputFn: maskInputFn, + maskTextFn: maskTextFn, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + slimDOMOptions: slimDOMOptions, + mirror: mirror, + iframeManager: iframeManager, +@@ -4275,7 +4336,12 @@ var rrweb = (function (exports) { + }, hooks); + }; + iframeManager.addLoadListener(function (iframeEl) { +- handlers_1.push(observe_1(iframeEl.contentDocument)); ++ try { ++ handlers_1.push(observe_1(iframeEl.contentDocument)); ++ } ++ catch (error) { ++ console.warn(error); ++ } + }); + var init_1 = function () { + takeFullSnapshot(); +diff --git a/node_modules/rrweb/dist/rrweb-all.min.css b/node_modules/rrweb/dist/rrweb-all.min.css +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/rrweb-all.min.css.map b/node_modules/rrweb/dist/rrweb-all.min.css.map +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/rrweb-all.min.js b/node_modules/rrweb/dist/rrweb-all.min.js +old mode 100644 +new mode 100755 +index 3925d85..588bf8f +--- a/node_modules/rrweb/dist/rrweb-all.min.js ++++ b/node_modules/rrweb/dist/rrweb-all.min.js +@@ -12,7 +12,7 @@ var rrweb=function(e){"use strict"; + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. +- ***************************************************************************** */var t,r=function(){return(r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function a(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+l)+c+")";var u=t.split("/"),d=l.split("/");u.pop();for(var f=0,p=d;f=t.length);){var a=n(S);if(","===a.slice(-1))a=x(e,a.substring(0,a.length-1)),o.push(a);else{var i="";a=x(e,a);for(var s=!1;;){var l=t.charAt(r);if(""===l){o.push((a+i).trim());break}if(s)")"===l&&(s=!1);else{if(","===l){r+=1,o.push((a+i).trim());break}"("===l&&(s=!0)}i+=l,r+=1}}}return o.join(", ")}(e,n):"style"===r&&n?b(n,E()):"object"===t&&"data"===r&&n?x(e,n):n:x(e,n)}function I(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n'):n.write('')),f=n),f.__sn=e,o[e.id]=f,(e.type===t.Document||e.type===t.Element)&&!s)for(var p=0,h=e.childNodes;pt?(n&&(clearTimeout(n),n=null),o=i,e.apply(l,c)):n||!1===r.trailing||(n=setTimeout((function(){o=!1===r.leading?0:Date.now(),n=null,e.apply(l,c)}),s))}}function J(e,t,r,n,o){void 0===o&&(o=window);var a=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,n?r:{set:function(e){var t=this;setTimeout((function(){r.set.call(t,e)}),0),a&&a.set&&a.set.call(this,e)}}),function(){return J(e,t,a||{},!0)}}function K(e,t,r){try{if(!(t in e))return function(){};var n=e[t],o=r(n);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=o,function(){e[t]=n}}catch(e){return function(){}}}function Z(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function ee(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function te(e,t){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){var r=!1;if("string"==typeof t){if(void 0!==e.closest)return null!==e.closest("."+t);r=e.classList.contains(t)}else e.classList.forEach((function(e){t.test(e)&&(r=!0)}));return r||te(e.parentNode,t)}return e.nodeType,e.TEXT_NODE,te(e.parentNode,t)}function re(e){return"__sn"in e&&-2===e.__sn.id}function ne(e,t){if(s(e))return!1;var r=t.getId(e);return!t.has(r)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||ne(e.parentNode,t))}function oe(e){return Boolean(e.changedTouches)}function ae(e){void 0===e&&(e=window),"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1})}e.mirror={map:{},getId:function(){return console.error(Q),-1},getNode:function(){return console.error(Q),null},removeNodeFromMap:function(){console.error(Q)},has:function(){return console.error(Q),!1},reset:function(){console.error(Q)}},"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(e.mirror=new Proxy(e.mirror,{get:function(e,t,r){return"map"===t&&console.error(Q),Reflect.get(e,t,r)}}));var ie=function(){function t(){this.reset()}return t.prototype.add=function(e){var t=this.indexes.get(e.parentId),r={id:e.node.id,mutation:e,children:[],texts:[],attributes:[]};t?(r.parent=t,t.children[r.id]=r):this.tree[r.id]=r,this.indexes.set(r.id,r)},t.prototype.remove=function(e,t){var r=this,n=this.indexes.get(e.parentId),o=this.indexes.get(e.id),a=function(e){r.removeIdSet.add(e);var n=t.getNode(e);null==n||n.childNodes.forEach((function(e){"__sn"in e&&a(e.__sn.id)}))},i=function(t){r.removeIdSet.add(t.id),Object.values(t.children).forEach((function(e){return i(e)}));var n=r.indexes.get(t.id);if(n){var o=n.parent;o&&(delete n.parent,delete o.children[n.id],r.indexes.delete(e.id))}};o?n?(delete o.parent,delete n.children[o.id],this.indexes.delete(e.id),i(o)):(delete this.tree[o.id],this.indexes.delete(o.id),i(o)):(this.removeNodeMutations.push(e),a(e.id))},t.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},t.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},t.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},t.prototype.input=function(e){this.inputMap.set(e.id,e)},t.prototype.flush=function(){var t,r,o,a,i=this,s=this,l=s.tree,c=s.removeNodeMutations,u=s.textMutations,d=s.attributeMutations,f={source:e.IncrementalSource.Mutation,removes:c,texts:u,attributes:d,adds:[]},p=function(e,t){t&&i.removeIdSet.add(e.id),f.texts=f.texts.concat(t?[]:e.texts).filter((function(e){return!i.removeIdSet.has(e.id)})),f.attributes=f.attributes.concat(t?[]:e.attributes).filter((function(e){return!i.removeIdSet.has(e.id)})),i.removeIdSet.has(e.id)||i.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return p(e,!0)})):(f.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return p(e,!1)})))};Object.values(l).forEach((function(e){return p(e,!1)}));try{for(var h=n(this.scrollMap.keys()),m=h.next();!m.done;m=h.next()){var v=m.value;this.removeIdSet.has(v)&&this.scrollMap.delete(v)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=h.return)&&r.call(h)}finally{if(t)throw t.error}}try{for(var y=n(this.inputMap.keys()),g=y.next();!g.done;g=y.next()){v=g.value;this.removeIdSet.has(v)&&this.inputMap.delete(v)}}catch(e){o={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}var b=new Map(this.scrollMap),S=new Map(this.inputMap);return this.reset(),{mutationData:f,scrollMap:b,inputMap:S}},t.prototype.reset=function(){this.tree=[],this.indexes=new Map,this.removeNodeMutations=[],this.textMutations=[],this.attributeMutations=[],this.removeIdSet=new Set,this.scrollMap=new Map,this.inputMap=new Map},t.prototype.idRemoved=function(e){return this.removeIdSet.has(e)},t}();function se(e){var t,r,o={},a=function(e,t){var r={value:e,parent:t,children:[]};return o[e.node.id]=r,r},i=[];try{for(var s=n(e),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.nextId,d=c.parentId;if(u&&u in o){var f=o[u];if(f.parent){var p=f.parent.children.indexOf(f);f.parent.children.splice(p,0,a(c,f.parent))}else{p=i.indexOf(f);i.splice(p,0,a(c,null))}}else if(d in o){var h=o[d];h.children.push(a(c,h))}else i.push(a(c,null))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return i}function le(e,t){t(e.value);for(var r=e.children.length-1;r>=0;r--)le(e.children[r],t)}function ce(e){return"__sn"in e&&(e.__sn.type===t.Element&&"iframe"===e.__sn.tagName)}function ue(e,t){var r,n,o=null===(n=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===n?void 0:n.frameElement;if(!o||o===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};var a=o.getBoundingClientRect(),i=ue(o,t),s=a.height/o.clientHeight;return{x:a.x*i.relativeScale+i.x,y:a.y*i.relativeScale+i.y,relativeScale:s,absoluteScale:i.absoluteScale*s}}function de(e){return Boolean(null==e?void 0:e.shadowRoot)}var fe=Object.freeze({__proto__:null,on:X,createMirror:q,get _mirror(){return e.mirror},throttle:$,hookSetter:J,patch:K,getWindowHeight:Z,getWindowWidth:ee,isBlocked:te,isIgnored:re,isAncestorRemoved:ne,isTouchEvent:oe,polyfill:ae,TreeIndex:ie,queueToResolveTrees:se,iterateResolveTree:le,isIframeINode:ce,getBaseDimension:ue,hasShadowRoot:de});function pe(e){return"__ln"in e}var he=function(){function e(){this.length=0,this.head=null}return e.prototype.get=function(e){if(e>=this.length)throw new Error("Position outside of list range");for(var t=this.head,r=0;r=0;S--){var w=l.get(S);if(w){g=e.mirror.getId(w.value.parentNode),b=c(w.value);if(-1!==g&&-1!==b){y=w;break}}}if(!y){for(;l.head;)l.removeNode(l.head.value);break}v=y.previous,l.removeNode(y.value),u(y.value)}var x={texts:e.texts.map((function(t){return{id:e.mirror.getId(t.node),value:t.value}})).filter((function(t){return e.mirror.has(t.id)})),attributes:e.attributes.map((function(t){return{id:e.mirror.getId(t.node),attributes:t.attributes}})).filter((function(t){return e.mirror.has(t.id)})),removes:e.removes,adds:i};(x.texts.length||x.attributes.length||x.removes.length||x.adds.length)&&(e.texts=[],e.attributes=[],e.removes=[],e.addedSet=new Set,e.movedSet=new Set,e.droppedSet=new Set,e.movedMap={},e.mutationCb(x))}},this.processMutation=function(t){var r,o,a,i;if(!re(t.target))switch(t.type){case"characterData":var c=t.target.textContent;te(t.target,e.blockClass)||c===t.oldValue||e.texts.push({value:I(t.target,e.maskTextClass,e.maskTextSelector)&&c?e.maskTextFn?e.maskTextFn(c):c.replace(/[\S]/g,"*"):c,node:t.target});break;case"attributes":var u=t.target;c=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(c=l({maskInputOptions:e.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:c,maskInputFn:e.maskInputFn})),te(t.target,e.blockClass)||c===t.oldValue)return;var d=e.attributes.find((function(e){return e.node===t.target}));if(d||(d={node:t.target,attributes:{}},e.attributes.push(d)),"style"===t.attributeName){var f=e.doc.createElement("span");t.oldValue&&f.setAttribute("style",t.oldValue),void 0!==d.attributes.style&&null!==d.attributes.style||(d.attributes.style={});var p=d.attributes.style;try{for(var h=n(Array.from(u.style)),m=h.next();!m.done;m=h.next()){var v=m.value,y=u.style.getPropertyValue(v),g=u.style.getPropertyPriority(v);y===f.style.getPropertyValue(v)&&g===f.style.getPropertyPriority(v)||(p[v]=""===g?y:[y,g])}}catch(e){r={error:e}}finally{try{m&&!m.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}try{for(var b=n(Array.from(f.style)),S=b.next();!S.done;S=b.next()){v=S.value;""===u.style.getPropertyValue(v)&&(p[v]=!1)}}catch(e){a={error:e}}finally{try{S&&!S.done&&(i=b.return)&&i.call(b)}finally{if(a)throw a.error}}}else d.attributes[t.attributeName]=T(e.doc,t.target.tagName,t.attributeName,c);break;case"childList":t.addedNodes.forEach((function(r){return e.genAdds(r,t.target)})),t.removedNodes.forEach((function(r){var n=e.mirror.getId(r),o=s(t.target)?e.mirror.getId(t.target.host):e.mirror.getId(t.target);te(t.target,e.blockClass)||re(r)||(e.addedSet.has(r)?(ge(e.addedSet,r),e.droppedSet.add(r)):e.addedSet.has(t.target)&&-1===n||ne(t.target,e.mirror)||(e.movedSet.has(r)&&e.movedMap[me(n,o)]?ge(e.movedSet,r):e.removes.push({parentId:o,id:n,isShadow:!!s(t.target)||void 0})),e.mapRemoves.push(r))}))}},this.genAdds=function(t,r){if(!r||!te(r,e.blockClass)){if(ve(t)){if(re(t))return;e.movedSet.add(t);var n=null;r&&ve(r)&&(n=r.__sn.id),n&&(e.movedMap[me(t.__sn.id,n)]=!0)}else e.addedSet.add(t),e.droppedSet.delete(t);te(t,e.blockClass)||t.childNodes.forEach((function(t){return e.genAdds(t)}))}}}return e.prototype.init=function(e){var t=this;["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","recordCanvas","inlineImages","slimDOMOptions","doc","mirror","iframeManager","shadowDomManager","canvasManager"].forEach((function(r){t[r]=e[r]}))},e.prototype.freeze=function(){this.frozen=!0,this.canvasManager.freeze()},e.prototype.unfreeze=function(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()},e.prototype.isFrozen=function(){return this.frozen},e.prototype.lock=function(){this.locked=!0,this.canvasManager.lock()},e.prototype.unlock=function(){this.locked=!1,this.canvasManager.unlock(),this.emit()},e.prototype.reset=function(){this.shadowDomManager.reset(),this.canvasManager.reset()},e}();function ge(e,t){e.delete(t),t.childNodes.forEach((function(t){return ge(e,t)}))}function be(e,t,r){var n=t.parentNode;if(!n)return!1;var o=r.getId(n);return!!e.some((function(e){return e.id===o}))||be(e,n,r)}function Se(e,t){var r=t.parentNode;return!!r&&(!!e.has(r)||Se(e,r))}var we=[],xe="undefined"!=typeof CSSGroupingRule,Ee="undefined"!=typeof CSSMediaRule,Te="undefined"!=typeof CSSSupportsRule,Ie="undefined"!=typeof CSSConditionRule;function Ce(e){try{if("composedPath"in e){var t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function Me(e,t){var r,n,o=new ye;we.push(o),o.init(e);var a=window.MutationObserver||window.__rrMutationObserver,i=null===(n=null===(r=null===window||void 0===window?void 0:window.Zone)||void 0===r?void 0:r.__symbol__)||void 0===n?void 0:n.call(r,"MutationObserver");i&&window[i]&&(a=window[i]);var s=new a(o.processMutations.bind(o));return s.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),s}function ke(t){var r=t.mouseInteractionCb,n=t.doc,o=t.mirror,a=t.blockClass,i=t.sampling;if(!1===i.mouseInteraction)return function(){};var s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,l=[];return Object.keys(e.MouseInteractions).filter((function(e){return Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]})).forEach((function(t){var i=t.toLowerCase(),s=function(t){return function(n){var i=Ce(n);if(!te(i,a)){var s=oe(n)?n.changedTouches[0]:n;if(s){var l=o.getId(i),c=s.clientX,u=s.clientY;r({type:e.MouseInteractions[t],id:l,x:c,y:u})}}}}(t);l.push(X(i,s,n))})),function(){l.forEach((function(e){return e()}))}}function Ne(e){var t=e.scrollCb,r=e.doc,n=e.mirror,o=e.blockClass;return X("scroll",$((function(e){var a=Ce(e);if(a&&!te(a,o)){var i=n.getId(a);if(a===r){var s=r.scrollingElement||r.documentElement;t({id:i,x:s.scrollLeft,y:s.scrollTop})}else t({id:i,x:a.scrollLeft,y:a.scrollTop})}}),e.sampling.scroll||100),r)}function Re(e,t){var n=r({},e);return t||delete n.userTriggered,n}var _e=["INPUT","TEXTAREA","SELECT"],Oe=new WeakMap;function Le(e){return function(e,t){if(xe&&e.parentRule instanceof CSSGroupingRule||Ee&&e.parentRule instanceof CSSMediaRule||Te&&e.parentRule instanceof CSSSupportsRule||Ie&&e.parentRule instanceof CSSConditionRule){var r=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(r)}else{r=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(r)}return t}(e,[])}function Ae(t,i){var s,c;void 0===i&&(i={});var u=t.doc.defaultView;if(!u)return function(){};!function(e,t){var r=e.mutationCb,n=e.mousemoveCb,i=e.mouseInteractionCb,s=e.scrollCb,l=e.viewportResizeCb,c=e.inputCb,u=e.mediaInteractionCb,d=e.styleSheetRuleCb,f=e.styleDeclarationCb,p=e.canvasMutationCb,h=e.fontCb;e.mutationCb=function(){for(var e=[],n=0;n>2],o+=Pe[(3&r[t])<<4|r[t+1]>>4],o+=Pe[(15&r[t+1])<<2|r[t+2]>>6],o+=Pe[63&r[t+2]];return n%3==2?o=o.substring(0,o.length-1)+"=":n%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)}:e instanceof DataView?{rr_type:e.constructor.name,args:[Be(e.buffer,t,r),e.byteOffset,e.byteLength]}:e instanceof HTMLImageElement?{rr_type:e.constructor.name,src:e.src}:e instanceof ImageData?{rr_type:e.constructor.name,args:[Be(e.data,t,r),e.width,e.height]}:Ve(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:ze(e,t,r)}:e}var He=function(e,t,r){return a([],o(e),!1).map((function(e){return Be(e,t,r)}))},Ve=function(e,t){var r=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((function(e){return"function"==typeof t[e]}));return Boolean(r.find((function(r){return e instanceof t[r]})))};function Ge(e,t,r,i,s,l){var c,u,d=[],f=Object.getOwnPropertyNames(e),p=function(n){try{if("function"!=typeof e[n])return"continue";var c=K(e,n,(function(c){return function(){for(var u=[],d=0;d=s,c=i&&t.timestamp-B.timestamp>i;(l||c)&&Xe(!0)}};var Y=function(t){Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.Mutation},t)}))},q=function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.Scroll},t)}))},Q=function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.CanvasMutation},t)}))},$=new De({mutationCb:Y}),J=new qe({recordCanvas:O,mutationCb:Q,win:window,blockClass:c,mirror:$e}),K=new Fe({mutationCb:Y,scrollCb:q,bypassOptions:{blockClass:c,blockSelector:d,maskTextClass:m,maskTextSelector:y,inlineStylesheet:b,maskInputOptions:H,maskTextFn:T,maskInputFn:E,recordCanvas:O,inlineImages:W,sampling:N,slimDOMOptions:V,iframeManager:$,canvasManager:J},mirror:$e});Xe=function(t){var r,n,a,i;void 0===t&&(t=!1),Ye(Qe({type:e.EventType.Meta,data:{href:window.location.href,width:ee(),height:Z()}}),t),we.forEach((function(e){return e.lock()}));var s=o(function(e,t){var r=t||{},n=r.blockClass,o=void 0===n?"rr-block":n,a=r.blockSelector,i=void 0===a?null:a,s=r.maskTextClass,l=void 0===s?"rr-mask":s,c=r.maskTextSelector,u=void 0===c?null:c,d=r.inlineStylesheet,f=void 0===d||d,p=r.inlineImages,h=void 0!==p&&p,m=r.recordCanvas,v=void 0!==m&&m,y=r.maskAllInputs,g=void 0!==y&&y,b=r.maskTextFn,S=r.maskInputFn,w=r.slimDOM,x=void 0!==w&&w,E=r.dataURLOptions,T=r.preserveWhiteSpace,I=r.onSerialize,C=r.onIframeLoad,M=r.iframeLoadTimeout,N=r.keepIframeSrcFn,R={};return[k(e,{doc:e,map:R,blockClass:o,blockSelector:i,maskTextClass:l,maskTextSelector:u,skipChild:!1,inlineStylesheet:f,maskInputOptions:!0===g?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===g?{password:!0}:g,maskTextFn:b,maskInputFn:S,slimDOMOptions:!0===x||"all"===x?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===x,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===x?{}:x,dataURLOptions:E,inlineImages:h,recordCanvas:v,preserveWhiteSpace:T,onSerialize:I,onIframeLoad:C,iframeLoadTimeout:M,keepIframeSrcFn:void 0===N?function(){return!1}:N}),R]}(document,{blockClass:c,blockSelector:d,maskTextClass:m,maskTextSelector:y,inlineStylesheet:b,maskAllInputs:H,maskTextFn:T,slimDOM:V,recordCanvas:O,inlineImages:W,onSerialize:function(e){ce(e)&&$.addIframe(e),de(e)&&K.addShadowRoot(e.shadowRoot,document)},onIframeLoad:function(e,t){$.attachIframe(e,t),K.observeAttachShadow(e)},keepIframeSrcFn:z}),2),l=s[0],u=s[1];if(!l)return console.warn("Failed to snapshot the document");$e.map=u,Ye(Qe({type:e.EventType.FullSnapshot,data:{node:l,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===document||void 0===document?void 0:document.body.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(i=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===i?void 0:i.scrollTop)||(null===document||void 0===document?void 0:document.body.scrollTop)||0}}})),we.forEach((function(e){return e.unlock()}))};try{var te=[];te.push(X("DOMContentLoaded",(function(){Ye(Qe({type:e.EventType.DomContentLoaded,data:{}}))})));var re=function(t){var n;return Ae({mutationCb:Y,mousemoveCb:function(t,r){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:{source:r,positions:t}}))},mouseInteractionCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.MouseInteraction},t)}))},scrollCb:q,viewportResizeCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.ViewportResize},t)}))},inputCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.Input},t)}))},mediaInteractionCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.MediaInteraction},t)}))},styleSheetRuleCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.StyleSheetRule},t)}))},styleDeclarationCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.StyleDeclaration},t)}))},canvasMutationCb:Q,fontCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.Font},t)}))},blockClass:c,ignoreClass:p,maskTextClass:m,maskTextSelector:y,maskInputOptions:H,inlineStylesheet:b,sampling:N,recordCanvas:O,inlineImages:W,userTriggeredOnInput:A,collectFonts:F,doc:t,maskInputFn:E,maskTextFn:T,blockSelector:d,slimDOMOptions:V,mirror:$e,iframeManager:$,shadowDomManager:K,canvasManager:J,plugins:(null===(n=null==j?void 0:j.filter((function(e){return e.observer})))||void 0===n?void 0:n.map((function(t){return{observer:t.observer,options:t.options,callback:function(r){return Ye(Qe({type:e.EventType.Plugin,data:{plugin:t.name,payload:r}}))}}})))||[]},I)};$.addLoadListener((function(e){te.push(re(e.contentDocument))}));var ne=function(){Xe(),te.push(re(document))};return"interactive"===document.readyState||"complete"===document.readyState?ne():te.push(X("load",(function(){Ye(Qe({type:e.EventType.Load,data:{}})),ne()}),window)),function(){te.forEach((function(e){return e()}))}}catch(e){console.warn(e)}}function Ke(e){return e=e||Object.create(null),{on:function(t,r){(e[t]||(e[t]=[])).push(r)},off:function(t,r){e[t]&&e[t].splice(e[t].indexOf(r)>>>0,1)},emit:function(t,r){(e[t]||[]).slice().map((function(e){e(r)})),(e["*"]||[]).slice().map((function(e){e(t,r)}))}}}Je.addCustomEvent=function(t,r){if(!Ye)throw new Error("please add custom event after start recording");Ye(Qe({type:e.EventType.Custom,data:{tag:t,payload:r}}))},Je.freezePage=function(){we.forEach((function(e){return e.freeze()}))},Je.takeFullSnapshot=function(e){if(!Xe)throw new Error("please take full snapshot after start recording");Xe(e)},Je.mirror=$e;var Ze=Object.freeze({__proto__:null,default:Ke});function et(e,t){if(void 0===e&&(e=window),void 0===t&&(t=document),!("scrollBehavior"in t.documentElement.style)||!0===e.__forceSmoothScrollPolyfill__){var r,n=e.HTMLElement||e.Element,o={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:n.prototype.scroll||s,scrollIntoView:n.prototype.scrollIntoView},a=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now,i=(r=e.navigator.userAgent,new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(r)?1:0);e.scroll=e.scrollTo=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?h.call(e,t.body,void 0!==arguments[0].left?~~arguments[0].left:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:e.scrollY||e.pageYOffset):o.scroll.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:e.scrollY||e.pageYOffset))},e.scrollBy=function(){void 0!==arguments[0]&&(l(arguments[0])?o.scrollBy.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:0,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:0):h.call(e,t.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset)))},n.prototype.scroll=n.prototype.scrollTo=function(){if(void 0!==arguments[0])if(!0!==l(arguments[0])){var e=arguments[0].left,t=arguments[0].top;h.call(this,this,void 0===e?this.scrollLeft:~~e,void 0===t?this.scrollTop:~~t)}else{if("number"==typeof arguments[0]&&void 0===arguments[1])throw new SyntaxError("Value could not be converted");o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left:"object"!=typeof arguments[0]?~~arguments[0]:this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top:void 0!==arguments[1]?~~arguments[1]:this.scrollTop)}},n.prototype.scrollBy=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior}):o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop))},n.prototype.scrollIntoView=function(){if(!0!==l(arguments[0])){var r=f(this),n=r.getBoundingClientRect(),a=this.getBoundingClientRect();r!==t.body?(h.call(this,r,r.scrollLeft+a.left-n.left,r.scrollTop+a.top-n.top),"fixed"!==e.getComputedStyle(r).position&&e.scrollBy({left:n.left,top:n.top,behavior:"smooth"})):e.scrollBy({left:a.left,top:a.top,behavior:"smooth"})}else o.scrollIntoView.call(this,void 0===arguments[0]||arguments[0])}}function s(e,t){this.scrollLeft=e,this.scrollTop=t}function l(e){if(null===e||"object"!=typeof e||void 0===e.behavior||"auto"===e.behavior||"instant"===e.behavior)return!0;if("object"==typeof e&&"smooth"===e.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+e.behavior+" is not a valid value for enumeration ScrollBehavior.")}function c(e,t){return"Y"===t?e.clientHeight+i1?1:s,r=.5*(1-Math.cos(Math.PI*i)),n=t.startX+(t.x-t.startX)*r,o=t.startY+(t.y-t.startY)*r,t.method.call(t.scrollable,n,o),n===t.x&&o===t.y||e.requestAnimationFrame(p.bind(e,t))}function h(r,n,i){var l,c,u,d,f=a();r===t.body?(l=e,c=e.scrollX||e.pageXOffset,u=e.scrollY||e.pageYOffset,d=o.scroll):(l=r,c=r.scrollLeft,u=r.scrollTop,d=s),p({scrollable:l,method:d,startTime:f,startX:c,startY:u,x:n,y:i})}}var tt,rt=function(){function e(e,t){void 0===e&&(e=[]),this.timeOffset=0,this.raf=null,this.actions=e,this.speed=t}return e.prototype.addAction=function(e){var t=this.findActionIndex(e);this.actions.splice(t,0,e)},e.prototype.addActions=function(e){this.actions=this.actions.concat(e)},e.prototype.start=function(){this.timeOffset=0;var e=performance.now(),t=this.actions,r=this;this.raf=requestAnimationFrame((function n(){var o=performance.now();for(r.timeOffset+=(o-e)*r.speed,e=o;t.length;){var a=t[0];if(!(r.timeOffset>=a.delay))break;t.shift(),a.doAction()}(t.length>0||r.liveMode)&&(r.raf=requestAnimationFrame(n))}))},e.prototype.clear=function(){this.raf&&(cancelAnimationFrame(this.raf),this.raf=null),this.actions.length=0},e.prototype.setSpeed=function(e){this.speed=e},e.prototype.toggleLiveMode=function(e){this.liveMode=e},e.prototype.isActive=function(){return null!==this.raf},e.prototype.findActionIndex=function(e){for(var t=0,r=this.actions.length-1;t<=r;){var n=Math.floor((t+r)/2);if(this.actions[n].delaye.delay))return n+1;r=n-1}}return t},e}();function nt(t,r){if(t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.MouseMove){var n=t.data.positions[0].timeOffset,o=t.timestamp+n;return t.delay=o-r,o-r}return t.delay=t.timestamp-r,t.delay} ++ ***************************************************************************** */var t,r=function(){return(r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function a(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+l)+c+")";var u=t.split("/"),d=l.split("/");u.pop();for(var f=0,p=d;f=t.length);){var a=n(b);if(","===a.slice(-1))a=x(e,a.substring(0,a.length-1)),o.push(a);else{var i="";a=x(e,a);for(var s=!1;;){var l=t.charAt(r);if(""===l){o.push((a+i).trim());break}if(s)")"===l&&(s=!1);else{if(","===l){r+=1,o.push((a+i).trim());break}"("===l&&(s=!0)}i+=l,r+=1}}}return o.join(", ")}(e,n):"style"===r&&n?S(n,I()):"object"===t&&"data"===r&&n?x(e,n):n:x(e,n)}function T(e,t,r,n){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if(n&&(e.matches(n)||e.closest(n)))return!1;if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=0;o'):n.write('')),f=n),f.__sn=e,o[e.id]=f,(e.type===t.Document||e.type===t.Element)&&!s)for(var p=0,h=e.childNodes;pt?(n&&(clearTimeout(n),n=null),o=i,e.apply(l,c)):n||!1===r.trailing||(n=setTimeout((function(){o=!1===r.leading?0:Date.now(),n=null,e.apply(l,c)}),s))}}function J(e,t,r,n,o){void 0===o&&(o=window);var a=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,n?r:{set:function(e){var t=this;setTimeout((function(){r.set.call(t,e)}),0),a&&a.set&&a.set.call(this,e)}}),function(){return J(e,t,a||{},!0)}}function K(e,t,r){try{if(!(t in e))return function(){};var n=e[t],o=r(n);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=o,function(){e[t]=n}}catch(e){return function(){}}}function Z(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function ee(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function te(e,t){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){var r=!1;if("string"==typeof t){if(void 0!==e.closest)return null!==e.closest("."+t);r=e.classList.contains(t)}else e.classList.forEach((function(e){t.test(e)&&(r=!0)}));return r||te(e.parentNode,t)}return e.nodeType,e.TEXT_NODE,te(e.parentNode,t)}function re(e){return"__sn"in e&&-2===e.__sn.id}function ne(e,t){if(s(e))return!1;var r=t.getId(e);return!t.has(r)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||ne(e.parentNode,t))}function oe(e){return Boolean(e.changedTouches)}function ae(e){void 0===e&&(e=window),"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1})}e.mirror={map:{},getId:function(){return console.error(Q),-1},getNode:function(){return console.error(Q),null},removeNodeFromMap:function(){console.error(Q)},has:function(){return console.error(Q),!1},reset:function(){console.error(Q)}},"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(e.mirror=new Proxy(e.mirror,{get:function(e,t,r){return"map"===t&&console.error(Q),Reflect.get(e,t,r)}}));var ie=function(){function t(){this.reset()}return t.prototype.add=function(e){var t=this.indexes.get(e.parentId),r={id:e.node.id,mutation:e,children:[],texts:[],attributes:[]};t?(r.parent=t,t.children[r.id]=r):this.tree[r.id]=r,this.indexes.set(r.id,r)},t.prototype.remove=function(e,t){var r=this,n=this.indexes.get(e.parentId),o=this.indexes.get(e.id),a=function(e){r.removeIdSet.add(e);var n=t.getNode(e);null==n||n.childNodes.forEach((function(e){"__sn"in e&&a(e.__sn.id)}))},i=function(t){r.removeIdSet.add(t.id),Object.values(t.children).forEach((function(e){return i(e)}));var n=r.indexes.get(t.id);if(n){var o=n.parent;o&&(delete n.parent,delete o.children[n.id],r.indexes.delete(e.id))}};o?n?(delete o.parent,delete n.children[o.id],this.indexes.delete(e.id),i(o)):(delete this.tree[o.id],this.indexes.delete(o.id),i(o)):(this.removeNodeMutations.push(e),a(e.id))},t.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},t.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},t.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},t.prototype.input=function(e){this.inputMap.set(e.id,e)},t.prototype.flush=function(){var t,r,o,a,i=this,s=this,l=s.tree,c=s.removeNodeMutations,u=s.textMutations,d=s.attributeMutations,f={source:e.IncrementalSource.Mutation,removes:c,texts:u,attributes:d,adds:[]},p=function(e,t){t&&i.removeIdSet.add(e.id),f.texts=f.texts.concat(t?[]:e.texts).filter((function(e){return!i.removeIdSet.has(e.id)})),f.attributes=f.attributes.concat(t?[]:e.attributes).filter((function(e){return!i.removeIdSet.has(e.id)})),i.removeIdSet.has(e.id)||i.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return p(e,!0)})):(f.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return p(e,!1)})))};Object.values(l).forEach((function(e){return p(e,!1)}));try{for(var h=n(this.scrollMap.keys()),m=h.next();!m.done;m=h.next()){var v=m.value;this.removeIdSet.has(v)&&this.scrollMap.delete(v)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=h.return)&&r.call(h)}finally{if(t)throw t.error}}try{for(var y=n(this.inputMap.keys()),g=y.next();!g.done;g=y.next()){v=g.value;this.removeIdSet.has(v)&&this.inputMap.delete(v)}}catch(e){o={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}var S=new Map(this.scrollMap),b=new Map(this.inputMap);return this.reset(),{mutationData:f,scrollMap:S,inputMap:b}},t.prototype.reset=function(){this.tree=[],this.indexes=new Map,this.removeNodeMutations=[],this.textMutations=[],this.attributeMutations=[],this.removeIdSet=new Set,this.scrollMap=new Map,this.inputMap=new Map},t.prototype.idRemoved=function(e){return this.removeIdSet.has(e)},t}();function se(e){var t,r,o={},a=function(e,t){var r={value:e,parent:t,children:[]};return o[e.node.id]=r,r},i=[];try{for(var s=n(e),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.nextId,d=c.parentId;if(u&&u in o){var f=o[u];if(f.parent){var p=f.parent.children.indexOf(f);f.parent.children.splice(p,0,a(c,f.parent))}else{p=i.indexOf(f);i.splice(p,0,a(c,null))}}else if(d in o){var h=o[d];h.children.push(a(c,h))}else i.push(a(c,null))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return i}function le(e,t){t(e.value);for(var r=e.children.length-1;r>=0;r--)le(e.children[r],t)}function ce(e){return"__sn"in e&&(e.__sn.type===t.Element&&"iframe"===e.__sn.tagName)}function ue(e,t){var r,n,o=null===(n=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===n?void 0:n.frameElement;if(!o||o===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};var a=o.getBoundingClientRect(),i=ue(o,t),s=a.height/o.clientHeight;return{x:a.x*i.relativeScale+i.x,y:a.y*i.relativeScale+i.y,relativeScale:s,absoluteScale:i.absoluteScale*s}}function de(e){return Boolean(null==e?void 0:e.shadowRoot)}var fe=Object.freeze({__proto__:null,on:X,createMirror:q,get _mirror(){return e.mirror},throttle:$,hookSetter:J,patch:K,getWindowHeight:Z,getWindowWidth:ee,isBlocked:te,isIgnored:re,isAncestorRemoved:ne,isTouchEvent:oe,polyfill:ae,TreeIndex:ie,queueToResolveTrees:se,iterateResolveTree:le,isIframeINode:ce,getBaseDimension:ue,hasShadowRoot:de});function pe(e){return"__ln"in e}var he=function(){function e(){this.length=0,this.head=null}return e.prototype.get=function(e){if(e>=this.length)throw new Error("Position outside of list range");for(var t=this.head,r=0;r=0;b--){var w=l.get(b);if(w){g=e.mirror.getId(w.value.parentNode),S=c(w.value);if(-1!==g&&-1!==S){y=w;break}}}if(!y){for(;l.head;)l.removeNode(l.head.value);break}v=y.previous,l.removeNode(y.value),u(y.value)}var x={texts:e.texts.map((function(t){return{id:e.mirror.getId(t.node),value:t.value}})).filter((function(t){return e.mirror.has(t.id)})),attributes:e.attributes.map((function(t){return{id:e.mirror.getId(t.node),attributes:t.attributes}})).filter((function(t){return e.mirror.has(t.id)})),removes:e.removes,adds:i};(x.texts.length||x.attributes.length||x.removes.length||x.adds.length)&&(e.texts=[],e.attributes=[],e.removes=[],e.addedSet=new Set,e.movedSet=new Set,e.droppedSet=new Set,e.movedMap={},e.mutationCb(x))}},this.processMutation=function(t){var r,o,a,i;if(!re(t.target))switch(t.type){case"characterData":var c=t.target.textContent;te(t.target,e.blockClass)||c===t.oldValue||e.texts.push({value:T(t.target,e.maskTextClass,e.maskTextSelector,e.unmaskTextSelector)&&c?e.maskTextFn?e.maskTextFn(c):c.replace(/[\S]/g,"*"):c,node:t.target});break;case"attributes":var u=t.target;c=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(c=l({input:u,maskInputSelector:e.maskInputSelector,unmaskInputSelector:e.unmaskInputSelector,maskInputOptions:e.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:c,maskInputFn:e.maskInputFn})),te(t.target,e.blockClass)||c===t.oldValue)return;var d=e.attributes.find((function(e){return e.node===t.target}));if(d||(d={node:t.target,attributes:{}},e.attributes.push(d)),"style"===t.attributeName){var f=e.doc.createElement("span");t.oldValue&&f.setAttribute("style",t.oldValue),void 0!==d.attributes.style&&null!==d.attributes.style||(d.attributes.style={});var p=d.attributes.style;try{for(var h=n(Array.from(u.style)),m=h.next();!m.done;m=h.next()){var v=m.value,y=u.style.getPropertyValue(v),g=u.style.getPropertyPriority(v);y===f.style.getPropertyValue(v)&&g===f.style.getPropertyPriority(v)||(p[v]=""===g?y:[y,g])}}catch(e){r={error:e}}finally{try{m&&!m.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}try{for(var S=n(Array.from(f.style)),b=S.next();!b.done;b=S.next()){v=b.value;""===u.style.getPropertyValue(v)&&(p[v]=!1)}}catch(e){a={error:e}}finally{try{b&&!b.done&&(i=S.return)&&i.call(S)}finally{if(a)throw a.error}}}else d.attributes[t.attributeName]=E(e.doc,t.target.tagName,t.attributeName,c);break;case"childList":t.addedNodes.forEach((function(r){return e.genAdds(r,t.target)})),t.removedNodes.forEach((function(r){var n=e.mirror.getId(r),o=s(t.target)?e.mirror.getId(t.target.host):e.mirror.getId(t.target);te(t.target,e.blockClass)||re(r)||(e.addedSet.has(r)?(ge(e.addedSet,r),e.droppedSet.add(r)):e.addedSet.has(t.target)&&-1===n||ne(t.target,e.mirror)||(e.movedSet.has(r)&&e.movedMap[me(n,o)]?ge(e.movedSet,r):e.removes.push({parentId:o,id:n,isShadow:!!s(t.target)||void 0})),e.mapRemoves.push(r))}))}},this.genAdds=function(t,r){if(!r||!te(r,e.blockClass)){if(ve(t)){if(re(t))return;e.movedSet.add(t);var n=null;r&&ve(r)&&(n=r.__sn.id),n&&(e.movedMap[me(t.__sn.id,n)]=!0)}else e.addedSet.add(t),e.droppedSet.delete(t);te(t,e.blockClass)||t.childNodes.forEach((function(t){return e.genAdds(t)}))}}}return e.prototype.init=function(e){var t=this;["mutationCb","blockClass","blockSelector","unblockSelector","maskTextClass","maskTextSelector","unmaskTextSelector","maskInputSelector","unmaskInputSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","recordCanvas","inlineImages","slimDOMOptions","doc","mirror","iframeManager","shadowDomManager","canvasManager"].forEach((function(r){t[r]=e[r]}))},e.prototype.freeze=function(){this.frozen=!0,this.canvasManager.freeze()},e.prototype.unfreeze=function(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()},e.prototype.isFrozen=function(){return this.frozen},e.prototype.lock=function(){this.locked=!0,this.canvasManager.lock()},e.prototype.unlock=function(){this.locked=!1,this.canvasManager.unlock(),this.emit()},e.prototype.reset=function(){this.shadowDomManager.reset(),this.canvasManager.reset()},e}();function ge(e,t){e.delete(t),t.childNodes.forEach((function(t){return ge(e,t)}))}function Se(e,t,r){var n=t.parentNode;if(!n)return!1;var o=r.getId(n);return!!e.some((function(e){return e.id===o}))||Se(e,n,r)}function be(e,t){var r=t.parentNode;return!!r&&(!!e.has(r)||be(e,r))}var we=[],xe="undefined"!=typeof CSSGroupingRule,Ie="undefined"!=typeof CSSMediaRule,Ee="undefined"!=typeof CSSSupportsRule,Te="undefined"!=typeof CSSConditionRule;function ke(e){try{if("composedPath"in e){var t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function Ce(e,t){var r,n,o=new ye;we.push(o),o.init(e);var a=window.MutationObserver||window.__rrMutationObserver,i=null===(n=null===(r=null===window||void 0===window?void 0:window.Zone)||void 0===r?void 0:r.__symbol__)||void 0===n?void 0:n.call(r,"MutationObserver");i&&window[i]&&(a=window[i]);var s=new a(o.processMutations.bind(o));return s.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),s}function Me(t){var r=t.mouseInteractionCb,n=t.doc,o=t.mirror,a=t.blockClass,i=t.sampling;if(!1===i.mouseInteraction)return function(){};var s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,l=[];return Object.keys(e.MouseInteractions).filter((function(e){return Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]})).forEach((function(t){var i=t.toLowerCase(),s=function(t){return function(n){var i=ke(n);if(!te(i,a)){var s=oe(n)?n.changedTouches[0]:n;if(s){var l=o.getId(i),c=s.clientX,u=s.clientY;r({type:e.MouseInteractions[t],id:l,x:c,y:u})}}}}(t);l.push(X(i,s,n))})),function(){l.forEach((function(e){return e()}))}}function Ne(e){var t=e.scrollCb,r=e.doc,n=e.mirror,o=e.blockClass;return X("scroll",$((function(e){var a=ke(e);if(a&&!te(a,o)){var i=n.getId(a);if(a===r){var s=r.scrollingElement||r.documentElement;t({id:i,x:s.scrollLeft,y:s.scrollTop})}else t({id:i,x:a.scrollLeft,y:a.scrollTop})}}),e.sampling.scroll||100),r)}function Re(e,t){var n=r({},e);return t||delete n.userTriggered,n}var _e=["INPUT","TEXTAREA","SELECT"],Oe=new WeakMap;function Le(e){return function(e,t){if(xe&&e.parentRule instanceof CSSGroupingRule||Ie&&e.parentRule instanceof CSSMediaRule||Ee&&e.parentRule instanceof CSSSupportsRule||Te&&e.parentRule instanceof CSSConditionRule){var r=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(r)}else{r=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(r)}return t}(e,[])}function Ae(t,i){var s,c;void 0===i&&(i={});var u=t.doc.defaultView;if(!u)return function(){};!function(e,t){var r=e.mutationCb,n=e.mousemoveCb,i=e.mouseInteractionCb,s=e.scrollCb,l=e.viewportResizeCb,c=e.inputCb,u=e.mediaInteractionCb,d=e.styleSheetRuleCb,f=e.styleDeclarationCb,p=e.canvasMutationCb,h=e.fontCb;e.mutationCb=function(){for(var e=[],n=0;n>2],o+=Pe[(3&r[t])<<4|r[t+1]>>4],o+=Pe[(15&r[t+1])<<2|r[t+2]>>6],o+=Pe[63&r[t+2]];return n%3==2?o=o.substring(0,o.length-1)+"=":n%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)}:e instanceof DataView?{rr_type:e.constructor.name,args:[Be(e.buffer,t,r),e.byteOffset,e.byteLength]}:e instanceof HTMLImageElement?{rr_type:e.constructor.name,src:e.src}:e instanceof ImageData?{rr_type:e.constructor.name,args:[Be(e.data,t,r),e.width,e.height]}:Ve(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:ze(e,t,r)}:e}var He=function(e,t,r){return a([],o(e),!1).map((function(e){return Be(e,t,r)}))},Ve=function(e,t){var r=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((function(e){return"function"==typeof t[e]}));return Boolean(r.find((function(r){return e instanceof t[r]})))};function Ge(e,t,r,i,s,l){var c,u,d=[],f=Object.getOwnPropertyNames(e),p=function(n){try{if("function"!=typeof e[n])return"continue";var c=K(e,n,(function(c){return function(){for(var u=[],d=0;d=s,c=i&&t.timestamp-te.timestamp>i;(l||c)&&Xe(!0)}};var ie=function(t){Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.Mutation},t)}))},se=function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.Scroll},t)}))},le=function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.CanvasMutation},t)}))},ue=new De({mutationCb:ie}),fe=new qe({recordCanvas:B,mutationCb:le,win:window,blockClass:c,mirror:$e}),pe=new Fe({mutationCb:ie,scrollCb:se,bypassOptions:{blockClass:c,blockSelector:d,unblockSelector:p,maskTextClass:S,maskTextSelector:w,unmaskTextSelector:T,maskInputSelector:I,unmaskInputSelector:C,inlineStylesheet:R,maskInputOptions:re,maskTextFn:D,maskInputFn:A,recordCanvas:B,inlineImages:Q,sampling:j,slimDOMOptions:ne,iframeManager:ue,canvasManager:fe},mirror:$e});Xe=function(t){var r,n,a,i;void 0===t&&(t=!1),Ye(Qe({type:e.EventType.Meta,data:{href:window.location.href,width:ee(),height:Z()}}),t),we.forEach((function(e){return e.lock()}));var s=o(function(e,t){var r=t||{},n=r.blockClass,o=void 0===n?"rr-block":n,a=r.blockSelector,i=void 0===a?null:a,s=r.unblockSelector,l=void 0===s?null:s,c=r.maskTextClass,u=void 0===c?"rr-mask":c,d=r.maskTextSelector,f=void 0===d?null:d,p=r.unmaskTextSelector,h=void 0===p?null:p,m=r.inlineStylesheet,v=void 0===m||m,y=r.inlineImages,g=void 0!==y&&y,S=r.recordCanvas,b=void 0!==S&&S,w=r.maskInputSelector,x=void 0===w?null:w,I=r.unmaskInputSelector,E=void 0===I?null:I,T=r.maskAllInputs,k=void 0!==T&&T,C=r.maskTextFn,N=r.maskInputFn,R=r.slimDOM,_=void 0!==R&&R,O=r.dataURLOptions,L=r.preserveWhiteSpace,A=r.onSerialize,D=r.onIframeLoad,F=r.iframeLoadTimeout,P=r.keepIframeSrcFn,W={};return[M(e,{doc:e,map:W,blockClass:o,blockSelector:i,unblockSelector:l,maskTextClass:u,maskTextSelector:f,unmaskTextSelector:h,skipChild:!1,inlineStylesheet:v,maskInputSelector:x,unmaskInputSelector:E,maskInputOptions:!0===k?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===k?{password:!0}:k,maskTextFn:C,maskInputFn:N,slimDOMOptions:!0===_||"all"===_?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===_,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===_?{}:_,dataURLOptions:O,inlineImages:g,recordCanvas:b,preserveWhiteSpace:L,onSerialize:A,onIframeLoad:D,iframeLoadTimeout:F,keepIframeSrcFn:void 0===P?function(){return!1}:P}),W]}(document,{blockClass:c,blockSelector:d,unblockSelector:p,maskTextClass:S,maskTextSelector:w,unmaskTextSelector:T,maskInputSelector:I,unmaskInputSelector:C,inlineStylesheet:R,maskAllInputs:re,maskTextFn:D,slimDOM:ne,recordCanvas:B,inlineImages:Q,onSerialize:function(e){ce(e)&&ue.addIframe(e),de(e)&&pe.addShadowRoot(e.shadowRoot,document)},onIframeLoad:function(e,t){ue.attachIframe(e,t),pe.observeAttachShadow(e)},keepIframeSrcFn:K}),2),l=s[0],u=s[1];if(!l)return console.warn("Failed to snapshot the document");$e.map=u,Ye(Qe({type:e.EventType.FullSnapshot,data:{node:l,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===document||void 0===document?void 0:document.body.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(i=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===i?void 0:i.scrollTop)||(null===document||void 0===document?void 0:document.body.scrollTop)||0}}})),we.forEach((function(e){return e.unlock()}))};try{var he=[];he.push(X("DOMContentLoaded",(function(){Ye(Qe({type:e.EventType.DomContentLoaded,data:{}}))})));var me=function(t){var n;return Ae({mutationCb:ie,mousemoveCb:function(t,r){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:{source:r,positions:t}}))},mouseInteractionCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.MouseInteraction},t)}))},scrollCb:se,viewportResizeCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.ViewportResize},t)}))},inputCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.Input},t)}))},mediaInteractionCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.MediaInteraction},t)}))},styleSheetRuleCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.StyleSheetRule},t)}))},styleDeclarationCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.StyleDeclaration},t)}))},canvasMutationCb:le,fontCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:r({source:e.IncrementalSource.Font},t)}))},blockClass:c,ignoreClass:m,ignoreSelector:y,maskTextClass:S,maskTextSelector:w,unmaskTextSelector:T,maskInputSelector:I,unmaskInputSelector:C,maskInputOptions:re,inlineStylesheet:R,sampling:j,recordCanvas:B,inlineImages:Q,userTriggeredOnInput:V,collectFonts:Y,doc:t,maskInputFn:A,maskTextFn:D,blockSelector:d,unblockSelector:p,slimDOMOptions:ne,mirror:$e,iframeManager:ue,shadowDomManager:pe,canvasManager:fe,plugins:(null===(n=null==$?void 0:$.filter((function(e){return e.observer})))||void 0===n?void 0:n.map((function(t){return{observer:t.observer,options:t.options,callback:function(r){return Ye(Qe({type:e.EventType.Plugin,data:{plugin:t.name,payload:r}}))}}})))||[]},F)};ue.addLoadListener((function(e){try{he.push(me(e.contentDocument))}catch(e){console.warn(e)}}));var ve=function(){Xe(),he.push(me(document))};return"interactive"===document.readyState||"complete"===document.readyState?ve():he.push(X("load",(function(){Ye(Qe({type:e.EventType.Load,data:{}})),ve()}),window)),function(){he.forEach((function(e){return e()}))}}catch(e){console.warn(e)}}function Ke(e){return e=e||Object.create(null),{on:function(t,r){(e[t]||(e[t]=[])).push(r)},off:function(t,r){e[t]&&e[t].splice(e[t].indexOf(r)>>>0,1)},emit:function(t,r){(e[t]||[]).slice().map((function(e){e(r)})),(e["*"]||[]).slice().map((function(e){e(t,r)}))}}}Je.addCustomEvent=function(t,r){if(!Ye)throw new Error("please add custom event after start recording");Ye(Qe({type:e.EventType.Custom,data:{tag:t,payload:r}}))},Je.freezePage=function(){we.forEach((function(e){return e.freeze()}))},Je.takeFullSnapshot=function(e){if(!Xe)throw new Error("please take full snapshot after start recording");Xe(e)},Je.mirror=$e;var Ze=Object.freeze({__proto__:null,default:Ke});function et(e,t){if(void 0===e&&(e=window),void 0===t&&(t=document),!("scrollBehavior"in t.documentElement.style)||!0===e.__forceSmoothScrollPolyfill__){var r,n=e.HTMLElement||e.Element,o={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:n.prototype.scroll||s,scrollIntoView:n.prototype.scrollIntoView},a=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now,i=(r=e.navigator.userAgent,new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(r)?1:0);e.scroll=e.scrollTo=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?h.call(e,t.body,void 0!==arguments[0].left?~~arguments[0].left:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:e.scrollY||e.pageYOffset):o.scroll.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:e.scrollY||e.pageYOffset))},e.scrollBy=function(){void 0!==arguments[0]&&(l(arguments[0])?o.scrollBy.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:0,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:0):h.call(e,t.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset)))},n.prototype.scroll=n.prototype.scrollTo=function(){if(void 0!==arguments[0])if(!0!==l(arguments[0])){var e=arguments[0].left,t=arguments[0].top;h.call(this,this,void 0===e?this.scrollLeft:~~e,void 0===t?this.scrollTop:~~t)}else{if("number"==typeof arguments[0]&&void 0===arguments[1])throw new SyntaxError("Value could not be converted");o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left:"object"!=typeof arguments[0]?~~arguments[0]:this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top:void 0!==arguments[1]?~~arguments[1]:this.scrollTop)}},n.prototype.scrollBy=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior}):o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop))},n.prototype.scrollIntoView=function(){if(!0!==l(arguments[0])){var r=f(this),n=r.getBoundingClientRect(),a=this.getBoundingClientRect();r!==t.body?(h.call(this,r,r.scrollLeft+a.left-n.left,r.scrollTop+a.top-n.top),"fixed"!==e.getComputedStyle(r).position&&e.scrollBy({left:n.left,top:n.top,behavior:"smooth"})):e.scrollBy({left:a.left,top:a.top,behavior:"smooth"})}else o.scrollIntoView.call(this,void 0===arguments[0]||arguments[0])}}function s(e,t){this.scrollLeft=e,this.scrollTop=t}function l(e){if(null===e||"object"!=typeof e||void 0===e.behavior||"auto"===e.behavior||"instant"===e.behavior)return!0;if("object"==typeof e&&"smooth"===e.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+e.behavior+" is not a valid value for enumeration ScrollBehavior.")}function c(e,t){return"Y"===t?e.clientHeight+i1?1:s,r=.5*(1-Math.cos(Math.PI*i)),n=t.startX+(t.x-t.startX)*r,o=t.startY+(t.y-t.startY)*r,t.method.call(t.scrollable,n,o),n===t.x&&o===t.y||e.requestAnimationFrame(p.bind(e,t))}function h(r,n,i){var l,c,u,d,f=a();r===t.body?(l=e,c=e.scrollX||e.pageXOffset,u=e.scrollY||e.pageYOffset,d=o.scroll):(l=r,c=r.scrollLeft,u=r.scrollTop,d=s),p({scrollable:l,method:d,startTime:f,startX:c,startY:u,x:n,y:i})}}var tt,rt=function(){function e(e,t){void 0===e&&(e=[]),this.timeOffset=0,this.raf=null,this.actions=e,this.speed=t}return e.prototype.addAction=function(e){var t=this.findActionIndex(e);this.actions.splice(t,0,e)},e.prototype.addActions=function(e){this.actions=this.actions.concat(e)},e.prototype.start=function(){this.timeOffset=0;var e=performance.now(),t=this.actions,r=this;this.raf=requestAnimationFrame((function n(){var o=performance.now();for(r.timeOffset+=(o-e)*r.speed,e=o;t.length;){var a=t[0];if(!(r.timeOffset>=a.delay))break;t.shift(),a.doAction()}(t.length>0||r.liveMode)&&(r.raf=requestAnimationFrame(n))}))},e.prototype.clear=function(){this.raf&&(cancelAnimationFrame(this.raf),this.raf=null),this.actions.length=0},e.prototype.setSpeed=function(e){this.speed=e},e.prototype.toggleLiveMode=function(e){this.liveMode=e},e.prototype.isActive=function(){return null!==this.raf},e.prototype.findActionIndex=function(e){for(var t=0,r=this.actions.length-1;t<=r;){var n=Math.floor((t+r)/2);if(this.actions[n].delaye.delay))return n+1;r=n-1}}return t},e}();function nt(t,r){if(t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.MouseMove){var n=t.data.positions[0].timeOffset,o=t.timestamp+n;return t.delay=o-r,o-r}return t.delay=t.timestamp-r,t.delay} + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + +@@ -26,5 +26,5 @@ var rrweb=function(e){"use strict"; + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. +- ***************************************************************************** */function ot(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(tt||(tt={}));var at={type:"xstate.init"};function it(e){return void 0===e?[]:[].concat(e)}function st(e){return{type:"xstate.assign",assignment:e}}function lt(e,t){return"string"==typeof(e="string"==typeof e&&t&&t[e]?t[e]:e)?{type:e}:"function"==typeof e?{type:e.name,exec:e}:e}function ct(e){return function(t){return e===t}}function ut(e){return"string"==typeof e?{type:e}:e}function dt(e,t){return{value:e,context:t,actions:[],changed:!1,matches:ct(e)}}function ft(e,t,r){var n=t,o=!1;return[e.filter((function(e){if("xstate.assign"===e.type){o=!0;var t=Object.assign({},n);return"function"==typeof e.assignment?t=e.assignment(n,r):Object.keys(e.assignment).forEach((function(o){t[o]="function"==typeof e.assignment[o]?e.assignment[o](n,r):e.assignment[o]})),n=t,!1}return!0})),n,o]}function pt(e,t){void 0===t&&(t={});var r=ot(ft(it(e.states[e.initial].entry).map((function(e){return lt(e,t.actions)})),e.context,at),2),n=r[0],o=r[1],a={config:e,_options:t,initialState:{value:e.initial,actions:n,context:o,matches:ct(e.initial)},transition:function(t,r){var n,o,i="string"==typeof t?{value:t,context:e.context}:t,s=i.value,l=i.context,c=ut(r),u=e.states[s];if(u.on){var d=it(u.on[c.type]);try{for(var f=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(d),p=f.next();!p.done;p=f.next()){var h=p.value;if(void 0===h)return dt(s,l);var m="string"==typeof h?{target:h}:h,v=m.target,y=m.actions,g=void 0===y?[]:y,b=m.cond,S=void 0===b?function(){return!0}:b,w=void 0===v,x=null!=v?v:s,E=e.states[x];if(S(l,c)){var T=ot(ft((w?it(g):[].concat(u.exit,g,E.entry).filter((function(e){return e}))).map((function(e){return lt(e,a._options.actions)})),l,c),3),I=T[0],C=T[1],M=T[2],k=null!=v?v:s;return{value:k,context:C,actions:I,changed:v!==s||I.length>0||M,matches:ct(k)}}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(n)throw n.error}}}return dt(s,l)}};return a}var ht=function(e,t){return e.actions.forEach((function(r){var n=r.exec;return n&&n(e.context,t)}))};function mt(e){var t=e.initialState,r=tt.NotStarted,n=new Set,o={_machine:e,send:function(o){r===tt.Running&&(t=e.transition(t,o),ht(t,ut(o)),n.forEach((function(e){return e(t)})))},subscribe:function(e){return n.add(e),e(t),{unsubscribe:function(){return n.delete(e)}}},start:function(n){if(n){var a="object"==typeof n?n:{context:e.config.context,value:n};t={value:a.value,actions:[],context:a.context,matches:ct(a.value)}}return r=tt.Running,ht(t,at),o},stop:function(){return r=tt.Stopped,n.clear(),o},get state(){return t},get status(){return r}};return o}function vt(t,o){var a=o.getCastFn,i=o.applyEventsSynchronously,s=o.emitter;return mt(pt({id:"player",context:t,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:st({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:st((function(e,t){var n=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(n=t.payload.timeOffset),r(r({},e),{timeOffset:n,baselineTime:e.events[0].timestamp+n})})),play:function(t){var r,o,l,c,u,d=t.timer,f=t.events,p=t.baselineTime,h=t.lastPlayedEvent;d.clear();try{for(var m=n(f),v=m.next();!v.done;v=m.next()){nt(v.value,p)}}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=m.return)&&o.call(m)}finally{if(r)throw r.error}}var y=function(t,r){for(var n=t.length-1;n>=0;n--){var o=t[n];if(o.type===e.EventType.Meta&&o.timestamp<=r)return t.slice(n)}return t}(f,p),g=null==h?void 0:h.timestamp;(null==h?void 0:h.type)===e.EventType.IncrementalSnapshot&&h.data.source===e.IncrementalSource.MouseMove&&(g=h.timestamp+(null===(u=h.data.positions[0])||void 0===u?void 0:u.timeOffset)),p<(g||0)&&s.emit(e.ReplayerEvents.PlayBack);var b=new Array,S=new Array,w=function(e){if(g&&gi)try{null===(n=t.sheet)||void 0===n||n.deleteRule(Number(s))}catch(e){}i=c})),e.forEach((function(e,r){var n,o,a;try{(null===(o=null===(n=t.sheet)||void 0===n?void 0:n.cssRules[r])||void 0===o?void 0:o.cssText)!==e&&(null===(a=t.sheet)||void 0===a||a.insertRule(e,r))}catch(e){}}))}catch(e){}}(e.cssTexts,t);else if(e.type===yt.SetProperty){gt(r.cssRules,e.index).style.setProperty(e.property,e.value,e.priority)}else if(e.type===yt.RemoveProperty){gt(r.cssRules,e.index).style.removeProperty(e.property)}}))}!function(e){e[e.Insert=0]="Insert",e[e.Remove=1]="Remove",e[e.Snapshot=2]="Snapshot",e[e.SetProperty=3]="SetProperty",e[e.RemoveProperty=4]="RemoveProperty"}(yt||(yt={}));var wt=new Map;function xt(e,t){var r=wt.get(e);return r||(r=new Map,wt.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}var Et=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Tt(e,t){return function(r){if(r&&"object"==typeof r&&"rr_type"in r){if("index"in r){var n=r.rr_type,i=r.index;return xt(t,n)[i]}if("args"in r){var s=r.rr_type,l=r.args,c=window[s];return new(c.bind.apply(c,a([void 0],o(l.map(Tt(e,t))),!1)))}if("base64"in r)return function(e){var t,r,n,o,a,i=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);var c=new ArrayBuffer(i),u=new Uint8Array(c);for(t=0;t>4,u[l++]=(15&n)<<4|o>>2,u[l++]=(3&o)<<6|63&a;return c}(r.base64);if("src"in r){var u=e.get(r.src);if(u)return u;var d=new Image;return d.src=r.src,e.set(r.src,d),d}}else if(Array.isArray(r))return r.map(Tt(e,t));return r}}function It(e){var t=e.mutation,r=e.target,n=e.type,o=e.imageMap,a=e.errorHandler;try{var i=function(e,t){try{return t===P.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(e){return null}}(r,n);if(!i)return;if(t.setter)return void(i[t.property]=t.args[0]);var s=i[t.property],l=t.args.map(Tt(o,i));!function(e,t){if(null==t?void 0:t.constructor){var r=t.constructor.name;if(Et.includes(r)){var n=xt(e,r);n.includes(t)||n.push(t)}}}(i,s.apply(i,l))}catch(e){a(t,e)}}var Ct=Ke||Ze,Mt="[replayer]",kt={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Nt(t){return t.type==e.EventType.IncrementalSnapshot&&(t.data.source==e.IncrementalSource.TouchMove||t.data.source==e.IncrementalSource.MouseInteraction&&t.data.type==e.MouseInteractions.TouchStart)}var Rt=function(){function i(t,r){var o=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=Ct(),this.legacy_missingNodeRetryMap={},this.cache=H(),this.imageMap=new Map,this.mirror={map:{},getId:function(e){return e&&e.__sn?e.__sn.id:-1},getNode:function(e){return this.map[e]||null},removeNodeFromMap:function(e){var t=this,r=e.__sn&&e.__sn.id;delete this.map[r],e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},has:function(e){return this.map.hasOwnProperty(e)},reset:function(){this.map={}}},this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(null==r?void 0:r.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");var a={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:kt};this.config=Object.assign({},a,r),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(e.ReplayerEvents.Resize,this.handleResize),this.setupDom(),this.treeIndex=new ie,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.virtualStyleRulesMap=new Map,this.emitter.on(e.ReplayerEvents.Flush,(function(){var e,t,r,a,i,s,l,c,u=o.treeIndex.flush(),d=u.scrollMap,f=u.inputMap,p=u.mutationData;o.fragmentParentMap.forEach((function(e,t){return o.restoreRealParent(t,e)}));try{for(var h=n(p.texts),m=h.next();!m.done;m=h.next()){var v=m.value;o.applyText(v,p)}}catch(t){e={error:t}}finally{try{m&&!m.done&&(t=h.return)&&t.call(h)}finally{if(e)throw e.error}}try{for(var y=n(o.virtualStyleRulesMap.keys()),g=y.next();!g.done;g=y.next()){var b=g.value;o.restoreNodeSheet(b)}}catch(e){r={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(r)throw r.error}}o.fragmentParentMap.clear(),o.elementStateMap.clear(),o.virtualStyleRulesMap.clear();try{for(var S=n(d.values()),w=S.next();!w.done;w=S.next()){v=w.value;o.applyScroll(v,!0)}}catch(e){i={error:e}}finally{try{w&&!w.done&&(s=S.return)&&s.call(S)}finally{if(i)throw i.error}}try{for(var x=n(f.values()),E=x.next();!E.done;E=x.next()){v=E.value;o.applyInput(v)}}catch(e){l={error:e}}finally{try{E&&!E.done&&(c=x.return)&&c.call(x)}finally{if(l)throw l.error}}})),this.emitter.on(e.ReplayerEvents.PlayBack,(function(){o.firstFullSnapshot=null,o.mirror.reset()}));var i=new rt([],(null==r?void 0:r.speed)||a.speed);this.service=vt({events:t.map((function(e){return r&&r.unpackFn?r.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(t){o.emitter.emit(e.ReplayerEvents.StateChange,{player:t})})),this.speedService=mt(pt({id:"speed",context:{normalSpeed:-1,timer:i},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:function(e,t){"payload"in t&&e.timer.setSpeed(t.payload.speed)},recordSpeed:st({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(t){o.emitter.emit(e.ReplayerEvents.StateChange,{speed:t})}));var s=this.service.state.context.events.find((function(t){return t.type===e.EventType.Meta})),l=this.service.state.context.events.find((function(t){return t.type===e.EventType.FullSnapshot}));if(s){var c=s.data,u=c.width,d=c.height;setTimeout((function(){o.emitter.emit(e.ReplayerEvents.Resize,{width:u,height:d})}),0)}l&&setTimeout((function(){o.firstFullSnapshot||(o.firstFullSnapshot=l,o.rebuildFullSnapshot(l),o.iframe.contentWindow.scrollTo(l.data.initialOffset))}),1),this.service.state.context.events.find(Nt)&&this.mouse.classList.add("touch-device")}return Object.defineProperty(i.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),i.prototype.on=function(e,t){return this.emitter.on(e,t),this},i.prototype.off=function(e,t){return this.emitter.off(e,t),this},i.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(r){t.config[r]=e[r]})),this.config.skipInactive||this.backToNormal(),void 0!==e.speed&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),void 0!==e.mouseTail&&(!1===e.mouseTail?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"))},i.prototype.getMetaData=function(){var e=this.service.state.context.events[0],t=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:e.timestamp,endTime:t.timestamp,totalTime:t.timestamp-e.timestamp}},i.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},i.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},i.prototype.getMirror=function(){return this.mirror},i.prototype.play=function(t){var r;void 0===t&&(t=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}}),null===(r=this.iframe.contentDocument)||void 0===r||r.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Start)},i.prototype.pause=function(t){var r;void 0===t&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof t&&(this.play(t),this.service.send({type:"PAUSE"})),null===(r=this.iframe.contentDocument)||void 0===r||r.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Pause)},i.prototype.resume=function(t){void 0===t&&(t=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(e.ReplayerEvents.Resume)},i.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},i.prototype.addEvent=function(e){var t=this,r=this.config.unpackFn?this.config.unpackFn(e):e;Nt(r)&&this.mouse.classList.add("touch-device"),Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:r}})}))},i.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},i.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},i.prototype.resetCache=function(){this.cache=H()},i.prototype.setupDom=function(){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),!1!==this.config.mouseTail&&(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");var e=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&e.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",e.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(et(this.iframe.contentWindow,this.iframe.contentDocument),ae(this.iframe.contentWindow))},i.prototype.handleResize=function(e){var t,r;this.iframe.style.display="inherit";try{for(var o=n([this.mouseTail,this.iframe]),a=o.next();!a.done;a=o.next()){var i=a.value;i&&(i.setAttribute("width",String(e.width)),i.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},i.prototype.applyEventsSynchronously=function(t){var r,o;try{for(var a=n(t),i=a.next();!i.done;i=a.next()){var s=i.value;switch(s.type){case e.EventType.DomContentLoaded:case e.EventType.Load:case e.EventType.Custom:continue;case e.EventType.FullSnapshot:case e.EventType.Meta:case e.EventType.Plugin:break;case e.EventType.IncrementalSnapshot:switch(s.data.source){case e.IncrementalSource.MediaInteraction:continue}}this.getCastFn(s,!0)()}}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null,!0===this.touchActive?this.mouse.classList.add("touch-active"):!1===this.touchActive&&this.mouse.classList.remove("touch-active"),this.touchActive=null},i.prototype.getCastFn=function(t,r){var o,a=this;switch(void 0===r&&(r=!1),t.type){case e.EventType.DomContentLoaded:case e.EventType.Load:break;case e.EventType.Custom:o=function(){a.emitter.emit(e.ReplayerEvents.CustomEvent,t)};break;case e.EventType.Meta:o=function(){return a.emitter.emit(e.ReplayerEvents.Resize,{width:t.data.width,height:t.data.height})};break;case e.EventType.FullSnapshot:o=function(){if(a.firstFullSnapshot){if(a.firstFullSnapshot===t)return void(a.firstFullSnapshot=!0)}else a.firstFullSnapshot=!0;a.rebuildFullSnapshot(t,r),a.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case e.EventType.IncrementalSnapshot:o=function(){var o,i;if(a.applyIncremental(t,r),!r&&(t===a.nextUserInteractionEvent&&(a.nextUserInteractionEvent=null,a.backToNormal()),a.config.skipInactive&&!a.nextUserInteractionEvent)){try{for(var s=n(a.service.state.context.events),l=s.next();!l.done;l=s.next()){var c=l.value;if(!(c.timestamp<=t.timestamp)&&a.isUserInteraction(c)){c.delay-t.delay>1e4*a.speedService.state.context.timer.speed&&(a.nextUserInteractionEvent=c);break}}}catch(e){o={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}if(a.nextUserInteractionEvent){var u=a.nextUserInteractionEvent.delay-t.delay,d={speed:Math.min(Math.round(u/5e3),a.config.maxSpeed)};a.speedService.send({type:"FAST_FORWARD",payload:d}),a.emitter.emit(e.ReplayerEvents.SkipStart,d)}}}}return function(){var i,s;o&&o();try{for(var l=n(a.config.plugins||[]),c=l.next();!c.done;c=l.next()){c.value.handler(t,r,{replayer:a})}}catch(e){i={error:e}}finally{try{c&&!c.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}a.service.send({type:"CAST_EVENT",payload:{event:t}});var u=a.service.state.context.events.length-1;if(t===a.service.state.context.events[u]){var d=function(){u0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(e.ReplayerEvents.LoadStylesheetStart),o=setTimeout((function(){i.matches("playing")&&r.play(r.getCurrentTime()),o=-1,l()}),this.config.loadTimeout))}},i.prototype.hasImageArg=function(e){var t,r;try{for(var o=n(e),a=o.next();!a.done;a=o.next()){var i=a.value;if(i&&"object"==typeof i)if("rr_type"in i&&"args"in i){if(this.hasImageArg(i.args))return!0}else{if("rr_type"in i&&"HTMLImageElement"===i.rr_type)return!0;if(i instanceof Array&&this.hasImageArg(i))return!0}else;}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return!1},i.prototype.getImageArgs=function(e){var t,r,i=[];try{for(var s=n(e),l=s.next();!l.done;l=s.next()){var c=l.value;c&&"object"==typeof c&&("rr_type"in c&&"args"in c?i.push.apply(i,a([],o(this.getImageArgs(c.args)),!1)):"rr_type"in c&&"HTMLImageElement"===c.rr_type?i.push(c.src):c instanceof Array&&i.push.apply(i,a([],o(this.getImageArgs(c)),!1)))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return i},i.prototype.preloadAllImages=function(){var t,r,o=this;this.service.state;var a=function(){o.service.state};this.emitter.on(e.ReplayerEvents.Start,a),this.emitter.on(e.ReplayerEvents.Pause,a);var i=function(t){t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.CanvasMutation&&("commands"in t.data?t.data.commands.forEach((function(e){return o.preloadImages(e,t)})):s.preloadImages(t.data,t))},s=this;try{for(var l=n(this.service.state.context.events),c=l.next();!c.done;c=l.next()){i(c.value)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}},i.prototype.preloadImages=function(e,t){var r=this;if("drawImage"!==e.property||"string"!=typeof e.args[0]||this.imageMap.has(t))this.hasImageArg(e.args)&&this.getImageArgs(e.args).forEach((function(e){var t=new Image;t.src=e,r.imageMap.set(e,t)}));else{var n=document.createElement("canvas"),o=n.getContext("2d"),a=null==o?void 0:o.createImageData(n.width,n.height);null==a||a.data,JSON.parse(e.args[0]),null==o||o.putImageData(a,0,0)}},i.prototype.applyIncremental=function(t,n){var o,a,i=this,s=t.data;switch(s.source){case e.IncrementalSource.Mutation:n&&(s.adds.forEach((function(e){return i.treeIndex.add(e)})),s.texts.forEach((function(e){var t=i.mirror.getNode(e.id),r=null==t?void 0:t.parentNode;r&&i.virtualStyleRulesMap.has(r)&&i.virtualStyleRulesMap.delete(r),i.treeIndex.text(e)})),s.attributes.forEach((function(e){return i.treeIndex.attribute(e)})),s.removes.forEach((function(e){return i.treeIndex.remove(e,i.mirror)})));try{this.applyMutation(s,n)}catch(e){this.warn("Exception in mutation ".concat(e.message||e),s)}break;case e.IncrementalSource.Drag:case e.IncrementalSource.TouchMove:case e.IncrementalSource.MouseMove:if(n){var l=s.positions[s.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:s}}else s.positions.forEach((function(e){var r={doAction:function(){i.moveAndHover(e.x,e.y,e.id,n,s)},delay:e.timeOffset+t.timestamp-i.service.state.context.baselineTime};i.timer.addAction(r)})),this.timer.addAction({doAction:function(){},delay:t.delay-(null===(o=s.positions[0])||void 0===o?void 0:o.timeOffset)});break;case e.IncrementalSource.MouseInteraction:if(-1===s.id)break;var c=new Event(e.MouseInteractions[s.type].toLowerCase());if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);this.emitter.emit(e.ReplayerEvents.MouseInteraction,{type:s.type,target:S});var u=this.config.triggerFocus;switch(s.type){case e.MouseInteractions.Blur:"blur"in S&&S.blur();break;case e.MouseInteractions.Focus:u&&S.focus&&S.focus({preventScroll:!0});break;case e.MouseInteractions.Click:case e.MouseInteractions.TouchStart:case e.MouseInteractions.TouchEnd:n?(s.type===e.MouseInteractions.TouchStart?this.touchActive=!0:s.type===e.MouseInteractions.TouchEnd&&(this.touchActive=!1),this.mousePos={x:s.x,y:s.y,id:s.id,debugData:s}):(s.type===e.MouseInteractions.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(s.x,s.y,s.id,n,s),s.type===e.MouseInteractions.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):s.type===e.MouseInteractions.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):s.type===e.MouseInteractions.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case e.MouseInteractions.TouchCancel:n?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:S.dispatchEvent(c)}break;case e.IncrementalSource.Scroll:if(-1===s.id)break;if(n){this.treeIndex.scroll(s);break}this.applyScroll(s,!1);break;case e.IncrementalSource.ViewportResize:this.emitter.emit(e.ReplayerEvents.Resize,{width:s.width,height:s.height});break;case e.IncrementalSource.Input:if(-1===s.id)break;if(n){this.treeIndex.input(s);break}this.applyInput(s);break;case e.IncrementalSource.MediaInteraction:if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);var d=S;try{s.currentTime&&(d.currentTime=s.currentTime),s.volume&&(d.volume=s.volume),s.muted&&(d.muted=s.muted),1===s.type&&d.pause(),0===s.type&&d.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: ".concat(e.message||e))}break;case e.IncrementalSource.StyleSheetRule:if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);var f,p=S,h=S.parentNode,m=this.fragmentParentMap.has(h),v=m?null:p.sheet;v||(this.virtualStyleRulesMap.has(S)?f=this.virtualStyleRulesMap.get(S):(f=[],this.virtualStyleRulesMap.set(S,f))),s.adds&&s.adds.forEach((function(e){var t=e.rule,r=e.index;if(v)try{if(Array.isArray(r)){var n=bt(r),o=n.positions,a=n.index;gt(v.cssRules,o).insertRule(t,a)}else{a=void 0===r?void 0:Math.min(r,v.cssRules.length);v.insertRule(t,a)}}catch(e){}else null==f||f.push({cssText:t,index:r,type:yt.Insert})})),s.removes&&s.removes.forEach((function(e){var t=e.index;if(m)null==f||f.push({index:t,type:yt.Remove});else try{if(Array.isArray(t)){var r=bt(t),n=r.positions,o=r.index;gt(v.cssRules,n).deleteRule(o||0)}else null==v||v.deleteRule(t)}catch(e){}}));break;case e.IncrementalSource.StyleDeclaration:if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);p=S;var y=S.parentNode,g=this.fragmentParentMap.has(y)?null:p.sheet,b=[];if(g||(this.virtualStyleRulesMap.has(S)?b=this.virtualStyleRulesMap.get(S):(b=[],this.virtualStyleRulesMap.set(S,b))),s.set)if(g)gt(g.rules,s.index).style.setProperty(s.set.property,s.set.value,s.set.priority);else b.push(r({type:yt.SetProperty,index:s.index},s.set));if(s.remove)if(g)gt(g.rules,s.index).style.removeProperty(s.remove.property);else b.push(r({type:yt.RemoveProperty,index:s.index},s.remove));break;case e.IncrementalSource.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var S;if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);!function(e){var t=e.event,r=e.mutation,n=e.target,o=e.imageMap,a=e.errorHandler;try{var i="commands"in r?r.commands:[r];[P.WebGL,P.WebGL2].includes(r.type)?i.forEach((function(e){It({mutation:e,type:r.type,target:n,imageMap:o,errorHandler:a})})):i.forEach((function(e){!function(e){var t=e.event,r=e.mutation,n=e.target,o=e.imageMap,a=e.errorHandler;try{var i=n.getContext("2d");if(r.setter)return void(i[r.property]=r.args[0]);var s=i[r.property];if("drawImage"===r.property&&"string"==typeof r.args[0]){var l=o.get(t);r.args[0]=l,s.apply(i,r.args)}else s.apply(i,r.args)}catch(e){a(r,e)}}({event:t,mutation:e,target:n,imageMap:o,errorHandler:a})}))}catch(e){a(r,e)}}({event:t,mutation:s,target:S,imageMap:this.imageMap,errorHandler:this.warnCanvasMutationFailed.bind(this)});break;case e.IncrementalSource.Font:try{var w=new FontFace(s.family,s.buffer?new Uint8Array(JSON.parse(s.fontSource)):s.fontSource,s.descriptors);null===(a=this.iframe.contentDocument)||void 0===a||a.fonts.add(w)}catch(e){this.config.showWarning&&console.warn(e)}}},i.prototype.applyMutation=function(e,o){var a,i,s=this;e.removes.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.parentId})))return;return s.warnNodeNotFound(e,t.id)}s.virtualStyleRulesMap.has(r)&&s.virtualStyleRulesMap.delete(r);var n=s.mirror.getNode(t.parentId);if(!n)return s.warnNodeNotFound(e,t.parentId);if(t.isShadow&&de(n)&&(n=n.shadowRoot),s.mirror.removeNodeFromMap(r),n){var o=null,a="__sn"in n?s.fragmentParentMap.get(n):void 0;a&&a.contains(r)?n=a:s.fragmentParentMap.has(r)&&(o=s.fragmentParentMap.get(r),s.fragmentParentMap.delete(r),r=o);try{n.removeChild(r)}catch(t){if(!(t instanceof DOMException))throw t;s.warn("parent could not remove child in mutation",n,a,r,o,e)}}}));var l=r({},this.legacy_missingNodeRetryMap),c=[],u=function(e){var r,a,i,u;if(!s.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var d=s.mirror.getNode(e.parentId);if(!d)return e.node.type===t.Document?s.newDocumentQueue.push(e):c.push(e);var f=null;s.iframe.contentDocument.contains?f=s.iframe.contentDocument.contains(d):s.iframe.contentDocument.body.contains&&(f=s.iframe.contentDocument.body.contains(d));var p=(null===(u=(i=d).getElementsByTagName)||void 0===u?void 0:u.call(i,"iframe").length)>0;if(o&&f&&!ce(d)&&!p){var h=document.createDocumentFragment();for(s.mirror.map[e.parentId]=h,s.fragmentParentMap.set(h,d),s.storeState(d);d.firstChild;)h.appendChild(d.firstChild);d=h}e.node.isShadow&&(de(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);var m=null,v=null;if(e.previousId&&(m=s.mirror.getNode(e.previousId)),e.nextId&&(v=s.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=s.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return c.push(e);if(!e.node.rootId||s.mirror.getNode(e.node.rootId)){var y=e.node.rootId?s.mirror.getNode(e.node.rootId):s.iframe.contentDocument;if(ce(d))s.attachDocumentToIframe(e,d);else{var g=G(e.node,{doc:y,map:s.mirror.map,skipChild:!0,hackCss:!0,cache:s.cache});if(-1!==e.previousId&&-1!==e.nextId){if("__sn"in d&&d.__sn.type===t.Element&&"textarea"===d.__sn.tagName&&e.node.type===t.Text)try{for(var b=n(Array.from(d.childNodes)),S=b.next();!S.done;S=b.next()){var w=S.value;w.nodeType===d.TEXT_NODE&&d.removeChild(w)}}catch(e){r={error:e}}finally{try{S&&!S.done&&(a=b.return)&&a.call(b)}finally{if(r)throw r.error}}if(m&&m.nextSibling&&m.nextSibling.parentNode)d.insertBefore(g,m.nextSibling);else if(v&&v.parentNode)d.contains(v)?d.insertBefore(g,v):d.insertBefore(g,null);else{if(d===y)for(;y.firstChild;)y.removeChild(y.firstChild);d.appendChild(g)}if(ce(g)){var x=s.newDocumentQueue.find((function(e){return e.parentId===g.__sn.id}));x&&(s.attachDocumentToIframe(x,g),s.newDocumentQueue=s.newDocumentQueue.filter((function(e){return e!==x})))}(e.previousId||e.nextId)&&s.legacy_resolveMissingNode(l,d,g,e)}else l[e.node.id]={node:g,mutation:e}}}};e.adds.forEach((function(e){u(e)}));for(var d=Date.now();c.length;){var f=se(c);if(c.length=0,Date.now()-d>500){this.warn("Timeout in the loop, please check the resolve tree data:",f);break}try{for(var p=(a=void 0,n(f)),h=p.next();!h.done;h=p.next()){var m=h.value;this.mirror.getNode(m.value.parentId)?le(m,(function(e){u(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",m)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}}Object.keys(l).length&&Object.assign(this.legacy_missingNodeRetryMap,l),e.texts.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.id})))return;return s.warnNodeNotFound(e,t.id)}s.fragmentParentMap.has(r)&&(r=s.fragmentParentMap.get(r)),r.textContent=t.value})),e.attributes.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.id})))return;return s.warnNodeNotFound(e,t.id)}for(var n in s.fragmentParentMap.has(r)&&(r=s.fragmentParentMap.get(r)),t.attributes)if("string"==typeof n){var o=t.attributes[n];if(null===o)r.removeAttribute(n);else if("string"==typeof o)try{r.setAttribute(n,o)}catch(e){s.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}else if("style"===n){var a=o,i=r;for(var l in a)if(!1===a[l])i.style.removeProperty(l);else if(a[l]instanceof Array){var c=a[l];i.style.setProperty(l,c[0],c[1])}else{var u=a[l];i.style.setProperty(l,u)}}}}))},i.prototype.applyScroll=function(e,r){var n=this.mirror.getNode(e.id);if(!n)return this.debugNodeNotFound(e,e.id);if(n===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:r?"auto":"smooth"});else if(n.__sn.type===t.Document)n.defaultView.scrollTo({top:e.y,left:e.x,behavior:r?"auto":"smooth"});else try{n.scrollTop=e.y,n.scrollLeft=e.x}catch(e){}},i.prototype.applyInput=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);try{t.checked=e.isChecked,t.value=e.text}catch(e){}},i.prototype.applyText=function(e,t){var r=this.mirror.getNode(e.id);if(!r)return this.debugNodeNotFound(t,e.id);try{r.textContent=e.value}catch(e){}},i.prototype.legacy_resolveMissingNode=function(e,t,r,n){var o=n.previousId,a=n.nextId,i=o&&e[o],s=a&&e[a];if(i){var l=i,c=l.node,u=l.mutation;t.insertBefore(c,r),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}if(s){var d=s;c=d.node,u=d.mutation;t.insertBefore(c,r.nextSibling),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}},i.prototype.moveAndHover=function(e,t,r,n,o){var a=this.mirror.getNode(r);if(!a)return this.debugNodeNotFound(o,r);var i=ue(a,this.iframe),s=e*i.absoluteScale+i.x,l=t*i.absoluteScale+i.y;this.mouse.style.left="".concat(s,"px"),this.mouse.style.top="".concat(l,"px"),n||this.drawMouseTail({x:s,y:l}),this.hoverElements(a)},i.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var r=!0===this.config.mouseTail?kt:Object.assign({},kt,this.config.mouseTail),n=r.lineCap,o=r.lineWidth,a=r.strokeStyle,i=r.duration,s=function(){if(t.mouseTail){var e=t.mouseTail.getContext("2d");e&&t.tailPositions.length&&(e.clearRect(0,0,t.mouseTail.width,t.mouseTail.height),e.beginPath(),e.lineWidth=o,e.lineCap=n,e.strokeStyle=a,e.moveTo(t.tailPositions[0].x,t.tailPositions[0].y),t.tailPositions.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}};this.tailPositions.push(e),s(),setTimeout((function(){t.tailPositions=t.tailPositions.filter((function(t){return t!==e})),s()}),i/this.speedService.state.context.timer.speed)}},i.prototype.hoverElements=function(e){var t;null===(t=this.iframe.contentDocument)||void 0===t||t.querySelectorAll(".\\:hover").forEach((function(e){e.classList.remove(":hover")}));for(var r=e;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement},i.prototype.isUserInteraction=function(t){return t.type===e.EventType.IncrementalSnapshot&&(t.data.source>e.IncrementalSource.Mutation&&t.data.source<=e.IncrementalSource.Input)},i.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(e.ReplayerEvents.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},i.prototype.restoreRealParent=function(e,r){this.mirror.map[r.__sn.id]=r,r.__sn.type===t.Element&&"textarea"===r.__sn.tagName&&e.textContent&&(r.value=e.textContent),r.appendChild(e),this.restoreState(r)},i.prototype.storeState=function(e){var t,r;if(e&&e.nodeType===e.ELEMENT_NODE){var o=e;(o.scrollLeft||o.scrollTop)&&this.elementStateMap.set(e,{scroll:[o.scrollLeft,o.scrollTop]}),"STYLE"===o.tagName&&function(e,t){var r;try{var n=Array.from((null===(r=e.sheet)||void 0===r?void 0:r.cssRules)||[]).map((function(e){return e.cssText}));t.set(e,[{type:yt.Snapshot,cssTexts:n}])}catch(e){}}(o,this.virtualStyleRulesMap);var a=o.children;try{for(var i=n(Array.from(a)),s=i.next();!s.done;s=i.next()){var l=s.value;this.storeState(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}},i.prototype.restoreState=function(e){var t,r;if(e.nodeType===e.ELEMENT_NODE){var o=e;if(this.elementStateMap.has(e)){var a=this.elementStateMap.get(e);a.scroll&&(o.scrollLeft=a.scroll[0],o.scrollTop=a.scroll[1]),this.elementStateMap.delete(e)}var i=o.children;try{for(var s=n(Array.from(i)),l=s.next();!l.done;l=s.next()){var c=l.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}},i.prototype.restoreNodeSheet=function(e){var t=this.virtualStyleRulesMap.get(e);"STYLE"===e.nodeName&&(t&&St(t,e))},i.prototype.warnNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.warn("Node with id '".concat(t,"' was previously removed. "),e):this.warn("Node with id '".concat(t,"' not found. "),e)},i.prototype.warnCanvasMutationFailed=function(e,t){this.warn("Has error on canvas update",t,"canvas mutation:",e)},i.prototype.debugNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.debug(Mt,"Node with id '".concat(t,"' was previously removed. "),e):this.debug(Mt,"Node with id '".concat(t,"' not found. "),e)},i.prototype.warn=function(){for(var e=[],t=0;t>>1|(21845&Xt)<<1;qt=(61680&(qt=(52428&qt)>>>2|(13107&qt)<<2))>>>4|(3855&qt)<<4,Yt[Xt]=((65280&qt)>>>8|(255&qt)<<8)>>>1}var Qt=function(e,t,r){for(var n=e.length,o=0,a=new At(t);o>>l]=c}else for(i=new At(n),o=0;o>>15-e[o];return i},$t=new Lt(288);for(Xt=0;Xt<144;++Xt)$t[Xt]=8;for(Xt=144;Xt<256;++Xt)$t[Xt]=9;for(Xt=256;Xt<280;++Xt)$t[Xt]=7;for(Xt=280;Xt<288;++Xt)$t[Xt]=8;var Jt=new Lt(32);for(Xt=0;Xt<32;++Xt)Jt[Xt]=5;var Kt=Qt($t,9,0),Zt=Qt($t,9,1),er=Qt(Jt,5,0),tr=Qt(Jt,5,1),rr=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},nr=function(e,t,r){var n=t/8>>0;return(e[n]|e[n+1]<<8)>>>(7&t)&r},or=function(e,t){var r=t/8>>0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>>(7&t)},ar=function(e){return(e/8>>0)+(7&e&&1)},ir=function(e,t,r){(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length);var n=new(e instanceof At?At:e instanceof Dt?Dt:Lt)(r-t);return n.set(e.subarray(t,r)),n},sr=function(e,t,r){r<<=7&t;var n=t/8>>0;e[n]|=r,e[n+1]|=r>>>8},lr=function(e,t,r){r<<=7&t;var n=t/8>>0;e[n]|=r,e[n+1]|=r>>>8,e[n+2]|=r>>>16},cr=function(e,t){for(var r=[],n=0;nf&&(f=a[n].s);var p=new At(f+1),h=ur(r[u-1],p,0);if(h>t){n=0;var m=0,v=h-t,y=1<t))break;m+=y-(1<>>=v;m>0;){var b=a[n].s;p[b]=0&&m;--n){var S=a[n].s;p[S]==t&&(--p[S],++m)}h=t}return[new Lt(p),h]},ur=function(e,t,r){return-1==e.s?Math.max(ur(e.l,t,r+1),ur(e.r,t,r+1)):t[e.s]=r},dr=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new At(++t),n=0,o=e[0],a=1,i=function(e){r[n++]=e},s=1;s<=t;++s)if(e[s]==o&&s!=t)++a;else{if(!o&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(o),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(o);a=1,o=e[s]}return[r.subarray(0,n),t]},fr=function(e,t){for(var r=0,n=0;n>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var a=0;a4&&!C[Wt[k-1]];--k);var N,R,_,O,L=c+5<<3,A=fr(o,$t)+fr(a,Jt)+i,D=fr(o,f)+fr(a,m)+i+14+3*k+fr(E,C)+(2*E[16]+3*E[17]+7*E[18]);if(L<=A&&L<=D)return pr(t,u,e.subarray(l,l+c));if(sr(t,u,1+(D15&&(sr(t,u,j[T]>>>5&127),u+=j[T]>>>12)}}}else N=Kt,R=$t,_=er,O=Jt;for(T=0;T255){U=n[T]>>>18&31;lr(t,u,N[U+257]),u+=R[U+257],U>7&&(sr(t,u,n[T]>>>23&31),u+=Ft[U]);var z=31&n[T];lr(t,u,_[z]),u+=O[z],z>3&&(lr(t,u,n[T]>>>5&8191),u+=Pt[z])}else lr(t,u,N[n[T]]),u+=R[n[T]];return lr(t,u,N[256]),u+R[256]},mr=new Dt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),vr=new Lt(0),yr=function(e,t,r,n,o){return function(e,t,r,n,o,a){var i=e.length,s=new Lt(n+i+5*(1+Math.floor(i/7e3))+o),l=s.subarray(n,s.length-o),c=0;if(!t||i<8)for(var u=0;u<=i;u+=65535){var d=u+65535;d>>13,h=8191&f,m=(1<7e3||C>24576)&&O>423){c=hr(e,l,0,w,x,E,I,C,k,u-k,c),C=T=I=0,k=u;for(var L=0;L<286;++L)x[L]=0;for(L=0;L<30;++L)E[L]=0}var A=2,D=0,F=h,P=R-_&32767;if(O>2&&N==S(u-P))for(var W=Math.min(p,O)-1,j=Math.min(32767,u),U=Math.min(258,O);P<=j&&--F&&R!=_;){if(e[u+A]==e[u+A-P]){for(var z=0;zA){if(A=z,D=P,z>W)break;var B=Math.min(P,z-2),H=0;for(L=0;LH&&(H=G,_=V)}}}P+=(R=_)-(_=v[R])+32768&32767}if(D){w[C++]=268435456|Bt[A]<<18|Gt[D];var Y=31&Bt[A],X=31&Gt[D];I+=Ft[Y]+Pt[X],++x[257+Y],++E[X],M=u+A,++T}else w[C++]=e[u],++x[e[u]]}}c=hr(e,l,a,w,x,E,I,C,k,u-k,c),a||(c=pr(l,c,vr))}return ir(s,0,n+ar(c)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,r,n,!o)};function gr(e,t){void 0===t&&(t={});var r=function(){var e=1,t=0;return{p:function(r){for(var n=e,o=t,a=r.length,i=0;i!=a;){for(var s=Math.min(i+5552,a);i>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();r.p(e);var n=yr(e,t,2,4);return function(e,t){var r=t.level,n=0==r?0:r<6?1:9==r?3:2;e[0]=120,e[1]=n<<6|(n?32-2*n:1)}(n,t),function(e,t,r){for(;r;++t)e[t]=r,r>>>=8}(n,n.length-4,r.d()),n}function br(e,t){return function(e,t,r){var n=e.length,o=!t||r,a=!r||r.i;r||(r={}),t||(t=new Lt(3*n));var i=function(e){var r=t.length;if(e>r){var n=new Lt(Math.max(2*r,e));n.set(t),t=n}},s=r.f||0,l=r.p||0,c=r.b||0,u=r.l,d=r.d,f=r.m,p=r.n,h=8*n;do{if(!u){r.f=s=nr(e,l,1);var m=nr(e,l+1,3);if(l+=3,!m){var v=e[(M=ar(l)+4)-4]|e[M-3]<<8,y=M+v;if(y>n){if(a)throw"unexpected EOF";break}o&&i(c+v),t.set(e.subarray(M,y),c),r.b=c+=v,r.p=l=8*y;continue}if(1==m)u=Zt,d=tr,f=9,p=5;else{if(2!=m)throw"invalid block type";var g=nr(e,l,31)+257,b=nr(e,l+10,15)+4,S=g+nr(e,l+5,31)+1;l+=14;for(var w=new Lt(S),x=new Lt(19),E=0;Eh)break;var C=Qt(x,T,1);for(E=0;E>>4)<16)w[E++]=M;else{var N=0,R=0;for(16==M?(R=3+nr(e,l,3),l+=2,N=w[E-1]):17==M?(R=3+nr(e,l,7),l+=3):18==M&&(R=11+nr(e,l,127),l+=7);R--;)w[E++]=N}}var _=w.subarray(0,g),O=w.subarray(g);f=rr(_),p=rr(O),u=Qt(_,f,1),d=Qt(O,p,1)}if(l>h)throw"unexpected EOF"}o&&i(c+131072);for(var L=(1<>>4;if((l+=15&N)>h)throw"unexpected EOF";if(!N)throw"invalid length/literal";if(F<256)t[c++]=F;else{if(256==F){u=null;break}var P=F-254;if(F>264){var W=Ft[E=F-257];P=nr(e,l,(1<>>4;if(!j)throw"invalid distance";if(l+=15&j,O=Vt[U],U>3&&(W=Pt[U],O+=or(e,l)&(1<h)throw"unexpected EOF";o&&i(c+131072);for(var z=c+P;c>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}function Sr(e,t){var r=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var n=new Lt(e.length+(e.length>>>1)),o=0,a=function(e){n[o++]=e},i=0;in.length){var s=new Lt(o+8+(r-i<<1));s.set(n),n=s}var l=e.charCodeAt(i);l<128||t?a(l):l<2048?(a(192|l>>>6),a(128|63&l)):l>55295&&l<57344?(a(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++i))>>>18),a(128|l>>>12&63),a(128|l>>>6&63),a(128|63&l)):(a(224|l>>>12),a(128|l>>>6&63),a(128|63&l))}return ir(n,0,o)}function wr(e,t){var r="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var n=0;n>10,56320|1023&o))}return r}var xr="v1",Er=function(){function e(e){this.fileName=e.fileName||"",this.functionName=e.functionName||"",this.lineNumber=e.lineNumber,this.columnNumber=e.columnNumber}return e.prototype.toString=function(){var e=this.lineNumber||"",t=this.columnNumber||"";return this.functionName?this.functionName+" ("+this.fileName+":"+e+":"+t+")":this.fileName+":"+e+":"+t},e}(),Tr=/(^|@)\S+:\d+/,Ir=/^\s*at .*(\S+:\d+|\(native\))/m,Cr=/^(eval@)?(\[native code])?$/,Mr={parse:function(e){if(!e)return[];if(void 0!==e.stacktrace||void 0!==e["opera#sourceloc"])return this.parseOpera(e);if(e.stack&&e.stack.match(Ir))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(-1===e.indexOf(":"))return[e];var t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!t)throw new Error("Cannot parse given url: ".concat(e));return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE:function(e){return e.stack.split("\n").filter((function(e){return!!e.match(Ir)}),this).map((function(e){e.indexOf("(eval ")>-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));var t=e.replace(/^\s+/,"").replace(/\(eval code/g,"("),r=t.match(/ (\((.+):(\d+):(\d+)\)$)/),n=(t=r?t.replace(r[0],""):t).split(/\s+/).slice(1),o=this.extractLocation(r?r[1]:n.pop()),a=n.join(" ")||void 0,i=["eval",""].indexOf(o[0])>-1?void 0:o[0];return new Er({functionName:a,fileName:i,lineNumber:o[1],columnNumber:o[2]})}),this)},parseFFOrSafari:function(e){return e.stack.split("\n").filter((function(e){return!e.match(Cr)}),this).map((function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new Er({functionName:e});var t=/((.*".+"[^@]*)?[^@]*)(?:@)/,r=e.match(t),n=r&&r[1]?r[1]:void 0,o=this.extractLocation(e.replace(t,""));return new Er({functionName:n,fileName:o[0],lineNumber:o[1],columnNumber:o[2]})}),this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){for(var t=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split("\n"),n=[],o=2,a=r.length;o/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new Er({functionName:n,fileName:r[0],lineNumber:r[1],columnNumber:r[2]})}),this)}};function kr(e){if(!e||!e.outerHTML)return"";for(var t="";e.parentElement;){var r=e.localName;if(!r)break;r=r.toLowerCase();var n=e.parentElement,o=[];if(n.children&&n.children.length>0)for(var a=0;a1&&(r+=":eq("+o.indexOf(e)+")"),t=r+(t?">"+t:""),e=n}return t}function Nr(e){return"[object Object]"===Object.prototype.toString.call(e)}function Rr(e,t){var r,o;if(0===t)return!0;var a=Object.keys(e);try{for(var i=n(a),s=i.next();!s.done;s=i.next()){var l=s.value;if(Nr(e[l])&&Rr(e[l],t-1))return!0}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}return!1}function _r(e,t){var r={numOfKeysLimit:50,depthOfLimit:4};Object.assign(r,t);var n=[],o=[];return JSON.stringify(e,(function(e,t){if(n.length>0){var a=n.indexOf(this);~a?n.splice(a+1):n.push(this),~a?o.splice(a,1/0,e):o.push(e),~n.indexOf(t)&&(t=n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]")}else n.push(t);if(null==t)return t;if(function(e){if(Nr(e)&&Object.keys(e).length>r.numOfKeysLimit)return!0;if("function"==typeof e)return!0;if(Nr(e)&&Rr(e,r.depthOfLimit))return!0;return!1}(t))return function(e){var t=e.toString();r.stringLengthLimit&&t.length>r.stringLengthLimit&&(t="".concat(t.slice(0,r.stringLengthLimit),"..."));return t}(t);if(t instanceof Event){var i={};for(var s in t){var l=t[s];Array.isArray(l)?i[s]=kr(l.length?l[0]:null):i[s]=l}return i}return t instanceof Node?t instanceof HTMLElement?t?t.outerHTML:"":t.nodeName:t instanceof Error?t.stack?t.stack+"\nEnd of stack for Error object":t.name+": "+t.message:t}))}var Or={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function Lr(e,t,r){var i,s,l,c=r.logger;if(!c)return function(){};l="string"==typeof c?t[c]:c;var u=0,d=[];if(r.level.includes("error")&&window){var f=function(t){var n=t.message,o=t.error,a=Mr.parse(o).map((function(e){return e.toString()})),i=[_r(n,r.stringifyOptions)];e({level:"error",trace:a,payload:i})};window.addEventListener("error",f),d.push((function(){window&&window.removeEventListener("error",f)}))}try{for(var p=n(r.level),h=p.next();!h.done;h=p.next()){var m=h.value;d.push(v(l,m))}}catch(e){i={error:e}}finally{try{h&&!h.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}return function(){d.forEach((function(e){return e()}))};function v(t,n){var i=this;return t[n]?K(t,n,(function(t){return function(){for(var s=[],l=0;l0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(tt||(tt={}));var at={type:"xstate.init"};function it(e){return void 0===e?[]:[].concat(e)}function st(e){return{type:"xstate.assign",assignment:e}}function lt(e,t){return"string"==typeof(e="string"==typeof e&&t&&t[e]?t[e]:e)?{type:e}:"function"==typeof e?{type:e.name,exec:e}:e}function ct(e){return function(t){return e===t}}function ut(e){return"string"==typeof e?{type:e}:e}function dt(e,t){return{value:e,context:t,actions:[],changed:!1,matches:ct(e)}}function ft(e,t,r){var n=t,o=!1;return[e.filter((function(e){if("xstate.assign"===e.type){o=!0;var t=Object.assign({},n);return"function"==typeof e.assignment?t=e.assignment(n,r):Object.keys(e.assignment).forEach((function(o){t[o]="function"==typeof e.assignment[o]?e.assignment[o](n,r):e.assignment[o]})),n=t,!1}return!0})),n,o]}function pt(e,t){void 0===t&&(t={});var r=ot(ft(it(e.states[e.initial].entry).map((function(e){return lt(e,t.actions)})),e.context,at),2),n=r[0],o=r[1],a={config:e,_options:t,initialState:{value:e.initial,actions:n,context:o,matches:ct(e.initial)},transition:function(t,r){var n,o,i="string"==typeof t?{value:t,context:e.context}:t,s=i.value,l=i.context,c=ut(r),u=e.states[s];if(u.on){var d=it(u.on[c.type]);try{for(var f=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(d),p=f.next();!p.done;p=f.next()){var h=p.value;if(void 0===h)return dt(s,l);var m="string"==typeof h?{target:h}:h,v=m.target,y=m.actions,g=void 0===y?[]:y,S=m.cond,b=void 0===S?function(){return!0}:S,w=void 0===v,x=null!=v?v:s,I=e.states[x];if(b(l,c)){var E=ot(ft((w?it(g):[].concat(u.exit,g,I.entry).filter((function(e){return e}))).map((function(e){return lt(e,a._options.actions)})),l,c),3),T=E[0],k=E[1],C=E[2],M=null!=v?v:s;return{value:M,context:k,actions:T,changed:v!==s||T.length>0||C,matches:ct(M)}}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(n)throw n.error}}}return dt(s,l)}};return a}var ht=function(e,t){return e.actions.forEach((function(r){var n=r.exec;return n&&n(e.context,t)}))};function mt(e){var t=e.initialState,r=tt.NotStarted,n=new Set,o={_machine:e,send:function(o){r===tt.Running&&(t=e.transition(t,o),ht(t,ut(o)),n.forEach((function(e){return e(t)})))},subscribe:function(e){return n.add(e),e(t),{unsubscribe:function(){return n.delete(e)}}},start:function(n){if(n){var a="object"==typeof n?n:{context:e.config.context,value:n};t={value:a.value,actions:[],context:a.context,matches:ct(a.value)}}return r=tt.Running,ht(t,at),o},stop:function(){return r=tt.Stopped,n.clear(),o},get state(){return t},get status(){return r}};return o}function vt(t,o){var a=o.getCastFn,i=o.applyEventsSynchronously,s=o.emitter;return mt(pt({id:"player",context:t,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:st({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:st((function(e,t){var n=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(n=t.payload.timeOffset),r(r({},e),{timeOffset:n,baselineTime:e.events[0].timestamp+n})})),play:function(t){var r,o,l,c,u,d=t.timer,f=t.events,p=t.baselineTime,h=t.lastPlayedEvent;d.clear();try{for(var m=n(f),v=m.next();!v.done;v=m.next()){nt(v.value,p)}}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=m.return)&&o.call(m)}finally{if(r)throw r.error}}var y=function(t,r){for(var n=t.length-1;n>=0;n--){var o=t[n];if(o.type===e.EventType.Meta&&o.timestamp<=r)return t.slice(n)}return t}(f,p),g=null==h?void 0:h.timestamp;(null==h?void 0:h.type)===e.EventType.IncrementalSnapshot&&h.data.source===e.IncrementalSource.MouseMove&&(g=h.timestamp+(null===(u=h.data.positions[0])||void 0===u?void 0:u.timeOffset)),p<(g||0)&&s.emit(e.ReplayerEvents.PlayBack);var S=new Array,b=new Array,w=function(e){if(g&&gi)try{null===(n=t.sheet)||void 0===n||n.deleteRule(Number(s))}catch(e){}i=c})),e.forEach((function(e,r){var n,o,a;try{(null===(o=null===(n=t.sheet)||void 0===n?void 0:n.cssRules[r])||void 0===o?void 0:o.cssText)!==e&&(null===(a=t.sheet)||void 0===a||a.insertRule(e,r))}catch(e){}}))}catch(e){}}(e.cssTexts,t);else if(e.type===yt.SetProperty){gt(r.cssRules,e.index).style.setProperty(e.property,e.value,e.priority)}else if(e.type===yt.RemoveProperty){gt(r.cssRules,e.index).style.removeProperty(e.property)}}))}!function(e){e[e.Insert=0]="Insert",e[e.Remove=1]="Remove",e[e.Snapshot=2]="Snapshot",e[e.SetProperty=3]="SetProperty",e[e.RemoveProperty=4]="RemoveProperty"}(yt||(yt={}));var wt=new Map;function xt(e,t){var r=wt.get(e);return r||(r=new Map,wt.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}var It=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Et(e,t){return function(r){if(r&&"object"==typeof r&&"rr_type"in r){if("index"in r){var n=r.rr_type,i=r.index;return xt(t,n)[i]}if("args"in r){var s=r.rr_type,l=r.args,c=window[s];return new(c.bind.apply(c,a([void 0],o(l.map(Et(e,t))),!1)))}if("base64"in r)return function(e){var t,r,n,o,a,i=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);var c=new ArrayBuffer(i),u=new Uint8Array(c);for(t=0;t>4,u[l++]=(15&n)<<4|o>>2,u[l++]=(3&o)<<6|63&a;return c}(r.base64);if("src"in r){var u=e.get(r.src);if(u)return u;var d=new Image;return d.src=r.src,e.set(r.src,d),d}}else if(Array.isArray(r))return r.map(Et(e,t));return r}}function Tt(e){var t=e.mutation,r=e.target,n=e.type,o=e.imageMap,a=e.errorHandler;try{var i=function(e,t){try{return t===P.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(e){return null}}(r,n);if(!i)return;if(t.setter)return void(i[t.property]=t.args[0]);var s=i[t.property],l=t.args.map(Et(o,i));!function(e,t){if(null==t?void 0:t.constructor){var r=t.constructor.name;if(It.includes(r)){var n=xt(e,r);n.includes(t)||n.push(t)}}}(i,s.apply(i,l))}catch(e){a(t,e)}}var kt=Ke||Ze,Ct="[replayer]",Mt={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Nt(t){return t.type==e.EventType.IncrementalSnapshot&&(t.data.source==e.IncrementalSource.TouchMove||t.data.source==e.IncrementalSource.MouseInteraction&&t.data.type==e.MouseInteractions.TouchStart)}var Rt=function(){function i(t,r){var o=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=kt(),this.legacy_missingNodeRetryMap={},this.cache=H(),this.imageMap=new Map,this.mirror={map:{},getId:function(e){return e&&e.__sn?e.__sn.id:-1},getNode:function(e){return this.map[e]||null},removeNodeFromMap:function(e){var t=this,r=e.__sn&&e.__sn.id;delete this.map[r],e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},has:function(e){return this.map.hasOwnProperty(e)},reset:function(){this.map={}}},this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(null==r?void 0:r.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");var a={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:Mt};this.config=Object.assign({},a,r),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(e.ReplayerEvents.Resize,this.handleResize),this.setupDom(),this.treeIndex=new ie,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.virtualStyleRulesMap=new Map,this.emitter.on(e.ReplayerEvents.Flush,(function(){var e,t,r,a,i,s,l,c,u=o.treeIndex.flush(),d=u.scrollMap,f=u.inputMap,p=u.mutationData;o.fragmentParentMap.forEach((function(e,t){return o.restoreRealParent(t,e)}));try{for(var h=n(p.texts),m=h.next();!m.done;m=h.next()){var v=m.value;o.applyText(v,p)}}catch(t){e={error:t}}finally{try{m&&!m.done&&(t=h.return)&&t.call(h)}finally{if(e)throw e.error}}try{for(var y=n(o.virtualStyleRulesMap.keys()),g=y.next();!g.done;g=y.next()){var S=g.value;o.restoreNodeSheet(S)}}catch(e){r={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(r)throw r.error}}o.fragmentParentMap.clear(),o.elementStateMap.clear(),o.virtualStyleRulesMap.clear();try{for(var b=n(d.values()),w=b.next();!w.done;w=b.next()){v=w.value;o.applyScroll(v,!0)}}catch(e){i={error:e}}finally{try{w&&!w.done&&(s=b.return)&&s.call(b)}finally{if(i)throw i.error}}try{for(var x=n(f.values()),I=x.next();!I.done;I=x.next()){v=I.value;o.applyInput(v)}}catch(e){l={error:e}}finally{try{I&&!I.done&&(c=x.return)&&c.call(x)}finally{if(l)throw l.error}}})),this.emitter.on(e.ReplayerEvents.PlayBack,(function(){o.firstFullSnapshot=null,o.mirror.reset()}));var i=new rt([],(null==r?void 0:r.speed)||a.speed);this.service=vt({events:t.map((function(e){return r&&r.unpackFn?r.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(t){o.emitter.emit(e.ReplayerEvents.StateChange,{player:t})})),this.speedService=mt(pt({id:"speed",context:{normalSpeed:-1,timer:i},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:function(e,t){"payload"in t&&e.timer.setSpeed(t.payload.speed)},recordSpeed:st({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(t){o.emitter.emit(e.ReplayerEvents.StateChange,{speed:t})}));var s=this.service.state.context.events.find((function(t){return t.type===e.EventType.Meta})),l=this.service.state.context.events.find((function(t){return t.type===e.EventType.FullSnapshot}));if(s){var c=s.data,u=c.width,d=c.height;setTimeout((function(){o.emitter.emit(e.ReplayerEvents.Resize,{width:u,height:d})}),0)}l&&setTimeout((function(){o.firstFullSnapshot||(o.firstFullSnapshot=l,o.rebuildFullSnapshot(l),o.iframe.contentWindow.scrollTo(l.data.initialOffset))}),1),this.service.state.context.events.find(Nt)&&this.mouse.classList.add("touch-device")}return Object.defineProperty(i.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),i.prototype.on=function(e,t){return this.emitter.on(e,t),this},i.prototype.off=function(e,t){return this.emitter.off(e,t),this},i.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(r){t.config[r]=e[r]})),this.config.skipInactive||this.backToNormal(),void 0!==e.speed&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),void 0!==e.mouseTail&&(!1===e.mouseTail?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"))},i.prototype.getMetaData=function(){var e=this.service.state.context.events[0],t=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:e.timestamp,endTime:t.timestamp,totalTime:t.timestamp-e.timestamp}},i.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},i.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},i.prototype.getMirror=function(){return this.mirror},i.prototype.play=function(t){var r;void 0===t&&(t=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}}),null===(r=this.iframe.contentDocument)||void 0===r||r.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Start)},i.prototype.pause=function(t){var r;void 0===t&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof t&&(this.play(t),this.service.send({type:"PAUSE"})),null===(r=this.iframe.contentDocument)||void 0===r||r.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Pause)},i.prototype.resume=function(t){void 0===t&&(t=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(e.ReplayerEvents.Resume)},i.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},i.prototype.addEvent=function(e){var t=this,r=this.config.unpackFn?this.config.unpackFn(e):e;Nt(r)&&this.mouse.classList.add("touch-device"),Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:r}})}))},i.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},i.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},i.prototype.resetCache=function(){this.cache=H()},i.prototype.setupDom=function(){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),!1!==this.config.mouseTail&&(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");var e=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&e.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",e.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(et(this.iframe.contentWindow,this.iframe.contentDocument),ae(this.iframe.contentWindow))},i.prototype.handleResize=function(e){var t,r;this.iframe.style.display="inherit";try{for(var o=n([this.mouseTail,this.iframe]),a=o.next();!a.done;a=o.next()){var i=a.value;i&&(i.setAttribute("width",String(e.width)),i.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},i.prototype.applyEventsSynchronously=function(t){var r,o;try{for(var a=n(t),i=a.next();!i.done;i=a.next()){var s=i.value;switch(s.type){case e.EventType.DomContentLoaded:case e.EventType.Load:case e.EventType.Custom:continue;case e.EventType.FullSnapshot:case e.EventType.Meta:case e.EventType.Plugin:break;case e.EventType.IncrementalSnapshot:switch(s.data.source){case e.IncrementalSource.MediaInteraction:continue}}this.getCastFn(s,!0)()}}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null,!0===this.touchActive?this.mouse.classList.add("touch-active"):!1===this.touchActive&&this.mouse.classList.remove("touch-active"),this.touchActive=null},i.prototype.getCastFn=function(t,r){var o,a=this;switch(void 0===r&&(r=!1),t.type){case e.EventType.DomContentLoaded:case e.EventType.Load:break;case e.EventType.Custom:o=function(){a.emitter.emit(e.ReplayerEvents.CustomEvent,t)};break;case e.EventType.Meta:o=function(){return a.emitter.emit(e.ReplayerEvents.Resize,{width:t.data.width,height:t.data.height})};break;case e.EventType.FullSnapshot:o=function(){if(a.firstFullSnapshot){if(a.firstFullSnapshot===t)return void(a.firstFullSnapshot=!0)}else a.firstFullSnapshot=!0;a.rebuildFullSnapshot(t,r),a.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case e.EventType.IncrementalSnapshot:o=function(){var o,i;if(a.applyIncremental(t,r),!r&&(t===a.nextUserInteractionEvent&&(a.nextUserInteractionEvent=null,a.backToNormal()),a.config.skipInactive&&!a.nextUserInteractionEvent)){try{for(var s=n(a.service.state.context.events),l=s.next();!l.done;l=s.next()){var c=l.value;if(!(c.timestamp<=t.timestamp)&&a.isUserInteraction(c)){c.delay-t.delay>1e4*a.speedService.state.context.timer.speed&&(a.nextUserInteractionEvent=c);break}}}catch(e){o={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}if(a.nextUserInteractionEvent){var u=a.nextUserInteractionEvent.delay-t.delay,d={speed:Math.min(Math.round(u/5e3),a.config.maxSpeed)};a.speedService.send({type:"FAST_FORWARD",payload:d}),a.emitter.emit(e.ReplayerEvents.SkipStart,d)}}}}return function(){var i,s;o&&o();try{for(var l=n(a.config.plugins||[]),c=l.next();!c.done;c=l.next()){c.value.handler(t,r,{replayer:a})}}catch(e){i={error:e}}finally{try{c&&!c.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}a.service.send({type:"CAST_EVENT",payload:{event:t}});var u=a.service.state.context.events.length-1;if(t===a.service.state.context.events[u]){var d=function(){u0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(e.ReplayerEvents.LoadStylesheetStart),o=setTimeout((function(){i.matches("playing")&&r.play(r.getCurrentTime()),o=-1,l()}),this.config.loadTimeout))}},i.prototype.hasImageArg=function(e){var t,r;try{for(var o=n(e),a=o.next();!a.done;a=o.next()){var i=a.value;if(i&&"object"==typeof i)if("rr_type"in i&&"args"in i){if(this.hasImageArg(i.args))return!0}else{if("rr_type"in i&&"HTMLImageElement"===i.rr_type)return!0;if(i instanceof Array&&this.hasImageArg(i))return!0}else;}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return!1},i.prototype.getImageArgs=function(e){var t,r,i=[];try{for(var s=n(e),l=s.next();!l.done;l=s.next()){var c=l.value;c&&"object"==typeof c&&("rr_type"in c&&"args"in c?i.push.apply(i,a([],o(this.getImageArgs(c.args)),!1)):"rr_type"in c&&"HTMLImageElement"===c.rr_type?i.push(c.src):c instanceof Array&&i.push.apply(i,a([],o(this.getImageArgs(c)),!1)))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return i},i.prototype.preloadAllImages=function(){var t,r,o=this;this.service.state;var a=function(){o.service.state};this.emitter.on(e.ReplayerEvents.Start,a),this.emitter.on(e.ReplayerEvents.Pause,a);var i=function(t){t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.CanvasMutation&&("commands"in t.data?t.data.commands.forEach((function(e){return o.preloadImages(e,t)})):s.preloadImages(t.data,t))},s=this;try{for(var l=n(this.service.state.context.events),c=l.next();!c.done;c=l.next()){i(c.value)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}},i.prototype.preloadImages=function(e,t){var r=this;if("drawImage"!==e.property||"string"!=typeof e.args[0]||this.imageMap.has(t))this.hasImageArg(e.args)&&this.getImageArgs(e.args).forEach((function(e){var t=new Image;t.src=e,r.imageMap.set(e,t)}));else{var n=document.createElement("canvas"),o=n.getContext("2d"),a=null==o?void 0:o.createImageData(n.width,n.height);null==a||a.data,JSON.parse(e.args[0]),null==o||o.putImageData(a,0,0)}},i.prototype.applyIncremental=function(t,n){var o,a,i=this,s=t.data;switch(s.source){case e.IncrementalSource.Mutation:n&&(s.adds.forEach((function(e){return i.treeIndex.add(e)})),s.texts.forEach((function(e){var t=i.mirror.getNode(e.id),r=null==t?void 0:t.parentNode;r&&i.virtualStyleRulesMap.has(r)&&i.virtualStyleRulesMap.delete(r),i.treeIndex.text(e)})),s.attributes.forEach((function(e){return i.treeIndex.attribute(e)})),s.removes.forEach((function(e){return i.treeIndex.remove(e,i.mirror)})));try{this.applyMutation(s,n)}catch(e){this.warn("Exception in mutation ".concat(e.message||e),s)}break;case e.IncrementalSource.Drag:case e.IncrementalSource.TouchMove:case e.IncrementalSource.MouseMove:if(n){var l=s.positions[s.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:s}}else s.positions.forEach((function(e){var r={doAction:function(){i.moveAndHover(e.x,e.y,e.id,n,s)},delay:e.timeOffset+t.timestamp-i.service.state.context.baselineTime};i.timer.addAction(r)})),this.timer.addAction({doAction:function(){},delay:t.delay-(null===(o=s.positions[0])||void 0===o?void 0:o.timeOffset)});break;case e.IncrementalSource.MouseInteraction:if(-1===s.id)break;var c=new Event(e.MouseInteractions[s.type].toLowerCase());if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);this.emitter.emit(e.ReplayerEvents.MouseInteraction,{type:s.type,target:b});var u=this.config.triggerFocus;switch(s.type){case e.MouseInteractions.Blur:"blur"in b&&b.blur();break;case e.MouseInteractions.Focus:u&&b.focus&&b.focus({preventScroll:!0});break;case e.MouseInteractions.Click:case e.MouseInteractions.TouchStart:case e.MouseInteractions.TouchEnd:n?(s.type===e.MouseInteractions.TouchStart?this.touchActive=!0:s.type===e.MouseInteractions.TouchEnd&&(this.touchActive=!1),this.mousePos={x:s.x,y:s.y,id:s.id,debugData:s}):(s.type===e.MouseInteractions.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(s.x,s.y,s.id,n,s),s.type===e.MouseInteractions.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):s.type===e.MouseInteractions.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):s.type===e.MouseInteractions.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case e.MouseInteractions.TouchCancel:n?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:b.dispatchEvent(c)}break;case e.IncrementalSource.Scroll:if(-1===s.id)break;if(n){this.treeIndex.scroll(s);break}this.applyScroll(s,!1);break;case e.IncrementalSource.ViewportResize:this.emitter.emit(e.ReplayerEvents.Resize,{width:s.width,height:s.height});break;case e.IncrementalSource.Input:if(-1===s.id)break;if(n){this.treeIndex.input(s);break}this.applyInput(s);break;case e.IncrementalSource.MediaInteraction:if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);var d=b;try{s.currentTime&&(d.currentTime=s.currentTime),s.volume&&(d.volume=s.volume),s.muted&&(d.muted=s.muted),1===s.type&&d.pause(),0===s.type&&d.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: ".concat(e.message||e))}break;case e.IncrementalSource.StyleSheetRule:if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);var f,p=b,h=b.parentNode,m=this.fragmentParentMap.has(h),v=m?null:p.sheet;v||(this.virtualStyleRulesMap.has(b)?f=this.virtualStyleRulesMap.get(b):(f=[],this.virtualStyleRulesMap.set(b,f))),s.adds&&s.adds.forEach((function(e){var t=e.rule,r=e.index;if(v)try{if(Array.isArray(r)){var n=St(r),o=n.positions,a=n.index;gt(v.cssRules,o).insertRule(t,a)}else{a=void 0===r?void 0:Math.min(r,v.cssRules.length);v.insertRule(t,a)}}catch(e){}else null==f||f.push({cssText:t,index:r,type:yt.Insert})})),s.removes&&s.removes.forEach((function(e){var t=e.index;if(m)null==f||f.push({index:t,type:yt.Remove});else try{if(Array.isArray(t)){var r=St(t),n=r.positions,o=r.index;gt(v.cssRules,n).deleteRule(o||0)}else null==v||v.deleteRule(t)}catch(e){}}));break;case e.IncrementalSource.StyleDeclaration:if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);p=b;var y=b.parentNode,g=this.fragmentParentMap.has(y)?null:p.sheet,S=[];if(g||(this.virtualStyleRulesMap.has(b)?S=this.virtualStyleRulesMap.get(b):(S=[],this.virtualStyleRulesMap.set(b,S))),s.set)if(g)gt(g.rules,s.index).style.setProperty(s.set.property,s.set.value,s.set.priority);else S.push(r({type:yt.SetProperty,index:s.index},s.set));if(s.remove)if(g)gt(g.rules,s.index).style.removeProperty(s.remove.property);else S.push(r({type:yt.RemoveProperty,index:s.index},s.remove));break;case e.IncrementalSource.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var b;if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);!function(e){var t=e.event,r=e.mutation,n=e.target,o=e.imageMap,a=e.errorHandler;try{var i="commands"in r?r.commands:[r];[P.WebGL,P.WebGL2].includes(r.type)?i.forEach((function(e){Tt({mutation:e,type:r.type,target:n,imageMap:o,errorHandler:a})})):i.forEach((function(e){!function(e){var t=e.event,r=e.mutation,n=e.target,o=e.imageMap,a=e.errorHandler;try{var i=n.getContext("2d");if(r.setter)return void(i[r.property]=r.args[0]);var s=i[r.property];if("drawImage"===r.property&&"string"==typeof r.args[0]){var l=o.get(t);r.args[0]=l,s.apply(i,r.args)}else s.apply(i,r.args)}catch(e){a(r,e)}}({event:t,mutation:e,target:n,imageMap:o,errorHandler:a})}))}catch(e){a(r,e)}}({event:t,mutation:s,target:b,imageMap:this.imageMap,errorHandler:this.warnCanvasMutationFailed.bind(this)});break;case e.IncrementalSource.Font:try{var w=new FontFace(s.family,s.buffer?new Uint8Array(JSON.parse(s.fontSource)):s.fontSource,s.descriptors);null===(a=this.iframe.contentDocument)||void 0===a||a.fonts.add(w)}catch(e){this.config.showWarning&&console.warn(e)}}},i.prototype.applyMutation=function(e,o){var a,i,s=this;e.removes.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.parentId})))return;return s.warnNodeNotFound(e,t.id)}s.virtualStyleRulesMap.has(r)&&s.virtualStyleRulesMap.delete(r);var n=s.mirror.getNode(t.parentId);if(!n)return s.warnNodeNotFound(e,t.parentId);if(t.isShadow&&de(n)&&(n=n.shadowRoot),s.mirror.removeNodeFromMap(r),n){var o=null,a="__sn"in n?s.fragmentParentMap.get(n):void 0;a&&a.contains(r)?n=a:s.fragmentParentMap.has(r)&&(o=s.fragmentParentMap.get(r),s.fragmentParentMap.delete(r),r=o);try{n.removeChild(r)}catch(t){if(!(t instanceof DOMException))throw t;s.warn("parent could not remove child in mutation",n,a,r,o,e)}}}));var l=r({},this.legacy_missingNodeRetryMap),c=[],u=function(e){var r,a,i,u;if(!s.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var d=s.mirror.getNode(e.parentId);if(!d)return e.node.type===t.Document?s.newDocumentQueue.push(e):c.push(e);var f=null;s.iframe.contentDocument.contains?f=s.iframe.contentDocument.contains(d):s.iframe.contentDocument.body.contains&&(f=s.iframe.contentDocument.body.contains(d));var p=(null===(u=(i=d).getElementsByTagName)||void 0===u?void 0:u.call(i,"iframe").length)>0;if(o&&f&&!ce(d)&&!p){var h=document.createDocumentFragment();for(s.mirror.map[e.parentId]=h,s.fragmentParentMap.set(h,d),s.storeState(d);d.firstChild;)h.appendChild(d.firstChild);d=h}e.node.isShadow&&(de(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);var m=null,v=null;if(e.previousId&&(m=s.mirror.getNode(e.previousId)),e.nextId&&(v=s.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=s.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return c.push(e);if(!e.node.rootId||s.mirror.getNode(e.node.rootId)){var y=e.node.rootId?s.mirror.getNode(e.node.rootId):s.iframe.contentDocument;if(ce(d))s.attachDocumentToIframe(e,d);else{var g=G(e.node,{doc:y,map:s.mirror.map,skipChild:!0,hackCss:!0,cache:s.cache});if(-1!==e.previousId&&-1!==e.nextId){if("__sn"in d&&d.__sn.type===t.Element&&"textarea"===d.__sn.tagName&&e.node.type===t.Text)try{for(var S=n(Array.from(d.childNodes)),b=S.next();!b.done;b=S.next()){var w=b.value;w.nodeType===d.TEXT_NODE&&d.removeChild(w)}}catch(e){r={error:e}}finally{try{b&&!b.done&&(a=S.return)&&a.call(S)}finally{if(r)throw r.error}}if(m&&m.nextSibling&&m.nextSibling.parentNode)d.insertBefore(g,m.nextSibling);else if(v&&v.parentNode)d.contains(v)?d.insertBefore(g,v):d.insertBefore(g,null);else{if(d===y)for(;y.firstChild;)y.removeChild(y.firstChild);d.appendChild(g)}if(ce(g)){var x=s.newDocumentQueue.find((function(e){return e.parentId===g.__sn.id}));x&&(s.attachDocumentToIframe(x,g),s.newDocumentQueue=s.newDocumentQueue.filter((function(e){return e!==x})))}(e.previousId||e.nextId)&&s.legacy_resolveMissingNode(l,d,g,e)}else l[e.node.id]={node:g,mutation:e}}}};e.adds.forEach((function(e){u(e)}));for(var d=Date.now();c.length;){var f=se(c);if(c.length=0,Date.now()-d>500){this.warn("Timeout in the loop, please check the resolve tree data:",f);break}try{for(var p=(a=void 0,n(f)),h=p.next();!h.done;h=p.next()){var m=h.value;this.mirror.getNode(m.value.parentId)?le(m,(function(e){u(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",m)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}}Object.keys(l).length&&Object.assign(this.legacy_missingNodeRetryMap,l),e.texts.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.id})))return;return s.warnNodeNotFound(e,t.id)}s.fragmentParentMap.has(r)&&(r=s.fragmentParentMap.get(r)),r.textContent=t.value})),e.attributes.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.id})))return;return s.warnNodeNotFound(e,t.id)}for(var n in s.fragmentParentMap.has(r)&&(r=s.fragmentParentMap.get(r)),t.attributes)if("string"==typeof n){var o=t.attributes[n];if(null===o)r.removeAttribute(n);else if("string"==typeof o)try{r.setAttribute(n,o)}catch(e){s.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}else if("style"===n){var a=o,i=r;for(var l in a)if(!1===a[l])i.style.removeProperty(l);else if(a[l]instanceof Array){var c=a[l];i.style.setProperty(l,c[0],c[1])}else{var u=a[l];i.style.setProperty(l,u)}}}}))},i.prototype.applyScroll=function(e,r){var n=this.mirror.getNode(e.id);if(!n)return this.debugNodeNotFound(e,e.id);if(n===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:r?"auto":"smooth"});else if(n.__sn.type===t.Document)n.defaultView.scrollTo({top:e.y,left:e.x,behavior:r?"auto":"smooth"});else try{n.scrollTop=e.y,n.scrollLeft=e.x}catch(e){}},i.prototype.applyInput=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);try{t.checked=e.isChecked,t.value=e.text}catch(e){}},i.prototype.applyText=function(e,t){var r=this.mirror.getNode(e.id);if(!r)return this.debugNodeNotFound(t,e.id);try{r.textContent=e.value}catch(e){}},i.prototype.legacy_resolveMissingNode=function(e,t,r,n){var o=n.previousId,a=n.nextId,i=o&&e[o],s=a&&e[a];if(i){var l=i,c=l.node,u=l.mutation;t.insertBefore(c,r),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}if(s){var d=s;c=d.node,u=d.mutation;t.insertBefore(c,r.nextSibling),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}},i.prototype.moveAndHover=function(e,t,r,n,o){var a=this.mirror.getNode(r);if(!a)return this.debugNodeNotFound(o,r);var i=ue(a,this.iframe),s=e*i.absoluteScale+i.x,l=t*i.absoluteScale+i.y;this.mouse.style.left="".concat(s,"px"),this.mouse.style.top="".concat(l,"px"),n||this.drawMouseTail({x:s,y:l}),this.hoverElements(a)},i.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var r=!0===this.config.mouseTail?Mt:Object.assign({},Mt,this.config.mouseTail),n=r.lineCap,o=r.lineWidth,a=r.strokeStyle,i=r.duration,s=function(){if(t.mouseTail){var e=t.mouseTail.getContext("2d");e&&t.tailPositions.length&&(e.clearRect(0,0,t.mouseTail.width,t.mouseTail.height),e.beginPath(),e.lineWidth=o,e.lineCap=n,e.strokeStyle=a,e.moveTo(t.tailPositions[0].x,t.tailPositions[0].y),t.tailPositions.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}};this.tailPositions.push(e),s(),setTimeout((function(){t.tailPositions=t.tailPositions.filter((function(t){return t!==e})),s()}),i/this.speedService.state.context.timer.speed)}},i.prototype.hoverElements=function(e){var t;null===(t=this.iframe.contentDocument)||void 0===t||t.querySelectorAll(".\\:hover").forEach((function(e){e.classList.remove(":hover")}));for(var r=e;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement},i.prototype.isUserInteraction=function(t){return t.type===e.EventType.IncrementalSnapshot&&(t.data.source>e.IncrementalSource.Mutation&&t.data.source<=e.IncrementalSource.Input)},i.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(e.ReplayerEvents.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},i.prototype.restoreRealParent=function(e,r){this.mirror.map[r.__sn.id]=r,r.__sn.type===t.Element&&"textarea"===r.__sn.tagName&&e.textContent&&(r.value=e.textContent),r.appendChild(e),this.restoreState(r)},i.prototype.storeState=function(e){var t,r;if(e&&e.nodeType===e.ELEMENT_NODE){var o=e;(o.scrollLeft||o.scrollTop)&&this.elementStateMap.set(e,{scroll:[o.scrollLeft,o.scrollTop]}),"STYLE"===o.tagName&&function(e,t){var r;try{var n=Array.from((null===(r=e.sheet)||void 0===r?void 0:r.cssRules)||[]).map((function(e){return e.cssText}));t.set(e,[{type:yt.Snapshot,cssTexts:n}])}catch(e){}}(o,this.virtualStyleRulesMap);var a=o.children;try{for(var i=n(Array.from(a)),s=i.next();!s.done;s=i.next()){var l=s.value;this.storeState(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}},i.prototype.restoreState=function(e){var t,r;if(e.nodeType===e.ELEMENT_NODE){var o=e;if(this.elementStateMap.has(e)){var a=this.elementStateMap.get(e);a.scroll&&(o.scrollLeft=a.scroll[0],o.scrollTop=a.scroll[1]),this.elementStateMap.delete(e)}var i=o.children;try{for(var s=n(Array.from(i)),l=s.next();!l.done;l=s.next()){var c=l.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}},i.prototype.restoreNodeSheet=function(e){var t=this.virtualStyleRulesMap.get(e);"STYLE"===e.nodeName&&(t&&bt(t,e))},i.prototype.warnNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.warn("Node with id '".concat(t,"' was previously removed. "),e):this.warn("Node with id '".concat(t,"' not found. "),e)},i.prototype.warnCanvasMutationFailed=function(e,t){this.warn("Has error on canvas update",t,"canvas mutation:",e)},i.prototype.debugNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.debug(Ct,"Node with id '".concat(t,"' was previously removed. "),e):this.debug(Ct,"Node with id '".concat(t,"' not found. "),e)},i.prototype.warn=function(){for(var e=[],t=0;t>>1|(21845&Xt)<<1;qt=(61680&(qt=(52428&qt)>>>2|(13107&qt)<<2))>>>4|(3855&qt)<<4,Yt[Xt]=((65280&qt)>>>8|(255&qt)<<8)>>>1}var Qt=function(e,t,r){for(var n=e.length,o=0,a=new At(t);o>>l]=c}else for(i=new At(n),o=0;o>>15-e[o];return i},$t=new Lt(288);for(Xt=0;Xt<144;++Xt)$t[Xt]=8;for(Xt=144;Xt<256;++Xt)$t[Xt]=9;for(Xt=256;Xt<280;++Xt)$t[Xt]=7;for(Xt=280;Xt<288;++Xt)$t[Xt]=8;var Jt=new Lt(32);for(Xt=0;Xt<32;++Xt)Jt[Xt]=5;var Kt=Qt($t,9,0),Zt=Qt($t,9,1),er=Qt(Jt,5,0),tr=Qt(Jt,5,1),rr=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},nr=function(e,t,r){var n=t/8>>0;return(e[n]|e[n+1]<<8)>>>(7&t)&r},or=function(e,t){var r=t/8>>0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>>(7&t)},ar=function(e){return(e/8>>0)+(7&e&&1)},ir=function(e,t,r){(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length);var n=new(e instanceof At?At:e instanceof Dt?Dt:Lt)(r-t);return n.set(e.subarray(t,r)),n},sr=function(e,t,r){r<<=7&t;var n=t/8>>0;e[n]|=r,e[n+1]|=r>>>8},lr=function(e,t,r){r<<=7&t;var n=t/8>>0;e[n]|=r,e[n+1]|=r>>>8,e[n+2]|=r>>>16},cr=function(e,t){for(var r=[],n=0;nf&&(f=a[n].s);var p=new At(f+1),h=ur(r[u-1],p,0);if(h>t){n=0;var m=0,v=h-t,y=1<t))break;m+=y-(1<>>=v;m>0;){var S=a[n].s;p[S]=0&&m;--n){var b=a[n].s;p[b]==t&&(--p[b],++m)}h=t}return[new Lt(p),h]},ur=function(e,t,r){return-1==e.s?Math.max(ur(e.l,t,r+1),ur(e.r,t,r+1)):t[e.s]=r},dr=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new At(++t),n=0,o=e[0],a=1,i=function(e){r[n++]=e},s=1;s<=t;++s)if(e[s]==o&&s!=t)++a;else{if(!o&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(o),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(o);a=1,o=e[s]}return[r.subarray(0,n),t]},fr=function(e,t){for(var r=0,n=0;n>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var a=0;a4&&!k[Wt[M-1]];--M);var N,R,_,O,L=c+5<<3,A=fr(o,$t)+fr(a,Jt)+i,D=fr(o,f)+fr(a,m)+i+14+3*M+fr(I,k)+(2*I[16]+3*I[17]+7*I[18]);if(L<=A&&L<=D)return pr(t,u,e.subarray(l,l+c));if(sr(t,u,1+(D15&&(sr(t,u,j[E]>>>5&127),u+=j[E]>>>12)}}}else N=Kt,R=$t,_=er,O=Jt;for(E=0;E255){U=n[E]>>>18&31;lr(t,u,N[U+257]),u+=R[U+257],U>7&&(sr(t,u,n[E]>>>23&31),u+=Ft[U]);var z=31&n[E];lr(t,u,_[z]),u+=O[z],z>3&&(lr(t,u,n[E]>>>5&8191),u+=Pt[z])}else lr(t,u,N[n[E]]),u+=R[n[E]];return lr(t,u,N[256]),u+R[256]},mr=new Dt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),vr=new Lt(0),yr=function(e,t,r,n,o){return function(e,t,r,n,o,a){var i=e.length,s=new Lt(n+i+5*(1+Math.floor(i/7e3))+o),l=s.subarray(n,s.length-o),c=0;if(!t||i<8)for(var u=0;u<=i;u+=65535){var d=u+65535;d>>13,h=8191&f,m=(1<7e3||k>24576)&&O>423){c=hr(e,l,0,w,x,I,T,k,M,u-M,c),k=E=T=0,M=u;for(var L=0;L<286;++L)x[L]=0;for(L=0;L<30;++L)I[L]=0}var A=2,D=0,F=h,P=R-_&32767;if(O>2&&N==b(u-P))for(var W=Math.min(p,O)-1,j=Math.min(32767,u),U=Math.min(258,O);P<=j&&--F&&R!=_;){if(e[u+A]==e[u+A-P]){for(var z=0;zA){if(A=z,D=P,z>W)break;var B=Math.min(P,z-2),H=0;for(L=0;LH&&(H=G,_=V)}}}P+=(R=_)-(_=v[R])+32768&32767}if(D){w[k++]=268435456|Bt[A]<<18|Gt[D];var Y=31&Bt[A],X=31&Gt[D];T+=Ft[Y]+Pt[X],++x[257+Y],++I[X],C=u+A,++E}else w[k++]=e[u],++x[e[u]]}}c=hr(e,l,a,w,x,I,T,k,M,u-M,c),a||(c=pr(l,c,vr))}return ir(s,0,n+ar(c)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,r,n,!o)};function gr(e,t){void 0===t&&(t={});var r=function(){var e=1,t=0;return{p:function(r){for(var n=e,o=t,a=r.length,i=0;i!=a;){for(var s=Math.min(i+5552,a);i>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();r.p(e);var n=yr(e,t,2,4);return function(e,t){var r=t.level,n=0==r?0:r<6?1:9==r?3:2;e[0]=120,e[1]=n<<6|(n?32-2*n:1)}(n,t),function(e,t,r){for(;r;++t)e[t]=r,r>>>=8}(n,n.length-4,r.d()),n}function Sr(e,t){return function(e,t,r){var n=e.length,o=!t||r,a=!r||r.i;r||(r={}),t||(t=new Lt(3*n));var i=function(e){var r=t.length;if(e>r){var n=new Lt(Math.max(2*r,e));n.set(t),t=n}},s=r.f||0,l=r.p||0,c=r.b||0,u=r.l,d=r.d,f=r.m,p=r.n,h=8*n;do{if(!u){r.f=s=nr(e,l,1);var m=nr(e,l+1,3);if(l+=3,!m){var v=e[(C=ar(l)+4)-4]|e[C-3]<<8,y=C+v;if(y>n){if(a)throw"unexpected EOF";break}o&&i(c+v),t.set(e.subarray(C,y),c),r.b=c+=v,r.p=l=8*y;continue}if(1==m)u=Zt,d=tr,f=9,p=5;else{if(2!=m)throw"invalid block type";var g=nr(e,l,31)+257,S=nr(e,l+10,15)+4,b=g+nr(e,l+5,31)+1;l+=14;for(var w=new Lt(b),x=new Lt(19),I=0;Ih)break;var k=Qt(x,E,1);for(I=0;I>>4)<16)w[I++]=C;else{var N=0,R=0;for(16==C?(R=3+nr(e,l,3),l+=2,N=w[I-1]):17==C?(R=3+nr(e,l,7),l+=3):18==C&&(R=11+nr(e,l,127),l+=7);R--;)w[I++]=N}}var _=w.subarray(0,g),O=w.subarray(g);f=rr(_),p=rr(O),u=Qt(_,f,1),d=Qt(O,p,1)}if(l>h)throw"unexpected EOF"}o&&i(c+131072);for(var L=(1<>>4;if((l+=15&N)>h)throw"unexpected EOF";if(!N)throw"invalid length/literal";if(F<256)t[c++]=F;else{if(256==F){u=null;break}var P=F-254;if(F>264){var W=Ft[I=F-257];P=nr(e,l,(1<>>4;if(!j)throw"invalid distance";if(l+=15&j,O=Vt[U],U>3&&(W=Pt[U],O+=or(e,l)&(1<h)throw"unexpected EOF";o&&i(c+131072);for(var z=c+P;c>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}function br(e,t){var r=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var n=new Lt(e.length+(e.length>>>1)),o=0,a=function(e){n[o++]=e},i=0;in.length){var s=new Lt(o+8+(r-i<<1));s.set(n),n=s}var l=e.charCodeAt(i);l<128||t?a(l):l<2048?(a(192|l>>>6),a(128|63&l)):l>55295&&l<57344?(a(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++i))>>>18),a(128|l>>>12&63),a(128|l>>>6&63),a(128|63&l)):(a(224|l>>>12),a(128|l>>>6&63),a(128|63&l))}return ir(n,0,o)}function wr(e,t){var r="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var n=0;n>10,56320|1023&o))}return r}var xr="v1",Ir=function(){function e(e){this.fileName=e.fileName||"",this.functionName=e.functionName||"",this.lineNumber=e.lineNumber,this.columnNumber=e.columnNumber}return e.prototype.toString=function(){var e=this.lineNumber||"",t=this.columnNumber||"";return this.functionName?this.functionName+" ("+this.fileName+":"+e+":"+t+")":this.fileName+":"+e+":"+t},e}(),Er=/(^|@)\S+:\d+/,Tr=/^\s*at .*(\S+:\d+|\(native\))/m,kr=/^(eval@)?(\[native code])?$/,Cr={parse:function(e){if(!e)return[];if(void 0!==e.stacktrace||void 0!==e["opera#sourceloc"])return this.parseOpera(e);if(e.stack&&e.stack.match(Tr))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(-1===e.indexOf(":"))return[e];var t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!t)throw new Error("Cannot parse given url: ".concat(e));return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE:function(e){return e.stack.split("\n").filter((function(e){return!!e.match(Tr)}),this).map((function(e){e.indexOf("(eval ")>-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));var t=e.replace(/^\s+/,"").replace(/\(eval code/g,"("),r=t.match(/ (\((.+):(\d+):(\d+)\)$)/),n=(t=r?t.replace(r[0],""):t).split(/\s+/).slice(1),o=this.extractLocation(r?r[1]:n.pop()),a=n.join(" ")||void 0,i=["eval",""].indexOf(o[0])>-1?void 0:o[0];return new Ir({functionName:a,fileName:i,lineNumber:o[1],columnNumber:o[2]})}),this)},parseFFOrSafari:function(e){return e.stack.split("\n").filter((function(e){return!e.match(kr)}),this).map((function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new Ir({functionName:e});var t=/((.*".+"[^@]*)?[^@]*)(?:@)/,r=e.match(t),n=r&&r[1]?r[1]:void 0,o=this.extractLocation(e.replace(t,""));return new Ir({functionName:n,fileName:o[0],lineNumber:o[1],columnNumber:o[2]})}),this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){for(var t=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split("\n"),n=[],o=2,a=r.length;o/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new Ir({functionName:n,fileName:r[0],lineNumber:r[1],columnNumber:r[2]})}),this)}};function Mr(e){if(!e||!e.outerHTML)return"";for(var t="";e.parentElement;){var r=e.localName;if(!r)break;r=r.toLowerCase();var n=e.parentElement,o=[];if(n.children&&n.children.length>0)for(var a=0;a1&&(r+=":eq("+o.indexOf(e)+")"),t=r+(t?">"+t:""),e=n}return t}function Nr(e){return"[object Object]"===Object.prototype.toString.call(e)}function Rr(e,t){var r,o;if(0===t)return!0;var a=Object.keys(e);try{for(var i=n(a),s=i.next();!s.done;s=i.next()){var l=s.value;if(Nr(e[l])&&Rr(e[l],t-1))return!0}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}return!1}function _r(e,t){var r={numOfKeysLimit:50,depthOfLimit:4};Object.assign(r,t);var n=[],o=[];return JSON.stringify(e,(function(e,t){if(n.length>0){var a=n.indexOf(this);~a?n.splice(a+1):n.push(this),~a?o.splice(a,1/0,e):o.push(e),~n.indexOf(t)&&(t=n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]")}else n.push(t);if(null==t)return t;if(function(e){if(Nr(e)&&Object.keys(e).length>r.numOfKeysLimit)return!0;if("function"==typeof e)return!0;if(Nr(e)&&Rr(e,r.depthOfLimit))return!0;return!1}(t))return function(e){var t=e.toString();r.stringLengthLimit&&t.length>r.stringLengthLimit&&(t="".concat(t.slice(0,r.stringLengthLimit),"..."));return t}(t);if(t instanceof Event){var i={};for(var s in t){var l=t[s];Array.isArray(l)?i[s]=Mr(l.length?l[0]:null):i[s]=l}return i}return t instanceof Node?t instanceof HTMLElement?t?t.outerHTML:"":t.nodeName:t instanceof Error?t.stack?t.stack+"\nEnd of stack for Error object":t.name+": "+t.message:t}))}var Or={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function Lr(e,t,r){var i,s,l,c=r.logger;if(!c)return function(){};l="string"==typeof c?t[c]:c;var u=0,d=[];if(r.level.includes("error")&&window){var f=function(t){var n=t.message,o=t.error,a=Cr.parse(o).map((function(e){return e.toString()})),i=[_r(n,r.stringifyOptions)];e({level:"error",trace:a,payload:i})};window.addEventListener("error",f),d.push((function(){window&&window.removeEventListener("error",f)}))}try{for(var p=n(r.level),h=p.next();!h.done;h=p.next()){var m=h.value;d.push(v(l,m))}}catch(e){i={error:e}}finally{try{h&&!h.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}return function(){d.forEach((function(e){return e()}))};function v(t,n){var i=this;return t[n]?K(t,n,(function(t){return function(){for(var s=[],l=0;l= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type]) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector) {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n ignoreClass?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n ignoreClass: string;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","import {\n INode,\n serializeNodeWithId,\n transformAttribute,\n IGNORED_NODE,\n isShadowRoot,\n needMaskingText,\n maskInputValue,\n} from 'rrweb-snapshot';\nimport {\n mutationRecord,\n textCursor,\n attributeCursor,\n removedNodeMutation,\n addedNodeMutation,\n Mirror,\n styleAttributeValue,\n observerParam,\n MutationBufferParam,\n Optional,\n} from '../types';\nimport {\n isBlocked,\n isAncestorRemoved,\n isIgnored,\n isIframeINode,\n hasShadowRoot,\n} from '../utils';\n\ntype DoubleLinkedListNode = {\n previous: DoubleLinkedListNode | null;\n next: DoubleLinkedListNode | null;\n value: NodeInLinkedList;\n};\ntype NodeInLinkedList = Node & {\n __ln: DoubleLinkedListNode;\n};\n\nfunction isNodeInLinkedList(n: Node | NodeInLinkedList): n is NodeInLinkedList {\n return '__ln' in n;\n}\nclass DoubleLinkedList {\n public length = 0;\n public head: DoubleLinkedListNode | null = null;\n\n public get(position: number) {\n if (position >= this.length) {\n throw new Error('Position outside of list range');\n }\n\n let current = this.head;\n for (let index = 0; index < position; index++) {\n current = current?.next || null;\n }\n return current;\n }\n\n public addNode(n: Node) {\n const node: DoubleLinkedListNode = {\n value: n as NodeInLinkedList,\n previous: null,\n next: null,\n };\n (n as NodeInLinkedList).__ln = node;\n if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {\n const current = n.previousSibling.__ln.next;\n node.next = current;\n node.previous = n.previousSibling.__ln;\n n.previousSibling.__ln.next = node;\n if (current) {\n current.previous = node;\n }\n } else if (\n n.nextSibling &&\n isNodeInLinkedList(n.nextSibling) &&\n n.nextSibling.__ln.previous\n ) {\n const current = n.nextSibling.__ln.previous;\n node.previous = current;\n node.next = n.nextSibling.__ln;\n n.nextSibling.__ln.previous = node;\n if (current) {\n current.next = node;\n }\n } else {\n if (this.head) {\n this.head.previous = node;\n }\n node.next = this.head;\n this.head = node;\n }\n this.length++;\n }\n\n public removeNode(n: NodeInLinkedList) {\n const current = n.__ln;\n if (!this.head) {\n return;\n }\n\n if (!current.previous) {\n this.head = current.next;\n if (this.head) {\n this.head.previous = null;\n }\n } else {\n current.previous.next = current.next;\n if (current.next) {\n current.next.previous = current.previous;\n }\n }\n if (n.__ln) {\n delete (n as Optional).__ln;\n }\n this.length--;\n }\n}\n\nconst moveKey = (id: number, parentId: number) => `${id}@${parentId}`;\nfunction isINode(n: Node | INode): n is INode {\n return '__sn' in n;\n}\n\n/**\n * controls behaviour of a MutationObserver\n */\nexport default class MutationBuffer {\n private frozen: boolean = false;\n private locked: boolean = false;\n\n private texts: textCursor[] = [];\n private attributes: attributeCursor[] = [];\n private removes: removedNodeMutation[] = [];\n private mapRemoves: Node[] = [];\n\n private movedMap: Record = {};\n\n /**\n * the browser MutationObserver emits multiple mutations after\n * a delay for performance reasons, making tracing added nodes hard\n * in our `processMutations` callback function.\n * For example, if we append an element el_1 into body, and then append\n * another element el_2 into el_1, these two mutations may be passed to the\n * callback function together when the two operations were done.\n * Generally we need to trace child nodes of newly added nodes, but in this\n * case if we count el_2 as el_1's child node in the first mutation record,\n * then we will count el_2 again in the second mutation record which was\n * duplicated.\n * To avoid of duplicate counting added nodes, we use a Set to store\n * added nodes and its child nodes during iterate mutation records. Then\n * collect added nodes from the Set which have no duplicate copy. But\n * this also causes newly added nodes will not be serialized with id ASAP,\n * which means all the id related calculation should be lazy too.\n */\n private addedSet = new Set();\n private movedSet = new Set();\n private droppedSet = new Set();\n\n private mutationCb: observerParam['mutationCb'];\n private blockClass: observerParam['blockClass'];\n private blockSelector: observerParam['blockSelector'];\n private maskTextClass: observerParam['maskTextClass'];\n private maskTextSelector: observerParam['maskTextSelector'];\n private inlineStylesheet: observerParam['inlineStylesheet'];\n private maskInputOptions: observerParam['maskInputOptions'];\n private maskTextFn: observerParam['maskTextFn'];\n private maskInputFn: observerParam['maskInputFn'];\n private recordCanvas: observerParam['recordCanvas'];\n private inlineImages: observerParam['inlineImages'];\n private slimDOMOptions: observerParam['slimDOMOptions'];\n private doc: observerParam['doc'];\n private mirror: observerParam['mirror'];\n private iframeManager: observerParam['iframeManager'];\n private shadowDomManager: observerParam['shadowDomManager'];\n private canvasManager: observerParam['canvasManager'];\n\n public init(options: MutationBufferParam) {\n ([\n 'mutationCb',\n 'blockClass',\n 'blockSelector',\n 'maskTextClass',\n 'maskTextSelector',\n 'inlineStylesheet',\n 'maskInputOptions',\n 'maskTextFn',\n 'maskInputFn',\n 'recordCanvas',\n 'inlineImages',\n 'slimDOMOptions',\n 'doc',\n 'mirror',\n 'iframeManager',\n 'shadowDomManager',\n 'canvasManager',\n ] as const).forEach((key) => {\n // just a type trick, the runtime result is correct\n this[key] = options[key] as never;\n });\n }\n\n public freeze() {\n this.frozen = true;\n this.canvasManager.freeze();\n }\n\n public unfreeze() {\n this.frozen = false;\n this.canvasManager.unfreeze();\n this.emit();\n }\n\n public isFrozen() {\n return this.frozen;\n }\n\n public lock() {\n this.locked = true;\n this.canvasManager.lock();\n }\n\n public unlock() {\n this.locked = false;\n this.canvasManager.unlock();\n this.emit();\n }\n\n public reset() {\n this.shadowDomManager.reset();\n this.canvasManager.reset();\n }\n\n public processMutations = (mutations: mutationRecord[]) => {\n mutations.forEach(this.processMutation); // adds mutations to the buffer\n this.emit(); // clears buffer if not locked/frozen\n };\n\n public emit = () => {\n if (this.frozen || this.locked) {\n return;\n }\n\n // delay any modification of the mirror until this function\n // so that the mirror for takeFullSnapshot doesn't get mutated while it's event is being processed\n\n const adds: addedNodeMutation[] = [];\n\n /**\n * Sometimes child node may be pushed before its newly added\n * parent, so we init a queue to store these nodes.\n */\n const addList = new DoubleLinkedList();\n const getNextId = (n: Node): number | null => {\n let ns: Node | null = n;\n let nextId: number | null = IGNORED_NODE; // slimDOM: ignored\n while (nextId === IGNORED_NODE) {\n ns = ns && ns.nextSibling;\n nextId = ns && this.mirror.getId((ns as unknown) as INode);\n }\n return nextId;\n };\n const pushAdd = (n: Node) => {\n const shadowHost: Element | null = n.getRootNode\n ? (n.getRootNode() as ShadowRoot)?.host\n : null;\n // If n is in a nested shadow dom.\n let rootShadowHost = shadowHost;\n while ((rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host)\n rootShadowHost =\n (rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host ||\n null;\n // ensure shadowHost is a Node, or doc.contains will throw an error\n const notInDoc =\n !this.doc.contains(n) &&\n (rootShadowHost === null || !this.doc.contains(rootShadowHost));\n if (!n.parentNode || notInDoc) {\n return;\n }\n const parentId = isShadowRoot(n.parentNode)\n ? this.mirror.getId((shadowHost as unknown) as INode)\n : this.mirror.getId((n.parentNode as Node) as INode);\n const nextId = getNextId(n);\n if (parentId === -1 || nextId === -1) {\n return addList.addNode(n);\n }\n let sn = serializeNodeWithId(n, {\n doc: this.doc,\n map: this.mirror.map,\n blockClass: this.blockClass,\n blockSelector: this.blockSelector,\n maskTextClass: this.maskTextClass,\n maskTextSelector: this.maskTextSelector,\n skipChild: true,\n inlineStylesheet: this.inlineStylesheet,\n maskInputOptions: this.maskInputOptions,\n maskTextFn: this.maskTextFn,\n maskInputFn: this.maskInputFn,\n slimDOMOptions: this.slimDOMOptions,\n recordCanvas: this.recordCanvas,\n inlineImages: this.inlineImages,\n onSerialize: (currentN) => {\n if (isIframeINode(currentN)) {\n this.iframeManager.addIframe(currentN);\n }\n if (hasShadowRoot(n)) {\n this.shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n this.iframeManager.attachIframe(iframe, childSn);\n this.shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n });\n if (sn) {\n adds.push({\n parentId,\n nextId,\n node: sn,\n });\n }\n };\n\n while (this.mapRemoves.length) {\n this.mirror.removeNodeFromMap(this.mapRemoves.shift() as INode);\n }\n\n for (const n of this.movedSet) {\n if (\n isParentRemoved(this.removes, n, this.mirror) &&\n !this.movedSet.has(n.parentNode!)\n ) {\n continue;\n }\n pushAdd(n);\n }\n\n for (const n of this.addedSet) {\n if (\n !isAncestorInSet(this.droppedSet, n) &&\n !isParentRemoved(this.removes, n, this.mirror)\n ) {\n pushAdd(n);\n } else if (isAncestorInSet(this.movedSet, n)) {\n pushAdd(n);\n } else {\n this.droppedSet.add(n);\n }\n }\n\n let candidate: DoubleLinkedListNode | null = null;\n while (addList.length) {\n let node: DoubleLinkedListNode | null = null;\n if (candidate) {\n const parentId = this.mirror.getId(\n (candidate.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(candidate.value);\n if (parentId !== -1 && nextId !== -1) {\n node = candidate;\n }\n }\n if (!node) {\n for (let index = addList.length - 1; index >= 0; index--) {\n const _node = addList.get(index)!;\n // ensure _node is defined before attempting to find value\n if (_node) {\n const parentId = this.mirror.getId(\n (_node.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(_node.value);\n if (parentId !== -1 && nextId !== -1) {\n node = _node;\n break;\n }\n }\n }\n }\n if (!node) {\n /**\n * If all nodes in queue could not find a serialized parent,\n * it may be a bug or corner case. We need to escape the\n * dead while loop at once.\n */\n while (addList.head) {\n addList.removeNode(addList.head.value);\n }\n break;\n }\n candidate = node.previous;\n addList.removeNode(node.value);\n pushAdd(node.value);\n }\n\n const payload = {\n texts: this.texts\n .map((text) => ({\n id: this.mirror.getId(text.node as INode),\n value: text.value,\n }))\n // text mutation's id was not in the mirror map means the target node has been removed\n .filter((text) => this.mirror.has(text.id)),\n attributes: this.attributes\n .map((attribute) => ({\n id: this.mirror.getId(attribute.node as INode),\n attributes: attribute.attributes,\n }))\n // attribute mutation's id was not in the mirror map means the target node has been removed\n .filter((attribute) => this.mirror.has(attribute.id)),\n removes: this.removes,\n adds,\n };\n // payload may be empty if the mutations happened in some blocked elements\n if (\n !payload.texts.length &&\n !payload.attributes.length &&\n !payload.removes.length &&\n !payload.adds.length\n ) {\n return;\n }\n\n // reset\n this.texts = [];\n this.attributes = [];\n this.removes = [];\n this.addedSet = new Set();\n this.movedSet = new Set();\n this.droppedSet = new Set();\n this.movedMap = {};\n\n this.mutationCb(payload);\n };\n\n private processMutation = (m: mutationRecord) => {\n if (isIgnored(m.target)) {\n return;\n }\n switch (m.type) {\n case 'characterData': {\n const value = m.target.textContent;\n if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {\n this.texts.push({\n value:\n needMaskingText(\n m.target,\n this.maskTextClass,\n this.maskTextSelector,\n ) && value\n ? this.maskTextFn\n ? this.maskTextFn(value)\n : value.replace(/[\\S]/g, '*')\n : value,\n node: m.target,\n });\n }\n break;\n }\n case 'attributes': {\n const target = m.target as HTMLElement;\n let value = (m.target as HTMLElement).getAttribute(m.attributeName!);\n if (m.attributeName === 'value') {\n value = maskInputValue({\n maskInputOptions: this.maskInputOptions,\n tagName: (m.target as HTMLElement).tagName,\n type: (m.target as HTMLElement).getAttribute('type'),\n value,\n maskInputFn: this.maskInputFn,\n });\n }\n if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {\n return;\n }\n let item: attributeCursor | undefined = this.attributes.find(\n (a) => a.node === m.target,\n );\n if (!item) {\n item = {\n node: m.target,\n attributes: {},\n };\n this.attributes.push(item);\n }\n if (m.attributeName === 'style') {\n const old = this.doc.createElement('span');\n if (m.oldValue) {\n old.setAttribute('style', m.oldValue);\n }\n if (\n item.attributes.style === undefined ||\n item.attributes.style === null\n ) {\n item.attributes.style = {};\n }\n const styleObj = item.attributes.style as styleAttributeValue;\n for (const pname of Array.from(target.style)) {\n const newValue = target.style.getPropertyValue(pname);\n const newPriority = target.style.getPropertyPriority(pname);\n if (\n newValue !== old.style.getPropertyValue(pname) ||\n newPriority !== old.style.getPropertyPriority(pname)\n ) {\n if (newPriority === '') {\n styleObj[pname] = newValue;\n } else {\n styleObj[pname] = [newValue, newPriority];\n }\n }\n }\n for (const pname of Array.from(old.style)) {\n if (target.style.getPropertyValue(pname) === '') {\n // \"if not set, returns the empty string\"\n styleObj[pname] = false; // delete\n }\n }\n } else {\n // overwrite attribute if the mutations was triggered in same time\n item.attributes[m.attributeName!] = transformAttribute(\n this.doc,\n (m.target as HTMLElement).tagName,\n m.attributeName!,\n value!,\n );\n }\n break;\n }\n case 'childList': {\n m.addedNodes.forEach((n) => this.genAdds(n, m.target));\n m.removedNodes.forEach((n) => {\n const nodeId = this.mirror.getId(n as INode);\n const parentId = isShadowRoot(m.target)\n ? this.mirror.getId((m.target.host as unknown) as INode)\n : this.mirror.getId(m.target as INode);\n if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {\n return;\n }\n // removed node has not been serialized yet, just remove it from the Set\n if (this.addedSet.has(n)) {\n deepDelete(this.addedSet, n);\n this.droppedSet.add(n);\n } else if (this.addedSet.has(m.target) && nodeId === -1) {\n /**\n * If target was newly added and removed child node was\n * not serialized, it means the child node has been removed\n * before callback fired, so we can ignore it because\n * newly added node will be serialized without child nodes.\n * TODO: verify this\n */\n } else if (isAncestorRemoved(m.target as INode, this.mirror)) {\n /**\n * If parent id was not in the mirror map any more, it\n * means the parent node has already been removed. So\n * the node is also removed which we do not need to track\n * and replay.\n */\n } else if (\n this.movedSet.has(n) &&\n this.movedMap[moveKey(nodeId, parentId)]\n ) {\n deepDelete(this.movedSet, n);\n } else {\n this.removes.push({\n parentId,\n id: nodeId,\n isShadow: isShadowRoot(m.target) ? true : undefined,\n });\n }\n this.mapRemoves.push(n);\n });\n break;\n }\n default:\n break;\n }\n };\n\n private genAdds = (n: Node | INode, target?: Node | INode) => {\n // parent was blocked, so we can ignore this node\n if (target && isBlocked(target, this.blockClass)) {\n return;\n }\n if (isINode(n)) {\n if (isIgnored(n)) {\n return;\n }\n this.movedSet.add(n);\n let targetId: number | null = null;\n if (target && isINode(target)) {\n targetId = target.__sn.id;\n }\n if (targetId) {\n this.movedMap[moveKey(n.__sn.id, targetId)] = true;\n }\n } else {\n this.addedSet.add(n);\n this.droppedSet.delete(n);\n }\n\n // if this node is blocked `serializeNode` will turn it into a placeholder element\n // but we have to remove it's children otherwise they will be added as placeholders too\n if (!isBlocked(n, this.blockClass))\n n.childNodes.forEach((childN) => this.genAdds(childN));\n };\n}\n\n/**\n * Some utils to handle the mutation observer DOM records.\n * It should be more clear to extend the native data structure\n * like Set and Map, but currently Typescript does not support\n * that.\n */\nfunction deepDelete(addsSet: Set, n: Node) {\n addsSet.delete(n);\n n.childNodes.forEach((childN) => deepDelete(addsSet, childN));\n}\n\nfunction isParentRemoved(\n removes: removedNodeMutation[],\n n: Node,\n mirror: Mirror,\n): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n const parentId = mirror.getId((parentNode as Node) as INode);\n if (removes.some((r) => r.id === parentId)) {\n return true;\n }\n return isParentRemoved(removes, parentNode, mirror);\n}\n\nfunction isAncestorInSet(set: Set, n: Node): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n if (set.has(parentNode)) {\n return true;\n }\n return isAncestorInSet(set, parentNode);\n}\n","import { INode, MaskInputOptions, maskInputValue } from 'rrweb-snapshot';\nimport { FontFaceSet } from 'css-font-loading-module';\nimport {\n throttle,\n on,\n hookSetter,\n getWindowHeight,\n getWindowWidth,\n isBlocked,\n isTouchEvent,\n patch,\n} from '../utils';\nimport {\n mutationCallBack,\n observerParam,\n mousemoveCallBack,\n mousePosition,\n mouseInteractionCallBack,\n MouseInteractions,\n listenerHandler,\n scrollCallback,\n styleSheetRuleCallback,\n viewportResizeCallback,\n inputValue,\n inputCallback,\n hookResetter,\n IncrementalSource,\n hooksParam,\n Arguments,\n mediaInteractionCallback,\n MediaInteractions,\n canvasMutationCallback,\n fontCallback,\n fontParam,\n styleDeclarationCallback,\n IWindow,\n MutationBufferParam,\n} from '../types';\nimport MutationBuffer from './mutation';\n\ntype WindowWithStoredMutationObserver = IWindow & {\n __rrMutationObserver?: MutationObserver;\n};\ntype WindowWithAngularZone = IWindow & {\n Zone?: {\n __symbol__?: (key: string) => string;\n };\n};\n\nexport const mutationBuffers: MutationBuffer[] = [];\n\nconst isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';\nconst isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';\nconst isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';\nconst isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';\n\n// Event.path is non-standard and used in some older browsers\ntype NonStandardEvent = Omit & {\n path: EventTarget[];\n};\n\nfunction getEventTarget(event: Event | NonStandardEvent): EventTarget | null {\n try {\n if ('composedPath' in event) {\n const path = event.composedPath();\n if (path.length) {\n return path[0];\n }\n } else if ('path' in event && event.path.length) {\n return event.path[0];\n }\n return event.target;\n } catch {\n return event.target;\n }\n}\n\nexport function initMutationObserver(\n options: MutationBufferParam,\n rootEl: Node,\n): MutationObserver {\n const mutationBuffer = new MutationBuffer();\n mutationBuffers.push(mutationBuffer);\n // see mutation.ts for details\n mutationBuffer.init(options);\n let mutationObserverCtor =\n window.MutationObserver ||\n /**\n * Some websites may disable MutationObserver by removing it from the window object.\n * If someone is using rrweb to build a browser extention or things like it, they\n * could not change the website's code but can have an opportunity to inject some\n * code before the website executing its JS logic.\n * Then they can do this to store the native MutationObserver:\n * window.__rrMutationObserver = MutationObserver\n */\n (window as WindowWithStoredMutationObserver).__rrMutationObserver;\n const angularZoneSymbol = (window as WindowWithAngularZone)?.Zone?.__symbol__?.(\n 'MutationObserver',\n );\n if (\n angularZoneSymbol &&\n ((window as unknown) as Record)[\n angularZoneSymbol\n ]\n ) {\n mutationObserverCtor = ((window as unknown) as Record<\n string,\n typeof MutationObserver\n >)[angularZoneSymbol];\n }\n const observer = new mutationObserverCtor(\n mutationBuffer.processMutations.bind(mutationBuffer),\n );\n observer.observe(rootEl, {\n attributes: true,\n attributeOldValue: true,\n characterData: true,\n characterDataOldValue: true,\n childList: true,\n subtree: true,\n });\n return observer;\n}\n\nfunction initMoveObserver({\n mousemoveCb,\n sampling,\n doc,\n mirror,\n}: observerParam): listenerHandler {\n if (sampling.mousemove === false) {\n return () => {};\n }\n\n const threshold =\n typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;\n const callbackThreshold =\n typeof sampling.mousemoveCallback === 'number'\n ? sampling.mousemoveCallback\n : 500;\n\n let positions: mousePosition[] = [];\n let timeBaseline: number | null;\n const wrappedCb = throttle(\n (\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n ) => {\n const totalOffset = Date.now() - timeBaseline!;\n mousemoveCb(\n positions.map((p) => {\n p.timeOffset -= totalOffset;\n return p;\n }),\n source,\n );\n positions = [];\n timeBaseline = null;\n },\n callbackThreshold,\n );\n const updatePosition = throttle(\n (evt) => {\n const target = getEventTarget(evt);\n const { clientX, clientY } = isTouchEvent(evt)\n ? evt.changedTouches[0]\n : evt;\n if (!timeBaseline) {\n timeBaseline = Date.now();\n }\n positions.push({\n x: clientX,\n y: clientY,\n id: mirror.getId(target as INode),\n timeOffset: Date.now() - timeBaseline,\n });\n // it is possible DragEvent is undefined even on devices\n // that support event 'drag'\n wrappedCb(\n typeof DragEvent !== 'undefined' && evt instanceof DragEvent\n ? IncrementalSource.Drag\n : evt instanceof MouseEvent\n ? IncrementalSource.MouseMove\n : IncrementalSource.TouchMove,\n );\n },\n threshold,\n {\n trailing: false,\n },\n );\n const handlers = [\n on('mousemove', updatePosition, doc),\n on('touchmove', updatePosition, doc),\n on('drag', updatePosition, doc),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initMouseInteractionObserver({\n mouseInteractionCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: observerParam): listenerHandler {\n if (sampling.mouseInteraction === false) {\n return () => {};\n }\n const disableMap: Record =\n sampling.mouseInteraction === true ||\n sampling.mouseInteraction === undefined\n ? {}\n : sampling.mouseInteraction;\n\n const handlers: listenerHandler[] = [];\n const getHandler = (eventKey: keyof typeof MouseInteractions) => {\n return (event: MouseEvent | TouchEvent) => {\n const target = getEventTarget(event) as Node;\n if (isBlocked(target as Node, blockClass)) {\n return;\n }\n const e = isTouchEvent(event) ? event.changedTouches[0] : event;\n if (!e) {\n return;\n }\n const id = mirror.getId(target as INode);\n const { clientX, clientY } = e;\n mouseInteractionCb({\n type: MouseInteractions[eventKey],\n id,\n x: clientX,\n y: clientY,\n });\n };\n };\n Object.keys(MouseInteractions)\n .filter(\n (key) =>\n Number.isNaN(Number(key)) &&\n !key.endsWith('_Departed') &&\n disableMap[key] !== false,\n )\n .forEach((eventKey: keyof typeof MouseInteractions) => {\n const eventName = eventKey.toLowerCase();\n const handler = getHandler(eventKey);\n handlers.push(on(eventName, handler, doc));\n });\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nexport function initScrollObserver({\n scrollCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: Pick<\n observerParam,\n 'scrollCb' | 'doc' | 'mirror' | 'blockClass' | 'sampling'\n>): listenerHandler {\n const updatePosition = throttle((evt) => {\n const target = getEventTarget(evt);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const id = mirror.getId(target as INode);\n if (target === doc) {\n const scrollEl = (doc.scrollingElement || doc.documentElement)!;\n scrollCb({\n id,\n x: scrollEl.scrollLeft,\n y: scrollEl.scrollTop,\n });\n } else {\n scrollCb({\n id,\n x: (target as HTMLElement).scrollLeft,\n y: (target as HTMLElement).scrollTop,\n });\n }\n }, sampling.scroll || 100);\n return on('scroll', updatePosition, doc);\n}\n\nfunction initViewportResizeObserver({\n viewportResizeCb,\n}: observerParam): listenerHandler {\n let lastH = -1;\n let lastW = -1;\n const updateDimension = throttle(() => {\n const height = getWindowHeight();\n const width = getWindowWidth();\n if (lastH !== height || lastW !== width) {\n viewportResizeCb({\n width: Number(width),\n height: Number(height),\n });\n lastH = height;\n lastW = width;\n }\n }, 200);\n return on('resize', updateDimension, window);\n}\n\nfunction wrapEventWithUserTriggeredFlag(\n v: inputValue,\n enable: boolean,\n): inputValue {\n const value = { ...v };\n if (!enable) delete value.userTriggered;\n return value;\n}\n\nexport const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];\nconst lastInputValueMap: WeakMap = new WeakMap();\nfunction initInputObserver({\n inputCb,\n doc,\n mirror,\n blockClass,\n ignoreClass,\n maskInputOptions,\n maskInputFn,\n sampling,\n userTriggeredOnInput,\n}: observerParam): listenerHandler {\n function eventHandler(event: Event) {\n let target = getEventTarget(event);\n const userTriggered = event.isTrusted;\n /**\n * If a site changes the value 'selected' of an option element, the value of its parent element, usually a select element, will be changed as well.\n * We can treat this change as a value change of the select element the current target belongs to.\n */\n if (target && (target as Element).tagName === 'OPTION')\n target = (target as Element).parentElement;\n if (\n !target ||\n !(target as Element).tagName ||\n INPUT_TAGS.indexOf((target as Element).tagName) < 0 ||\n isBlocked(target as Node, blockClass)\n ) {\n return;\n }\n const type: string | undefined = (target as HTMLInputElement).type;\n if ((target as HTMLElement).classList.contains(ignoreClass)) {\n return;\n }\n let text = (target as HTMLInputElement).value;\n let isChecked = false;\n if (type === 'radio' || type === 'checkbox') {\n isChecked = (target as HTMLInputElement).checked;\n } else if (\n maskInputOptions[\n (target as Element).tagName.toLowerCase() as keyof MaskInputOptions\n ] ||\n maskInputOptions[type as keyof MaskInputOptions]\n ) {\n text = maskInputValue({\n maskInputOptions,\n tagName: (target as HTMLElement).tagName,\n type,\n value: text,\n maskInputFn,\n });\n }\n cbWithDedup(\n target,\n wrapEventWithUserTriggeredFlag(\n { text, isChecked, userTriggered },\n userTriggeredOnInput,\n ),\n );\n // if a radio was checked\n // the other radios with the same name attribute will be unchecked.\n const name: string | undefined = (target as HTMLInputElement).name;\n if (type === 'radio' && name && isChecked) {\n doc\n .querySelectorAll(`input[type=\"radio\"][name=\"${name}\"]`)\n .forEach((el) => {\n if (el !== target) {\n cbWithDedup(\n el,\n wrapEventWithUserTriggeredFlag(\n {\n text: (el as HTMLInputElement).value,\n isChecked: !isChecked,\n userTriggered: false,\n },\n userTriggeredOnInput,\n ),\n );\n }\n });\n }\n }\n function cbWithDedup(target: EventTarget, v: inputValue) {\n const lastInputValue = lastInputValueMap.get(target);\n if (\n !lastInputValue ||\n lastInputValue.text !== v.text ||\n lastInputValue.isChecked !== v.isChecked\n ) {\n lastInputValueMap.set(target, v);\n const id = mirror.getId(target as INode);\n inputCb({\n ...v,\n id,\n });\n }\n }\n const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];\n const handlers: Array<\n listenerHandler | hookResetter\n > = events.map((eventName) => on(eventName, eventHandler, doc));\n const propertyDescriptor = Object.getOwnPropertyDescriptor(\n HTMLInputElement.prototype,\n 'value',\n );\n const hookProperties: Array<[HTMLElement, string]> = [\n [HTMLInputElement.prototype, 'value'],\n [HTMLInputElement.prototype, 'checked'],\n [HTMLSelectElement.prototype, 'value'],\n [HTMLTextAreaElement.prototype, 'value'],\n // Some UI library use selectedIndex to set select value\n [HTMLSelectElement.prototype, 'selectedIndex'],\n [HTMLOptionElement.prototype, 'selected'],\n ];\n if (propertyDescriptor && propertyDescriptor.set) {\n handlers.push(\n ...hookProperties.map((p) =>\n hookSetter(p[0], p[1], {\n set() {\n // mock to a normal event\n eventHandler({ target: this } as Event);\n },\n }),\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\ntype GroupingCSSRule =\n | CSSGroupingRule\n | CSSMediaRule\n | CSSSupportsRule\n | CSSConditionRule;\ntype GroupingCSSRuleTypes =\n | typeof CSSGroupingRule\n | typeof CSSMediaRule\n | typeof CSSSupportsRule\n | typeof CSSConditionRule;\n\nfunction getNestedCSSRulePositions(rule: CSSRule): number[] {\n const positions: number[] = [];\n function recurse(childRule: CSSRule, pos: number[]) {\n if (\n (isCSSGroupingRuleSupported &&\n childRule.parentRule instanceof CSSGroupingRule) ||\n (isCSSMediaRuleSupported &&\n childRule.parentRule instanceof CSSMediaRule) ||\n (isCSSSupportsRuleSupported &&\n childRule.parentRule instanceof CSSSupportsRule) ||\n (isCSSConditionRuleSupported &&\n childRule.parentRule instanceof CSSConditionRule)\n ) {\n const rules = Array.from(\n (childRule.parentRule as GroupingCSSRule).cssRules,\n );\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n } else {\n const rules = Array.from(childRule.parentStyleSheet!.cssRules);\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n }\n return pos;\n }\n return recurse(rule, positions);\n}\n\nfunction initStyleSheetObserver(\n { styleSheetRuleCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n const insertRule = win.CSSStyleSheet.prototype.insertRule;\n win.CSSStyleSheet.prototype.insertRule = function (\n rule: string,\n index?: number,\n ) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [{ rule, index }],\n });\n }\n return insertRule.apply(this, arguments);\n };\n\n const deleteRule = win.CSSStyleSheet.prototype.deleteRule;\n win.CSSStyleSheet.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index }],\n });\n }\n return deleteRule.apply(this, arguments);\n };\n\n const supportedNestedCSSRuleTypes: {\n [key: string]: GroupingCSSRuleTypes;\n } = {};\n if (isCSSGroupingRuleSupported) {\n supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;\n } else {\n // Some browsers (Safari) don't support CSSGroupingRule\n // https://caniuse.com/?search=cssgroupingrule\n // fall back to monkey patching classes that would have inherited from CSSGroupingRule\n\n if (isCSSMediaRuleSupported) {\n supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;\n }\n if (isCSSConditionRuleSupported) {\n supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;\n }\n if (isCSSSupportsRuleSupported) {\n supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;\n }\n }\n\n const unmodifiedFunctions: {\n [key: string]: {\n insertRule: (rule: string, index?: number) => number;\n deleteRule: (index: number) => void;\n };\n } = {};\n\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n unmodifiedFunctions[typeKey] = {\n insertRule: (type as GroupingCSSRuleTypes).prototype.insertRule,\n deleteRule: (type as GroupingCSSRuleTypes).prototype.deleteRule,\n };\n\n type.prototype.insertRule = function (rule: string, index?: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [\n {\n rule,\n index: [\n ...getNestedCSSRulePositions(this),\n index || 0, // defaults to 0\n ],\n },\n ],\n });\n }\n return unmodifiedFunctions[typeKey].insertRule.apply(this, arguments);\n };\n\n type.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index: [...getNestedCSSRulePositions(this), index] }],\n });\n }\n return unmodifiedFunctions[typeKey].deleteRule.apply(this, arguments);\n };\n });\n\n return () => {\n win.CSSStyleSheet.prototype.insertRule = insertRule;\n win.CSSStyleSheet.prototype.deleteRule = deleteRule;\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;\n type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;\n });\n };\n}\n\nfunction initStyleDeclarationObserver(\n { styleDeclarationCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n const setProperty = win.CSSStyleDeclaration.prototype.setProperty;\n win.CSSStyleDeclaration.prototype.setProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n value: string,\n priority: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n set: {\n property,\n value,\n priority,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return setProperty.apply(this, arguments);\n };\n\n const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n remove: {\n property,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return removeProperty.apply(this, arguments);\n };\n\n return () => {\n win.CSSStyleDeclaration.prototype.setProperty = setProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;\n };\n}\n\nfunction initMediaInteractionObserver({\n mediaInteractionCb,\n blockClass,\n mirror,\n sampling,\n}: observerParam): listenerHandler {\n const handler = (type: MediaInteractions) =>\n throttle((event: Event) => {\n const target = getEventTarget(event);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const { currentTime, volume, muted } = target as HTMLMediaElement;\n mediaInteractionCb({\n type,\n id: mirror.getId(target as INode),\n currentTime,\n volume,\n muted,\n });\n }, sampling.media || 500);\n const handlers = [\n on('play', handler(MediaInteractions.Play)),\n on('pause', handler(MediaInteractions.Pause)),\n on('seeked', handler(MediaInteractions.Seeked)),\n on('volumechange', handler(MediaInteractions.VolumeChange)),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initFontObserver({ fontCb, doc }: observerParam): listenerHandler {\n const win = doc.defaultView as IWindow;\n if (!win) {\n return () => {};\n }\n\n const handlers: listenerHandler[] = [];\n\n const fontMap = new WeakMap();\n\n const originalFontFace = win.FontFace;\n win.FontFace = (function FontFace(\n family: string,\n source: string | ArrayBufferView,\n descriptors?: FontFaceDescriptors,\n ) {\n const fontFace = new originalFontFace(family, source, descriptors);\n fontMap.set(fontFace, {\n family,\n buffer: typeof source !== 'string',\n descriptors,\n fontSource:\n typeof source === 'string'\n ? source\n : // tslint:disable-next-line: no-any\n JSON.stringify(Array.from(new Uint8Array(source as any))),\n });\n return fontFace;\n } as unknown) as typeof FontFace;\n\n const restoreHandler = patch(doc.fonts, 'add', function (original) {\n return function (this: FontFaceSet, fontFace: FontFace) {\n setTimeout(() => {\n const p = fontMap.get(fontFace);\n if (p) {\n fontCb(p);\n fontMap.delete(fontFace);\n }\n }, 0);\n return original.apply(this, [fontFace]);\n };\n });\n\n handlers.push(() => {\n win.FontFace = originalFontFace;\n });\n handlers.push(restoreHandler);\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction mergeHooks(o: observerParam, hooks: hooksParam) {\n const {\n mutationCb,\n mousemoveCb,\n mouseInteractionCb,\n scrollCb,\n viewportResizeCb,\n inputCb,\n mediaInteractionCb,\n styleSheetRuleCb,\n styleDeclarationCb,\n canvasMutationCb,\n fontCb,\n } = o;\n o.mutationCb = (...p: Arguments) => {\n if (hooks.mutation) {\n hooks.mutation(...p);\n }\n mutationCb(...p);\n };\n o.mousemoveCb = (...p: Arguments) => {\n if (hooks.mousemove) {\n hooks.mousemove(...p);\n }\n mousemoveCb(...p);\n };\n o.mouseInteractionCb = (...p: Arguments) => {\n if (hooks.mouseInteraction) {\n hooks.mouseInteraction(...p);\n }\n mouseInteractionCb(...p);\n };\n o.scrollCb = (...p: Arguments) => {\n if (hooks.scroll) {\n hooks.scroll(...p);\n }\n scrollCb(...p);\n };\n o.viewportResizeCb = (...p: Arguments) => {\n if (hooks.viewportResize) {\n hooks.viewportResize(...p);\n }\n viewportResizeCb(...p);\n };\n o.inputCb = (...p: Arguments) => {\n if (hooks.input) {\n hooks.input(...p);\n }\n inputCb(...p);\n };\n o.mediaInteractionCb = (...p: Arguments) => {\n if (hooks.mediaInteaction) {\n hooks.mediaInteaction(...p);\n }\n mediaInteractionCb(...p);\n };\n o.styleSheetRuleCb = (...p: Arguments) => {\n if (hooks.styleSheetRule) {\n hooks.styleSheetRule(...p);\n }\n styleSheetRuleCb(...p);\n };\n o.styleDeclarationCb = (...p: Arguments) => {\n if (hooks.styleDeclaration) {\n hooks.styleDeclaration(...p);\n }\n styleDeclarationCb(...p);\n };\n o.canvasMutationCb = (...p: Arguments) => {\n if (hooks.canvasMutation) {\n hooks.canvasMutation(...p);\n }\n canvasMutationCb(...p);\n };\n o.fontCb = (...p: Arguments) => {\n if (hooks.font) {\n hooks.font(...p);\n }\n fontCb(...p);\n };\n}\n\nexport function initObservers(\n o: observerParam,\n hooks: hooksParam = {},\n): listenerHandler {\n const currentWindow = o.doc.defaultView; // basically document.window\n if (!currentWindow) {\n return () => {};\n }\n\n mergeHooks(o, hooks);\n const mutationObserver = initMutationObserver(o, o.doc);\n const mousemoveHandler = initMoveObserver(o);\n const mouseInteractionHandler = initMouseInteractionObserver(o);\n const scrollHandler = initScrollObserver(o);\n const viewportResizeHandler = initViewportResizeObserver(o);\n const inputHandler = initInputObserver(o);\n const mediaInteractionHandler = initMediaInteractionObserver(o);\n\n const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });\n const styleDeclarationObserver = initStyleDeclarationObserver(o, {\n win: currentWindow,\n });\n const fontObserver = o.collectFonts ? initFontObserver(o) : () => {};\n // plugins\n const pluginHandlers: listenerHandler[] = [];\n for (const plugin of o.plugins) {\n pluginHandlers.push(\n plugin.observer(plugin.callback, currentWindow, plugin.options),\n );\n }\n\n return () => {\n mutationBuffers.forEach((b) => b.reset());\n mutationObserver.disconnect();\n mousemoveHandler();\n mouseInteractionHandler();\n scrollHandler();\n viewportResizeHandler();\n inputHandler();\n mediaInteractionHandler();\n styleSheetObserver();\n styleDeclarationObserver();\n fontObserver();\n pluginHandlers.forEach((h) => h());\n };\n}\n","import { serializedNodeWithId, INode } from 'rrweb-snapshot';\nimport { mutationCallBack } from '../types';\n\nexport class IframeManager {\n private iframes: WeakMap = new WeakMap();\n private mutationCb: mutationCallBack;\n private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;\n\n constructor(options: { mutationCb: mutationCallBack }) {\n this.mutationCb = options.mutationCb;\n }\n\n public addIframe(iframeEl: HTMLIFrameElement) {\n this.iframes.set(iframeEl, true);\n }\n\n public addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown) {\n this.loadListener = cb;\n }\n\n public attachIframe(iframeEl: INode, childSn: serializedNodeWithId) {\n this.mutationCb({\n adds: [\n {\n parentId: iframeEl.__sn.id,\n nextId: null,\n node: childSn,\n },\n ],\n removes: [],\n texts: [],\n attributes: [],\n isAttachIframe: true,\n });\n this.loadListener?.((iframeEl as unknown) as HTMLIFrameElement);\n }\n}\n","import {\n mutationCallBack,\n Mirror,\n scrollCallback,\n MutationBufferParam,\n SamplingStrategy,\n} from '../types';\nimport { initMutationObserver, initScrollObserver } from './observer';\nimport { patch } from '../utils';\n\ntype BypassOptions = Omit<\n MutationBufferParam,\n 'doc' | 'mutationCb' | 'mirror' | 'shadowDomManager'\n> & {\n sampling: SamplingStrategy;\n};\n\nexport class ShadowDomManager {\n private mutationCb: mutationCallBack;\n private scrollCb: scrollCallback;\n private bypassOptions: BypassOptions;\n private mirror: Mirror;\n private restorePatches: (() => void)[] = [];\n\n constructor(options: {\n mutationCb: mutationCallBack;\n scrollCb: scrollCallback;\n bypassOptions: BypassOptions;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.scrollCb = options.scrollCb;\n this.bypassOptions = options.bypassOptions;\n this.mirror = options.mirror;\n\n // Patch 'attachShadow' to observe newly added shadow doms.\n const manager = this;\n this.restorePatches.push(\n patch(HTMLElement.prototype, 'attachShadow', function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(this.shadowRoot, this.ownerDocument);\n return shadowRoot;\n };\n }),\n );\n }\n\n public addShadowRoot(shadowRoot: ShadowRoot, doc: Document) {\n initMutationObserver(\n {\n ...this.bypassOptions,\n doc,\n mutationCb: this.mutationCb,\n mirror: this.mirror,\n shadowDomManager: this,\n },\n shadowRoot,\n );\n initScrollObserver({\n ...this.bypassOptions,\n scrollCb: this.scrollCb,\n // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813\n // scroll is not allowed to pass the boundary, so we need to listen the shadow document\n doc: (shadowRoot as unknown) as Document,\n mirror: this.mirror,\n });\n }\n\n /**\n * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.\n */\n public observeAttachShadow(iframeElement: HTMLIFrameElement) {\n if (iframeElement.contentWindow) {\n const manager = this;\n this.restorePatches.push(\n patch(\n (iframeElement.contentWindow as Window & {\n HTMLElement: { prototype: HTMLElement };\n }).HTMLElement.prototype,\n 'attachShadow',\n function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(\n this.shadowRoot,\n iframeElement.contentDocument as Document,\n );\n return shadowRoot;\n };\n },\n ),\n );\n }\n }\n\n public reset() {\n this.restorePatches.forEach((restorePatch) => restorePatch());\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { encode } from 'base64-arraybuffer';\nimport { IWindow, SerializedWebGlArg } from '../../../types';\n\n// TODO: unify with `replay/webgl.ts`\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nexport const saveWebGLVar = (\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): number | void => {\n if (\n !value ||\n !(isInstanceOfWebGLObject(value, win) || typeof value === 'object')\n )\n return;\n\n const name = value.constructor.name;\n const list = variableListFor(ctx, name);\n let index = list.indexOf(value);\n\n if (index === -1) {\n index = list.length;\n list.push(value);\n }\n return index;\n};\n\n// from webgl-recorder: https://github.com/evanw/webgl-recorder/blob/bef0e65596e981ee382126587e2dcbe0fc7748e2/webgl-recorder.js#L50-L77\nexport function serializeArg(\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): SerializedWebGlArg {\n if (value instanceof Array) {\n return value.map((arg) => serializeArg(arg, win, ctx));\n } else if (value === null) {\n return value;\n } else if (\n value instanceof Float32Array ||\n value instanceof Float64Array ||\n value instanceof Int32Array ||\n value instanceof Uint32Array ||\n value instanceof Uint8Array ||\n value instanceof Uint16Array ||\n value instanceof Int16Array ||\n value instanceof Int8Array ||\n value instanceof Uint8ClampedArray\n ) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [Object.values(value)],\n };\n } else if (\n // SharedArrayBuffer disabled on most browsers due to spectre.\n // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer\n // value instanceof SharedArrayBuffer ||\n value instanceof ArrayBuffer\n ) {\n const name = value.constructor.name as 'ArrayBuffer';\n const base64 = encode(value);\n\n return {\n rr_type: name,\n base64,\n };\n } else if (value instanceof DataView) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [\n serializeArg(value.buffer, win, ctx),\n value.byteOffset,\n value.byteLength,\n ],\n };\n } else if (value instanceof HTMLImageElement) {\n const name = value.constructor.name;\n const { src } = value;\n return {\n rr_type: name,\n src,\n };\n } else if (value instanceof ImageData) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [serializeArg(value.data, win, ctx), value.width, value.height],\n };\n } else if (isInstanceOfWebGLObject(value, win) || typeof value === 'object') {\n const name = value.constructor.name;\n const index = saveWebGLVar(value, win, ctx) as number;\n\n return {\n rr_type: name,\n index: index,\n };\n }\n\n return value;\n}\n\nexport const serializeArgs = (\n args: Array,\n win: IWindow,\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n) => {\n return [...args].map((arg) => serializeArg(arg, win, ctx));\n};\n\nexport const isInstanceOfWebGLObject = (\n value: any,\n win: IWindow,\n): value is\n | WebGLActiveInfo\n | WebGLBuffer\n | WebGLFramebuffer\n | WebGLProgram\n | WebGLRenderbuffer\n | WebGLShader\n | WebGLShaderPrecisionFormat\n | WebGLTexture\n | WebGLUniformLocation\n | WebGLVertexArrayObject => {\n const webGLConstructorNames: string[] = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.\n 'WebGLVertexArrayObjectOES',\n ];\n const supportedWebGLConstructorNames = webGLConstructorNames.filter(\n (name: string) => typeof win[name as keyof Window] === 'function',\n );\n return Boolean(\n supportedWebGLConstructorNames.find(\n (name: string) => value instanceof win[name as keyof Window],\n ),\n );\n};\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\nimport { saveWebGLVar, serializeArgs } from './serialize-args';\n\nfunction patchGLPrototype(\n prototype: WebGLRenderingContext | WebGL2RenderingContext,\n type: CanvasContext,\n cb: canvasManagerMutationCallback,\n blockClass: blockClass,\n mirror: Mirror,\n win: IWindow,\n): listenerHandler[] {\n const handlers: listenerHandler[] = [];\n\n const props = Object.getOwnPropertyNames(prototype);\n\n for (const prop of props) {\n try {\n if (typeof prototype[prop as keyof typeof prototype] !== 'function') {\n continue;\n }\n const restoreHandler = patch(prototype, prop, function (original) {\n return function (this: typeof prototype, ...args: Array) {\n const result = original.apply(this, args);\n saveWebGLVar(result, win, prototype);\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n const id = mirror.getId((this.canvas as unknown) as INode);\n\n const recordArgs = serializeArgs([...args], win, prototype);\n const mutation: canvasMutationWithType = {\n type,\n property: prop,\n args: recordArgs,\n };\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, mutation);\n }\n\n return result;\n };\n });\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(prototype, prop, {\n set(v) {\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, {\n type,\n property: prop,\n args: [v],\n setter: true,\n });\n },\n });\n handlers.push(hookHandler);\n }\n }\n\n return handlers;\n}\n\nexport default function initCanvasWebGLMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n\n handlers.push(\n ...patchGLPrototype(\n win.WebGLRenderingContext.prototype,\n CanvasContext.WebGL,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n\n if (typeof win.WebGL2RenderingContext !== 'undefined') {\n handlers.push(\n ...patchGLPrototype(\n win.WebGL2RenderingContext.prototype,\n CanvasContext.WebGL2,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n }\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n canvasManagerMutationCallback,\n canvasMutationCallback,\n canvasMutationCommand,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport initCanvas2DMutationObserver from './2d';\nimport initCanvasContextObserver from './canvas';\nimport initCanvasWebGLMutationObserver from './webgl';\n\nexport type RafStamps = { latestId: number; invokeId: number | null };\n\ntype pendingCanvasMutationsMap = Map<\n HTMLCanvasElement,\n canvasMutationWithType[]\n>;\n\nexport class CanvasManager {\n private pendingCanvasMutations: pendingCanvasMutationsMap = new Map();\n private rafStamps: RafStamps = { latestId: 0, invokeId: null };\n private mirror: Mirror;\n\n private mutationCb: canvasMutationCallback;\n private resetObservers?: listenerHandler;\n private frozen: boolean = false;\n private locked: boolean = false;\n\n public reset() {\n this.pendingCanvasMutations.clear();\n this.resetObservers && this.resetObservers();\n }\n\n public freeze() {\n this.frozen = true;\n }\n\n public unfreeze() {\n this.frozen = false;\n }\n\n public lock() {\n this.locked = true;\n }\n\n public unlock() {\n this.locked = false;\n }\n\n constructor(options: {\n recordCanvas: boolean | number;\n mutationCb: canvasMutationCallback;\n win: IWindow;\n blockClass: blockClass;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.mirror = options.mirror;\n\n if (options.recordCanvas === true)\n this.initCanvasMutationObserver(options.win, options.blockClass);\n }\n\n private processMutation: canvasManagerMutationCallback = function (\n target,\n mutation,\n ) {\n const newFrame =\n this.rafStamps.invokeId &&\n this.rafStamps.latestId !== this.rafStamps.invokeId;\n if (newFrame || !this.rafStamps.invokeId)\n this.rafStamps.invokeId = this.rafStamps.latestId;\n\n if (!this.pendingCanvasMutations.has(target)) {\n this.pendingCanvasMutations.set(target, []);\n }\n\n this.pendingCanvasMutations.get(target)!.push(mutation);\n };\n\n private initCanvasMutationObserver(\n win: IWindow,\n blockClass: blockClass,\n ): void {\n this.startRAFTimestamping();\n this.startPendingCanvasMutationFlusher();\n\n const canvasContextReset = initCanvasContextObserver(win, blockClass);\n const canvas2DReset = initCanvas2DMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n this.resetObservers = () => {\n canvasContextReset();\n canvas2DReset();\n canvasWebGL1and2Reset();\n };\n }\n\n private startPendingCanvasMutationFlusher() {\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n private startRAFTimestamping() {\n const setLatestRAFTimestamp = (timestamp: DOMHighResTimeStamp) => {\n this.rafStamps.latestId = timestamp;\n requestAnimationFrame(setLatestRAFTimestamp);\n };\n requestAnimationFrame(setLatestRAFTimestamp);\n }\n\n flushPendingCanvasMutations() {\n this.pendingCanvasMutations.forEach(\n (values: canvasMutationCommand[], canvas: HTMLCanvasElement) => {\n const id = this.mirror.getId((canvas as unknown) as INode);\n this.flushPendingCanvasMutationFor(canvas, id);\n },\n );\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n flushPendingCanvasMutationFor(canvas: HTMLCanvasElement, id: number) {\n if (this.frozen || this.locked) {\n return;\n }\n\n const valuesWithType = this.pendingCanvasMutations.get(canvas);\n if (!valuesWithType || id === -1) return;\n\n const values = valuesWithType.map((value) => {\n const { type, ...rest } = value;\n return rest;\n });\n const { type } = valuesWithType[0];\n\n this.mutationCb({ id, type, commands: values });\n\n this.pendingCanvasMutations.delete(canvas);\n }\n}\n","import { snapshot, MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';\nimport { initObservers, mutationBuffers } from './observer';\nimport {\n on,\n getWindowWidth,\n getWindowHeight,\n polyfill,\n isIframeINode,\n hasShadowRoot,\n createMirror,\n} from '../utils';\nimport {\n EventType,\n event,\n eventWithTime,\n recordOptions,\n IncrementalSource,\n listenerHandler,\n mutationCallbackParam,\n scrollCallback,\n canvasMutationParam,\n} from '../types';\nimport { IframeManager } from './iframe-manager';\nimport { ShadowDomManager } from './shadow-dom-manager';\nimport { CanvasManager } from './observers/canvas/canvas-manager';\n\nfunction wrapEvent(e: event): eventWithTime {\n return {\n ...e,\n timestamp: Date.now(),\n };\n}\n\nlet wrappedEmit!: (e: eventWithTime, isCheckout?: boolean) => void;\n\nlet takeFullSnapshot!: (isCheckout?: boolean) => void;\n\nconst mirror = createMirror();\nfunction record(\n options: recordOptions = {},\n): listenerHandler | undefined {\n const {\n emit,\n checkoutEveryNms,\n checkoutEveryNth,\n blockClass = 'rr-block',\n blockSelector = null,\n ignoreClass = 'rr-ignore',\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n inlineStylesheet = true,\n maskAllInputs,\n maskInputOptions: _maskInputOptions,\n slimDOMOptions: _slimDOMOptions,\n maskInputFn,\n maskTextFn,\n hooks,\n packFn,\n sampling = {},\n mousemoveWait,\n recordCanvas = false,\n userTriggeredOnInput = false,\n collectFonts = false,\n inlineImages = false,\n plugins,\n keepIframeSrcFn = () => false,\n } = options;\n // runtime checks for user options\n if (!emit) {\n throw new Error('emit function is required');\n }\n // move departed options to new options\n if (mousemoveWait !== undefined && sampling.mousemove === undefined) {\n sampling.mousemove = mousemoveWait;\n }\n\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : _maskInputOptions !== undefined\n ? _maskInputOptions\n : { password: true };\n\n const slimDOMOptions: SlimDOMOptions =\n _slimDOMOptions === true || _slimDOMOptions === 'all'\n ? {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaVerification: true,\n // the following are off for slimDOMOptions === true,\n // as they destroy some (hidden) info:\n headMetaAuthorship: _slimDOMOptions === 'all',\n headMetaDescKeywords: _slimDOMOptions === 'all',\n }\n : _slimDOMOptions\n ? _slimDOMOptions\n : {};\n\n polyfill();\n\n let lastFullSnapshotEvent: eventWithTime;\n let incrementalSnapshotCount = 0;\n const eventProcessor = (e: eventWithTime): T => {\n for (const plugin of plugins || []) {\n if (plugin.eventProcessor) {\n e = plugin.eventProcessor(e);\n }\n }\n if (packFn) {\n e = (packFn(e) as unknown) as eventWithTime;\n }\n return (e as unknown) as T;\n };\n wrappedEmit = (e: eventWithTime, isCheckout?: boolean) => {\n if (\n mutationBuffers[0]?.isFrozen() &&\n e.type !== EventType.FullSnapshot &&\n !(\n e.type === EventType.IncrementalSnapshot &&\n e.data.source === IncrementalSource.Mutation\n )\n ) {\n // we've got a user initiated event so first we need to apply\n // all DOM changes that have been buffering during paused state\n mutationBuffers.forEach((buf) => buf.unfreeze());\n }\n\n emit(eventProcessor(e), isCheckout);\n if (e.type === EventType.FullSnapshot) {\n lastFullSnapshotEvent = e;\n incrementalSnapshotCount = 0;\n } else if (e.type === EventType.IncrementalSnapshot) {\n // attach iframe should be considered as full snapshot\n if (\n e.data.source === IncrementalSource.Mutation &&\n e.data.isAttachIframe\n ) {\n return;\n }\n\n incrementalSnapshotCount++;\n const exceedCount =\n checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;\n const exceedTime =\n checkoutEveryNms &&\n e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;\n if (exceedCount || exceedTime) {\n takeFullSnapshot(true);\n }\n }\n };\n\n const wrappedMutationEmit = (m: mutationCallbackParam) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Mutation,\n ...m,\n },\n }),\n );\n };\n const wrappedScrollEmit: scrollCallback = (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Scroll,\n ...p,\n },\n }),\n );\n const wrappedCanvasMutationEmit = (p: canvasMutationParam) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.CanvasMutation,\n ...p,\n },\n }),\n );\n\n const iframeManager = new IframeManager({\n mutationCb: wrappedMutationEmit,\n });\n\n const canvasManager = new CanvasManager({\n recordCanvas,\n mutationCb: wrappedCanvasMutationEmit,\n win: window,\n blockClass,\n mirror,\n });\n\n const shadowDomManager = new ShadowDomManager({\n mutationCb: wrappedMutationEmit,\n scrollCb: wrappedScrollEmit,\n bypassOptions: {\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n recordCanvas,\n inlineImages,\n sampling,\n slimDOMOptions,\n iframeManager,\n canvasManager,\n },\n mirror,\n });\n\n takeFullSnapshot = (isCheckout = false) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Meta,\n data: {\n href: window.location.href,\n width: getWindowWidth(),\n height: getWindowHeight(),\n },\n }),\n isCheckout,\n );\n\n mutationBuffers.forEach((buf) => buf.lock()); // don't allow any mirror modifications during snapshotting\n const [node, idNodeMap] = snapshot(document, {\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskAllInputs: maskInputOptions,\n maskTextFn,\n slimDOM: slimDOMOptions,\n recordCanvas,\n inlineImages,\n onSerialize: (n) => {\n if (isIframeINode(n)) {\n iframeManager.addIframe(n);\n }\n if (hasShadowRoot(n)) {\n shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n iframeManager.attachIframe(iframe, childSn);\n shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n keepIframeSrcFn,\n });\n\n if (!node) {\n return console.warn('Failed to snapshot the document');\n }\n\n mirror.map = idNodeMap;\n wrappedEmit(\n wrapEvent({\n type: EventType.FullSnapshot,\n data: {\n node,\n initialOffset: {\n left:\n window.pageXOffset !== undefined\n ? window.pageXOffset\n : document?.documentElement.scrollLeft ||\n document?.body?.parentElement?.scrollLeft ||\n document?.body.scrollLeft ||\n 0,\n top:\n window.pageYOffset !== undefined\n ? window.pageYOffset\n : document?.documentElement.scrollTop ||\n document?.body?.parentElement?.scrollTop ||\n document?.body.scrollTop ||\n 0,\n },\n },\n }),\n );\n mutationBuffers.forEach((buf) => buf.unlock()); // generate & emit any mutations that happened during snapshotting, as can now apply against the newly built mirror\n };\n\n try {\n const handlers: listenerHandler[] = [];\n handlers.push(\n on('DOMContentLoaded', () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.DomContentLoaded,\n data: {},\n }),\n );\n }),\n );\n\n const observe = (doc: Document) => {\n return initObservers(\n {\n mutationCb: wrappedMutationEmit,\n mousemoveCb: (positions, source) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source,\n positions,\n },\n }),\n ),\n mouseInteractionCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MouseInteraction,\n ...d,\n },\n }),\n ),\n scrollCb: wrappedScrollEmit,\n viewportResizeCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.ViewportResize,\n ...d,\n },\n }),\n ),\n inputCb: (v) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Input,\n ...v,\n },\n }),\n ),\n mediaInteractionCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MediaInteraction,\n ...p,\n },\n }),\n ),\n styleSheetRuleCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleSheetRule,\n ...r,\n },\n }),\n ),\n styleDeclarationCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleDeclaration,\n ...r,\n },\n }),\n ),\n canvasMutationCb: wrappedCanvasMutationEmit,\n fontCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Font,\n ...p,\n },\n }),\n ),\n blockClass,\n ignoreClass,\n maskTextClass,\n maskTextSelector,\n maskInputOptions,\n inlineStylesheet,\n sampling,\n recordCanvas,\n inlineImages,\n userTriggeredOnInput,\n collectFonts,\n doc,\n maskInputFn,\n maskTextFn,\n blockSelector,\n slimDOMOptions,\n mirror,\n iframeManager,\n shadowDomManager,\n canvasManager,\n plugins:\n plugins\n ?.filter((p) => p.observer)\n ?.map((p) => ({\n observer: p.observer!,\n options: p.options,\n callback: (payload: object) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.Plugin,\n data: {\n plugin: p.name,\n payload,\n },\n }),\n ),\n })) || [],\n },\n hooks,\n );\n };\n\n iframeManager.addLoadListener((iframeEl) => {\n handlers.push(observe(iframeEl.contentDocument!));\n });\n\n const init = () => {\n takeFullSnapshot();\n handlers.push(observe(document));\n };\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n init();\n } else {\n handlers.push(\n on(\n 'load',\n () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Load,\n data: {},\n }),\n );\n init();\n },\n window,\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n } catch (error) {\n // TODO: handle internal error\n console.warn(error);\n }\n}\n\nrecord.addCustomEvent = (tag: string, payload: T) => {\n if (!wrappedEmit) {\n throw new Error('please add custom event after start recording');\n }\n wrappedEmit(\n wrapEvent({\n type: EventType.Custom,\n data: {\n tag,\n payload,\n },\n }),\n );\n};\n\nrecord.freezePage = () => {\n mutationBuffers.forEach((buf) => buf.freeze());\n};\n\nrecord.takeFullSnapshot = (isCheckout?: boolean) => {\n if (!takeFullSnapshot) {\n throw new Error('please take full snapshot after start recording');\n }\n takeFullSnapshot(isCheckout);\n};\n\nrecord.mirror = mirror;\n\nexport default record;\n","import { INode, ICanvas } from 'rrweb-snapshot';\nimport { blockClass, IWindow, listenerHandler } from '../../../types';\nimport { isBlocked, patch } from '../../../utils';\n\nexport default function initCanvasContextObserver(\n win: IWindow,\n blockClass: blockClass,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n try {\n const restoreHandler = patch(\n win.HTMLCanvasElement.prototype,\n 'getContext',\n function (original) {\n return function (\n this: ICanvas,\n contextType: string,\n ...args: Array\n ) {\n if (!isBlocked((this as unknown) as INode, blockClass)) {\n if (!('__context' in this))\n (this as ICanvas).__context = contextType;\n }\n return original.apply(this, [contextType, ...args]);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n console.error('failed to patch HTMLCanvasElement.prototype.getContext');\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\n\nexport default function initCanvas2DMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n const props2D = Object.getOwnPropertyNames(\n win.CanvasRenderingContext2D.prototype,\n );\n for (const prop of props2D) {\n try {\n if (\n typeof win.CanvasRenderingContext2D.prototype[\n prop as keyof CanvasRenderingContext2D\n ] !== 'function'\n ) {\n continue;\n }\n const restoreHandler = patch(\n win.CanvasRenderingContext2D.prototype,\n prop,\n function (original) {\n return function (\n this: CanvasRenderingContext2D,\n ...args: Array\n ) {\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n // Using setTimeout as getImageData + JSON.stringify can be heavy\n // and we'd rather not block the main thread\n setTimeout(() => {\n const recordArgs = [...args];\n if (prop === 'drawImage') {\n if (\n recordArgs[0] &&\n recordArgs[0] instanceof HTMLCanvasElement\n ) {\n const canvas = recordArgs[0];\n const ctx = canvas.getContext('2d');\n let imgd = ctx?.getImageData(\n 0,\n 0,\n canvas.width,\n canvas.height,\n );\n let pix = imgd?.data;\n recordArgs[0] = JSON.stringify(pix);\n }\n }\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: recordArgs,\n });\n }, 0);\n }\n return original.apply(this, args);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(\n win.CanvasRenderingContext2D.prototype,\n prop,\n {\n set(v) {\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: [v],\n setter: true,\n });\n },\n },\n );\n handlers.push(hookHandler);\n }\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","// \n// An event handler can take an optional event argument\n// and should not return a value\n \n \n\n// An array of all currently registered event handlers for a type\n \n \n// A map of event types and their corresponding event handlers.\n \n \n \n \n\n/** Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nfunction mitt(all ) {\n\tall = all || Object.create(null);\n\n\treturn {\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton: function on(type , handler ) {\n\t\t\t(all[type] || (all[type] = [])).push(handler);\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff: function off(type , handler ) {\n\t\t\tif (all[type]) {\n\t\t\t\tall[type].splice(all[type].indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * @param {String} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit: function emit(type , evt ) {\n\t\t\t(all[type] || []).slice().map(function (handler) { handler(evt); });\n\t\t\t(all['*'] || []).slice().map(function (handler) { handler(type, evt); });\n\t\t}\n\t};\n}\n\nexport default mitt;\n//# sourceMappingURL=mitt.es.js.map\n","/**\n * A fork version of https://github.com/iamdustan/smoothscroll\n * Add support of customize target window and document\n */\n\n// @ts-nocheck\n// tslint:disable\nexport function polyfill(w: Window = window, d = document) {\n // return if scroll behavior is supported and polyfill is not forced\n if (\n 'scrollBehavior' in d.documentElement.style &&\n w.__forceSmoothScrollPolyfill__ !== true\n ) {\n return;\n }\n\n // globals\n var Element = w.HTMLElement || w.Element;\n var SCROLL_TIME = 468;\n\n // object gathering original scroll methods\n var original = {\n scroll: w.scroll || w.scrollTo,\n scrollBy: w.scrollBy,\n elementScroll: Element.prototype.scroll || scrollElement,\n scrollIntoView: Element.prototype.scrollIntoView,\n };\n\n // define timing method\n var now =\n w.performance && w.performance.now\n ? w.performance.now.bind(w.performance)\n : Date.now;\n\n /**\n * indicates if a the current browser is made by Microsoft\n * @method isMicrosoftBrowser\n * @param {String} userAgent\n * @returns {Boolean}\n */\n function isMicrosoftBrowser(userAgent) {\n var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];\n\n return new RegExp(userAgentPatterns.join('|')).test(userAgent);\n }\n\n /*\n * IE has rounding bug rounding down clientHeight and clientWidth and\n * rounding up scrollHeight and scrollWidth causing false positives\n * on hasScrollableSpace\n */\n var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;\n\n /**\n * changes scroll position inside an element\n * @method scrollElement\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function scrollElement(x, y) {\n this.scrollLeft = x;\n this.scrollTop = y;\n }\n\n /**\n * returns result of applying ease math function to a number\n * @method ease\n * @param {Number} k\n * @returns {Number}\n */\n function ease(k) {\n return 0.5 * (1 - Math.cos(Math.PI * k));\n }\n\n /**\n * indicates if a smooth behavior should be applied\n * @method shouldBailOut\n * @param {Number|Object} firstArg\n * @returns {Boolean}\n */\n function shouldBailOut(firstArg) {\n if (\n firstArg === null ||\n typeof firstArg !== 'object' ||\n firstArg.behavior === undefined ||\n firstArg.behavior === 'auto' ||\n firstArg.behavior === 'instant'\n ) {\n // first argument is not an object/null\n // or behavior is auto, instant or undefined\n return true;\n }\n\n if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {\n // first argument is an object and behavior is smooth\n return false;\n }\n\n // throw error when behavior is not supported\n throw new TypeError(\n 'behavior member of ScrollOptions ' +\n firstArg.behavior +\n ' is not a valid value for enumeration ScrollBehavior.',\n );\n }\n\n /**\n * indicates if an element has scrollable space in the provided axis\n * @method hasScrollableSpace\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function hasScrollableSpace(el, axis) {\n if (axis === 'Y') {\n return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;\n }\n\n if (axis === 'X') {\n return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;\n }\n }\n\n /**\n * indicates if an element has a scrollable overflow property in the axis\n * @method canOverflow\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function canOverflow(el, axis) {\n var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];\n\n return overflowValue === 'auto' || overflowValue === 'scroll';\n }\n\n /**\n * indicates if an element can be scrolled in either axis\n * @method isScrollable\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function isScrollable(el) {\n var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');\n var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');\n\n return isScrollableY || isScrollableX;\n }\n\n /**\n * finds scrollable parent of an element\n * @method findScrollableParent\n * @param {Node} el\n * @returns {Node} el\n */\n function findScrollableParent(el) {\n while (el !== d.body && isScrollable(el) === false) {\n el = el.parentNode || el.host;\n }\n\n return el;\n }\n\n /**\n * self invoked function that, given a context, steps through scrolling\n * @method step\n * @param {Object} context\n * @returns {undefined}\n */\n function step(context) {\n var time = now();\n var value;\n var currentX;\n var currentY;\n var elapsed = (time - context.startTime) / SCROLL_TIME;\n\n // avoid elapsed times higher than one\n elapsed = elapsed > 1 ? 1 : elapsed;\n\n // apply easing to elapsed time\n value = ease(elapsed);\n\n currentX = context.startX + (context.x - context.startX) * value;\n currentY = context.startY + (context.y - context.startY) * value;\n\n context.method.call(context.scrollable, currentX, currentY);\n\n // scroll more if we have not reached our destination\n if (currentX !== context.x || currentY !== context.y) {\n w.requestAnimationFrame(step.bind(w, context));\n }\n }\n\n /**\n * scrolls window or element with a smooth behavior\n * @method smoothScroll\n * @param {Object|Node} el\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function smoothScroll(el, x, y) {\n var scrollable;\n var startX;\n var startY;\n var method;\n var startTime = now();\n\n // define scroll context\n if (el === d.body) {\n scrollable = w;\n startX = w.scrollX || w.pageXOffset;\n startY = w.scrollY || w.pageYOffset;\n method = original.scroll;\n } else {\n scrollable = el;\n startX = el.scrollLeft;\n startY = el.scrollTop;\n method = scrollElement;\n }\n\n // scroll looping over a frame\n step({\n scrollable: scrollable,\n method: method,\n startTime: startTime,\n startX: startX,\n startY: startY,\n x: x,\n y: y,\n });\n }\n\n // ORIGINAL METHODS OVERRIDES\n // w.scroll and w.scrollTo\n w.scroll = w.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scroll.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : w.scrollX || w.pageXOffset,\n // use top prop, second argument if present or fallback to scrollY\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : w.scrollY || w.pageYOffset,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : w.scrollX || w.pageXOffset,\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : w.scrollY || w.pageYOffset,\n );\n };\n\n // w.scrollBy\n w.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0])) {\n original.scrollBy.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : 0,\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : 0,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n ~~arguments[0].left + (w.scrollX || w.pageXOffset),\n ~~arguments[0].top + (w.scrollY || w.pageYOffset),\n );\n };\n\n // Element.prototype.scroll and Element.prototype.scrollTo\n Element.prototype.scroll = Element.prototype.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n // if one number is passed, throw error to match Firefox implementation\n if (typeof arguments[0] === 'number' && arguments[1] === undefined) {\n throw new SyntaxError('Value could not be converted');\n }\n\n original.elementScroll.call(\n this,\n // use left prop, first number argument or fallback to scrollLeft\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : typeof arguments[0] !== 'object'\n ? ~~arguments[0]\n : this.scrollLeft,\n // use top prop, second argument or fallback to scrollTop\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : arguments[1] !== undefined\n ? ~~arguments[1]\n : this.scrollTop,\n );\n\n return;\n }\n\n var left = arguments[0].left;\n var top = arguments[0].top;\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n this,\n this,\n typeof left === 'undefined' ? this.scrollLeft : ~~left,\n typeof top === 'undefined' ? this.scrollTop : ~~top,\n );\n };\n\n // Element.prototype.scrollBy\n Element.prototype.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.elementScroll.call(\n this,\n arguments[0].left !== undefined\n ? ~~arguments[0].left + this.scrollLeft\n : ~~arguments[0] + this.scrollLeft,\n arguments[0].top !== undefined\n ? ~~arguments[0].top + this.scrollTop\n : ~~arguments[1] + this.scrollTop,\n );\n\n return;\n }\n\n this.scroll({\n left: ~~arguments[0].left + this.scrollLeft,\n top: ~~arguments[0].top + this.scrollTop,\n behavior: arguments[0].behavior,\n });\n };\n\n // Element.prototype.scrollIntoView\n Element.prototype.scrollIntoView = function () {\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scrollIntoView.call(\n this,\n arguments[0] === undefined ? true : arguments[0],\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n var scrollableParent = findScrollableParent(this);\n var parentRects = scrollableParent.getBoundingClientRect();\n var clientRects = this.getBoundingClientRect();\n\n if (scrollableParent !== d.body) {\n // reveal element inside parent\n smoothScroll.call(\n this,\n scrollableParent,\n scrollableParent.scrollLeft + clientRects.left - parentRects.left,\n scrollableParent.scrollTop + clientRects.top - parentRects.top,\n );\n\n // reveal parent in viewport unless is fixed\n if (w.getComputedStyle(scrollableParent).position !== 'fixed') {\n w.scrollBy({\n left: parentRects.left,\n top: parentRects.top,\n behavior: 'smooth',\n });\n }\n } else {\n // reveal element in viewport\n w.scrollBy({\n left: clientRects.left,\n top: clientRects.top,\n behavior: 'smooth',\n });\n }\n };\n}\n","import {\n actionWithDelay,\n eventWithTime,\n EventType,\n IncrementalSource,\n} from '../types';\n\nexport class Timer {\n public timeOffset: number = 0;\n public speed: number;\n\n private actions: actionWithDelay[];\n private raf: number | null = null;\n private liveMode: boolean;\n\n constructor(actions: actionWithDelay[] = [], speed: number) {\n this.actions = actions;\n this.speed = speed;\n }\n /**\n * Add an action after the timer starts.\n * @param action\n */\n public addAction(action: actionWithDelay) {\n const index = this.findActionIndex(action);\n this.actions.splice(index, 0, action);\n }\n /**\n * Add all actions before the timer starts\n * @param actions\n */\n public addActions(actions: actionWithDelay[]) {\n this.actions = this.actions.concat(actions);\n }\n\n public start() {\n this.timeOffset = 0;\n let lastTimestamp = performance.now();\n const { actions } = this;\n const self = this;\n function check() {\n const time = performance.now();\n self.timeOffset += (time - lastTimestamp) * self.speed;\n lastTimestamp = time;\n while (actions.length) {\n const action = actions[0];\n\n if (self.timeOffset >= action.delay) {\n actions.shift();\n action.doAction();\n } else {\n break;\n }\n }\n if (actions.length > 0 || self.liveMode) {\n self.raf = requestAnimationFrame(check);\n }\n }\n this.raf = requestAnimationFrame(check);\n }\n\n public clear() {\n if (this.raf) {\n cancelAnimationFrame(this.raf);\n this.raf = null;\n }\n this.actions.length = 0;\n }\n\n public setSpeed(speed: number) {\n this.speed = speed;\n }\n\n public toggleLiveMode(mode: boolean) {\n this.liveMode = mode;\n }\n\n public isActive() {\n return this.raf !== null;\n }\n\n private findActionIndex(action: actionWithDelay): number {\n let start = 0;\n let end = this.actions.length - 1;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (this.actions[mid].delay < action.delay) {\n start = mid + 1;\n } else if (this.actions[mid].delay > action.delay) {\n end = mid - 1;\n } else {\n // already an action with same delay (timestamp)\n // the plus one will splice the new one after the existing one\n return mid + 1;\n }\n }\n return start;\n }\n}\n\n// TODO: add speed to mouse move timestamp calculation\nexport function addDelay(event: eventWithTime, baselineTime: number): number {\n // Mouse move events was recorded in a throttle function,\n // so we need to find the real timestamp by traverse the time offsets.\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove\n ) {\n const firstOffset = event.data.positions[0].timeOffset;\n // timeOffset is a negative offset to event.timestamp\n const firstTimestamp = event.timestamp + firstOffset;\n event.delay = firstTimestamp - baselineTime;\n return firstTimestamp - baselineTime;\n }\n\n event.delay = event.timestamp - baselineTime;\n return event.delay;\n}\n","/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return{type:\"xstate.assign\",assignment:t}}function i(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){o=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]=\"function\"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o]})),r=n,!1}return!0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})))},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u=\"object\"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}export{n as InterpreterStatus,o as assign,s as createMachine,v as interpret};\n","import { createMachine, interpret, assign, StateMachine } from '@xstate/fsm';\nimport {\n playerConfig,\n eventWithTime,\n actionWithDelay,\n ReplayerEvents,\n EventType,\n Emitter,\n IncrementalSource,\n} from '../types';\nimport { Timer, addDelay } from './timer';\n\nexport type PlayerContext = {\n events: eventWithTime[];\n timer: Timer;\n timeOffset: number;\n baselineTime: number;\n lastPlayedEvent: eventWithTime | null;\n};\nexport type PlayerEvent =\n | {\n type: 'PLAY';\n payload: {\n timeOffset: number;\n };\n }\n | {\n type: 'CAST_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | { type: 'PAUSE' }\n | { type: 'TO_LIVE'; payload: { baselineTime?: number } }\n | {\n type: 'ADD_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | {\n type: 'END';\n };\nexport type PlayerState =\n | {\n value: 'playing';\n context: PlayerContext;\n }\n | {\n value: 'paused';\n context: PlayerContext;\n }\n | {\n value: 'live';\n context: PlayerContext;\n };\n\n/**\n * If the array have multiple meta and fullsnapshot events,\n * return the events from last meta to the end.\n */\nexport function discardPriorSnapshots(\n events: eventWithTime[],\n baselineTime: number,\n): eventWithTime[] {\n for (let idx = events.length - 1; idx >= 0; idx--) {\n const event = events[idx];\n if (event.type === EventType.Meta) {\n if (event.timestamp <= baselineTime) {\n return events.slice(idx);\n }\n }\n }\n return events;\n}\n\ntype PlayerAssets = {\n emitter: Emitter;\n applyEventsSynchronously(events: Array): void;\n getCastFn(event: eventWithTime, isSync: boolean): () => void;\n};\nexport function createPlayerService(\n context: PlayerContext,\n { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets,\n) {\n const playerMachine = createMachine(\n {\n id: 'player',\n context,\n initial: 'paused',\n states: {\n playing: {\n on: {\n PAUSE: {\n target: 'paused',\n actions: ['pause'],\n },\n CAST_EVENT: {\n target: 'playing',\n actions: 'castEvent',\n },\n END: {\n target: 'paused',\n actions: ['resetLastPlayedEvent', 'pause'],\n },\n ADD_EVENT: {\n target: 'playing',\n actions: ['addEvent'],\n },\n },\n },\n paused: {\n on: {\n PLAY: {\n target: 'playing',\n actions: ['recordTimeOffset', 'play'],\n },\n CAST_EVENT: {\n target: 'paused',\n actions: 'castEvent',\n },\n TO_LIVE: {\n target: 'live',\n actions: ['startLive'],\n },\n ADD_EVENT: {\n target: 'paused',\n actions: ['addEvent'],\n },\n },\n },\n live: {\n on: {\n ADD_EVENT: {\n target: 'live',\n actions: ['addEvent'],\n },\n CAST_EVENT: {\n target: 'live',\n actions: ['castEvent'],\n },\n },\n },\n },\n },\n {\n actions: {\n castEvent: assign({\n lastPlayedEvent: (ctx, event) => {\n if (event.type === 'CAST_EVENT') {\n return event.payload.event;\n }\n return ctx.lastPlayedEvent;\n },\n }),\n recordTimeOffset: assign((ctx, event) => {\n let timeOffset = ctx.timeOffset;\n if ('payload' in event && 'timeOffset' in event.payload) {\n timeOffset = event.payload.timeOffset;\n }\n return {\n ...ctx,\n timeOffset,\n baselineTime: ctx.events[0].timestamp + timeOffset,\n };\n }),\n play(ctx) {\n const { timer, events, baselineTime, lastPlayedEvent } = ctx;\n timer.clear();\n\n for (const event of events) {\n // TODO: improve this API\n addDelay(event, baselineTime);\n }\n const neededEvents = discardPriorSnapshots(events, baselineTime);\n\n let lastPlayedTimestamp = lastPlayedEvent?.timestamp;\n if (\n lastPlayedEvent?.type === EventType.IncrementalSnapshot &&\n lastPlayedEvent.data.source === IncrementalSource.MouseMove\n ) {\n lastPlayedTimestamp =\n lastPlayedEvent.timestamp +\n lastPlayedEvent.data.positions[0]?.timeOffset;\n }\n if (baselineTime < (lastPlayedTimestamp || 0)) {\n emitter.emit(ReplayerEvents.PlayBack);\n }\n\n const syncEvents = new Array();\n const actions = new Array();\n for (const event of neededEvents) {\n if (\n lastPlayedTimestamp &&\n lastPlayedTimestamp < baselineTime &&\n (event.timestamp <= lastPlayedTimestamp ||\n event === lastPlayedEvent)\n ) {\n continue;\n }\n if (event.timestamp < baselineTime) {\n syncEvents.push(event);\n } else {\n const castFn = getCastFn(event, false);\n actions.push({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n applyEventsSynchronously(syncEvents);\n emitter.emit(ReplayerEvents.Flush);\n timer.addActions(actions);\n timer.start();\n },\n pause(ctx) {\n ctx.timer.clear();\n },\n resetLastPlayedEvent: assign((ctx) => {\n return {\n ...ctx,\n lastPlayedEvent: null,\n };\n }),\n startLive: assign({\n baselineTime: (ctx, event) => {\n ctx.timer.toggleLiveMode(true);\n ctx.timer.start();\n if (event.type === 'TO_LIVE' && event.payload.baselineTime) {\n return event.payload.baselineTime;\n }\n return Date.now();\n },\n }),\n addEvent: assign((ctx, machineEvent) => {\n const { baselineTime, timer, events } = ctx;\n if (machineEvent.type === 'ADD_EVENT') {\n const { event } = machineEvent.payload;\n addDelay(event, baselineTime);\n\n let end = events.length - 1;\n if (!events[end] || events[end].timestamp <= event.timestamp) {\n // fast track\n events.push(event);\n } else {\n let insertionIndex = -1;\n let start = 0;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (events[mid].timestamp <= event.timestamp) {\n start = mid + 1;\n } else {\n end = mid - 1;\n }\n }\n if (insertionIndex === -1) {\n insertionIndex = start;\n }\n events.splice(insertionIndex, 0, event);\n }\n\n const isSync = event.timestamp < baselineTime;\n const castFn = getCastFn(event, isSync);\n if (isSync) {\n castFn();\n } else if (timer.isActive()) {\n timer.addAction({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n return { ...ctx, events };\n }),\n },\n },\n );\n return interpret(playerMachine);\n}\n\nexport type SpeedContext = {\n normalSpeed: playerConfig['speed'];\n timer: Timer;\n};\n\nexport type SpeedEvent =\n | {\n type: 'FAST_FORWARD';\n payload: { speed: playerConfig['speed'] };\n }\n | {\n type: 'BACK_TO_NORMAL';\n }\n | {\n type: 'SET_SPEED';\n payload: { speed: playerConfig['speed'] };\n };\n\nexport type SpeedState =\n | {\n value: 'normal';\n context: SpeedContext;\n }\n | {\n value: 'skipping';\n context: SpeedContext;\n };\n\nexport function createSpeedService(context: SpeedContext) {\n const speedMachine = createMachine(\n {\n id: 'speed',\n context,\n initial: 'normal',\n states: {\n normal: {\n on: {\n FAST_FORWARD: {\n target: 'skipping',\n actions: ['recordSpeed', 'setSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n skipping: {\n on: {\n BACK_TO_NORMAL: {\n target: 'normal',\n actions: ['restoreSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n },\n },\n {\n actions: {\n setSpeed: (ctx, event) => {\n if ('payload' in event) {\n ctx.timer.setSpeed(event.payload.speed);\n }\n },\n recordSpeed: assign({\n normalSpeed: (ctx) => ctx.timer.speed,\n }),\n restoreSpeed: (ctx) => {\n ctx.timer.setSpeed(ctx.normalSpeed);\n },\n },\n },\n );\n\n return interpret(speedMachine);\n}\n\nexport type PlayerMachineState = StateMachine.State<\n PlayerContext,\n PlayerEvent,\n PlayerState\n>;\n\nexport type SpeedMachineState = StateMachine.State<\n SpeedContext,\n SpeedEvent,\n SpeedState\n>;\n","const rules: (blockClass: string) => string[] = (blockClass: string) => [\n `.${blockClass} { background: currentColor }`,\n 'noscript { display: none !important; }',\n];\n\nexport default rules;\n","import { INode } from 'rrweb-snapshot';\n\nexport enum StyleRuleType {\n Insert,\n Remove,\n Snapshot,\n SetProperty,\n RemoveProperty,\n}\n\ntype InsertRule = {\n cssText: string;\n type: StyleRuleType.Insert;\n index?: number | number[];\n};\ntype RemoveRule = {\n type: StyleRuleType.Remove;\n index: number | number[];\n};\ntype SnapshotRule = {\n type: StyleRuleType.Snapshot;\n cssTexts: string[];\n};\ntype SetPropertyRule = {\n type: StyleRuleType.SetProperty;\n index: number[];\n property: string;\n value: string | null;\n priority: string | undefined;\n};\ntype RemovePropertyRule = {\n type: StyleRuleType.RemoveProperty;\n index: number[];\n property: string;\n};\n\nexport type VirtualStyleRules = Array<\n InsertRule | RemoveRule | SnapshotRule | SetPropertyRule | RemovePropertyRule\n>;\nexport type VirtualStyleRulesMap = Map;\n\nexport function getNestedRule(\n rules: CSSRuleList,\n position: number[],\n): CSSGroupingRule {\n const rule = rules[position[0]] as CSSGroupingRule;\n if (position.length === 1) {\n return rule;\n } else {\n return getNestedRule(\n ((rule as CSSGroupingRule).cssRules[position[1]] as CSSGroupingRule)\n .cssRules,\n position.slice(2),\n );\n }\n}\n\nexport function getPositionsAndIndex(nestedIndex: number[]) {\n const positions = [...nestedIndex];\n const index = positions.pop();\n return { positions, index };\n}\n\nexport function applyVirtualStyleRulesToNode(\n storedRules: VirtualStyleRules,\n styleNode: HTMLStyleElement,\n) {\n const { sheet } = styleNode;\n if (!sheet) {\n // styleNode without sheet means the DOM has been removed\n // so the rules no longer need to be applied\n return;\n }\n\n storedRules.forEach((rule) => {\n if (rule.type === StyleRuleType.Insert) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.insertRule(rule.cssText, index);\n } else {\n sheet.insertRule(rule.cssText, rule.index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n } else if (rule.type === StyleRuleType.Remove) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.deleteRule(index || 0);\n } else {\n sheet.deleteRule(rule.index);\n }\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else if (rule.type === StyleRuleType.Snapshot) {\n restoreSnapshotOfStyleRulesToNode(rule.cssTexts, styleNode);\n } else if (rule.type === StyleRuleType.SetProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.setProperty(rule.property, rule.value, rule.priority);\n } else if (rule.type === StyleRuleType.RemoveProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.removeProperty(rule.property);\n }\n });\n}\n\nfunction restoreSnapshotOfStyleRulesToNode(\n cssTexts: string[],\n styleNode: HTMLStyleElement,\n) {\n try {\n const existingRules = Array.from(styleNode.sheet?.cssRules || []).map(\n (rule) => rule.cssText,\n );\n const existingRulesReversed = Object.entries(existingRules).reverse();\n let lastMatch = existingRules.length;\n existingRulesReversed.forEach(([index, rule]) => {\n const indexOf = cssTexts.indexOf(rule);\n if (indexOf === -1 || indexOf > lastMatch) {\n try {\n styleNode.sheet?.deleteRule(Number(index));\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n }\n lastMatch = indexOf;\n });\n cssTexts.forEach((cssText, index) => {\n try {\n if (styleNode.sheet?.cssRules[index]?.cssText !== cssText) {\n styleNode.sheet?.insertRule(cssText, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n });\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n\nexport function storeCSSRules(\n parentElement: HTMLStyleElement,\n virtualStyleRulesMap: VirtualStyleRulesMap,\n) {\n try {\n const cssTexts = Array.from(\n (parentElement as HTMLStyleElement).sheet?.cssRules || [],\n ).map((rule) => rule.cssText);\n virtualStyleRulesMap.set((parentElement as unknown) as INode, [\n {\n type: StyleRuleType.Snapshot,\n cssTexts,\n },\n ]);\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n","import { decode } from 'base64-arraybuffer';\nimport { Replayer } from '../';\nimport {\n CanvasContext,\n canvasMutationCommand,\n SerializedWebGlArg,\n} from '../../types';\n\n// TODO: add ability to wipe this list\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nfunction getContext(\n target: HTMLCanvasElement,\n type: CanvasContext,\n): WebGLRenderingContext | WebGL2RenderingContext | null {\n // Note to whomever is going to implement support for `contextAttributes`:\n // if `preserveDrawingBuffer` is set to true,\n // you might have to do `ctx.flush()` before every webgl canvas event\n try {\n if (type === CanvasContext.WebGL) {\n return (\n target.getContext('webgl')! || target.getContext('experimental-webgl')\n );\n }\n return target.getContext('webgl2')!;\n } catch (e) {\n return null;\n }\n}\n\nconst WebGLVariableConstructorsNames = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n];\n\nfunction saveToWebGLVarMap(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n result: any,\n) {\n if (!result?.constructor) return; // probably null or undefined\n\n const { name } = result.constructor;\n if (!WebGLVariableConstructorsNames.includes(name)) return; // not a WebGL variable\n\n const variables = variableListFor(ctx, name);\n if (!variables.includes(result)) variables.push(result);\n}\n\nexport function deserializeArg(\n imageMap: Replayer['imageMap'],\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n): (arg: SerializedWebGlArg) => any {\n return (arg: SerializedWebGlArg): any => {\n if (arg && typeof arg === 'object' && 'rr_type' in arg) {\n if ('index' in arg) {\n const { rr_type: name, index } = arg;\n return variableListFor(ctx, name)[index];\n } else if ('args' in arg) {\n const { rr_type: name, args } = arg;\n const ctor = window[name as keyof Window];\n\n return new ctor(...args.map(deserializeArg(imageMap, ctx)));\n } else if ('base64' in arg) {\n return decode(arg.base64);\n } else if ('src' in arg) {\n const image = imageMap.get(arg.src);\n if (image) {\n return image;\n } else {\n const image = new Image();\n image.src = arg.src;\n imageMap.set(arg.src, image);\n return image;\n }\n }\n } else if (Array.isArray(arg)) {\n return arg.map(deserializeArg(imageMap, ctx));\n }\n return arg;\n };\n}\n\nexport default function webglMutation({\n mutation,\n target,\n type,\n imageMap,\n errorHandler,\n}: {\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n type: CanvasContext;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = getContext(target, type);\n if (!ctx) return;\n\n // NOTE: if `preserveDrawingBuffer` is set to true,\n // we must flush the buffers on every new canvas event\n // if (mutation.newFrame) ctx.flush();\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n const args = mutation.args.map(deserializeArg(imageMap, ctx));\n const result = original.apply(ctx, args);\n saveToWebGLVarMap(ctx, result);\n\n // Slows down replay considerably, only use for debugging\n const debugMode = false;\n if (debugMode) {\n if (mutation.property === 'compileShader') {\n if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getShaderInfoLog(args[0]),\n );\n } else if (mutation.property === 'linkProgram') {\n ctx.validateProgram(args[0]);\n if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getProgramInfoLog(args[0]),\n );\n }\n const webglError = ctx.getError();\n if (webglError !== ctx.NO_ERROR) {\n console.warn(\n 'WEBGL ERROR',\n webglError,\n 'on command:',\n mutation.property,\n ...args,\n );\n }\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import {\n rebuild,\n buildNodeWithSN,\n INode,\n NodeType,\n BuildCache,\n createCache,\n} from 'rrweb-snapshot';\nimport * as mittProxy from 'mitt';\nimport { polyfill as smoothscrollPolyfill } from './smoothscroll';\nimport { Timer } from './timer';\nimport { createPlayerService, createSpeedService } from './machine';\nimport {\n EventType,\n IncrementalSource,\n fullSnapshotEvent,\n eventWithTime,\n MouseInteractions,\n playerConfig,\n playerMetaData,\n viewportResizeDimension,\n missingNodeMap,\n addedNodeMutation,\n missingNode,\n incrementalSnapshotEvent,\n incrementalData,\n ReplayerEvents,\n Handler,\n Emitter,\n MediaInteractions,\n metaEvent,\n mutationData,\n scrollData,\n inputData,\n canvasMutationData,\n Mirror,\n ElementState,\n styleAttributeValue,\n styleValueWithPriority,\n mouseMovePos,\n IWindow,\n canvasMutationCommand,\n textMutation,\n} from '../types';\nimport {\n createMirror,\n polyfill,\n TreeIndex,\n queueToResolveTrees,\n iterateResolveTree,\n AppendedIframe,\n isIframeINode,\n getBaseDimension,\n hasShadowRoot,\n} from '../utils';\nimport getInjectStyleRules from './styles/inject-style';\nimport './styles/style.css';\nimport {\n applyVirtualStyleRulesToNode,\n storeCSSRules,\n StyleRuleType,\n VirtualStyleRules,\n VirtualStyleRulesMap,\n getNestedRule,\n getPositionsAndIndex,\n} from './virtual-styles';\nimport canvasMutation from './canvas';\n\nconst SKIP_TIME_THRESHOLD = 10 * 1000;\nconst SKIP_TIME_INTERVAL = 5 * 1000;\n\n// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734\n// tslint:disable-next-line\nconst mitt = (mittProxy as any).default || mittProxy;\n\nconst REPLAY_CONSOLE_PREFIX = '[replayer]';\n\nconst defaultMouseTailConfig = {\n duration: 500,\n lineCap: 'round',\n lineWidth: 3,\n strokeStyle: 'red',\n} as const;\n\nfunction indicatesTouchDevice(e: eventWithTime) {\n return (\n e.type == EventType.IncrementalSnapshot &&\n (e.data.source == IncrementalSource.TouchMove ||\n (e.data.source == IncrementalSource.MouseInteraction &&\n e.data.type == MouseInteractions.TouchStart))\n );\n}\n\nexport class Replayer {\n public wrapper: HTMLDivElement;\n public iframe: HTMLIFrameElement;\n\n public service: ReturnType;\n public speedService: ReturnType;\n public get timer() {\n return this.service.state.context.timer;\n }\n\n public config: playerConfig;\n\n private mouse: HTMLDivElement;\n private mouseTail: HTMLCanvasElement | null = null;\n private tailPositions: Array<{ x: number; y: number }> = [];\n\n private emitter: Emitter = mitt();\n\n private nextUserInteractionEvent: eventWithTime | null;\n\n // tslint:disable-next-line: variable-name\n private legacy_missingNodeRetryMap: missingNodeMap = {};\n\n private treeIndex!: TreeIndex;\n private fragmentParentMap!: Map;\n private elementStateMap!: Map;\n // Hold the list of CSSRules for in-memory state restoration\n private virtualStyleRulesMap!: VirtualStyleRulesMap;\n\n // The replayer uses the cache to speed up replay and scrubbing.\n private cache: BuildCache = createCache();\n\n private imageMap: Map = new Map();\n\n private mirror: Mirror = createMirror();\n\n private firstFullSnapshot: eventWithTime | true | null = null;\n\n private newDocumentQueue: addedNodeMutation[] = [];\n\n private mousePos: mouseMovePos | null = null;\n private touchActive: boolean | null = null;\n\n constructor(\n events: Array,\n config?: Partial,\n ) {\n if (!config?.liveMode && events.length < 2) {\n throw new Error('Replayer need at least 2 events.');\n }\n const defaultConfig: playerConfig = {\n speed: 1,\n maxSpeed: 360,\n root: document.body,\n loadTimeout: 0,\n skipInactive: false,\n showWarning: true,\n showDebug: false,\n blockClass: 'rr-block',\n liveMode: false,\n insertStyleRules: [],\n triggerFocus: true,\n UNSAFE_replayCanvas: false,\n pauseAnimation: true,\n mouseTail: defaultMouseTailConfig,\n };\n this.config = Object.assign({}, defaultConfig, config);\n\n this.handleResize = this.handleResize.bind(this);\n this.getCastFn = this.getCastFn.bind(this);\n this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);\n this.emitter.on(ReplayerEvents.Resize, this.handleResize as Handler);\n\n this.setupDom();\n\n this.treeIndex = new TreeIndex();\n this.fragmentParentMap = new Map();\n this.elementStateMap = new Map();\n this.virtualStyleRulesMap = new Map();\n\n this.emitter.on(ReplayerEvents.Flush, () => {\n const { scrollMap, inputMap, mutationData } = this.treeIndex.flush();\n\n this.fragmentParentMap.forEach((parent, frag) =>\n this.restoreRealParent(frag, parent),\n );\n // apply text needs to happen before virtual style rules gets applied\n // as it can overwrite the contents of a stylesheet\n for (const d of mutationData.texts) {\n this.applyText(d, mutationData);\n }\n\n for (const node of this.virtualStyleRulesMap.keys()) {\n // restore css rules of style elements after they are mounted\n this.restoreNodeSheet(node);\n }\n this.fragmentParentMap.clear();\n this.elementStateMap.clear();\n this.virtualStyleRulesMap.clear();\n\n for (const d of scrollMap.values()) {\n this.applyScroll(d, true);\n }\n for (const d of inputMap.values()) {\n this.applyInput(d);\n }\n });\n this.emitter.on(ReplayerEvents.PlayBack, () => {\n this.firstFullSnapshot = null;\n this.mirror.reset();\n });\n\n const timer = new Timer([], config?.speed || defaultConfig.speed);\n this.service = createPlayerService(\n {\n events: events\n .map((e) => {\n if (config && config.unpackFn) {\n return config.unpackFn(e as string);\n }\n return e as eventWithTime;\n })\n .sort((a1, a2) => a1.timestamp - a2.timestamp),\n timer,\n timeOffset: 0,\n baselineTime: 0,\n lastPlayedEvent: null,\n },\n {\n getCastFn: this.getCastFn,\n applyEventsSynchronously: this.applyEventsSynchronously,\n emitter: this.emitter,\n },\n );\n this.service.start();\n this.service.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n player: state,\n });\n });\n this.speedService = createSpeedService({\n normalSpeed: -1,\n timer,\n });\n this.speedService.start();\n this.speedService.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n speed: state,\n });\n });\n\n // rebuild first full snapshot as the poster of the player\n // maybe we can cache it for performance optimization\n const firstMeta = this.service.state.context.events.find(\n (e) => e.type === EventType.Meta,\n );\n const firstFullsnapshot = this.service.state.context.events.find(\n (e) => e.type === EventType.FullSnapshot,\n );\n if (firstMeta) {\n const { width, height } = firstMeta.data as metaEvent['data'];\n setTimeout(() => {\n this.emitter.emit(ReplayerEvents.Resize, {\n width,\n height,\n });\n }, 0);\n }\n if (firstFullsnapshot) {\n setTimeout(() => {\n // when something has been played, there is no need to rebuild poster\n if (this.firstFullSnapshot) {\n // true if any other fullSnapshot has been executed by Timer already\n return;\n }\n this.firstFullSnapshot = firstFullsnapshot;\n this.rebuildFullSnapshot(\n firstFullsnapshot as fullSnapshotEvent & { timestamp: number },\n );\n this.iframe.contentWindow!.scrollTo(\n (firstFullsnapshot as fullSnapshotEvent).data.initialOffset,\n );\n }, 1);\n }\n if (this.service.state.context.events.find(indicatesTouchDevice)) {\n this.mouse.classList.add('touch-device');\n }\n }\n\n public on(event: string, handler: Handler) {\n this.emitter.on(event, handler);\n return this;\n }\n\n public off(event: string, handler: Handler) {\n this.emitter.off(event, handler);\n return this;\n }\n\n public setConfig(config: Partial) {\n Object.keys(config).forEach((key) => {\n // @ts-ignore\n this.config[key] = config[key];\n });\n if (!this.config.skipInactive) {\n this.backToNormal();\n }\n if (typeof config.speed !== 'undefined') {\n this.speedService.send({\n type: 'SET_SPEED',\n payload: {\n speed: config.speed!,\n },\n });\n }\n if (typeof config.mouseTail !== 'undefined') {\n if (config.mouseTail === false) {\n if (this.mouseTail) {\n this.mouseTail.style.display = 'none';\n }\n } else {\n if (!this.mouseTail) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.width = Number.parseFloat(this.iframe.width);\n this.mouseTail.height = Number.parseFloat(this.iframe.height);\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.wrapper.insertBefore(this.mouseTail, this.iframe);\n }\n this.mouseTail.style.display = 'inherit';\n }\n }\n }\n\n public getMetaData(): playerMetaData {\n const firstEvent = this.service.state.context.events[0];\n const lastEvent = this.service.state.context.events[\n this.service.state.context.events.length - 1\n ];\n return {\n startTime: firstEvent.timestamp,\n endTime: lastEvent.timestamp,\n totalTime: lastEvent.timestamp - firstEvent.timestamp,\n };\n }\n\n public getCurrentTime(): number {\n return this.timer.timeOffset + this.getTimeOffset();\n }\n\n public getTimeOffset(): number {\n const { baselineTime, events } = this.service.state.context;\n return baselineTime - events[0].timestamp;\n }\n\n public getMirror(): Mirror {\n return this.mirror;\n }\n\n /**\n * This API was designed to be used as play at any time offset.\n * Since we minimized the data collected from recorder, we do not\n * have the ability of undo an event.\n * So the implementation of play at any time offset will always iterate\n * all of the events, cast event before the offset synchronously\n * and cast event after the offset asynchronously with timer.\n * @param timeOffset number\n */\n public play(timeOffset = 0) {\n if (this.service.state.matches('paused')) {\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n } else {\n this.service.send({ type: 'PAUSE' });\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.remove('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Start);\n }\n\n public pause(timeOffset?: number) {\n if (timeOffset === undefined && this.service.state.matches('playing')) {\n this.service.send({ type: 'PAUSE' });\n }\n if (typeof timeOffset === 'number') {\n this.play(timeOffset);\n this.service.send({ type: 'PAUSE' });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Pause);\n }\n\n public resume(timeOffset = 0) {\n console.warn(\n `The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.`,\n );\n this.play(timeOffset);\n this.emitter.emit(ReplayerEvents.Resume);\n }\n\n public startLive(baselineTime?: number) {\n this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });\n }\n\n public addEvent(rawEvent: eventWithTime | string) {\n const event = this.config.unpackFn\n ? this.config.unpackFn(rawEvent as string)\n : (rawEvent as eventWithTime);\n if (indicatesTouchDevice(event)) {\n this.mouse.classList.add('touch-device');\n }\n Promise.resolve().then(() =>\n this.service.send({ type: 'ADD_EVENT', payload: { event } }),\n );\n }\n\n public enableInteract() {\n this.iframe.setAttribute('scrolling', 'auto');\n this.iframe.style.pointerEvents = 'auto';\n }\n\n public disableInteract() {\n this.iframe.setAttribute('scrolling', 'no');\n this.iframe.style.pointerEvents = 'none';\n }\n\n /**\n * Empties the replayer's cache and reclaims memory.\n * The replayer will use this cache to speed up the playback.\n */\n public resetCache() {\n this.cache = createCache();\n }\n\n private setupDom() {\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add('replayer-wrapper');\n this.config.root!.appendChild(this.wrapper);\n\n this.mouse = document.createElement('div');\n this.mouse.classList.add('replayer-mouse');\n this.wrapper.appendChild(this.mouse);\n\n if (this.config.mouseTail !== false) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.mouseTail.style.display = 'inherit';\n this.wrapper.appendChild(this.mouseTail);\n }\n\n this.iframe = document.createElement('iframe');\n const attributes = ['allow-same-origin'];\n if (this.config.UNSAFE_replayCanvas) {\n attributes.push('allow-scripts');\n }\n // hide iframe before first meta event\n this.iframe.style.display = 'none';\n this.iframe.setAttribute('sandbox', attributes.join(' '));\n this.disableInteract();\n this.wrapper.appendChild(this.iframe);\n if (this.iframe.contentWindow && this.iframe.contentDocument) {\n smoothscrollPolyfill(\n this.iframe.contentWindow,\n this.iframe.contentDocument,\n );\n\n polyfill(this.iframe.contentWindow as IWindow);\n }\n }\n\n private handleResize(dimension: viewportResizeDimension) {\n this.iframe.style.display = 'inherit';\n for (const el of [this.mouseTail, this.iframe]) {\n if (!el) {\n continue;\n }\n el.setAttribute('width', String(dimension.width));\n el.setAttribute('height', String(dimension.height));\n }\n }\n\n private applyEventsSynchronously(events: Array) {\n for (const event of events) {\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n case EventType.Custom:\n continue;\n case EventType.FullSnapshot:\n case EventType.Meta:\n case EventType.Plugin:\n break;\n case EventType.IncrementalSnapshot:\n switch (event.data.source) {\n case IncrementalSource.MediaInteraction:\n continue;\n default:\n break;\n }\n break;\n default:\n break;\n }\n const castFn = this.getCastFn(event, true);\n castFn();\n }\n if (this.mousePos) {\n this.moveAndHover(\n this.mousePos.x,\n this.mousePos.y,\n this.mousePos.id,\n true,\n this.mousePos.debugData,\n );\n }\n this.mousePos = null;\n if (this.touchActive === true) {\n this.mouse.classList.add('touch-active');\n } else if (this.touchActive === false) {\n this.mouse.classList.remove('touch-active');\n }\n this.touchActive = null;\n }\n\n private getCastFn(event: eventWithTime, isSync = false) {\n let castFn: undefined | (() => void);\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n break;\n case EventType.Custom:\n castFn = () => {\n /**\n * emit custom-event and pass the event object.\n *\n * This will add more value to the custom event and allows the client to react for custom-event.\n */\n this.emitter.emit(ReplayerEvents.CustomEvent, event);\n };\n break;\n case EventType.Meta:\n castFn = () =>\n this.emitter.emit(ReplayerEvents.Resize, {\n width: event.data.width,\n height: event.data.height,\n });\n break;\n case EventType.FullSnapshot:\n castFn = () => {\n if (this.firstFullSnapshot) {\n if (this.firstFullSnapshot === event) {\n // we've already built this exact FullSnapshot when the player was mounted, and haven't built any other FullSnapshot since\n this.firstFullSnapshot = true; // forget as we might need to re-execute this FullSnapshot later e.g. to rebuild after scrubbing\n return;\n }\n } else {\n // Timer (requestAnimationFrame) can be faster than setTimeout(..., 1)\n this.firstFullSnapshot = true;\n }\n this.rebuildFullSnapshot(event, isSync);\n this.iframe.contentWindow!.scrollTo(event.data.initialOffset);\n };\n break;\n case EventType.IncrementalSnapshot:\n castFn = () => {\n this.applyIncremental(event, isSync);\n if (isSync) {\n // do not check skip in sync\n return;\n }\n if (event === this.nextUserInteractionEvent) {\n this.nextUserInteractionEvent = null;\n this.backToNormal();\n }\n if (this.config.skipInactive && !this.nextUserInteractionEvent) {\n for (const _event of this.service.state.context.events) {\n if (_event.timestamp! <= event.timestamp!) {\n continue;\n }\n if (this.isUserInteraction(_event)) {\n if (\n _event.delay! - event.delay! >\n SKIP_TIME_THRESHOLD *\n this.speedService.state.context.timer.speed\n ) {\n this.nextUserInteractionEvent = _event;\n }\n break;\n }\n }\n if (this.nextUserInteractionEvent) {\n const skipTime =\n this.nextUserInteractionEvent.delay! - event.delay!;\n const payload = {\n speed: Math.min(\n Math.round(skipTime / SKIP_TIME_INTERVAL),\n this.config.maxSpeed,\n ),\n };\n this.speedService.send({ type: 'FAST_FORWARD', payload });\n this.emitter.emit(ReplayerEvents.SkipStart, payload);\n }\n }\n };\n break;\n default:\n }\n const wrappedCastFn = () => {\n if (castFn) {\n castFn();\n }\n\n for (const plugin of this.config.plugins || []) {\n plugin.handler(event, isSync, { replayer: this });\n }\n\n this.service.send({ type: 'CAST_EVENT', payload: { event } });\n\n // events are kept sorted by timestamp, check if this is the last event\n let last_index = this.service.state.context.events.length - 1;\n if (event === this.service.state.context.events[last_index]) {\n const finish = () => {\n if (last_index < this.service.state.context.events.length - 1) {\n // more events have been added since the setTimeout\n return;\n }\n this.backToNormal();\n this.service.send('END');\n this.emitter.emit(ReplayerEvents.Finish);\n };\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove &&\n event.data.positions.length\n ) {\n // defer finish event if the last event is a mouse move\n setTimeout(() => {\n finish();\n }, Math.max(0, -event.data.positions[0].timeOffset + 50)); // Add 50 to make sure the timer would check the last mousemove event. Otherwise, the timer may be stopped by the service before checking the last event.\n } else {\n finish();\n }\n }\n\n this.emitter.emit(ReplayerEvents.EventCast, event);\n };\n return wrappedCastFn;\n }\n\n private rebuildFullSnapshot(\n event: fullSnapshotEvent & { timestamp: number },\n isSync: boolean = false,\n ) {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n console.warn(\n 'Found unresolved missing node map',\n this.legacy_missingNodeRetryMap,\n );\n }\n this.legacy_missingNodeRetryMap = {};\n const collected: AppendedIframe[] = [];\n this.mirror.map = rebuild(event.data.node, {\n doc: this.iframe.contentDocument,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n },\n cache: this.cache,\n })[1];\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n const { documentElement, head } = this.iframe.contentDocument;\n this.insertStyleRules(documentElement, head);\n if (!this.service.state.matches('playing')) {\n this.iframe.contentDocument\n .getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n }\n this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);\n if (!isSync) {\n this.waitForStylesheetLoad();\n }\n if (this.config.UNSAFE_replayCanvas) {\n this.preloadAllImages();\n }\n }\n\n private insertStyleRules(\n documentElement: HTMLElement,\n head: HTMLHeadElement,\n ) {\n const styleEl = document.createElement('style');\n documentElement!.insertBefore(styleEl, head);\n const injectStylesRules = getInjectStyleRules(\n this.config.blockClass,\n ).concat(this.config.insertStyleRules);\n if (this.config.pauseAnimation) {\n injectStylesRules.push(\n 'html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }',\n );\n }\n for (let idx = 0; idx < injectStylesRules.length; idx++) {\n (styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);\n }\n }\n\n private attachDocumentToIframe(\n mutation: addedNodeMutation,\n iframeEl: HTMLIFrameElement,\n ) {\n const collected: AppendedIframe[] = [];\n // If iframeEl is detached from dom, iframeEl.contentDocument is null.\n if (!iframeEl.contentDocument) {\n let parent = iframeEl.parentNode;\n while (parent) {\n // The parent of iframeEl is virtual parent and we need to mount it on the dom.\n if (this.fragmentParentMap.has((parent as unknown) as INode)) {\n const frag = (parent as unknown) as INode;\n const realParent = this.fragmentParentMap.get(frag)!;\n this.restoreRealParent(frag, realParent);\n break;\n }\n parent = parent.parentNode;\n }\n }\n buildNodeWithSN(mutation.node, {\n doc: iframeEl.contentDocument!,\n map: this.mirror.map,\n hackCss: true,\n skipChild: false,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n if (\n builtNode.__sn.type === NodeType.Element &&\n builtNode.__sn.tagName.toUpperCase() === 'HTML'\n ) {\n const { documentElement, head } = iframeEl.contentDocument!;\n this.insertStyleRules(documentElement, head);\n }\n },\n cache: this.cache,\n });\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n private collectIframeAndAttachDocument(\n collected: AppendedIframe[],\n builtNode: INode,\n ) {\n if (isIframeINode(builtNode)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === builtNode.__sn.id,\n );\n if (mutationInQueue) {\n collected.push({ mutationInQueue, builtNode });\n }\n }\n }\n\n /**\n * pause when loading style sheet, resume when loaded all timeout exceed\n */\n private waitForStylesheetLoad() {\n const head = this.iframe.contentDocument?.head;\n if (head) {\n const unloadSheets: Set = new Set();\n let timer: ReturnType | -1;\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n const unsubscribe = () => {\n this.emitter.off(ReplayerEvents.Start, stateHandler);\n this.emitter.off(ReplayerEvents.Pause, stateHandler);\n };\n head\n .querySelectorAll('link[rel=\"stylesheet\"]')\n .forEach((css: HTMLLinkElement) => {\n if (!css.sheet) {\n unloadSheets.add(css);\n css.addEventListener('load', () => {\n unloadSheets.delete(css);\n // all loaded and timer not released yet\n if (unloadSheets.size === 0 && timer !== -1) {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);\n if (timer) {\n clearTimeout(timer);\n }\n unsubscribe();\n }\n });\n }\n });\n\n if (unloadSheets.size > 0) {\n // find some unload sheets after iterate\n this.service.send({ type: 'PAUSE' });\n this.emitter.emit(ReplayerEvents.LoadStylesheetStart);\n timer = setTimeout(() => {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n // mark timer was called\n timer = -1;\n unsubscribe();\n }, this.config.loadTimeout);\n }\n }\n }\n\n private hasImageArg(args: any[]): boolean {\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n if (this.hasImageArg(arg.args)) return true;\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n return true; // has image!\n } else if (arg instanceof Array) {\n if (this.hasImageArg(arg)) return true;\n }\n }\n return false;\n }\n\n private getImageArgs(args: any[]): string[] {\n const images: string[] = [];\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n images.push(...this.getImageArgs(arg.args));\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n images.push(arg.src);\n } else if (arg instanceof Array) {\n images.push(...this.getImageArgs(arg));\n }\n }\n return images;\n }\n\n /**\n * pause when there are some canvas drawImage args need to be loaded\n */\n private preloadAllImages() {\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n for (const event of this.service.state.context.events) {\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.CanvasMutation\n )\n if ('commands' in event.data) {\n event.data.commands.forEach((c) => this.preloadImages(c, event));\n } else {\n this.preloadImages(event.data, event);\n }\n }\n }\n\n private preloadImages(data: canvasMutationCommand, event: eventWithTime) {\n if (\n data.property === 'drawImage' &&\n typeof data.args[0] === 'string' &&\n !this.imageMap.has(event)\n ) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const imgd = ctx?.createImageData(canvas.width, canvas.height);\n let d = imgd?.data;\n d = JSON.parse(data.args[0]);\n ctx?.putImageData(imgd!, 0, 0);\n } else if (this.hasImageArg(data.args)) {\n this.getImageArgs(data.args).forEach((url) => {\n const image = new Image();\n image.src = url; // this preloads the image\n this.imageMap.set(url, image);\n });\n }\n }\n\n private applyIncremental(\n e: incrementalSnapshotEvent & { timestamp: number; delay?: number },\n isSync: boolean,\n ) {\n const { data: d } = e;\n switch (d.source) {\n case IncrementalSource.Mutation: {\n if (isSync) {\n d.adds.forEach((m) => this.treeIndex.add(m));\n d.texts.forEach((m) => {\n const target = this.mirror.getNode(m.id);\n const parent = (target?.parentNode as unknown) as INode | null;\n // remove any style rules that pending\n // for stylesheets where the contents get replaced\n if (parent && this.virtualStyleRulesMap.has(parent))\n this.virtualStyleRulesMap.delete(parent);\n\n this.treeIndex.text(m);\n });\n d.attributes.forEach((m) => this.treeIndex.attribute(m));\n d.removes.forEach((m) => this.treeIndex.remove(m, this.mirror));\n }\n try {\n this.applyMutation(d, isSync);\n } catch (error) {\n this.warn(`Exception in mutation ${error.message || error}`, d);\n }\n break;\n }\n case IncrementalSource.Drag:\n case IncrementalSource.TouchMove:\n case IncrementalSource.MouseMove:\n if (isSync) {\n const lastPosition = d.positions[d.positions.length - 1];\n this.mousePos = {\n x: lastPosition.x,\n y: lastPosition.y,\n id: lastPosition.id,\n debugData: d,\n };\n } else {\n d.positions.forEach((p) => {\n const action = {\n doAction: () => {\n this.moveAndHover(p.x, p.y, p.id, isSync, d);\n },\n delay:\n p.timeOffset +\n e.timestamp -\n this.service.state.context.baselineTime,\n };\n this.timer.addAction(action);\n });\n // add a dummy action to keep timer alive\n this.timer.addAction({\n doAction() {},\n delay: e.delay! - d.positions[0]?.timeOffset,\n });\n }\n break;\n case IncrementalSource.MouseInteraction: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n const event = new Event(MouseInteractions[d.type].toLowerCase());\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n this.emitter.emit(ReplayerEvents.MouseInteraction, {\n type: d.type,\n target,\n });\n const { triggerFocus } = this.config;\n switch (d.type) {\n case MouseInteractions.Blur:\n if ('blur' in ((target as Node) as HTMLElement)) {\n ((target as Node) as HTMLElement).blur();\n }\n break;\n case MouseInteractions.Focus:\n if (triggerFocus && ((target as Node) as HTMLElement).focus) {\n ((target as Node) as HTMLElement).focus({\n preventScroll: true,\n });\n }\n break;\n case MouseInteractions.Click:\n case MouseInteractions.TouchStart:\n case MouseInteractions.TouchEnd:\n if (isSync) {\n if (d.type === MouseInteractions.TouchStart) {\n this.touchActive = true;\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.touchActive = false;\n }\n this.mousePos = {\n x: d.x,\n y: d.y,\n id: d.id,\n debugData: d,\n };\n } else {\n if (d.type === MouseInteractions.TouchStart) {\n // don't draw a trail as user has lifted finger and is placing at a new point\n this.tailPositions.length = 0;\n }\n this.moveAndHover(d.x, d.y, d.id, isSync, d);\n if (d.type === MouseInteractions.Click) {\n /*\n * don't want target.click() here as could trigger an iframe navigation\n * instead any effects of the click should already be covered by mutations\n */\n /*\n * removal and addition of .active class (along with void line to trigger repaint)\n * triggers the 'click' css animation in styles/style.css\n */\n this.mouse.classList.remove('active');\n // tslint:disable-next-line\n void this.mouse.offsetWidth;\n this.mouse.classList.add('active');\n } else if (d.type === MouseInteractions.TouchStart) {\n void this.mouse.offsetWidth; // needed for the position update of moveAndHover to apply without the .touch-active transition\n this.mouse.classList.add('touch-active');\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.mouse.classList.remove('touch-active');\n }\n }\n break;\n case MouseInteractions.TouchCancel:\n if (isSync) {\n this.touchActive = false;\n } else {\n this.mouse.classList.remove('touch-active');\n }\n break;\n default:\n target.dispatchEvent(event);\n }\n break;\n }\n case IncrementalSource.Scroll: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.scroll(d);\n break;\n }\n this.applyScroll(d, false);\n break;\n }\n case IncrementalSource.ViewportResize:\n this.emitter.emit(ReplayerEvents.Resize, {\n width: d.width,\n height: d.height,\n });\n break;\n case IncrementalSource.Input: {\n /**\n * Input event on an unserialized node usually means the event\n * was synchrony triggered programmatically after the node was\n * created. This means there was not an user observable interaction\n * and we do not need to replay it.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.input(d);\n break;\n }\n this.applyInput(d);\n break;\n }\n case IncrementalSource.MediaInteraction: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n const mediaEl = (target as Node) as HTMLMediaElement;\n try {\n if (d.currentTime) {\n mediaEl.currentTime = d.currentTime;\n }\n if (d.volume) {\n mediaEl.volume = d.volume;\n }\n if (d.muted) {\n mediaEl.muted = d.muted;\n }\n if (d.type === MediaInteractions.Pause) {\n mediaEl.pause();\n }\n if (d.type === MediaInteractions.Play) {\n // remove listener for 'canplay' event because play() is async and returns a promise\n // i.e. media will evntualy start to play when data is loaded\n // 'canplay' event fires even when currentTime attribute changes which may lead to\n // unexpeted behavior\n mediaEl.play();\n }\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n `Failed to replay media interactions: ${error.message || error}`,\n );\n }\n }\n break;\n }\n case IncrementalSource.StyleSheetRule: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n /**\n * Always use existing DOM node, when it's there.\n * In in-memory replay, there is virtual node, but it's `sheet` is inaccessible.\n * Hence, we buffer all style changes in virtualStyleRulesMap.\n */\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules;\n\n if (!styleSheet) {\n /**\n * styleEl.sheet is only accessible if the styleEl is part of the\n * dom. This doesn't work on DocumentFragments so we have to add the\n * style mutations to the virtualStyleRulesMap.\n */\n\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.adds) {\n d.adds.forEach(({ rule, index: nestedIndex }) => {\n if (styleSheet) {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet.cssRules,\n positions,\n );\n nestedRule.insertRule(rule, index);\n } else {\n const index =\n nestedIndex === undefined\n ? undefined\n : Math.min(nestedIndex, styleSheet.cssRules.length);\n styleSheet.insertRule(rule, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else {\n rules?.push({\n cssText: rule,\n index: nestedIndex,\n type: StyleRuleType.Insert,\n });\n }\n });\n }\n\n if (d.removes) {\n d.removes.forEach(({ index: nestedIndex }) => {\n if (usingVirtualParent) {\n rules?.push({ index: nestedIndex, type: StyleRuleType.Remove });\n } else {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet!.cssRules,\n positions,\n );\n nestedRule.deleteRule(index || 0);\n } else {\n styleSheet?.deleteRule(nestedIndex);\n }\n } catch (e) {\n /**\n * same as insertRule\n */\n }\n }\n });\n }\n break;\n }\n case IncrementalSource.StyleDeclaration: {\n // same with StyleSheetRule\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules = [];\n\n if (!styleSheet) {\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.set) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.setProperty(d.set.property, d.set.value, d.set.priority);\n } else {\n rules.push({\n type: StyleRuleType.SetProperty,\n index: d.index,\n ...d.set,\n });\n }\n }\n\n if (d.remove) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.removeProperty(d.remove.property);\n } else {\n rules.push({\n type: StyleRuleType.RemoveProperty,\n index: d.index,\n ...d.remove,\n });\n }\n }\n break;\n }\n case IncrementalSource.CanvasMutation: {\n if (!this.config.UNSAFE_replayCanvas) {\n return;\n }\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n canvasMutation({\n event: e,\n mutation: d,\n target: (target as unknown) as HTMLCanvasElement,\n imageMap: this.imageMap,\n errorHandler: this.warnCanvasMutationFailed.bind(this),\n });\n\n break;\n }\n case IncrementalSource.Font: {\n try {\n const fontFace = new FontFace(\n d.family,\n d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource,\n d.descriptors,\n );\n this.iframe.contentDocument?.fonts.add(fontFace);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(error);\n }\n }\n break;\n }\n default:\n }\n }\n\n private applyMutation(d: mutationData, useVirtualParent: boolean) {\n d.removes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.parentId)) {\n // no need to warn, parent was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.virtualStyleRulesMap.has(target)) {\n this.virtualStyleRulesMap.delete(target);\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n return this.warnNodeNotFound(d, mutation.parentId);\n }\n if (mutation.isShadow && hasShadowRoot(parent)) {\n parent = parent.shadowRoot;\n }\n // target may be removed with its parents before\n this.mirror.removeNodeFromMap(target);\n if (parent) {\n let realTarget = null;\n const realParent =\n '__sn' in parent ? this.fragmentParentMap.get(parent) : undefined;\n if (realParent && realParent.contains(target)) {\n parent = realParent;\n } else if (this.fragmentParentMap.has(target)) {\n /**\n * the target itself is a fragment document and it's not in the dom\n * so we should remove the real target from its parent\n */\n realTarget = this.fragmentParentMap.get(target)!;\n this.fragmentParentMap.delete(target);\n target = realTarget;\n }\n try {\n parent.removeChild(target);\n } catch (error) {\n if (error instanceof DOMException) {\n this.warn(\n 'parent could not remove child in mutation',\n parent,\n realParent,\n target,\n realTarget,\n d,\n );\n } else {\n throw error;\n }\n }\n }\n });\n\n // tslint:disable-next-line: variable-name\n const legacy_missingNodeMap: missingNodeMap = {\n ...this.legacy_missingNodeRetryMap,\n };\n const queue: addedNodeMutation[] = [];\n\n // next not present at this moment\n const nextNotInDOM = (mutation: addedNodeMutation) => {\n let next: Node | null = null;\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n // next not present at this moment\n if (\n mutation.nextId !== null &&\n mutation.nextId !== undefined &&\n mutation.nextId !== -1 &&\n !next\n ) {\n return true;\n }\n return false;\n };\n\n const appendNode = (mutation: addedNodeMutation) => {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n if (mutation.node.type === NodeType.Document) {\n // is newly added document, maybe the document node of an iframe\n return this.newDocumentQueue.push(mutation);\n }\n return queue.push(mutation);\n }\n\n let parentInDocument = null;\n if (this.iframe.contentDocument.contains) {\n parentInDocument = this.iframe.contentDocument.contains(parent);\n } else if (this.iframe.contentDocument.body.contains) {\n // fix for IE\n // refer 'Internet Explorer notes' at https://developer.mozilla.org/zh-CN/docs/Web/API/Document\n parentInDocument = this.iframe.contentDocument.body.contains(parent);\n }\n\n const hasIframeChild =\n ((parent as unknown) as HTMLElement).getElementsByTagName?.('iframe')\n .length > 0;\n /**\n * Why !isIframeINode(parent)? If parent element is an iframe, iframe document can't be appended to virtual parent.\n * Why !hasIframeChild? If we move iframe elements from dom to fragment document, we will lose the contentDocument of iframe. So we need to disable the virtual dom optimization if a parent node contains iframe elements.\n */\n if (\n useVirtualParent &&\n parentInDocument &&\n !isIframeINode(parent) &&\n !hasIframeChild\n ) {\n const virtualParent = (document.createDocumentFragment() as unknown) as INode;\n this.mirror.map[mutation.parentId] = virtualParent;\n this.fragmentParentMap.set(virtualParent, parent);\n\n // store the state, like scroll position, of child nodes before they are unmounted from dom\n this.storeState(parent);\n\n while (parent.firstChild) {\n virtualParent.appendChild(parent.firstChild);\n }\n parent = virtualParent;\n }\n\n if (mutation.node.isShadow) {\n // If the parent is attached a shadow dom after it's created, it won't have a shadow root.\n if (!hasShadowRoot(parent)) {\n ((parent as Node) as HTMLElement).attachShadow({ mode: 'open' });\n parent = ((parent as Node) as HTMLElement).shadowRoot!;\n } else parent = parent.shadowRoot;\n }\n\n let previous: Node | null = null;\n let next: Node | null = null;\n if (mutation.previousId) {\n previous = this.mirror.getNode(mutation.previousId) as Node;\n }\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n if (nextNotInDOM(mutation)) {\n return queue.push(mutation);\n }\n\n if (mutation.node.rootId && !this.mirror.getNode(mutation.node.rootId)) {\n return;\n }\n\n const targetDoc = mutation.node.rootId\n ? this.mirror.getNode(mutation.node.rootId)\n : this.iframe.contentDocument;\n if (isIframeINode(parent)) {\n this.attachDocumentToIframe(mutation, parent);\n return;\n }\n const target = buildNodeWithSN(mutation.node, {\n doc: targetDoc as Document,\n map: this.mirror.map,\n skipChild: true,\n hackCss: true,\n cache: this.cache,\n }) as INode;\n\n // legacy data, we should not have -1 siblings any more\n if (mutation.previousId === -1 || mutation.nextId === -1) {\n legacy_missingNodeMap[mutation.node.id] = {\n node: target,\n mutation,\n };\n return;\n }\n\n if (\n '__sn' in parent &&\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n mutation.node.type === NodeType.Text\n ) {\n // https://github.com/rrweb-io/rrweb/issues/745\n // parent is textarea, will only keep one child node as the value\n for (const c of Array.from(parent.childNodes)) {\n if (c.nodeType === parent.TEXT_NODE) {\n parent.removeChild(c);\n }\n }\n }\n\n if (previous && previous.nextSibling && previous.nextSibling.parentNode) {\n parent.insertBefore(target, previous.nextSibling);\n } else if (next && next.parentNode) {\n // making sure the parent contains the reference nodes\n // before we insert target before next.\n parent.contains(next)\n ? parent.insertBefore(target, next)\n : parent.insertBefore(target, null);\n } else {\n /**\n * Sometimes the document changes and the MutationObserver is disconnected, so the removal of child elements can't be detected and recorded. After the change of document, we may get another mutation which adds a new html element, while the old html element still exists in the dom, and we need to remove the old html element first to avoid collision.\n */\n if (parent === targetDoc) {\n while (targetDoc.firstChild) {\n targetDoc.removeChild(targetDoc.firstChild);\n }\n }\n\n parent.appendChild(target);\n }\n\n if (isIframeINode(target)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === target.__sn.id,\n );\n if (mutationInQueue) {\n this.attachDocumentToIframe(mutationInQueue, target);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(\n legacy_missingNodeMap,\n parent,\n target,\n mutation,\n );\n }\n };\n\n d.adds.forEach((mutation) => {\n appendNode(mutation);\n });\n\n let startTime = Date.now();\n while (queue.length) {\n // transform queue to resolve tree\n const resolveTrees = queueToResolveTrees(queue);\n queue.length = 0;\n if (Date.now() - startTime > 500) {\n this.warn(\n 'Timeout in the loop, please check the resolve tree data:',\n resolveTrees,\n );\n break;\n }\n for (const tree of resolveTrees) {\n let parent = this.mirror.getNode(tree.value.parentId);\n if (!parent) {\n this.debug(\n 'Drop resolve tree since there is no parent for the root node.',\n tree,\n );\n } else {\n iterateResolveTree(tree, (mutation) => {\n appendNode(mutation);\n });\n }\n }\n }\n\n if (Object.keys(legacy_missingNodeMap).length) {\n Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);\n }\n\n d.texts.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n /**\n * apply text content to real parent directly\n */\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n target.textContent = mutation.value;\n });\n d.attributes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n for (const attributeName in mutation.attributes) {\n if (typeof attributeName === 'string') {\n const value = mutation.attributes[attributeName];\n if (value === null) {\n ((target as Node) as Element).removeAttribute(attributeName);\n } else if (typeof value === 'string') {\n try {\n ((target as Node) as Element).setAttribute(attributeName, value);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n 'An error occurred may due to the checkout feature.',\n error,\n );\n }\n }\n } else if (attributeName === 'style') {\n let styleValues = value as styleAttributeValue;\n const targetEl = (target as Node) as HTMLElement;\n for (var s in styleValues) {\n if (styleValues[s] === false) {\n targetEl.style.removeProperty(s);\n } else if (styleValues[s] instanceof Array) {\n const svp = styleValues[s] as styleValueWithPriority;\n targetEl.style.setProperty(s, svp[0], svp[1]);\n } else {\n const svs = styleValues[s] as string;\n targetEl.style.setProperty(s, svs);\n }\n }\n }\n }\n }\n });\n }\n\n /**\n * Apply the scroll data on real elements.\n * If the replayer is in sync mode, smooth scroll behavior should be disabled.\n * @param d the scroll data\n * @param isSync whether the replayer is in sync mode(fast-forward)\n */\n private applyScroll(d: scrollData, isSync: boolean) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n if ((target as Node) === this.iframe.contentDocument) {\n this.iframe.contentWindow!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else if (target.__sn.type === NodeType.Document) {\n // nest iframe content document\n ((target as unknown) as Document).defaultView!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else {\n try {\n ((target as Node) as Element).scrollTop = d.y;\n ((target as Node) as Element).scrollLeft = d.x;\n } catch (error) {\n /**\n * Seldomly we may found scroll target was removed before\n * its last scroll event.\n */\n }\n }\n }\n\n private applyInput(d: inputData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n try {\n ((target as Node) as HTMLInputElement).checked = d.isChecked;\n ((target as Node) as HTMLInputElement).value = d.text;\n } catch (error) {\n // for safe\n }\n }\n\n private applyText(d: textMutation, mutation: mutationData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(mutation, d.id);\n }\n try {\n ((target as Node) as HTMLElement).textContent = d.value;\n } catch (error) {\n // for safe\n }\n }\n\n private legacy_resolveMissingNode(\n map: missingNodeMap,\n parent: Node,\n target: Node,\n targetMutation: addedNodeMutation,\n ) {\n const { previousId, nextId } = targetMutation;\n const previousInMap = previousId && map[previousId];\n const nextInMap = nextId && map[nextId];\n if (previousInMap) {\n const { node, mutation } = previousInMap as missingNode;\n parent.insertBefore(node, target);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n if (nextInMap) {\n const { node, mutation } = nextInMap as missingNode;\n parent.insertBefore(node, target.nextSibling);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n }\n\n private moveAndHover(\n x: number,\n y: number,\n id: number,\n isSync: boolean,\n debugData: incrementalData,\n ) {\n const target = this.mirror.getNode(id);\n if (!target) {\n return this.debugNodeNotFound(debugData, id);\n }\n\n const base = getBaseDimension(target, this.iframe);\n const _x = x * base.absoluteScale + base.x;\n const _y = y * base.absoluteScale + base.y;\n\n this.mouse.style.left = `${_x}px`;\n this.mouse.style.top = `${_y}px`;\n if (!isSync) {\n this.drawMouseTail({ x: _x, y: _y });\n }\n this.hoverElements((target as Node) as Element);\n }\n\n private drawMouseTail(position: { x: number; y: number }) {\n if (!this.mouseTail) {\n return;\n }\n\n const { lineCap, lineWidth, strokeStyle, duration } =\n this.config.mouseTail === true\n ? defaultMouseTailConfig\n : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);\n\n const draw = () => {\n if (!this.mouseTail) {\n return;\n }\n const ctx = this.mouseTail.getContext('2d');\n if (!ctx || !this.tailPositions.length) {\n return;\n }\n ctx.clearRect(0, 0, this.mouseTail.width, this.mouseTail.height);\n ctx.beginPath();\n ctx.lineWidth = lineWidth;\n ctx.lineCap = lineCap;\n ctx.strokeStyle = strokeStyle;\n ctx.moveTo(this.tailPositions[0].x, this.tailPositions[0].y);\n this.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));\n ctx.stroke();\n };\n\n this.tailPositions.push(position);\n draw();\n setTimeout(() => {\n this.tailPositions = this.tailPositions.filter((p) => p !== position);\n draw();\n }, duration / this.speedService.state.context.timer.speed);\n }\n\n private hoverElements(el: Element) {\n this.iframe.contentDocument\n ?.querySelectorAll('.\\\\:hover')\n .forEach((hoveredEl) => {\n hoveredEl.classList.remove(':hover');\n });\n let currentEl: Element | null = el;\n while (currentEl) {\n if (currentEl.classList) {\n currentEl.classList.add(':hover');\n }\n currentEl = currentEl.parentElement;\n }\n }\n\n private isUserInteraction(event: eventWithTime): boolean {\n if (event.type !== EventType.IncrementalSnapshot) {\n return false;\n }\n return (\n event.data.source > IncrementalSource.Mutation &&\n event.data.source <= IncrementalSource.Input\n );\n }\n\n private backToNormal() {\n this.nextUserInteractionEvent = null;\n if (this.speedService.state.matches('normal')) {\n return;\n }\n this.speedService.send({ type: 'BACK_TO_NORMAL' });\n this.emitter.emit(ReplayerEvents.SkipEnd, {\n speed: this.speedService.state.context.normalSpeed,\n });\n }\n\n /**\n * Replace the virtual parent with the real parent.\n * @param frag fragment document, the virtual parent\n * @param parent real parent element\n */\n private restoreRealParent(frag: INode, parent: INode) {\n this.mirror.map[parent.__sn.id] = parent;\n /**\n * If we have already set value attribute on textarea,\n * then we could not apply text content as default value any more.\n */\n if (\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n frag.textContent\n ) {\n ((parent as unknown) as HTMLTextAreaElement).value = frag.textContent;\n }\n parent.appendChild(frag);\n // restore state of elements after they are mounted\n this.restoreState(parent);\n }\n\n /**\n * store state of elements before unmounted from dom recursively\n * the state should be restored in the handler of event ReplayerEvents.Flush\n * e.g. browser would lose scroll position after the process that we add children of parent node to Fragment Document as virtual dom\n */\n private storeState(parent: INode) {\n if (parent) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (parentElement.scrollLeft || parentElement.scrollTop) {\n // store scroll position state\n this.elementStateMap.set(parent, {\n scroll: [parentElement.scrollLeft, parentElement.scrollTop],\n });\n }\n if (parentElement.tagName === 'STYLE')\n storeCSSRules(\n parentElement as HTMLStyleElement,\n this.virtualStyleRulesMap,\n );\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.storeState((child as unknown) as INode);\n }\n }\n }\n }\n\n /**\n * restore the state of elements recursively, which was stored before elements were unmounted from dom in virtual parent mode\n * this function corresponds to function storeState\n */\n private restoreState(parent: INode) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (this.elementStateMap.has(parent)) {\n const storedState = this.elementStateMap.get(parent)!;\n // restore scroll position\n if (storedState.scroll) {\n parentElement.scrollLeft = storedState.scroll[0];\n parentElement.scrollTop = storedState.scroll[1];\n }\n this.elementStateMap.delete(parent);\n }\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.restoreState((child as unknown) as INode);\n }\n }\n }\n\n private restoreNodeSheet(node: INode) {\n const storedRules = this.virtualStyleRulesMap.get(node);\n if (node.nodeName !== 'STYLE') {\n return;\n }\n\n if (!storedRules) {\n return;\n }\n\n const styleNode = (node as unknown) as HTMLStyleElement;\n\n applyVirtualStyleRulesToNode(storedRules, styleNode);\n }\n\n private warnNodeNotFound(d: incrementalData, id: number) {\n if (this.treeIndex.idRemoved(id)) {\n this.warn(`Node with id '${id}' was previously removed. `, d);\n } else {\n this.warn(`Node with id '${id}' not found. `, d);\n }\n }\n\n private warnCanvasMutationFailed(\n d: canvasMutationData | canvasMutationCommand,\n error: unknown,\n ) {\n this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);\n }\n\n private debugNodeNotFound(d: incrementalData, id: number) {\n /**\n * There maybe some valid scenes of node not being found.\n * Because DOM events are macrotask and MutationObserver callback\n * is microtask, so events fired on a removed DOM may emit\n * snapshots in the reverse order.\n */\n if (this.treeIndex.idRemoved(id)) {\n this.debug(\n REPLAY_CONSOLE_PREFIX,\n `Node with id '${id}' was previously removed. `,\n d,\n );\n } else {\n this.debug(REPLAY_CONSOLE_PREFIX, `Node with id '${id}' not found. `, d);\n }\n }\n\n private warn(...args: Parameters) {\n if (!this.config.showWarning) {\n return;\n }\n console.warn(REPLAY_CONSOLE_PREFIX, ...args);\n }\n\n private debug(...args: Parameters) {\n if (!this.config.showDebug) {\n return;\n }\n // tslint:disable-next-line: no-console\n console.log(REPLAY_CONSOLE_PREFIX, ...args);\n }\n}\n","import { Replayer } from '..';\nimport {\n CanvasContext,\n canvasMutationCommand,\n canvasMutationData,\n} from '../../types';\nimport webglMutation from './webgl';\nimport canvas2DMutation from './2d';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationData;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const mutations: canvasMutationCommand[] =\n 'commands' in mutation ? mutation.commands : [mutation];\n\n if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {\n return mutations.forEach((command) => {\n webglMutation({\n mutation: command,\n type: mutation.type,\n target,\n imageMap,\n errorHandler,\n });\n });\n }\n // default is '2d' for backwards compatibility (rrweb below 1.1.x)\n return mutations.forEach((command) => {\n canvas2DMutation({\n event,\n mutation: command,\n target,\n imageMap,\n errorHandler,\n });\n });\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import { Replayer } from '../';\nimport { canvasMutationCommand } from '../../types';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = ((target as unknown) as HTMLCanvasElement).getContext('2d')!;\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n /**\n * We have serialized the image source into base64 string during recording,\n * which has been preloaded before replay.\n * So we can get call drawImage SYNCHRONOUSLY which avoid some fragile cast.\n */\n if (\n mutation.property === 'drawImage' &&\n typeof mutation.args[0] === 'string'\n ) {\n const image = imageMap.get(event);\n mutation.args[0] = image;\n original.apply(ctx, mutation.args);\n } else {\n original.apply(ctx, mutation.args);\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import record from './record';\nimport { Replayer } from './replay';\nimport { _mirror } from './utils';\nimport * as utils from './utils';\n\nexport {\n EventType,\n IncrementalSource,\n MouseInteractions,\n ReplayerEvents,\n} from './types';\n\nconst { addCustomEvent } = record;\nconst { freezePage } = record;\n\nexport {\n record,\n addCustomEvent,\n freezePage,\n Replayer,\n _mirror as mirror,\n utils,\n};\n","// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Much of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// Many optimizations have been made, so the bundle size is ultimately smaller but performance is similar.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var u = ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([c], { type: 'text/javascript' })));\n var w = new Worker(u);\n w.onerror = function (e) { return cb(e.error, null); };\n w.onmessage = function (e) { return cb(null, e.data); };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;\n// fixed length extra bits\nvar fleb = new u8([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, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\n// see fleb note\nvar fdeb = new u8([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, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new u32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return [b, r];\n};\nvar _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b[0], revfd = _b[1];\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >>> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >>> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >>> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >>> 8) | ((x & 0x00FF) << 8)) >>> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i)\n ++l[cd[i] - 1];\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 0; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >>> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i)\n co[i] = rev[le[cd[i] - 1]++] >>> (15 - cd[i]);\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8)) >>> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >>> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p / 8) >> 0) + (p & 7 && 1); };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n var n = new (v instanceof u16 ? u16 : v instanceof u32 ? u32 : u8)(e - s);\n n.set(v.subarray(s, e));\n return n;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, buf, st) {\n // source length\n var sl = dat.length;\n // have to estimate size\n var noBuf = !buf || st;\n // no state\n var noSt = !st || st.i;\n if (!st)\n st = {};\n // Assumes roughly 33% compression ratio average\n if (!buf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n st.f = final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n throw 'unexpected EOF';\n break;\n }\n // ensure size\n if (noBuf)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n if (!noSt && pos + tl * (clb + 7) > tbts)\n break;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >>> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n throw 'invalid block type';\n if (pos > tbts)\n throw 'unexpected EOF';\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17;\n if (noBuf)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var mxa = lbt + dbt + 18;\n while (noSt || pos + mxa < tbts) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;\n pos += c & 15;\n if (pos > tbts)\n throw 'unexpected EOF';\n if (!c)\n throw 'invalid length/literal';\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;\n if (!d)\n throw 'invalid distance';\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & ((1 << b) - 1), pos += b;\n }\n if (pos > tbts)\n throw 'unexpected EOF';\n if (noBuf)\n cbuf(bt + 131072);\n var end = bt + add;\n for (; bt < end; bt += 4) {\n buf[bt] = buf[bt - dt];\n buf[bt + 1] = buf[bt + 1 - dt];\n buf[bt + 2] = buf[bt + 2 - dt];\n buf[bt + 3] = buf[bt + 3 - dt];\n }\n bt = end;\n }\n }\n st.l = lm, st.p = pos, st.b = bt;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n return bt == buf.length ? buf : slc(buf, 0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n d[o + 2] |= v >>> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return [new u8(0), 0];\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return [v, 1];\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return [new u8(tr), mbt];\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return [cl.subarray(0, cli), s];\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >>> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a[0], mlb = _a[1];\n var _b = hTree(df, 15), ddt = _b[0], mdb = _b[1];\n var _c = lc(dlt), lclt = _c[0], nlc = _c[1];\n var _d = lc(ddt), lcdt = _d[0], ndc = _d[1];\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n lcfreq[lclt[i] & 31]++;\n for (var i = 0; i < lcdt.length; ++i)\n lcfreq[lcdt[i] & 31]++;\n var _e = hTree(lcfreq, 7), lct = _e[0], mlcb = _e[1];\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);\n if (flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >>> 5) & 127), p += clct[i] >>> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n if (syms[i] > 255) {\n var len = (syms[i] >>> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (syms[i] >>> 23) & 31), p += fleb[len];\n var dst = syms[i] & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (syms[i] >>> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new u32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, lst) {\n var s = dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.floor(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var pos = 0;\n if (!lvl || s < 8) {\n for (var i = 0; i <= s; i += 65535) {\n // end\n var e = i + 65535;\n if (e < s) {\n // write full block\n pos = wfblk(w, pos, dat.subarray(i, e));\n }\n else {\n // write final block\n w[i] = lst;\n pos = wfblk(w, pos, dat.subarray(i, s));\n }\n }\n }\n else {\n var opt = deo[lvl - 1];\n var n = opt >>> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = new u16(32768), head = new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new u32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx bitpos\n var lc_1 = 0, eb = 0, i = 0, li = 0, wi = 0, bs = 0;\n for (; i < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768\n var imod = i & 32767;\n // previous index with this value\n var pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && rem > 423) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = (imod - pimod) & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = (i - dif + j + 32768) & 32767;\n var pti = prev[ti];\n var cd = (ti - pti + 32768) & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += (imod - pimod + 32768) & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one Uint32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n // this is the easiest way to avoid needing to maintain state\n if (!lst)\n pos = wfblk(w, pos, et);\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new u32(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && 0xEDB88320) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = 0xFFFFFFFF;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return c ^ 0xFFFFFFFF; }\n };\n};\n// Alder32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 5552, l);\n for (; i < e; ++i)\n n += d[i], m += n;\n n %= 65521, m %= 65521;\n }\n a = n, b = m;\n },\n d: function () { return ((a >>> 8) << 16 | (b & 255) << 8 | (b >>> 8)) + ((a & 255) << 23) * 2; }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post, !st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/ /g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return [fnStr, td];\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k] instanceof u8 || v[k] instanceof u16 || v[k] instanceof u32)\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n var _a;\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n _a = wcln(fns[i], fnStr, td_1), fnStr = _a[0], td_1 = _a[1];\n ch[id] = wcln(fns[m], fnStr, td_1);\n }\n var td = mrg({}, ch[id][1]);\n return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, hMap, max, bits, bits16, shft, slc, inflt, inflateSync, pbf, gu8]; };\nvar bDflt = function () { return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zlv]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get u8\nvar gu8 = function (o) { return o && o.size && new u8(o.size); };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n if (!opts.consume)\n dat = new u8(dat);\n w.postMessage([dat, opts], [dat.buffer]);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) { return strm.push(ev.data[0], ev.data[1]); };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.push = function (d, f) {\n if (t)\n throw 'stream finished';\n if (!strm.ondata)\n throw 'no stream handler';\n w.postMessage([d, t = f], [d.buffer]);\n };\n strm.terminate = function () { w.terminate(); };\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16)) + (d[b + 3] << 23) * 2; };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n throw 'invalid gzip data';\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += d[10] | (d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16) + (2 * (d[l - 1] << 23));\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + ((o.filename && (o.filename.length + 1)) || 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (fl ? (32 - 2 * fl) : 1);\n};\n// zlib valid\nvar zlv = function (d) {\n if ((d[0] & 15) != 8 || (d[0] >>> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n throw 'invalid zlib data';\n if (d[1] & 32)\n throw 'invalid zlib data: preset dictionaries not supported';\n};\nfunction AsyncCmpStrm(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n// zlib footer: -4 to -0 is Adler32\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, !f), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n this.d = final;\n this.p(chunk, final || false);\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n return dopt(data, opts, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n /**\n * Creates an inflation stream\n * @param cb The callback to call whenever data is inflated\n */\n function Inflate(cb) {\n this.s = {};\n this.p = new u8(0);\n this.ondata = cb;\n }\n Inflate.prototype.e = function (c) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n var l = this.p.length;\n var n = new u8(l + c.length);\n n.set(this.p), n.set(c, l), this.p = n;\n };\n Inflate.prototype.c = function (final) {\n this.d = this.s.i = final || false;\n var bts = this.s.b;\n var dt = inflt(this.p, this.o, this.s);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) >> 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous inflation stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncInflate(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, 0, function () {\n var strm = new Inflate();\n onmessage = astrm(strm);\n }, 7);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gu8(ev.data[1]))); }, 1, cb);\n}\n/**\n * Expands DEFLATE data with no wrapper\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function inflateSync(data, out) {\n return inflt(data, out);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n this.c.p(c);\n this.l += c.length;\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, !f);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n /**\n * Creates a GUNZIP stream\n * @param cb The callback to call whenever data is inflated\n */\n function Gunzip(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n var s = gzs(this.p);\n if (s >= this.p.length && !final)\n return;\n this.p = this.p.subarray(s), this.v = 0;\n }\n if (final) {\n if (this.p.length < 8)\n throw 'invalid gzip stream';\n this.p = this.p.subarray(0, -8);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous GUNZIP stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncGunzip(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, 0, function () {\n var strm = new Gunzip();\n onmessage = astrm(strm);\n }, 9);\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0])); }, 3, cb);\n}\n/**\n * Expands GZIP data\n * @param data The data to decompress\n * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.\n * @returns The decompressed version of the data\n */\nexport function gunzipSync(data, out) {\n return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n this.c.p(c);\n var raw = dopt(c, this.o, this.v && 2, f && 4, !f);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n /**\n * Creates a Zlib decompression stream\n * @param cb The callback to call whenever data is inflated\n */\n function Unzlib(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 2 && !final)\n return;\n this.p = this.p.subarray(2), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n throw 'invalid zlib stream';\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous Zlib decompression stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncUnzlib(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, 0, function () {\n var strm = new Unzlib();\n onmessage = astrm(strm);\n }, 11);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gu8(ev.data[1]))); }, 5, cb);\n}\n/**\n * Expands Zlib data\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function unzlibSync(data, out) {\n return inflt((zlv(data), data.subarray(2, -4)), out);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n /**\n * Creates a decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function Decompress(cb) {\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n throw 'no stream handler';\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n var _this_1 = this;\n var cb = function () { _this_1.ondata.apply(_this_1, arguments); };\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(cb)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(cb)\n : new this.Z(cb);\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function AsyncDecompress(cb) {\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, out) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, out)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, out)\n : unzlibSync(data, out);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k;\n if (val instanceof u8)\n t[n] = [val, o];\n else if (Array.isArray(val))\n t[n] = [val[0], mrg(o, val[1])];\n else\n fltn(val, n + '/', t, o);\n }\n};\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n var l = str.length;\n if (!latin1 && typeof TextEncoder != 'undefined')\n return new TextEncoder().encode(str);\n var ar = new u8(str.length + (str.length >>> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >>> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >>> 18)), w(128 | ((c >>> 12) & 63)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >>> 12)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n var r = '';\n if (!latin1 && typeof TextDecoder != 'undefined')\n return new TextDecoder().decode(dat);\n for (var i = 0; i < dat.length;) {\n var c = dat[i++];\n if (c < 128 || latin1)\n r += String.fromCharCode(c);\n else if (c < 224)\n r += String.fromCharCode((c & 31) << 6 | (dat[i++] & 63));\n else if (c < 240)\n r += String.fromCharCode((c & 15) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63));\n else\n c = ((c & 15) << 18 | (dat[i++] & 63) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n return r;\n}\n;\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;\n var _a = z ? z64e(d, es) : [b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];\n};\n// read zip64 extra field\nvar z64e = function (d, b) {\n for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))\n ;\n return [b4(d, b + 12), b4(d, b + 4), b4(d, b + 20)];\n};\n// write zip header\nvar wzh = function (d, b, c, cmp, su, fn, u, o, ce, t) {\n var fl = fn.length, l = cmp.length;\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b] = 20, b += 2;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (t == 8 && (o.level == 1 ? 6 : o.level < 6 ? 4 : o.level == 9 ? 2 : 0)), d[b++] = u && 8;\n d[b] = t, b += 2;\n var dt = new Date(o.mtime || Date.now()), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n throw 'date not in range 1980-2099';\n wbytes(d, b, ((y << 24) * 2) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >>> 1));\n b += 4;\n wbytes(d, b, c);\n wbytes(d, b + 4, l);\n wbytes(d, b + 8, su);\n wbytes(d, b + 12, fl), b += 16; // skip extra field, comment\n if (ce != null)\n wbytes(d, b += 10, ce), b += 4;\n d.set(fn, b);\n b += fl;\n if (ce == null)\n d.set(cmp, b);\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n wzh(out, tot, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, tot, f.t), o += 46 + f.n.length, tot += 30 + f.n.length + f.d.length;\n }\n catch (e) {\n return cb(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cb(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), m = file.length;\n c.p(file);\n var n = strToU8(fn), s = n.length;\n var t = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n var l = d.length;\n files[i] = {\n t: t,\n d: d,\n m: m,\n c: c.d(),\n u: fn.length != l,\n n: n,\n p: p\n };\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n if (!--lft)\n cbf();\n }\n };\n if (n.length > 65535)\n cbl('filename too long', null);\n if (!t)\n cbl(null, file);\n else if (m < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var t = p.level == 0 ? 0 : 8;\n var n = strToU8(fn), s = n.length;\n if (n.length > 65535)\n throw 'filename too long';\n var d = t ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push({\n t: t,\n d: d,\n m: file.length,\n c: c.d(),\n u: fn.length != s,\n n: n,\n o: o,\n p: p\n });\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, f.o, f.t), o += 46 + f.n.length;\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Asynchronously decompresses a ZIP archive\n * @param data The raw compressed ZIP file\n * @param cb The callback to call with the decompressed files\n * @returns A function that can be used to immediately terminate the unzipping\n */\nexport function unzip(data, cb) {\n if (typeof cb != 'function')\n throw 'no callback';\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cb('invalid zip file', null);\n return;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (!lft)\n cb(null, {});\n var c = lft;\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = lft = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n var _loop_2 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n files[fn] = d;\n if (!--lft)\n cb(null, files);\n }\n };\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n if (sc < 320000) {\n try {\n cbl(null, inflateSync(infl, new u8(su)));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl('unknown compression type ' + c_1, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_2(i);\n }\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @returns The decompressed files\n */\nexport function unzipSync(data) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n throw 'invalid zip file';\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));\n else\n throw 'unknown compression type ' + c_2;\n }\n return files;\n}\n","import { eventWithTime } from '../types';\n\nexport type PackFn = (event: eventWithTime) => string;\nexport type UnpackFn = (raw: string) => eventWithTime;\n\nexport type eventWithTimeAndPacker = eventWithTime & {\n v: string;\n};\n\nexport const MARK = 'v1';\n","// tslint:disable\n/**\n * Class StackFrame is a fork of https://github.com/stacktracejs/stackframe/blob/master/stackframe.js\n * I fork it because:\n * 1. There are some build issues when importing this package.\n * 2. Rewrites into typescript give us a better type interface.\n * 3. StackFrame contains some functions we don't need.\n */\nexport class StackFrame {\n private fileName: string;\n private functionName: string;\n private lineNumber?: number;\n private columnNumber?: number;\n\n constructor(obj: {\n fileName?: string;\n functionName?: string;\n lineNumber?: number;\n columnNumber?: number;\n }) {\n this.fileName = obj.fileName || '';\n this.functionName = obj.functionName || '';\n this.lineNumber = obj.lineNumber;\n this.columnNumber = obj.columnNumber;\n }\n\n toString() {\n const lineNumber = this.lineNumber || '';\n const columnNumber = this.columnNumber || '';\n if (this.functionName) {\n return (\n this.functionName +\n ' (' +\n this.fileName +\n ':' +\n lineNumber +\n ':' +\n columnNumber +\n ')'\n );\n }\n return this.fileName + ':' + lineNumber + ':' + columnNumber;\n }\n}\n\n/**\n * ErrorStackParser is a fork of https://github.com/stacktracejs/error-stack-parser/blob/master/error-stack-parser.js\n * I fork it because:\n * 1. There are some build issues when importing this package.\n * 2. Rewrites into typescript give us a better type interface.\n */\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/;\nconst CHROME_IE_STACK_REGEXP = /^\\s*at .*(\\S+:\\d+|\\(native\\))/m;\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code])?$/;\nexport const ErrorStackParser = {\n /**\n * Given an Error object, extract the most information from it.\n *\n * @param {Error} error object\n * @return {Array} of StackFrames\n */\n parse: function (error: Error): StackFrame[] {\n // https://github.com/rrweb-io/rrweb/issues/782\n if (!error) {\n return [];\n }\n if (\n // @ts-ignore\n typeof error.stacktrace !== 'undefined' ||\n // @ts-ignore\n typeof error['opera#sourceloc'] !== 'undefined'\n ) {\n return this.parseOpera(\n error as {\n stacktrace?: string;\n message: string;\n stack?: string;\n },\n );\n } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {\n return this.parseV8OrIE(error as { stack: string });\n } else if (error.stack) {\n return this.parseFFOrSafari(error as { stack: string });\n } else {\n throw new Error('Cannot parse given Error object');\n }\n },\n // Separate line and column numbers from a string of the form: (URI:Line:Column)\n extractLocation: function (urlLike: string) {\n // Fail-fast but return locations like \"(native)\"\n if (urlLike.indexOf(':') === -1) {\n return [urlLike];\n }\n\n const regExp = /(.+?)(?::(\\d+))?(?::(\\d+))?$/;\n const parts = regExp.exec(urlLike.replace(/[()]/g, ''));\n if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);\n return [parts[1], parts[2] || undefined, parts[3] || undefined];\n },\n parseV8OrIE: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return !!line.match(CHROME_IE_STACK_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n if (line.indexOf('(eval ') > -1) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n line = line\n .replace(/eval code/g, 'eval')\n .replace(/(\\(eval at [^()]*)|(\\),.*$)/g, '');\n }\n let sanitizedLine = line.replace(/^\\s+/, '').replace(/\\(eval code/g, '(');\n\n // capture and preseve the parenthesized location \"(/foo/my bar.js:12:87)\" in\n // case it has spaces in it, as the string is split on \\s+ later on\n const location = sanitizedLine.match(/ (\\((.+):(\\d+):(\\d+)\\)$)/);\n\n // remove the parenthesized location from the line, if it was matched\n sanitizedLine = location\n ? sanitizedLine.replace(location[0], '')\n : sanitizedLine;\n\n const tokens = sanitizedLine.split(/\\s+/).slice(1);\n // if a location was matched, pass it to extractLocation() otherwise pop the last token\n const locationParts = this.extractLocation(\n location ? location[1] : tokens.pop(),\n );\n const functionName = tokens.join(' ') || undefined;\n const fileName =\n ['eval', ''].indexOf(locationParts[0]) > -1\n ? undefined\n : locationParts[0];\n\n return new StackFrame({\n functionName,\n fileName,\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }, this);\n },\n parseFFOrSafari: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return !line.match(SAFARI_NATIVE_CODE_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n if (line.indexOf(' > eval') > -1) {\n line = line.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n ':$1',\n );\n }\n\n if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {\n // Safari eval frames only have function names and nothing else\n return new StackFrame({\n functionName: line,\n });\n } else {\n const functionNameRegex = /((.*\".+\"[^@]*)?[^@]*)(?:@)/;\n const matches = line.match(functionNameRegex);\n const functionName = matches && matches[1] ? matches[1] : undefined;\n const locationParts = this.extractLocation(\n line.replace(functionNameRegex, ''),\n );\n\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }\n }, this);\n },\n parseOpera: function (e: {\n stacktrace?: string;\n message: string;\n stack?: string;\n }): StackFrame[] {\n if (\n !e.stacktrace ||\n (e.message.indexOf('\\n') > -1 &&\n e.message.split('\\n').length > e.stacktrace.split('\\n').length)\n ) {\n return this.parseOpera9(e as { message: string });\n } else if (!e.stack) {\n return this.parseOpera10(e as { stacktrace: string });\n } else {\n return this.parseOpera11(e as { stack: string });\n }\n },\n parseOpera9: function (e: { message: string }) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)/i;\n const lines = e.message.split('\\n');\n const result = [];\n\n for (let i = 2, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n fileName: match[2],\n lineNumber: parseFloat(match[1]),\n }),\n );\n }\n }\n\n return result;\n },\n parseOpera10: function (e: { stacktrace: string }) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)(?:: In function (\\S+))?$/i;\n const lines = e.stacktrace.split('\\n');\n const result = [];\n\n for (let i = 0, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n functionName: match[3] || undefined,\n fileName: match[2],\n lineNumber: parseFloat(match[1]),\n }),\n );\n }\n }\n\n return result;\n },\n // Opera 10.65+ Error.stack very similar to FF/Safari\n parseOpera11: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return (\n !!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&\n !line.match(/^Error created at/)\n );\n }, this);\n\n return filtered.map(function (line: string) {\n const tokens = line.split('@');\n const locationParts = this.extractLocation(tokens.pop());\n const functionCall = tokens.shift() || '';\n const functionName =\n functionCall\n .replace(//, '$2')\n .replace(/\\([^)]*\\)/g, '') || undefined;\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }, this);\n },\n};\n","// tslint:disable:no-any no-bitwise forin\n/**\n * this file is used to serialize log message to string\n *\n */\n\nimport { StringifyOptions } from './index';\n\n/**\n * transfer the node path in Event to string\n * @param node the first node in a node path array\n */\nfunction pathToSelector(node: HTMLElement): string | '' {\n if (!node || !node.outerHTML) {\n return '';\n }\n\n let path = '';\n while (node.parentElement) {\n let name = node.localName;\n if (!name) {\n break;\n }\n name = name.toLowerCase();\n let parent = node.parentElement;\n\n let domSiblings = [];\n\n if (parent.children && parent.children.length > 0) {\n // tslint:disable-next-line:prefer-for-of\n for (let i = 0; i < parent.children.length; i++) {\n let sibling = parent.children[i];\n if (sibling.localName && sibling.localName.toLowerCase) {\n if (sibling.localName.toLowerCase() === name) {\n domSiblings.push(sibling);\n }\n }\n }\n }\n\n if (domSiblings.length > 1) {\n name += ':eq(' + domSiblings.indexOf(node) + ')';\n }\n path = name + (path ? '>' + path : '');\n node = parent;\n }\n\n return path;\n}\n\n/**\n * judge is object\n */\nfunction isObject(obj: any): boolean {\n return Object.prototype.toString.call(obj) === '[object Object]';\n}\n\n/**\n * judge the object's depth\n */\nfunction isObjTooDeep(obj: any, limit: number): boolean {\n if (limit === 0) {\n return true;\n }\n\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * stringify any js object\n * @param obj the object to stringify\n */\nexport function stringify(\n obj: any,\n stringifyOptions?: StringifyOptions,\n): string {\n const options: StringifyOptions = {\n numOfKeysLimit: 50,\n depthOfLimit: 4,\n };\n Object.assign(options, stringifyOptions);\n const stack: any[] = [];\n const keys: any[] = [];\n return JSON.stringify(obj, function (key, value) {\n /**\n * forked from https://github.com/moll/json-stringify-safe/blob/master/stringify.js\n * to deCycle the object\n */\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);\n if (~stack.indexOf(value)) {\n if (stack[0] === value) {\n value = '[Circular ~]';\n } else {\n value =\n '[Circular ~.' +\n keys.slice(0, stack.indexOf(value)).join('.') +\n ']';\n }\n }\n } else {\n stack.push(value);\n }\n /* END of the FORK */\n\n if (value === null || value === undefined) {\n return value;\n }\n if (shouldIgnore(value)) {\n return toString(value);\n }\n if (value instanceof Event) {\n const eventResult: any = {};\n for (const eventKey in value) {\n const eventValue = (value as any)[eventKey];\n if (Array.isArray(eventValue)) {\n eventResult[eventKey] = pathToSelector(\n eventValue.length ? eventValue[0] : null,\n );\n } else {\n eventResult[eventKey] = eventValue;\n }\n }\n return eventResult;\n } else if (value instanceof Node) {\n if (value instanceof HTMLElement) {\n return value ? value.outerHTML : '';\n }\n return value.nodeName;\n } else if (value instanceof Error) {\n return value.stack\n ? value.stack + '\\nEnd of stack for Error object'\n : value.name + ': ' + value.message;\n }\n return value;\n });\n\n /**\n * whether we should ignore obj's info and call toString() function instead\n */\n function shouldIgnore(_obj: object): boolean {\n // outof keys limit\n if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {\n return true;\n }\n\n // is function\n if (typeof _obj === 'function') {\n return true;\n }\n\n /**\n * judge object's depth to avoid browser's OOM\n *\n * issues: https://github.com/rrweb-io/rrweb/issues/653\n */\n if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * limit the toString() result according to option\n */\n function toString(_obj: object): string {\n let str = _obj.toString();\n if (options.stringLengthLimit && str.length > options.stringLengthLimit) {\n str = `${str.slice(0, options.stringLengthLimit)}...`;\n }\n return str;\n }\n}\n","import { listenerHandler, RecordPlugin, IWindow } from '../../../types';\nimport { patch } from '../../../utils';\nimport { ErrorStackParser, StackFrame } from './error-stack-parser';\nimport { stringify } from './stringify';\n\nexport type StringifyOptions = {\n // limit of string length\n stringLengthLimit?: number;\n /**\n * limit of number of keys in an object\n * if an object contains more keys than this limit, we would call its toString function directly\n */\n numOfKeysLimit: number;\n /**\n * limit number of depth in an object\n * if an object is too deep, toString process may cause browser OOM\n */\n depthOfLimit: number;\n};\n\ntype LogRecordOptions = {\n level?: LogLevel[];\n lengthThreshold?: number;\n stringifyOptions?: StringifyOptions;\n logger?: Logger | 'console';\n};\n\nconst defaultLogOptions: LogRecordOptions = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n lengthThreshold: 1000,\n logger: 'console',\n};\n\nexport type LogData = {\n level: LogLevel;\n trace: string[];\n payload: string[];\n};\n\ntype logCallback = (p: LogData) => void;\n\nexport type LogLevel =\n | 'assert'\n | 'clear'\n | 'count'\n | 'countReset'\n | 'debug'\n | 'dir'\n | 'dirxml'\n | 'error'\n | 'group'\n | 'groupCollapsed'\n | 'groupEnd'\n | 'info'\n | 'log'\n | 'table'\n | 'time'\n | 'timeEnd'\n | 'timeLog'\n | 'trace'\n | 'warn';\n\n/* fork from interface Console */\n// all kinds of console functions\nexport type Logger = {\n assert?: typeof console.assert;\n clear?: typeof console.clear;\n count?: typeof console.count;\n countReset?: typeof console.countReset;\n debug?: typeof console.debug;\n dir?: typeof console.dir;\n dirxml?: typeof console.dirxml;\n error?: typeof console.error;\n group?: typeof console.group;\n groupCollapsed?: typeof console.groupCollapsed;\n groupEnd?: () => void;\n info?: typeof console.info;\n log?: typeof console.log;\n table?: typeof console.table;\n time?: typeof console.time;\n timeEnd?: typeof console.timeEnd;\n timeLog?: typeof console.timeLog;\n trace?: typeof console.trace;\n warn?: typeof console.warn;\n};\n\nfunction initLogObserver(\n cb: logCallback,\n win: IWindow, // top window or in an iframe\n logOptions: LogRecordOptions,\n): listenerHandler {\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {};\n }\n let logger: Logger;\n if (typeof loggerType === 'string') {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n const cancelHandlers: listenerHandler[] = [];\n // add listener to thrown errors\n if (logOptions.level!.includes('error')) {\n if (window) {\n const errorHandler = (event: ErrorEvent) => {\n const { message, error } = event;\n const trace: string[] = ErrorStackParser.parse(\n error,\n ).map((stackFrame: StackFrame) => stackFrame.toString());\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: 'error',\n trace,\n payload,\n });\n };\n window.addEventListener('error', errorHandler);\n cancelHandlers.push(() => {\n if (window) window.removeEventListener('error', errorHandler);\n });\n }\n }\n for (const levelType of logOptions.level!) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n\n /**\n * replace the original console function and record logs\n * @param logger the logger object such as Console\n * @param level the name of log function to be replaced\n */\n function replace(_logger: Logger, level: LogLevel) {\n if (!_logger[level]) {\n return () => {};\n }\n // replace the logger.{level}. return a restore function\n return patch(_logger, level, (original) => {\n return (...args: Array) => {\n original.apply(this, args);\n try {\n const trace = ErrorStackParser.parse(new Error())\n .map((stackFrame: StackFrame) => stackFrame.toString())\n .splice(1); // splice(1) to omit the hijacked log function\n const payload = args.map((s) =>\n stringify(s, logOptions.stringifyOptions),\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold!) {\n cb({\n level,\n trace,\n payload,\n });\n } else if (logCount === logOptions.lengthThreshold) {\n // notify the user\n cb({\n level: 'warn',\n trace: [],\n payload: [\n stringify('The number of log records reached the threshold.'),\n ],\n });\n }\n } catch (error) {\n original('rrweb logger error:', error, ...args);\n }\n };\n });\n }\n}\n\nexport const PLUGIN_NAME = 'rrweb/console@1';\n\nexport const getRecordConsolePlugin: (\n options?: LogRecordOptions,\n) => RecordPlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options: options\n ? Object.assign({}, defaultLogOptions, options)\n : defaultLogOptions,\n});\n","import { LogLevel, LogData, PLUGIN_NAME } from '../record';\nimport {\n eventWithTime,\n EventType,\n IncrementalSource,\n ReplayPlugin,\n} from '../../../types';\n\n/**\n * define an interface to replay log records\n * (data: logData) => void> function to display the log data\n */\ntype ReplayLogger = Partial void>>;\n\ntype LogReplayConfig = {\n level?: LogLevel[];\n replayLogger?: ReplayLogger;\n};\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedConsoleLog = {\n [ORIGINAL_ATTRIBUTE_NAME]: typeof console.log;\n};\n\nconst defaultLogConfig: LogReplayConfig = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n replayLogger: undefined,\n};\n\nclass LogReplayPlugin {\n private config: LogReplayConfig;\n\n constructor(config?: LogReplayConfig) {\n this.config = Object.assign(defaultLogConfig, config);\n }\n\n /**\n * generate a console log replayer which implement the interface ReplayLogger\n */\n public getConsoleLogger(): ReplayLogger {\n const replayLogger: ReplayLogger = {};\n for (const level of this.config.level!) {\n if (level === 'trace') {\n replayLogger[level] = (data: LogData) => {\n const logger = ((console.log as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? ((console.log as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console.log;\n logger(\n ...data.payload.map((s) => JSON.parse(s)),\n this.formatMessage(data),\n );\n };\n } else {\n replayLogger[level] = (data: LogData) => {\n const logger = ((console[level] as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? ((console[level] as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console[level];\n logger(\n ...data.payload.map((s) => JSON.parse(s)),\n this.formatMessage(data),\n );\n };\n }\n }\n return replayLogger;\n }\n\n /**\n * format the trace data to a string\n * @param data the log data\n */\n private formatMessage(data: LogData): string {\n if (data.trace.length === 0) {\n return '';\n }\n const stackPrefix = '\\n\\tat ';\n let result = stackPrefix;\n result += data.trace.join(stackPrefix);\n return result;\n }\n}\n\nexport const getReplayConsolePlugin: (\n options?: LogReplayConfig,\n) => ReplayPlugin = (options) => {\n const replayLogger =\n options?.replayLogger || new LogReplayPlugin(options).getConsoleLogger();\n\n return {\n handler(event: eventWithTime, _isSync, context) {\n let logData: LogData | null = null;\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === (IncrementalSource.Log as IncrementalSource)\n ) {\n logData = (event.data as unknown) as LogData;\n } else if (\n event.type === EventType.Plugin &&\n event.data.plugin === PLUGIN_NAME\n ) {\n logData = event.data.payload as LogData;\n }\n if (logData) {\n try {\n if (typeof replayLogger[logData.level] === 'function') {\n replayLogger[logData.level]!(logData);\n }\n } catch (error) {\n if (context.replayer.config.showWarning) {\n console.warn(error);\n }\n }\n }\n },\n };\n};\n","import { strFromU8, strToU8, zlibSync } from 'fflate';\nimport { PackFn, MARK, eventWithTimeAndPacker } from './base';\n\nexport const pack: PackFn = (event) => {\n const _e: eventWithTimeAndPacker = {\n ...event,\n v: MARK,\n };\n return strFromU8(zlibSync(strToU8(JSON.stringify(_e))), true);\n};\n","import { strFromU8, strToU8, unzlibSync } from 'fflate';\nimport { UnpackFn, eventWithTimeAndPacker, MARK } from './base';\nimport { eventWithTime } from '../types';\n\nexport const unpack: UnpackFn = (raw: string) => {\n if (typeof raw !== 'string') {\n return raw;\n }\n try {\n const e: eventWithTime = JSON.parse(raw);\n if (e.timestamp) {\n return e;\n }\n } catch (error) {\n // ignore and continue\n }\n try {\n const e: eventWithTimeAndPacker = JSON.parse(\n strFromU8(unzlibSync(strToU8(raw, true)))\n );\n if (e.v === MARK) {\n return e;\n }\n throw new Error(\n `These events were packed with packer ${e.v} which is incompatible with current packer ${MARK}.`,\n );\n } catch (error) {\n console.error(error);\n throw new Error('Unknown data format.');\n }\n};\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isElement","nodeType","ELEMENT_NODE","isShadowRoot","_a","host","Boolean","shadowRoot","maskInputValue","maskInputOptions","tagName","type","maskInputFn","text","toLowerCase","repeat","ORIGINAL_ATTRIBUTE_NAME","canvasService","canvasCtx","_id","tagNameRegex","RegExp","getCssRulesString","rules","cssRules","map","getCssRuleString","join","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","stack","parts","pop","_i","parts_1","part","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","classList","contains","eIndex","className","matches","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","Math","min","data","buffer","some","pixel","is2DCanvasBlank","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","_l","_m","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","commentre","parse","css","lineno","column","updatePosition","str","lines","lastIndexOf","position","start","line","Position","whitespace","end","source","content","errorsList","msg","Error","reason","filename","silent","open","close","comments","atrule","re","selector","declaration","propMatch","prop","val","ret","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","vendor","frame","frames","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","atdocument","sel","selectors","atpage","athost","atfontface","addParent","parsingErrors","obj","parent","isNode","childParent","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cache","cachedStyle","stylesWithHoverClass","get","ast","selectorMatcher","filter","index","sort","b","result","newSelector","set","createCache","Map","buildNode","hackCss","implementation","createDocument","createDocumentType","node_1","getTagName","createElementNS","_loop_1","startsWith","image","setAttribute","play","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","removeChild","appendChild","setAttributeNS","srcset","firstChild","attachShadow","mode","createCDATASection","createComment","buildNodeWithSN","afterAppend","assert","xmlns","write","childN","childNode","rebuild","onVisit","idNodeMap","key","visit","visitedNode","name_2","handleScroll","on","fn","target","capture","passive","removeEventListener","createMirror","getId","getNode","removeNodeFromMap","_this","has","reset","DEPARTED_MIRROR_ACCESS_WARNING","throttle","func","wait","timeout","previous","arg","now","Date","leading","remaining","context","args","trailing","hookSetter","d","isRevoked","original","getOwnPropertyDescriptor","patch","replacement","original_1","wrapped","defineProperties","__rrweb_original__","getWindowHeight","window","innerHeight","documentElement","clientHeight","body","getWindowWidth","innerWidth","clientWidth","isBlocked","needBlock_1","closest","isIgnored","isAncestorRemoved","mirror","isTouchEvent","event","changedTouches","polyfill","NodeList","DOMTokenList","Node","Proxy","Reflect","_mirror","receiver","TreeIndex","mutation","parentTreeNode","indexes","parentId","treeNode","children","texts","tree","deepRemoveFromMirror","removeIdSet","add","deepRemoveFromTreeIndex","_treeNode","_parentTreeNode","delete","removeNodeMutations","textMutations","attributeMutations","scrollMap","inputMap","batchMutationData","Mutation","removes","adds","walk","removed","mutationData","Set","queueToResolveTrees","queue","queueNodeMap","putIntoMap","nodeInTree","queueNodeTrees","queue_1","nextId","nextInTree","idx","splice","parentInTree","iterateResolveTree","cb","isIframeINode","getBaseDimension","rootIframe","frameElement","ownerDocument","defaultView","relativeScale","absoluteScale","frameDimension","frameBaseDimension","hasShadowRoot","isNodeInLinkedList","DoubleLinkedList","current","head","__ln","moveKey","isINode","mutations","processMutation","emit","frozen","locked","addList","getNextId","ns","pushAdd","shadowHost","getRootNode","rootShadowHost","notInDoc","addNode","currentN","iframeManager","addIframe","shadowDomManager","addShadowRoot","iframe","childSn","attachIframe","observeAttachShadow","mapRemoves","shift","movedSet","isParentRemoved","addedSet","isAncestorInSet","droppedSet","candidate","_node","removeNode","payload","attribute","movedMap","mutationCb","oldValue","getAttribute","attributeName","item","old","styleObj","pname","newValue","getPropertyValue","newPriority","getPropertyPriority","addedNodes","genAdds","removedNodes","nodeId","deepDelete","targetId","MutationBuffer","canvasManager","freeze","unfreeze","lock","unlock","addsSet","mutationBuffers","isCSSGroupingRuleSupported","CSSGroupingRule","isCSSMediaRuleSupported","CSSMediaRule","isCSSSupportsRuleSupported","CSSSupportsRule","isCSSConditionRuleSupported","CSSConditionRule","getEventTarget","path","composedPath","initMutationObserver","rootEl","mutationBuffer","init","mutationObserverCtor","MutationObserver","__rrMutationObserver","angularZoneSymbol","Zone","__symbol__","observer","processMutations","bind","observe","attributeOldValue","characterData","characterDataOldValue","childList","subtree","initMouseInteractionObserver","mouseInteractionCb","sampling","mouseInteraction","disableMap","handlers","Number","isNaN","eventKey","eventName","handler","clientX","clientY","getHandler","h","initScrollObserver","scrollCb","evt","scrollEl","scrollingElement","scroll","wrapEventWithUserTriggeredFlag","enable","userTriggered","INPUT_TAGS","lastInputValueMap","WeakMap","getNestedCSSRulePositions","childRule","parentRule","unshift","parentStyleSheet","recurse","initObservers","hooks","currentWindow","mousemoveCb","viewportResizeCb","inputCb","mediaInteractionCb","styleSheetRuleCb","styleDeclarationCb","canvasMutationCb","fontCb","mousemove","viewportResize","input","mediaInteaction","styleSheetRule","styleDeclaration","canvasMutation","font","mergeHooks","mutationObserver","mousemoveHandler","timeBaseline","threshold","callbackThreshold","mousemoveCallback","positions","wrappedCb","totalOffset","timeOffset","DragEvent","Drag","MouseEvent","MouseMove","TouchMove","initMoveObserver","mouseInteractionHandler","scrollHandler","viewportResizeHandler","lastH","lastW","initViewportResizeObserver","inputHandler","ignoreClass","userTriggeredOnInput","eventHandler","isTrusted","parentElement","isChecked","cbWithDedup","querySelectorAll","lastInputValue","propertyDescriptor","HTMLInputElement","hookProperties","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement","initInputObserver","mediaInteractionHandler","volume","muted","initMediaInteractionObserver","styleSheetObserver","insertRule","CSSStyleSheet","ownerNode","deleteRule","supportedNestedCSSRuleTypes","unmodifiedFunctions","entries","typeKey","initStyleSheetObserver","styleDeclarationObserver","setProperty","CSSStyleDeclaration","priority","removeProperty","remove","initStyleDeclarationObserver","fontObserver","collectFonts","fontMap","originalFontFace","FontFace","family","descriptors","fontFace","fontSource","JSON","stringify","Uint8Array","restoreHandler","fonts","initFontObserver","pluginHandlers","plugins","plugin","callback","disconnect","IframeManager","iframes","loadListener","isAttachIframe","manager","restorePatches","HTMLElement","ShadowDomManager","iframeElement","manager_1","restorePatch","lookup","charCodeAt","webGLVarMap","saveWebGLVar","isInstanceOfWebGLObject","list","ctor","contextMap","variableListFor","constructor","serializeArg","Float32Array","Float64Array","Int32Array","Uint16Array","Int16Array","Int8Array","Uint8ClampedArray","rr_type","ArrayBuffer","base64","arraybuffer","bytes","len","encode","DataView","byteOffset","byteLength","HTMLImageElement","ImageData","serializeArgs","supportedWebGLConstructorNames","patchGLPrototype","props","getOwnPropertyNames","recordArgs","hookHandler","setter","props_1","wrappedEmit","takeFullSnapshot","latestId","invokeId","rafStamps","pendingCanvasMutations","initCanvasMutationObserver","CanvasManager","clear","resetObservers","startRAFTimestamping","startPendingCanvasMutationFlusher","canvasContextReset","HTMLCanvasElement","contextType","initCanvasContextObserver","canvas2DReset","props2D","CanvasRenderingContext2D","imgd","pix","props2D_1","initCanvas2DMutationObserver","canvasWebGL1and2Reset","WebGLRenderingContext","WebGL","WebGL2RenderingContext","WebGL2","initCanvasWebGLMutationObserver","requestAnimationFrame","flushPendingCanvasMutations","setLatestRAFTimestamp","timestamp","flushPendingCanvasMutationFor","valuesWithType","getOwnPropertySymbols","propertyIsEnumerable","commands","wrapEvent","record","checkoutEveryNms","checkoutEveryNth","maskAllInputs","_maskInputOptions","_slimDOMOptions","packFn","mousemoveWait","lastFullSnapshotEvent","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","incrementalSnapshotCount","isCheckout","isFrozen","FullSnapshot","IncrementalSnapshot","buf","eventProcessor","exceedCount","exceedTime","wrappedMutationEmit","wrappedScrollEmit","Scroll","wrappedCanvasMutationEmit","CanvasMutation","Meta","slimDOM","snapshot","initialOffset","left","pageXOffset","top","pageYOffset","handlers_1","DomContentLoaded","observe_1","MouseInteraction","ViewportResize","Input","MediaInteraction","StyleSheetRule","StyleDeclaration","Font","Plugin","addLoadListener","init_1","Load","mitt","all","create","off","addCustomEvent","tag","Custom","freezePage","w","__forceSmoothScrollPolyfill__","userAgent","scrollTo","scrollBy","elementScroll","scrollElement","scrollIntoView","performance","ROUNDING_TOLERANCE","navigator","shouldBailOut","smoothScroll","scrollX","scrollY","SyntaxError","behavior","scrollableParent","findScrollableParent","parentRects","clientRects","getComputedStyle","firstArg","hasScrollableSpace","axis","scrollHeight","scrollWidth","canOverflow","overflowValue","isScrollable","isScrollableY","isScrollableX","step","currentX","currentY","k","elapsed","startTime","cos","PI","startX","startY","method","scrollable","actions","speed","Timer","action","findActionIndex","lastTimestamp","self","raf","check","delay","doAction","liveMode","cancelAnimationFrame","mid","floor","addDelay","baselineTime","firstOffset","firstTimestamp","return","NotStarted","Running","Stopped","assignment","u","changed","f","states","initial","entry","config","_options","initialState","transition","g","S","j","E","R","N","cond","O","_","T","q","exit","z","A","B","C","_machine","send","subscribe","unsubscribe","stop","state","status","createPlayerService","getCastFn","applyEventsSynchronously","emitter","interpret","createMachine","playing","PAUSE","CAST_EVENT","END","ADD_EVENT","PLAY","TO_LIVE","live","castEvent","lastPlayedEvent","recordTimeOffset","events","timer","events_1","neededEvents","event_1","discardPriorSnapshots","lastPlayedTimestamp","PlayBack","syncEvents","event_3","castFn_1","neededEvents_1","Flush","addActions","resetLastPlayedEvent","startLive","toggleLiveMode","addEvent","machineEvent","event_4","insertionIndex","isSync","castFn_2","isActive","addAction","StyleRuleType","getNestedRule","getPositionsAndIndex","nestedIndex","applyVirtualStyleRulesToNode","storedRules","styleNode","Insert","Remove","Snapshot","cssTexts","existingRules","existingRulesReversed","reverse","lastMatch_1","restoreSnapshotOfStyleRulesToNode","SetProperty","RemoveProperty","WebGLVariableConstructorsNames","deserializeArg","imageMap","encoded1","encoded2","encoded3","encoded4","bufferLength","decode","Image","webglMutation","errorHandler","includes","variables","saveToWebGLVarMap","mittProxy.default","mittProxy","REPLAY_CONSOLE_PREFIX","defaultMouseTailConfig","duration","lineCap","lineWidth","strokeStyle","indicatesTouchDevice","TouchStart","defaultConfig","maxSpeed","root","loadTimeout","skipInactive","showWarning","showDebug","insertStyleRules","triggerFocus","UNSAFE_replayCanvas","pauseAnimation","mouseTail","handleResize","Resize","setupDom","treeIndex","fragmentParentMap","elementStateMap","virtualStyleRulesMap","flush","frag","restoreRealParent","applyText","restoreNodeSheet","applyScroll","applyInput","firstFullSnapshot","service","unpackFn","a1","a2","StateChange","player","speedService","normalSpeed","normal","FAST_FORWARD","SET_SPEED","skipping","BACK_TO_NORMAL","setSpeed","recordSpeed","restoreSpeed","firstMeta","firstFullsnapshot","width_1","height_1","rebuildFullSnapshot","mouse","Replayer","backToNormal","display","parseFloat","wrapper","insertBefore","firstEvent","lastEvent","endTime","totalTime","getTimeOffset","getElementsByTagName","Start","Pause","Resume","rawEvent","Promise","resolve","then","pointerEvents","disableInteract","smoothscrollPolyfill","dimension","String","castFn","mousePos","moveAndHover","debugData","touchActive","CustomEvent","applyIncremental","nextUserInteractionEvent","_event","isUserInteraction","skipTime","round","SkipStart","replayer","last_index","finish_1","Finish","max","EventCast","legacy_missingNodeRetryMap","collected","builtNode","collectIframeAndAttachDocument","mutationInQueue","this_1","attachDocumentToIframe","newDocumentQueue","collected_1","FullsnapshotRebuilded","waitForStylesheetLoad","preloadAllImages","styleEl","injectStylesRules","parent_1","realParent","toUpperCase","this_2","collected_2","unloadSheets_1","beforeLoadState_1","stateHandler_1","unsubscribe_1","size","getCurrentTime","LoadStylesheetEnd","LoadStylesheetStart","args_1","hasImageArg","images","args_2","getImageArgs","stateHandler","event_2","preloadImages","this_3","createImageData","putImageData","applyMutation","message","lastPosition","Event","debugNodeNotFound","Blur","blur","Focus","focus","preventScroll","Click","TouchEnd","tailPositions","offsetWidth","TouchCancel","dispatchEvent","mediaEl","rules_1","parent_2","usingVirtualParent_1","styleSheet_1","parent_3","command","canvas2DMutation","warnCanvasMutationFailed","useVirtualParent","warnNodeNotFound","realTarget","DOMException","legacy_missingNodeMap","appendNode","parentInDocument","hasIframeChild","virtualParent","createDocumentFragment","storeState","previousId","nextNotInDOM","targetDoc","mutationInQueue_1","legacy_resolveMissingNode","resolveTrees","resolveTrees_1","debug","removeAttribute","styleValues","targetEl","svp","svs","targetMutation","previousInMap","nextInMap","base","_x","_y","drawMouseTail","hoverElements","draw","clearRect","beginPath","moveTo","lineTo","stroke","hoveredEl","currentEl","SkipEnd","restoreState","storeCSSRules","storedState","nodeName","idRemoved","log","u8","u16","u32","fleb","fdeb","clim","freb","eb","fl","revfl","fd","revfd","rev","hMap","cd","mb","co","le","rvb","sv","r_1","flt","fdt","flm","flrm","fdm","fdrm","bits","bits16","shft","slc","subarray","wbits","wbits16","hTree","t2","i0","i1","i2","maxSym","tr","mbt","ln","dt","lft","cst","i2_1","i2_2","i2_3","lc","cl","cli","cln","cls","clen","cf","wfblk","out","dat","wblk","final","syms","lf","df","li","bs","bl","dlt","mlb","ddt","mdb","lclt","nlc","lcdt","ndc","lcfreq","lct","mlcb","nlcc","lm","ll","dm","dl","flen","ftlen","dtlen","llm","lcts","it","clct","dst","deo","et","dopt","opt","pre","post","st","lvl","plvl","lst","msk_1","prev","bs1_1","ceil","bs2_1","hsh","lc_1","wi","hv","imod","pimod","rem","ch_1","dif","maxn","maxd","ml","nl","mmd","md","ti","lin","din","dflt","level","mem","zlibSync","opts","adler","lv","zlh","wbytes","unzlibSync","sl","noBuf","noSt","cbuf","nbuf","bt","lbt","dbt","tbts","hLit","hcLen","tl","ldt","clt","clb","clbmsk","clm","lt","lms","dms","mxa","sym","dsym","inflt","zlv","strToU8","latin1","TextEncoder","ai","strFromU8","TextDecoder","fromCharCode","MARK","fileName","functionName","lineNumber","columnNumber","StackFrame","FIREFOX_SAFARI_STACK_REGEXP","CHROME_IE_STACK_REGEXP","SAFARI_NATIVE_CODE_REGEXP","ErrorStackParser","stacktrace","parseOpera","parseV8OrIE","parseFFOrSafari","extractLocation","urlLike","sanitizedLine","tokens","locationParts","functionNameRegex","parseOpera9","parseOpera11","parseOpera10","lineRE","pathToSelector","outerHTML","localName","domSiblings","sibling","isObject","toString","isObjTooDeep","limit","keys_1","stringifyOptions","numOfKeysLimit","depthOfLimit","thisPos","Infinity","_obj","shouldIgnore","stringLengthLimit","eventResult","eventValue","defaultLogOptions","lengthThreshold","logger","initLogObserver","logOptions","loggerType","logCount","cancelHandlers","errorHandler_1","trace","stackFrame","levelType","_logger","PLUGIN_NAME","defaultLogConfig","replayLogger","LogReplayPlugin","formatMessage","stackPrefix","get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B,IAAMzW,SACDyW,IACHlK,EAAG+oC,KAEL,OAAOH,GAAUpC,GAASgC,GAAQzsB,KAAKC,UAAUvoB,MAAO,yBCJ1B,SAACy5C,GAC/B,GAAmB,iBAARA,EACT,OAAOA,EAET,IAEE,IADMtiD,EAAmBmxB,KAAKrgB,MAAMwxC,IAC9BtrB,UACJ,OAAOh3B,EAET,MAAOG,IAGT,IACE,IAAMH,EAGN,IAHMA,EAA4BmxB,KAAKrgB,MACrCktC,GAAU9B,GAAW0B,GAAQ0E,GAAK,OAE9BltC,IAAM+oC,GACV,OAAOn+C,EAET,MAAM,IAAIgS,MACR,+CAAwChS,EAAEoV,wDAA+C+oC,SAE3F,MAAOh+C,GAEP,MADAoL,QAAQpL,MAAMA,GACR,IAAI6R,MAAM"} +\ No newline at end of file ++{"version":3,"file":"rrweb-all.min.js","sources":["../node_modules/tslib/tslib.es6.js","../../rrweb-snapshot/es/rrweb-snapshot.js","../../src/types.ts","../../src/utils.ts","../../src/record/mutation.ts","../../src/record/observer.ts","../../src/record/iframe-manager.ts","../../src/record/shadow-dom-manager.ts","../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../src/record/observers/canvas/serialize-args.ts","../../src/record/observers/canvas/webgl.ts","../../src/record/observers/canvas/canvas-manager.ts","../../src/record/index.ts","../../src/record/observers/canvas/canvas.ts","../../src/record/observers/canvas/2d.ts","../../../node_modules/mitt/dist/mitt.es.js","../../src/replay/smoothscroll.ts","../../src/replay/timer.ts","../../../node_modules/@xstate/fsm/es/index.js","../../src/replay/machine.ts","../../src/replay/styles/inject-style.ts","../../src/replay/virtual-styles.ts","../../src/replay/canvas/webgl.ts","../../src/replay/index.ts","../../src/replay/canvas/index.ts","../../src/replay/canvas/2d.ts","../../src/index.ts","../../../node_modules/fflate/esm/browser.js","../../src/packer/base.ts","../../src/plugins/console/record/error-stack-parser.ts","../../src/plugins/console/record/stringify.ts","../../src/plugins/console/record/index.ts","../../src/plugins/console/replay/index.ts","../../src/packer/pack.ts","../../src/packer/unpack.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type] ||\n (maskInputSelector && input.matches(maskInputSelector))) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) {\n return false;\n }\n }\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n input: n,\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n unblockSelector?: string;\n ignoreClass?: string;\n ignoreSelector?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputSelector?: string;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n unmaskTextSelector?: string;\n unmaskInputSelector?: string;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n unblockSelector: string | null;\n ignoreClass: string;\n ignoreSelector: string | null;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'unblockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'unmaskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputSelector'\n | 'unmaskInputSelector'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","import {\n INode,\n serializeNodeWithId,\n transformAttribute,\n IGNORED_NODE,\n isShadowRoot,\n needMaskingText,\n maskInputValue,\n} from 'rrweb-snapshot';\nimport {\n mutationRecord,\n textCursor,\n attributeCursor,\n removedNodeMutation,\n addedNodeMutation,\n Mirror,\n styleAttributeValue,\n observerParam,\n MutationBufferParam,\n Optional,\n} from '../types';\nimport {\n isBlocked,\n isAncestorRemoved,\n isIgnored,\n isIframeINode,\n hasShadowRoot,\n} from '../utils';\n\ntype DoubleLinkedListNode = {\n previous: DoubleLinkedListNode | null;\n next: DoubleLinkedListNode | null;\n value: NodeInLinkedList;\n};\ntype NodeInLinkedList = Node & {\n __ln: DoubleLinkedListNode;\n};\n\nfunction isNodeInLinkedList(n: Node | NodeInLinkedList): n is NodeInLinkedList {\n return '__ln' in n;\n}\nclass DoubleLinkedList {\n public length = 0;\n public head: DoubleLinkedListNode | null = null;\n\n public get(position: number) {\n if (position >= this.length) {\n throw new Error('Position outside of list range');\n }\n\n let current = this.head;\n for (let index = 0; index < position; index++) {\n current = current?.next || null;\n }\n return current;\n }\n\n public addNode(n: Node) {\n const node: DoubleLinkedListNode = {\n value: n as NodeInLinkedList,\n previous: null,\n next: null,\n };\n (n as NodeInLinkedList).__ln = node;\n if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {\n const current = n.previousSibling.__ln.next;\n node.next = current;\n node.previous = n.previousSibling.__ln;\n n.previousSibling.__ln.next = node;\n if (current) {\n current.previous = node;\n }\n } else if (\n n.nextSibling &&\n isNodeInLinkedList(n.nextSibling) &&\n n.nextSibling.__ln.previous\n ) {\n const current = n.nextSibling.__ln.previous;\n node.previous = current;\n node.next = n.nextSibling.__ln;\n n.nextSibling.__ln.previous = node;\n if (current) {\n current.next = node;\n }\n } else {\n if (this.head) {\n this.head.previous = node;\n }\n node.next = this.head;\n this.head = node;\n }\n this.length++;\n }\n\n public removeNode(n: NodeInLinkedList) {\n const current = n.__ln;\n if (!this.head) {\n return;\n }\n\n if (!current.previous) {\n this.head = current.next;\n if (this.head) {\n this.head.previous = null;\n }\n } else {\n current.previous.next = current.next;\n if (current.next) {\n current.next.previous = current.previous;\n }\n }\n if (n.__ln) {\n delete (n as Optional).__ln;\n }\n this.length--;\n }\n}\n\nconst moveKey = (id: number, parentId: number) => `${id}@${parentId}`;\nfunction isINode(n: Node | INode): n is INode {\n return '__sn' in n;\n}\n\n/**\n * controls behaviour of a MutationObserver\n */\nexport default class MutationBuffer {\n private frozen: boolean = false;\n private locked: boolean = false;\n\n private texts: textCursor[] = [];\n private attributes: attributeCursor[] = [];\n private removes: removedNodeMutation[] = [];\n private mapRemoves: Node[] = [];\n\n private movedMap: Record = {};\n\n /**\n * the browser MutationObserver emits multiple mutations after\n * a delay for performance reasons, making tracing added nodes hard\n * in our `processMutations` callback function.\n * For example, if we append an element el_1 into body, and then append\n * another element el_2 into el_1, these two mutations may be passed to the\n * callback function together when the two operations were done.\n * Generally we need to trace child nodes of newly added nodes, but in this\n * case if we count el_2 as el_1's child node in the first mutation record,\n * then we will count el_2 again in the second mutation record which was\n * duplicated.\n * To avoid of duplicate counting added nodes, we use a Set to store\n * added nodes and its child nodes during iterate mutation records. Then\n * collect added nodes from the Set which have no duplicate copy. But\n * this also causes newly added nodes will not be serialized with id ASAP,\n * which means all the id related calculation should be lazy too.\n */\n private addedSet = new Set();\n private movedSet = new Set();\n private droppedSet = new Set();\n\n private mutationCb: observerParam['mutationCb'];\n private blockClass: observerParam['blockClass'];\n private blockSelector: observerParam['blockSelector'];\n private unblockSelector: observerParam['unblockSelector'];\n private maskTextClass: observerParam['maskTextClass'];\n private maskTextSelector: observerParam['maskTextSelector'];\n private unmaskTextSelector: observerParam['unmaskTextSelector'];\n private maskInputSelector: observerParam['maskInputSelector'];\n private unmaskInputSelector: observerParam['unmaskInputSelector'];\n private inlineStylesheet: observerParam['inlineStylesheet'];\n private maskInputOptions: observerParam['maskInputOptions'];\n private maskTextFn: observerParam['maskTextFn'];\n private maskInputFn: observerParam['maskInputFn'];\n private recordCanvas: observerParam['recordCanvas'];\n private inlineImages: observerParam['inlineImages'];\n private slimDOMOptions: observerParam['slimDOMOptions'];\n private doc: observerParam['doc'];\n private mirror: observerParam['mirror'];\n private iframeManager: observerParam['iframeManager'];\n private shadowDomManager: observerParam['shadowDomManager'];\n private canvasManager: observerParam['canvasManager'];\n\n public init(options: MutationBufferParam) {\n ([\n 'mutationCb',\n 'blockClass',\n 'blockSelector',\n 'unblockSelector',\n 'maskTextClass',\n 'maskTextSelector',\n 'unmaskTextSelector',\n 'maskInputSelector',\n 'unmaskInputSelector',\n 'inlineStylesheet',\n 'maskInputOptions',\n 'maskTextFn',\n 'maskInputFn',\n 'recordCanvas',\n 'inlineImages',\n 'slimDOMOptions',\n 'doc',\n 'mirror',\n 'iframeManager',\n 'shadowDomManager',\n 'canvasManager',\n ] as const).forEach((key) => {\n // just a type trick, the runtime result is correct\n this[key] = options[key] as never;\n });\n }\n\n public freeze() {\n this.frozen = true;\n this.canvasManager.freeze();\n }\n\n public unfreeze() {\n this.frozen = false;\n this.canvasManager.unfreeze();\n this.emit();\n }\n\n public isFrozen() {\n return this.frozen;\n }\n\n public lock() {\n this.locked = true;\n this.canvasManager.lock();\n }\n\n public unlock() {\n this.locked = false;\n this.canvasManager.unlock();\n this.emit();\n }\n\n public reset() {\n this.shadowDomManager.reset();\n this.canvasManager.reset();\n }\n\n public processMutations = (mutations: mutationRecord[]) => {\n mutations.forEach(this.processMutation); // adds mutations to the buffer\n this.emit(); // clears buffer if not locked/frozen\n };\n\n public emit = () => {\n if (this.frozen || this.locked) {\n return;\n }\n\n // delay any modification of the mirror until this function\n // so that the mirror for takeFullSnapshot doesn't get mutated while it's event is being processed\n\n const adds: addedNodeMutation[] = [];\n\n /**\n * Sometimes child node may be pushed before its newly added\n * parent, so we init a queue to store these nodes.\n */\n const addList = new DoubleLinkedList();\n const getNextId = (n: Node): number | null => {\n let ns: Node | null = n;\n let nextId: number | null = IGNORED_NODE; // slimDOM: ignored\n while (nextId === IGNORED_NODE) {\n ns = ns && ns.nextSibling;\n nextId = ns && this.mirror.getId((ns as unknown) as INode);\n }\n return nextId;\n };\n const pushAdd = (n: Node) => {\n const shadowHost: Element | null = n.getRootNode\n ? (n.getRootNode() as ShadowRoot)?.host\n : null;\n // If n is in a nested shadow dom.\n let rootShadowHost = shadowHost;\n while ((rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host)\n rootShadowHost =\n (rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host ||\n null;\n // ensure shadowHost is a Node, or doc.contains will throw an error\n const notInDoc =\n !this.doc.contains(n) &&\n (rootShadowHost === null || !this.doc.contains(rootShadowHost));\n if (!n.parentNode || notInDoc) {\n return;\n }\n const parentId = isShadowRoot(n.parentNode)\n ? this.mirror.getId((shadowHost as unknown) as INode)\n : this.mirror.getId((n.parentNode as Node) as INode);\n const nextId = getNextId(n);\n if (parentId === -1 || nextId === -1) {\n return addList.addNode(n);\n }\n let sn = serializeNodeWithId(n, {\n doc: this.doc,\n map: this.mirror.map,\n blockClass: this.blockClass,\n blockSelector: this.blockSelector,\n unblockSelector: this.unblockSelector,\n maskTextClass: this.maskTextClass,\n maskTextSelector: this.maskTextSelector,\n unmaskTextSelector: this.unmaskTextSelector,\n maskInputSelector: this.maskInputSelector,\n unmaskInputSelector: this.unmaskInputSelector,\n skipChild: true,\n inlineStylesheet: this.inlineStylesheet,\n maskInputOptions: this.maskInputOptions,\n maskTextFn: this.maskTextFn,\n maskInputFn: this.maskInputFn,\n slimDOMOptions: this.slimDOMOptions,\n recordCanvas: this.recordCanvas,\n inlineImages: this.inlineImages,\n onSerialize: (currentN) => {\n if (isIframeINode(currentN)) {\n this.iframeManager.addIframe(currentN);\n }\n if (hasShadowRoot(n)) {\n this.shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n this.iframeManager.attachIframe(iframe, childSn);\n this.shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n });\n if (sn) {\n adds.push({\n parentId,\n nextId,\n node: sn,\n });\n }\n };\n\n while (this.mapRemoves.length) {\n this.mirror.removeNodeFromMap(this.mapRemoves.shift() as INode);\n }\n\n for (const n of this.movedSet) {\n if (\n isParentRemoved(this.removes, n, this.mirror) &&\n !this.movedSet.has(n.parentNode!)\n ) {\n continue;\n }\n pushAdd(n);\n }\n\n for (const n of this.addedSet) {\n if (\n !isAncestorInSet(this.droppedSet, n) &&\n !isParentRemoved(this.removes, n, this.mirror)\n ) {\n pushAdd(n);\n } else if (isAncestorInSet(this.movedSet, n)) {\n pushAdd(n);\n } else {\n this.droppedSet.add(n);\n }\n }\n\n let candidate: DoubleLinkedListNode | null = null;\n while (addList.length) {\n let node: DoubleLinkedListNode | null = null;\n if (candidate) {\n const parentId = this.mirror.getId(\n (candidate.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(candidate.value);\n if (parentId !== -1 && nextId !== -1) {\n node = candidate;\n }\n }\n if (!node) {\n for (let index = addList.length - 1; index >= 0; index--) {\n const _node = addList.get(index)!;\n // ensure _node is defined before attempting to find value\n if (_node) {\n const parentId = this.mirror.getId(\n (_node.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(_node.value);\n if (parentId !== -1 && nextId !== -1) {\n node = _node;\n break;\n }\n }\n }\n }\n if (!node) {\n /**\n * If all nodes in queue could not find a serialized parent,\n * it may be a bug or corner case. We need to escape the\n * dead while loop at once.\n */\n while (addList.head) {\n addList.removeNode(addList.head.value);\n }\n break;\n }\n candidate = node.previous;\n addList.removeNode(node.value);\n pushAdd(node.value);\n }\n\n const payload = {\n texts: this.texts\n .map((text) => ({\n id: this.mirror.getId(text.node as INode),\n value: text.value,\n }))\n // text mutation's id was not in the mirror map means the target node has been removed\n .filter((text) => this.mirror.has(text.id)),\n attributes: this.attributes\n .map((attribute) => ({\n id: this.mirror.getId(attribute.node as INode),\n attributes: attribute.attributes,\n }))\n // attribute mutation's id was not in the mirror map means the target node has been removed\n .filter((attribute) => this.mirror.has(attribute.id)),\n removes: this.removes,\n adds,\n };\n // payload may be empty if the mutations happened in some blocked elements\n if (\n !payload.texts.length &&\n !payload.attributes.length &&\n !payload.removes.length &&\n !payload.adds.length\n ) {\n return;\n }\n\n // reset\n this.texts = [];\n this.attributes = [];\n this.removes = [];\n this.addedSet = new Set();\n this.movedSet = new Set();\n this.droppedSet = new Set();\n this.movedMap = {};\n\n this.mutationCb(payload);\n };\n\n private processMutation = (m: mutationRecord) => {\n if (isIgnored(m.target)) {\n return;\n }\n switch (m.type) {\n case 'characterData': {\n const value = m.target.textContent;\n if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {\n this.texts.push({\n value:\n needMaskingText(\n m.target,\n this.maskTextClass,\n this.maskTextSelector,\n this.unmaskTextSelector\n ) && value\n ? this.maskTextFn\n ? this.maskTextFn(value)\n : value.replace(/[\\S]/g, '*')\n : value,\n node: m.target,\n });\n }\n break;\n }\n case 'attributes': {\n const target = m.target as HTMLElement;\n let value = (m.target as HTMLElement).getAttribute(m.attributeName!);\n if (m.attributeName === 'value') {\n value = maskInputValue({\n input: target,\n maskInputSelector: this.maskInputSelector,\n unmaskInputSelector: this.unmaskInputSelector,\n maskInputOptions: this.maskInputOptions,\n tagName: (m.target as HTMLElement).tagName,\n type: (m.target as HTMLElement).getAttribute('type'),\n value,\n maskInputFn: this.maskInputFn,\n });\n }\n if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {\n return;\n }\n let item: attributeCursor | undefined = this.attributes.find(\n (a) => a.node === m.target,\n );\n if (!item) {\n item = {\n node: m.target,\n attributes: {},\n };\n this.attributes.push(item);\n }\n if (m.attributeName === 'style') {\n const old = this.doc.createElement('span');\n if (m.oldValue) {\n old.setAttribute('style', m.oldValue);\n }\n if (\n item.attributes.style === undefined ||\n item.attributes.style === null\n ) {\n item.attributes.style = {};\n }\n const styleObj = item.attributes.style as styleAttributeValue;\n for (const pname of Array.from(target.style)) {\n const newValue = target.style.getPropertyValue(pname);\n const newPriority = target.style.getPropertyPriority(pname);\n if (\n newValue !== old.style.getPropertyValue(pname) ||\n newPriority !== old.style.getPropertyPriority(pname)\n ) {\n if (newPriority === '') {\n styleObj[pname] = newValue;\n } else {\n styleObj[pname] = [newValue, newPriority];\n }\n }\n }\n for (const pname of Array.from(old.style)) {\n if (target.style.getPropertyValue(pname) === '') {\n // \"if not set, returns the empty string\"\n styleObj[pname] = false; // delete\n }\n }\n } else {\n // overwrite attribute if the mutations was triggered in same time\n item.attributes[m.attributeName!] = transformAttribute(\n this.doc,\n (m.target as HTMLElement).tagName,\n m.attributeName!,\n value!,\n );\n }\n break;\n }\n case 'childList': {\n m.addedNodes.forEach((n) => this.genAdds(n, m.target));\n m.removedNodes.forEach((n) => {\n const nodeId = this.mirror.getId(n as INode);\n const parentId = isShadowRoot(m.target)\n ? this.mirror.getId((m.target.host as unknown) as INode)\n : this.mirror.getId(m.target as INode);\n if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {\n return;\n }\n // removed node has not been serialized yet, just remove it from the Set\n if (this.addedSet.has(n)) {\n deepDelete(this.addedSet, n);\n this.droppedSet.add(n);\n } else if (this.addedSet.has(m.target) && nodeId === -1) {\n /**\n * If target was newly added and removed child node was\n * not serialized, it means the child node has been removed\n * before callback fired, so we can ignore it because\n * newly added node will be serialized without child nodes.\n * TODO: verify this\n */\n } else if (isAncestorRemoved(m.target as INode, this.mirror)) {\n /**\n * If parent id was not in the mirror map any more, it\n * means the parent node has already been removed. So\n * the node is also removed which we do not need to track\n * and replay.\n */\n } else if (\n this.movedSet.has(n) &&\n this.movedMap[moveKey(nodeId, parentId)]\n ) {\n deepDelete(this.movedSet, n);\n } else {\n this.removes.push({\n parentId,\n id: nodeId,\n isShadow: isShadowRoot(m.target) ? true : undefined,\n });\n }\n this.mapRemoves.push(n);\n });\n break;\n }\n default:\n break;\n }\n };\n\n private genAdds = (n: Node | INode, target?: Node | INode) => {\n // parent was blocked, so we can ignore this node\n if (target && isBlocked(target, this.blockClass)) {\n return;\n }\n if (isINode(n)) {\n if (isIgnored(n)) {\n return;\n }\n this.movedSet.add(n);\n let targetId: number | null = null;\n if (target && isINode(target)) {\n targetId = target.__sn.id;\n }\n if (targetId) {\n this.movedMap[moveKey(n.__sn.id, targetId)] = true;\n }\n } else {\n this.addedSet.add(n);\n this.droppedSet.delete(n);\n }\n\n // if this node is blocked `serializeNode` will turn it into a placeholder element\n // but we have to remove it's children otherwise they will be added as placeholders too\n if (!isBlocked(n, this.blockClass))\n n.childNodes.forEach((childN) => this.genAdds(childN));\n };\n}\n\n/**\n * Some utils to handle the mutation observer DOM records.\n * It should be more clear to extend the native data structure\n * like Set and Map, but currently Typescript does not support\n * that.\n */\nfunction deepDelete(addsSet: Set, n: Node) {\n addsSet.delete(n);\n n.childNodes.forEach((childN) => deepDelete(addsSet, childN));\n}\n\nfunction isParentRemoved(\n removes: removedNodeMutation[],\n n: Node,\n mirror: Mirror,\n): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n const parentId = mirror.getId((parentNode as Node) as INode);\n if (removes.some((r) => r.id === parentId)) {\n return true;\n }\n return isParentRemoved(removes, parentNode, mirror);\n}\n\nfunction isAncestorInSet(set: Set, n: Node): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n if (set.has(parentNode)) {\n return true;\n }\n return isAncestorInSet(set, parentNode);\n}\n","import { INode, MaskInputOptions, maskInputValue } from 'rrweb-snapshot';\nimport { FontFaceSet } from 'css-font-loading-module';\nimport {\n throttle,\n on,\n hookSetter,\n getWindowHeight,\n getWindowWidth,\n isBlocked,\n isTouchEvent,\n patch,\n} from '../utils';\nimport {\n mutationCallBack,\n observerParam,\n mousemoveCallBack,\n mousePosition,\n mouseInteractionCallBack,\n MouseInteractions,\n listenerHandler,\n scrollCallback,\n styleSheetRuleCallback,\n viewportResizeCallback,\n inputValue,\n inputCallback,\n hookResetter,\n IncrementalSource,\n hooksParam,\n Arguments,\n mediaInteractionCallback,\n MediaInteractions,\n canvasMutationCallback,\n fontCallback,\n fontParam,\n styleDeclarationCallback,\n IWindow,\n MutationBufferParam,\n} from '../types';\nimport MutationBuffer from './mutation';\n\ntype WindowWithStoredMutationObserver = IWindow & {\n __rrMutationObserver?: MutationObserver;\n};\ntype WindowWithAngularZone = IWindow & {\n Zone?: {\n __symbol__?: (key: string) => string;\n };\n};\n\nexport const mutationBuffers: MutationBuffer[] = [];\n\nconst isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';\nconst isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';\nconst isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';\nconst isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';\n\n// Event.path is non-standard and used in some older browsers\ntype NonStandardEvent = Omit & {\n path: EventTarget[];\n};\n\nfunction getEventTarget(event: Event | NonStandardEvent): EventTarget | null {\n try {\n if ('composedPath' in event) {\n const path = event.composedPath();\n if (path.length) {\n return path[0];\n }\n } else if ('path' in event && event.path.length) {\n return event.path[0];\n }\n return event.target;\n } catch {\n return event.target;\n }\n}\n\nexport function initMutationObserver(\n options: MutationBufferParam,\n rootEl: Node,\n): MutationObserver {\n const mutationBuffer = new MutationBuffer();\n mutationBuffers.push(mutationBuffer);\n // see mutation.ts for details\n mutationBuffer.init(options);\n let mutationObserverCtor =\n window.MutationObserver ||\n /**\n * Some websites may disable MutationObserver by removing it from the window object.\n * If someone is using rrweb to build a browser extention or things like it, they\n * could not change the website's code but can have an opportunity to inject some\n * code before the website executing its JS logic.\n * Then they can do this to store the native MutationObserver:\n * window.__rrMutationObserver = MutationObserver\n */\n (window as WindowWithStoredMutationObserver).__rrMutationObserver;\n const angularZoneSymbol = (window as WindowWithAngularZone)?.Zone?.__symbol__?.(\n 'MutationObserver',\n );\n if (\n angularZoneSymbol &&\n ((window as unknown) as Record)[\n angularZoneSymbol\n ]\n ) {\n mutationObserverCtor = ((window as unknown) as Record<\n string,\n typeof MutationObserver\n >)[angularZoneSymbol];\n }\n const observer = new mutationObserverCtor(\n mutationBuffer.processMutations.bind(mutationBuffer),\n );\n observer.observe(rootEl, {\n attributes: true,\n attributeOldValue: true,\n characterData: true,\n characterDataOldValue: true,\n childList: true,\n subtree: true,\n });\n return observer;\n}\n\nfunction initMoveObserver({\n mousemoveCb,\n sampling,\n doc,\n mirror,\n}: observerParam): listenerHandler {\n if (sampling.mousemove === false) {\n return () => {};\n }\n\n const threshold =\n typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;\n const callbackThreshold =\n typeof sampling.mousemoveCallback === 'number'\n ? sampling.mousemoveCallback\n : 500;\n\n let positions: mousePosition[] = [];\n let timeBaseline: number | null;\n const wrappedCb = throttle(\n (\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n ) => {\n const totalOffset = Date.now() - timeBaseline!;\n mousemoveCb(\n positions.map((p) => {\n p.timeOffset -= totalOffset;\n return p;\n }),\n source,\n );\n positions = [];\n timeBaseline = null;\n },\n callbackThreshold,\n );\n const updatePosition = throttle(\n (evt) => {\n const target = getEventTarget(evt);\n const { clientX, clientY } = isTouchEvent(evt)\n ? evt.changedTouches[0]\n : evt;\n if (!timeBaseline) {\n timeBaseline = Date.now();\n }\n positions.push({\n x: clientX,\n y: clientY,\n id: mirror.getId(target as INode),\n timeOffset: Date.now() - timeBaseline,\n });\n // it is possible DragEvent is undefined even on devices\n // that support event 'drag'\n wrappedCb(\n typeof DragEvent !== 'undefined' && evt instanceof DragEvent\n ? IncrementalSource.Drag\n : evt instanceof MouseEvent\n ? IncrementalSource.MouseMove\n : IncrementalSource.TouchMove,\n );\n },\n threshold,\n {\n trailing: false,\n },\n );\n const handlers = [\n on('mousemove', updatePosition, doc),\n on('touchmove', updatePosition, doc),\n on('drag', updatePosition, doc),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initMouseInteractionObserver({\n mouseInteractionCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: observerParam): listenerHandler {\n if (sampling.mouseInteraction === false) {\n return () => {};\n }\n const disableMap: Record =\n sampling.mouseInteraction === true ||\n sampling.mouseInteraction === undefined\n ? {}\n : sampling.mouseInteraction;\n\n const handlers: listenerHandler[] = [];\n const getHandler = (eventKey: keyof typeof MouseInteractions) => {\n return (event: MouseEvent | TouchEvent) => {\n const target = getEventTarget(event) as Node;\n if (isBlocked(target as Node, blockClass)) {\n return;\n }\n const e = isTouchEvent(event) ? event.changedTouches[0] : event;\n if (!e) {\n return;\n }\n const id = mirror.getId(target as INode);\n const { clientX, clientY } = e;\n mouseInteractionCb({\n type: MouseInteractions[eventKey],\n id,\n x: clientX,\n y: clientY,\n });\n };\n };\n Object.keys(MouseInteractions)\n .filter(\n (key) =>\n Number.isNaN(Number(key)) &&\n !key.endsWith('_Departed') &&\n disableMap[key] !== false,\n )\n .forEach((eventKey: keyof typeof MouseInteractions) => {\n const eventName = eventKey.toLowerCase();\n const handler = getHandler(eventKey);\n handlers.push(on(eventName, handler, doc));\n });\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nexport function initScrollObserver({\n scrollCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: Pick<\n observerParam,\n 'scrollCb' | 'doc' | 'mirror' | 'blockClass' | 'sampling'\n>): listenerHandler {\n const updatePosition = throttle((evt) => {\n const target = getEventTarget(evt);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const id = mirror.getId(target as INode);\n if (target === doc) {\n const scrollEl = (doc.scrollingElement || doc.documentElement)!;\n scrollCb({\n id,\n x: scrollEl.scrollLeft,\n y: scrollEl.scrollTop,\n });\n } else {\n scrollCb({\n id,\n x: (target as HTMLElement).scrollLeft,\n y: (target as HTMLElement).scrollTop,\n });\n }\n }, sampling.scroll || 100);\n return on('scroll', updatePosition, doc);\n}\n\nfunction initViewportResizeObserver({\n viewportResizeCb,\n}: observerParam): listenerHandler {\n let lastH = -1;\n let lastW = -1;\n const updateDimension = throttle(() => {\n const height = getWindowHeight();\n const width = getWindowWidth();\n if (lastH !== height || lastW !== width) {\n viewportResizeCb({\n width: Number(width),\n height: Number(height),\n });\n lastH = height;\n lastW = width;\n }\n }, 200);\n return on('resize', updateDimension, window);\n}\n\nfunction wrapEventWithUserTriggeredFlag(\n v: inputValue,\n enable: boolean,\n): inputValue {\n const value = { ...v };\n if (!enable) delete value.userTriggered;\n return value;\n}\n\nexport const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];\nconst lastInputValueMap: WeakMap = new WeakMap();\nfunction initInputObserver({\n inputCb,\n doc,\n mirror,\n blockClass,\n ignoreClass,\n ignoreSelector,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskInputFn,\n sampling,\n userTriggeredOnInput,\n}: observerParam): listenerHandler {\n function eventHandler(event: Event) {\n let target = getEventTarget(event);\n const userTriggered = event.isTrusted;\n /**\n * If a site changes the value 'selected' of an option element, the value of its parent element, usually a select element, will be changed as well.\n * We can treat this change as a value change of the select element the current target belongs to.\n */\n if (target && (target as Element).tagName === 'OPTION')\n target = (target as Element).parentElement;\n if (\n !target ||\n !(target as Element).tagName ||\n INPUT_TAGS.indexOf((target as Element).tagName) < 0 ||\n isBlocked(target as Node, blockClass)\n ) {\n return;\n }\n const type: string | undefined = (target as HTMLInputElement).type;\n if ((target as HTMLElement).classList.contains(ignoreClass) || (ignoreSelector && (target as HTMLElement).matches(ignoreSelector))) {\n return;\n }\n let text = (target as HTMLInputElement).value;\n let isChecked = false;\n if (type === 'radio' || type === 'checkbox') {\n isChecked = (target as HTMLInputElement).checked;\n } else if (\n maskInputOptions[\n (target as Element).tagName.toLowerCase() as keyof MaskInputOptions\n ] ||\n maskInputOptions[type as keyof MaskInputOptions]\n ) {\n text = maskInputValue({\n input: (target as HTMLElement),\n maskInputOptions,\n maskInputSelector,\n unmaskInputSelector,\n tagName: (target as HTMLElement).tagName,\n type,\n value: text,\n maskInputFn,\n });\n }\n cbWithDedup(\n target,\n wrapEventWithUserTriggeredFlag(\n { text, isChecked, userTriggered },\n userTriggeredOnInput,\n ),\n );\n // if a radio was checked\n // the other radios with the same name attribute will be unchecked.\n const name: string | undefined = (target as HTMLInputElement).name;\n if (type === 'radio' && name && isChecked) {\n doc\n .querySelectorAll(`input[type=\"radio\"][name=\"${name}\"]`)\n .forEach((el) => {\n if (el !== target) {\n cbWithDedup(\n el,\n wrapEventWithUserTriggeredFlag(\n {\n text: (el as HTMLInputElement).value,\n isChecked: !isChecked,\n userTriggered: false,\n },\n userTriggeredOnInput,\n ),\n );\n }\n });\n }\n }\n function cbWithDedup(target: EventTarget, v: inputValue) {\n const lastInputValue = lastInputValueMap.get(target);\n if (\n !lastInputValue ||\n lastInputValue.text !== v.text ||\n lastInputValue.isChecked !== v.isChecked\n ) {\n lastInputValueMap.set(target, v);\n const id = mirror.getId(target as INode);\n inputCb({\n ...v,\n id,\n });\n }\n }\n const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];\n const handlers: Array<\n listenerHandler | hookResetter\n > = events.map((eventName) => on(eventName, eventHandler, doc));\n const propertyDescriptor = Object.getOwnPropertyDescriptor(\n HTMLInputElement.prototype,\n 'value',\n );\n const hookProperties: Array<[HTMLElement, string]> = [\n [HTMLInputElement.prototype, 'value'],\n [HTMLInputElement.prototype, 'checked'],\n [HTMLSelectElement.prototype, 'value'],\n [HTMLTextAreaElement.prototype, 'value'],\n // Some UI library use selectedIndex to set select value\n [HTMLSelectElement.prototype, 'selectedIndex'],\n [HTMLOptionElement.prototype, 'selected'],\n ];\n if (propertyDescriptor && propertyDescriptor.set) {\n handlers.push(\n ...hookProperties.map((p) =>\n hookSetter(p[0], p[1], {\n set() {\n // mock to a normal event\n eventHandler({ target: this } as Event);\n },\n }),\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\ntype GroupingCSSRule =\n | CSSGroupingRule\n | CSSMediaRule\n | CSSSupportsRule\n | CSSConditionRule;\ntype GroupingCSSRuleTypes =\n | typeof CSSGroupingRule\n | typeof CSSMediaRule\n | typeof CSSSupportsRule\n | typeof CSSConditionRule;\n\nfunction getNestedCSSRulePositions(rule: CSSRule): number[] {\n const positions: number[] = [];\n function recurse(childRule: CSSRule, pos: number[]) {\n if (\n (isCSSGroupingRuleSupported &&\n childRule.parentRule instanceof CSSGroupingRule) ||\n (isCSSMediaRuleSupported &&\n childRule.parentRule instanceof CSSMediaRule) ||\n (isCSSSupportsRuleSupported &&\n childRule.parentRule instanceof CSSSupportsRule) ||\n (isCSSConditionRuleSupported &&\n childRule.parentRule instanceof CSSConditionRule)\n ) {\n const rules = Array.from(\n (childRule.parentRule as GroupingCSSRule).cssRules,\n );\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n } else {\n const rules = Array.from(childRule.parentStyleSheet!.cssRules);\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n }\n return pos;\n }\n return recurse(rule, positions);\n}\n\nfunction initStyleSheetObserver(\n { styleSheetRuleCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {\n // If, for whatever reason, CSSStyleSheet is not available, we skip the observation of stylesheets.\n return () => {};\n }\n\n const insertRule = win.CSSStyleSheet.prototype.insertRule;\n win.CSSStyleSheet.prototype.insertRule = function (\n rule: string,\n index?: number,\n ) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [{ rule, index }],\n });\n }\n return insertRule.apply(this, arguments);\n };\n\n const deleteRule = win.CSSStyleSheet.prototype.deleteRule;\n win.CSSStyleSheet.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index }],\n });\n }\n return deleteRule.apply(this, arguments);\n };\n\n const supportedNestedCSSRuleTypes: {\n [key: string]: GroupingCSSRuleTypes;\n } = {};\n if (isCSSGroupingRuleSupported) {\n supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;\n } else {\n // Some browsers (Safari) don't support CSSGroupingRule\n // https://caniuse.com/?search=cssgroupingrule\n // fall back to monkey patching classes that would have inherited from CSSGroupingRule\n\n if (isCSSMediaRuleSupported) {\n supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;\n }\n if (isCSSConditionRuleSupported) {\n supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;\n }\n if (isCSSSupportsRuleSupported) {\n supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;\n }\n }\n\n const unmodifiedFunctions: {\n [key: string]: {\n insertRule: (rule: string, index?: number) => number;\n deleteRule: (index: number) => void;\n };\n } = {};\n\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n unmodifiedFunctions[typeKey] = {\n insertRule: (type as GroupingCSSRuleTypes).prototype.insertRule,\n deleteRule: (type as GroupingCSSRuleTypes).prototype.deleteRule,\n };\n\n type.prototype.insertRule = function (rule: string, index?: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [\n {\n rule,\n index: [\n ...getNestedCSSRulePositions(this),\n index || 0, // defaults to 0\n ],\n },\n ],\n });\n }\n return unmodifiedFunctions[typeKey].insertRule.apply(this, arguments);\n };\n\n type.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index: [...getNestedCSSRulePositions(this), index] }],\n });\n }\n return unmodifiedFunctions[typeKey].deleteRule.apply(this, arguments);\n };\n });\n\n return () => {\n win.CSSStyleSheet.prototype.insertRule = insertRule;\n win.CSSStyleSheet.prototype.deleteRule = deleteRule;\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;\n type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;\n });\n };\n}\n\nfunction initStyleDeclarationObserver(\n { styleDeclarationCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n const setProperty = win.CSSStyleDeclaration.prototype.setProperty;\n win.CSSStyleDeclaration.prototype.setProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n value: string,\n priority: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n set: {\n property,\n value,\n priority,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return setProperty.apply(this, arguments);\n };\n\n const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n remove: {\n property,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return removeProperty.apply(this, arguments);\n };\n\n return () => {\n win.CSSStyleDeclaration.prototype.setProperty = setProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;\n };\n}\n\nfunction initMediaInteractionObserver({\n mediaInteractionCb,\n blockClass,\n mirror,\n sampling,\n}: observerParam): listenerHandler {\n const handler = (type: MediaInteractions) =>\n throttle((event: Event) => {\n const target = getEventTarget(event);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const { currentTime, volume, muted } = target as HTMLMediaElement;\n mediaInteractionCb({\n type,\n id: mirror.getId(target as INode),\n currentTime,\n volume,\n muted,\n });\n }, sampling.media || 500);\n const handlers = [\n on('play', handler(MediaInteractions.Play)),\n on('pause', handler(MediaInteractions.Pause)),\n on('seeked', handler(MediaInteractions.Seeked)),\n on('volumechange', handler(MediaInteractions.VolumeChange)),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initFontObserver({ fontCb, doc }: observerParam): listenerHandler {\n const win = doc.defaultView as IWindow;\n if (!win) {\n return () => {};\n }\n\n const handlers: listenerHandler[] = [];\n\n const fontMap = new WeakMap();\n\n const originalFontFace = win.FontFace;\n win.FontFace = (function FontFace(\n family: string,\n source: string | ArrayBufferView,\n descriptors?: FontFaceDescriptors,\n ) {\n const fontFace = new originalFontFace(family, source, descriptors);\n fontMap.set(fontFace, {\n family,\n buffer: typeof source !== 'string',\n descriptors,\n fontSource:\n typeof source === 'string'\n ? source\n : // tslint:disable-next-line: no-any\n JSON.stringify(Array.from(new Uint8Array(source as any))),\n });\n return fontFace;\n } as unknown) as typeof FontFace;\n\n const restoreHandler = patch(doc.fonts, 'add', function (original) {\n return function (this: FontFaceSet, fontFace: FontFace) {\n setTimeout(() => {\n const p = fontMap.get(fontFace);\n if (p) {\n fontCb(p);\n fontMap.delete(fontFace);\n }\n }, 0);\n return original.apply(this, [fontFace]);\n };\n });\n\n handlers.push(() => {\n win.FontFace = originalFontFace;\n });\n handlers.push(restoreHandler);\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction mergeHooks(o: observerParam, hooks: hooksParam) {\n const {\n mutationCb,\n mousemoveCb,\n mouseInteractionCb,\n scrollCb,\n viewportResizeCb,\n inputCb,\n mediaInteractionCb,\n styleSheetRuleCb,\n styleDeclarationCb,\n canvasMutationCb,\n fontCb,\n } = o;\n o.mutationCb = (...p: Arguments) => {\n if (hooks.mutation) {\n hooks.mutation(...p);\n }\n mutationCb(...p);\n };\n o.mousemoveCb = (...p: Arguments) => {\n if (hooks.mousemove) {\n hooks.mousemove(...p);\n }\n mousemoveCb(...p);\n };\n o.mouseInteractionCb = (...p: Arguments) => {\n if (hooks.mouseInteraction) {\n hooks.mouseInteraction(...p);\n }\n mouseInteractionCb(...p);\n };\n o.scrollCb = (...p: Arguments) => {\n if (hooks.scroll) {\n hooks.scroll(...p);\n }\n scrollCb(...p);\n };\n o.viewportResizeCb = (...p: Arguments) => {\n if (hooks.viewportResize) {\n hooks.viewportResize(...p);\n }\n viewportResizeCb(...p);\n };\n o.inputCb = (...p: Arguments) => {\n if (hooks.input) {\n hooks.input(...p);\n }\n inputCb(...p);\n };\n o.mediaInteractionCb = (...p: Arguments) => {\n if (hooks.mediaInteaction) {\n hooks.mediaInteaction(...p);\n }\n mediaInteractionCb(...p);\n };\n o.styleSheetRuleCb = (...p: Arguments) => {\n if (hooks.styleSheetRule) {\n hooks.styleSheetRule(...p);\n }\n styleSheetRuleCb(...p);\n };\n o.styleDeclarationCb = (...p: Arguments) => {\n if (hooks.styleDeclaration) {\n hooks.styleDeclaration(...p);\n }\n styleDeclarationCb(...p);\n };\n o.canvasMutationCb = (...p: Arguments) => {\n if (hooks.canvasMutation) {\n hooks.canvasMutation(...p);\n }\n canvasMutationCb(...p);\n };\n o.fontCb = (...p: Arguments) => {\n if (hooks.font) {\n hooks.font(...p);\n }\n fontCb(...p);\n };\n}\n\nexport function initObservers(\n o: observerParam,\n hooks: hooksParam = {},\n): listenerHandler {\n const currentWindow = o.doc.defaultView; // basically document.window\n if (!currentWindow) {\n return () => {};\n }\n\n mergeHooks(o, hooks);\n const mutationObserver = initMutationObserver(o, o.doc);\n const mousemoveHandler = initMoveObserver(o);\n const mouseInteractionHandler = initMouseInteractionObserver(o);\n const scrollHandler = initScrollObserver(o);\n const viewportResizeHandler = initViewportResizeObserver(o);\n const inputHandler = initInputObserver(o);\n const mediaInteractionHandler = initMediaInteractionObserver(o);\n\n const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });\n const styleDeclarationObserver = initStyleDeclarationObserver(o, {\n win: currentWindow,\n });\n const fontObserver = o.collectFonts ? initFontObserver(o) : () => {};\n // plugins\n const pluginHandlers: listenerHandler[] = [];\n for (const plugin of o.plugins) {\n pluginHandlers.push(\n plugin.observer(plugin.callback, currentWindow, plugin.options),\n );\n }\n\n return () => {\n mutationBuffers.forEach((b) => b.reset());\n mutationObserver.disconnect();\n mousemoveHandler();\n mouseInteractionHandler();\n scrollHandler();\n viewportResizeHandler();\n inputHandler();\n mediaInteractionHandler();\n styleSheetObserver();\n styleDeclarationObserver();\n fontObserver();\n pluginHandlers.forEach((h) => h());\n };\n}\n","import { serializedNodeWithId, INode } from 'rrweb-snapshot';\nimport { mutationCallBack } from '../types';\n\nexport class IframeManager {\n private iframes: WeakMap = new WeakMap();\n private mutationCb: mutationCallBack;\n private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;\n\n constructor(options: { mutationCb: mutationCallBack }) {\n this.mutationCb = options.mutationCb;\n }\n\n public addIframe(iframeEl: HTMLIFrameElement) {\n this.iframes.set(iframeEl, true);\n }\n\n public addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown) {\n this.loadListener = cb;\n }\n\n public attachIframe(iframeEl: INode, childSn: serializedNodeWithId) {\n this.mutationCb({\n adds: [\n {\n parentId: iframeEl.__sn.id,\n nextId: null,\n node: childSn,\n },\n ],\n removes: [],\n texts: [],\n attributes: [],\n isAttachIframe: true,\n });\n this.loadListener?.((iframeEl as unknown) as HTMLIFrameElement);\n }\n}\n","import {\n mutationCallBack,\n Mirror,\n scrollCallback,\n MutationBufferParam,\n SamplingStrategy,\n} from '../types';\nimport { initMutationObserver, initScrollObserver } from './observer';\nimport { patch } from '../utils';\n\ntype BypassOptions = Omit<\n MutationBufferParam,\n 'doc' | 'mutationCb' | 'mirror' | 'shadowDomManager'\n> & {\n sampling: SamplingStrategy;\n};\n\nexport class ShadowDomManager {\n private mutationCb: mutationCallBack;\n private scrollCb: scrollCallback;\n private bypassOptions: BypassOptions;\n private mirror: Mirror;\n private restorePatches: (() => void)[] = [];\n\n constructor(options: {\n mutationCb: mutationCallBack;\n scrollCb: scrollCallback;\n bypassOptions: BypassOptions;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.scrollCb = options.scrollCb;\n this.bypassOptions = options.bypassOptions;\n this.mirror = options.mirror;\n\n // Patch 'attachShadow' to observe newly added shadow doms.\n const manager = this;\n this.restorePatches.push(\n patch(HTMLElement.prototype, 'attachShadow', function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(this.shadowRoot, this.ownerDocument);\n return shadowRoot;\n };\n }),\n );\n }\n\n public addShadowRoot(shadowRoot: ShadowRoot, doc: Document) {\n initMutationObserver(\n {\n ...this.bypassOptions,\n doc,\n mutationCb: this.mutationCb,\n mirror: this.mirror,\n shadowDomManager: this,\n },\n shadowRoot,\n );\n initScrollObserver({\n ...this.bypassOptions,\n scrollCb: this.scrollCb,\n // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813\n // scroll is not allowed to pass the boundary, so we need to listen the shadow document\n doc: (shadowRoot as unknown) as Document,\n mirror: this.mirror,\n });\n }\n\n /**\n * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.\n */\n public observeAttachShadow(iframeElement: HTMLIFrameElement) {\n if (iframeElement.contentWindow) {\n const manager = this;\n this.restorePatches.push(\n patch(\n (iframeElement.contentWindow as Window & {\n HTMLElement: { prototype: HTMLElement };\n }).HTMLElement.prototype,\n 'attachShadow',\n function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(\n this.shadowRoot,\n iframeElement.contentDocument as Document,\n );\n return shadowRoot;\n };\n },\n ),\n );\n }\n }\n\n public reset() {\n this.restorePatches.forEach((restorePatch) => restorePatch());\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { encode } from 'base64-arraybuffer';\nimport { IWindow, SerializedWebGlArg } from '../../../types';\n\n// TODO: unify with `replay/webgl.ts`\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nexport const saveWebGLVar = (\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): number | void => {\n if (\n !value ||\n !(isInstanceOfWebGLObject(value, win) || typeof value === 'object')\n )\n return;\n\n const name = value.constructor.name;\n const list = variableListFor(ctx, name);\n let index = list.indexOf(value);\n\n if (index === -1) {\n index = list.length;\n list.push(value);\n }\n return index;\n};\n\n// from webgl-recorder: https://github.com/evanw/webgl-recorder/blob/bef0e65596e981ee382126587e2dcbe0fc7748e2/webgl-recorder.js#L50-L77\nexport function serializeArg(\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): SerializedWebGlArg {\n if (value instanceof Array) {\n return value.map((arg) => serializeArg(arg, win, ctx));\n } else if (value === null) {\n return value;\n } else if (\n value instanceof Float32Array ||\n value instanceof Float64Array ||\n value instanceof Int32Array ||\n value instanceof Uint32Array ||\n value instanceof Uint8Array ||\n value instanceof Uint16Array ||\n value instanceof Int16Array ||\n value instanceof Int8Array ||\n value instanceof Uint8ClampedArray\n ) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [Object.values(value)],\n };\n } else if (\n // SharedArrayBuffer disabled on most browsers due to spectre.\n // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer\n // value instanceof SharedArrayBuffer ||\n value instanceof ArrayBuffer\n ) {\n const name = value.constructor.name as 'ArrayBuffer';\n const base64 = encode(value);\n\n return {\n rr_type: name,\n base64,\n };\n } else if (value instanceof DataView) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [\n serializeArg(value.buffer, win, ctx),\n value.byteOffset,\n value.byteLength,\n ],\n };\n } else if (value instanceof HTMLImageElement) {\n const name = value.constructor.name;\n const { src } = value;\n return {\n rr_type: name,\n src,\n };\n } else if (value instanceof ImageData) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [serializeArg(value.data, win, ctx), value.width, value.height],\n };\n } else if (isInstanceOfWebGLObject(value, win) || typeof value === 'object') {\n const name = value.constructor.name;\n const index = saveWebGLVar(value, win, ctx) as number;\n\n return {\n rr_type: name,\n index: index,\n };\n }\n\n return value;\n}\n\nexport const serializeArgs = (\n args: Array,\n win: IWindow,\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n) => {\n return [...args].map((arg) => serializeArg(arg, win, ctx));\n};\n\nexport const isInstanceOfWebGLObject = (\n value: any,\n win: IWindow,\n): value is\n | WebGLActiveInfo\n | WebGLBuffer\n | WebGLFramebuffer\n | WebGLProgram\n | WebGLRenderbuffer\n | WebGLShader\n | WebGLShaderPrecisionFormat\n | WebGLTexture\n | WebGLUniformLocation\n | WebGLVertexArrayObject => {\n const webGLConstructorNames: string[] = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.\n 'WebGLVertexArrayObjectOES',\n ];\n const supportedWebGLConstructorNames = webGLConstructorNames.filter(\n (name: string) => typeof win[name as keyof Window] === 'function',\n );\n return Boolean(\n supportedWebGLConstructorNames.find(\n (name: string) => value instanceof win[name as keyof Window],\n ),\n );\n};\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\nimport { saveWebGLVar, serializeArgs } from './serialize-args';\n\nfunction patchGLPrototype(\n prototype: WebGLRenderingContext | WebGL2RenderingContext,\n type: CanvasContext,\n cb: canvasManagerMutationCallback,\n blockClass: blockClass,\n mirror: Mirror,\n win: IWindow,\n): listenerHandler[] {\n const handlers: listenerHandler[] = [];\n\n const props = Object.getOwnPropertyNames(prototype);\n\n for (const prop of props) {\n try {\n if (typeof prototype[prop as keyof typeof prototype] !== 'function') {\n continue;\n }\n const restoreHandler = patch(prototype, prop, function (original) {\n return function (this: typeof prototype, ...args: Array) {\n const result = original.apply(this, args);\n saveWebGLVar(result, win, prototype);\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n const id = mirror.getId((this.canvas as unknown) as INode);\n\n const recordArgs = serializeArgs([...args], win, prototype);\n const mutation: canvasMutationWithType = {\n type,\n property: prop,\n args: recordArgs,\n };\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, mutation);\n }\n\n return result;\n };\n });\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(prototype, prop, {\n set(v) {\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, {\n type,\n property: prop,\n args: [v],\n setter: true,\n });\n },\n });\n handlers.push(hookHandler);\n }\n }\n\n return handlers;\n}\n\nexport default function initCanvasWebGLMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n\n handlers.push(\n ...patchGLPrototype(\n win.WebGLRenderingContext.prototype,\n CanvasContext.WebGL,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n\n if (typeof win.WebGL2RenderingContext !== 'undefined') {\n handlers.push(\n ...patchGLPrototype(\n win.WebGL2RenderingContext.prototype,\n CanvasContext.WebGL2,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n }\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n canvasManagerMutationCallback,\n canvasMutationCallback,\n canvasMutationCommand,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport initCanvas2DMutationObserver from './2d';\nimport initCanvasContextObserver from './canvas';\nimport initCanvasWebGLMutationObserver from './webgl';\n\nexport type RafStamps = { latestId: number; invokeId: number | null };\n\ntype pendingCanvasMutationsMap = Map<\n HTMLCanvasElement,\n canvasMutationWithType[]\n>;\n\nexport class CanvasManager {\n private pendingCanvasMutations: pendingCanvasMutationsMap = new Map();\n private rafStamps: RafStamps = { latestId: 0, invokeId: null };\n private mirror: Mirror;\n\n private mutationCb: canvasMutationCallback;\n private resetObservers?: listenerHandler;\n private frozen: boolean = false;\n private locked: boolean = false;\n\n public reset() {\n this.pendingCanvasMutations.clear();\n this.resetObservers && this.resetObservers();\n }\n\n public freeze() {\n this.frozen = true;\n }\n\n public unfreeze() {\n this.frozen = false;\n }\n\n public lock() {\n this.locked = true;\n }\n\n public unlock() {\n this.locked = false;\n }\n\n constructor(options: {\n recordCanvas: boolean | number;\n mutationCb: canvasMutationCallback;\n win: IWindow;\n blockClass: blockClass;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.mirror = options.mirror;\n\n if (options.recordCanvas === true)\n this.initCanvasMutationObserver(options.win, options.blockClass);\n }\n\n private processMutation: canvasManagerMutationCallback = function (\n target,\n mutation,\n ) {\n const newFrame =\n this.rafStamps.invokeId &&\n this.rafStamps.latestId !== this.rafStamps.invokeId;\n if (newFrame || !this.rafStamps.invokeId)\n this.rafStamps.invokeId = this.rafStamps.latestId;\n\n if (!this.pendingCanvasMutations.has(target)) {\n this.pendingCanvasMutations.set(target, []);\n }\n\n this.pendingCanvasMutations.get(target)!.push(mutation);\n };\n\n private initCanvasMutationObserver(\n win: IWindow,\n blockClass: blockClass,\n ): void {\n this.startRAFTimestamping();\n this.startPendingCanvasMutationFlusher();\n\n const canvasContextReset = initCanvasContextObserver(win, blockClass);\n const canvas2DReset = initCanvas2DMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n this.resetObservers = () => {\n canvasContextReset();\n canvas2DReset();\n canvasWebGL1and2Reset();\n };\n }\n\n private startPendingCanvasMutationFlusher() {\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n private startRAFTimestamping() {\n const setLatestRAFTimestamp = (timestamp: DOMHighResTimeStamp) => {\n this.rafStamps.latestId = timestamp;\n requestAnimationFrame(setLatestRAFTimestamp);\n };\n requestAnimationFrame(setLatestRAFTimestamp);\n }\n\n flushPendingCanvasMutations() {\n this.pendingCanvasMutations.forEach(\n (values: canvasMutationCommand[], canvas: HTMLCanvasElement) => {\n const id = this.mirror.getId((canvas as unknown) as INode);\n this.flushPendingCanvasMutationFor(canvas, id);\n },\n );\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n flushPendingCanvasMutationFor(canvas: HTMLCanvasElement, id: number) {\n if (this.frozen || this.locked) {\n return;\n }\n\n const valuesWithType = this.pendingCanvasMutations.get(canvas);\n if (!valuesWithType || id === -1) return;\n\n const values = valuesWithType.map((value) => {\n const { type, ...rest } = value;\n return rest;\n });\n const { type } = valuesWithType[0];\n\n this.mutationCb({ id, type, commands: values });\n\n this.pendingCanvasMutations.delete(canvas);\n }\n}\n","import { snapshot, MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';\nimport { initObservers, mutationBuffers } from './observer';\nimport {\n on,\n getWindowWidth,\n getWindowHeight,\n polyfill,\n isIframeINode,\n hasShadowRoot,\n createMirror,\n} from '../utils';\nimport {\n EventType,\n event,\n eventWithTime,\n recordOptions,\n IncrementalSource,\n listenerHandler,\n mutationCallbackParam,\n scrollCallback,\n canvasMutationParam,\n} from '../types';\nimport { IframeManager } from './iframe-manager';\nimport { ShadowDomManager } from './shadow-dom-manager';\nimport { CanvasManager } from './observers/canvas/canvas-manager';\n\nfunction wrapEvent(e: event): eventWithTime {\n return {\n ...e,\n timestamp: Date.now(),\n };\n}\n\nlet wrappedEmit!: (e: eventWithTime, isCheckout?: boolean) => void;\n\nlet takeFullSnapshot!: (isCheckout?: boolean) => void;\n\nconst mirror = createMirror();\nfunction record(\n options: recordOptions = {},\n): listenerHandler | undefined {\n const {\n emit,\n checkoutEveryNms,\n checkoutEveryNth,\n blockClass = 'rr-block',\n blockSelector = null,\n unblockSelector = null,\n ignoreClass = 'rr-ignore',\n ignoreSelector =null,\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n maskInputSelector = null,\n unmaskTextSelector = null,\n unmaskInputSelector = null,\n inlineStylesheet = true,\n maskAllInputs,\n maskInputOptions: _maskInputOptions,\n slimDOMOptions: _slimDOMOptions,\n maskInputFn,\n maskTextFn,\n hooks,\n packFn,\n sampling = {},\n mousemoveWait,\n recordCanvas = false,\n userTriggeredOnInput = false,\n collectFonts = false,\n inlineImages = false,\n plugins,\n keepIframeSrcFn = () => false,\n } = options;\n // runtime checks for user options\n if (!emit) {\n throw new Error('emit function is required');\n }\n // move departed options to new options\n if (mousemoveWait !== undefined && sampling.mousemove === undefined) {\n sampling.mousemove = mousemoveWait;\n }\n\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : _maskInputOptions !== undefined\n ? _maskInputOptions\n : { password: true };\n\n const slimDOMOptions: SlimDOMOptions =\n _slimDOMOptions === true || _slimDOMOptions === 'all'\n ? {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaVerification: true,\n // the following are off for slimDOMOptions === true,\n // as they destroy some (hidden) info:\n headMetaAuthorship: _slimDOMOptions === 'all',\n headMetaDescKeywords: _slimDOMOptions === 'all',\n }\n : _slimDOMOptions\n ? _slimDOMOptions\n : {};\n\n polyfill();\n\n let lastFullSnapshotEvent: eventWithTime;\n let incrementalSnapshotCount = 0;\n const eventProcessor = (e: eventWithTime): T => {\n for (const plugin of plugins || []) {\n if (plugin.eventProcessor) {\n e = plugin.eventProcessor(e);\n }\n }\n if (packFn) {\n e = (packFn(e) as unknown) as eventWithTime;\n }\n return (e as unknown) as T;\n };\n wrappedEmit = (e: eventWithTime, isCheckout?: boolean) => {\n if (\n mutationBuffers[0]?.isFrozen() &&\n e.type !== EventType.FullSnapshot &&\n !(\n e.type === EventType.IncrementalSnapshot &&\n e.data.source === IncrementalSource.Mutation\n )\n ) {\n // we've got a user initiated event so first we need to apply\n // all DOM changes that have been buffering during paused state\n mutationBuffers.forEach((buf) => buf.unfreeze());\n }\n\n emit(eventProcessor(e), isCheckout);\n if (e.type === EventType.FullSnapshot) {\n lastFullSnapshotEvent = e;\n incrementalSnapshotCount = 0;\n } else if (e.type === EventType.IncrementalSnapshot) {\n // attach iframe should be considered as full snapshot\n if (\n e.data.source === IncrementalSource.Mutation &&\n e.data.isAttachIframe\n ) {\n return;\n }\n\n incrementalSnapshotCount++;\n const exceedCount =\n checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;\n const exceedTime =\n checkoutEveryNms &&\n e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;\n if (exceedCount || exceedTime) {\n takeFullSnapshot(true);\n }\n }\n };\n\n const wrappedMutationEmit = (m: mutationCallbackParam) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Mutation,\n ...m,\n },\n }),\n );\n };\n const wrappedScrollEmit: scrollCallback = (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Scroll,\n ...p,\n },\n }),\n );\n const wrappedCanvasMutationEmit = (p: canvasMutationParam) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.CanvasMutation,\n ...p,\n },\n }),\n );\n\n const iframeManager = new IframeManager({\n mutationCb: wrappedMutationEmit,\n });\n\n const canvasManager = new CanvasManager({\n recordCanvas,\n mutationCb: wrappedCanvasMutationEmit,\n win: window,\n blockClass,\n mirror,\n });\n\n const shadowDomManager = new ShadowDomManager({\n mutationCb: wrappedMutationEmit,\n scrollCb: wrappedScrollEmit,\n bypassOptions: {\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n maskInputSelector,\n unmaskInputSelector,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n recordCanvas,\n inlineImages,\n sampling,\n slimDOMOptions,\n iframeManager,\n canvasManager,\n },\n mirror,\n });\n\n takeFullSnapshot = (isCheckout = false) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Meta,\n data: {\n href: window.location.href,\n width: getWindowWidth(),\n height: getWindowHeight(),\n },\n }),\n isCheckout,\n );\n\n mutationBuffers.forEach((buf) => buf.lock()); // don't allow any mirror modifications during snapshotting\n const [node, idNodeMap] = snapshot(document, {\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n maskInputSelector,\n unmaskInputSelector,\n inlineStylesheet,\n maskAllInputs: maskInputOptions,\n maskTextFn,\n slimDOM: slimDOMOptions,\n recordCanvas,\n inlineImages,\n onSerialize: (n) => {\n if (isIframeINode(n)) {\n iframeManager.addIframe(n);\n }\n if (hasShadowRoot(n)) {\n shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n iframeManager.attachIframe(iframe, childSn);\n shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n keepIframeSrcFn,\n });\n\n if (!node) {\n return console.warn('Failed to snapshot the document');\n }\n\n mirror.map = idNodeMap;\n wrappedEmit(\n wrapEvent({\n type: EventType.FullSnapshot,\n data: {\n node,\n initialOffset: {\n left:\n window.pageXOffset !== undefined\n ? window.pageXOffset\n : document?.documentElement.scrollLeft ||\n document?.body?.parentElement?.scrollLeft ||\n document?.body.scrollLeft ||\n 0,\n top:\n window.pageYOffset !== undefined\n ? window.pageYOffset\n : document?.documentElement.scrollTop ||\n document?.body?.parentElement?.scrollTop ||\n document?.body.scrollTop ||\n 0,\n },\n },\n }),\n );\n mutationBuffers.forEach((buf) => buf.unlock()); // generate & emit any mutations that happened during snapshotting, as can now apply against the newly built mirror\n };\n\n try {\n const handlers: listenerHandler[] = [];\n handlers.push(\n on('DOMContentLoaded', () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.DomContentLoaded,\n data: {},\n }),\n );\n }),\n );\n\n const observe = (doc: Document) => {\n return initObservers(\n {\n mutationCb: wrappedMutationEmit,\n mousemoveCb: (positions, source) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source,\n positions,\n },\n }),\n ),\n mouseInteractionCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MouseInteraction,\n ...d,\n },\n }),\n ),\n scrollCb: wrappedScrollEmit,\n viewportResizeCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.ViewportResize,\n ...d,\n },\n }),\n ),\n inputCb: (v) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Input,\n ...v,\n },\n }),\n ),\n mediaInteractionCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MediaInteraction,\n ...p,\n },\n }),\n ),\n styleSheetRuleCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleSheetRule,\n ...r,\n },\n }),\n ),\n styleDeclarationCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleDeclaration,\n ...r,\n },\n }),\n ),\n canvasMutationCb: wrappedCanvasMutationEmit,\n fontCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Font,\n ...p,\n },\n }),\n ),\n blockClass,\n ignoreClass,\n ignoreSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n inlineStylesheet,\n sampling,\n recordCanvas,\n inlineImages,\n userTriggeredOnInput,\n collectFonts,\n doc,\n maskInputFn,\n maskTextFn,\n blockSelector,\n unblockSelector,\n slimDOMOptions,\n mirror,\n iframeManager,\n shadowDomManager,\n canvasManager,\n plugins:\n plugins\n ?.filter((p) => p.observer)\n ?.map((p) => ({\n observer: p.observer!,\n options: p.options,\n callback: (payload: object) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.Plugin,\n data: {\n plugin: p.name,\n payload,\n },\n }),\n ),\n })) || [],\n },\n hooks,\n );\n };\n\n iframeManager.addLoadListener((iframeEl) => {\n try {\n handlers.push(observe(iframeEl.contentDocument!));\n } catch (error) {\n // TODO: handle internal error\n console.warn(error);\n }\n });\n\n const init = () => {\n takeFullSnapshot();\n handlers.push(observe(document));\n };\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n init();\n } else {\n handlers.push(\n on(\n 'load',\n () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Load,\n data: {},\n }),\n );\n init();\n },\n window,\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n } catch (error) {\n // TODO: handle internal error\n console.warn(error);\n }\n}\n\nrecord.addCustomEvent = (tag: string, payload: T) => {\n if (!wrappedEmit) {\n throw new Error('please add custom event after start recording');\n }\n wrappedEmit(\n wrapEvent({\n type: EventType.Custom,\n data: {\n tag,\n payload,\n },\n }),\n );\n};\n\nrecord.freezePage = () => {\n mutationBuffers.forEach((buf) => buf.freeze());\n};\n\nrecord.takeFullSnapshot = (isCheckout?: boolean) => {\n if (!takeFullSnapshot) {\n throw new Error('please take full snapshot after start recording');\n }\n takeFullSnapshot(isCheckout);\n};\n\nrecord.mirror = mirror;\n\nexport default record;\n","import { INode, ICanvas } from 'rrweb-snapshot';\nimport { blockClass, IWindow, listenerHandler } from '../../../types';\nimport { isBlocked, patch } from '../../../utils';\n\nexport default function initCanvasContextObserver(\n win: IWindow,\n blockClass: blockClass,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n try {\n const restoreHandler = patch(\n win.HTMLCanvasElement.prototype,\n 'getContext',\n function (original) {\n return function (\n this: ICanvas,\n contextType: string,\n ...args: Array\n ) {\n if (!isBlocked((this as unknown) as INode, blockClass)) {\n if (!('__context' in this))\n (this as ICanvas).__context = contextType;\n }\n return original.apply(this, [contextType, ...args]);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n console.error('failed to patch HTMLCanvasElement.prototype.getContext');\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\n\nexport default function initCanvas2DMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n const props2D = Object.getOwnPropertyNames(\n win.CanvasRenderingContext2D.prototype,\n );\n for (const prop of props2D) {\n try {\n if (\n typeof win.CanvasRenderingContext2D.prototype[\n prop as keyof CanvasRenderingContext2D\n ] !== 'function'\n ) {\n continue;\n }\n const restoreHandler = patch(\n win.CanvasRenderingContext2D.prototype,\n prop,\n function (original) {\n return function (\n this: CanvasRenderingContext2D,\n ...args: Array\n ) {\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n // Using setTimeout as getImageData + JSON.stringify can be heavy\n // and we'd rather not block the main thread\n setTimeout(() => {\n const recordArgs = [...args];\n if (prop === 'drawImage') {\n if (\n recordArgs[0] &&\n recordArgs[0] instanceof HTMLCanvasElement\n ) {\n const canvas = recordArgs[0];\n const ctx = canvas.getContext('2d');\n let imgd = ctx?.getImageData(\n 0,\n 0,\n canvas.width,\n canvas.height,\n );\n let pix = imgd?.data;\n recordArgs[0] = JSON.stringify(pix);\n }\n }\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: recordArgs,\n });\n }, 0);\n }\n return original.apply(this, args);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(\n win.CanvasRenderingContext2D.prototype,\n prop,\n {\n set(v) {\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: [v],\n setter: true,\n });\n },\n },\n );\n handlers.push(hookHandler);\n }\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","// \n// An event handler can take an optional event argument\n// and should not return a value\n \n \n\n// An array of all currently registered event handlers for a type\n \n \n// A map of event types and their corresponding event handlers.\n \n \n \n \n\n/** Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nfunction mitt(all ) {\n\tall = all || Object.create(null);\n\n\treturn {\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton: function on(type , handler ) {\n\t\t\t(all[type] || (all[type] = [])).push(handler);\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff: function off(type , handler ) {\n\t\t\tif (all[type]) {\n\t\t\t\tall[type].splice(all[type].indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * @param {String} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit: function emit(type , evt ) {\n\t\t\t(all[type] || []).slice().map(function (handler) { handler(evt); });\n\t\t\t(all['*'] || []).slice().map(function (handler) { handler(type, evt); });\n\t\t}\n\t};\n}\n\nexport default mitt;\n//# sourceMappingURL=mitt.es.js.map\n","/**\n * A fork version of https://github.com/iamdustan/smoothscroll\n * Add support of customize target window and document\n */\n\n// @ts-nocheck\n// tslint:disable\nexport function polyfill(w: Window = window, d = document) {\n // return if scroll behavior is supported and polyfill is not forced\n if (\n 'scrollBehavior' in d.documentElement.style &&\n w.__forceSmoothScrollPolyfill__ !== true\n ) {\n return;\n }\n\n // globals\n var Element = w.HTMLElement || w.Element;\n var SCROLL_TIME = 468;\n\n // object gathering original scroll methods\n var original = {\n scroll: w.scroll || w.scrollTo,\n scrollBy: w.scrollBy,\n elementScroll: Element.prototype.scroll || scrollElement,\n scrollIntoView: Element.prototype.scrollIntoView,\n };\n\n // define timing method\n var now =\n w.performance && w.performance.now\n ? w.performance.now.bind(w.performance)\n : Date.now;\n\n /**\n * indicates if a the current browser is made by Microsoft\n * @method isMicrosoftBrowser\n * @param {String} userAgent\n * @returns {Boolean}\n */\n function isMicrosoftBrowser(userAgent) {\n var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];\n\n return new RegExp(userAgentPatterns.join('|')).test(userAgent);\n }\n\n /*\n * IE has rounding bug rounding down clientHeight and clientWidth and\n * rounding up scrollHeight and scrollWidth causing false positives\n * on hasScrollableSpace\n */\n var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;\n\n /**\n * changes scroll position inside an element\n * @method scrollElement\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function scrollElement(x, y) {\n this.scrollLeft = x;\n this.scrollTop = y;\n }\n\n /**\n * returns result of applying ease math function to a number\n * @method ease\n * @param {Number} k\n * @returns {Number}\n */\n function ease(k) {\n return 0.5 * (1 - Math.cos(Math.PI * k));\n }\n\n /**\n * indicates if a smooth behavior should be applied\n * @method shouldBailOut\n * @param {Number|Object} firstArg\n * @returns {Boolean}\n */\n function shouldBailOut(firstArg) {\n if (\n firstArg === null ||\n typeof firstArg !== 'object' ||\n firstArg.behavior === undefined ||\n firstArg.behavior === 'auto' ||\n firstArg.behavior === 'instant'\n ) {\n // first argument is not an object/null\n // or behavior is auto, instant or undefined\n return true;\n }\n\n if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {\n // first argument is an object and behavior is smooth\n return false;\n }\n\n // throw error when behavior is not supported\n throw new TypeError(\n 'behavior member of ScrollOptions ' +\n firstArg.behavior +\n ' is not a valid value for enumeration ScrollBehavior.',\n );\n }\n\n /**\n * indicates if an element has scrollable space in the provided axis\n * @method hasScrollableSpace\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function hasScrollableSpace(el, axis) {\n if (axis === 'Y') {\n return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;\n }\n\n if (axis === 'X') {\n return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;\n }\n }\n\n /**\n * indicates if an element has a scrollable overflow property in the axis\n * @method canOverflow\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function canOverflow(el, axis) {\n var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];\n\n return overflowValue === 'auto' || overflowValue === 'scroll';\n }\n\n /**\n * indicates if an element can be scrolled in either axis\n * @method isScrollable\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function isScrollable(el) {\n var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');\n var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');\n\n return isScrollableY || isScrollableX;\n }\n\n /**\n * finds scrollable parent of an element\n * @method findScrollableParent\n * @param {Node} el\n * @returns {Node} el\n */\n function findScrollableParent(el) {\n while (el !== d.body && isScrollable(el) === false) {\n el = el.parentNode || el.host;\n }\n\n return el;\n }\n\n /**\n * self invoked function that, given a context, steps through scrolling\n * @method step\n * @param {Object} context\n * @returns {undefined}\n */\n function step(context) {\n var time = now();\n var value;\n var currentX;\n var currentY;\n var elapsed = (time - context.startTime) / SCROLL_TIME;\n\n // avoid elapsed times higher than one\n elapsed = elapsed > 1 ? 1 : elapsed;\n\n // apply easing to elapsed time\n value = ease(elapsed);\n\n currentX = context.startX + (context.x - context.startX) * value;\n currentY = context.startY + (context.y - context.startY) * value;\n\n context.method.call(context.scrollable, currentX, currentY);\n\n // scroll more if we have not reached our destination\n if (currentX !== context.x || currentY !== context.y) {\n w.requestAnimationFrame(step.bind(w, context));\n }\n }\n\n /**\n * scrolls window or element with a smooth behavior\n * @method smoothScroll\n * @param {Object|Node} el\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function smoothScroll(el, x, y) {\n var scrollable;\n var startX;\n var startY;\n var method;\n var startTime = now();\n\n // define scroll context\n if (el === d.body) {\n scrollable = w;\n startX = w.scrollX || w.pageXOffset;\n startY = w.scrollY || w.pageYOffset;\n method = original.scroll;\n } else {\n scrollable = el;\n startX = el.scrollLeft;\n startY = el.scrollTop;\n method = scrollElement;\n }\n\n // scroll looping over a frame\n step({\n scrollable: scrollable,\n method: method,\n startTime: startTime,\n startX: startX,\n startY: startY,\n x: x,\n y: y,\n });\n }\n\n // ORIGINAL METHODS OVERRIDES\n // w.scroll and w.scrollTo\n w.scroll = w.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scroll.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : w.scrollX || w.pageXOffset,\n // use top prop, second argument if present or fallback to scrollY\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : w.scrollY || w.pageYOffset,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : w.scrollX || w.pageXOffset,\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : w.scrollY || w.pageYOffset,\n );\n };\n\n // w.scrollBy\n w.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0])) {\n original.scrollBy.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : 0,\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : 0,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n ~~arguments[0].left + (w.scrollX || w.pageXOffset),\n ~~arguments[0].top + (w.scrollY || w.pageYOffset),\n );\n };\n\n // Element.prototype.scroll and Element.prototype.scrollTo\n Element.prototype.scroll = Element.prototype.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n // if one number is passed, throw error to match Firefox implementation\n if (typeof arguments[0] === 'number' && arguments[1] === undefined) {\n throw new SyntaxError('Value could not be converted');\n }\n\n original.elementScroll.call(\n this,\n // use left prop, first number argument or fallback to scrollLeft\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : typeof arguments[0] !== 'object'\n ? ~~arguments[0]\n : this.scrollLeft,\n // use top prop, second argument or fallback to scrollTop\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : arguments[1] !== undefined\n ? ~~arguments[1]\n : this.scrollTop,\n );\n\n return;\n }\n\n var left = arguments[0].left;\n var top = arguments[0].top;\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n this,\n this,\n typeof left === 'undefined' ? this.scrollLeft : ~~left,\n typeof top === 'undefined' ? this.scrollTop : ~~top,\n );\n };\n\n // Element.prototype.scrollBy\n Element.prototype.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.elementScroll.call(\n this,\n arguments[0].left !== undefined\n ? ~~arguments[0].left + this.scrollLeft\n : ~~arguments[0] + this.scrollLeft,\n arguments[0].top !== undefined\n ? ~~arguments[0].top + this.scrollTop\n : ~~arguments[1] + this.scrollTop,\n );\n\n return;\n }\n\n this.scroll({\n left: ~~arguments[0].left + this.scrollLeft,\n top: ~~arguments[0].top + this.scrollTop,\n behavior: arguments[0].behavior,\n });\n };\n\n // Element.prototype.scrollIntoView\n Element.prototype.scrollIntoView = function () {\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scrollIntoView.call(\n this,\n arguments[0] === undefined ? true : arguments[0],\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n var scrollableParent = findScrollableParent(this);\n var parentRects = scrollableParent.getBoundingClientRect();\n var clientRects = this.getBoundingClientRect();\n\n if (scrollableParent !== d.body) {\n // reveal element inside parent\n smoothScroll.call(\n this,\n scrollableParent,\n scrollableParent.scrollLeft + clientRects.left - parentRects.left,\n scrollableParent.scrollTop + clientRects.top - parentRects.top,\n );\n\n // reveal parent in viewport unless is fixed\n if (w.getComputedStyle(scrollableParent).position !== 'fixed') {\n w.scrollBy({\n left: parentRects.left,\n top: parentRects.top,\n behavior: 'smooth',\n });\n }\n } else {\n // reveal element in viewport\n w.scrollBy({\n left: clientRects.left,\n top: clientRects.top,\n behavior: 'smooth',\n });\n }\n };\n}\n","import {\n actionWithDelay,\n eventWithTime,\n EventType,\n IncrementalSource,\n} from '../types';\n\nexport class Timer {\n public timeOffset: number = 0;\n public speed: number;\n\n private actions: actionWithDelay[];\n private raf: number | null = null;\n private liveMode: boolean;\n\n constructor(actions: actionWithDelay[] = [], speed: number) {\n this.actions = actions;\n this.speed = speed;\n }\n /**\n * Add an action after the timer starts.\n * @param action\n */\n public addAction(action: actionWithDelay) {\n const index = this.findActionIndex(action);\n this.actions.splice(index, 0, action);\n }\n /**\n * Add all actions before the timer starts\n * @param actions\n */\n public addActions(actions: actionWithDelay[]) {\n this.actions = this.actions.concat(actions);\n }\n\n public start() {\n this.timeOffset = 0;\n let lastTimestamp = performance.now();\n const { actions } = this;\n const self = this;\n function check() {\n const time = performance.now();\n self.timeOffset += (time - lastTimestamp) * self.speed;\n lastTimestamp = time;\n while (actions.length) {\n const action = actions[0];\n\n if (self.timeOffset >= action.delay) {\n actions.shift();\n action.doAction();\n } else {\n break;\n }\n }\n if (actions.length > 0 || self.liveMode) {\n self.raf = requestAnimationFrame(check);\n }\n }\n this.raf = requestAnimationFrame(check);\n }\n\n public clear() {\n if (this.raf) {\n cancelAnimationFrame(this.raf);\n this.raf = null;\n }\n this.actions.length = 0;\n }\n\n public setSpeed(speed: number) {\n this.speed = speed;\n }\n\n public toggleLiveMode(mode: boolean) {\n this.liveMode = mode;\n }\n\n public isActive() {\n return this.raf !== null;\n }\n\n private findActionIndex(action: actionWithDelay): number {\n let start = 0;\n let end = this.actions.length - 1;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (this.actions[mid].delay < action.delay) {\n start = mid + 1;\n } else if (this.actions[mid].delay > action.delay) {\n end = mid - 1;\n } else {\n // already an action with same delay (timestamp)\n // the plus one will splice the new one after the existing one\n return mid + 1;\n }\n }\n return start;\n }\n}\n\n// TODO: add speed to mouse move timestamp calculation\nexport function addDelay(event: eventWithTime, baselineTime: number): number {\n // Mouse move events was recorded in a throttle function,\n // so we need to find the real timestamp by traverse the time offsets.\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove\n ) {\n const firstOffset = event.data.positions[0].timeOffset;\n // timeOffset is a negative offset to event.timestamp\n const firstTimestamp = event.timestamp + firstOffset;\n event.delay = firstTimestamp - baselineTime;\n return firstTimestamp - baselineTime;\n }\n\n event.delay = event.timestamp - baselineTime;\n return event.delay;\n}\n","/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return{type:\"xstate.assign\",assignment:t}}function i(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){o=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]=\"function\"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o]})),r=n,!1}return!0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})))},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u=\"object\"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}export{n as InterpreterStatus,o as assign,s as createMachine,v as interpret};\n","import { createMachine, interpret, assign, StateMachine } from '@xstate/fsm';\nimport {\n playerConfig,\n eventWithTime,\n actionWithDelay,\n ReplayerEvents,\n EventType,\n Emitter,\n IncrementalSource,\n} from '../types';\nimport { Timer, addDelay } from './timer';\n\nexport type PlayerContext = {\n events: eventWithTime[];\n timer: Timer;\n timeOffset: number;\n baselineTime: number;\n lastPlayedEvent: eventWithTime | null;\n};\nexport type PlayerEvent =\n | {\n type: 'PLAY';\n payload: {\n timeOffset: number;\n };\n }\n | {\n type: 'CAST_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | { type: 'PAUSE' }\n | { type: 'TO_LIVE'; payload: { baselineTime?: number } }\n | {\n type: 'ADD_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | {\n type: 'END';\n };\nexport type PlayerState =\n | {\n value: 'playing';\n context: PlayerContext;\n }\n | {\n value: 'paused';\n context: PlayerContext;\n }\n | {\n value: 'live';\n context: PlayerContext;\n };\n\n/**\n * If the array have multiple meta and fullsnapshot events,\n * return the events from last meta to the end.\n */\nexport function discardPriorSnapshots(\n events: eventWithTime[],\n baselineTime: number,\n): eventWithTime[] {\n for (let idx = events.length - 1; idx >= 0; idx--) {\n const event = events[idx];\n if (event.type === EventType.Meta) {\n if (event.timestamp <= baselineTime) {\n return events.slice(idx);\n }\n }\n }\n return events;\n}\n\ntype PlayerAssets = {\n emitter: Emitter;\n applyEventsSynchronously(events: Array): void;\n getCastFn(event: eventWithTime, isSync: boolean): () => void;\n};\nexport function createPlayerService(\n context: PlayerContext,\n { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets,\n) {\n const playerMachine = createMachine(\n {\n id: 'player',\n context,\n initial: 'paused',\n states: {\n playing: {\n on: {\n PAUSE: {\n target: 'paused',\n actions: ['pause'],\n },\n CAST_EVENT: {\n target: 'playing',\n actions: 'castEvent',\n },\n END: {\n target: 'paused',\n actions: ['resetLastPlayedEvent', 'pause'],\n },\n ADD_EVENT: {\n target: 'playing',\n actions: ['addEvent'],\n },\n },\n },\n paused: {\n on: {\n PLAY: {\n target: 'playing',\n actions: ['recordTimeOffset', 'play'],\n },\n CAST_EVENT: {\n target: 'paused',\n actions: 'castEvent',\n },\n TO_LIVE: {\n target: 'live',\n actions: ['startLive'],\n },\n ADD_EVENT: {\n target: 'paused',\n actions: ['addEvent'],\n },\n },\n },\n live: {\n on: {\n ADD_EVENT: {\n target: 'live',\n actions: ['addEvent'],\n },\n CAST_EVENT: {\n target: 'live',\n actions: ['castEvent'],\n },\n },\n },\n },\n },\n {\n actions: {\n castEvent: assign({\n lastPlayedEvent: (ctx, event) => {\n if (event.type === 'CAST_EVENT') {\n return event.payload.event;\n }\n return ctx.lastPlayedEvent;\n },\n }),\n recordTimeOffset: assign((ctx, event) => {\n let timeOffset = ctx.timeOffset;\n if ('payload' in event && 'timeOffset' in event.payload) {\n timeOffset = event.payload.timeOffset;\n }\n return {\n ...ctx,\n timeOffset,\n baselineTime: ctx.events[0].timestamp + timeOffset,\n };\n }),\n play(ctx) {\n const { timer, events, baselineTime, lastPlayedEvent } = ctx;\n timer.clear();\n\n for (const event of events) {\n // TODO: improve this API\n addDelay(event, baselineTime);\n }\n const neededEvents = discardPriorSnapshots(events, baselineTime);\n\n let lastPlayedTimestamp = lastPlayedEvent?.timestamp;\n if (\n lastPlayedEvent?.type === EventType.IncrementalSnapshot &&\n lastPlayedEvent.data.source === IncrementalSource.MouseMove\n ) {\n lastPlayedTimestamp =\n lastPlayedEvent.timestamp +\n lastPlayedEvent.data.positions[0]?.timeOffset;\n }\n if (baselineTime < (lastPlayedTimestamp || 0)) {\n emitter.emit(ReplayerEvents.PlayBack);\n }\n\n const syncEvents = new Array();\n const actions = new Array();\n for (const event of neededEvents) {\n if (\n lastPlayedTimestamp &&\n lastPlayedTimestamp < baselineTime &&\n (event.timestamp <= lastPlayedTimestamp ||\n event === lastPlayedEvent)\n ) {\n continue;\n }\n if (event.timestamp < baselineTime) {\n syncEvents.push(event);\n } else {\n const castFn = getCastFn(event, false);\n actions.push({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n applyEventsSynchronously(syncEvents);\n emitter.emit(ReplayerEvents.Flush);\n timer.addActions(actions);\n timer.start();\n },\n pause(ctx) {\n ctx.timer.clear();\n },\n resetLastPlayedEvent: assign((ctx) => {\n return {\n ...ctx,\n lastPlayedEvent: null,\n };\n }),\n startLive: assign({\n baselineTime: (ctx, event) => {\n ctx.timer.toggleLiveMode(true);\n ctx.timer.start();\n if (event.type === 'TO_LIVE' && event.payload.baselineTime) {\n return event.payload.baselineTime;\n }\n return Date.now();\n },\n }),\n addEvent: assign((ctx, machineEvent) => {\n const { baselineTime, timer, events } = ctx;\n if (machineEvent.type === 'ADD_EVENT') {\n const { event } = machineEvent.payload;\n addDelay(event, baselineTime);\n\n let end = events.length - 1;\n if (!events[end] || events[end].timestamp <= event.timestamp) {\n // fast track\n events.push(event);\n } else {\n let insertionIndex = -1;\n let start = 0;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (events[mid].timestamp <= event.timestamp) {\n start = mid + 1;\n } else {\n end = mid - 1;\n }\n }\n if (insertionIndex === -1) {\n insertionIndex = start;\n }\n events.splice(insertionIndex, 0, event);\n }\n\n const isSync = event.timestamp < baselineTime;\n const castFn = getCastFn(event, isSync);\n if (isSync) {\n castFn();\n } else if (timer.isActive()) {\n timer.addAction({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n return { ...ctx, events };\n }),\n },\n },\n );\n return interpret(playerMachine);\n}\n\nexport type SpeedContext = {\n normalSpeed: playerConfig['speed'];\n timer: Timer;\n};\n\nexport type SpeedEvent =\n | {\n type: 'FAST_FORWARD';\n payload: { speed: playerConfig['speed'] };\n }\n | {\n type: 'BACK_TO_NORMAL';\n }\n | {\n type: 'SET_SPEED';\n payload: { speed: playerConfig['speed'] };\n };\n\nexport type SpeedState =\n | {\n value: 'normal';\n context: SpeedContext;\n }\n | {\n value: 'skipping';\n context: SpeedContext;\n };\n\nexport function createSpeedService(context: SpeedContext) {\n const speedMachine = createMachine(\n {\n id: 'speed',\n context,\n initial: 'normal',\n states: {\n normal: {\n on: {\n FAST_FORWARD: {\n target: 'skipping',\n actions: ['recordSpeed', 'setSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n skipping: {\n on: {\n BACK_TO_NORMAL: {\n target: 'normal',\n actions: ['restoreSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n },\n },\n {\n actions: {\n setSpeed: (ctx, event) => {\n if ('payload' in event) {\n ctx.timer.setSpeed(event.payload.speed);\n }\n },\n recordSpeed: assign({\n normalSpeed: (ctx) => ctx.timer.speed,\n }),\n restoreSpeed: (ctx) => {\n ctx.timer.setSpeed(ctx.normalSpeed);\n },\n },\n },\n );\n\n return interpret(speedMachine);\n}\n\nexport type PlayerMachineState = StateMachine.State<\n PlayerContext,\n PlayerEvent,\n PlayerState\n>;\n\nexport type SpeedMachineState = StateMachine.State<\n SpeedContext,\n SpeedEvent,\n SpeedState\n>;\n","const rules: (blockClass: string) => string[] = (blockClass: string) => [\n `.${blockClass} { background: currentColor }`,\n 'noscript { display: none !important; }',\n];\n\nexport default rules;\n","import { INode } from 'rrweb-snapshot';\n\nexport enum StyleRuleType {\n Insert,\n Remove,\n Snapshot,\n SetProperty,\n RemoveProperty,\n}\n\ntype InsertRule = {\n cssText: string;\n type: StyleRuleType.Insert;\n index?: number | number[];\n};\ntype RemoveRule = {\n type: StyleRuleType.Remove;\n index: number | number[];\n};\ntype SnapshotRule = {\n type: StyleRuleType.Snapshot;\n cssTexts: string[];\n};\ntype SetPropertyRule = {\n type: StyleRuleType.SetProperty;\n index: number[];\n property: string;\n value: string | null;\n priority: string | undefined;\n};\ntype RemovePropertyRule = {\n type: StyleRuleType.RemoveProperty;\n index: number[];\n property: string;\n};\n\nexport type VirtualStyleRules = Array<\n InsertRule | RemoveRule | SnapshotRule | SetPropertyRule | RemovePropertyRule\n>;\nexport type VirtualStyleRulesMap = Map;\n\nexport function getNestedRule(\n rules: CSSRuleList,\n position: number[],\n): CSSGroupingRule {\n const rule = rules[position[0]] as CSSGroupingRule;\n if (position.length === 1) {\n return rule;\n } else {\n return getNestedRule(\n ((rule as CSSGroupingRule).cssRules[position[1]] as CSSGroupingRule)\n .cssRules,\n position.slice(2),\n );\n }\n}\n\nexport function getPositionsAndIndex(nestedIndex: number[]) {\n const positions = [...nestedIndex];\n const index = positions.pop();\n return { positions, index };\n}\n\nexport function applyVirtualStyleRulesToNode(\n storedRules: VirtualStyleRules,\n styleNode: HTMLStyleElement,\n) {\n const { sheet } = styleNode;\n if (!sheet) {\n // styleNode without sheet means the DOM has been removed\n // so the rules no longer need to be applied\n return;\n }\n\n storedRules.forEach((rule) => {\n if (rule.type === StyleRuleType.Insert) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.insertRule(rule.cssText, index);\n } else {\n sheet.insertRule(rule.cssText, rule.index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n } else if (rule.type === StyleRuleType.Remove) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.deleteRule(index || 0);\n } else {\n sheet.deleteRule(rule.index);\n }\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else if (rule.type === StyleRuleType.Snapshot) {\n restoreSnapshotOfStyleRulesToNode(rule.cssTexts, styleNode);\n } else if (rule.type === StyleRuleType.SetProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.setProperty(rule.property, rule.value, rule.priority);\n } else if (rule.type === StyleRuleType.RemoveProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.removeProperty(rule.property);\n }\n });\n}\n\nfunction restoreSnapshotOfStyleRulesToNode(\n cssTexts: string[],\n styleNode: HTMLStyleElement,\n) {\n try {\n const existingRules = Array.from(styleNode.sheet?.cssRules || []).map(\n (rule) => rule.cssText,\n );\n const existingRulesReversed = Object.entries(existingRules).reverse();\n let lastMatch = existingRules.length;\n existingRulesReversed.forEach(([index, rule]) => {\n const indexOf = cssTexts.indexOf(rule);\n if (indexOf === -1 || indexOf > lastMatch) {\n try {\n styleNode.sheet?.deleteRule(Number(index));\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n }\n lastMatch = indexOf;\n });\n cssTexts.forEach((cssText, index) => {\n try {\n if (styleNode.sheet?.cssRules[index]?.cssText !== cssText) {\n styleNode.sheet?.insertRule(cssText, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n });\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n\nexport function storeCSSRules(\n parentElement: HTMLStyleElement,\n virtualStyleRulesMap: VirtualStyleRulesMap,\n) {\n try {\n const cssTexts = Array.from(\n (parentElement as HTMLStyleElement).sheet?.cssRules || [],\n ).map((rule) => rule.cssText);\n virtualStyleRulesMap.set((parentElement as unknown) as INode, [\n {\n type: StyleRuleType.Snapshot,\n cssTexts,\n },\n ]);\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n","import { decode } from 'base64-arraybuffer';\nimport { Replayer } from '../';\nimport {\n CanvasContext,\n canvasMutationCommand,\n SerializedWebGlArg,\n} from '../../types';\n\n// TODO: add ability to wipe this list\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nfunction getContext(\n target: HTMLCanvasElement,\n type: CanvasContext,\n): WebGLRenderingContext | WebGL2RenderingContext | null {\n // Note to whomever is going to implement support for `contextAttributes`:\n // if `preserveDrawingBuffer` is set to true,\n // you might have to do `ctx.flush()` before every webgl canvas event\n try {\n if (type === CanvasContext.WebGL) {\n return (\n target.getContext('webgl')! || target.getContext('experimental-webgl')\n );\n }\n return target.getContext('webgl2')!;\n } catch (e) {\n return null;\n }\n}\n\nconst WebGLVariableConstructorsNames = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n];\n\nfunction saveToWebGLVarMap(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n result: any,\n) {\n if (!result?.constructor) return; // probably null or undefined\n\n const { name } = result.constructor;\n if (!WebGLVariableConstructorsNames.includes(name)) return; // not a WebGL variable\n\n const variables = variableListFor(ctx, name);\n if (!variables.includes(result)) variables.push(result);\n}\n\nexport function deserializeArg(\n imageMap: Replayer['imageMap'],\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n): (arg: SerializedWebGlArg) => any {\n return (arg: SerializedWebGlArg): any => {\n if (arg && typeof arg === 'object' && 'rr_type' in arg) {\n if ('index' in arg) {\n const { rr_type: name, index } = arg;\n return variableListFor(ctx, name)[index];\n } else if ('args' in arg) {\n const { rr_type: name, args } = arg;\n const ctor = window[name as keyof Window];\n\n return new ctor(...args.map(deserializeArg(imageMap, ctx)));\n } else if ('base64' in arg) {\n return decode(arg.base64);\n } else if ('src' in arg) {\n const image = imageMap.get(arg.src);\n if (image) {\n return image;\n } else {\n const image = new Image();\n image.src = arg.src;\n imageMap.set(arg.src, image);\n return image;\n }\n }\n } else if (Array.isArray(arg)) {\n return arg.map(deserializeArg(imageMap, ctx));\n }\n return arg;\n };\n}\n\nexport default function webglMutation({\n mutation,\n target,\n type,\n imageMap,\n errorHandler,\n}: {\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n type: CanvasContext;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = getContext(target, type);\n if (!ctx) return;\n\n // NOTE: if `preserveDrawingBuffer` is set to true,\n // we must flush the buffers on every new canvas event\n // if (mutation.newFrame) ctx.flush();\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n const args = mutation.args.map(deserializeArg(imageMap, ctx));\n const result = original.apply(ctx, args);\n saveToWebGLVarMap(ctx, result);\n\n // Slows down replay considerably, only use for debugging\n const debugMode = false;\n if (debugMode) {\n if (mutation.property === 'compileShader') {\n if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getShaderInfoLog(args[0]),\n );\n } else if (mutation.property === 'linkProgram') {\n ctx.validateProgram(args[0]);\n if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getProgramInfoLog(args[0]),\n );\n }\n const webglError = ctx.getError();\n if (webglError !== ctx.NO_ERROR) {\n console.warn(\n 'WEBGL ERROR',\n webglError,\n 'on command:',\n mutation.property,\n ...args,\n );\n }\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import {\n rebuild,\n buildNodeWithSN,\n INode,\n NodeType,\n BuildCache,\n createCache,\n} from 'rrweb-snapshot';\nimport * as mittProxy from 'mitt';\nimport { polyfill as smoothscrollPolyfill } from './smoothscroll';\nimport { Timer } from './timer';\nimport { createPlayerService, createSpeedService } from './machine';\nimport {\n EventType,\n IncrementalSource,\n fullSnapshotEvent,\n eventWithTime,\n MouseInteractions,\n playerConfig,\n playerMetaData,\n viewportResizeDimension,\n missingNodeMap,\n addedNodeMutation,\n missingNode,\n incrementalSnapshotEvent,\n incrementalData,\n ReplayerEvents,\n Handler,\n Emitter,\n MediaInteractions,\n metaEvent,\n mutationData,\n scrollData,\n inputData,\n canvasMutationData,\n Mirror,\n ElementState,\n styleAttributeValue,\n styleValueWithPriority,\n mouseMovePos,\n IWindow,\n canvasMutationCommand,\n textMutation,\n} from '../types';\nimport {\n createMirror,\n polyfill,\n TreeIndex,\n queueToResolveTrees,\n iterateResolveTree,\n AppendedIframe,\n isIframeINode,\n getBaseDimension,\n hasShadowRoot,\n} from '../utils';\nimport getInjectStyleRules from './styles/inject-style';\nimport './styles/style.css';\nimport {\n applyVirtualStyleRulesToNode,\n storeCSSRules,\n StyleRuleType,\n VirtualStyleRules,\n VirtualStyleRulesMap,\n getNestedRule,\n getPositionsAndIndex,\n} from './virtual-styles';\nimport canvasMutation from './canvas';\n\nconst SKIP_TIME_THRESHOLD = 10 * 1000;\nconst SKIP_TIME_INTERVAL = 5 * 1000;\n\n// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734\n// tslint:disable-next-line\nconst mitt = (mittProxy as any).default || mittProxy;\n\nconst REPLAY_CONSOLE_PREFIX = '[replayer]';\n\nconst defaultMouseTailConfig = {\n duration: 500,\n lineCap: 'round',\n lineWidth: 3,\n strokeStyle: 'red',\n} as const;\n\nfunction indicatesTouchDevice(e: eventWithTime) {\n return (\n e.type == EventType.IncrementalSnapshot &&\n (e.data.source == IncrementalSource.TouchMove ||\n (e.data.source == IncrementalSource.MouseInteraction &&\n e.data.type == MouseInteractions.TouchStart))\n );\n}\n\nexport class Replayer {\n public wrapper: HTMLDivElement;\n public iframe: HTMLIFrameElement;\n\n public service: ReturnType;\n public speedService: ReturnType;\n public get timer() {\n return this.service.state.context.timer;\n }\n\n public config: playerConfig;\n\n private mouse: HTMLDivElement;\n private mouseTail: HTMLCanvasElement | null = null;\n private tailPositions: Array<{ x: number; y: number }> = [];\n\n private emitter: Emitter = mitt();\n\n private nextUserInteractionEvent: eventWithTime | null;\n\n // tslint:disable-next-line: variable-name\n private legacy_missingNodeRetryMap: missingNodeMap = {};\n\n private treeIndex!: TreeIndex;\n private fragmentParentMap!: Map;\n private elementStateMap!: Map;\n // Hold the list of CSSRules for in-memory state restoration\n private virtualStyleRulesMap!: VirtualStyleRulesMap;\n\n // The replayer uses the cache to speed up replay and scrubbing.\n private cache: BuildCache = createCache();\n\n private imageMap: Map = new Map();\n\n private mirror: Mirror = createMirror();\n\n private firstFullSnapshot: eventWithTime | true | null = null;\n\n private newDocumentQueue: addedNodeMutation[] = [];\n\n private mousePos: mouseMovePos | null = null;\n private touchActive: boolean | null = null;\n\n constructor(\n events: Array,\n config?: Partial,\n ) {\n if (!config?.liveMode && events.length < 2) {\n throw new Error('Replayer need at least 2 events.');\n }\n const defaultConfig: playerConfig = {\n speed: 1,\n maxSpeed: 360,\n root: document.body,\n loadTimeout: 0,\n skipInactive: false,\n showWarning: true,\n showDebug: false,\n blockClass: 'rr-block',\n liveMode: false,\n insertStyleRules: [],\n triggerFocus: true,\n UNSAFE_replayCanvas: false,\n pauseAnimation: true,\n mouseTail: defaultMouseTailConfig,\n };\n this.config = Object.assign({}, defaultConfig, config);\n\n this.handleResize = this.handleResize.bind(this);\n this.getCastFn = this.getCastFn.bind(this);\n this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);\n this.emitter.on(ReplayerEvents.Resize, this.handleResize as Handler);\n\n this.setupDom();\n\n this.treeIndex = new TreeIndex();\n this.fragmentParentMap = new Map();\n this.elementStateMap = new Map();\n this.virtualStyleRulesMap = new Map();\n\n this.emitter.on(ReplayerEvents.Flush, () => {\n const { scrollMap, inputMap, mutationData } = this.treeIndex.flush();\n\n this.fragmentParentMap.forEach((parent, frag) =>\n this.restoreRealParent(frag, parent),\n );\n // apply text needs to happen before virtual style rules gets applied\n // as it can overwrite the contents of a stylesheet\n for (const d of mutationData.texts) {\n this.applyText(d, mutationData);\n }\n\n for (const node of this.virtualStyleRulesMap.keys()) {\n // restore css rules of style elements after they are mounted\n this.restoreNodeSheet(node);\n }\n this.fragmentParentMap.clear();\n this.elementStateMap.clear();\n this.virtualStyleRulesMap.clear();\n\n for (const d of scrollMap.values()) {\n this.applyScroll(d, true);\n }\n for (const d of inputMap.values()) {\n this.applyInput(d);\n }\n });\n this.emitter.on(ReplayerEvents.PlayBack, () => {\n this.firstFullSnapshot = null;\n this.mirror.reset();\n });\n\n const timer = new Timer([], config?.speed || defaultConfig.speed);\n this.service = createPlayerService(\n {\n events: events\n .map((e) => {\n if (config && config.unpackFn) {\n return config.unpackFn(e as string);\n }\n return e as eventWithTime;\n })\n .sort((a1, a2) => a1.timestamp - a2.timestamp),\n timer,\n timeOffset: 0,\n baselineTime: 0,\n lastPlayedEvent: null,\n },\n {\n getCastFn: this.getCastFn,\n applyEventsSynchronously: this.applyEventsSynchronously,\n emitter: this.emitter,\n },\n );\n this.service.start();\n this.service.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n player: state,\n });\n });\n this.speedService = createSpeedService({\n normalSpeed: -1,\n timer,\n });\n this.speedService.start();\n this.speedService.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n speed: state,\n });\n });\n\n // rebuild first full snapshot as the poster of the player\n // maybe we can cache it for performance optimization\n const firstMeta = this.service.state.context.events.find(\n (e) => e.type === EventType.Meta,\n );\n const firstFullsnapshot = this.service.state.context.events.find(\n (e) => e.type === EventType.FullSnapshot,\n );\n if (firstMeta) {\n const { width, height } = firstMeta.data as metaEvent['data'];\n setTimeout(() => {\n this.emitter.emit(ReplayerEvents.Resize, {\n width,\n height,\n });\n }, 0);\n }\n if (firstFullsnapshot) {\n setTimeout(() => {\n // when something has been played, there is no need to rebuild poster\n if (this.firstFullSnapshot) {\n // true if any other fullSnapshot has been executed by Timer already\n return;\n }\n this.firstFullSnapshot = firstFullsnapshot;\n this.rebuildFullSnapshot(\n firstFullsnapshot as fullSnapshotEvent & { timestamp: number },\n );\n this.iframe.contentWindow!.scrollTo(\n (firstFullsnapshot as fullSnapshotEvent).data.initialOffset,\n );\n }, 1);\n }\n if (this.service.state.context.events.find(indicatesTouchDevice)) {\n this.mouse.classList.add('touch-device');\n }\n }\n\n public on(event: string, handler: Handler) {\n this.emitter.on(event, handler);\n return this;\n }\n\n public off(event: string, handler: Handler) {\n this.emitter.off(event, handler);\n return this;\n }\n\n public setConfig(config: Partial) {\n Object.keys(config).forEach((key) => {\n // @ts-ignore\n this.config[key] = config[key];\n });\n if (!this.config.skipInactive) {\n this.backToNormal();\n }\n if (typeof config.speed !== 'undefined') {\n this.speedService.send({\n type: 'SET_SPEED',\n payload: {\n speed: config.speed!,\n },\n });\n }\n if (typeof config.mouseTail !== 'undefined') {\n if (config.mouseTail === false) {\n if (this.mouseTail) {\n this.mouseTail.style.display = 'none';\n }\n } else {\n if (!this.mouseTail) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.width = Number.parseFloat(this.iframe.width);\n this.mouseTail.height = Number.parseFloat(this.iframe.height);\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.wrapper.insertBefore(this.mouseTail, this.iframe);\n }\n this.mouseTail.style.display = 'inherit';\n }\n }\n }\n\n public getMetaData(): playerMetaData {\n const firstEvent = this.service.state.context.events[0];\n const lastEvent = this.service.state.context.events[\n this.service.state.context.events.length - 1\n ];\n return {\n startTime: firstEvent.timestamp,\n endTime: lastEvent.timestamp,\n totalTime: lastEvent.timestamp - firstEvent.timestamp,\n };\n }\n\n public getCurrentTime(): number {\n return this.timer.timeOffset + this.getTimeOffset();\n }\n\n public getTimeOffset(): number {\n const { baselineTime, events } = this.service.state.context;\n return baselineTime - events[0].timestamp;\n }\n\n public getMirror(): Mirror {\n return this.mirror;\n }\n\n /**\n * This API was designed to be used as play at any time offset.\n * Since we minimized the data collected from recorder, we do not\n * have the ability of undo an event.\n * So the implementation of play at any time offset will always iterate\n * all of the events, cast event before the offset synchronously\n * and cast event after the offset asynchronously with timer.\n * @param timeOffset number\n */\n public play(timeOffset = 0) {\n if (this.service.state.matches('paused')) {\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n } else {\n this.service.send({ type: 'PAUSE' });\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.remove('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Start);\n }\n\n public pause(timeOffset?: number) {\n if (timeOffset === undefined && this.service.state.matches('playing')) {\n this.service.send({ type: 'PAUSE' });\n }\n if (typeof timeOffset === 'number') {\n this.play(timeOffset);\n this.service.send({ type: 'PAUSE' });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Pause);\n }\n\n public resume(timeOffset = 0) {\n console.warn(\n `The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.`,\n );\n this.play(timeOffset);\n this.emitter.emit(ReplayerEvents.Resume);\n }\n\n public startLive(baselineTime?: number) {\n this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });\n }\n\n public addEvent(rawEvent: eventWithTime | string) {\n const event = this.config.unpackFn\n ? this.config.unpackFn(rawEvent as string)\n : (rawEvent as eventWithTime);\n if (indicatesTouchDevice(event)) {\n this.mouse.classList.add('touch-device');\n }\n Promise.resolve().then(() =>\n this.service.send({ type: 'ADD_EVENT', payload: { event } }),\n );\n }\n\n public enableInteract() {\n this.iframe.setAttribute('scrolling', 'auto');\n this.iframe.style.pointerEvents = 'auto';\n }\n\n public disableInteract() {\n this.iframe.setAttribute('scrolling', 'no');\n this.iframe.style.pointerEvents = 'none';\n }\n\n /**\n * Empties the replayer's cache and reclaims memory.\n * The replayer will use this cache to speed up the playback.\n */\n public resetCache() {\n this.cache = createCache();\n }\n\n private setupDom() {\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add('replayer-wrapper');\n this.config.root!.appendChild(this.wrapper);\n\n this.mouse = document.createElement('div');\n this.mouse.classList.add('replayer-mouse');\n this.wrapper.appendChild(this.mouse);\n\n if (this.config.mouseTail !== false) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.mouseTail.style.display = 'inherit';\n this.wrapper.appendChild(this.mouseTail);\n }\n\n this.iframe = document.createElement('iframe');\n const attributes = ['allow-same-origin'];\n if (this.config.UNSAFE_replayCanvas) {\n attributes.push('allow-scripts');\n }\n // hide iframe before first meta event\n this.iframe.style.display = 'none';\n this.iframe.setAttribute('sandbox', attributes.join(' '));\n this.disableInteract();\n this.wrapper.appendChild(this.iframe);\n if (this.iframe.contentWindow && this.iframe.contentDocument) {\n smoothscrollPolyfill(\n this.iframe.contentWindow,\n this.iframe.contentDocument,\n );\n\n polyfill(this.iframe.contentWindow as IWindow);\n }\n }\n\n private handleResize(dimension: viewportResizeDimension) {\n this.iframe.style.display = 'inherit';\n for (const el of [this.mouseTail, this.iframe]) {\n if (!el) {\n continue;\n }\n el.setAttribute('width', String(dimension.width));\n el.setAttribute('height', String(dimension.height));\n }\n }\n\n private applyEventsSynchronously(events: Array) {\n for (const event of events) {\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n case EventType.Custom:\n continue;\n case EventType.FullSnapshot:\n case EventType.Meta:\n case EventType.Plugin:\n break;\n case EventType.IncrementalSnapshot:\n switch (event.data.source) {\n case IncrementalSource.MediaInteraction:\n continue;\n default:\n break;\n }\n break;\n default:\n break;\n }\n const castFn = this.getCastFn(event, true);\n castFn();\n }\n if (this.mousePos) {\n this.moveAndHover(\n this.mousePos.x,\n this.mousePos.y,\n this.mousePos.id,\n true,\n this.mousePos.debugData,\n );\n }\n this.mousePos = null;\n if (this.touchActive === true) {\n this.mouse.classList.add('touch-active');\n } else if (this.touchActive === false) {\n this.mouse.classList.remove('touch-active');\n }\n this.touchActive = null;\n }\n\n private getCastFn(event: eventWithTime, isSync = false) {\n let castFn: undefined | (() => void);\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n break;\n case EventType.Custom:\n castFn = () => {\n /**\n * emit custom-event and pass the event object.\n *\n * This will add more value to the custom event and allows the client to react for custom-event.\n */\n this.emitter.emit(ReplayerEvents.CustomEvent, event);\n };\n break;\n case EventType.Meta:\n castFn = () =>\n this.emitter.emit(ReplayerEvents.Resize, {\n width: event.data.width,\n height: event.data.height,\n });\n break;\n case EventType.FullSnapshot:\n castFn = () => {\n if (this.firstFullSnapshot) {\n if (this.firstFullSnapshot === event) {\n // we've already built this exact FullSnapshot when the player was mounted, and haven't built any other FullSnapshot since\n this.firstFullSnapshot = true; // forget as we might need to re-execute this FullSnapshot later e.g. to rebuild after scrubbing\n return;\n }\n } else {\n // Timer (requestAnimationFrame) can be faster than setTimeout(..., 1)\n this.firstFullSnapshot = true;\n }\n this.rebuildFullSnapshot(event, isSync);\n this.iframe.contentWindow!.scrollTo(event.data.initialOffset);\n };\n break;\n case EventType.IncrementalSnapshot:\n castFn = () => {\n this.applyIncremental(event, isSync);\n if (isSync) {\n // do not check skip in sync\n return;\n }\n if (event === this.nextUserInteractionEvent) {\n this.nextUserInteractionEvent = null;\n this.backToNormal();\n }\n if (this.config.skipInactive && !this.nextUserInteractionEvent) {\n for (const _event of this.service.state.context.events) {\n if (_event.timestamp! <= event.timestamp!) {\n continue;\n }\n if (this.isUserInteraction(_event)) {\n if (\n _event.delay! - event.delay! >\n SKIP_TIME_THRESHOLD *\n this.speedService.state.context.timer.speed\n ) {\n this.nextUserInteractionEvent = _event;\n }\n break;\n }\n }\n if (this.nextUserInteractionEvent) {\n const skipTime =\n this.nextUserInteractionEvent.delay! - event.delay!;\n const payload = {\n speed: Math.min(\n Math.round(skipTime / SKIP_TIME_INTERVAL),\n this.config.maxSpeed,\n ),\n };\n this.speedService.send({ type: 'FAST_FORWARD', payload });\n this.emitter.emit(ReplayerEvents.SkipStart, payload);\n }\n }\n };\n break;\n default:\n }\n const wrappedCastFn = () => {\n if (castFn) {\n castFn();\n }\n\n for (const plugin of this.config.plugins || []) {\n plugin.handler(event, isSync, { replayer: this });\n }\n\n this.service.send({ type: 'CAST_EVENT', payload: { event } });\n\n // events are kept sorted by timestamp, check if this is the last event\n let last_index = this.service.state.context.events.length - 1;\n if (event === this.service.state.context.events[last_index]) {\n const finish = () => {\n if (last_index < this.service.state.context.events.length - 1) {\n // more events have been added since the setTimeout\n return;\n }\n this.backToNormal();\n this.service.send('END');\n this.emitter.emit(ReplayerEvents.Finish);\n };\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove &&\n event.data.positions.length\n ) {\n // defer finish event if the last event is a mouse move\n setTimeout(() => {\n finish();\n }, Math.max(0, -event.data.positions[0].timeOffset + 50)); // Add 50 to make sure the timer would check the last mousemove event. Otherwise, the timer may be stopped by the service before checking the last event.\n } else {\n finish();\n }\n }\n\n this.emitter.emit(ReplayerEvents.EventCast, event);\n };\n return wrappedCastFn;\n }\n\n private rebuildFullSnapshot(\n event: fullSnapshotEvent & { timestamp: number },\n isSync: boolean = false,\n ) {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n console.warn(\n 'Found unresolved missing node map',\n this.legacy_missingNodeRetryMap,\n );\n }\n this.legacy_missingNodeRetryMap = {};\n const collected: AppendedIframe[] = [];\n this.mirror.map = rebuild(event.data.node, {\n doc: this.iframe.contentDocument,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n },\n cache: this.cache,\n })[1];\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n const { documentElement, head } = this.iframe.contentDocument;\n this.insertStyleRules(documentElement, head);\n if (!this.service.state.matches('playing')) {\n this.iframe.contentDocument\n .getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n }\n this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);\n if (!isSync) {\n this.waitForStylesheetLoad();\n }\n if (this.config.UNSAFE_replayCanvas) {\n this.preloadAllImages();\n }\n }\n\n private insertStyleRules(\n documentElement: HTMLElement,\n head: HTMLHeadElement,\n ) {\n const styleEl = document.createElement('style');\n documentElement!.insertBefore(styleEl, head);\n const injectStylesRules = getInjectStyleRules(\n this.config.blockClass,\n ).concat(this.config.insertStyleRules);\n if (this.config.pauseAnimation) {\n injectStylesRules.push(\n 'html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }',\n );\n }\n for (let idx = 0; idx < injectStylesRules.length; idx++) {\n (styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);\n }\n }\n\n private attachDocumentToIframe(\n mutation: addedNodeMutation,\n iframeEl: HTMLIFrameElement,\n ) {\n const collected: AppendedIframe[] = [];\n // If iframeEl is detached from dom, iframeEl.contentDocument is null.\n if (!iframeEl.contentDocument) {\n let parent = iframeEl.parentNode;\n while (parent) {\n // The parent of iframeEl is virtual parent and we need to mount it on the dom.\n if (this.fragmentParentMap.has((parent as unknown) as INode)) {\n const frag = (parent as unknown) as INode;\n const realParent = this.fragmentParentMap.get(frag)!;\n this.restoreRealParent(frag, realParent);\n break;\n }\n parent = parent.parentNode;\n }\n }\n buildNodeWithSN(mutation.node, {\n doc: iframeEl.contentDocument!,\n map: this.mirror.map,\n hackCss: true,\n skipChild: false,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n if (\n builtNode.__sn.type === NodeType.Element &&\n builtNode.__sn.tagName.toUpperCase() === 'HTML'\n ) {\n const { documentElement, head } = iframeEl.contentDocument!;\n this.insertStyleRules(documentElement, head);\n }\n },\n cache: this.cache,\n });\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n private collectIframeAndAttachDocument(\n collected: AppendedIframe[],\n builtNode: INode,\n ) {\n if (isIframeINode(builtNode)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === builtNode.__sn.id,\n );\n if (mutationInQueue) {\n collected.push({ mutationInQueue, builtNode });\n }\n }\n }\n\n /**\n * pause when loading style sheet, resume when loaded all timeout exceed\n */\n private waitForStylesheetLoad() {\n const head = this.iframe.contentDocument?.head;\n if (head) {\n const unloadSheets: Set = new Set();\n let timer: ReturnType | -1;\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n const unsubscribe = () => {\n this.emitter.off(ReplayerEvents.Start, stateHandler);\n this.emitter.off(ReplayerEvents.Pause, stateHandler);\n };\n head\n .querySelectorAll('link[rel=\"stylesheet\"]')\n .forEach((css: HTMLLinkElement) => {\n if (!css.sheet) {\n unloadSheets.add(css);\n css.addEventListener('load', () => {\n unloadSheets.delete(css);\n // all loaded and timer not released yet\n if (unloadSheets.size === 0 && timer !== -1) {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);\n if (timer) {\n clearTimeout(timer);\n }\n unsubscribe();\n }\n });\n }\n });\n\n if (unloadSheets.size > 0) {\n // find some unload sheets after iterate\n this.service.send({ type: 'PAUSE' });\n this.emitter.emit(ReplayerEvents.LoadStylesheetStart);\n timer = setTimeout(() => {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n // mark timer was called\n timer = -1;\n unsubscribe();\n }, this.config.loadTimeout);\n }\n }\n }\n\n private hasImageArg(args: any[]): boolean {\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n if (this.hasImageArg(arg.args)) return true;\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n return true; // has image!\n } else if (arg instanceof Array) {\n if (this.hasImageArg(arg)) return true;\n }\n }\n return false;\n }\n\n private getImageArgs(args: any[]): string[] {\n const images: string[] = [];\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n images.push(...this.getImageArgs(arg.args));\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n images.push(arg.src);\n } else if (arg instanceof Array) {\n images.push(...this.getImageArgs(arg));\n }\n }\n return images;\n }\n\n /**\n * pause when there are some canvas drawImage args need to be loaded\n */\n private preloadAllImages() {\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n for (const event of this.service.state.context.events) {\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.CanvasMutation\n )\n if ('commands' in event.data) {\n event.data.commands.forEach((c) => this.preloadImages(c, event));\n } else {\n this.preloadImages(event.data, event);\n }\n }\n }\n\n private preloadImages(data: canvasMutationCommand, event: eventWithTime) {\n if (\n data.property === 'drawImage' &&\n typeof data.args[0] === 'string' &&\n !this.imageMap.has(event)\n ) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const imgd = ctx?.createImageData(canvas.width, canvas.height);\n let d = imgd?.data;\n d = JSON.parse(data.args[0]);\n ctx?.putImageData(imgd!, 0, 0);\n } else if (this.hasImageArg(data.args)) {\n this.getImageArgs(data.args).forEach((url) => {\n const image = new Image();\n image.src = url; // this preloads the image\n this.imageMap.set(url, image);\n });\n }\n }\n\n private applyIncremental(\n e: incrementalSnapshotEvent & { timestamp: number; delay?: number },\n isSync: boolean,\n ) {\n const { data: d } = e;\n switch (d.source) {\n case IncrementalSource.Mutation: {\n if (isSync) {\n d.adds.forEach((m) => this.treeIndex.add(m));\n d.texts.forEach((m) => {\n const target = this.mirror.getNode(m.id);\n const parent = (target?.parentNode as unknown) as INode | null;\n // remove any style rules that pending\n // for stylesheets where the contents get replaced\n if (parent && this.virtualStyleRulesMap.has(parent))\n this.virtualStyleRulesMap.delete(parent);\n\n this.treeIndex.text(m);\n });\n d.attributes.forEach((m) => this.treeIndex.attribute(m));\n d.removes.forEach((m) => this.treeIndex.remove(m, this.mirror));\n }\n try {\n this.applyMutation(d, isSync);\n } catch (error) {\n this.warn(`Exception in mutation ${error.message || error}`, d);\n }\n break;\n }\n case IncrementalSource.Drag:\n case IncrementalSource.TouchMove:\n case IncrementalSource.MouseMove:\n if (isSync) {\n const lastPosition = d.positions[d.positions.length - 1];\n this.mousePos = {\n x: lastPosition.x,\n y: lastPosition.y,\n id: lastPosition.id,\n debugData: d,\n };\n } else {\n d.positions.forEach((p) => {\n const action = {\n doAction: () => {\n this.moveAndHover(p.x, p.y, p.id, isSync, d);\n },\n delay:\n p.timeOffset +\n e.timestamp -\n this.service.state.context.baselineTime,\n };\n this.timer.addAction(action);\n });\n // add a dummy action to keep timer alive\n this.timer.addAction({\n doAction() {},\n delay: e.delay! - d.positions[0]?.timeOffset,\n });\n }\n break;\n case IncrementalSource.MouseInteraction: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n const event = new Event(MouseInteractions[d.type].toLowerCase());\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n this.emitter.emit(ReplayerEvents.MouseInteraction, {\n type: d.type,\n target,\n });\n const { triggerFocus } = this.config;\n switch (d.type) {\n case MouseInteractions.Blur:\n if ('blur' in ((target as Node) as HTMLElement)) {\n ((target as Node) as HTMLElement).blur();\n }\n break;\n case MouseInteractions.Focus:\n if (triggerFocus && ((target as Node) as HTMLElement).focus) {\n ((target as Node) as HTMLElement).focus({\n preventScroll: true,\n });\n }\n break;\n case MouseInteractions.Click:\n case MouseInteractions.TouchStart:\n case MouseInteractions.TouchEnd:\n if (isSync) {\n if (d.type === MouseInteractions.TouchStart) {\n this.touchActive = true;\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.touchActive = false;\n }\n this.mousePos = {\n x: d.x,\n y: d.y,\n id: d.id,\n debugData: d,\n };\n } else {\n if (d.type === MouseInteractions.TouchStart) {\n // don't draw a trail as user has lifted finger and is placing at a new point\n this.tailPositions.length = 0;\n }\n this.moveAndHover(d.x, d.y, d.id, isSync, d);\n if (d.type === MouseInteractions.Click) {\n /*\n * don't want target.click() here as could trigger an iframe navigation\n * instead any effects of the click should already be covered by mutations\n */\n /*\n * removal and addition of .active class (along with void line to trigger repaint)\n * triggers the 'click' css animation in styles/style.css\n */\n this.mouse.classList.remove('active');\n // tslint:disable-next-line\n void this.mouse.offsetWidth;\n this.mouse.classList.add('active');\n } else if (d.type === MouseInteractions.TouchStart) {\n void this.mouse.offsetWidth; // needed for the position update of moveAndHover to apply without the .touch-active transition\n this.mouse.classList.add('touch-active');\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.mouse.classList.remove('touch-active');\n }\n }\n break;\n case MouseInteractions.TouchCancel:\n if (isSync) {\n this.touchActive = false;\n } else {\n this.mouse.classList.remove('touch-active');\n }\n break;\n default:\n target.dispatchEvent(event);\n }\n break;\n }\n case IncrementalSource.Scroll: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.scroll(d);\n break;\n }\n this.applyScroll(d, false);\n break;\n }\n case IncrementalSource.ViewportResize:\n this.emitter.emit(ReplayerEvents.Resize, {\n width: d.width,\n height: d.height,\n });\n break;\n case IncrementalSource.Input: {\n /**\n * Input event on an unserialized node usually means the event\n * was synchrony triggered programmatically after the node was\n * created. This means there was not an user observable interaction\n * and we do not need to replay it.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.input(d);\n break;\n }\n this.applyInput(d);\n break;\n }\n case IncrementalSource.MediaInteraction: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n const mediaEl = (target as Node) as HTMLMediaElement;\n try {\n if (d.currentTime) {\n mediaEl.currentTime = d.currentTime;\n }\n if (d.volume) {\n mediaEl.volume = d.volume;\n }\n if (d.muted) {\n mediaEl.muted = d.muted;\n }\n if (d.type === MediaInteractions.Pause) {\n mediaEl.pause();\n }\n if (d.type === MediaInteractions.Play) {\n // remove listener for 'canplay' event because play() is async and returns a promise\n // i.e. media will evntualy start to play when data is loaded\n // 'canplay' event fires even when currentTime attribute changes which may lead to\n // unexpeted behavior\n mediaEl.play();\n }\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n `Failed to replay media interactions: ${error.message || error}`,\n );\n }\n }\n break;\n }\n case IncrementalSource.StyleSheetRule: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n /**\n * Always use existing DOM node, when it's there.\n * In in-memory replay, there is virtual node, but it's `sheet` is inaccessible.\n * Hence, we buffer all style changes in virtualStyleRulesMap.\n */\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules;\n\n if (!styleSheet) {\n /**\n * styleEl.sheet is only accessible if the styleEl is part of the\n * dom. This doesn't work on DocumentFragments so we have to add the\n * style mutations to the virtualStyleRulesMap.\n */\n\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.adds) {\n d.adds.forEach(({ rule, index: nestedIndex }) => {\n if (styleSheet) {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet.cssRules,\n positions,\n );\n nestedRule.insertRule(rule, index);\n } else {\n const index =\n nestedIndex === undefined\n ? undefined\n : Math.min(nestedIndex, styleSheet.cssRules.length);\n styleSheet.insertRule(rule, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else {\n rules?.push({\n cssText: rule,\n index: nestedIndex,\n type: StyleRuleType.Insert,\n });\n }\n });\n }\n\n if (d.removes) {\n d.removes.forEach(({ index: nestedIndex }) => {\n if (usingVirtualParent) {\n rules?.push({ index: nestedIndex, type: StyleRuleType.Remove });\n } else {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet!.cssRules,\n positions,\n );\n nestedRule.deleteRule(index || 0);\n } else {\n styleSheet?.deleteRule(nestedIndex);\n }\n } catch (e) {\n /**\n * same as insertRule\n */\n }\n }\n });\n }\n break;\n }\n case IncrementalSource.StyleDeclaration: {\n // same with StyleSheetRule\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules = [];\n\n if (!styleSheet) {\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.set) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.setProperty(d.set.property, d.set.value, d.set.priority);\n } else {\n rules.push({\n type: StyleRuleType.SetProperty,\n index: d.index,\n ...d.set,\n });\n }\n }\n\n if (d.remove) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.removeProperty(d.remove.property);\n } else {\n rules.push({\n type: StyleRuleType.RemoveProperty,\n index: d.index,\n ...d.remove,\n });\n }\n }\n break;\n }\n case IncrementalSource.CanvasMutation: {\n if (!this.config.UNSAFE_replayCanvas) {\n return;\n }\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n canvasMutation({\n event: e,\n mutation: d,\n target: (target as unknown) as HTMLCanvasElement,\n imageMap: this.imageMap,\n errorHandler: this.warnCanvasMutationFailed.bind(this),\n });\n\n break;\n }\n case IncrementalSource.Font: {\n try {\n const fontFace = new FontFace(\n d.family,\n d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource,\n d.descriptors,\n );\n this.iframe.contentDocument?.fonts.add(fontFace);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(error);\n }\n }\n break;\n }\n default:\n }\n }\n\n private applyMutation(d: mutationData, useVirtualParent: boolean) {\n d.removes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.parentId)) {\n // no need to warn, parent was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.virtualStyleRulesMap.has(target)) {\n this.virtualStyleRulesMap.delete(target);\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n return this.warnNodeNotFound(d, mutation.parentId);\n }\n if (mutation.isShadow && hasShadowRoot(parent)) {\n parent = parent.shadowRoot;\n }\n // target may be removed with its parents before\n this.mirror.removeNodeFromMap(target);\n if (parent) {\n let realTarget = null;\n const realParent =\n '__sn' in parent ? this.fragmentParentMap.get(parent) : undefined;\n if (realParent && realParent.contains(target)) {\n parent = realParent;\n } else if (this.fragmentParentMap.has(target)) {\n /**\n * the target itself is a fragment document and it's not in the dom\n * so we should remove the real target from its parent\n */\n realTarget = this.fragmentParentMap.get(target)!;\n this.fragmentParentMap.delete(target);\n target = realTarget;\n }\n try {\n parent.removeChild(target);\n } catch (error) {\n if (error instanceof DOMException) {\n this.warn(\n 'parent could not remove child in mutation',\n parent,\n realParent,\n target,\n realTarget,\n d,\n );\n } else {\n throw error;\n }\n }\n }\n });\n\n // tslint:disable-next-line: variable-name\n const legacy_missingNodeMap: missingNodeMap = {\n ...this.legacy_missingNodeRetryMap,\n };\n const queue: addedNodeMutation[] = [];\n\n // next not present at this moment\n const nextNotInDOM = (mutation: addedNodeMutation) => {\n let next: Node | null = null;\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n // next not present at this moment\n if (\n mutation.nextId !== null &&\n mutation.nextId !== undefined &&\n mutation.nextId !== -1 &&\n !next\n ) {\n return true;\n }\n return false;\n };\n\n const appendNode = (mutation: addedNodeMutation) => {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n if (mutation.node.type === NodeType.Document) {\n // is newly added document, maybe the document node of an iframe\n return this.newDocumentQueue.push(mutation);\n }\n return queue.push(mutation);\n }\n\n let parentInDocument = null;\n if (this.iframe.contentDocument.contains) {\n parentInDocument = this.iframe.contentDocument.contains(parent);\n } else if (this.iframe.contentDocument.body.contains) {\n // fix for IE\n // refer 'Internet Explorer notes' at https://developer.mozilla.org/zh-CN/docs/Web/API/Document\n parentInDocument = this.iframe.contentDocument.body.contains(parent);\n }\n\n const hasIframeChild =\n ((parent as unknown) as HTMLElement).getElementsByTagName?.('iframe')\n .length > 0;\n /**\n * Why !isIframeINode(parent)? If parent element is an iframe, iframe document can't be appended to virtual parent.\n * Why !hasIframeChild? If we move iframe elements from dom to fragment document, we will lose the contentDocument of iframe. So we need to disable the virtual dom optimization if a parent node contains iframe elements.\n */\n if (\n useVirtualParent &&\n parentInDocument &&\n !isIframeINode(parent) &&\n !hasIframeChild\n ) {\n const virtualParent = (document.createDocumentFragment() as unknown) as INode;\n this.mirror.map[mutation.parentId] = virtualParent;\n this.fragmentParentMap.set(virtualParent, parent);\n\n // store the state, like scroll position, of child nodes before they are unmounted from dom\n this.storeState(parent);\n\n while (parent.firstChild) {\n virtualParent.appendChild(parent.firstChild);\n }\n parent = virtualParent;\n }\n\n if (mutation.node.isShadow) {\n // If the parent is attached a shadow dom after it's created, it won't have a shadow root.\n if (!hasShadowRoot(parent)) {\n ((parent as Node) as HTMLElement).attachShadow({ mode: 'open' });\n parent = ((parent as Node) as HTMLElement).shadowRoot!;\n } else parent = parent.shadowRoot;\n }\n\n let previous: Node | null = null;\n let next: Node | null = null;\n if (mutation.previousId) {\n previous = this.mirror.getNode(mutation.previousId) as Node;\n }\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n if (nextNotInDOM(mutation)) {\n return queue.push(mutation);\n }\n\n if (mutation.node.rootId && !this.mirror.getNode(mutation.node.rootId)) {\n return;\n }\n\n const targetDoc = mutation.node.rootId\n ? this.mirror.getNode(mutation.node.rootId)\n : this.iframe.contentDocument;\n if (isIframeINode(parent)) {\n this.attachDocumentToIframe(mutation, parent);\n return;\n }\n const target = buildNodeWithSN(mutation.node, {\n doc: targetDoc as Document,\n map: this.mirror.map,\n skipChild: true,\n hackCss: true,\n cache: this.cache,\n }) as INode;\n\n // legacy data, we should not have -1 siblings any more\n if (mutation.previousId === -1 || mutation.nextId === -1) {\n legacy_missingNodeMap[mutation.node.id] = {\n node: target,\n mutation,\n };\n return;\n }\n\n if (\n '__sn' in parent &&\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n mutation.node.type === NodeType.Text\n ) {\n // https://github.com/rrweb-io/rrweb/issues/745\n // parent is textarea, will only keep one child node as the value\n for (const c of Array.from(parent.childNodes)) {\n if (c.nodeType === parent.TEXT_NODE) {\n parent.removeChild(c);\n }\n }\n }\n\n if (previous && previous.nextSibling && previous.nextSibling.parentNode) {\n parent.insertBefore(target, previous.nextSibling);\n } else if (next && next.parentNode) {\n // making sure the parent contains the reference nodes\n // before we insert target before next.\n parent.contains(next)\n ? parent.insertBefore(target, next)\n : parent.insertBefore(target, null);\n } else {\n /**\n * Sometimes the document changes and the MutationObserver is disconnected, so the removal of child elements can't be detected and recorded. After the change of document, we may get another mutation which adds a new html element, while the old html element still exists in the dom, and we need to remove the old html element first to avoid collision.\n */\n if (parent === targetDoc) {\n while (targetDoc.firstChild) {\n targetDoc.removeChild(targetDoc.firstChild);\n }\n }\n\n parent.appendChild(target);\n }\n\n if (isIframeINode(target)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === target.__sn.id,\n );\n if (mutationInQueue) {\n this.attachDocumentToIframe(mutationInQueue, target);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(\n legacy_missingNodeMap,\n parent,\n target,\n mutation,\n );\n }\n };\n\n d.adds.forEach((mutation) => {\n appendNode(mutation);\n });\n\n let startTime = Date.now();\n while (queue.length) {\n // transform queue to resolve tree\n const resolveTrees = queueToResolveTrees(queue);\n queue.length = 0;\n if (Date.now() - startTime > 500) {\n this.warn(\n 'Timeout in the loop, please check the resolve tree data:',\n resolveTrees,\n );\n break;\n }\n for (const tree of resolveTrees) {\n let parent = this.mirror.getNode(tree.value.parentId);\n if (!parent) {\n this.debug(\n 'Drop resolve tree since there is no parent for the root node.',\n tree,\n );\n } else {\n iterateResolveTree(tree, (mutation) => {\n appendNode(mutation);\n });\n }\n }\n }\n\n if (Object.keys(legacy_missingNodeMap).length) {\n Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);\n }\n\n d.texts.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n /**\n * apply text content to real parent directly\n */\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n target.textContent = mutation.value;\n });\n d.attributes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n for (const attributeName in mutation.attributes) {\n if (typeof attributeName === 'string') {\n const value = mutation.attributes[attributeName];\n if (value === null) {\n ((target as Node) as Element).removeAttribute(attributeName);\n } else if (typeof value === 'string') {\n try {\n ((target as Node) as Element).setAttribute(attributeName, value);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n 'An error occurred may due to the checkout feature.',\n error,\n );\n }\n }\n } else if (attributeName === 'style') {\n let styleValues = value as styleAttributeValue;\n const targetEl = (target as Node) as HTMLElement;\n for (var s in styleValues) {\n if (styleValues[s] === false) {\n targetEl.style.removeProperty(s);\n } else if (styleValues[s] instanceof Array) {\n const svp = styleValues[s] as styleValueWithPriority;\n targetEl.style.setProperty(s, svp[0], svp[1]);\n } else {\n const svs = styleValues[s] as string;\n targetEl.style.setProperty(s, svs);\n }\n }\n }\n }\n }\n });\n }\n\n /**\n * Apply the scroll data on real elements.\n * If the replayer is in sync mode, smooth scroll behavior should be disabled.\n * @param d the scroll data\n * @param isSync whether the replayer is in sync mode(fast-forward)\n */\n private applyScroll(d: scrollData, isSync: boolean) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n if ((target as Node) === this.iframe.contentDocument) {\n this.iframe.contentWindow!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else if (target.__sn.type === NodeType.Document) {\n // nest iframe content document\n ((target as unknown) as Document).defaultView!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else {\n try {\n ((target as Node) as Element).scrollTop = d.y;\n ((target as Node) as Element).scrollLeft = d.x;\n } catch (error) {\n /**\n * Seldomly we may found scroll target was removed before\n * its last scroll event.\n */\n }\n }\n }\n\n private applyInput(d: inputData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n try {\n ((target as Node) as HTMLInputElement).checked = d.isChecked;\n ((target as Node) as HTMLInputElement).value = d.text;\n } catch (error) {\n // for safe\n }\n }\n\n private applyText(d: textMutation, mutation: mutationData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(mutation, d.id);\n }\n try {\n ((target as Node) as HTMLElement).textContent = d.value;\n } catch (error) {\n // for safe\n }\n }\n\n private legacy_resolveMissingNode(\n map: missingNodeMap,\n parent: Node,\n target: Node,\n targetMutation: addedNodeMutation,\n ) {\n const { previousId, nextId } = targetMutation;\n const previousInMap = previousId && map[previousId];\n const nextInMap = nextId && map[nextId];\n if (previousInMap) {\n const { node, mutation } = previousInMap as missingNode;\n parent.insertBefore(node, target);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n if (nextInMap) {\n const { node, mutation } = nextInMap as missingNode;\n parent.insertBefore(node, target.nextSibling);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n }\n\n private moveAndHover(\n x: number,\n y: number,\n id: number,\n isSync: boolean,\n debugData: incrementalData,\n ) {\n const target = this.mirror.getNode(id);\n if (!target) {\n return this.debugNodeNotFound(debugData, id);\n }\n\n const base = getBaseDimension(target, this.iframe);\n const _x = x * base.absoluteScale + base.x;\n const _y = y * base.absoluteScale + base.y;\n\n this.mouse.style.left = `${_x}px`;\n this.mouse.style.top = `${_y}px`;\n if (!isSync) {\n this.drawMouseTail({ x: _x, y: _y });\n }\n this.hoverElements((target as Node) as Element);\n }\n\n private drawMouseTail(position: { x: number; y: number }) {\n if (!this.mouseTail) {\n return;\n }\n\n const { lineCap, lineWidth, strokeStyle, duration } =\n this.config.mouseTail === true\n ? defaultMouseTailConfig\n : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);\n\n const draw = () => {\n if (!this.mouseTail) {\n return;\n }\n const ctx = this.mouseTail.getContext('2d');\n if (!ctx || !this.tailPositions.length) {\n return;\n }\n ctx.clearRect(0, 0, this.mouseTail.width, this.mouseTail.height);\n ctx.beginPath();\n ctx.lineWidth = lineWidth;\n ctx.lineCap = lineCap;\n ctx.strokeStyle = strokeStyle;\n ctx.moveTo(this.tailPositions[0].x, this.tailPositions[0].y);\n this.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));\n ctx.stroke();\n };\n\n this.tailPositions.push(position);\n draw();\n setTimeout(() => {\n this.tailPositions = this.tailPositions.filter((p) => p !== position);\n draw();\n }, duration / this.speedService.state.context.timer.speed);\n }\n\n private hoverElements(el: Element) {\n this.iframe.contentDocument\n ?.querySelectorAll('.\\\\:hover')\n .forEach((hoveredEl) => {\n hoveredEl.classList.remove(':hover');\n });\n let currentEl: Element | null = el;\n while (currentEl) {\n if (currentEl.classList) {\n currentEl.classList.add(':hover');\n }\n currentEl = currentEl.parentElement;\n }\n }\n\n private isUserInteraction(event: eventWithTime): boolean {\n if (event.type !== EventType.IncrementalSnapshot) {\n return false;\n }\n return (\n event.data.source > IncrementalSource.Mutation &&\n event.data.source <= IncrementalSource.Input\n );\n }\n\n private backToNormal() {\n this.nextUserInteractionEvent = null;\n if (this.speedService.state.matches('normal')) {\n return;\n }\n this.speedService.send({ type: 'BACK_TO_NORMAL' });\n this.emitter.emit(ReplayerEvents.SkipEnd, {\n speed: this.speedService.state.context.normalSpeed,\n });\n }\n\n /**\n * Replace the virtual parent with the real parent.\n * @param frag fragment document, the virtual parent\n * @param parent real parent element\n */\n private restoreRealParent(frag: INode, parent: INode) {\n this.mirror.map[parent.__sn.id] = parent;\n /**\n * If we have already set value attribute on textarea,\n * then we could not apply text content as default value any more.\n */\n if (\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n frag.textContent\n ) {\n ((parent as unknown) as HTMLTextAreaElement).value = frag.textContent;\n }\n parent.appendChild(frag);\n // restore state of elements after they are mounted\n this.restoreState(parent);\n }\n\n /**\n * store state of elements before unmounted from dom recursively\n * the state should be restored in the handler of event ReplayerEvents.Flush\n * e.g. browser would lose scroll position after the process that we add children of parent node to Fragment Document as virtual dom\n */\n private storeState(parent: INode) {\n if (parent) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (parentElement.scrollLeft || parentElement.scrollTop) {\n // store scroll position state\n this.elementStateMap.set(parent, {\n scroll: [parentElement.scrollLeft, parentElement.scrollTop],\n });\n }\n if (parentElement.tagName === 'STYLE')\n storeCSSRules(\n parentElement as HTMLStyleElement,\n this.virtualStyleRulesMap,\n );\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.storeState((child as unknown) as INode);\n }\n }\n }\n }\n\n /**\n * restore the state of elements recursively, which was stored before elements were unmounted from dom in virtual parent mode\n * this function corresponds to function storeState\n */\n private restoreState(parent: INode) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (this.elementStateMap.has(parent)) {\n const storedState = this.elementStateMap.get(parent)!;\n // restore scroll position\n if (storedState.scroll) {\n parentElement.scrollLeft = storedState.scroll[0];\n parentElement.scrollTop = storedState.scroll[1];\n }\n this.elementStateMap.delete(parent);\n }\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.restoreState((child as unknown) as INode);\n }\n }\n }\n\n private restoreNodeSheet(node: INode) {\n const storedRules = this.virtualStyleRulesMap.get(node);\n if (node.nodeName !== 'STYLE') {\n return;\n }\n\n if (!storedRules) {\n return;\n }\n\n const styleNode = (node as unknown) as HTMLStyleElement;\n\n applyVirtualStyleRulesToNode(storedRules, styleNode);\n }\n\n private warnNodeNotFound(d: incrementalData, id: number) {\n if (this.treeIndex.idRemoved(id)) {\n this.warn(`Node with id '${id}' was previously removed. `, d);\n } else {\n this.warn(`Node with id '${id}' not found. `, d);\n }\n }\n\n private warnCanvasMutationFailed(\n d: canvasMutationData | canvasMutationCommand,\n error: unknown,\n ) {\n this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);\n }\n\n private debugNodeNotFound(d: incrementalData, id: number) {\n /**\n * There maybe some valid scenes of node not being found.\n * Because DOM events are macrotask and MutationObserver callback\n * is microtask, so events fired on a removed DOM may emit\n * snapshots in the reverse order.\n */\n if (this.treeIndex.idRemoved(id)) {\n this.debug(\n REPLAY_CONSOLE_PREFIX,\n `Node with id '${id}' was previously removed. `,\n d,\n );\n } else {\n this.debug(REPLAY_CONSOLE_PREFIX, `Node with id '${id}' not found. `, d);\n }\n }\n\n private warn(...args: Parameters) {\n if (!this.config.showWarning) {\n return;\n }\n console.warn(REPLAY_CONSOLE_PREFIX, ...args);\n }\n\n private debug(...args: Parameters) {\n if (!this.config.showDebug) {\n return;\n }\n // tslint:disable-next-line: no-console\n console.log(REPLAY_CONSOLE_PREFIX, ...args);\n }\n}\n","import { Replayer } from '..';\nimport {\n CanvasContext,\n canvasMutationCommand,\n canvasMutationData,\n} from '../../types';\nimport webglMutation from './webgl';\nimport canvas2DMutation from './2d';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationData;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const mutations: canvasMutationCommand[] =\n 'commands' in mutation ? mutation.commands : [mutation];\n\n if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {\n return mutations.forEach((command) => {\n webglMutation({\n mutation: command,\n type: mutation.type,\n target,\n imageMap,\n errorHandler,\n });\n });\n }\n // default is '2d' for backwards compatibility (rrweb below 1.1.x)\n return mutations.forEach((command) => {\n canvas2DMutation({\n event,\n mutation: command,\n target,\n imageMap,\n errorHandler,\n });\n });\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import { Replayer } from '../';\nimport { canvasMutationCommand } from '../../types';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = ((target as unknown) as HTMLCanvasElement).getContext('2d')!;\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n /**\n * We have serialized the image source into base64 string during recording,\n * which has been preloaded before replay.\n * So we can get call drawImage SYNCHRONOUSLY which avoid some fragile cast.\n */\n if (\n mutation.property === 'drawImage' &&\n typeof mutation.args[0] === 'string'\n ) {\n const image = imageMap.get(event);\n mutation.args[0] = image;\n original.apply(ctx, mutation.args);\n } else {\n original.apply(ctx, mutation.args);\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import record from './record';\nimport { Replayer } from './replay';\nimport { _mirror } from './utils';\nimport * as utils from './utils';\n\nexport {\n EventType,\n IncrementalSource,\n MouseInteractions,\n ReplayerEvents,\n} from './types';\n\nconst { addCustomEvent } = record;\nconst { freezePage } = record;\n\nexport {\n record,\n addCustomEvent,\n freezePage,\n Replayer,\n _mirror as mirror,\n utils,\n};\n","// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Much of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// Many optimizations have been made, so the bundle size is ultimately smaller but performance is similar.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var u = ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([c], { type: 'text/javascript' })));\n var w = new Worker(u);\n w.onerror = function (e) { return cb(e.error, null); };\n w.onmessage = function (e) { return cb(null, e.data); };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;\n// fixed length extra bits\nvar fleb = new u8([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, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\n// see fleb note\nvar fdeb = new u8([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, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new u32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return [b, r];\n};\nvar _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b[0], revfd = _b[1];\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >>> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >>> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >>> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >>> 8) | ((x & 0x00FF) << 8)) >>> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i)\n ++l[cd[i] - 1];\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 0; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >>> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i)\n co[i] = rev[le[cd[i] - 1]++] >>> (15 - cd[i]);\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8)) >>> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) >> 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >>> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p / 8) >> 0) + (p & 7 && 1); };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n var n = new (v instanceof u16 ? u16 : v instanceof u32 ? u32 : u8)(e - s);\n n.set(v.subarray(s, e));\n return n;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, buf, st) {\n // source length\n var sl = dat.length;\n // have to estimate size\n var noBuf = !buf || st;\n // no state\n var noSt = !st || st.i;\n if (!st)\n st = {};\n // Assumes roughly 33% compression ratio average\n if (!buf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n st.f = final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n throw 'unexpected EOF';\n break;\n }\n // ensure size\n if (noBuf)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n if (!noSt && pos + tl * (clb + 7) > tbts)\n break;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >>> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n throw 'invalid block type';\n if (pos > tbts)\n throw 'unexpected EOF';\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17;\n if (noBuf)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var mxa = lbt + dbt + 18;\n while (noSt || pos + mxa < tbts) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;\n pos += c & 15;\n if (pos > tbts)\n throw 'unexpected EOF';\n if (!c)\n throw 'invalid length/literal';\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;\n if (!d)\n throw 'invalid distance';\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & ((1 << b) - 1), pos += b;\n }\n if (pos > tbts)\n throw 'unexpected EOF';\n if (noBuf)\n cbuf(bt + 131072);\n var end = bt + add;\n for (; bt < end; bt += 4) {\n buf[bt] = buf[bt - dt];\n buf[bt + 1] = buf[bt + 1 - dt];\n buf[bt + 2] = buf[bt + 2 - dt];\n buf[bt + 3] = buf[bt + 3 - dt];\n }\n bt = end;\n }\n }\n st.l = lm, st.p = pos, st.b = bt;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n return bt == buf.length ? buf : slc(buf, 0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) >> 0;\n d[o] |= v;\n d[o + 1] |= v >>> 8;\n d[o + 2] |= v >>> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return [new u8(0), 0];\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return [v, 1];\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return [new u8(tr), mbt];\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return [cl.subarray(0, cli), s];\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >>> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a[0], mlb = _a[1];\n var _b = hTree(df, 15), ddt = _b[0], mdb = _b[1];\n var _c = lc(dlt), lclt = _c[0], nlc = _c[1];\n var _d = lc(ddt), lcdt = _d[0], ndc = _d[1];\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n lcfreq[lclt[i] & 31]++;\n for (var i = 0; i < lcdt.length; ++i)\n lcfreq[lcdt[i] & 31]++;\n var _e = hTree(lcfreq, 7), lct = _e[0], mlcb = _e[1];\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);\n if (flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >>> 5) & 127), p += clct[i] >>> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n if (syms[i] > 255) {\n var len = (syms[i] >>> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (syms[i] >>> 23) & 31), p += fleb[len];\n var dst = syms[i] & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (syms[i] >>> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new u32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, lst) {\n var s = dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.floor(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var pos = 0;\n if (!lvl || s < 8) {\n for (var i = 0; i <= s; i += 65535) {\n // end\n var e = i + 65535;\n if (e < s) {\n // write full block\n pos = wfblk(w, pos, dat.subarray(i, e));\n }\n else {\n // write final block\n w[i] = lst;\n pos = wfblk(w, pos, dat.subarray(i, s));\n }\n }\n }\n else {\n var opt = deo[lvl - 1];\n var n = opt >>> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = new u16(32768), head = new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new u32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx bitpos\n var lc_1 = 0, eb = 0, i = 0, li = 0, wi = 0, bs = 0;\n for (; i < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768\n var imod = i & 32767;\n // previous index with this value\n var pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && rem > 423) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = (imod - pimod) & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = (i - dif + j + 32768) & 32767;\n var pti = prev[ti];\n var cd = (ti - pti + 32768) & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += (imod - pimod + 32768) & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one Uint32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n // this is the easiest way to avoid needing to maintain state\n if (!lst)\n pos = wfblk(w, pos, et);\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new u32(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && 0xEDB88320) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = 0xFFFFFFFF;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return c ^ 0xFFFFFFFF; }\n };\n};\n// Alder32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 5552, l);\n for (; i < e; ++i)\n n += d[i], m += n;\n n %= 65521, m %= 65521;\n }\n a = n, b = m;\n },\n d: function () { return ((a >>> 8) << 16 | (b & 255) << 8 | (b >>> 8)) + ((a & 255) << 23) * 2; }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post, !st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/ /g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return [fnStr, td];\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k] instanceof u8 || v[k] instanceof u16 || v[k] instanceof u32)\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n var _a;\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n _a = wcln(fns[i], fnStr, td_1), fnStr = _a[0], td_1 = _a[1];\n ch[id] = wcln(fns[m], fnStr, td_1);\n }\n var td = mrg({}, ch[id][1]);\n return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, hMap, max, bits, bits16, shft, slc, inflt, inflateSync, pbf, gu8]; };\nvar bDflt = function () { return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zlv]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get u8\nvar gu8 = function (o) { return o && o.size && new u8(o.size); };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n if (!opts.consume)\n dat = new u8(dat);\n w.postMessage([dat, opts], [dat.buffer]);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) { return strm.push(ev.data[0], ev.data[1]); };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.push = function (d, f) {\n if (t)\n throw 'stream finished';\n if (!strm.ondata)\n throw 'no stream handler';\n w.postMessage([d, t = f], [d.buffer]);\n };\n strm.terminate = function () { w.terminate(); };\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16)) + (d[b + 3] << 23) * 2; };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n throw 'invalid gzip data';\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += d[10] | (d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16) + (2 * (d[l - 1] << 23));\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + ((o.filename && (o.filename.length + 1)) || 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (fl ? (32 - 2 * fl) : 1);\n};\n// zlib valid\nvar zlv = function (d) {\n if ((d[0] & 15) != 8 || (d[0] >>> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n throw 'invalid zlib data';\n if (d[1] & 32)\n throw 'invalid zlib data: preset dictionaries not supported';\n};\nfunction AsyncCmpStrm(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n// zlib footer: -4 to -0 is Adler32\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (!cb && typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, !f), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n this.d = final;\n this.p(chunk, final || false);\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n return dopt(data, opts, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n /**\n * Creates an inflation stream\n * @param cb The callback to call whenever data is inflated\n */\n function Inflate(cb) {\n this.s = {};\n this.p = new u8(0);\n this.ondata = cb;\n }\n Inflate.prototype.e = function (c) {\n if (this.d)\n throw 'stream finished';\n if (!this.ondata)\n throw 'no stream handler';\n var l = this.p.length;\n var n = new u8(l + c.length);\n n.set(this.p), n.set(c, l), this.p = n;\n };\n Inflate.prototype.c = function (final) {\n this.d = this.s.i = final || false;\n var bts = this.s.b;\n var dt = inflt(this.p, this.o, this.s);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) >> 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous inflation stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncInflate(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, 0, function () {\n var strm = new Inflate();\n onmessage = astrm(strm);\n }, 7);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gu8(ev.data[1]))); }, 1, cb);\n}\n/**\n * Expands DEFLATE data with no wrapper\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function inflateSync(data, out) {\n return inflt(data, out);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n this.c.p(c);\n this.l += c.length;\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, !f);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n /**\n * Creates a GUNZIP stream\n * @param cb The callback to call whenever data is inflated\n */\n function Gunzip(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n var s = gzs(this.p);\n if (s >= this.p.length && !final)\n return;\n this.p = this.p.subarray(s), this.v = 0;\n }\n if (final) {\n if (this.p.length < 8)\n throw 'invalid gzip stream';\n this.p = this.p.subarray(0, -8);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous GUNZIP stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncGunzip(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, 0, function () {\n var strm = new Gunzip();\n onmessage = astrm(strm);\n }, 9);\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0])); }, 3, cb);\n}\n/**\n * Expands GZIP data\n * @param data The data to decompress\n * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.\n * @returns The decompressed version of the data\n */\nexport function gunzipSync(data, out) {\n return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n this.c.p(c);\n var raw = dopt(c, this.o, this.v && 2, f && 4, !f);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n /**\n * Creates a Zlib decompression stream\n * @param cb The callback to call whenever data is inflated\n */\n function Unzlib(cb) {\n this.v = 1;\n Inflate.call(this, cb);\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 2 && !final)\n return;\n this.p = this.p.subarray(2), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n throw 'invalid zlib stream';\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous Zlib decompression stream\n * @param cb The callback to call whenever data is deflated\n */\n function AsyncUnzlib(cb) {\n this.ondata = cb;\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, 0, function () {\n var strm = new Unzlib();\n onmessage = astrm(strm);\n }, 11);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gu8(ev.data[1]))); }, 5, cb);\n}\n/**\n * Expands Zlib data\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function unzlibSync(data, out) {\n return inflt((zlv(data), data.subarray(2, -4)), out);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n /**\n * Creates a decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function Decompress(cb) {\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n throw 'no stream handler';\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n var _this_1 = this;\n var cb = function () { _this_1.ondata.apply(_this_1, arguments); };\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(cb)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(cb)\n : new this.Z(cb);\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous decompression stream\n * @param cb The callback to call whenever data is decompressed\n */\n function AsyncDecompress(cb) {\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, out) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, out)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, out)\n : unzlibSync(data, out);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k;\n if (val instanceof u8)\n t[n] = [val, o];\n else if (Array.isArray(val))\n t[n] = [val[0], mrg(o, val[1])];\n else\n fltn(val, n + '/', t, o);\n }\n};\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n var l = str.length;\n if (!latin1 && typeof TextEncoder != 'undefined')\n return new TextEncoder().encode(str);\n var ar = new u8(str.length + (str.length >>> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >>> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >>> 18)), w(128 | ((c >>> 12) & 63)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >>> 12)), w(128 | ((c >>> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n var r = '';\n if (!latin1 && typeof TextDecoder != 'undefined')\n return new TextDecoder().decode(dat);\n for (var i = 0; i < dat.length;) {\n var c = dat[i++];\n if (c < 128 || latin1)\n r += String.fromCharCode(c);\n else if (c < 224)\n r += String.fromCharCode((c & 31) << 6 | (dat[i++] & 63));\n else if (c < 240)\n r += String.fromCharCode((c & 15) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63));\n else\n c = ((c & 15) << 18 | (dat[i++] & 63) << 12 | (dat[i++] & 63) << 6 | (dat[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n return r;\n}\n;\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;\n var _a = z ? z64e(d, es) : [b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];\n};\n// read zip64 extra field\nvar z64e = function (d, b) {\n for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))\n ;\n return [b4(d, b + 12), b4(d, b + 4), b4(d, b + 20)];\n};\n// write zip header\nvar wzh = function (d, b, c, cmp, su, fn, u, o, ce, t) {\n var fl = fn.length, l = cmp.length;\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b] = 20, b += 2;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (t == 8 && (o.level == 1 ? 6 : o.level < 6 ? 4 : o.level == 9 ? 2 : 0)), d[b++] = u && 8;\n d[b] = t, b += 2;\n var dt = new Date(o.mtime || Date.now()), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n throw 'date not in range 1980-2099';\n wbytes(d, b, ((y << 24) * 2) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >>> 1));\n b += 4;\n wbytes(d, b, c);\n wbytes(d, b + 4, l);\n wbytes(d, b + 8, su);\n wbytes(d, b + 12, fl), b += 16; // skip extra field, comment\n if (ce != null)\n wbytes(d, b += 10, ce), b += 4;\n d.set(fn, b);\n b += fl;\n if (ce == null)\n d.set(cmp, b);\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n throw 'no callback';\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n wzh(out, tot, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, tot, f.t), o += 46 + f.n.length, tot += 30 + f.n.length + f.d.length;\n }\n catch (e) {\n return cb(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cb(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), m = file.length;\n c.p(file);\n var n = strToU8(fn), s = n.length;\n var t = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n var l = d.length;\n files[i] = {\n t: t,\n d: d,\n m: m,\n c: c.d(),\n u: fn.length != l,\n n: n,\n p: p\n };\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n if (!--lft)\n cbf();\n }\n };\n if (n.length > 65535)\n cbl('filename too long', null);\n if (!t)\n cbl(null, file);\n else if (m < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (opts === void 0) { opts = {}; }\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var t = p.level == 0 ? 0 : 8;\n var n = strToU8(fn), s = n.length;\n if (n.length > 65535)\n throw 'filename too long';\n var d = t ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push({\n t: t,\n d: d,\n m: file.length,\n c: c.d(),\n u: fn.length != s,\n n: n,\n o: o,\n p: p\n });\n o += 30 + s + l;\n tot += 76 + 2 * s + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f.c, f.d, f.m, f.n, f.u, f.p, null, f.t);\n wzh(out, o, f.c, f.d, f.m, f.n, f.u, f.p, f.o, f.t), o += 46 + f.n.length;\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Asynchronously decompresses a ZIP archive\n * @param data The raw compressed ZIP file\n * @param cb The callback to call with the decompressed files\n * @returns A function that can be used to immediately terminate the unzipping\n */\nexport function unzip(data, cb) {\n if (typeof cb != 'function')\n throw 'no callback';\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cb('invalid zip file', null);\n return;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (!lft)\n cb(null, {});\n var c = lft;\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = lft = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n var _loop_2 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cb(e, null);\n }\n else {\n files[fn] = d;\n if (!--lft)\n cb(null, files);\n }\n };\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n if (sc < 320000) {\n try {\n cbl(null, inflateSync(infl, new u8(su)));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl('unknown compression type ' + c_1, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_2(i);\n }\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @returns The decompressed files\n */\nexport function unzipSync(data) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n throw 'invalid zip file';\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = o == 4294967295;\n if (z) {\n e = b4(data, e - 12);\n if (b4(data, e) != 0x6064B50)\n throw 'invalid zip file';\n c = b4(data, e + 32);\n o = b4(data, e + 48);\n }\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));\n else\n throw 'unknown compression type ' + c_2;\n }\n return files;\n}\n","import { eventWithTime } from '../types';\n\nexport type PackFn = (event: eventWithTime) => string;\nexport type UnpackFn = (raw: string) => eventWithTime;\n\nexport type eventWithTimeAndPacker = eventWithTime & {\n v: string;\n};\n\nexport const MARK = 'v1';\n","// tslint:disable\n/**\n * Class StackFrame is a fork of https://github.com/stacktracejs/stackframe/blob/master/stackframe.js\n * I fork it because:\n * 1. There are some build issues when importing this package.\n * 2. Rewrites into typescript give us a better type interface.\n * 3. StackFrame contains some functions we don't need.\n */\nexport class StackFrame {\n private fileName: string;\n private functionName: string;\n private lineNumber?: number;\n private columnNumber?: number;\n\n constructor(obj: {\n fileName?: string;\n functionName?: string;\n lineNumber?: number;\n columnNumber?: number;\n }) {\n this.fileName = obj.fileName || '';\n this.functionName = obj.functionName || '';\n this.lineNumber = obj.lineNumber;\n this.columnNumber = obj.columnNumber;\n }\n\n toString() {\n const lineNumber = this.lineNumber || '';\n const columnNumber = this.columnNumber || '';\n if (this.functionName) {\n return (\n this.functionName +\n ' (' +\n this.fileName +\n ':' +\n lineNumber +\n ':' +\n columnNumber +\n ')'\n );\n }\n return this.fileName + ':' + lineNumber + ':' + columnNumber;\n }\n}\n\n/**\n * ErrorStackParser is a fork of https://github.com/stacktracejs/error-stack-parser/blob/master/error-stack-parser.js\n * I fork it because:\n * 1. There are some build issues when importing this package.\n * 2. Rewrites into typescript give us a better type interface.\n */\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/;\nconst CHROME_IE_STACK_REGEXP = /^\\s*at .*(\\S+:\\d+|\\(native\\))/m;\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code])?$/;\nexport const ErrorStackParser = {\n /**\n * Given an Error object, extract the most information from it.\n *\n * @param {Error} error object\n * @return {Array} of StackFrames\n */\n parse: function (error: Error): StackFrame[] {\n // https://github.com/rrweb-io/rrweb/issues/782\n if (!error) {\n return [];\n }\n if (\n // @ts-ignore\n typeof error.stacktrace !== 'undefined' ||\n // @ts-ignore\n typeof error['opera#sourceloc'] !== 'undefined'\n ) {\n return this.parseOpera(\n error as {\n stacktrace?: string;\n message: string;\n stack?: string;\n },\n );\n } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {\n return this.parseV8OrIE(error as { stack: string });\n } else if (error.stack) {\n return this.parseFFOrSafari(error as { stack: string });\n } else {\n throw new Error('Cannot parse given Error object');\n }\n },\n // Separate line and column numbers from a string of the form: (URI:Line:Column)\n extractLocation: function (urlLike: string) {\n // Fail-fast but return locations like \"(native)\"\n if (urlLike.indexOf(':') === -1) {\n return [urlLike];\n }\n\n const regExp = /(.+?)(?::(\\d+))?(?::(\\d+))?$/;\n const parts = regExp.exec(urlLike.replace(/[()]/g, ''));\n if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);\n return [parts[1], parts[2] || undefined, parts[3] || undefined];\n },\n parseV8OrIE: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return !!line.match(CHROME_IE_STACK_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n if (line.indexOf('(eval ') > -1) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n line = line\n .replace(/eval code/g, 'eval')\n .replace(/(\\(eval at [^()]*)|(\\),.*$)/g, '');\n }\n let sanitizedLine = line.replace(/^\\s+/, '').replace(/\\(eval code/g, '(');\n\n // capture and preseve the parenthesized location \"(/foo/my bar.js:12:87)\" in\n // case it has spaces in it, as the string is split on \\s+ later on\n const location = sanitizedLine.match(/ (\\((.+):(\\d+):(\\d+)\\)$)/);\n\n // remove the parenthesized location from the line, if it was matched\n sanitizedLine = location\n ? sanitizedLine.replace(location[0], '')\n : sanitizedLine;\n\n const tokens = sanitizedLine.split(/\\s+/).slice(1);\n // if a location was matched, pass it to extractLocation() otherwise pop the last token\n const locationParts = this.extractLocation(\n location ? location[1] : tokens.pop(),\n );\n const functionName = tokens.join(' ') || undefined;\n const fileName =\n ['eval', ''].indexOf(locationParts[0]) > -1\n ? undefined\n : locationParts[0];\n\n return new StackFrame({\n functionName,\n fileName,\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }, this);\n },\n parseFFOrSafari: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return !line.match(SAFARI_NATIVE_CODE_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n if (line.indexOf(' > eval') > -1) {\n line = line.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n ':$1',\n );\n }\n\n if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {\n // Safari eval frames only have function names and nothing else\n return new StackFrame({\n functionName: line,\n });\n } else {\n const functionNameRegex = /((.*\".+\"[^@]*)?[^@]*)(?:@)/;\n const matches = line.match(functionNameRegex);\n const functionName = matches && matches[1] ? matches[1] : undefined;\n const locationParts = this.extractLocation(\n line.replace(functionNameRegex, ''),\n );\n\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }\n }, this);\n },\n parseOpera: function (e: {\n stacktrace?: string;\n message: string;\n stack?: string;\n }): StackFrame[] {\n if (\n !e.stacktrace ||\n (e.message.indexOf('\\n') > -1 &&\n e.message.split('\\n').length > e.stacktrace.split('\\n').length)\n ) {\n return this.parseOpera9(e as { message: string });\n } else if (!e.stack) {\n return this.parseOpera10(e as { stacktrace: string });\n } else {\n return this.parseOpera11(e as { stack: string });\n }\n },\n parseOpera9: function (e: { message: string }) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)/i;\n const lines = e.message.split('\\n');\n const result = [];\n\n for (let i = 2, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n fileName: match[2],\n lineNumber: parseFloat(match[1]),\n }),\n );\n }\n }\n\n return result;\n },\n parseOpera10: function (e: { stacktrace: string }) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)(?:: In function (\\S+))?$/i;\n const lines = e.stacktrace.split('\\n');\n const result = [];\n\n for (let i = 0, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n functionName: match[3] || undefined,\n fileName: match[2],\n lineNumber: parseFloat(match[1]),\n }),\n );\n }\n }\n\n return result;\n },\n // Opera 10.65+ Error.stack very similar to FF/Safari\n parseOpera11: function (error: { stack: string }) {\n const filtered = error.stack.split('\\n').filter(function (line) {\n return (\n !!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&\n !line.match(/^Error created at/)\n );\n }, this);\n\n return filtered.map(function (line: string) {\n const tokens = line.split('@');\n const locationParts = this.extractLocation(tokens.pop());\n const functionCall = tokens.shift() || '';\n const functionName =\n functionCall\n .replace(//, '$2')\n .replace(/\\([^)]*\\)/g, '') || undefined;\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n });\n }, this);\n },\n};\n","// tslint:disable:no-any no-bitwise forin\n/**\n * this file is used to serialize log message to string\n *\n */\n\nimport { StringifyOptions } from './index';\n\n/**\n * transfer the node path in Event to string\n * @param node the first node in a node path array\n */\nfunction pathToSelector(node: HTMLElement): string | '' {\n if (!node || !node.outerHTML) {\n return '';\n }\n\n let path = '';\n while (node.parentElement) {\n let name = node.localName;\n if (!name) {\n break;\n }\n name = name.toLowerCase();\n let parent = node.parentElement;\n\n let domSiblings = [];\n\n if (parent.children && parent.children.length > 0) {\n // tslint:disable-next-line:prefer-for-of\n for (let i = 0; i < parent.children.length; i++) {\n let sibling = parent.children[i];\n if (sibling.localName && sibling.localName.toLowerCase) {\n if (sibling.localName.toLowerCase() === name) {\n domSiblings.push(sibling);\n }\n }\n }\n }\n\n if (domSiblings.length > 1) {\n name += ':eq(' + domSiblings.indexOf(node) + ')';\n }\n path = name + (path ? '>' + path : '');\n node = parent;\n }\n\n return path;\n}\n\n/**\n * judge is object\n */\nfunction isObject(obj: any): boolean {\n return Object.prototype.toString.call(obj) === '[object Object]';\n}\n\n/**\n * judge the object's depth\n */\nfunction isObjTooDeep(obj: any, limit: number): boolean {\n if (limit === 0) {\n return true;\n }\n\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * stringify any js object\n * @param obj the object to stringify\n */\nexport function stringify(\n obj: any,\n stringifyOptions?: StringifyOptions,\n): string {\n const options: StringifyOptions = {\n numOfKeysLimit: 50,\n depthOfLimit: 4,\n };\n Object.assign(options, stringifyOptions);\n const stack: any[] = [];\n const keys: any[] = [];\n return JSON.stringify(obj, function (key, value) {\n /**\n * forked from https://github.com/moll/json-stringify-safe/blob/master/stringify.js\n * to deCycle the object\n */\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);\n if (~stack.indexOf(value)) {\n if (stack[0] === value) {\n value = '[Circular ~]';\n } else {\n value =\n '[Circular ~.' +\n keys.slice(0, stack.indexOf(value)).join('.') +\n ']';\n }\n }\n } else {\n stack.push(value);\n }\n /* END of the FORK */\n\n if (value === null || value === undefined) {\n return value;\n }\n if (shouldIgnore(value)) {\n return toString(value);\n }\n if (value instanceof Event) {\n const eventResult: any = {};\n for (const eventKey in value) {\n const eventValue = (value as any)[eventKey];\n if (Array.isArray(eventValue)) {\n eventResult[eventKey] = pathToSelector(\n eventValue.length ? eventValue[0] : null,\n );\n } else {\n eventResult[eventKey] = eventValue;\n }\n }\n return eventResult;\n } else if (value instanceof Node) {\n if (value instanceof HTMLElement) {\n return value ? value.outerHTML : '';\n }\n return value.nodeName;\n } else if (value instanceof Error) {\n return value.stack\n ? value.stack + '\\nEnd of stack for Error object'\n : value.name + ': ' + value.message;\n }\n return value;\n });\n\n /**\n * whether we should ignore obj's info and call toString() function instead\n */\n function shouldIgnore(_obj: object): boolean {\n // outof keys limit\n if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {\n return true;\n }\n\n // is function\n if (typeof _obj === 'function') {\n return true;\n }\n\n /**\n * judge object's depth to avoid browser's OOM\n *\n * issues: https://github.com/rrweb-io/rrweb/issues/653\n */\n if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * limit the toString() result according to option\n */\n function toString(_obj: object): string {\n let str = _obj.toString();\n if (options.stringLengthLimit && str.length > options.stringLengthLimit) {\n str = `${str.slice(0, options.stringLengthLimit)}...`;\n }\n return str;\n }\n}\n","import { listenerHandler, RecordPlugin, IWindow } from '../../../types';\nimport { patch } from '../../../utils';\nimport { ErrorStackParser, StackFrame } from './error-stack-parser';\nimport { stringify } from './stringify';\n\nexport type StringifyOptions = {\n // limit of string length\n stringLengthLimit?: number;\n /**\n * limit of number of keys in an object\n * if an object contains more keys than this limit, we would call its toString function directly\n */\n numOfKeysLimit: number;\n /**\n * limit number of depth in an object\n * if an object is too deep, toString process may cause browser OOM\n */\n depthOfLimit: number;\n};\n\ntype LogRecordOptions = {\n level?: LogLevel[];\n lengthThreshold?: number;\n stringifyOptions?: StringifyOptions;\n logger?: Logger | 'console';\n};\n\nconst defaultLogOptions: LogRecordOptions = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n lengthThreshold: 1000,\n logger: 'console',\n};\n\nexport type LogData = {\n level: LogLevel;\n trace: string[];\n payload: string[];\n};\n\ntype logCallback = (p: LogData) => void;\n\nexport type LogLevel =\n | 'assert'\n | 'clear'\n | 'count'\n | 'countReset'\n | 'debug'\n | 'dir'\n | 'dirxml'\n | 'error'\n | 'group'\n | 'groupCollapsed'\n | 'groupEnd'\n | 'info'\n | 'log'\n | 'table'\n | 'time'\n | 'timeEnd'\n | 'timeLog'\n | 'trace'\n | 'warn';\n\n/* fork from interface Console */\n// all kinds of console functions\nexport type Logger = {\n assert?: typeof console.assert;\n clear?: typeof console.clear;\n count?: typeof console.count;\n countReset?: typeof console.countReset;\n debug?: typeof console.debug;\n dir?: typeof console.dir;\n dirxml?: typeof console.dirxml;\n error?: typeof console.error;\n group?: typeof console.group;\n groupCollapsed?: typeof console.groupCollapsed;\n groupEnd?: () => void;\n info?: typeof console.info;\n log?: typeof console.log;\n table?: typeof console.table;\n time?: typeof console.time;\n timeEnd?: typeof console.timeEnd;\n timeLog?: typeof console.timeLog;\n trace?: typeof console.trace;\n warn?: typeof console.warn;\n};\n\nfunction initLogObserver(\n cb: logCallback,\n win: IWindow, // top window or in an iframe\n logOptions: LogRecordOptions,\n): listenerHandler {\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {};\n }\n let logger: Logger;\n if (typeof loggerType === 'string') {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n const cancelHandlers: listenerHandler[] = [];\n // add listener to thrown errors\n if (logOptions.level!.includes('error')) {\n if (window) {\n const errorHandler = (event: ErrorEvent) => {\n const { message, error } = event;\n const trace: string[] = ErrorStackParser.parse(\n error,\n ).map((stackFrame: StackFrame) => stackFrame.toString());\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: 'error',\n trace,\n payload,\n });\n };\n window.addEventListener('error', errorHandler);\n cancelHandlers.push(() => {\n if (window) window.removeEventListener('error', errorHandler);\n });\n }\n }\n for (const levelType of logOptions.level!) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n\n /**\n * replace the original console function and record logs\n * @param logger the logger object such as Console\n * @param level the name of log function to be replaced\n */\n function replace(_logger: Logger, level: LogLevel) {\n if (!_logger[level]) {\n return () => {};\n }\n // replace the logger.{level}. return a restore function\n return patch(_logger, level, (original) => {\n return (...args: Array) => {\n original.apply(this, args);\n try {\n const trace = ErrorStackParser.parse(new Error())\n .map((stackFrame: StackFrame) => stackFrame.toString())\n .splice(1); // splice(1) to omit the hijacked log function\n const payload = args.map((s) =>\n stringify(s, logOptions.stringifyOptions),\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold!) {\n cb({\n level,\n trace,\n payload,\n });\n } else if (logCount === logOptions.lengthThreshold) {\n // notify the user\n cb({\n level: 'warn',\n trace: [],\n payload: [\n stringify('The number of log records reached the threshold.'),\n ],\n });\n }\n } catch (error) {\n original('rrweb logger error:', error, ...args);\n }\n };\n });\n }\n}\n\nexport const PLUGIN_NAME = 'rrweb/console@1';\n\nexport const getRecordConsolePlugin: (\n options?: LogRecordOptions,\n) => RecordPlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options: options\n ? Object.assign({}, defaultLogOptions, options)\n : defaultLogOptions,\n});\n","import { LogLevel, LogData, PLUGIN_NAME } from '../record';\nimport {\n eventWithTime,\n EventType,\n IncrementalSource,\n ReplayPlugin,\n} from '../../../types';\n\n/**\n * define an interface to replay log records\n * (data: logData) => void> function to display the log data\n */\ntype ReplayLogger = Partial void>>;\n\ntype LogReplayConfig = {\n level?: LogLevel[];\n replayLogger?: ReplayLogger;\n};\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedConsoleLog = {\n [ORIGINAL_ATTRIBUTE_NAME]: typeof console.log;\n};\n\nconst defaultLogConfig: LogReplayConfig = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n replayLogger: undefined,\n};\n\nclass LogReplayPlugin {\n private config: LogReplayConfig;\n\n constructor(config?: LogReplayConfig) {\n this.config = Object.assign(defaultLogConfig, config);\n }\n\n /**\n * generate a console log replayer which implement the interface ReplayLogger\n */\n public getConsoleLogger(): ReplayLogger {\n const replayLogger: ReplayLogger = {};\n for (const level of this.config.level!) {\n if (level === 'trace') {\n replayLogger[level] = (data: LogData) => {\n const logger = ((console.log as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? ((console.log as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console.log;\n logger(\n ...data.payload.map((s) => JSON.parse(s)),\n this.formatMessage(data),\n );\n };\n } else {\n replayLogger[level] = (data: LogData) => {\n const logger = ((console[level] as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? ((console[level] as unknown) as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console[level];\n logger(\n ...data.payload.map((s) => JSON.parse(s)),\n this.formatMessage(data),\n );\n };\n }\n }\n return replayLogger;\n }\n\n /**\n * format the trace data to a string\n * @param data the log data\n */\n private formatMessage(data: LogData): string {\n if (data.trace.length === 0) {\n return '';\n }\n const stackPrefix = '\\n\\tat ';\n let result = stackPrefix;\n result += data.trace.join(stackPrefix);\n return result;\n }\n}\n\nexport const getReplayConsolePlugin: (\n options?: LogReplayConfig,\n) => ReplayPlugin = (options) => {\n const replayLogger =\n options?.replayLogger || new LogReplayPlugin(options).getConsoleLogger();\n\n return {\n handler(event: eventWithTime, _isSync, context) {\n let logData: LogData | null = null;\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === (IncrementalSource.Log as IncrementalSource)\n ) {\n logData = (event.data as unknown) as LogData;\n } else if (\n event.type === EventType.Plugin &&\n event.data.plugin === PLUGIN_NAME\n ) {\n logData = event.data.payload as LogData;\n }\n if (logData) {\n try {\n if (typeof replayLogger[logData.level] === 'function') {\n replayLogger[logData.level]!(logData);\n }\n } catch (error) {\n if (context.replayer.config.showWarning) {\n console.warn(error);\n }\n }\n }\n },\n };\n};\n","import { strFromU8, strToU8, zlibSync } from 'fflate';\nimport { PackFn, MARK, eventWithTimeAndPacker } from './base';\n\nexport const pack: PackFn = (event) => {\n const _e: eventWithTimeAndPacker = {\n ...event,\n v: MARK,\n };\n return strFromU8(zlibSync(strToU8(JSON.stringify(_e))), true);\n};\n","import { strFromU8, strToU8, unzlibSync } from 'fflate';\nimport { UnpackFn, eventWithTimeAndPacker, MARK } from './base';\nimport { eventWithTime } from '../types';\n\nexport const unpack: UnpackFn = (raw: string) => {\n if (typeof raw !== 'string') {\n return raw;\n }\n try {\n const e: eventWithTime = JSON.parse(raw);\n if (e.timestamp) {\n return e;\n }\n } catch (error) {\n // ignore and continue\n }\n try {\n const e: eventWithTimeAndPacker = JSON.parse(\n strFromU8(unzlibSync(strToU8(raw, true)))\n );\n if (e.v === MARK) {\n return e;\n }\n throw new Error(\n `These events were packed with packer ${e.v} which is incompatible with current packer ${MARK}.`,\n );\n } catch (error) {\n console.error(error);\n throw new Error('Unknown data format.');\n }\n};\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isElement","nodeType","ELEMENT_NODE","isShadowRoot","_a","host","Boolean","shadowRoot","maskInputValue","input","maskInputSelector","unmaskInputSelector","maskInputOptions","tagName","type","maskInputFn","text","matches","toLowerCase","repeat","ORIGINAL_ATTRIBUTE_NAME","canvasService","canvasCtx","_id","tagNameRegex","RegExp","getCssRulesString","rules","cssRules","map","getCssRuleString","join","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","stack","parts","pop","_i","parts_1","part","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","unmaskTextSelector","closest","classList","contains","eIndex","className","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","unblockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","Math","min","data","buffer","some","pixel","is2DCanvasBlank","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","_l","_m","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","commentre","parse","css","lineno","column","updatePosition","str","lines","lastIndexOf","position","start","line","Position","whitespace","end","source","content","errorsList","msg","Error","reason","filename","silent","open","close","comments","atrule","re","selector","declaration","propMatch","prop","val","ret","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","vendor","frame","frames","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","atdocument","sel","selectors","atpage","athost","atfontface","addParent","parsingErrors","obj","parent","isNode","childParent","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cache","cachedStyle","stylesWithHoverClass","get","ast","selectorMatcher","filter","index","sort","b","result","newSelector","set","createCache","Map","buildNode","hackCss","implementation","createDocument","createDocumentType","node_1","getTagName","createElementNS","_loop_1","startsWith","image","setAttribute","play","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","removeChild","appendChild","setAttributeNS","srcset","firstChild","attachShadow","mode","createCDATASection","createComment","buildNodeWithSN","afterAppend","assert","xmlns","write","childN","childNode","rebuild","onVisit","idNodeMap","key","visit","visitedNode","name_2","handleScroll","on","fn","target","capture","passive","removeEventListener","createMirror","getId","getNode","removeNodeFromMap","_this","has","reset","DEPARTED_MIRROR_ACCESS_WARNING","throttle","func","wait","timeout","previous","arg","now","Date","leading","remaining","context","args","trailing","hookSetter","d","isRevoked","original","getOwnPropertyDescriptor","patch","replacement","original_1","wrapped","defineProperties","__rrweb_original__","getWindowHeight","window","innerHeight","documentElement","clientHeight","body","getWindowWidth","innerWidth","clientWidth","isBlocked","needBlock_1","isIgnored","isAncestorRemoved","mirror","isTouchEvent","event","changedTouches","polyfill","NodeList","DOMTokenList","Node","Proxy","Reflect","_mirror","receiver","TreeIndex","mutation","parentTreeNode","indexes","parentId","treeNode","children","texts","tree","deepRemoveFromMirror","removeIdSet","add","deepRemoveFromTreeIndex","_treeNode","_parentTreeNode","delete","removeNodeMutations","textMutations","attributeMutations","scrollMap","inputMap","batchMutationData","Mutation","removes","adds","walk","removed","mutationData","Set","queueToResolveTrees","queue","queueNodeMap","putIntoMap","nodeInTree","queueNodeTrees","queue_1","nextId","nextInTree","idx","splice","parentInTree","iterateResolveTree","cb","isIframeINode","getBaseDimension","rootIframe","frameElement","ownerDocument","defaultView","relativeScale","absoluteScale","frameDimension","frameBaseDimension","hasShadowRoot","isNodeInLinkedList","DoubleLinkedList","current","head","__ln","moveKey","isINode","mutations","processMutation","emit","frozen","locked","addList","getNextId","ns","pushAdd","shadowHost","getRootNode","rootShadowHost","notInDoc","addNode","currentN","iframeManager","addIframe","shadowDomManager","addShadowRoot","iframe","childSn","attachIframe","observeAttachShadow","mapRemoves","shift","movedSet","isParentRemoved","addedSet","isAncestorInSet","droppedSet","candidate","_node","removeNode","payload","attribute","movedMap","mutationCb","oldValue","getAttribute","attributeName","item","old","styleObj","pname","newValue","getPropertyValue","newPriority","getPropertyPriority","addedNodes","genAdds","removedNodes","nodeId","deepDelete","targetId","MutationBuffer","canvasManager","freeze","unfreeze","lock","unlock","addsSet","mutationBuffers","isCSSGroupingRuleSupported","CSSGroupingRule","isCSSMediaRuleSupported","CSSMediaRule","isCSSSupportsRuleSupported","CSSSupportsRule","isCSSConditionRuleSupported","CSSConditionRule","getEventTarget","path","composedPath","initMutationObserver","rootEl","mutationBuffer","init","mutationObserverCtor","MutationObserver","__rrMutationObserver","angularZoneSymbol","Zone","__symbol__","observer","processMutations","bind","observe","attributeOldValue","characterData","characterDataOldValue","childList","subtree","initMouseInteractionObserver","mouseInteractionCb","sampling","mouseInteraction","disableMap","handlers","Number","isNaN","eventKey","eventName","handler","clientX","clientY","getHandler","h","initScrollObserver","scrollCb","evt","scrollEl","scrollingElement","scroll","wrapEventWithUserTriggeredFlag","enable","userTriggered","INPUT_TAGS","lastInputValueMap","WeakMap","getNestedCSSRulePositions","childRule","parentRule","unshift","parentStyleSheet","recurse","initObservers","hooks","currentWindow","mousemoveCb","viewportResizeCb","inputCb","mediaInteractionCb","styleSheetRuleCb","styleDeclarationCb","canvasMutationCb","fontCb","mousemove","viewportResize","mediaInteaction","styleSheetRule","styleDeclaration","canvasMutation","font","mergeHooks","mutationObserver","mousemoveHandler","timeBaseline","threshold","callbackThreshold","mousemoveCallback","positions","wrappedCb","totalOffset","timeOffset","DragEvent","Drag","MouseEvent","MouseMove","TouchMove","initMoveObserver","mouseInteractionHandler","scrollHandler","viewportResizeHandler","lastH","lastW","initViewportResizeObserver","inputHandler","ignoreClass","ignoreSelector","userTriggeredOnInput","eventHandler","isTrusted","parentElement","isChecked","cbWithDedup","querySelectorAll","lastInputValue","propertyDescriptor","HTMLInputElement","hookProperties","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement","initInputObserver","mediaInteractionHandler","volume","muted","initMediaInteractionObserver","styleSheetObserver","CSSStyleSheet","insertRule","ownerNode","deleteRule","supportedNestedCSSRuleTypes","unmodifiedFunctions","entries","typeKey","initStyleSheetObserver","styleDeclarationObserver","setProperty","CSSStyleDeclaration","priority","removeProperty","remove","initStyleDeclarationObserver","fontObserver","collectFonts","fontMap","originalFontFace","FontFace","family","descriptors","fontFace","fontSource","JSON","stringify","Uint8Array","restoreHandler","fonts","initFontObserver","pluginHandlers","plugins","plugin","callback","disconnect","IframeManager","iframes","loadListener","isAttachIframe","manager","restorePatches","HTMLElement","ShadowDomManager","iframeElement","manager_1","restorePatch","lookup","charCodeAt","webGLVarMap","saveWebGLVar","isInstanceOfWebGLObject","list","ctor","contextMap","variableListFor","constructor","serializeArg","Float32Array","Float64Array","Int32Array","Uint16Array","Int16Array","Int8Array","Uint8ClampedArray","rr_type","ArrayBuffer","base64","arraybuffer","bytes","len","encode","DataView","byteOffset","byteLength","HTMLImageElement","ImageData","serializeArgs","supportedWebGLConstructorNames","patchGLPrototype","props","getOwnPropertyNames","recordArgs","hookHandler","setter","props_1","wrappedEmit","takeFullSnapshot","latestId","invokeId","rafStamps","pendingCanvasMutations","initCanvasMutationObserver","CanvasManager","clear","resetObservers","startRAFTimestamping","startPendingCanvasMutationFlusher","canvasContextReset","HTMLCanvasElement","contextType","initCanvasContextObserver","canvas2DReset","props2D","CanvasRenderingContext2D","imgd","pix","props2D_1","initCanvas2DMutationObserver","canvasWebGL1and2Reset","WebGLRenderingContext","WebGL","WebGL2RenderingContext","WebGL2","initCanvasWebGLMutationObserver","requestAnimationFrame","flushPendingCanvasMutations","setLatestRAFTimestamp","timestamp","flushPendingCanvasMutationFor","valuesWithType","getOwnPropertySymbols","propertyIsEnumerable","commands","wrapEvent","record","checkoutEveryNms","checkoutEveryNth","maskAllInputs","_maskInputOptions","_slimDOMOptions","packFn","mousemoveWait","_o","_p","_q","_r","_s","lastFullSnapshotEvent","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","incrementalSnapshotCount","isCheckout","isFrozen","FullSnapshot","IncrementalSnapshot","buf","eventProcessor","exceedCount","exceedTime","wrappedMutationEmit","wrappedScrollEmit","Scroll","wrappedCanvasMutationEmit","CanvasMutation","Meta","slimDOM","snapshot","initialOffset","left","pageXOffset","top","pageYOffset","handlers_1","DomContentLoaded","observe_1","MouseInteraction","ViewportResize","Input","MediaInteraction","StyleSheetRule","StyleDeclaration","Font","Plugin","addLoadListener","init_1","Load","mitt","all","create","off","addCustomEvent","tag","Custom","freezePage","w","__forceSmoothScrollPolyfill__","userAgent","scrollTo","scrollBy","elementScroll","scrollElement","scrollIntoView","performance","ROUNDING_TOLERANCE","navigator","shouldBailOut","smoothScroll","scrollX","scrollY","SyntaxError","behavior","scrollableParent","findScrollableParent","parentRects","clientRects","getComputedStyle","firstArg","hasScrollableSpace","axis","scrollHeight","scrollWidth","canOverflow","overflowValue","isScrollable","isScrollableY","isScrollableX","step","currentX","currentY","k","elapsed","startTime","cos","PI","startX","startY","method","scrollable","actions","speed","Timer","action","findActionIndex","lastTimestamp","self","raf","check","delay","doAction","liveMode","cancelAnimationFrame","mid","floor","addDelay","baselineTime","firstOffset","firstTimestamp","return","NotStarted","Running","Stopped","assignment","u","changed","f","states","initial","entry","config","_options","initialState","transition","g","S","j","E","R","N","cond","O","_","T","q","exit","z","A","B","C","_machine","send","subscribe","unsubscribe","stop","state","status","createPlayerService","getCastFn","applyEventsSynchronously","emitter","interpret","createMachine","playing","PAUSE","CAST_EVENT","END","ADD_EVENT","PLAY","TO_LIVE","live","castEvent","lastPlayedEvent","recordTimeOffset","events","timer","events_1","neededEvents","event_1","discardPriorSnapshots","lastPlayedTimestamp","PlayBack","syncEvents","event_3","castFn_1","neededEvents_1","Flush","addActions","resetLastPlayedEvent","startLive","toggleLiveMode","addEvent","machineEvent","event_4","insertionIndex","isSync","castFn_2","isActive","addAction","StyleRuleType","getNestedRule","getPositionsAndIndex","nestedIndex","applyVirtualStyleRulesToNode","storedRules","styleNode","Insert","Remove","Snapshot","cssTexts","existingRules","existingRulesReversed","reverse","lastMatch_1","restoreSnapshotOfStyleRulesToNode","SetProperty","RemoveProperty","WebGLVariableConstructorsNames","deserializeArg","imageMap","encoded1","encoded2","encoded3","encoded4","bufferLength","decode","Image","webglMutation","errorHandler","includes","variables","saveToWebGLVarMap","mittProxy.default","mittProxy","REPLAY_CONSOLE_PREFIX","defaultMouseTailConfig","duration","lineCap","lineWidth","strokeStyle","indicatesTouchDevice","TouchStart","defaultConfig","maxSpeed","root","loadTimeout","skipInactive","showWarning","showDebug","insertStyleRules","triggerFocus","UNSAFE_replayCanvas","pauseAnimation","mouseTail","handleResize","Resize","setupDom","treeIndex","fragmentParentMap","elementStateMap","virtualStyleRulesMap","flush","frag","restoreRealParent","applyText","restoreNodeSheet","applyScroll","applyInput","firstFullSnapshot","service","unpackFn","a1","a2","StateChange","player","speedService","normalSpeed","normal","FAST_FORWARD","SET_SPEED","skipping","BACK_TO_NORMAL","setSpeed","recordSpeed","restoreSpeed","firstMeta","firstFullsnapshot","width_1","height_1","rebuildFullSnapshot","mouse","Replayer","backToNormal","display","parseFloat","wrapper","insertBefore","firstEvent","lastEvent","endTime","totalTime","getTimeOffset","getElementsByTagName","Start","Pause","Resume","rawEvent","Promise","resolve","then","pointerEvents","disableInteract","smoothscrollPolyfill","dimension","String","castFn","mousePos","moveAndHover","debugData","touchActive","CustomEvent","applyIncremental","nextUserInteractionEvent","_event","isUserInteraction","skipTime","round","SkipStart","replayer","last_index","finish_1","Finish","max","EventCast","legacy_missingNodeRetryMap","collected","builtNode","collectIframeAndAttachDocument","mutationInQueue","this_1","attachDocumentToIframe","newDocumentQueue","collected_1","FullsnapshotRebuilded","waitForStylesheetLoad","preloadAllImages","styleEl","injectStylesRules","parent_1","realParent","toUpperCase","this_2","collected_2","unloadSheets_1","beforeLoadState_1","stateHandler_1","unsubscribe_1","size","getCurrentTime","LoadStylesheetEnd","LoadStylesheetStart","args_1","hasImageArg","images","args_2","getImageArgs","stateHandler","event_2","preloadImages","this_3","createImageData","putImageData","applyMutation","message","lastPosition","Event","debugNodeNotFound","Blur","blur","Focus","focus","preventScroll","Click","TouchEnd","tailPositions","offsetWidth","TouchCancel","dispatchEvent","mediaEl","rules_1","parent_2","usingVirtualParent_1","styleSheet_1","parent_3","command","canvas2DMutation","warnCanvasMutationFailed","useVirtualParent","warnNodeNotFound","realTarget","DOMException","legacy_missingNodeMap","appendNode","parentInDocument","hasIframeChild","virtualParent","createDocumentFragment","storeState","previousId","nextNotInDOM","targetDoc","mutationInQueue_1","legacy_resolveMissingNode","resolveTrees","resolveTrees_1","debug","removeAttribute","styleValues","targetEl","svp","svs","targetMutation","previousInMap","nextInMap","base","_x","_y","drawMouseTail","hoverElements","draw","clearRect","beginPath","moveTo","lineTo","stroke","hoveredEl","currentEl","SkipEnd","restoreState","storeCSSRules","storedState","nodeName","idRemoved","log","u8","u16","u32","fleb","fdeb","clim","freb","eb","fl","revfl","fd","revfd","rev","hMap","cd","mb","co","le","rvb","sv","r_1","flt","fdt","flm","flrm","fdm","fdrm","bits","bits16","shft","slc","subarray","wbits","wbits16","hTree","t2","i0","i1","i2","maxSym","tr","mbt","ln","dt","lft","cst","i2_1","i2_2","i2_3","lc","cl","cli","cln","cls","clen","cf","wfblk","out","dat","wblk","final","syms","lf","df","li","bs","bl","dlt","mlb","ddt","mdb","lclt","nlc","lcdt","ndc","lcfreq","lct","mlcb","nlcc","lm","ll","dm","dl","flen","ftlen","dtlen","llm","lcts","it","clct","dst","deo","et","dopt","opt","pre","post","st","lvl","plvl","lst","msk_1","prev","bs1_1","ceil","bs2_1","hsh","lc_1","wi","hv","imod","pimod","rem","ch_1","dif","maxn","maxd","ml","nl","mmd","md","ti","lin","din","dflt","level","mem","zlibSync","opts","adler","lv","zlh","wbytes","unzlibSync","sl","noBuf","noSt","cbuf","nbuf","bt","lbt","dbt","tbts","hLit","hcLen","tl","ldt","clt","clb","clbmsk","clm","lt","lms","dms","mxa","sym","dsym","inflt","zlv","strToU8","latin1","TextEncoder","ai","strFromU8","TextDecoder","fromCharCode","MARK","fileName","functionName","lineNumber","columnNumber","StackFrame","FIREFOX_SAFARI_STACK_REGEXP","CHROME_IE_STACK_REGEXP","SAFARI_NATIVE_CODE_REGEXP","ErrorStackParser","stacktrace","parseOpera","parseV8OrIE","parseFFOrSafari","extractLocation","urlLike","sanitizedLine","tokens","locationParts","functionNameRegex","parseOpera9","parseOpera11","parseOpera10","lineRE","pathToSelector","outerHTML","localName","domSiblings","sibling","isObject","toString","isObjTooDeep","limit","keys_1","stringifyOptions","numOfKeysLimit","depthOfLimit","thisPos","Infinity","_obj","shouldIgnore","stringLengthLimit","eventResult","eventValue","defaultLogOptions","lengthThreshold","logger","initLogObserver","logOptions","loggerType","logCount","cancelHandlers","errorHandler_1","trace","stackFrame","levelType","_logger","PLUGIN_NAME","defaultLogConfig","replayLogger","LogReplayPlugin","formatMessage","stackPrefix","getConsoleLogger","_isSync","logData","Log","raw"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ED+BOC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,YAgFzB,SAASQ,EAASC,GACrB,IAAIZ,EAAsB,mBAAXa,QAAyBA,OAAOC,SAAUC,EAAIf,GAAKY,EAAEZ,GAAIC,EAAI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BAAhCN,EAAaM,EAAQ1G,QAC9BoG,EAAaM,EAAQ1G,OAAQ0G,GAE/B,MAAO3iD,GACH2d,EAAQqvB,SAAStM,OAAOqH,aAC1Br8B,QAAQC,KAAK3L,cCtIG,SAACwf,GAC3B,IAAMxW,SACDwW,IACHjK,EAAGmpC,KAEL,OAAOH,GAAUpC,GAASgC,GAAQ9sB,KAAKC,UAAUtoB,MAAO,yBCJ1B,SAAC65C,GAC/B,GAAmB,iBAARA,EACT,OAAOA,EAET,IAEE,IADMhjD,EAAmBwxB,KAAKpgB,MAAM4xC,IAC9B3rB,UACJ,OAAOr3B,EAET,MAAOG,IAGT,IACE,IAAMH,EAGN,IAHMA,EAA4BwxB,KAAKpgB,MACrCstC,GAAU9B,GAAW0B,GAAQ0E,GAAK,OAE9BttC,IAAMmpC,GACV,OAAO7+C,EAET,MAAM,IAAIsS,MACR,+CAAwCtS,EAAE0V,wDAA+CmpC,SAE3F,MAAO1+C,GAEP,MADA0L,QAAQ1L,MAAMA,GACR,IAAImS,MAAM"} +\ No newline at end of file +diff --git a/node_modules/rrweb/dist/rrweb.css b/node_modules/rrweb/dist/rrweb.css +new file mode 100755 +index 0000000..b459e51 +--- /dev/null ++++ b/node_modules/rrweb/dist/rrweb.css +@@ -0,0 +1,79 @@ ++.replayer-wrapper { ++ position: relative; ++} ++.replayer-mouse { ++ position: absolute; ++ width: 20px; ++ height: 20px; ++ transition: left 0.05s linear, top 0.05s linear; ++ background-size: contain; ++ background-position: center center; ++ background-repeat: no-repeat; ++ background-image: url('data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzMwMHB4JyB3aWR0aD0nMzAwcHgnICBmaWxsPSIjMDAwMDAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGRhdGEtbmFtZT0iTGF5ZXIgMSIgdmlld0JveD0iMCAwIDUwIDUwIiB4PSIwcHgiIHk9IjBweCI+PHRpdGxlPkRlc2lnbl90bnA8L3RpdGxlPjxwYXRoIGQ9Ik00OC43MSw0Mi45MUwzNC4wOCwyOC4yOSw0NC4zMywxOEExLDEsMCwwLDAsNDQsMTYuMzlMMi4zNSwxLjA2QTEsMSwwLDAsMCwxLjA2LDIuMzVMMTYuMzksNDRhMSwxLDAsMCwwLDEuNjUuMzZMMjguMjksMzQuMDgsNDIuOTEsNDguNzFhMSwxLDAsMCwwLDEuNDEsMGw0LjM4LTQuMzhBMSwxLDAsMCwwLDQ4LjcxLDQyLjkxWm0tNS4wOSwzLjY3TDI5LDMyYTEsMSwwLDAsMC0xLjQxLDBsLTkuODUsOS44NUwzLjY5LDMuNjlsMzguMTIsMTRMMzIsMjcuNThBMSwxLDAsMCwwLDMyLDI5TDQ2LjU5LDQzLjYyWiI+PC9wYXRoPjwvc3ZnPg=='); ++ border-color: transparent; /* otherwise we transition from black when .touch-device class is added */ ++} ++.replayer-mouse::after { ++ content: ''; ++ display: inline-block; ++ width: 20px; ++ height: 20px; ++ background: rgb(73, 80, 246); ++ border-radius: 100%; ++ transform: translate(-50%, -50%); ++ opacity: 0.3; ++} ++.replayer-mouse.active::after { ++ animation: click 0.2s ease-in-out 1; ++} ++.replayer-mouse.touch-device { ++ background-image: none; /* there's no passive cursor on touch-only screens */ ++ width: 70px; ++ height: 70px; ++ border-width: 4px; ++ border-style: solid; ++ border-radius: 100%; ++ margin-left: -37px; ++ margin-top: -37px; ++ border-color: rgba(73, 80, 246, 0); ++ transition: left 0s linear, top 0s linear, border-color 0.2s ease-in-out; ++} ++.replayer-mouse.touch-device.touch-active { ++ border-color: rgba(73, 80, 246, 1); ++ transition: left 0.25s linear, top 0.25s linear, border-color 0.2s ease-in-out; ++} ++.replayer-mouse.touch-device::after { ++ opacity: 0; /* there's no passive cursor on touch-only screens */ ++} ++.replayer-mouse.touch-device.active::after { ++ animation: touch-click 0.2s ease-in-out 1; ++} ++.replayer-mouse-tail { ++ position: absolute; ++ pointer-events: none; ++} ++ ++@keyframes click { ++ 0% { ++ opacity: 0.3; ++ width: 20px; ++ height: 20px; ++ } ++ 50% { ++ opacity: 0.5; ++ width: 10px; ++ height: 10px; ++ } ++} ++ ++@keyframes touch-click { ++ 0% { ++ opacity: 0; ++ width: 20px; ++ height: 20px; ++ } ++ 50% { ++ opacity: 0.5; ++ width: 10px; ++ height: 10px; ++ } ++} +diff --git a/node_modules/rrweb/dist/rrweb.js b/node_modules/rrweb/dist/rrweb.js +old mode 100644 +new mode 100755 +index 446a6a7..a06fec9 +--- a/node_modules/rrweb/dist/rrweb.js ++++ b/node_modules/rrweb/dist/rrweb.js +@@ -97,10 +97,14 @@ var rrweb = (function (exports) { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -327,7 +331,10 @@ var rrweb = (function (exports) { + return value; + } + } +- function _isBlockedElement(element, blockClass, blockSelector) { ++ function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -346,11 +353,16 @@ var rrweb = (function (exports) { + } + return false; + } +- function needMaskingText(node, maskTextClass, maskTextSelector) { ++ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -369,12 +381,12 @@ var rrweb = (function (exports) { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -414,7 +426,7 @@ var rrweb = (function (exports) { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -446,7 +458,7 @@ var rrweb = (function (exports) { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -487,9 +499,12 @@ var rrweb = (function (exports) { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -608,7 +623,7 @@ var rrweb = (function (exports) { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -716,15 +731,19 @@ var rrweb = (function (exports) { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -780,10 +799,14 @@ var rrweb = (function (exports) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -828,10 +851,14 @@ var rrweb = (function (exports) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -854,7 +881,7 @@ var rrweb = (function (exports) { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -903,10 +930,14 @@ var rrweb = (function (exports) { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -2442,8 +2473,12 @@ var rrweb = (function (exports) { + map: _this.mirror.map, + blockClass: _this.blockClass, + blockSelector: _this.blockSelector, ++ unblockSelector: _this.unblockSelector, + maskTextClass: _this.maskTextClass, + maskTextSelector: _this.maskTextSelector, ++ unmaskTextSelector: _this.unmaskTextSelector, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + skipChild: true, + inlineStylesheet: _this.inlineStylesheet, + maskInputOptions: _this.maskInputOptions, +@@ -2589,7 +2624,7 @@ var rrweb = (function (exports) { + var value = m.target.textContent; + if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) { + _this.texts.push({ +- value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector) && value ++ value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, _this.unmaskTextSelector) && value + ? _this.maskTextFn + ? _this.maskTextFn(value) + : value.replace(/[\S]/g, '*') +@@ -2604,6 +2639,9 @@ var rrweb = (function (exports) { + var value = m.target.getAttribute(m.attributeName); + if (m.attributeName === 'value') { + value = maskInputValue({ ++ input: target, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + maskInputOptions: _this.maskInputOptions, + tagName: m.target.tagName, + type: m.target.getAttribute('type'), +@@ -2740,8 +2778,12 @@ var rrweb = (function (exports) { + 'mutationCb', + 'blockClass', + 'blockSelector', ++ 'unblockSelector', + 'maskTextClass', + 'maskTextSelector', ++ 'unmaskTextSelector', ++ 'maskInputSelector', ++ 'unmaskInputSelector', + 'inlineStylesheet', + 'maskInputOptions', + 'maskTextFn', +@@ -3005,7 +3047,7 @@ var rrweb = (function (exports) { + var INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT']; + var lastInputValueMap = new WeakMap(); + function initInputObserver(_a) { +- var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; ++ var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; + function eventHandler(event) { + var target = getEventTarget(event); + var userTriggered = event.isTrusted; +@@ -3018,7 +3060,7 @@ var rrweb = (function (exports) { + return; + } + var type = target.type; +- if (target.classList.contains(ignoreClass)) { ++ if (target.classList.contains(ignoreClass) || (ignoreSelector && target.matches(ignoreSelector))) { + return; + } + var text = target.value; +@@ -3029,7 +3071,10 @@ var rrweb = (function (exports) { + else if (maskInputOptions[target.tagName.toLowerCase()] || + maskInputOptions[type]) { + text = maskInputValue({ ++ input: target, + maskInputOptions: maskInputOptions, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + tagName: target.tagName, + type: type, + value: text, +@@ -3113,6 +3158,9 @@ var rrweb = (function (exports) { + function initStyleSheetObserver(_a, _b) { + var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror; + var win = _b.win; ++ if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) { ++ return function () { }; ++ } + var insertRule = win.CSSStyleSheet.prototype.insertRule; + win.CSSStyleSheet.prototype.insertRule = function (rule, index) { + var id = mirror.getId(this.ownerNode); +@@ -3965,7 +4013,7 @@ var rrweb = (function (exports) { + var mirror = createMirror(); + function record(options) { + if (options === void 0) { options = {}; } +- var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.ignoreClass, ignoreClass = _c === void 0 ? 'rr-ignore' : _c, _d = options.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = options.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = options.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _g = options.sampling, sampling = _g === void 0 ? {} : _g, mousemoveWait = options.mousemoveWait, _h = options.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = options.userTriggeredOnInput, userTriggeredOnInput = _j === void 0 ? false : _j, _k = options.collectFonts, collectFonts = _k === void 0 ? false : _k, _l = options.inlineImages, inlineImages = _l === void 0 ? false : _l, plugins = options.plugins, _m = options.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m; ++ var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s; + if (!emit) { + throw new Error('emit function is required'); + } +@@ -4096,8 +4144,12 @@ var rrweb = (function (exports) { + bypassOptions: { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, +@@ -4126,8 +4178,12 @@ var rrweb = (function (exports) { + var _e = __read(snapshot(document, { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskAllInputs: maskInputOptions, + maskTextFn: maskTextFn, +@@ -4241,8 +4297,12 @@ var rrweb = (function (exports) { + }, + blockClass: blockClass, + ignoreClass: ignoreClass, ++ ignoreSelector: ignoreSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + inlineStylesheet: inlineStylesheet, + sampling: sampling, +@@ -4254,6 +4314,7 @@ var rrweb = (function (exports) { + maskInputFn: maskInputFn, + maskTextFn: maskTextFn, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + slimDOMOptions: slimDOMOptions, + mirror: mirror, + iframeManager: iframeManager, +@@ -4275,7 +4336,12 @@ var rrweb = (function (exports) { + }, hooks); + }; + iframeManager.addLoadListener(function (iframeEl) { +- handlers_1.push(observe_1(iframeEl.contentDocument)); ++ try { ++ handlers_1.push(observe_1(iframeEl.contentDocument)); ++ } ++ catch (error) { ++ console.warn(error); ++ } + }); + var init_1 = function () { + takeFullSnapshot(); +diff --git a/node_modules/rrweb/dist/rrweb.min.css b/node_modules/rrweb/dist/rrweb.min.css +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/rrweb.min.css.map b/node_modules/rrweb/dist/rrweb.min.css.map +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/dist/rrweb.min.js b/node_modules/rrweb/dist/rrweb.min.js +old mode 100644 +new mode 100755 +index e8e7c59..6c6597b +--- a/node_modules/rrweb/dist/rrweb.min.js ++++ b/node_modules/rrweb/dist/rrweb.min.js +@@ -12,7 +12,7 @@ var rrweb=function(e){"use strict"; + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. +- ***************************************************************************** */var t,n=function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}function a(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+l)+c+")";var u=t.split("/"),d=l.split("/");u.pop();for(var p=0,f=d;p=t.length);){var a=r(S);if(","===a.slice(-1))a=x(e,a.substring(0,a.length-1)),o.push(a);else{var i="";a=x(e,a);for(var s=!1;;){var l=t.charAt(n);if(""===l){o.push((a+i).trim());break}if(s)")"===l&&(s=!1);else{if(","===l){n+=1,o.push((a+i).trim());break}"("===l&&(s=!0)}i+=l,n+=1}}}return o.join(", ")}(e,r):"style"===n&&r?b(r,I()):"object"===t&&"data"===n&&r?x(e,r):r:x(e,r)}function T(e,t,n){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=0;r'):r.write('')),p=r),p.__sn=e,o[e.id]=p,(e.type===t.Document||e.type===t.Element)&&!s)for(var f=0,h=e.childNodes;ft?(r&&(clearTimeout(r),r=null),o=i,e.apply(l,c)):r||!1===n.trailing||(r=setTimeout((function(){o=!1===n.leading?0:Date.now(),r=null,e.apply(l,c)}),s))}}function K(e,t,n,r,o){void 0===o&&(o=window);var a=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set:function(e){var t=this;setTimeout((function(){n.set.call(t,e)}),0),a&&a.set&&a.set.call(this,e)}}),function(){return K(e,t,a||{},!0)}}function J(e,t,n){try{if(!(t in e))return function(){};var r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,function(){e[t]=r}}catch(e){return function(){}}}function Z(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function ee(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function te(e,t){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){var n=!1;if("string"==typeof t){if(void 0!==e.closest)return null!==e.closest("."+t);n=e.classList.contains(t)}else e.classList.forEach((function(e){t.test(e)&&(n=!0)}));return n||te(e.parentNode,t)}return e.nodeType,e.TEXT_NODE,te(e.parentNode,t)}function ne(e){return"__sn"in e&&-2===e.__sn.id}function re(e,t){if(s(e))return!1;var n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||re(e.parentNode,t))}function oe(e){return Boolean(e.changedTouches)}function ae(e){void 0===e&&(e=window),"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1})}e.mirror={map:{},getId:function(){return console.error(Q),-1},getNode:function(){return console.error(Q),null},removeNodeFromMap:function(){console.error(Q)},has:function(){return console.error(Q),!1},reset:function(){console.error(Q)}},"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(e.mirror=new Proxy(e.mirror,{get:function(e,t,n){return"map"===t&&console.error(Q),Reflect.get(e,t,n)}}));var ie=function(){function t(){this.reset()}return t.prototype.add=function(e){var t=this.indexes.get(e.parentId),n={id:e.node.id,mutation:e,children:[],texts:[],attributes:[]};t?(n.parent=t,t.children[n.id]=n):this.tree[n.id]=n,this.indexes.set(n.id,n)},t.prototype.remove=function(e,t){var n=this,r=this.indexes.get(e.parentId),o=this.indexes.get(e.id),a=function(e){n.removeIdSet.add(e);var r=t.getNode(e);null==r||r.childNodes.forEach((function(e){"__sn"in e&&a(e.__sn.id)}))},i=function(t){n.removeIdSet.add(t.id),Object.values(t.children).forEach((function(e){return i(e)}));var r=n.indexes.get(t.id);if(r){var o=r.parent;o&&(delete r.parent,delete o.children[r.id],n.indexes.delete(e.id))}};o?r?(delete o.parent,delete r.children[o.id],this.indexes.delete(e.id),i(o)):(delete this.tree[o.id],this.indexes.delete(o.id),i(o)):(this.removeNodeMutations.push(e),a(e.id))},t.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},t.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},t.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},t.prototype.input=function(e){this.inputMap.set(e.id,e)},t.prototype.flush=function(){var t,n,o,a,i=this,s=this,l=s.tree,c=s.removeNodeMutations,u=s.textMutations,d=s.attributeMutations,p={source:e.IncrementalSource.Mutation,removes:c,texts:u,attributes:d,adds:[]},f=function(e,t){t&&i.removeIdSet.add(e.id),p.texts=p.texts.concat(t?[]:e.texts).filter((function(e){return!i.removeIdSet.has(e.id)})),p.attributes=p.attributes.concat(t?[]:e.attributes).filter((function(e){return!i.removeIdSet.has(e.id)})),i.removeIdSet.has(e.id)||i.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return f(e,!0)})):(p.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return f(e,!1)})))};Object.values(l).forEach((function(e){return f(e,!1)}));try{for(var h=r(this.scrollMap.keys()),m=h.next();!m.done;m=h.next()){var v=m.value;this.removeIdSet.has(v)&&this.scrollMap.delete(v)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}try{for(var y=r(this.inputMap.keys()),g=y.next();!g.done;g=y.next()){v=g.value;this.removeIdSet.has(v)&&this.inputMap.delete(v)}}catch(e){o={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}var b=new Map(this.scrollMap),S=new Map(this.inputMap);return this.reset(),{mutationData:p,scrollMap:b,inputMap:S}},t.prototype.reset=function(){this.tree=[],this.indexes=new Map,this.removeNodeMutations=[],this.textMutations=[],this.attributeMutations=[],this.removeIdSet=new Set,this.scrollMap=new Map,this.inputMap=new Map},t.prototype.idRemoved=function(e){return this.removeIdSet.has(e)},t}();function se(e){var t,n,o={},a=function(e,t){var n={value:e,parent:t,children:[]};return o[e.node.id]=n,n},i=[];try{for(var s=r(e),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.nextId,d=c.parentId;if(u&&u in o){var p=o[u];if(p.parent){var f=p.parent.children.indexOf(p);p.parent.children.splice(f,0,a(c,p.parent))}else{f=i.indexOf(p);i.splice(f,0,a(c,null))}}else if(d in o){var h=o[d];h.children.push(a(c,h))}else i.push(a(c,null))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i}function le(e,t){t(e.value);for(var n=e.children.length-1;n>=0;n--)le(e.children[n],t)}function ce(e){return"__sn"in e&&(e.__sn.type===t.Element&&"iframe"===e.__sn.tagName)}function ue(e,t){var n,r,o=null===(r=null===(n=e.ownerDocument)||void 0===n?void 0:n.defaultView)||void 0===r?void 0:r.frameElement;if(!o||o===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};var a=o.getBoundingClientRect(),i=ue(o,t),s=a.height/o.clientHeight;return{x:a.x*i.relativeScale+i.x,y:a.y*i.relativeScale+i.y,relativeScale:s,absoluteScale:i.absoluteScale*s}}function de(e){return Boolean(null==e?void 0:e.shadowRoot)}var pe=Object.freeze({__proto__:null,on:X,createMirror:q,get _mirror(){return e.mirror},throttle:$,hookSetter:K,patch:J,getWindowHeight:Z,getWindowWidth:ee,isBlocked:te,isIgnored:ne,isAncestorRemoved:re,isTouchEvent:oe,polyfill:ae,TreeIndex:ie,queueToResolveTrees:se,iterateResolveTree:le,isIframeINode:ce,getBaseDimension:ue,hasShadowRoot:de});function fe(e){return"__ln"in e}var he=function(){function e(){this.length=0,this.head=null}return e.prototype.get=function(e){if(e>=this.length)throw new Error("Position outside of list range");for(var t=this.head,n=0;n=0;S--){var w=l.get(S);if(w){g=e.mirror.getId(w.value.parentNode),b=c(w.value);if(-1!==g&&-1!==b){y=w;break}}}if(!y){for(;l.head;)l.removeNode(l.head.value);break}v=y.previous,l.removeNode(y.value),u(y.value)}var x={texts:e.texts.map((function(t){return{id:e.mirror.getId(t.node),value:t.value}})).filter((function(t){return e.mirror.has(t.id)})),attributes:e.attributes.map((function(t){return{id:e.mirror.getId(t.node),attributes:t.attributes}})).filter((function(t){return e.mirror.has(t.id)})),removes:e.removes,adds:i};(x.texts.length||x.attributes.length||x.removes.length||x.adds.length)&&(e.texts=[],e.attributes=[],e.removes=[],e.addedSet=new Set,e.movedSet=new Set,e.droppedSet=new Set,e.movedMap={},e.mutationCb(x))}},this.processMutation=function(t){var n,o,a,i;if(!ne(t.target))switch(t.type){case"characterData":var c=t.target.textContent;te(t.target,e.blockClass)||c===t.oldValue||e.texts.push({value:T(t.target,e.maskTextClass,e.maskTextSelector)&&c?e.maskTextFn?e.maskTextFn(c):c.replace(/[\S]/g,"*"):c,node:t.target});break;case"attributes":var u=t.target;c=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(c=l({maskInputOptions:e.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:c,maskInputFn:e.maskInputFn})),te(t.target,e.blockClass)||c===t.oldValue)return;var d=e.attributes.find((function(e){return e.node===t.target}));if(d||(d={node:t.target,attributes:{}},e.attributes.push(d)),"style"===t.attributeName){var p=e.doc.createElement("span");t.oldValue&&p.setAttribute("style",t.oldValue),void 0!==d.attributes.style&&null!==d.attributes.style||(d.attributes.style={});var f=d.attributes.style;try{for(var h=r(Array.from(u.style)),m=h.next();!m.done;m=h.next()){var v=m.value,y=u.style.getPropertyValue(v),g=u.style.getPropertyPriority(v);y===p.style.getPropertyValue(v)&&g===p.style.getPropertyPriority(v)||(f[v]=""===g?y:[y,g])}}catch(e){n={error:e}}finally{try{m&&!m.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}try{for(var b=r(Array.from(p.style)),S=b.next();!S.done;S=b.next()){v=S.value;""===u.style.getPropertyValue(v)&&(f[v]=!1)}}catch(e){a={error:e}}finally{try{S&&!S.done&&(i=b.return)&&i.call(b)}finally{if(a)throw a.error}}}else d.attributes[t.attributeName]=E(e.doc,t.target.tagName,t.attributeName,c);break;case"childList":t.addedNodes.forEach((function(n){return e.genAdds(n,t.target)})),t.removedNodes.forEach((function(n){var r=e.mirror.getId(n),o=s(t.target)?e.mirror.getId(t.target.host):e.mirror.getId(t.target);te(t.target,e.blockClass)||ne(n)||(e.addedSet.has(n)?(ge(e.addedSet,n),e.droppedSet.add(n)):e.addedSet.has(t.target)&&-1===r||re(t.target,e.mirror)||(e.movedSet.has(n)&&e.movedMap[me(r,o)]?ge(e.movedSet,n):e.removes.push({parentId:o,id:r,isShadow:!!s(t.target)||void 0})),e.mapRemoves.push(n))}))}},this.genAdds=function(t,n){if(!n||!te(n,e.blockClass)){if(ve(t)){if(ne(t))return;e.movedSet.add(t);var r=null;n&&ve(n)&&(r=n.__sn.id),r&&(e.movedMap[me(t.__sn.id,r)]=!0)}else e.addedSet.add(t),e.droppedSet.delete(t);te(t,e.blockClass)||t.childNodes.forEach((function(t){return e.genAdds(t)}))}}}return e.prototype.init=function(e){var t=this;["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","recordCanvas","inlineImages","slimDOMOptions","doc","mirror","iframeManager","shadowDomManager","canvasManager"].forEach((function(n){t[n]=e[n]}))},e.prototype.freeze=function(){this.frozen=!0,this.canvasManager.freeze()},e.prototype.unfreeze=function(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()},e.prototype.isFrozen=function(){return this.frozen},e.prototype.lock=function(){this.locked=!0,this.canvasManager.lock()},e.prototype.unlock=function(){this.locked=!1,this.canvasManager.unlock(),this.emit()},e.prototype.reset=function(){this.shadowDomManager.reset(),this.canvasManager.reset()},e}();function ge(e,t){e.delete(t),t.childNodes.forEach((function(t){return ge(e,t)}))}function be(e,t,n){var r=t.parentNode;if(!r)return!1;var o=n.getId(r);return!!e.some((function(e){return e.id===o}))||be(e,r,n)}function Se(e,t){var n=t.parentNode;return!!n&&(!!e.has(n)||Se(e,n))}var we=[],xe="undefined"!=typeof CSSGroupingRule,Ie="undefined"!=typeof CSSMediaRule,Ee="undefined"!=typeof CSSSupportsRule,Te="undefined"!=typeof CSSConditionRule;function Ce(e){try{if("composedPath"in e){var t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function Me(e,t){var n,r,o=new ye;we.push(o),o.init(e);var a=window.MutationObserver||window.__rrMutationObserver,i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(a=window[i]);var s=new a(o.processMutations.bind(o));return s.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),s}function ke(t){var n=t.mouseInteractionCb,r=t.doc,o=t.mirror,a=t.blockClass,i=t.sampling;if(!1===i.mouseInteraction)return function(){};var s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,l=[];return Object.keys(e.MouseInteractions).filter((function(e){return Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]})).forEach((function(t){var i=t.toLowerCase(),s=function(t){return function(r){var i=Ce(r);if(!te(i,a)){var s=oe(r)?r.changedTouches[0]:r;if(s){var l=o.getId(i),c=s.clientX,u=s.clientY;n({type:e.MouseInteractions[t],id:l,x:c,y:u})}}}}(t);l.push(X(i,s,r))})),function(){l.forEach((function(e){return e()}))}}function Ne(e){var t=e.scrollCb,n=e.doc,r=e.mirror,o=e.blockClass;return X("scroll",$((function(e){var a=Ce(e);if(a&&!te(a,o)){var i=r.getId(a);if(a===n){var s=n.scrollingElement||n.documentElement;t({id:i,x:s.scrollLeft,y:s.scrollTop})}else t({id:i,x:a.scrollLeft,y:a.scrollTop})}}),e.sampling.scroll||100),n)}function Re(e,t){var r=n({},e);return t||delete r.userTriggered,r}var _e=["INPUT","TEXTAREA","SELECT"],Oe=new WeakMap;function De(e){return function(e,t){if(xe&&e.parentRule instanceof CSSGroupingRule||Ie&&e.parentRule instanceof CSSMediaRule||Ee&&e.parentRule instanceof CSSSupportsRule||Te&&e.parentRule instanceof CSSConditionRule){var n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else{n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function Ae(t,i){var s,c;void 0===i&&(i={});var u=t.doc.defaultView;if(!u)return function(){};!function(e,t){var n=e.mutationCb,r=e.mousemoveCb,i=e.mouseInteractionCb,s=e.scrollCb,l=e.viewportResizeCb,c=e.inputCb,u=e.mediaInteractionCb,d=e.styleSheetRuleCb,p=e.styleDeclarationCb,f=e.canvasMutationCb,h=e.fontCb;e.mutationCb=function(){for(var e=[],r=0;r>2],o+=Pe[(3&n[t])<<4|n[t+1]>>4],o+=Pe[(15&n[t+1])<<2|n[t+2]>>6],o+=Pe[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)}:e instanceof DataView?{rr_type:e.constructor.name,args:[Be(e.buffer,t,n),e.byteOffset,e.byteLength]}:e instanceof HTMLImageElement?{rr_type:e.constructor.name,src:e.src}:e instanceof ImageData?{rr_type:e.constructor.name,args:[Be(e.data,t,n),e.width,e.height]}:Ge(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Ue(e,t,n)}:e}var Ve=function(e,t,n){return a([],o(e),!1).map((function(e){return Be(e,t,n)}))},Ge=function(e,t){var n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((function(e){return"function"==typeof t[e]}));return Boolean(n.find((function(n){return e instanceof t[n]})))};function He(e,t,n,i,s,l){var c,u,d=[],p=Object.getOwnPropertyNames(e),f=function(r){try{if("function"!=typeof e[r])return"continue";var c=J(e,r,(function(c){return function(){for(var u=[],d=0;d=s,c=i&&t.timestamp-B.timestamp>i;(l||c)&&Xe(!0)}};var Y=function(t){Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Mutation},t)}))},q=function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Scroll},t)}))},Q=function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.CanvasMutation},t)}))},$=new Le({mutationCb:Y}),K=new qe({recordCanvas:O,mutationCb:Q,win:window,blockClass:c,mirror:$e}),J=new Fe({mutationCb:Y,scrollCb:q,bypassOptions:{blockClass:c,blockSelector:d,maskTextClass:m,maskTextSelector:y,inlineStylesheet:b,maskInputOptions:V,maskTextFn:E,maskInputFn:I,recordCanvas:O,inlineImages:W,sampling:N,slimDOMOptions:G,iframeManager:$,canvasManager:K},mirror:$e});Xe=function(t){var n,r,a,i;void 0===t&&(t=!1),Ye(Qe({type:e.EventType.Meta,data:{href:window.location.href,width:ee(),height:Z()}}),t),we.forEach((function(e){return e.lock()}));var s=o(function(e,t){var n=t||{},r=n.blockClass,o=void 0===r?"rr-block":r,a=n.blockSelector,i=void 0===a?null:a,s=n.maskTextClass,l=void 0===s?"rr-mask":s,c=n.maskTextSelector,u=void 0===c?null:c,d=n.inlineStylesheet,p=void 0===d||d,f=n.inlineImages,h=void 0!==f&&f,m=n.recordCanvas,v=void 0!==m&&m,y=n.maskAllInputs,g=void 0!==y&&y,b=n.maskTextFn,S=n.maskInputFn,w=n.slimDOM,x=void 0!==w&&w,I=n.dataURLOptions,E=n.preserveWhiteSpace,T=n.onSerialize,C=n.onIframeLoad,M=n.iframeLoadTimeout,N=n.keepIframeSrcFn,R={};return[k(e,{doc:e,map:R,blockClass:o,blockSelector:i,maskTextClass:l,maskTextSelector:u,skipChild:!1,inlineStylesheet:p,maskInputOptions:!0===g?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===g?{password:!0}:g,maskTextFn:b,maskInputFn:S,slimDOMOptions:!0===x||"all"===x?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===x,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===x?{}:x,dataURLOptions:I,inlineImages:h,recordCanvas:v,preserveWhiteSpace:E,onSerialize:T,onIframeLoad:C,iframeLoadTimeout:M,keepIframeSrcFn:void 0===N?function(){return!1}:N}),R]}(document,{blockClass:c,blockSelector:d,maskTextClass:m,maskTextSelector:y,inlineStylesheet:b,maskAllInputs:V,maskTextFn:E,slimDOM:G,recordCanvas:O,inlineImages:W,onSerialize:function(e){ce(e)&&$.addIframe(e),de(e)&&J.addShadowRoot(e.shadowRoot,document)},onIframeLoad:function(e,t){$.attachIframe(e,t),J.observeAttachShadow(e)},keepIframeSrcFn:U}),2),l=s[0],u=s[1];if(!l)return console.warn("Failed to snapshot the document");$e.map=u,Ye(Qe({type:e.EventType.FullSnapshot,data:{node:l,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(r=null===(n=null===document||void 0===document?void 0:document.body)||void 0===n?void 0:n.parentElement)||void 0===r?void 0:r.scrollLeft)||(null===document||void 0===document?void 0:document.body.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(i=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===i?void 0:i.scrollTop)||(null===document||void 0===document?void 0:document.body.scrollTop)||0}}})),we.forEach((function(e){return e.unlock()}))};try{var te=[];te.push(X("DOMContentLoaded",(function(){Ye(Qe({type:e.EventType.DomContentLoaded,data:{}}))})));var ne=function(t){var r;return Ae({mutationCb:Y,mousemoveCb:function(t,n){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:{source:n,positions:t}}))},mouseInteractionCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.MouseInteraction},t)}))},scrollCb:q,viewportResizeCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.ViewportResize},t)}))},inputCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Input},t)}))},mediaInteractionCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.MediaInteraction},t)}))},styleSheetRuleCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.StyleSheetRule},t)}))},styleDeclarationCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.StyleDeclaration},t)}))},canvasMutationCb:Q,fontCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Font},t)}))},blockClass:c,ignoreClass:f,maskTextClass:m,maskTextSelector:y,maskInputOptions:V,inlineStylesheet:b,sampling:N,recordCanvas:O,inlineImages:W,userTriggeredOnInput:A,collectFonts:F,doc:t,maskInputFn:I,maskTextFn:E,blockSelector:d,slimDOMOptions:G,mirror:$e,iframeManager:$,shadowDomManager:J,canvasManager:K,plugins:(null===(r=null==j?void 0:j.filter((function(e){return e.observer})))||void 0===r?void 0:r.map((function(t){return{observer:t.observer,options:t.options,callback:function(n){return Ye(Qe({type:e.EventType.Plugin,data:{plugin:t.name,payload:n}}))}}})))||[]},T)};$.addLoadListener((function(e){te.push(ne(e.contentDocument))}));var re=function(){Xe(),te.push(ne(document))};return"interactive"===document.readyState||"complete"===document.readyState?re():te.push(X("load",(function(){Ye(Qe({type:e.EventType.Load,data:{}})),re()}),window)),function(){te.forEach((function(e){return e()}))}}catch(e){console.warn(e)}}function Je(e){return e=e||Object.create(null),{on:function(t,n){(e[t]||(e[t]=[])).push(n)},off:function(t,n){e[t]&&e[t].splice(e[t].indexOf(n)>>>0,1)},emit:function(t,n){(e[t]||[]).slice().map((function(e){e(n)})),(e["*"]||[]).slice().map((function(e){e(t,n)}))}}}Ke.addCustomEvent=function(t,n){if(!Ye)throw new Error("please add custom event after start recording");Ye(Qe({type:e.EventType.Custom,data:{tag:t,payload:n}}))},Ke.freezePage=function(){we.forEach((function(e){return e.freeze()}))},Ke.takeFullSnapshot=function(e){if(!Xe)throw new Error("please take full snapshot after start recording");Xe(e)},Ke.mirror=$e;var Ze=Object.freeze({__proto__:null,default:Je});function et(e,t){if(void 0===e&&(e=window),void 0===t&&(t=document),!("scrollBehavior"in t.documentElement.style)||!0===e.__forceSmoothScrollPolyfill__){var n,r=e.HTMLElement||e.Element,o={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:r.prototype.scroll||s,scrollIntoView:r.prototype.scrollIntoView},a=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now,i=(n=e.navigator.userAgent,new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(n)?1:0);e.scroll=e.scrollTo=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?h.call(e,t.body,void 0!==arguments[0].left?~~arguments[0].left:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:e.scrollY||e.pageYOffset):o.scroll.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:e.scrollY||e.pageYOffset))},e.scrollBy=function(){void 0!==arguments[0]&&(l(arguments[0])?o.scrollBy.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:0,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:0):h.call(e,t.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset)))},r.prototype.scroll=r.prototype.scrollTo=function(){if(void 0!==arguments[0])if(!0!==l(arguments[0])){var e=arguments[0].left,t=arguments[0].top;h.call(this,this,void 0===e?this.scrollLeft:~~e,void 0===t?this.scrollTop:~~t)}else{if("number"==typeof arguments[0]&&void 0===arguments[1])throw new SyntaxError("Value could not be converted");o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left:"object"!=typeof arguments[0]?~~arguments[0]:this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top:void 0!==arguments[1]?~~arguments[1]:this.scrollTop)}},r.prototype.scrollBy=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior}):o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop))},r.prototype.scrollIntoView=function(){if(!0!==l(arguments[0])){var n=p(this),r=n.getBoundingClientRect(),a=this.getBoundingClientRect();n!==t.body?(h.call(this,n,n.scrollLeft+a.left-r.left,n.scrollTop+a.top-r.top),"fixed"!==e.getComputedStyle(n).position&&e.scrollBy({left:r.left,top:r.top,behavior:"smooth"})):e.scrollBy({left:a.left,top:a.top,behavior:"smooth"})}else o.scrollIntoView.call(this,void 0===arguments[0]||arguments[0])}}function s(e,t){this.scrollLeft=e,this.scrollTop=t}function l(e){if(null===e||"object"!=typeof e||void 0===e.behavior||"auto"===e.behavior||"instant"===e.behavior)return!0;if("object"==typeof e&&"smooth"===e.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+e.behavior+" is not a valid value for enumeration ScrollBehavior.")}function c(e,t){return"Y"===t?e.clientHeight+i1?1:s,n=.5*(1-Math.cos(Math.PI*i)),r=t.startX+(t.x-t.startX)*n,o=t.startY+(t.y-t.startY)*n,t.method.call(t.scrollable,r,o),r===t.x&&o===t.y||e.requestAnimationFrame(f.bind(e,t))}function h(n,r,i){var l,c,u,d,p=a();n===t.body?(l=e,c=e.scrollX||e.pageXOffset,u=e.scrollY||e.pageYOffset,d=o.scroll):(l=n,c=n.scrollLeft,u=n.scrollTop,d=s),f({scrollable:l,method:d,startTime:p,startX:c,startY:u,x:r,y:i})}}var tt,nt=function(){function e(e,t){void 0===e&&(e=[]),this.timeOffset=0,this.raf=null,this.actions=e,this.speed=t}return e.prototype.addAction=function(e){var t=this.findActionIndex(e);this.actions.splice(t,0,e)},e.prototype.addActions=function(e){this.actions=this.actions.concat(e)},e.prototype.start=function(){this.timeOffset=0;var e=performance.now(),t=this.actions,n=this;this.raf=requestAnimationFrame((function r(){var o=performance.now();for(n.timeOffset+=(o-e)*n.speed,e=o;t.length;){var a=t[0];if(!(n.timeOffset>=a.delay))break;t.shift(),a.doAction()}(t.length>0||n.liveMode)&&(n.raf=requestAnimationFrame(r))}))},e.prototype.clear=function(){this.raf&&(cancelAnimationFrame(this.raf),this.raf=null),this.actions.length=0},e.prototype.setSpeed=function(e){this.speed=e},e.prototype.toggleLiveMode=function(e){this.liveMode=e},e.prototype.isActive=function(){return null!==this.raf},e.prototype.findActionIndex=function(e){for(var t=0,n=this.actions.length-1;t<=n;){var r=Math.floor((t+n)/2);if(this.actions[r].delaye.delay))return r+1;n=r-1}}return t},e}();function rt(t,n){if(t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.MouseMove){var r=t.data.positions[0].timeOffset,o=t.timestamp+r;return t.delay=o-n,o-n}return t.delay=t.timestamp-n,t.delay} ++ ***************************************************************************** */var t,n=function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}function a(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+l)+c+")";var u=t.split("/"),d=l.split("/");u.pop();for(var p=0,f=d;p=t.length);){var a=r(b);if(","===a.slice(-1))a=I(e,a.substring(0,a.length-1)),o.push(a);else{var i="";a=I(e,a);for(var s=!1;;){var l=t.charAt(n);if(""===l){o.push((a+i).trim());break}if(s)")"===l&&(s=!1);else{if(","===l){n+=1,o.push((a+i).trim());break}"("===l&&(s=!0)}i+=l,n+=1}}}return o.join(", ")}(e,r):"style"===n&&r?S(r,x()):"object"===t&&"data"===n&&r?I(e,r):r:I(e,r)}function E(e,t,n,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if(r&&(e.matches(r)||e.closest(r)))return!1;if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=0;o'):r.write('')),p=r),p.__sn=e,o[e.id]=p,(e.type===t.Document||e.type===t.Element)&&!s)for(var f=0,h=e.childNodes;ft?(r&&(clearTimeout(r),r=null),o=i,e.apply(l,c)):r||!1===n.trailing||(r=setTimeout((function(){o=!1===n.leading?0:Date.now(),r=null,e.apply(l,c)}),s))}}function K(e,t,n,r,o){void 0===o&&(o=window);var a=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set:function(e){var t=this;setTimeout((function(){n.set.call(t,e)}),0),a&&a.set&&a.set.call(this,e)}}),function(){return K(e,t,a||{},!0)}}function J(e,t,n){try{if(!(t in e))return function(){};var r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,function(){e[t]=r}}catch(e){return function(){}}}function Z(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function ee(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function te(e,t){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){var n=!1;if("string"==typeof t){if(void 0!==e.closest)return null!==e.closest("."+t);n=e.classList.contains(t)}else e.classList.forEach((function(e){t.test(e)&&(n=!0)}));return n||te(e.parentNode,t)}return e.nodeType,e.TEXT_NODE,te(e.parentNode,t)}function ne(e){return"__sn"in e&&-2===e.__sn.id}function re(e,t){if(s(e))return!1;var n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||re(e.parentNode,t))}function oe(e){return Boolean(e.changedTouches)}function ae(e){void 0===e&&(e=window),"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1})}e.mirror={map:{},getId:function(){return console.error(Q),-1},getNode:function(){return console.error(Q),null},removeNodeFromMap:function(){console.error(Q)},has:function(){return console.error(Q),!1},reset:function(){console.error(Q)}},"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(e.mirror=new Proxy(e.mirror,{get:function(e,t,n){return"map"===t&&console.error(Q),Reflect.get(e,t,n)}}));var ie=function(){function t(){this.reset()}return t.prototype.add=function(e){var t=this.indexes.get(e.parentId),n={id:e.node.id,mutation:e,children:[],texts:[],attributes:[]};t?(n.parent=t,t.children[n.id]=n):this.tree[n.id]=n,this.indexes.set(n.id,n)},t.prototype.remove=function(e,t){var n=this,r=this.indexes.get(e.parentId),o=this.indexes.get(e.id),a=function(e){n.removeIdSet.add(e);var r=t.getNode(e);null==r||r.childNodes.forEach((function(e){"__sn"in e&&a(e.__sn.id)}))},i=function(t){n.removeIdSet.add(t.id),Object.values(t.children).forEach((function(e){return i(e)}));var r=n.indexes.get(t.id);if(r){var o=r.parent;o&&(delete r.parent,delete o.children[r.id],n.indexes.delete(e.id))}};o?r?(delete o.parent,delete r.children[o.id],this.indexes.delete(e.id),i(o)):(delete this.tree[o.id],this.indexes.delete(o.id),i(o)):(this.removeNodeMutations.push(e),a(e.id))},t.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},t.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},t.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},t.prototype.input=function(e){this.inputMap.set(e.id,e)},t.prototype.flush=function(){var t,n,o,a,i=this,s=this,l=s.tree,c=s.removeNodeMutations,u=s.textMutations,d=s.attributeMutations,p={source:e.IncrementalSource.Mutation,removes:c,texts:u,attributes:d,adds:[]},f=function(e,t){t&&i.removeIdSet.add(e.id),p.texts=p.texts.concat(t?[]:e.texts).filter((function(e){return!i.removeIdSet.has(e.id)})),p.attributes=p.attributes.concat(t?[]:e.attributes).filter((function(e){return!i.removeIdSet.has(e.id)})),i.removeIdSet.has(e.id)||i.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return f(e,!0)})):(p.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return f(e,!1)})))};Object.values(l).forEach((function(e){return f(e,!1)}));try{for(var h=r(this.scrollMap.keys()),m=h.next();!m.done;m=h.next()){var v=m.value;this.removeIdSet.has(v)&&this.scrollMap.delete(v)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}try{for(var y=r(this.inputMap.keys()),g=y.next();!g.done;g=y.next()){v=g.value;this.removeIdSet.has(v)&&this.inputMap.delete(v)}}catch(e){o={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}var S=new Map(this.scrollMap),b=new Map(this.inputMap);return this.reset(),{mutationData:p,scrollMap:S,inputMap:b}},t.prototype.reset=function(){this.tree=[],this.indexes=new Map,this.removeNodeMutations=[],this.textMutations=[],this.attributeMutations=[],this.removeIdSet=new Set,this.scrollMap=new Map,this.inputMap=new Map},t.prototype.idRemoved=function(e){return this.removeIdSet.has(e)},t}();function se(e){var t,n,o={},a=function(e,t){var n={value:e,parent:t,children:[]};return o[e.node.id]=n,n},i=[];try{for(var s=r(e),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.nextId,d=c.parentId;if(u&&u in o){var p=o[u];if(p.parent){var f=p.parent.children.indexOf(p);p.parent.children.splice(f,0,a(c,p.parent))}else{f=i.indexOf(p);i.splice(f,0,a(c,null))}}else if(d in o){var h=o[d];h.children.push(a(c,h))}else i.push(a(c,null))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i}function le(e,t){t(e.value);for(var n=e.children.length-1;n>=0;n--)le(e.children[n],t)}function ce(e){return"__sn"in e&&(e.__sn.type===t.Element&&"iframe"===e.__sn.tagName)}function ue(e,t){var n,r,o=null===(r=null===(n=e.ownerDocument)||void 0===n?void 0:n.defaultView)||void 0===r?void 0:r.frameElement;if(!o||o===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};var a=o.getBoundingClientRect(),i=ue(o,t),s=a.height/o.clientHeight;return{x:a.x*i.relativeScale+i.x,y:a.y*i.relativeScale+i.y,relativeScale:s,absoluteScale:i.absoluteScale*s}}function de(e){return Boolean(null==e?void 0:e.shadowRoot)}var pe=Object.freeze({__proto__:null,on:X,createMirror:q,get _mirror(){return e.mirror},throttle:$,hookSetter:K,patch:J,getWindowHeight:Z,getWindowWidth:ee,isBlocked:te,isIgnored:ne,isAncestorRemoved:re,isTouchEvent:oe,polyfill:ae,TreeIndex:ie,queueToResolveTrees:se,iterateResolveTree:le,isIframeINode:ce,getBaseDimension:ue,hasShadowRoot:de});function fe(e){return"__ln"in e}var he=function(){function e(){this.length=0,this.head=null}return e.prototype.get=function(e){if(e>=this.length)throw new Error("Position outside of list range");for(var t=this.head,n=0;n=0;b--){var w=l.get(b);if(w){g=e.mirror.getId(w.value.parentNode),S=c(w.value);if(-1!==g&&-1!==S){y=w;break}}}if(!y){for(;l.head;)l.removeNode(l.head.value);break}v=y.previous,l.removeNode(y.value),u(y.value)}var I={texts:e.texts.map((function(t){return{id:e.mirror.getId(t.node),value:t.value}})).filter((function(t){return e.mirror.has(t.id)})),attributes:e.attributes.map((function(t){return{id:e.mirror.getId(t.node),attributes:t.attributes}})).filter((function(t){return e.mirror.has(t.id)})),removes:e.removes,adds:i};(I.texts.length||I.attributes.length||I.removes.length||I.adds.length)&&(e.texts=[],e.attributes=[],e.removes=[],e.addedSet=new Set,e.movedSet=new Set,e.droppedSet=new Set,e.movedMap={},e.mutationCb(I))}},this.processMutation=function(t){var n,o,a,i;if(!ne(t.target))switch(t.type){case"characterData":var c=t.target.textContent;te(t.target,e.blockClass)||c===t.oldValue||e.texts.push({value:E(t.target,e.maskTextClass,e.maskTextSelector,e.unmaskTextSelector)&&c?e.maskTextFn?e.maskTextFn(c):c.replace(/[\S]/g,"*"):c,node:t.target});break;case"attributes":var u=t.target;c=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(c=l({input:u,maskInputSelector:e.maskInputSelector,unmaskInputSelector:e.unmaskInputSelector,maskInputOptions:e.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:c,maskInputFn:e.maskInputFn})),te(t.target,e.blockClass)||c===t.oldValue)return;var d=e.attributes.find((function(e){return e.node===t.target}));if(d||(d={node:t.target,attributes:{}},e.attributes.push(d)),"style"===t.attributeName){var p=e.doc.createElement("span");t.oldValue&&p.setAttribute("style",t.oldValue),void 0!==d.attributes.style&&null!==d.attributes.style||(d.attributes.style={});var f=d.attributes.style;try{for(var h=r(Array.from(u.style)),m=h.next();!m.done;m=h.next()){var v=m.value,y=u.style.getPropertyValue(v),g=u.style.getPropertyPriority(v);y===p.style.getPropertyValue(v)&&g===p.style.getPropertyPriority(v)||(f[v]=""===g?y:[y,g])}}catch(e){n={error:e}}finally{try{m&&!m.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}try{for(var S=r(Array.from(p.style)),b=S.next();!b.done;b=S.next()){v=b.value;""===u.style.getPropertyValue(v)&&(f[v]=!1)}}catch(e){a={error:e}}finally{try{b&&!b.done&&(i=S.return)&&i.call(S)}finally{if(a)throw a.error}}}else d.attributes[t.attributeName]=T(e.doc,t.target.tagName,t.attributeName,c);break;case"childList":t.addedNodes.forEach((function(n){return e.genAdds(n,t.target)})),t.removedNodes.forEach((function(n){var r=e.mirror.getId(n),o=s(t.target)?e.mirror.getId(t.target.host):e.mirror.getId(t.target);te(t.target,e.blockClass)||ne(n)||(e.addedSet.has(n)?(ge(e.addedSet,n),e.droppedSet.add(n)):e.addedSet.has(t.target)&&-1===r||re(t.target,e.mirror)||(e.movedSet.has(n)&&e.movedMap[me(r,o)]?ge(e.movedSet,n):e.removes.push({parentId:o,id:r,isShadow:!!s(t.target)||void 0})),e.mapRemoves.push(n))}))}},this.genAdds=function(t,n){if(!n||!te(n,e.blockClass)){if(ve(t)){if(ne(t))return;e.movedSet.add(t);var r=null;n&&ve(n)&&(r=n.__sn.id),r&&(e.movedMap[me(t.__sn.id,r)]=!0)}else e.addedSet.add(t),e.droppedSet.delete(t);te(t,e.blockClass)||t.childNodes.forEach((function(t){return e.genAdds(t)}))}}}return e.prototype.init=function(e){var t=this;["mutationCb","blockClass","blockSelector","unblockSelector","maskTextClass","maskTextSelector","unmaskTextSelector","maskInputSelector","unmaskInputSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","recordCanvas","inlineImages","slimDOMOptions","doc","mirror","iframeManager","shadowDomManager","canvasManager"].forEach((function(n){t[n]=e[n]}))},e.prototype.freeze=function(){this.frozen=!0,this.canvasManager.freeze()},e.prototype.unfreeze=function(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()},e.prototype.isFrozen=function(){return this.frozen},e.prototype.lock=function(){this.locked=!0,this.canvasManager.lock()},e.prototype.unlock=function(){this.locked=!1,this.canvasManager.unlock(),this.emit()},e.prototype.reset=function(){this.shadowDomManager.reset(),this.canvasManager.reset()},e}();function ge(e,t){e.delete(t),t.childNodes.forEach((function(t){return ge(e,t)}))}function Se(e,t,n){var r=t.parentNode;if(!r)return!1;var o=n.getId(r);return!!e.some((function(e){return e.id===o}))||Se(e,r,n)}function be(e,t){var n=t.parentNode;return!!n&&(!!e.has(n)||be(e,n))}var we=[],Ie="undefined"!=typeof CSSGroupingRule,xe="undefined"!=typeof CSSMediaRule,Te="undefined"!=typeof CSSSupportsRule,Ee="undefined"!=typeof CSSConditionRule;function ke(e){try{if("composedPath"in e){var t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function Ce(e,t){var n,r,o=new ye;we.push(o),o.init(e);var a=window.MutationObserver||window.__rrMutationObserver,i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(a=window[i]);var s=new a(o.processMutations.bind(o));return s.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),s}function Me(t){var n=t.mouseInteractionCb,r=t.doc,o=t.mirror,a=t.blockClass,i=t.sampling;if(!1===i.mouseInteraction)return function(){};var s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,l=[];return Object.keys(e.MouseInteractions).filter((function(e){return Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]})).forEach((function(t){var i=t.toLowerCase(),s=function(t){return function(r){var i=ke(r);if(!te(i,a)){var s=oe(r)?r.changedTouches[0]:r;if(s){var l=o.getId(i),c=s.clientX,u=s.clientY;n({type:e.MouseInteractions[t],id:l,x:c,y:u})}}}}(t);l.push(X(i,s,r))})),function(){l.forEach((function(e){return e()}))}}function Ne(e){var t=e.scrollCb,n=e.doc,r=e.mirror,o=e.blockClass;return X("scroll",$((function(e){var a=ke(e);if(a&&!te(a,o)){var i=r.getId(a);if(a===n){var s=n.scrollingElement||n.documentElement;t({id:i,x:s.scrollLeft,y:s.scrollTop})}else t({id:i,x:a.scrollLeft,y:a.scrollTop})}}),e.sampling.scroll||100),n)}function Re(e,t){var r=n({},e);return t||delete r.userTriggered,r}var _e=["INPUT","TEXTAREA","SELECT"],Oe=new WeakMap;function De(e){return function(e,t){if(Ie&&e.parentRule instanceof CSSGroupingRule||xe&&e.parentRule instanceof CSSMediaRule||Te&&e.parentRule instanceof CSSSupportsRule||Ee&&e.parentRule instanceof CSSConditionRule){var n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else{n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function Ae(t,i){var s,c;void 0===i&&(i={});var u=t.doc.defaultView;if(!u)return function(){};!function(e,t){var n=e.mutationCb,r=e.mousemoveCb,i=e.mouseInteractionCb,s=e.scrollCb,l=e.viewportResizeCb,c=e.inputCb,u=e.mediaInteractionCb,d=e.styleSheetRuleCb,p=e.styleDeclarationCb,f=e.canvasMutationCb,h=e.fontCb;e.mutationCb=function(){for(var e=[],r=0;r>2],o+=Pe[(3&n[t])<<4|n[t+1]>>4],o+=Pe[(15&n[t+1])<<2|n[t+2]>>6],o+=Pe[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)}:e instanceof DataView?{rr_type:e.constructor.name,args:[Be(e.buffer,t,n),e.byteOffset,e.byteLength]}:e instanceof HTMLImageElement?{rr_type:e.constructor.name,src:e.src}:e instanceof ImageData?{rr_type:e.constructor.name,args:[Be(e.data,t,n),e.width,e.height]}:Ge(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Ue(e,t,n)}:e}var Ve=function(e,t,n){return a([],o(e),!1).map((function(e){return Be(e,t,n)}))},Ge=function(e,t){var n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((function(e){return"function"==typeof t[e]}));return Boolean(n.find((function(n){return e instanceof t[n]})))};function He(e,t,n,i,s,l){var c,u,d=[],p=Object.getOwnPropertyNames(e),f=function(r){try{if("function"!=typeof e[r])return"continue";var c=J(e,r,(function(c){return function(){for(var u=[],d=0;d=s,c=i&&t.timestamp-te.timestamp>i;(l||c)&&Xe(!0)}};var ie=function(t){Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Mutation},t)}))},se=function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Scroll},t)}))},le=function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.CanvasMutation},t)}))},ue=new Le({mutationCb:ie}),pe=new qe({recordCanvas:B,mutationCb:le,win:window,blockClass:c,mirror:$e}),fe=new Fe({mutationCb:ie,scrollCb:se,bypassOptions:{blockClass:c,blockSelector:d,unblockSelector:f,maskTextClass:S,maskTextSelector:w,unmaskTextSelector:E,maskInputSelector:x,unmaskInputSelector:C,inlineStylesheet:R,maskInputOptions:ne,maskTextFn:L,maskInputFn:A,recordCanvas:B,inlineImages:Q,sampling:j,slimDOMOptions:re,iframeManager:ue,canvasManager:pe},mirror:$e});Xe=function(t){var n,r,a,i;void 0===t&&(t=!1),Ye(Qe({type:e.EventType.Meta,data:{href:window.location.href,width:ee(),height:Z()}}),t),we.forEach((function(e){return e.lock()}));var s=o(function(e,t){var n=t||{},r=n.blockClass,o=void 0===r?"rr-block":r,a=n.blockSelector,i=void 0===a?null:a,s=n.unblockSelector,l=void 0===s?null:s,c=n.maskTextClass,u=void 0===c?"rr-mask":c,d=n.maskTextSelector,p=void 0===d?null:d,f=n.unmaskTextSelector,h=void 0===f?null:f,m=n.inlineStylesheet,v=void 0===m||m,y=n.inlineImages,g=void 0!==y&&y,S=n.recordCanvas,b=void 0!==S&&S,w=n.maskInputSelector,I=void 0===w?null:w,x=n.unmaskInputSelector,T=void 0===x?null:x,E=n.maskAllInputs,k=void 0!==E&&E,C=n.maskTextFn,N=n.maskInputFn,R=n.slimDOM,_=void 0!==R&&R,O=n.dataURLOptions,D=n.preserveWhiteSpace,A=n.onSerialize,L=n.onIframeLoad,F=n.iframeLoadTimeout,P=n.keepIframeSrcFn,W={};return[M(e,{doc:e,map:W,blockClass:o,blockSelector:i,unblockSelector:l,maskTextClass:u,maskTextSelector:p,unmaskTextSelector:h,skipChild:!1,inlineStylesheet:v,maskInputSelector:I,unmaskInputSelector:T,maskInputOptions:!0===k?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===k?{password:!0}:k,maskTextFn:C,maskInputFn:N,slimDOMOptions:!0===_||"all"===_?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===_,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===_?{}:_,dataURLOptions:O,inlineImages:g,recordCanvas:b,preserveWhiteSpace:D,onSerialize:A,onIframeLoad:L,iframeLoadTimeout:F,keepIframeSrcFn:void 0===P?function(){return!1}:P}),W]}(document,{blockClass:c,blockSelector:d,unblockSelector:f,maskTextClass:S,maskTextSelector:w,unmaskTextSelector:E,maskInputSelector:x,unmaskInputSelector:C,inlineStylesheet:R,maskAllInputs:ne,maskTextFn:L,slimDOM:re,recordCanvas:B,inlineImages:Q,onSerialize:function(e){ce(e)&&ue.addIframe(e),de(e)&&fe.addShadowRoot(e.shadowRoot,document)},onIframeLoad:function(e,t){ue.attachIframe(e,t),fe.observeAttachShadow(e)},keepIframeSrcFn:J}),2),l=s[0],u=s[1];if(!l)return console.warn("Failed to snapshot the document");$e.map=u,Ye(Qe({type:e.EventType.FullSnapshot,data:{node:l,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(r=null===(n=null===document||void 0===document?void 0:document.body)||void 0===n?void 0:n.parentElement)||void 0===r?void 0:r.scrollLeft)||(null===document||void 0===document?void 0:document.body.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(i=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===i?void 0:i.scrollTop)||(null===document||void 0===document?void 0:document.body.scrollTop)||0}}})),we.forEach((function(e){return e.unlock()}))};try{var he=[];he.push(X("DOMContentLoaded",(function(){Ye(Qe({type:e.EventType.DomContentLoaded,data:{}}))})));var me=function(t){var r;return Ae({mutationCb:ie,mousemoveCb:function(t,n){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:{source:n,positions:t}}))},mouseInteractionCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.MouseInteraction},t)}))},scrollCb:se,viewportResizeCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.ViewportResize},t)}))},inputCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Input},t)}))},mediaInteractionCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.MediaInteraction},t)}))},styleSheetRuleCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.StyleSheetRule},t)}))},styleDeclarationCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.StyleDeclaration},t)}))},canvasMutationCb:le,fontCb:function(t){return Ye(Qe({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Font},t)}))},blockClass:c,ignoreClass:m,ignoreSelector:y,maskTextClass:S,maskTextSelector:w,unmaskTextSelector:E,maskInputSelector:x,unmaskInputSelector:C,maskInputOptions:ne,inlineStylesheet:R,sampling:j,recordCanvas:B,inlineImages:Q,userTriggeredOnInput:G,collectFonts:Y,doc:t,maskInputFn:A,maskTextFn:L,blockSelector:d,unblockSelector:f,slimDOMOptions:re,mirror:$e,iframeManager:ue,shadowDomManager:fe,canvasManager:pe,plugins:(null===(r=null==$?void 0:$.filter((function(e){return e.observer})))||void 0===r?void 0:r.map((function(t){return{observer:t.observer,options:t.options,callback:function(n){return Ye(Qe({type:e.EventType.Plugin,data:{plugin:t.name,payload:n}}))}}})))||[]},F)};ue.addLoadListener((function(e){try{he.push(me(e.contentDocument))}catch(e){console.warn(e)}}));var ve=function(){Xe(),he.push(me(document))};return"interactive"===document.readyState||"complete"===document.readyState?ve():he.push(X("load",(function(){Ye(Qe({type:e.EventType.Load,data:{}})),ve()}),window)),function(){he.forEach((function(e){return e()}))}}catch(e){console.warn(e)}}function Je(e){return e=e||Object.create(null),{on:function(t,n){(e[t]||(e[t]=[])).push(n)},off:function(t,n){e[t]&&e[t].splice(e[t].indexOf(n)>>>0,1)},emit:function(t,n){(e[t]||[]).slice().map((function(e){e(n)})),(e["*"]||[]).slice().map((function(e){e(t,n)}))}}}Ke.addCustomEvent=function(t,n){if(!Ye)throw new Error("please add custom event after start recording");Ye(Qe({type:e.EventType.Custom,data:{tag:t,payload:n}}))},Ke.freezePage=function(){we.forEach((function(e){return e.freeze()}))},Ke.takeFullSnapshot=function(e){if(!Xe)throw new Error("please take full snapshot after start recording");Xe(e)},Ke.mirror=$e;var Ze=Object.freeze({__proto__:null,default:Je});function et(e,t){if(void 0===e&&(e=window),void 0===t&&(t=document),!("scrollBehavior"in t.documentElement.style)||!0===e.__forceSmoothScrollPolyfill__){var n,r=e.HTMLElement||e.Element,o={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:r.prototype.scroll||s,scrollIntoView:r.prototype.scrollIntoView},a=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now,i=(n=e.navigator.userAgent,new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(n)?1:0);e.scroll=e.scrollTo=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?h.call(e,t.body,void 0!==arguments[0].left?~~arguments[0].left:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:e.scrollY||e.pageYOffset):o.scroll.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:e.scrollY||e.pageYOffset))},e.scrollBy=function(){void 0!==arguments[0]&&(l(arguments[0])?o.scrollBy.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:0,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:0):h.call(e,t.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset)))},r.prototype.scroll=r.prototype.scrollTo=function(){if(void 0!==arguments[0])if(!0!==l(arguments[0])){var e=arguments[0].left,t=arguments[0].top;h.call(this,this,void 0===e?this.scrollLeft:~~e,void 0===t?this.scrollTop:~~t)}else{if("number"==typeof arguments[0]&&void 0===arguments[1])throw new SyntaxError("Value could not be converted");o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left:"object"!=typeof arguments[0]?~~arguments[0]:this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top:void 0!==arguments[1]?~~arguments[1]:this.scrollTop)}},r.prototype.scrollBy=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior}):o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop))},r.prototype.scrollIntoView=function(){if(!0!==l(arguments[0])){var n=p(this),r=n.getBoundingClientRect(),a=this.getBoundingClientRect();n!==t.body?(h.call(this,n,n.scrollLeft+a.left-r.left,n.scrollTop+a.top-r.top),"fixed"!==e.getComputedStyle(n).position&&e.scrollBy({left:r.left,top:r.top,behavior:"smooth"})):e.scrollBy({left:a.left,top:a.top,behavior:"smooth"})}else o.scrollIntoView.call(this,void 0===arguments[0]||arguments[0])}}function s(e,t){this.scrollLeft=e,this.scrollTop=t}function l(e){if(null===e||"object"!=typeof e||void 0===e.behavior||"auto"===e.behavior||"instant"===e.behavior)return!0;if("object"==typeof e&&"smooth"===e.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+e.behavior+" is not a valid value for enumeration ScrollBehavior.")}function c(e,t){return"Y"===t?e.clientHeight+i1?1:s,n=.5*(1-Math.cos(Math.PI*i)),r=t.startX+(t.x-t.startX)*n,o=t.startY+(t.y-t.startY)*n,t.method.call(t.scrollable,r,o),r===t.x&&o===t.y||e.requestAnimationFrame(f.bind(e,t))}function h(n,r,i){var l,c,u,d,p=a();n===t.body?(l=e,c=e.scrollX||e.pageXOffset,u=e.scrollY||e.pageYOffset,d=o.scroll):(l=n,c=n.scrollLeft,u=n.scrollTop,d=s),f({scrollable:l,method:d,startTime:p,startX:c,startY:u,x:r,y:i})}}var tt,nt=function(){function e(e,t){void 0===e&&(e=[]),this.timeOffset=0,this.raf=null,this.actions=e,this.speed=t}return e.prototype.addAction=function(e){var t=this.findActionIndex(e);this.actions.splice(t,0,e)},e.prototype.addActions=function(e){this.actions=this.actions.concat(e)},e.prototype.start=function(){this.timeOffset=0;var e=performance.now(),t=this.actions,n=this;this.raf=requestAnimationFrame((function r(){var o=performance.now();for(n.timeOffset+=(o-e)*n.speed,e=o;t.length;){var a=t[0];if(!(n.timeOffset>=a.delay))break;t.shift(),a.doAction()}(t.length>0||n.liveMode)&&(n.raf=requestAnimationFrame(r))}))},e.prototype.clear=function(){this.raf&&(cancelAnimationFrame(this.raf),this.raf=null),this.actions.length=0},e.prototype.setSpeed=function(e){this.speed=e},e.prototype.toggleLiveMode=function(e){this.liveMode=e},e.prototype.isActive=function(){return null!==this.raf},e.prototype.findActionIndex=function(e){for(var t=0,n=this.actions.length-1;t<=n;){var r=Math.floor((t+n)/2);if(this.actions[r].delaye.delay))return r+1;n=r-1}}return t},e}();function rt(t,n){if(t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.MouseMove){var r=t.data.positions[0].timeOffset,o=t.timestamp+r;return t.delay=o-n,o-n}return t.delay=t.timestamp-n,t.delay} + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + +@@ -26,5 +26,5 @@ var rrweb=function(e){"use strict"; + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. +- ***************************************************************************** */function ot(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(tt||(tt={}));var at={type:"xstate.init"};function it(e){return void 0===e?[]:[].concat(e)}function st(e){return{type:"xstate.assign",assignment:e}}function lt(e,t){return"string"==typeof(e="string"==typeof e&&t&&t[e]?t[e]:e)?{type:e}:"function"==typeof e?{type:e.name,exec:e}:e}function ct(e){return function(t){return e===t}}function ut(e){return"string"==typeof e?{type:e}:e}function dt(e,t){return{value:e,context:t,actions:[],changed:!1,matches:ct(e)}}function pt(e,t,n){var r=t,o=!1;return[e.filter((function(e){if("xstate.assign"===e.type){o=!0;var t=Object.assign({},r);return"function"==typeof e.assignment?t=e.assignment(r,n):Object.keys(e.assignment).forEach((function(o){t[o]="function"==typeof e.assignment[o]?e.assignment[o](r,n):e.assignment[o]})),r=t,!1}return!0})),r,o]}function ft(e,t){void 0===t&&(t={});var n=ot(pt(it(e.states[e.initial].entry).map((function(e){return lt(e,t.actions)})),e.context,at),2),r=n[0],o=n[1],a={config:e,_options:t,initialState:{value:e.initial,actions:r,context:o,matches:ct(e.initial)},transition:function(t,n){var r,o,i="string"==typeof t?{value:t,context:e.context}:t,s=i.value,l=i.context,c=ut(n),u=e.states[s];if(u.on){var d=it(u.on[c.type]);try{for(var p=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(d),f=p.next();!f.done;f=p.next()){var h=f.value;if(void 0===h)return dt(s,l);var m="string"==typeof h?{target:h}:h,v=m.target,y=m.actions,g=void 0===y?[]:y,b=m.cond,S=void 0===b?function(){return!0}:b,w=void 0===v,x=null!=v?v:s,I=e.states[x];if(S(l,c)){var E=ot(pt((w?it(g):[].concat(u.exit,g,I.entry).filter((function(e){return e}))).map((function(e){return lt(e,a._options.actions)})),l,c),3),T=E[0],C=E[1],M=E[2],k=null!=v?v:s;return{value:k,context:C,actions:T,changed:v!==s||T.length>0||M,matches:ct(k)}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}}return dt(s,l)}};return a}var ht=function(e,t){return e.actions.forEach((function(n){var r=n.exec;return r&&r(e.context,t)}))};function mt(e){var t=e.initialState,n=tt.NotStarted,r=new Set,o={_machine:e,send:function(o){n===tt.Running&&(t=e.transition(t,o),ht(t,ut(o)),r.forEach((function(e){return e(t)})))},subscribe:function(e){return r.add(e),e(t),{unsubscribe:function(){return r.delete(e)}}},start:function(r){if(r){var a="object"==typeof r?r:{context:e.config.context,value:r};t={value:a.value,actions:[],context:a.context,matches:ct(a.value)}}return n=tt.Running,ht(t,at),o},stop:function(){return n=tt.Stopped,r.clear(),o},get state(){return t},get status(){return n}};return o}function vt(t,o){var a=o.getCastFn,i=o.applyEventsSynchronously,s=o.emitter;return mt(ft({id:"player",context:t,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:st({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:st((function(e,t){var r=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(r=t.payload.timeOffset),n(n({},e),{timeOffset:r,baselineTime:e.events[0].timestamp+r})})),play:function(t){var n,o,l,c,u,d=t.timer,p=t.events,f=t.baselineTime,h=t.lastPlayedEvent;d.clear();try{for(var m=r(p),v=m.next();!v.done;v=m.next()){rt(v.value,f)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(o=m.return)&&o.call(m)}finally{if(n)throw n.error}}var y=function(t,n){for(var r=t.length-1;r>=0;r--){var o=t[r];if(o.type===e.EventType.Meta&&o.timestamp<=n)return t.slice(r)}return t}(p,f),g=null==h?void 0:h.timestamp;(null==h?void 0:h.type)===e.EventType.IncrementalSnapshot&&h.data.source===e.IncrementalSource.MouseMove&&(g=h.timestamp+(null===(u=h.data.positions[0])||void 0===u?void 0:u.timeOffset)),f<(g||0)&&s.emit(e.ReplayerEvents.PlayBack);var b=new Array,S=new Array,w=function(e){if(g&&gi)try{null===(r=t.sheet)||void 0===r||r.deleteRule(Number(s))}catch(e){}i=c})),e.forEach((function(e,n){var r,o,a;try{(null===(o=null===(r=t.sheet)||void 0===r?void 0:r.cssRules[n])||void 0===o?void 0:o.cssText)!==e&&(null===(a=t.sheet)||void 0===a||a.insertRule(e,n))}catch(e){}}))}catch(e){}}(e.cssTexts,t);else if(e.type===yt.SetProperty){gt(n.cssRules,e.index).style.setProperty(e.property,e.value,e.priority)}else if(e.type===yt.RemoveProperty){gt(n.cssRules,e.index).style.removeProperty(e.property)}}))}!function(e){e[e.Insert=0]="Insert",e[e.Remove=1]="Remove",e[e.Snapshot=2]="Snapshot",e[e.SetProperty=3]="SetProperty",e[e.RemoveProperty=4]="RemoveProperty"}(yt||(yt={}));var wt=new Map;function xt(e,t){var n=wt.get(e);return n||(n=new Map,wt.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}var It=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Et(e,t){return function(n){if(n&&"object"==typeof n&&"rr_type"in n){if("index"in n){var r=n.rr_type,i=n.index;return xt(t,r)[i]}if("args"in n){var s=n.rr_type,l=n.args,c=window[s];return new(c.bind.apply(c,a([void 0],o(l.map(Et(e,t))),!1)))}if("base64"in n)return function(e){var t,n,r,o,a,i=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);var c=new ArrayBuffer(i),u=new Uint8Array(c);for(t=0;t>4,u[l++]=(15&r)<<4|o>>2,u[l++]=(3&o)<<6|63&a;return c}(n.base64);if("src"in n){var u=e.get(n.src);if(u)return u;var d=new Image;return d.src=n.src,e.set(n.src,d),d}}else if(Array.isArray(n))return n.map(Et(e,t));return n}}function Tt(e){var t=e.mutation,n=e.target,r=e.type,o=e.imageMap,a=e.errorHandler;try{var i=function(e,t){try{return t===P.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(e){return null}}(n,r);if(!i)return;if(t.setter)return void(i[t.property]=t.args[0]);var s=i[t.property],l=t.args.map(Et(o,i));!function(e,t){if(null==t?void 0:t.constructor){var n=t.constructor.name;if(It.includes(n)){var r=xt(e,n);r.includes(t)||r.push(t)}}}(i,s.apply(i,l))}catch(e){a(t,e)}}var Ct=Je||Ze,Mt="[replayer]",kt={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Nt(t){return t.type==e.EventType.IncrementalSnapshot&&(t.data.source==e.IncrementalSource.TouchMove||t.data.source==e.IncrementalSource.MouseInteraction&&t.data.type==e.MouseInteractions.TouchStart)}var Rt=function(){function i(t,n){var o=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=Ct(),this.legacy_missingNodeRetryMap={},this.cache=V(),this.imageMap=new Map,this.mirror={map:{},getId:function(e){return e&&e.__sn?e.__sn.id:-1},getNode:function(e){return this.map[e]||null},removeNodeFromMap:function(e){var t=this,n=e.__sn&&e.__sn.id;delete this.map[n],e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},has:function(e){return this.map.hasOwnProperty(e)},reset:function(){this.map={}}},this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(null==n?void 0:n.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");var a={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:kt};this.config=Object.assign({},a,n),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(e.ReplayerEvents.Resize,this.handleResize),this.setupDom(),this.treeIndex=new ie,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.virtualStyleRulesMap=new Map,this.emitter.on(e.ReplayerEvents.Flush,(function(){var e,t,n,a,i,s,l,c,u=o.treeIndex.flush(),d=u.scrollMap,p=u.inputMap,f=u.mutationData;o.fragmentParentMap.forEach((function(e,t){return o.restoreRealParent(t,e)}));try{for(var h=r(f.texts),m=h.next();!m.done;m=h.next()){var v=m.value;o.applyText(v,f)}}catch(t){e={error:t}}finally{try{m&&!m.done&&(t=h.return)&&t.call(h)}finally{if(e)throw e.error}}try{for(var y=r(o.virtualStyleRulesMap.keys()),g=y.next();!g.done;g=y.next()){var b=g.value;o.restoreNodeSheet(b)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(n)throw n.error}}o.fragmentParentMap.clear(),o.elementStateMap.clear(),o.virtualStyleRulesMap.clear();try{for(var S=r(d.values()),w=S.next();!w.done;w=S.next()){v=w.value;o.applyScroll(v,!0)}}catch(e){i={error:e}}finally{try{w&&!w.done&&(s=S.return)&&s.call(S)}finally{if(i)throw i.error}}try{for(var x=r(p.values()),I=x.next();!I.done;I=x.next()){v=I.value;o.applyInput(v)}}catch(e){l={error:e}}finally{try{I&&!I.done&&(c=x.return)&&c.call(x)}finally{if(l)throw l.error}}})),this.emitter.on(e.ReplayerEvents.PlayBack,(function(){o.firstFullSnapshot=null,o.mirror.reset()}));var i=new nt([],(null==n?void 0:n.speed)||a.speed);this.service=vt({events:t.map((function(e){return n&&n.unpackFn?n.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(t){o.emitter.emit(e.ReplayerEvents.StateChange,{player:t})})),this.speedService=mt(ft({id:"speed",context:{normalSpeed:-1,timer:i},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:function(e,t){"payload"in t&&e.timer.setSpeed(t.payload.speed)},recordSpeed:st({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(t){o.emitter.emit(e.ReplayerEvents.StateChange,{speed:t})}));var s=this.service.state.context.events.find((function(t){return t.type===e.EventType.Meta})),l=this.service.state.context.events.find((function(t){return t.type===e.EventType.FullSnapshot}));if(s){var c=s.data,u=c.width,d=c.height;setTimeout((function(){o.emitter.emit(e.ReplayerEvents.Resize,{width:u,height:d})}),0)}l&&setTimeout((function(){o.firstFullSnapshot||(o.firstFullSnapshot=l,o.rebuildFullSnapshot(l),o.iframe.contentWindow.scrollTo(l.data.initialOffset))}),1),this.service.state.context.events.find(Nt)&&this.mouse.classList.add("touch-device")}return Object.defineProperty(i.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),i.prototype.on=function(e,t){return this.emitter.on(e,t),this},i.prototype.off=function(e,t){return this.emitter.off(e,t),this},i.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(n){t.config[n]=e[n]})),this.config.skipInactive||this.backToNormal(),void 0!==e.speed&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),void 0!==e.mouseTail&&(!1===e.mouseTail?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"))},i.prototype.getMetaData=function(){var e=this.service.state.context.events[0],t=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:e.timestamp,endTime:t.timestamp,totalTime:t.timestamp-e.timestamp}},i.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},i.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},i.prototype.getMirror=function(){return this.mirror},i.prototype.play=function(t){var n;void 0===t&&(t=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}}),null===(n=this.iframe.contentDocument)||void 0===n||n.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Start)},i.prototype.pause=function(t){var n;void 0===t&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof t&&(this.play(t),this.service.send({type:"PAUSE"})),null===(n=this.iframe.contentDocument)||void 0===n||n.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Pause)},i.prototype.resume=function(t){void 0===t&&(t=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(e.ReplayerEvents.Resume)},i.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},i.prototype.addEvent=function(e){var t=this,n=this.config.unpackFn?this.config.unpackFn(e):e;Nt(n)&&this.mouse.classList.add("touch-device"),Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:n}})}))},i.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},i.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},i.prototype.resetCache=function(){this.cache=V()},i.prototype.setupDom=function(){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),!1!==this.config.mouseTail&&(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");var e=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&e.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",e.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(et(this.iframe.contentWindow,this.iframe.contentDocument),ae(this.iframe.contentWindow))},i.prototype.handleResize=function(e){var t,n;this.iframe.style.display="inherit";try{for(var o=r([this.mouseTail,this.iframe]),a=o.next();!a.done;a=o.next()){var i=a.value;i&&(i.setAttribute("width",String(e.width)),i.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},i.prototype.applyEventsSynchronously=function(t){var n,o;try{for(var a=r(t),i=a.next();!i.done;i=a.next()){var s=i.value;switch(s.type){case e.EventType.DomContentLoaded:case e.EventType.Load:case e.EventType.Custom:continue;case e.EventType.FullSnapshot:case e.EventType.Meta:case e.EventType.Plugin:break;case e.EventType.IncrementalSnapshot:switch(s.data.source){case e.IncrementalSource.MediaInteraction:continue}}this.getCastFn(s,!0)()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null,!0===this.touchActive?this.mouse.classList.add("touch-active"):!1===this.touchActive&&this.mouse.classList.remove("touch-active"),this.touchActive=null},i.prototype.getCastFn=function(t,n){var o,a=this;switch(void 0===n&&(n=!1),t.type){case e.EventType.DomContentLoaded:case e.EventType.Load:break;case e.EventType.Custom:o=function(){a.emitter.emit(e.ReplayerEvents.CustomEvent,t)};break;case e.EventType.Meta:o=function(){return a.emitter.emit(e.ReplayerEvents.Resize,{width:t.data.width,height:t.data.height})};break;case e.EventType.FullSnapshot:o=function(){if(a.firstFullSnapshot){if(a.firstFullSnapshot===t)return void(a.firstFullSnapshot=!0)}else a.firstFullSnapshot=!0;a.rebuildFullSnapshot(t,n),a.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case e.EventType.IncrementalSnapshot:o=function(){var o,i;if(a.applyIncremental(t,n),!n&&(t===a.nextUserInteractionEvent&&(a.nextUserInteractionEvent=null,a.backToNormal()),a.config.skipInactive&&!a.nextUserInteractionEvent)){try{for(var s=r(a.service.state.context.events),l=s.next();!l.done;l=s.next()){var c=l.value;if(!(c.timestamp<=t.timestamp)&&a.isUserInteraction(c)){c.delay-t.delay>1e4*a.speedService.state.context.timer.speed&&(a.nextUserInteractionEvent=c);break}}}catch(e){o={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}if(a.nextUserInteractionEvent){var u=a.nextUserInteractionEvent.delay-t.delay,d={speed:Math.min(Math.round(u/5e3),a.config.maxSpeed)};a.speedService.send({type:"FAST_FORWARD",payload:d}),a.emitter.emit(e.ReplayerEvents.SkipStart,d)}}}}return function(){var i,s;o&&o();try{for(var l=r(a.config.plugins||[]),c=l.next();!c.done;c=l.next()){c.value.handler(t,n,{replayer:a})}}catch(e){i={error:e}}finally{try{c&&!c.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}a.service.send({type:"CAST_EVENT",payload:{event:t}});var u=a.service.state.context.events.length-1;if(t===a.service.state.context.events[u]){var d=function(){u0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(e.ReplayerEvents.LoadStylesheetStart),o=setTimeout((function(){i.matches("playing")&&n.play(n.getCurrentTime()),o=-1,l()}),this.config.loadTimeout))}},i.prototype.hasImageArg=function(e){var t,n;try{for(var o=r(e),a=o.next();!a.done;a=o.next()){var i=a.value;if(i&&"object"==typeof i)if("rr_type"in i&&"args"in i){if(this.hasImageArg(i.args))return!0}else{if("rr_type"in i&&"HTMLImageElement"===i.rr_type)return!0;if(i instanceof Array&&this.hasImageArg(i))return!0}else;}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return!1},i.prototype.getImageArgs=function(e){var t,n,i=[];try{for(var s=r(e),l=s.next();!l.done;l=s.next()){var c=l.value;c&&"object"==typeof c&&("rr_type"in c&&"args"in c?i.push.apply(i,a([],o(this.getImageArgs(c.args)),!1)):"rr_type"in c&&"HTMLImageElement"===c.rr_type?i.push(c.src):c instanceof Array&&i.push.apply(i,a([],o(this.getImageArgs(c)),!1)))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},i.prototype.preloadAllImages=function(){var t,n,o=this;this.service.state;var a=function(){o.service.state};this.emitter.on(e.ReplayerEvents.Start,a),this.emitter.on(e.ReplayerEvents.Pause,a);var i=function(t){t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.CanvasMutation&&("commands"in t.data?t.data.commands.forEach((function(e){return o.preloadImages(e,t)})):s.preloadImages(t.data,t))},s=this;try{for(var l=r(this.service.state.context.events),c=l.next();!c.done;c=l.next()){i(c.value)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}},i.prototype.preloadImages=function(e,t){var n=this;if("drawImage"!==e.property||"string"!=typeof e.args[0]||this.imageMap.has(t))this.hasImageArg(e.args)&&this.getImageArgs(e.args).forEach((function(e){var t=new Image;t.src=e,n.imageMap.set(e,t)}));else{var r=document.createElement("canvas"),o=r.getContext("2d"),a=null==o?void 0:o.createImageData(r.width,r.height);null==a||a.data,JSON.parse(e.args[0]),null==o||o.putImageData(a,0,0)}},i.prototype.applyIncremental=function(t,r){var o,a,i=this,s=t.data;switch(s.source){case e.IncrementalSource.Mutation:r&&(s.adds.forEach((function(e){return i.treeIndex.add(e)})),s.texts.forEach((function(e){var t=i.mirror.getNode(e.id),n=null==t?void 0:t.parentNode;n&&i.virtualStyleRulesMap.has(n)&&i.virtualStyleRulesMap.delete(n),i.treeIndex.text(e)})),s.attributes.forEach((function(e){return i.treeIndex.attribute(e)})),s.removes.forEach((function(e){return i.treeIndex.remove(e,i.mirror)})));try{this.applyMutation(s,r)}catch(e){this.warn("Exception in mutation ".concat(e.message||e),s)}break;case e.IncrementalSource.Drag:case e.IncrementalSource.TouchMove:case e.IncrementalSource.MouseMove:if(r){var l=s.positions[s.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:s}}else s.positions.forEach((function(e){var n={doAction:function(){i.moveAndHover(e.x,e.y,e.id,r,s)},delay:e.timeOffset+t.timestamp-i.service.state.context.baselineTime};i.timer.addAction(n)})),this.timer.addAction({doAction:function(){},delay:t.delay-(null===(o=s.positions[0])||void 0===o?void 0:o.timeOffset)});break;case e.IncrementalSource.MouseInteraction:if(-1===s.id)break;var c=new Event(e.MouseInteractions[s.type].toLowerCase());if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);this.emitter.emit(e.ReplayerEvents.MouseInteraction,{type:s.type,target:S});var u=this.config.triggerFocus;switch(s.type){case e.MouseInteractions.Blur:"blur"in S&&S.blur();break;case e.MouseInteractions.Focus:u&&S.focus&&S.focus({preventScroll:!0});break;case e.MouseInteractions.Click:case e.MouseInteractions.TouchStart:case e.MouseInteractions.TouchEnd:r?(s.type===e.MouseInteractions.TouchStart?this.touchActive=!0:s.type===e.MouseInteractions.TouchEnd&&(this.touchActive=!1),this.mousePos={x:s.x,y:s.y,id:s.id,debugData:s}):(s.type===e.MouseInteractions.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(s.x,s.y,s.id,r,s),s.type===e.MouseInteractions.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):s.type===e.MouseInteractions.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):s.type===e.MouseInteractions.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case e.MouseInteractions.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:S.dispatchEvent(c)}break;case e.IncrementalSource.Scroll:if(-1===s.id)break;if(r){this.treeIndex.scroll(s);break}this.applyScroll(s,!1);break;case e.IncrementalSource.ViewportResize:this.emitter.emit(e.ReplayerEvents.Resize,{width:s.width,height:s.height});break;case e.IncrementalSource.Input:if(-1===s.id)break;if(r){this.treeIndex.input(s);break}this.applyInput(s);break;case e.IncrementalSource.MediaInteraction:if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);var d=S;try{s.currentTime&&(d.currentTime=s.currentTime),s.volume&&(d.volume=s.volume),s.muted&&(d.muted=s.muted),1===s.type&&d.pause(),0===s.type&&d.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: ".concat(e.message||e))}break;case e.IncrementalSource.StyleSheetRule:if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);var p,f=S,h=S.parentNode,m=this.fragmentParentMap.has(h),v=m?null:f.sheet;v||(this.virtualStyleRulesMap.has(S)?p=this.virtualStyleRulesMap.get(S):(p=[],this.virtualStyleRulesMap.set(S,p))),s.adds&&s.adds.forEach((function(e){var t=e.rule,n=e.index;if(v)try{if(Array.isArray(n)){var r=bt(n),o=r.positions,a=r.index;gt(v.cssRules,o).insertRule(t,a)}else{a=void 0===n?void 0:Math.min(n,v.cssRules.length);v.insertRule(t,a)}}catch(e){}else null==p||p.push({cssText:t,index:n,type:yt.Insert})})),s.removes&&s.removes.forEach((function(e){var t=e.index;if(m)null==p||p.push({index:t,type:yt.Remove});else try{if(Array.isArray(t)){var n=bt(t),r=n.positions,o=n.index;gt(v.cssRules,r).deleteRule(o||0)}else null==v||v.deleteRule(t)}catch(e){}}));break;case e.IncrementalSource.StyleDeclaration:if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);f=S;var y=S.parentNode,g=this.fragmentParentMap.has(y)?null:f.sheet,b=[];if(g||(this.virtualStyleRulesMap.has(S)?b=this.virtualStyleRulesMap.get(S):(b=[],this.virtualStyleRulesMap.set(S,b))),s.set)if(g)gt(g.rules,s.index).style.setProperty(s.set.property,s.set.value,s.set.priority);else b.push(n({type:yt.SetProperty,index:s.index},s.set));if(s.remove)if(g)gt(g.rules,s.index).style.removeProperty(s.remove.property);else b.push(n({type:yt.RemoveProperty,index:s.index},s.remove));break;case e.IncrementalSource.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var S;if(!(S=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);!function(e){var t=e.event,n=e.mutation,r=e.target,o=e.imageMap,a=e.errorHandler;try{var i="commands"in n?n.commands:[n];[P.WebGL,P.WebGL2].includes(n.type)?i.forEach((function(e){Tt({mutation:e,type:n.type,target:r,imageMap:o,errorHandler:a})})):i.forEach((function(e){!function(e){var t=e.event,n=e.mutation,r=e.target,o=e.imageMap,a=e.errorHandler;try{var i=r.getContext("2d");if(n.setter)return void(i[n.property]=n.args[0]);var s=i[n.property];if("drawImage"===n.property&&"string"==typeof n.args[0]){var l=o.get(t);n.args[0]=l,s.apply(i,n.args)}else s.apply(i,n.args)}catch(e){a(n,e)}}({event:t,mutation:e,target:r,imageMap:o,errorHandler:a})}))}catch(e){a(n,e)}}({event:t,mutation:s,target:S,imageMap:this.imageMap,errorHandler:this.warnCanvasMutationFailed.bind(this)});break;case e.IncrementalSource.Font:try{var w=new FontFace(s.family,s.buffer?new Uint8Array(JSON.parse(s.fontSource)):s.fontSource,s.descriptors);null===(a=this.iframe.contentDocument)||void 0===a||a.fonts.add(w)}catch(e){this.config.showWarning&&console.warn(e)}}},i.prototype.applyMutation=function(e,o){var a,i,s=this;e.removes.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n){if(e.removes.find((function(e){return e.id===t.parentId})))return;return s.warnNodeNotFound(e,t.id)}s.virtualStyleRulesMap.has(n)&&s.virtualStyleRulesMap.delete(n);var r=s.mirror.getNode(t.parentId);if(!r)return s.warnNodeNotFound(e,t.parentId);if(t.isShadow&&de(r)&&(r=r.shadowRoot),s.mirror.removeNodeFromMap(n),r){var o=null,a="__sn"in r?s.fragmentParentMap.get(r):void 0;a&&a.contains(n)?r=a:s.fragmentParentMap.has(n)&&(o=s.fragmentParentMap.get(n),s.fragmentParentMap.delete(n),n=o);try{r.removeChild(n)}catch(t){if(!(t instanceof DOMException))throw t;s.warn("parent could not remove child in mutation",r,a,n,o,e)}}}));var l=n({},this.legacy_missingNodeRetryMap),c=[],u=function(e){var n,a,i,u;if(!s.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var d=s.mirror.getNode(e.parentId);if(!d)return e.node.type===t.Document?s.newDocumentQueue.push(e):c.push(e);var p=null;s.iframe.contentDocument.contains?p=s.iframe.contentDocument.contains(d):s.iframe.contentDocument.body.contains&&(p=s.iframe.contentDocument.body.contains(d));var f=(null===(u=(i=d).getElementsByTagName)||void 0===u?void 0:u.call(i,"iframe").length)>0;if(o&&p&&!ce(d)&&!f){var h=document.createDocumentFragment();for(s.mirror.map[e.parentId]=h,s.fragmentParentMap.set(h,d),s.storeState(d);d.firstChild;)h.appendChild(d.firstChild);d=h}e.node.isShadow&&(de(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);var m=null,v=null;if(e.previousId&&(m=s.mirror.getNode(e.previousId)),e.nextId&&(v=s.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=s.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return c.push(e);if(!e.node.rootId||s.mirror.getNode(e.node.rootId)){var y=e.node.rootId?s.mirror.getNode(e.node.rootId):s.iframe.contentDocument;if(ce(d))s.attachDocumentToIframe(e,d);else{var g=H(e.node,{doc:y,map:s.mirror.map,skipChild:!0,hackCss:!0,cache:s.cache});if(-1!==e.previousId&&-1!==e.nextId){if("__sn"in d&&d.__sn.type===t.Element&&"textarea"===d.__sn.tagName&&e.node.type===t.Text)try{for(var b=r(Array.from(d.childNodes)),S=b.next();!S.done;S=b.next()){var w=S.value;w.nodeType===d.TEXT_NODE&&d.removeChild(w)}}catch(e){n={error:e}}finally{try{S&&!S.done&&(a=b.return)&&a.call(b)}finally{if(n)throw n.error}}if(m&&m.nextSibling&&m.nextSibling.parentNode)d.insertBefore(g,m.nextSibling);else if(v&&v.parentNode)d.contains(v)?d.insertBefore(g,v):d.insertBefore(g,null);else{if(d===y)for(;y.firstChild;)y.removeChild(y.firstChild);d.appendChild(g)}if(ce(g)){var x=s.newDocumentQueue.find((function(e){return e.parentId===g.__sn.id}));x&&(s.attachDocumentToIframe(x,g),s.newDocumentQueue=s.newDocumentQueue.filter((function(e){return e!==x})))}(e.previousId||e.nextId)&&s.legacy_resolveMissingNode(l,d,g,e)}else l[e.node.id]={node:g,mutation:e}}}};e.adds.forEach((function(e){u(e)}));for(var d=Date.now();c.length;){var p=se(c);if(c.length=0,Date.now()-d>500){this.warn("Timeout in the loop, please check the resolve tree data:",p);break}try{for(var f=(a=void 0,r(p)),h=f.next();!h.done;h=f.next()){var m=h.value;this.mirror.getNode(m.value.parentId)?le(m,(function(e){u(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",m)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(a)throw a.error}}}Object.keys(l).length&&Object.assign(this.legacy_missingNodeRetryMap,l),e.texts.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n){if(e.removes.find((function(e){return e.id===t.id})))return;return s.warnNodeNotFound(e,t.id)}s.fragmentParentMap.has(n)&&(n=s.fragmentParentMap.get(n)),n.textContent=t.value})),e.attributes.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n){if(e.removes.find((function(e){return e.id===t.id})))return;return s.warnNodeNotFound(e,t.id)}for(var r in s.fragmentParentMap.has(n)&&(n=s.fragmentParentMap.get(n)),t.attributes)if("string"==typeof r){var o=t.attributes[r];if(null===o)n.removeAttribute(r);else if("string"==typeof o)try{n.setAttribute(r,o)}catch(e){s.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}else if("style"===r){var a=o,i=n;for(var l in a)if(!1===a[l])i.style.removeProperty(l);else if(a[l]instanceof Array){var c=a[l];i.style.setProperty(l,c[0],c[1])}else{var u=a[l];i.style.setProperty(l,u)}}}}))},i.prototype.applyScroll=function(e,n){var r=this.mirror.getNode(e.id);if(!r)return this.debugNodeNotFound(e,e.id);if(r===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:n?"auto":"smooth"});else if(r.__sn.type===t.Document)r.defaultView.scrollTo({top:e.y,left:e.x,behavior:n?"auto":"smooth"});else try{r.scrollTop=e.y,r.scrollLeft=e.x}catch(e){}},i.prototype.applyInput=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);try{t.checked=e.isChecked,t.value=e.text}catch(e){}},i.prototype.applyText=function(e,t){var n=this.mirror.getNode(e.id);if(!n)return this.debugNodeNotFound(t,e.id);try{n.textContent=e.value}catch(e){}},i.prototype.legacy_resolveMissingNode=function(e,t,n,r){var o=r.previousId,a=r.nextId,i=o&&e[o],s=a&&e[a];if(i){var l=i,c=l.node,u=l.mutation;t.insertBefore(c,n),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}if(s){var d=s;c=d.node,u=d.mutation;t.insertBefore(c,n.nextSibling),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}},i.prototype.moveAndHover=function(e,t,n,r,o){var a=this.mirror.getNode(n);if(!a)return this.debugNodeNotFound(o,n);var i=ue(a,this.iframe),s=e*i.absoluteScale+i.x,l=t*i.absoluteScale+i.y;this.mouse.style.left="".concat(s,"px"),this.mouse.style.top="".concat(l,"px"),r||this.drawMouseTail({x:s,y:l}),this.hoverElements(a)},i.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var n=!0===this.config.mouseTail?kt:Object.assign({},kt,this.config.mouseTail),r=n.lineCap,o=n.lineWidth,a=n.strokeStyle,i=n.duration,s=function(){if(t.mouseTail){var e=t.mouseTail.getContext("2d");e&&t.tailPositions.length&&(e.clearRect(0,0,t.mouseTail.width,t.mouseTail.height),e.beginPath(),e.lineWidth=o,e.lineCap=r,e.strokeStyle=a,e.moveTo(t.tailPositions[0].x,t.tailPositions[0].y),t.tailPositions.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}};this.tailPositions.push(e),s(),setTimeout((function(){t.tailPositions=t.tailPositions.filter((function(t){return t!==e})),s()}),i/this.speedService.state.context.timer.speed)}},i.prototype.hoverElements=function(e){var t;null===(t=this.iframe.contentDocument)||void 0===t||t.querySelectorAll(".\\:hover").forEach((function(e){e.classList.remove(":hover")}));for(var n=e;n;)n.classList&&n.classList.add(":hover"),n=n.parentElement},i.prototype.isUserInteraction=function(t){return t.type===e.EventType.IncrementalSnapshot&&(t.data.source>e.IncrementalSource.Mutation&&t.data.source<=e.IncrementalSource.Input)},i.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(e.ReplayerEvents.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},i.prototype.restoreRealParent=function(e,n){this.mirror.map[n.__sn.id]=n,n.__sn.type===t.Element&&"textarea"===n.__sn.tagName&&e.textContent&&(n.value=e.textContent),n.appendChild(e),this.restoreState(n)},i.prototype.storeState=function(e){var t,n;if(e&&e.nodeType===e.ELEMENT_NODE){var o=e;(o.scrollLeft||o.scrollTop)&&this.elementStateMap.set(e,{scroll:[o.scrollLeft,o.scrollTop]}),"STYLE"===o.tagName&&function(e,t){var n;try{var r=Array.from((null===(n=e.sheet)||void 0===n?void 0:n.cssRules)||[]).map((function(e){return e.cssText}));t.set(e,[{type:yt.Snapshot,cssTexts:r}])}catch(e){}}(o,this.virtualStyleRulesMap);var a=o.children;try{for(var i=r(Array.from(a)),s=i.next();!s.done;s=i.next()){var l=s.value;this.storeState(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}},i.prototype.restoreState=function(e){var t,n;if(e.nodeType===e.ELEMENT_NODE){var o=e;if(this.elementStateMap.has(e)){var a=this.elementStateMap.get(e);a.scroll&&(o.scrollLeft=a.scroll[0],o.scrollTop=a.scroll[1]),this.elementStateMap.delete(e)}var i=o.children;try{for(var s=r(Array.from(i)),l=s.next();!l.done;l=s.next()){var c=l.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}}},i.prototype.restoreNodeSheet=function(e){var t=this.virtualStyleRulesMap.get(e);"STYLE"===e.nodeName&&(t&&St(t,e))},i.prototype.warnNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.warn("Node with id '".concat(t,"' was previously removed. "),e):this.warn("Node with id '".concat(t,"' not found. "),e)},i.prototype.warnCanvasMutationFailed=function(e,t){this.warn("Has error on canvas update",t,"canvas mutation:",e)},i.prototype.debugNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.debug(Mt,"Node with id '".concat(t,"' was previously removed. "),e):this.debug(Mt,"Node with id '".concat(t,"' not found. "),e)},i.prototype.warn=function(){for(var e=[],t=0;t0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(tt||(tt={}));var at={type:"xstate.init"};function it(e){return void 0===e?[]:[].concat(e)}function st(e){return{type:"xstate.assign",assignment:e}}function lt(e,t){return"string"==typeof(e="string"==typeof e&&t&&t[e]?t[e]:e)?{type:e}:"function"==typeof e?{type:e.name,exec:e}:e}function ct(e){return function(t){return e===t}}function ut(e){return"string"==typeof e?{type:e}:e}function dt(e,t){return{value:e,context:t,actions:[],changed:!1,matches:ct(e)}}function pt(e,t,n){var r=t,o=!1;return[e.filter((function(e){if("xstate.assign"===e.type){o=!0;var t=Object.assign({},r);return"function"==typeof e.assignment?t=e.assignment(r,n):Object.keys(e.assignment).forEach((function(o){t[o]="function"==typeof e.assignment[o]?e.assignment[o](r,n):e.assignment[o]})),r=t,!1}return!0})),r,o]}function ft(e,t){void 0===t&&(t={});var n=ot(pt(it(e.states[e.initial].entry).map((function(e){return lt(e,t.actions)})),e.context,at),2),r=n[0],o=n[1],a={config:e,_options:t,initialState:{value:e.initial,actions:r,context:o,matches:ct(e.initial)},transition:function(t,n){var r,o,i="string"==typeof t?{value:t,context:e.context}:t,s=i.value,l=i.context,c=ut(n),u=e.states[s];if(u.on){var d=it(u.on[c.type]);try{for(var p=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(d),f=p.next();!f.done;f=p.next()){var h=f.value;if(void 0===h)return dt(s,l);var m="string"==typeof h?{target:h}:h,v=m.target,y=m.actions,g=void 0===y?[]:y,S=m.cond,b=void 0===S?function(){return!0}:S,w=void 0===v,I=null!=v?v:s,x=e.states[I];if(b(l,c)){var T=ot(pt((w?it(g):[].concat(u.exit,g,x.entry).filter((function(e){return e}))).map((function(e){return lt(e,a._options.actions)})),l,c),3),E=T[0],k=T[1],C=T[2],M=null!=v?v:s;return{value:M,context:k,actions:E,changed:v!==s||E.length>0||C,matches:ct(M)}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}}return dt(s,l)}};return a}var ht=function(e,t){return e.actions.forEach((function(n){var r=n.exec;return r&&r(e.context,t)}))};function mt(e){var t=e.initialState,n=tt.NotStarted,r=new Set,o={_machine:e,send:function(o){n===tt.Running&&(t=e.transition(t,o),ht(t,ut(o)),r.forEach((function(e){return e(t)})))},subscribe:function(e){return r.add(e),e(t),{unsubscribe:function(){return r.delete(e)}}},start:function(r){if(r){var a="object"==typeof r?r:{context:e.config.context,value:r};t={value:a.value,actions:[],context:a.context,matches:ct(a.value)}}return n=tt.Running,ht(t,at),o},stop:function(){return n=tt.Stopped,r.clear(),o},get state(){return t},get status(){return n}};return o}function vt(t,o){var a=o.getCastFn,i=o.applyEventsSynchronously,s=o.emitter;return mt(ft({id:"player",context:t,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:st({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:st((function(e,t){var r=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(r=t.payload.timeOffset),n(n({},e),{timeOffset:r,baselineTime:e.events[0].timestamp+r})})),play:function(t){var n,o,l,c,u,d=t.timer,p=t.events,f=t.baselineTime,h=t.lastPlayedEvent;d.clear();try{for(var m=r(p),v=m.next();!v.done;v=m.next()){rt(v.value,f)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(o=m.return)&&o.call(m)}finally{if(n)throw n.error}}var y=function(t,n){for(var r=t.length-1;r>=0;r--){var o=t[r];if(o.type===e.EventType.Meta&&o.timestamp<=n)return t.slice(r)}return t}(p,f),g=null==h?void 0:h.timestamp;(null==h?void 0:h.type)===e.EventType.IncrementalSnapshot&&h.data.source===e.IncrementalSource.MouseMove&&(g=h.timestamp+(null===(u=h.data.positions[0])||void 0===u?void 0:u.timeOffset)),f<(g||0)&&s.emit(e.ReplayerEvents.PlayBack);var S=new Array,b=new Array,w=function(e){if(g&&gi)try{null===(r=t.sheet)||void 0===r||r.deleteRule(Number(s))}catch(e){}i=c})),e.forEach((function(e,n){var r,o,a;try{(null===(o=null===(r=t.sheet)||void 0===r?void 0:r.cssRules[n])||void 0===o?void 0:o.cssText)!==e&&(null===(a=t.sheet)||void 0===a||a.insertRule(e,n))}catch(e){}}))}catch(e){}}(e.cssTexts,t);else if(e.type===yt.SetProperty){gt(n.cssRules,e.index).style.setProperty(e.property,e.value,e.priority)}else if(e.type===yt.RemoveProperty){gt(n.cssRules,e.index).style.removeProperty(e.property)}}))}!function(e){e[e.Insert=0]="Insert",e[e.Remove=1]="Remove",e[e.Snapshot=2]="Snapshot",e[e.SetProperty=3]="SetProperty",e[e.RemoveProperty=4]="RemoveProperty"}(yt||(yt={}));var wt=new Map;function It(e,t){var n=wt.get(e);return n||(n=new Map,wt.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}var xt=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Tt(e,t){return function(n){if(n&&"object"==typeof n&&"rr_type"in n){if("index"in n){var r=n.rr_type,i=n.index;return It(t,r)[i]}if("args"in n){var s=n.rr_type,l=n.args,c=window[s];return new(c.bind.apply(c,a([void 0],o(l.map(Tt(e,t))),!1)))}if("base64"in n)return function(e){var t,n,r,o,a,i=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);var c=new ArrayBuffer(i),u=new Uint8Array(c);for(t=0;t>4,u[l++]=(15&r)<<4|o>>2,u[l++]=(3&o)<<6|63&a;return c}(n.base64);if("src"in n){var u=e.get(n.src);if(u)return u;var d=new Image;return d.src=n.src,e.set(n.src,d),d}}else if(Array.isArray(n))return n.map(Tt(e,t));return n}}function Et(e){var t=e.mutation,n=e.target,r=e.type,o=e.imageMap,a=e.errorHandler;try{var i=function(e,t){try{return t===P.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(e){return null}}(n,r);if(!i)return;if(t.setter)return void(i[t.property]=t.args[0]);var s=i[t.property],l=t.args.map(Tt(o,i));!function(e,t){if(null==t?void 0:t.constructor){var n=t.constructor.name;if(xt.includes(n)){var r=It(e,n);r.includes(t)||r.push(t)}}}(i,s.apply(i,l))}catch(e){a(t,e)}}var kt=Je||Ze,Ct="[replayer]",Mt={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Nt(t){return t.type==e.EventType.IncrementalSnapshot&&(t.data.source==e.IncrementalSource.TouchMove||t.data.source==e.IncrementalSource.MouseInteraction&&t.data.type==e.MouseInteractions.TouchStart)}var Rt=function(){function i(t,n){var o=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=kt(),this.legacy_missingNodeRetryMap={},this.cache=V(),this.imageMap=new Map,this.mirror={map:{},getId:function(e){return e&&e.__sn?e.__sn.id:-1},getNode:function(e){return this.map[e]||null},removeNodeFromMap:function(e){var t=this,n=e.__sn&&e.__sn.id;delete this.map[n],e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},has:function(e){return this.map.hasOwnProperty(e)},reset:function(){this.map={}}},this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(null==n?void 0:n.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");var a={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:Mt};this.config=Object.assign({},a,n),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(e.ReplayerEvents.Resize,this.handleResize),this.setupDom(),this.treeIndex=new ie,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.virtualStyleRulesMap=new Map,this.emitter.on(e.ReplayerEvents.Flush,(function(){var e,t,n,a,i,s,l,c,u=o.treeIndex.flush(),d=u.scrollMap,p=u.inputMap,f=u.mutationData;o.fragmentParentMap.forEach((function(e,t){return o.restoreRealParent(t,e)}));try{for(var h=r(f.texts),m=h.next();!m.done;m=h.next()){var v=m.value;o.applyText(v,f)}}catch(t){e={error:t}}finally{try{m&&!m.done&&(t=h.return)&&t.call(h)}finally{if(e)throw e.error}}try{for(var y=r(o.virtualStyleRulesMap.keys()),g=y.next();!g.done;g=y.next()){var S=g.value;o.restoreNodeSheet(S)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(n)throw n.error}}o.fragmentParentMap.clear(),o.elementStateMap.clear(),o.virtualStyleRulesMap.clear();try{for(var b=r(d.values()),w=b.next();!w.done;w=b.next()){v=w.value;o.applyScroll(v,!0)}}catch(e){i={error:e}}finally{try{w&&!w.done&&(s=b.return)&&s.call(b)}finally{if(i)throw i.error}}try{for(var I=r(p.values()),x=I.next();!x.done;x=I.next()){v=x.value;o.applyInput(v)}}catch(e){l={error:e}}finally{try{x&&!x.done&&(c=I.return)&&c.call(I)}finally{if(l)throw l.error}}})),this.emitter.on(e.ReplayerEvents.PlayBack,(function(){o.firstFullSnapshot=null,o.mirror.reset()}));var i=new nt([],(null==n?void 0:n.speed)||a.speed);this.service=vt({events:t.map((function(e){return n&&n.unpackFn?n.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(t){o.emitter.emit(e.ReplayerEvents.StateChange,{player:t})})),this.speedService=mt(ft({id:"speed",context:{normalSpeed:-1,timer:i},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:function(e,t){"payload"in t&&e.timer.setSpeed(t.payload.speed)},recordSpeed:st({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(t){o.emitter.emit(e.ReplayerEvents.StateChange,{speed:t})}));var s=this.service.state.context.events.find((function(t){return t.type===e.EventType.Meta})),l=this.service.state.context.events.find((function(t){return t.type===e.EventType.FullSnapshot}));if(s){var c=s.data,u=c.width,d=c.height;setTimeout((function(){o.emitter.emit(e.ReplayerEvents.Resize,{width:u,height:d})}),0)}l&&setTimeout((function(){o.firstFullSnapshot||(o.firstFullSnapshot=l,o.rebuildFullSnapshot(l),o.iframe.contentWindow.scrollTo(l.data.initialOffset))}),1),this.service.state.context.events.find(Nt)&&this.mouse.classList.add("touch-device")}return Object.defineProperty(i.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),i.prototype.on=function(e,t){return this.emitter.on(e,t),this},i.prototype.off=function(e,t){return this.emitter.off(e,t),this},i.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(n){t.config[n]=e[n]})),this.config.skipInactive||this.backToNormal(),void 0!==e.speed&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),void 0!==e.mouseTail&&(!1===e.mouseTail?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"))},i.prototype.getMetaData=function(){var e=this.service.state.context.events[0],t=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:e.timestamp,endTime:t.timestamp,totalTime:t.timestamp-e.timestamp}},i.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},i.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},i.prototype.getMirror=function(){return this.mirror},i.prototype.play=function(t){var n;void 0===t&&(t=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}}),null===(n=this.iframe.contentDocument)||void 0===n||n.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Start)},i.prototype.pause=function(t){var n;void 0===t&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof t&&(this.play(t),this.service.send({type:"PAUSE"})),null===(n=this.iframe.contentDocument)||void 0===n||n.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Pause)},i.prototype.resume=function(t){void 0===t&&(t=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(e.ReplayerEvents.Resume)},i.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},i.prototype.addEvent=function(e){var t=this,n=this.config.unpackFn?this.config.unpackFn(e):e;Nt(n)&&this.mouse.classList.add("touch-device"),Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:n}})}))},i.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},i.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},i.prototype.resetCache=function(){this.cache=V()},i.prototype.setupDom=function(){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),!1!==this.config.mouseTail&&(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");var e=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&e.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",e.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(et(this.iframe.contentWindow,this.iframe.contentDocument),ae(this.iframe.contentWindow))},i.prototype.handleResize=function(e){var t,n;this.iframe.style.display="inherit";try{for(var o=r([this.mouseTail,this.iframe]),a=o.next();!a.done;a=o.next()){var i=a.value;i&&(i.setAttribute("width",String(e.width)),i.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},i.prototype.applyEventsSynchronously=function(t){var n,o;try{for(var a=r(t),i=a.next();!i.done;i=a.next()){var s=i.value;switch(s.type){case e.EventType.DomContentLoaded:case e.EventType.Load:case e.EventType.Custom:continue;case e.EventType.FullSnapshot:case e.EventType.Meta:case e.EventType.Plugin:break;case e.EventType.IncrementalSnapshot:switch(s.data.source){case e.IncrementalSource.MediaInteraction:continue}}this.getCastFn(s,!0)()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null,!0===this.touchActive?this.mouse.classList.add("touch-active"):!1===this.touchActive&&this.mouse.classList.remove("touch-active"),this.touchActive=null},i.prototype.getCastFn=function(t,n){var o,a=this;switch(void 0===n&&(n=!1),t.type){case e.EventType.DomContentLoaded:case e.EventType.Load:break;case e.EventType.Custom:o=function(){a.emitter.emit(e.ReplayerEvents.CustomEvent,t)};break;case e.EventType.Meta:o=function(){return a.emitter.emit(e.ReplayerEvents.Resize,{width:t.data.width,height:t.data.height})};break;case e.EventType.FullSnapshot:o=function(){if(a.firstFullSnapshot){if(a.firstFullSnapshot===t)return void(a.firstFullSnapshot=!0)}else a.firstFullSnapshot=!0;a.rebuildFullSnapshot(t,n),a.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case e.EventType.IncrementalSnapshot:o=function(){var o,i;if(a.applyIncremental(t,n),!n&&(t===a.nextUserInteractionEvent&&(a.nextUserInteractionEvent=null,a.backToNormal()),a.config.skipInactive&&!a.nextUserInteractionEvent)){try{for(var s=r(a.service.state.context.events),l=s.next();!l.done;l=s.next()){var c=l.value;if(!(c.timestamp<=t.timestamp)&&a.isUserInteraction(c)){c.delay-t.delay>1e4*a.speedService.state.context.timer.speed&&(a.nextUserInteractionEvent=c);break}}}catch(e){o={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}if(a.nextUserInteractionEvent){var u=a.nextUserInteractionEvent.delay-t.delay,d={speed:Math.min(Math.round(u/5e3),a.config.maxSpeed)};a.speedService.send({type:"FAST_FORWARD",payload:d}),a.emitter.emit(e.ReplayerEvents.SkipStart,d)}}}}return function(){var i,s;o&&o();try{for(var l=r(a.config.plugins||[]),c=l.next();!c.done;c=l.next()){c.value.handler(t,n,{replayer:a})}}catch(e){i={error:e}}finally{try{c&&!c.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}a.service.send({type:"CAST_EVENT",payload:{event:t}});var u=a.service.state.context.events.length-1;if(t===a.service.state.context.events[u]){var d=function(){u0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(e.ReplayerEvents.LoadStylesheetStart),o=setTimeout((function(){i.matches("playing")&&n.play(n.getCurrentTime()),o=-1,l()}),this.config.loadTimeout))}},i.prototype.hasImageArg=function(e){var t,n;try{for(var o=r(e),a=o.next();!a.done;a=o.next()){var i=a.value;if(i&&"object"==typeof i)if("rr_type"in i&&"args"in i){if(this.hasImageArg(i.args))return!0}else{if("rr_type"in i&&"HTMLImageElement"===i.rr_type)return!0;if(i instanceof Array&&this.hasImageArg(i))return!0}else;}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return!1},i.prototype.getImageArgs=function(e){var t,n,i=[];try{for(var s=r(e),l=s.next();!l.done;l=s.next()){var c=l.value;c&&"object"==typeof c&&("rr_type"in c&&"args"in c?i.push.apply(i,a([],o(this.getImageArgs(c.args)),!1)):"rr_type"in c&&"HTMLImageElement"===c.rr_type?i.push(c.src):c instanceof Array&&i.push.apply(i,a([],o(this.getImageArgs(c)),!1)))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},i.prototype.preloadAllImages=function(){var t,n,o=this;this.service.state;var a=function(){o.service.state};this.emitter.on(e.ReplayerEvents.Start,a),this.emitter.on(e.ReplayerEvents.Pause,a);var i=function(t){t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.CanvasMutation&&("commands"in t.data?t.data.commands.forEach((function(e){return o.preloadImages(e,t)})):s.preloadImages(t.data,t))},s=this;try{for(var l=r(this.service.state.context.events),c=l.next();!c.done;c=l.next()){i(c.value)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}},i.prototype.preloadImages=function(e,t){var n=this;if("drawImage"!==e.property||"string"!=typeof e.args[0]||this.imageMap.has(t))this.hasImageArg(e.args)&&this.getImageArgs(e.args).forEach((function(e){var t=new Image;t.src=e,n.imageMap.set(e,t)}));else{var r=document.createElement("canvas"),o=r.getContext("2d"),a=null==o?void 0:o.createImageData(r.width,r.height);null==a||a.data,JSON.parse(e.args[0]),null==o||o.putImageData(a,0,0)}},i.prototype.applyIncremental=function(t,r){var o,a,i=this,s=t.data;switch(s.source){case e.IncrementalSource.Mutation:r&&(s.adds.forEach((function(e){return i.treeIndex.add(e)})),s.texts.forEach((function(e){var t=i.mirror.getNode(e.id),n=null==t?void 0:t.parentNode;n&&i.virtualStyleRulesMap.has(n)&&i.virtualStyleRulesMap.delete(n),i.treeIndex.text(e)})),s.attributes.forEach((function(e){return i.treeIndex.attribute(e)})),s.removes.forEach((function(e){return i.treeIndex.remove(e,i.mirror)})));try{this.applyMutation(s,r)}catch(e){this.warn("Exception in mutation ".concat(e.message||e),s)}break;case e.IncrementalSource.Drag:case e.IncrementalSource.TouchMove:case e.IncrementalSource.MouseMove:if(r){var l=s.positions[s.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:s}}else s.positions.forEach((function(e){var n={doAction:function(){i.moveAndHover(e.x,e.y,e.id,r,s)},delay:e.timeOffset+t.timestamp-i.service.state.context.baselineTime};i.timer.addAction(n)})),this.timer.addAction({doAction:function(){},delay:t.delay-(null===(o=s.positions[0])||void 0===o?void 0:o.timeOffset)});break;case e.IncrementalSource.MouseInteraction:if(-1===s.id)break;var c=new Event(e.MouseInteractions[s.type].toLowerCase());if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);this.emitter.emit(e.ReplayerEvents.MouseInteraction,{type:s.type,target:b});var u=this.config.triggerFocus;switch(s.type){case e.MouseInteractions.Blur:"blur"in b&&b.blur();break;case e.MouseInteractions.Focus:u&&b.focus&&b.focus({preventScroll:!0});break;case e.MouseInteractions.Click:case e.MouseInteractions.TouchStart:case e.MouseInteractions.TouchEnd:r?(s.type===e.MouseInteractions.TouchStart?this.touchActive=!0:s.type===e.MouseInteractions.TouchEnd&&(this.touchActive=!1),this.mousePos={x:s.x,y:s.y,id:s.id,debugData:s}):(s.type===e.MouseInteractions.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(s.x,s.y,s.id,r,s),s.type===e.MouseInteractions.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):s.type===e.MouseInteractions.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):s.type===e.MouseInteractions.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case e.MouseInteractions.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:b.dispatchEvent(c)}break;case e.IncrementalSource.Scroll:if(-1===s.id)break;if(r){this.treeIndex.scroll(s);break}this.applyScroll(s,!1);break;case e.IncrementalSource.ViewportResize:this.emitter.emit(e.ReplayerEvents.Resize,{width:s.width,height:s.height});break;case e.IncrementalSource.Input:if(-1===s.id)break;if(r){this.treeIndex.input(s);break}this.applyInput(s);break;case e.IncrementalSource.MediaInteraction:if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);var d=b;try{s.currentTime&&(d.currentTime=s.currentTime),s.volume&&(d.volume=s.volume),s.muted&&(d.muted=s.muted),1===s.type&&d.pause(),0===s.type&&d.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: ".concat(e.message||e))}break;case e.IncrementalSource.StyleSheetRule:if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);var p,f=b,h=b.parentNode,m=this.fragmentParentMap.has(h),v=m?null:f.sheet;v||(this.virtualStyleRulesMap.has(b)?p=this.virtualStyleRulesMap.get(b):(p=[],this.virtualStyleRulesMap.set(b,p))),s.adds&&s.adds.forEach((function(e){var t=e.rule,n=e.index;if(v)try{if(Array.isArray(n)){var r=St(n),o=r.positions,a=r.index;gt(v.cssRules,o).insertRule(t,a)}else{a=void 0===n?void 0:Math.min(n,v.cssRules.length);v.insertRule(t,a)}}catch(e){}else null==p||p.push({cssText:t,index:n,type:yt.Insert})})),s.removes&&s.removes.forEach((function(e){var t=e.index;if(m)null==p||p.push({index:t,type:yt.Remove});else try{if(Array.isArray(t)){var n=St(t),r=n.positions,o=n.index;gt(v.cssRules,r).deleteRule(o||0)}else null==v||v.deleteRule(t)}catch(e){}}));break;case e.IncrementalSource.StyleDeclaration:if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);f=b;var y=b.parentNode,g=this.fragmentParentMap.has(y)?null:f.sheet,S=[];if(g||(this.virtualStyleRulesMap.has(b)?S=this.virtualStyleRulesMap.get(b):(S=[],this.virtualStyleRulesMap.set(b,S))),s.set)if(g)gt(g.rules,s.index).style.setProperty(s.set.property,s.set.value,s.set.priority);else S.push(n({type:yt.SetProperty,index:s.index},s.set));if(s.remove)if(g)gt(g.rules,s.index).style.removeProperty(s.remove.property);else S.push(n({type:yt.RemoveProperty,index:s.index},s.remove));break;case e.IncrementalSource.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var b;if(!(b=this.mirror.getNode(s.id)))return this.debugNodeNotFound(s,s.id);!function(e){var t=e.event,n=e.mutation,r=e.target,o=e.imageMap,a=e.errorHandler;try{var i="commands"in n?n.commands:[n];[P.WebGL,P.WebGL2].includes(n.type)?i.forEach((function(e){Et({mutation:e,type:n.type,target:r,imageMap:o,errorHandler:a})})):i.forEach((function(e){!function(e){var t=e.event,n=e.mutation,r=e.target,o=e.imageMap,a=e.errorHandler;try{var i=r.getContext("2d");if(n.setter)return void(i[n.property]=n.args[0]);var s=i[n.property];if("drawImage"===n.property&&"string"==typeof n.args[0]){var l=o.get(t);n.args[0]=l,s.apply(i,n.args)}else s.apply(i,n.args)}catch(e){a(n,e)}}({event:t,mutation:e,target:r,imageMap:o,errorHandler:a})}))}catch(e){a(n,e)}}({event:t,mutation:s,target:b,imageMap:this.imageMap,errorHandler:this.warnCanvasMutationFailed.bind(this)});break;case e.IncrementalSource.Font:try{var w=new FontFace(s.family,s.buffer?new Uint8Array(JSON.parse(s.fontSource)):s.fontSource,s.descriptors);null===(a=this.iframe.contentDocument)||void 0===a||a.fonts.add(w)}catch(e){this.config.showWarning&&console.warn(e)}}},i.prototype.applyMutation=function(e,o){var a,i,s=this;e.removes.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n){if(e.removes.find((function(e){return e.id===t.parentId})))return;return s.warnNodeNotFound(e,t.id)}s.virtualStyleRulesMap.has(n)&&s.virtualStyleRulesMap.delete(n);var r=s.mirror.getNode(t.parentId);if(!r)return s.warnNodeNotFound(e,t.parentId);if(t.isShadow&&de(r)&&(r=r.shadowRoot),s.mirror.removeNodeFromMap(n),r){var o=null,a="__sn"in r?s.fragmentParentMap.get(r):void 0;a&&a.contains(n)?r=a:s.fragmentParentMap.has(n)&&(o=s.fragmentParentMap.get(n),s.fragmentParentMap.delete(n),n=o);try{r.removeChild(n)}catch(t){if(!(t instanceof DOMException))throw t;s.warn("parent could not remove child in mutation",r,a,n,o,e)}}}));var l=n({},this.legacy_missingNodeRetryMap),c=[],u=function(e){var n,a,i,u;if(!s.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var d=s.mirror.getNode(e.parentId);if(!d)return e.node.type===t.Document?s.newDocumentQueue.push(e):c.push(e);var p=null;s.iframe.contentDocument.contains?p=s.iframe.contentDocument.contains(d):s.iframe.contentDocument.body.contains&&(p=s.iframe.contentDocument.body.contains(d));var f=(null===(u=(i=d).getElementsByTagName)||void 0===u?void 0:u.call(i,"iframe").length)>0;if(o&&p&&!ce(d)&&!f){var h=document.createDocumentFragment();for(s.mirror.map[e.parentId]=h,s.fragmentParentMap.set(h,d),s.storeState(d);d.firstChild;)h.appendChild(d.firstChild);d=h}e.node.isShadow&&(de(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);var m=null,v=null;if(e.previousId&&(m=s.mirror.getNode(e.previousId)),e.nextId&&(v=s.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=s.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return c.push(e);if(!e.node.rootId||s.mirror.getNode(e.node.rootId)){var y=e.node.rootId?s.mirror.getNode(e.node.rootId):s.iframe.contentDocument;if(ce(d))s.attachDocumentToIframe(e,d);else{var g=H(e.node,{doc:y,map:s.mirror.map,skipChild:!0,hackCss:!0,cache:s.cache});if(-1!==e.previousId&&-1!==e.nextId){if("__sn"in d&&d.__sn.type===t.Element&&"textarea"===d.__sn.tagName&&e.node.type===t.Text)try{for(var S=r(Array.from(d.childNodes)),b=S.next();!b.done;b=S.next()){var w=b.value;w.nodeType===d.TEXT_NODE&&d.removeChild(w)}}catch(e){n={error:e}}finally{try{b&&!b.done&&(a=S.return)&&a.call(S)}finally{if(n)throw n.error}}if(m&&m.nextSibling&&m.nextSibling.parentNode)d.insertBefore(g,m.nextSibling);else if(v&&v.parentNode)d.contains(v)?d.insertBefore(g,v):d.insertBefore(g,null);else{if(d===y)for(;y.firstChild;)y.removeChild(y.firstChild);d.appendChild(g)}if(ce(g)){var I=s.newDocumentQueue.find((function(e){return e.parentId===g.__sn.id}));I&&(s.attachDocumentToIframe(I,g),s.newDocumentQueue=s.newDocumentQueue.filter((function(e){return e!==I})))}(e.previousId||e.nextId)&&s.legacy_resolveMissingNode(l,d,g,e)}else l[e.node.id]={node:g,mutation:e}}}};e.adds.forEach((function(e){u(e)}));for(var d=Date.now();c.length;){var p=se(c);if(c.length=0,Date.now()-d>500){this.warn("Timeout in the loop, please check the resolve tree data:",p);break}try{for(var f=(a=void 0,r(p)),h=f.next();!h.done;h=f.next()){var m=h.value;this.mirror.getNode(m.value.parentId)?le(m,(function(e){u(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",m)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(a)throw a.error}}}Object.keys(l).length&&Object.assign(this.legacy_missingNodeRetryMap,l),e.texts.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n){if(e.removes.find((function(e){return e.id===t.id})))return;return s.warnNodeNotFound(e,t.id)}s.fragmentParentMap.has(n)&&(n=s.fragmentParentMap.get(n)),n.textContent=t.value})),e.attributes.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n){if(e.removes.find((function(e){return e.id===t.id})))return;return s.warnNodeNotFound(e,t.id)}for(var r in s.fragmentParentMap.has(n)&&(n=s.fragmentParentMap.get(n)),t.attributes)if("string"==typeof r){var o=t.attributes[r];if(null===o)n.removeAttribute(r);else if("string"==typeof o)try{n.setAttribute(r,o)}catch(e){s.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}else if("style"===r){var a=o,i=n;for(var l in a)if(!1===a[l])i.style.removeProperty(l);else if(a[l]instanceof Array){var c=a[l];i.style.setProperty(l,c[0],c[1])}else{var u=a[l];i.style.setProperty(l,u)}}}}))},i.prototype.applyScroll=function(e,n){var r=this.mirror.getNode(e.id);if(!r)return this.debugNodeNotFound(e,e.id);if(r===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:n?"auto":"smooth"});else if(r.__sn.type===t.Document)r.defaultView.scrollTo({top:e.y,left:e.x,behavior:n?"auto":"smooth"});else try{r.scrollTop=e.y,r.scrollLeft=e.x}catch(e){}},i.prototype.applyInput=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);try{t.checked=e.isChecked,t.value=e.text}catch(e){}},i.prototype.applyText=function(e,t){var n=this.mirror.getNode(e.id);if(!n)return this.debugNodeNotFound(t,e.id);try{n.textContent=e.value}catch(e){}},i.prototype.legacy_resolveMissingNode=function(e,t,n,r){var o=r.previousId,a=r.nextId,i=o&&e[o],s=a&&e[a];if(i){var l=i,c=l.node,u=l.mutation;t.insertBefore(c,n),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}if(s){var d=s;c=d.node,u=d.mutation;t.insertBefore(c,n.nextSibling),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}},i.prototype.moveAndHover=function(e,t,n,r,o){var a=this.mirror.getNode(n);if(!a)return this.debugNodeNotFound(o,n);var i=ue(a,this.iframe),s=e*i.absoluteScale+i.x,l=t*i.absoluteScale+i.y;this.mouse.style.left="".concat(s,"px"),this.mouse.style.top="".concat(l,"px"),r||this.drawMouseTail({x:s,y:l}),this.hoverElements(a)},i.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var n=!0===this.config.mouseTail?Mt:Object.assign({},Mt,this.config.mouseTail),r=n.lineCap,o=n.lineWidth,a=n.strokeStyle,i=n.duration,s=function(){if(t.mouseTail){var e=t.mouseTail.getContext("2d");e&&t.tailPositions.length&&(e.clearRect(0,0,t.mouseTail.width,t.mouseTail.height),e.beginPath(),e.lineWidth=o,e.lineCap=r,e.strokeStyle=a,e.moveTo(t.tailPositions[0].x,t.tailPositions[0].y),t.tailPositions.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}};this.tailPositions.push(e),s(),setTimeout((function(){t.tailPositions=t.tailPositions.filter((function(t){return t!==e})),s()}),i/this.speedService.state.context.timer.speed)}},i.prototype.hoverElements=function(e){var t;null===(t=this.iframe.contentDocument)||void 0===t||t.querySelectorAll(".\\:hover").forEach((function(e){e.classList.remove(":hover")}));for(var n=e;n;)n.classList&&n.classList.add(":hover"),n=n.parentElement},i.prototype.isUserInteraction=function(t){return t.type===e.EventType.IncrementalSnapshot&&(t.data.source>e.IncrementalSource.Mutation&&t.data.source<=e.IncrementalSource.Input)},i.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(e.ReplayerEvents.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},i.prototype.restoreRealParent=function(e,n){this.mirror.map[n.__sn.id]=n,n.__sn.type===t.Element&&"textarea"===n.__sn.tagName&&e.textContent&&(n.value=e.textContent),n.appendChild(e),this.restoreState(n)},i.prototype.storeState=function(e){var t,n;if(e&&e.nodeType===e.ELEMENT_NODE){var o=e;(o.scrollLeft||o.scrollTop)&&this.elementStateMap.set(e,{scroll:[o.scrollLeft,o.scrollTop]}),"STYLE"===o.tagName&&function(e,t){var n;try{var r=Array.from((null===(n=e.sheet)||void 0===n?void 0:n.cssRules)||[]).map((function(e){return e.cssText}));t.set(e,[{type:yt.Snapshot,cssTexts:r}])}catch(e){}}(o,this.virtualStyleRulesMap);var a=o.children;try{for(var i=r(Array.from(a)),s=i.next();!s.done;s=i.next()){var l=s.value;this.storeState(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}},i.prototype.restoreState=function(e){var t,n;if(e.nodeType===e.ELEMENT_NODE){var o=e;if(this.elementStateMap.has(e)){var a=this.elementStateMap.get(e);a.scroll&&(o.scrollLeft=a.scroll[0],o.scrollTop=a.scroll[1]),this.elementStateMap.delete(e)}var i=o.children;try{for(var s=r(Array.from(i)),l=s.next();!l.done;l=s.next()){var c=l.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}}},i.prototype.restoreNodeSheet=function(e){var t=this.virtualStyleRulesMap.get(e);"STYLE"===e.nodeName&&(t&&bt(t,e))},i.prototype.warnNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.warn("Node with id '".concat(t,"' was previously removed. "),e):this.warn("Node with id '".concat(t,"' not found. "),e)},i.prototype.warnCanvasMutationFailed=function(e,t){this.warn("Has error on canvas update",t,"canvas mutation:",e)},i.prototype.debugNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.debug(Ct,"Node with id '".concat(t,"' was previously removed. "),e):this.debug(Ct,"Node with id '".concat(t,"' not found. "),e)},i.prototype.warn=function(){for(var e=[],t=0;t= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type]) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector) {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n ignoreClass?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n ignoreClass: string;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","import {\n INode,\n serializeNodeWithId,\n transformAttribute,\n IGNORED_NODE,\n isShadowRoot,\n needMaskingText,\n maskInputValue,\n} from 'rrweb-snapshot';\nimport {\n mutationRecord,\n textCursor,\n attributeCursor,\n removedNodeMutation,\n addedNodeMutation,\n Mirror,\n styleAttributeValue,\n observerParam,\n MutationBufferParam,\n Optional,\n} from '../types';\nimport {\n isBlocked,\n isAncestorRemoved,\n isIgnored,\n isIframeINode,\n hasShadowRoot,\n} from '../utils';\n\ntype DoubleLinkedListNode = {\n previous: DoubleLinkedListNode | null;\n next: DoubleLinkedListNode | null;\n value: NodeInLinkedList;\n};\ntype NodeInLinkedList = Node & {\n __ln: DoubleLinkedListNode;\n};\n\nfunction isNodeInLinkedList(n: Node | NodeInLinkedList): n is NodeInLinkedList {\n return '__ln' in n;\n}\nclass DoubleLinkedList {\n public length = 0;\n public head: DoubleLinkedListNode | null = null;\n\n public get(position: number) {\n if (position >= this.length) {\n throw new Error('Position outside of list range');\n }\n\n let current = this.head;\n for (let index = 0; index < position; index++) {\n current = current?.next || null;\n }\n return current;\n }\n\n public addNode(n: Node) {\n const node: DoubleLinkedListNode = {\n value: n as NodeInLinkedList,\n previous: null,\n next: null,\n };\n (n as NodeInLinkedList).__ln = node;\n if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {\n const current = n.previousSibling.__ln.next;\n node.next = current;\n node.previous = n.previousSibling.__ln;\n n.previousSibling.__ln.next = node;\n if (current) {\n current.previous = node;\n }\n } else if (\n n.nextSibling &&\n isNodeInLinkedList(n.nextSibling) &&\n n.nextSibling.__ln.previous\n ) {\n const current = n.nextSibling.__ln.previous;\n node.previous = current;\n node.next = n.nextSibling.__ln;\n n.nextSibling.__ln.previous = node;\n if (current) {\n current.next = node;\n }\n } else {\n if (this.head) {\n this.head.previous = node;\n }\n node.next = this.head;\n this.head = node;\n }\n this.length++;\n }\n\n public removeNode(n: NodeInLinkedList) {\n const current = n.__ln;\n if (!this.head) {\n return;\n }\n\n if (!current.previous) {\n this.head = current.next;\n if (this.head) {\n this.head.previous = null;\n }\n } else {\n current.previous.next = current.next;\n if (current.next) {\n current.next.previous = current.previous;\n }\n }\n if (n.__ln) {\n delete (n as Optional).__ln;\n }\n this.length--;\n }\n}\n\nconst moveKey = (id: number, parentId: number) => `${id}@${parentId}`;\nfunction isINode(n: Node | INode): n is INode {\n return '__sn' in n;\n}\n\n/**\n * controls behaviour of a MutationObserver\n */\nexport default class MutationBuffer {\n private frozen: boolean = false;\n private locked: boolean = false;\n\n private texts: textCursor[] = [];\n private attributes: attributeCursor[] = [];\n private removes: removedNodeMutation[] = [];\n private mapRemoves: Node[] = [];\n\n private movedMap: Record = {};\n\n /**\n * the browser MutationObserver emits multiple mutations after\n * a delay for performance reasons, making tracing added nodes hard\n * in our `processMutations` callback function.\n * For example, if we append an element el_1 into body, and then append\n * another element el_2 into el_1, these two mutations may be passed to the\n * callback function together when the two operations were done.\n * Generally we need to trace child nodes of newly added nodes, but in this\n * case if we count el_2 as el_1's child node in the first mutation record,\n * then we will count el_2 again in the second mutation record which was\n * duplicated.\n * To avoid of duplicate counting added nodes, we use a Set to store\n * added nodes and its child nodes during iterate mutation records. Then\n * collect added nodes from the Set which have no duplicate copy. But\n * this also causes newly added nodes will not be serialized with id ASAP,\n * which means all the id related calculation should be lazy too.\n */\n private addedSet = new Set();\n private movedSet = new Set();\n private droppedSet = new Set();\n\n private mutationCb: observerParam['mutationCb'];\n private blockClass: observerParam['blockClass'];\n private blockSelector: observerParam['blockSelector'];\n private maskTextClass: observerParam['maskTextClass'];\n private maskTextSelector: observerParam['maskTextSelector'];\n private inlineStylesheet: observerParam['inlineStylesheet'];\n private maskInputOptions: observerParam['maskInputOptions'];\n private maskTextFn: observerParam['maskTextFn'];\n private maskInputFn: observerParam['maskInputFn'];\n private recordCanvas: observerParam['recordCanvas'];\n private inlineImages: observerParam['inlineImages'];\n private slimDOMOptions: observerParam['slimDOMOptions'];\n private doc: observerParam['doc'];\n private mirror: observerParam['mirror'];\n private iframeManager: observerParam['iframeManager'];\n private shadowDomManager: observerParam['shadowDomManager'];\n private canvasManager: observerParam['canvasManager'];\n\n public init(options: MutationBufferParam) {\n ([\n 'mutationCb',\n 'blockClass',\n 'blockSelector',\n 'maskTextClass',\n 'maskTextSelector',\n 'inlineStylesheet',\n 'maskInputOptions',\n 'maskTextFn',\n 'maskInputFn',\n 'recordCanvas',\n 'inlineImages',\n 'slimDOMOptions',\n 'doc',\n 'mirror',\n 'iframeManager',\n 'shadowDomManager',\n 'canvasManager',\n ] as const).forEach((key) => {\n // just a type trick, the runtime result is correct\n this[key] = options[key] as never;\n });\n }\n\n public freeze() {\n this.frozen = true;\n this.canvasManager.freeze();\n }\n\n public unfreeze() {\n this.frozen = false;\n this.canvasManager.unfreeze();\n this.emit();\n }\n\n public isFrozen() {\n return this.frozen;\n }\n\n public lock() {\n this.locked = true;\n this.canvasManager.lock();\n }\n\n public unlock() {\n this.locked = false;\n this.canvasManager.unlock();\n this.emit();\n }\n\n public reset() {\n this.shadowDomManager.reset();\n this.canvasManager.reset();\n }\n\n public processMutations = (mutations: mutationRecord[]) => {\n mutations.forEach(this.processMutation); // adds mutations to the buffer\n this.emit(); // clears buffer if not locked/frozen\n };\n\n public emit = () => {\n if (this.frozen || this.locked) {\n return;\n }\n\n // delay any modification of the mirror until this function\n // so that the mirror for takeFullSnapshot doesn't get mutated while it's event is being processed\n\n const adds: addedNodeMutation[] = [];\n\n /**\n * Sometimes child node may be pushed before its newly added\n * parent, so we init a queue to store these nodes.\n */\n const addList = new DoubleLinkedList();\n const getNextId = (n: Node): number | null => {\n let ns: Node | null = n;\n let nextId: number | null = IGNORED_NODE; // slimDOM: ignored\n while (nextId === IGNORED_NODE) {\n ns = ns && ns.nextSibling;\n nextId = ns && this.mirror.getId((ns as unknown) as INode);\n }\n return nextId;\n };\n const pushAdd = (n: Node) => {\n const shadowHost: Element | null = n.getRootNode\n ? (n.getRootNode() as ShadowRoot)?.host\n : null;\n // If n is in a nested shadow dom.\n let rootShadowHost = shadowHost;\n while ((rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host)\n rootShadowHost =\n (rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host ||\n null;\n // ensure shadowHost is a Node, or doc.contains will throw an error\n const notInDoc =\n !this.doc.contains(n) &&\n (rootShadowHost === null || !this.doc.contains(rootShadowHost));\n if (!n.parentNode || notInDoc) {\n return;\n }\n const parentId = isShadowRoot(n.parentNode)\n ? this.mirror.getId((shadowHost as unknown) as INode)\n : this.mirror.getId((n.parentNode as Node) as INode);\n const nextId = getNextId(n);\n if (parentId === -1 || nextId === -1) {\n return addList.addNode(n);\n }\n let sn = serializeNodeWithId(n, {\n doc: this.doc,\n map: this.mirror.map,\n blockClass: this.blockClass,\n blockSelector: this.blockSelector,\n maskTextClass: this.maskTextClass,\n maskTextSelector: this.maskTextSelector,\n skipChild: true,\n inlineStylesheet: this.inlineStylesheet,\n maskInputOptions: this.maskInputOptions,\n maskTextFn: this.maskTextFn,\n maskInputFn: this.maskInputFn,\n slimDOMOptions: this.slimDOMOptions,\n recordCanvas: this.recordCanvas,\n inlineImages: this.inlineImages,\n onSerialize: (currentN) => {\n if (isIframeINode(currentN)) {\n this.iframeManager.addIframe(currentN);\n }\n if (hasShadowRoot(n)) {\n this.shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n this.iframeManager.attachIframe(iframe, childSn);\n this.shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n });\n if (sn) {\n adds.push({\n parentId,\n nextId,\n node: sn,\n });\n }\n };\n\n while (this.mapRemoves.length) {\n this.mirror.removeNodeFromMap(this.mapRemoves.shift() as INode);\n }\n\n for (const n of this.movedSet) {\n if (\n isParentRemoved(this.removes, n, this.mirror) &&\n !this.movedSet.has(n.parentNode!)\n ) {\n continue;\n }\n pushAdd(n);\n }\n\n for (const n of this.addedSet) {\n if (\n !isAncestorInSet(this.droppedSet, n) &&\n !isParentRemoved(this.removes, n, this.mirror)\n ) {\n pushAdd(n);\n } else if (isAncestorInSet(this.movedSet, n)) {\n pushAdd(n);\n } else {\n this.droppedSet.add(n);\n }\n }\n\n let candidate: DoubleLinkedListNode | null = null;\n while (addList.length) {\n let node: DoubleLinkedListNode | null = null;\n if (candidate) {\n const parentId = this.mirror.getId(\n (candidate.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(candidate.value);\n if (parentId !== -1 && nextId !== -1) {\n node = candidate;\n }\n }\n if (!node) {\n for (let index = addList.length - 1; index >= 0; index--) {\n const _node = addList.get(index)!;\n // ensure _node is defined before attempting to find value\n if (_node) {\n const parentId = this.mirror.getId(\n (_node.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(_node.value);\n if (parentId !== -1 && nextId !== -1) {\n node = _node;\n break;\n }\n }\n }\n }\n if (!node) {\n /**\n * If all nodes in queue could not find a serialized parent,\n * it may be a bug or corner case. We need to escape the\n * dead while loop at once.\n */\n while (addList.head) {\n addList.removeNode(addList.head.value);\n }\n break;\n }\n candidate = node.previous;\n addList.removeNode(node.value);\n pushAdd(node.value);\n }\n\n const payload = {\n texts: this.texts\n .map((text) => ({\n id: this.mirror.getId(text.node as INode),\n value: text.value,\n }))\n // text mutation's id was not in the mirror map means the target node has been removed\n .filter((text) => this.mirror.has(text.id)),\n attributes: this.attributes\n .map((attribute) => ({\n id: this.mirror.getId(attribute.node as INode),\n attributes: attribute.attributes,\n }))\n // attribute mutation's id was not in the mirror map means the target node has been removed\n .filter((attribute) => this.mirror.has(attribute.id)),\n removes: this.removes,\n adds,\n };\n // payload may be empty if the mutations happened in some blocked elements\n if (\n !payload.texts.length &&\n !payload.attributes.length &&\n !payload.removes.length &&\n !payload.adds.length\n ) {\n return;\n }\n\n // reset\n this.texts = [];\n this.attributes = [];\n this.removes = [];\n this.addedSet = new Set();\n this.movedSet = new Set();\n this.droppedSet = new Set();\n this.movedMap = {};\n\n this.mutationCb(payload);\n };\n\n private processMutation = (m: mutationRecord) => {\n if (isIgnored(m.target)) {\n return;\n }\n switch (m.type) {\n case 'characterData': {\n const value = m.target.textContent;\n if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {\n this.texts.push({\n value:\n needMaskingText(\n m.target,\n this.maskTextClass,\n this.maskTextSelector,\n ) && value\n ? this.maskTextFn\n ? this.maskTextFn(value)\n : value.replace(/[\\S]/g, '*')\n : value,\n node: m.target,\n });\n }\n break;\n }\n case 'attributes': {\n const target = m.target as HTMLElement;\n let value = (m.target as HTMLElement).getAttribute(m.attributeName!);\n if (m.attributeName === 'value') {\n value = maskInputValue({\n maskInputOptions: this.maskInputOptions,\n tagName: (m.target as HTMLElement).tagName,\n type: (m.target as HTMLElement).getAttribute('type'),\n value,\n maskInputFn: this.maskInputFn,\n });\n }\n if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {\n return;\n }\n let item: attributeCursor | undefined = this.attributes.find(\n (a) => a.node === m.target,\n );\n if (!item) {\n item = {\n node: m.target,\n attributes: {},\n };\n this.attributes.push(item);\n }\n if (m.attributeName === 'style') {\n const old = this.doc.createElement('span');\n if (m.oldValue) {\n old.setAttribute('style', m.oldValue);\n }\n if (\n item.attributes.style === undefined ||\n item.attributes.style === null\n ) {\n item.attributes.style = {};\n }\n const styleObj = item.attributes.style as styleAttributeValue;\n for (const pname of Array.from(target.style)) {\n const newValue = target.style.getPropertyValue(pname);\n const newPriority = target.style.getPropertyPriority(pname);\n if (\n newValue !== old.style.getPropertyValue(pname) ||\n newPriority !== old.style.getPropertyPriority(pname)\n ) {\n if (newPriority === '') {\n styleObj[pname] = newValue;\n } else {\n styleObj[pname] = [newValue, newPriority];\n }\n }\n }\n for (const pname of Array.from(old.style)) {\n if (target.style.getPropertyValue(pname) === '') {\n // \"if not set, returns the empty string\"\n styleObj[pname] = false; // delete\n }\n }\n } else {\n // overwrite attribute if the mutations was triggered in same time\n item.attributes[m.attributeName!] = transformAttribute(\n this.doc,\n (m.target as HTMLElement).tagName,\n m.attributeName!,\n value!,\n );\n }\n break;\n }\n case 'childList': {\n m.addedNodes.forEach((n) => this.genAdds(n, m.target));\n m.removedNodes.forEach((n) => {\n const nodeId = this.mirror.getId(n as INode);\n const parentId = isShadowRoot(m.target)\n ? this.mirror.getId((m.target.host as unknown) as INode)\n : this.mirror.getId(m.target as INode);\n if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {\n return;\n }\n // removed node has not been serialized yet, just remove it from the Set\n if (this.addedSet.has(n)) {\n deepDelete(this.addedSet, n);\n this.droppedSet.add(n);\n } else if (this.addedSet.has(m.target) && nodeId === -1) {\n /**\n * If target was newly added and removed child node was\n * not serialized, it means the child node has been removed\n * before callback fired, so we can ignore it because\n * newly added node will be serialized without child nodes.\n * TODO: verify this\n */\n } else if (isAncestorRemoved(m.target as INode, this.mirror)) {\n /**\n * If parent id was not in the mirror map any more, it\n * means the parent node has already been removed. So\n * the node is also removed which we do not need to track\n * and replay.\n */\n } else if (\n this.movedSet.has(n) &&\n this.movedMap[moveKey(nodeId, parentId)]\n ) {\n deepDelete(this.movedSet, n);\n } else {\n this.removes.push({\n parentId,\n id: nodeId,\n isShadow: isShadowRoot(m.target) ? true : undefined,\n });\n }\n this.mapRemoves.push(n);\n });\n break;\n }\n default:\n break;\n }\n };\n\n private genAdds = (n: Node | INode, target?: Node | INode) => {\n // parent was blocked, so we can ignore this node\n if (target && isBlocked(target, this.blockClass)) {\n return;\n }\n if (isINode(n)) {\n if (isIgnored(n)) {\n return;\n }\n this.movedSet.add(n);\n let targetId: number | null = null;\n if (target && isINode(target)) {\n targetId = target.__sn.id;\n }\n if (targetId) {\n this.movedMap[moveKey(n.__sn.id, targetId)] = true;\n }\n } else {\n this.addedSet.add(n);\n this.droppedSet.delete(n);\n }\n\n // if this node is blocked `serializeNode` will turn it into a placeholder element\n // but we have to remove it's children otherwise they will be added as placeholders too\n if (!isBlocked(n, this.blockClass))\n n.childNodes.forEach((childN) => this.genAdds(childN));\n };\n}\n\n/**\n * Some utils to handle the mutation observer DOM records.\n * It should be more clear to extend the native data structure\n * like Set and Map, but currently Typescript does not support\n * that.\n */\nfunction deepDelete(addsSet: Set, n: Node) {\n addsSet.delete(n);\n n.childNodes.forEach((childN) => deepDelete(addsSet, childN));\n}\n\nfunction isParentRemoved(\n removes: removedNodeMutation[],\n n: Node,\n mirror: Mirror,\n): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n const parentId = mirror.getId((parentNode as Node) as INode);\n if (removes.some((r) => r.id === parentId)) {\n return true;\n }\n return isParentRemoved(removes, parentNode, mirror);\n}\n\nfunction isAncestorInSet(set: Set, n: Node): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n if (set.has(parentNode)) {\n return true;\n }\n return isAncestorInSet(set, parentNode);\n}\n","import { INode, MaskInputOptions, maskInputValue } from 'rrweb-snapshot';\nimport { FontFaceSet } from 'css-font-loading-module';\nimport {\n throttle,\n on,\n hookSetter,\n getWindowHeight,\n getWindowWidth,\n isBlocked,\n isTouchEvent,\n patch,\n} from '../utils';\nimport {\n mutationCallBack,\n observerParam,\n mousemoveCallBack,\n mousePosition,\n mouseInteractionCallBack,\n MouseInteractions,\n listenerHandler,\n scrollCallback,\n styleSheetRuleCallback,\n viewportResizeCallback,\n inputValue,\n inputCallback,\n hookResetter,\n IncrementalSource,\n hooksParam,\n Arguments,\n mediaInteractionCallback,\n MediaInteractions,\n canvasMutationCallback,\n fontCallback,\n fontParam,\n styleDeclarationCallback,\n IWindow,\n MutationBufferParam,\n} from '../types';\nimport MutationBuffer from './mutation';\n\ntype WindowWithStoredMutationObserver = IWindow & {\n __rrMutationObserver?: MutationObserver;\n};\ntype WindowWithAngularZone = IWindow & {\n Zone?: {\n __symbol__?: (key: string) => string;\n };\n};\n\nexport const mutationBuffers: MutationBuffer[] = [];\n\nconst isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';\nconst isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';\nconst isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';\nconst isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';\n\n// Event.path is non-standard and used in some older browsers\ntype NonStandardEvent = Omit & {\n path: EventTarget[];\n};\n\nfunction getEventTarget(event: Event | NonStandardEvent): EventTarget | null {\n try {\n if ('composedPath' in event) {\n const path = event.composedPath();\n if (path.length) {\n return path[0];\n }\n } else if ('path' in event && event.path.length) {\n return event.path[0];\n }\n return event.target;\n } catch {\n return event.target;\n }\n}\n\nexport function initMutationObserver(\n options: MutationBufferParam,\n rootEl: Node,\n): MutationObserver {\n const mutationBuffer = new MutationBuffer();\n mutationBuffers.push(mutationBuffer);\n // see mutation.ts for details\n mutationBuffer.init(options);\n let mutationObserverCtor =\n window.MutationObserver ||\n /**\n * Some websites may disable MutationObserver by removing it from the window object.\n * If someone is using rrweb to build a browser extention or things like it, they\n * could not change the website's code but can have an opportunity to inject some\n * code before the website executing its JS logic.\n * Then they can do this to store the native MutationObserver:\n * window.__rrMutationObserver = MutationObserver\n */\n (window as WindowWithStoredMutationObserver).__rrMutationObserver;\n const angularZoneSymbol = (window as WindowWithAngularZone)?.Zone?.__symbol__?.(\n 'MutationObserver',\n );\n if (\n angularZoneSymbol &&\n ((window as unknown) as Record)[\n angularZoneSymbol\n ]\n ) {\n mutationObserverCtor = ((window as unknown) as Record<\n string,\n typeof MutationObserver\n >)[angularZoneSymbol];\n }\n const observer = new mutationObserverCtor(\n mutationBuffer.processMutations.bind(mutationBuffer),\n );\n observer.observe(rootEl, {\n attributes: true,\n attributeOldValue: true,\n characterData: true,\n characterDataOldValue: true,\n childList: true,\n subtree: true,\n });\n return observer;\n}\n\nfunction initMoveObserver({\n mousemoveCb,\n sampling,\n doc,\n mirror,\n}: observerParam): listenerHandler {\n if (sampling.mousemove === false) {\n return () => {};\n }\n\n const threshold =\n typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;\n const callbackThreshold =\n typeof sampling.mousemoveCallback === 'number'\n ? sampling.mousemoveCallback\n : 500;\n\n let positions: mousePosition[] = [];\n let timeBaseline: number | null;\n const wrappedCb = throttle(\n (\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n ) => {\n const totalOffset = Date.now() - timeBaseline!;\n mousemoveCb(\n positions.map((p) => {\n p.timeOffset -= totalOffset;\n return p;\n }),\n source,\n );\n positions = [];\n timeBaseline = null;\n },\n callbackThreshold,\n );\n const updatePosition = throttle(\n (evt) => {\n const target = getEventTarget(evt);\n const { clientX, clientY } = isTouchEvent(evt)\n ? evt.changedTouches[0]\n : evt;\n if (!timeBaseline) {\n timeBaseline = Date.now();\n }\n positions.push({\n x: clientX,\n y: clientY,\n id: mirror.getId(target as INode),\n timeOffset: Date.now() - timeBaseline,\n });\n // it is possible DragEvent is undefined even on devices\n // that support event 'drag'\n wrappedCb(\n typeof DragEvent !== 'undefined' && evt instanceof DragEvent\n ? IncrementalSource.Drag\n : evt instanceof MouseEvent\n ? IncrementalSource.MouseMove\n : IncrementalSource.TouchMove,\n );\n },\n threshold,\n {\n trailing: false,\n },\n );\n const handlers = [\n on('mousemove', updatePosition, doc),\n on('touchmove', updatePosition, doc),\n on('drag', updatePosition, doc),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initMouseInteractionObserver({\n mouseInteractionCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: observerParam): listenerHandler {\n if (sampling.mouseInteraction === false) {\n return () => {};\n }\n const disableMap: Record =\n sampling.mouseInteraction === true ||\n sampling.mouseInteraction === undefined\n ? {}\n : sampling.mouseInteraction;\n\n const handlers: listenerHandler[] = [];\n const getHandler = (eventKey: keyof typeof MouseInteractions) => {\n return (event: MouseEvent | TouchEvent) => {\n const target = getEventTarget(event) as Node;\n if (isBlocked(target as Node, blockClass)) {\n return;\n }\n const e = isTouchEvent(event) ? event.changedTouches[0] : event;\n if (!e) {\n return;\n }\n const id = mirror.getId(target as INode);\n const { clientX, clientY } = e;\n mouseInteractionCb({\n type: MouseInteractions[eventKey],\n id,\n x: clientX,\n y: clientY,\n });\n };\n };\n Object.keys(MouseInteractions)\n .filter(\n (key) =>\n Number.isNaN(Number(key)) &&\n !key.endsWith('_Departed') &&\n disableMap[key] !== false,\n )\n .forEach((eventKey: keyof typeof MouseInteractions) => {\n const eventName = eventKey.toLowerCase();\n const handler = getHandler(eventKey);\n handlers.push(on(eventName, handler, doc));\n });\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nexport function initScrollObserver({\n scrollCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: Pick<\n observerParam,\n 'scrollCb' | 'doc' | 'mirror' | 'blockClass' | 'sampling'\n>): listenerHandler {\n const updatePosition = throttle((evt) => {\n const target = getEventTarget(evt);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const id = mirror.getId(target as INode);\n if (target === doc) {\n const scrollEl = (doc.scrollingElement || doc.documentElement)!;\n scrollCb({\n id,\n x: scrollEl.scrollLeft,\n y: scrollEl.scrollTop,\n });\n } else {\n scrollCb({\n id,\n x: (target as HTMLElement).scrollLeft,\n y: (target as HTMLElement).scrollTop,\n });\n }\n }, sampling.scroll || 100);\n return on('scroll', updatePosition, doc);\n}\n\nfunction initViewportResizeObserver({\n viewportResizeCb,\n}: observerParam): listenerHandler {\n let lastH = -1;\n let lastW = -1;\n const updateDimension = throttle(() => {\n const height = getWindowHeight();\n const width = getWindowWidth();\n if (lastH !== height || lastW !== width) {\n viewportResizeCb({\n width: Number(width),\n height: Number(height),\n });\n lastH = height;\n lastW = width;\n }\n }, 200);\n return on('resize', updateDimension, window);\n}\n\nfunction wrapEventWithUserTriggeredFlag(\n v: inputValue,\n enable: boolean,\n): inputValue {\n const value = { ...v };\n if (!enable) delete value.userTriggered;\n return value;\n}\n\nexport const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];\nconst lastInputValueMap: WeakMap = new WeakMap();\nfunction initInputObserver({\n inputCb,\n doc,\n mirror,\n blockClass,\n ignoreClass,\n maskInputOptions,\n maskInputFn,\n sampling,\n userTriggeredOnInput,\n}: observerParam): listenerHandler {\n function eventHandler(event: Event) {\n let target = getEventTarget(event);\n const userTriggered = event.isTrusted;\n /**\n * If a site changes the value 'selected' of an option element, the value of its parent element, usually a select element, will be changed as well.\n * We can treat this change as a value change of the select element the current target belongs to.\n */\n if (target && (target as Element).tagName === 'OPTION')\n target = (target as Element).parentElement;\n if (\n !target ||\n !(target as Element).tagName ||\n INPUT_TAGS.indexOf((target as Element).tagName) < 0 ||\n isBlocked(target as Node, blockClass)\n ) {\n return;\n }\n const type: string | undefined = (target as HTMLInputElement).type;\n if ((target as HTMLElement).classList.contains(ignoreClass)) {\n return;\n }\n let text = (target as HTMLInputElement).value;\n let isChecked = false;\n if (type === 'radio' || type === 'checkbox') {\n isChecked = (target as HTMLInputElement).checked;\n } else if (\n maskInputOptions[\n (target as Element).tagName.toLowerCase() as keyof MaskInputOptions\n ] ||\n maskInputOptions[type as keyof MaskInputOptions]\n ) {\n text = maskInputValue({\n maskInputOptions,\n tagName: (target as HTMLElement).tagName,\n type,\n value: text,\n maskInputFn,\n });\n }\n cbWithDedup(\n target,\n wrapEventWithUserTriggeredFlag(\n { text, isChecked, userTriggered },\n userTriggeredOnInput,\n ),\n );\n // if a radio was checked\n // the other radios with the same name attribute will be unchecked.\n const name: string | undefined = (target as HTMLInputElement).name;\n if (type === 'radio' && name && isChecked) {\n doc\n .querySelectorAll(`input[type=\"radio\"][name=\"${name}\"]`)\n .forEach((el) => {\n if (el !== target) {\n cbWithDedup(\n el,\n wrapEventWithUserTriggeredFlag(\n {\n text: (el as HTMLInputElement).value,\n isChecked: !isChecked,\n userTriggered: false,\n },\n userTriggeredOnInput,\n ),\n );\n }\n });\n }\n }\n function cbWithDedup(target: EventTarget, v: inputValue) {\n const lastInputValue = lastInputValueMap.get(target);\n if (\n !lastInputValue ||\n lastInputValue.text !== v.text ||\n lastInputValue.isChecked !== v.isChecked\n ) {\n lastInputValueMap.set(target, v);\n const id = mirror.getId(target as INode);\n inputCb({\n ...v,\n id,\n });\n }\n }\n const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];\n const handlers: Array<\n listenerHandler | hookResetter\n > = events.map((eventName) => on(eventName, eventHandler, doc));\n const propertyDescriptor = Object.getOwnPropertyDescriptor(\n HTMLInputElement.prototype,\n 'value',\n );\n const hookProperties: Array<[HTMLElement, string]> = [\n [HTMLInputElement.prototype, 'value'],\n [HTMLInputElement.prototype, 'checked'],\n [HTMLSelectElement.prototype, 'value'],\n [HTMLTextAreaElement.prototype, 'value'],\n // Some UI library use selectedIndex to set select value\n [HTMLSelectElement.prototype, 'selectedIndex'],\n [HTMLOptionElement.prototype, 'selected'],\n ];\n if (propertyDescriptor && propertyDescriptor.set) {\n handlers.push(\n ...hookProperties.map((p) =>\n hookSetter(p[0], p[1], {\n set() {\n // mock to a normal event\n eventHandler({ target: this } as Event);\n },\n }),\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\ntype GroupingCSSRule =\n | CSSGroupingRule\n | CSSMediaRule\n | CSSSupportsRule\n | CSSConditionRule;\ntype GroupingCSSRuleTypes =\n | typeof CSSGroupingRule\n | typeof CSSMediaRule\n | typeof CSSSupportsRule\n | typeof CSSConditionRule;\n\nfunction getNestedCSSRulePositions(rule: CSSRule): number[] {\n const positions: number[] = [];\n function recurse(childRule: CSSRule, pos: number[]) {\n if (\n (isCSSGroupingRuleSupported &&\n childRule.parentRule instanceof CSSGroupingRule) ||\n (isCSSMediaRuleSupported &&\n childRule.parentRule instanceof CSSMediaRule) ||\n (isCSSSupportsRuleSupported &&\n childRule.parentRule instanceof CSSSupportsRule) ||\n (isCSSConditionRuleSupported &&\n childRule.parentRule instanceof CSSConditionRule)\n ) {\n const rules = Array.from(\n (childRule.parentRule as GroupingCSSRule).cssRules,\n );\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n } else {\n const rules = Array.from(childRule.parentStyleSheet!.cssRules);\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n }\n return pos;\n }\n return recurse(rule, positions);\n}\n\nfunction initStyleSheetObserver(\n { styleSheetRuleCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n const insertRule = win.CSSStyleSheet.prototype.insertRule;\n win.CSSStyleSheet.prototype.insertRule = function (\n rule: string,\n index?: number,\n ) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [{ rule, index }],\n });\n }\n return insertRule.apply(this, arguments);\n };\n\n const deleteRule = win.CSSStyleSheet.prototype.deleteRule;\n win.CSSStyleSheet.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index }],\n });\n }\n return deleteRule.apply(this, arguments);\n };\n\n const supportedNestedCSSRuleTypes: {\n [key: string]: GroupingCSSRuleTypes;\n } = {};\n if (isCSSGroupingRuleSupported) {\n supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;\n } else {\n // Some browsers (Safari) don't support CSSGroupingRule\n // https://caniuse.com/?search=cssgroupingrule\n // fall back to monkey patching classes that would have inherited from CSSGroupingRule\n\n if (isCSSMediaRuleSupported) {\n supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;\n }\n if (isCSSConditionRuleSupported) {\n supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;\n }\n if (isCSSSupportsRuleSupported) {\n supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;\n }\n }\n\n const unmodifiedFunctions: {\n [key: string]: {\n insertRule: (rule: string, index?: number) => number;\n deleteRule: (index: number) => void;\n };\n } = {};\n\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n unmodifiedFunctions[typeKey] = {\n insertRule: (type as GroupingCSSRuleTypes).prototype.insertRule,\n deleteRule: (type as GroupingCSSRuleTypes).prototype.deleteRule,\n };\n\n type.prototype.insertRule = function (rule: string, index?: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [\n {\n rule,\n index: [\n ...getNestedCSSRulePositions(this),\n index || 0, // defaults to 0\n ],\n },\n ],\n });\n }\n return unmodifiedFunctions[typeKey].insertRule.apply(this, arguments);\n };\n\n type.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index: [...getNestedCSSRulePositions(this), index] }],\n });\n }\n return unmodifiedFunctions[typeKey].deleteRule.apply(this, arguments);\n };\n });\n\n return () => {\n win.CSSStyleSheet.prototype.insertRule = insertRule;\n win.CSSStyleSheet.prototype.deleteRule = deleteRule;\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;\n type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;\n });\n };\n}\n\nfunction initStyleDeclarationObserver(\n { styleDeclarationCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n const setProperty = win.CSSStyleDeclaration.prototype.setProperty;\n win.CSSStyleDeclaration.prototype.setProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n value: string,\n priority: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n set: {\n property,\n value,\n priority,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return setProperty.apply(this, arguments);\n };\n\n const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n remove: {\n property,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return removeProperty.apply(this, arguments);\n };\n\n return () => {\n win.CSSStyleDeclaration.prototype.setProperty = setProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;\n };\n}\n\nfunction initMediaInteractionObserver({\n mediaInteractionCb,\n blockClass,\n mirror,\n sampling,\n}: observerParam): listenerHandler {\n const handler = (type: MediaInteractions) =>\n throttle((event: Event) => {\n const target = getEventTarget(event);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const { currentTime, volume, muted } = target as HTMLMediaElement;\n mediaInteractionCb({\n type,\n id: mirror.getId(target as INode),\n currentTime,\n volume,\n muted,\n });\n }, sampling.media || 500);\n const handlers = [\n on('play', handler(MediaInteractions.Play)),\n on('pause', handler(MediaInteractions.Pause)),\n on('seeked', handler(MediaInteractions.Seeked)),\n on('volumechange', handler(MediaInteractions.VolumeChange)),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initFontObserver({ fontCb, doc }: observerParam): listenerHandler {\n const win = doc.defaultView as IWindow;\n if (!win) {\n return () => {};\n }\n\n const handlers: listenerHandler[] = [];\n\n const fontMap = new WeakMap();\n\n const originalFontFace = win.FontFace;\n win.FontFace = (function FontFace(\n family: string,\n source: string | ArrayBufferView,\n descriptors?: FontFaceDescriptors,\n ) {\n const fontFace = new originalFontFace(family, source, descriptors);\n fontMap.set(fontFace, {\n family,\n buffer: typeof source !== 'string',\n descriptors,\n fontSource:\n typeof source === 'string'\n ? source\n : // tslint:disable-next-line: no-any\n JSON.stringify(Array.from(new Uint8Array(source as any))),\n });\n return fontFace;\n } as unknown) as typeof FontFace;\n\n const restoreHandler = patch(doc.fonts, 'add', function (original) {\n return function (this: FontFaceSet, fontFace: FontFace) {\n setTimeout(() => {\n const p = fontMap.get(fontFace);\n if (p) {\n fontCb(p);\n fontMap.delete(fontFace);\n }\n }, 0);\n return original.apply(this, [fontFace]);\n };\n });\n\n handlers.push(() => {\n win.FontFace = originalFontFace;\n });\n handlers.push(restoreHandler);\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction mergeHooks(o: observerParam, hooks: hooksParam) {\n const {\n mutationCb,\n mousemoveCb,\n mouseInteractionCb,\n scrollCb,\n viewportResizeCb,\n inputCb,\n mediaInteractionCb,\n styleSheetRuleCb,\n styleDeclarationCb,\n canvasMutationCb,\n fontCb,\n } = o;\n o.mutationCb = (...p: Arguments) => {\n if (hooks.mutation) {\n hooks.mutation(...p);\n }\n mutationCb(...p);\n };\n o.mousemoveCb = (...p: Arguments) => {\n if (hooks.mousemove) {\n hooks.mousemove(...p);\n }\n mousemoveCb(...p);\n };\n o.mouseInteractionCb = (...p: Arguments) => {\n if (hooks.mouseInteraction) {\n hooks.mouseInteraction(...p);\n }\n mouseInteractionCb(...p);\n };\n o.scrollCb = (...p: Arguments) => {\n if (hooks.scroll) {\n hooks.scroll(...p);\n }\n scrollCb(...p);\n };\n o.viewportResizeCb = (...p: Arguments) => {\n if (hooks.viewportResize) {\n hooks.viewportResize(...p);\n }\n viewportResizeCb(...p);\n };\n o.inputCb = (...p: Arguments) => {\n if (hooks.input) {\n hooks.input(...p);\n }\n inputCb(...p);\n };\n o.mediaInteractionCb = (...p: Arguments) => {\n if (hooks.mediaInteaction) {\n hooks.mediaInteaction(...p);\n }\n mediaInteractionCb(...p);\n };\n o.styleSheetRuleCb = (...p: Arguments) => {\n if (hooks.styleSheetRule) {\n hooks.styleSheetRule(...p);\n }\n styleSheetRuleCb(...p);\n };\n o.styleDeclarationCb = (...p: Arguments) => {\n if (hooks.styleDeclaration) {\n hooks.styleDeclaration(...p);\n }\n styleDeclarationCb(...p);\n };\n o.canvasMutationCb = (...p: Arguments) => {\n if (hooks.canvasMutation) {\n hooks.canvasMutation(...p);\n }\n canvasMutationCb(...p);\n };\n o.fontCb = (...p: Arguments) => {\n if (hooks.font) {\n hooks.font(...p);\n }\n fontCb(...p);\n };\n}\n\nexport function initObservers(\n o: observerParam,\n hooks: hooksParam = {},\n): listenerHandler {\n const currentWindow = o.doc.defaultView; // basically document.window\n if (!currentWindow) {\n return () => {};\n }\n\n mergeHooks(o, hooks);\n const mutationObserver = initMutationObserver(o, o.doc);\n const mousemoveHandler = initMoveObserver(o);\n const mouseInteractionHandler = initMouseInteractionObserver(o);\n const scrollHandler = initScrollObserver(o);\n const viewportResizeHandler = initViewportResizeObserver(o);\n const inputHandler = initInputObserver(o);\n const mediaInteractionHandler = initMediaInteractionObserver(o);\n\n const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });\n const styleDeclarationObserver = initStyleDeclarationObserver(o, {\n win: currentWindow,\n });\n const fontObserver = o.collectFonts ? initFontObserver(o) : () => {};\n // plugins\n const pluginHandlers: listenerHandler[] = [];\n for (const plugin of o.plugins) {\n pluginHandlers.push(\n plugin.observer(plugin.callback, currentWindow, plugin.options),\n );\n }\n\n return () => {\n mutationBuffers.forEach((b) => b.reset());\n mutationObserver.disconnect();\n mousemoveHandler();\n mouseInteractionHandler();\n scrollHandler();\n viewportResizeHandler();\n inputHandler();\n mediaInteractionHandler();\n styleSheetObserver();\n styleDeclarationObserver();\n fontObserver();\n pluginHandlers.forEach((h) => h());\n };\n}\n","import { serializedNodeWithId, INode } from 'rrweb-snapshot';\nimport { mutationCallBack } from '../types';\n\nexport class IframeManager {\n private iframes: WeakMap = new WeakMap();\n private mutationCb: mutationCallBack;\n private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;\n\n constructor(options: { mutationCb: mutationCallBack }) {\n this.mutationCb = options.mutationCb;\n }\n\n public addIframe(iframeEl: HTMLIFrameElement) {\n this.iframes.set(iframeEl, true);\n }\n\n public addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown) {\n this.loadListener = cb;\n }\n\n public attachIframe(iframeEl: INode, childSn: serializedNodeWithId) {\n this.mutationCb({\n adds: [\n {\n parentId: iframeEl.__sn.id,\n nextId: null,\n node: childSn,\n },\n ],\n removes: [],\n texts: [],\n attributes: [],\n isAttachIframe: true,\n });\n this.loadListener?.((iframeEl as unknown) as HTMLIFrameElement);\n }\n}\n","import {\n mutationCallBack,\n Mirror,\n scrollCallback,\n MutationBufferParam,\n SamplingStrategy,\n} from '../types';\nimport { initMutationObserver, initScrollObserver } from './observer';\nimport { patch } from '../utils';\n\ntype BypassOptions = Omit<\n MutationBufferParam,\n 'doc' | 'mutationCb' | 'mirror' | 'shadowDomManager'\n> & {\n sampling: SamplingStrategy;\n};\n\nexport class ShadowDomManager {\n private mutationCb: mutationCallBack;\n private scrollCb: scrollCallback;\n private bypassOptions: BypassOptions;\n private mirror: Mirror;\n private restorePatches: (() => void)[] = [];\n\n constructor(options: {\n mutationCb: mutationCallBack;\n scrollCb: scrollCallback;\n bypassOptions: BypassOptions;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.scrollCb = options.scrollCb;\n this.bypassOptions = options.bypassOptions;\n this.mirror = options.mirror;\n\n // Patch 'attachShadow' to observe newly added shadow doms.\n const manager = this;\n this.restorePatches.push(\n patch(HTMLElement.prototype, 'attachShadow', function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(this.shadowRoot, this.ownerDocument);\n return shadowRoot;\n };\n }),\n );\n }\n\n public addShadowRoot(shadowRoot: ShadowRoot, doc: Document) {\n initMutationObserver(\n {\n ...this.bypassOptions,\n doc,\n mutationCb: this.mutationCb,\n mirror: this.mirror,\n shadowDomManager: this,\n },\n shadowRoot,\n );\n initScrollObserver({\n ...this.bypassOptions,\n scrollCb: this.scrollCb,\n // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813\n // scroll is not allowed to pass the boundary, so we need to listen the shadow document\n doc: (shadowRoot as unknown) as Document,\n mirror: this.mirror,\n });\n }\n\n /**\n * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.\n */\n public observeAttachShadow(iframeElement: HTMLIFrameElement) {\n if (iframeElement.contentWindow) {\n const manager = this;\n this.restorePatches.push(\n patch(\n (iframeElement.contentWindow as Window & {\n HTMLElement: { prototype: HTMLElement };\n }).HTMLElement.prototype,\n 'attachShadow',\n function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(\n this.shadowRoot,\n iframeElement.contentDocument as Document,\n );\n return shadowRoot;\n };\n },\n ),\n );\n }\n }\n\n public reset() {\n this.restorePatches.forEach((restorePatch) => restorePatch());\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { encode } from 'base64-arraybuffer';\nimport { IWindow, SerializedWebGlArg } from '../../../types';\n\n// TODO: unify with `replay/webgl.ts`\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nexport const saveWebGLVar = (\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): number | void => {\n if (\n !value ||\n !(isInstanceOfWebGLObject(value, win) || typeof value === 'object')\n )\n return;\n\n const name = value.constructor.name;\n const list = variableListFor(ctx, name);\n let index = list.indexOf(value);\n\n if (index === -1) {\n index = list.length;\n list.push(value);\n }\n return index;\n};\n\n// from webgl-recorder: https://github.com/evanw/webgl-recorder/blob/bef0e65596e981ee382126587e2dcbe0fc7748e2/webgl-recorder.js#L50-L77\nexport function serializeArg(\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): SerializedWebGlArg {\n if (value instanceof Array) {\n return value.map((arg) => serializeArg(arg, win, ctx));\n } else if (value === null) {\n return value;\n } else if (\n value instanceof Float32Array ||\n value instanceof Float64Array ||\n value instanceof Int32Array ||\n value instanceof Uint32Array ||\n value instanceof Uint8Array ||\n value instanceof Uint16Array ||\n value instanceof Int16Array ||\n value instanceof Int8Array ||\n value instanceof Uint8ClampedArray\n ) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [Object.values(value)],\n };\n } else if (\n // SharedArrayBuffer disabled on most browsers due to spectre.\n // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer\n // value instanceof SharedArrayBuffer ||\n value instanceof ArrayBuffer\n ) {\n const name = value.constructor.name as 'ArrayBuffer';\n const base64 = encode(value);\n\n return {\n rr_type: name,\n base64,\n };\n } else if (value instanceof DataView) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [\n serializeArg(value.buffer, win, ctx),\n value.byteOffset,\n value.byteLength,\n ],\n };\n } else if (value instanceof HTMLImageElement) {\n const name = value.constructor.name;\n const { src } = value;\n return {\n rr_type: name,\n src,\n };\n } else if (value instanceof ImageData) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [serializeArg(value.data, win, ctx), value.width, value.height],\n };\n } else if (isInstanceOfWebGLObject(value, win) || typeof value === 'object') {\n const name = value.constructor.name;\n const index = saveWebGLVar(value, win, ctx) as number;\n\n return {\n rr_type: name,\n index: index,\n };\n }\n\n return value;\n}\n\nexport const serializeArgs = (\n args: Array,\n win: IWindow,\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n) => {\n return [...args].map((arg) => serializeArg(arg, win, ctx));\n};\n\nexport const isInstanceOfWebGLObject = (\n value: any,\n win: IWindow,\n): value is\n | WebGLActiveInfo\n | WebGLBuffer\n | WebGLFramebuffer\n | WebGLProgram\n | WebGLRenderbuffer\n | WebGLShader\n | WebGLShaderPrecisionFormat\n | WebGLTexture\n | WebGLUniformLocation\n | WebGLVertexArrayObject => {\n const webGLConstructorNames: string[] = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.\n 'WebGLVertexArrayObjectOES',\n ];\n const supportedWebGLConstructorNames = webGLConstructorNames.filter(\n (name: string) => typeof win[name as keyof Window] === 'function',\n );\n return Boolean(\n supportedWebGLConstructorNames.find(\n (name: string) => value instanceof win[name as keyof Window],\n ),\n );\n};\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\nimport { saveWebGLVar, serializeArgs } from './serialize-args';\n\nfunction patchGLPrototype(\n prototype: WebGLRenderingContext | WebGL2RenderingContext,\n type: CanvasContext,\n cb: canvasManagerMutationCallback,\n blockClass: blockClass,\n mirror: Mirror,\n win: IWindow,\n): listenerHandler[] {\n const handlers: listenerHandler[] = [];\n\n const props = Object.getOwnPropertyNames(prototype);\n\n for (const prop of props) {\n try {\n if (typeof prototype[prop as keyof typeof prototype] !== 'function') {\n continue;\n }\n const restoreHandler = patch(prototype, prop, function (original) {\n return function (this: typeof prototype, ...args: Array) {\n const result = original.apply(this, args);\n saveWebGLVar(result, win, prototype);\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n const id = mirror.getId((this.canvas as unknown) as INode);\n\n const recordArgs = serializeArgs([...args], win, prototype);\n const mutation: canvasMutationWithType = {\n type,\n property: prop,\n args: recordArgs,\n };\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, mutation);\n }\n\n return result;\n };\n });\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(prototype, prop, {\n set(v) {\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, {\n type,\n property: prop,\n args: [v],\n setter: true,\n });\n },\n });\n handlers.push(hookHandler);\n }\n }\n\n return handlers;\n}\n\nexport default function initCanvasWebGLMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n\n handlers.push(\n ...patchGLPrototype(\n win.WebGLRenderingContext.prototype,\n CanvasContext.WebGL,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n\n if (typeof win.WebGL2RenderingContext !== 'undefined') {\n handlers.push(\n ...patchGLPrototype(\n win.WebGL2RenderingContext.prototype,\n CanvasContext.WebGL2,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n }\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n canvasManagerMutationCallback,\n canvasMutationCallback,\n canvasMutationCommand,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport initCanvas2DMutationObserver from './2d';\nimport initCanvasContextObserver from './canvas';\nimport initCanvasWebGLMutationObserver from './webgl';\n\nexport type RafStamps = { latestId: number; invokeId: number | null };\n\ntype pendingCanvasMutationsMap = Map<\n HTMLCanvasElement,\n canvasMutationWithType[]\n>;\n\nexport class CanvasManager {\n private pendingCanvasMutations: pendingCanvasMutationsMap = new Map();\n private rafStamps: RafStamps = { latestId: 0, invokeId: null };\n private mirror: Mirror;\n\n private mutationCb: canvasMutationCallback;\n private resetObservers?: listenerHandler;\n private frozen: boolean = false;\n private locked: boolean = false;\n\n public reset() {\n this.pendingCanvasMutations.clear();\n this.resetObservers && this.resetObservers();\n }\n\n public freeze() {\n this.frozen = true;\n }\n\n public unfreeze() {\n this.frozen = false;\n }\n\n public lock() {\n this.locked = true;\n }\n\n public unlock() {\n this.locked = false;\n }\n\n constructor(options: {\n recordCanvas: boolean | number;\n mutationCb: canvasMutationCallback;\n win: IWindow;\n blockClass: blockClass;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.mirror = options.mirror;\n\n if (options.recordCanvas === true)\n this.initCanvasMutationObserver(options.win, options.blockClass);\n }\n\n private processMutation: canvasManagerMutationCallback = function (\n target,\n mutation,\n ) {\n const newFrame =\n this.rafStamps.invokeId &&\n this.rafStamps.latestId !== this.rafStamps.invokeId;\n if (newFrame || !this.rafStamps.invokeId)\n this.rafStamps.invokeId = this.rafStamps.latestId;\n\n if (!this.pendingCanvasMutations.has(target)) {\n this.pendingCanvasMutations.set(target, []);\n }\n\n this.pendingCanvasMutations.get(target)!.push(mutation);\n };\n\n private initCanvasMutationObserver(\n win: IWindow,\n blockClass: blockClass,\n ): void {\n this.startRAFTimestamping();\n this.startPendingCanvasMutationFlusher();\n\n const canvasContextReset = initCanvasContextObserver(win, blockClass);\n const canvas2DReset = initCanvas2DMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n this.resetObservers = () => {\n canvasContextReset();\n canvas2DReset();\n canvasWebGL1and2Reset();\n };\n }\n\n private startPendingCanvasMutationFlusher() {\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n private startRAFTimestamping() {\n const setLatestRAFTimestamp = (timestamp: DOMHighResTimeStamp) => {\n this.rafStamps.latestId = timestamp;\n requestAnimationFrame(setLatestRAFTimestamp);\n };\n requestAnimationFrame(setLatestRAFTimestamp);\n }\n\n flushPendingCanvasMutations() {\n this.pendingCanvasMutations.forEach(\n (values: canvasMutationCommand[], canvas: HTMLCanvasElement) => {\n const id = this.mirror.getId((canvas as unknown) as INode);\n this.flushPendingCanvasMutationFor(canvas, id);\n },\n );\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n flushPendingCanvasMutationFor(canvas: HTMLCanvasElement, id: number) {\n if (this.frozen || this.locked) {\n return;\n }\n\n const valuesWithType = this.pendingCanvasMutations.get(canvas);\n if (!valuesWithType || id === -1) return;\n\n const values = valuesWithType.map((value) => {\n const { type, ...rest } = value;\n return rest;\n });\n const { type } = valuesWithType[0];\n\n this.mutationCb({ id, type, commands: values });\n\n this.pendingCanvasMutations.delete(canvas);\n }\n}\n","import { snapshot, MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';\nimport { initObservers, mutationBuffers } from './observer';\nimport {\n on,\n getWindowWidth,\n getWindowHeight,\n polyfill,\n isIframeINode,\n hasShadowRoot,\n createMirror,\n} from '../utils';\nimport {\n EventType,\n event,\n eventWithTime,\n recordOptions,\n IncrementalSource,\n listenerHandler,\n mutationCallbackParam,\n scrollCallback,\n canvasMutationParam,\n} from '../types';\nimport { IframeManager } from './iframe-manager';\nimport { ShadowDomManager } from './shadow-dom-manager';\nimport { CanvasManager } from './observers/canvas/canvas-manager';\n\nfunction wrapEvent(e: event): eventWithTime {\n return {\n ...e,\n timestamp: Date.now(),\n };\n}\n\nlet wrappedEmit!: (e: eventWithTime, isCheckout?: boolean) => void;\n\nlet takeFullSnapshot!: (isCheckout?: boolean) => void;\n\nconst mirror = createMirror();\nfunction record(\n options: recordOptions = {},\n): listenerHandler | undefined {\n const {\n emit,\n checkoutEveryNms,\n checkoutEveryNth,\n blockClass = 'rr-block',\n blockSelector = null,\n ignoreClass = 'rr-ignore',\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n inlineStylesheet = true,\n maskAllInputs,\n maskInputOptions: _maskInputOptions,\n slimDOMOptions: _slimDOMOptions,\n maskInputFn,\n maskTextFn,\n hooks,\n packFn,\n sampling = {},\n mousemoveWait,\n recordCanvas = false,\n userTriggeredOnInput = false,\n collectFonts = false,\n inlineImages = false,\n plugins,\n keepIframeSrcFn = () => false,\n } = options;\n // runtime checks for user options\n if (!emit) {\n throw new Error('emit function is required');\n }\n // move departed options to new options\n if (mousemoveWait !== undefined && sampling.mousemove === undefined) {\n sampling.mousemove = mousemoveWait;\n }\n\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : _maskInputOptions !== undefined\n ? _maskInputOptions\n : { password: true };\n\n const slimDOMOptions: SlimDOMOptions =\n _slimDOMOptions === true || _slimDOMOptions === 'all'\n ? {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaVerification: true,\n // the following are off for slimDOMOptions === true,\n // as they destroy some (hidden) info:\n headMetaAuthorship: _slimDOMOptions === 'all',\n headMetaDescKeywords: _slimDOMOptions === 'all',\n }\n : _slimDOMOptions\n ? _slimDOMOptions\n : {};\n\n polyfill();\n\n let lastFullSnapshotEvent: eventWithTime;\n let incrementalSnapshotCount = 0;\n const eventProcessor = (e: eventWithTime): T => {\n for (const plugin of plugins || []) {\n if (plugin.eventProcessor) {\n e = plugin.eventProcessor(e);\n }\n }\n if (packFn) {\n e = (packFn(e) as unknown) as eventWithTime;\n }\n return (e as unknown) as T;\n };\n wrappedEmit = (e: eventWithTime, isCheckout?: boolean) => {\n if (\n mutationBuffers[0]?.isFrozen() &&\n e.type !== EventType.FullSnapshot &&\n !(\n e.type === EventType.IncrementalSnapshot &&\n e.data.source === IncrementalSource.Mutation\n )\n ) {\n // we've got a user initiated event so first we need to apply\n // all DOM changes that have been buffering during paused state\n mutationBuffers.forEach((buf) => buf.unfreeze());\n }\n\n emit(eventProcessor(e), isCheckout);\n if (e.type === EventType.FullSnapshot) {\n lastFullSnapshotEvent = e;\n incrementalSnapshotCount = 0;\n } else if (e.type === EventType.IncrementalSnapshot) {\n // attach iframe should be considered as full snapshot\n if (\n e.data.source === IncrementalSource.Mutation &&\n e.data.isAttachIframe\n ) {\n return;\n }\n\n incrementalSnapshotCount++;\n const exceedCount =\n checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;\n const exceedTime =\n checkoutEveryNms &&\n e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;\n if (exceedCount || exceedTime) {\n takeFullSnapshot(true);\n }\n }\n };\n\n const wrappedMutationEmit = (m: mutationCallbackParam) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Mutation,\n ...m,\n },\n }),\n );\n };\n const wrappedScrollEmit: scrollCallback = (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Scroll,\n ...p,\n },\n }),\n );\n const wrappedCanvasMutationEmit = (p: canvasMutationParam) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.CanvasMutation,\n ...p,\n },\n }),\n );\n\n const iframeManager = new IframeManager({\n mutationCb: wrappedMutationEmit,\n });\n\n const canvasManager = new CanvasManager({\n recordCanvas,\n mutationCb: wrappedCanvasMutationEmit,\n win: window,\n blockClass,\n mirror,\n });\n\n const shadowDomManager = new ShadowDomManager({\n mutationCb: wrappedMutationEmit,\n scrollCb: wrappedScrollEmit,\n bypassOptions: {\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n recordCanvas,\n inlineImages,\n sampling,\n slimDOMOptions,\n iframeManager,\n canvasManager,\n },\n mirror,\n });\n\n takeFullSnapshot = (isCheckout = false) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Meta,\n data: {\n href: window.location.href,\n width: getWindowWidth(),\n height: getWindowHeight(),\n },\n }),\n isCheckout,\n );\n\n mutationBuffers.forEach((buf) => buf.lock()); // don't allow any mirror modifications during snapshotting\n const [node, idNodeMap] = snapshot(document, {\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskAllInputs: maskInputOptions,\n maskTextFn,\n slimDOM: slimDOMOptions,\n recordCanvas,\n inlineImages,\n onSerialize: (n) => {\n if (isIframeINode(n)) {\n iframeManager.addIframe(n);\n }\n if (hasShadowRoot(n)) {\n shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n iframeManager.attachIframe(iframe, childSn);\n shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n keepIframeSrcFn,\n });\n\n if (!node) {\n return console.warn('Failed to snapshot the document');\n }\n\n mirror.map = idNodeMap;\n wrappedEmit(\n wrapEvent({\n type: EventType.FullSnapshot,\n data: {\n node,\n initialOffset: {\n left:\n window.pageXOffset !== undefined\n ? window.pageXOffset\n : document?.documentElement.scrollLeft ||\n document?.body?.parentElement?.scrollLeft ||\n document?.body.scrollLeft ||\n 0,\n top:\n window.pageYOffset !== undefined\n ? window.pageYOffset\n : document?.documentElement.scrollTop ||\n document?.body?.parentElement?.scrollTop ||\n document?.body.scrollTop ||\n 0,\n },\n },\n }),\n );\n mutationBuffers.forEach((buf) => buf.unlock()); // generate & emit any mutations that happened during snapshotting, as can now apply against the newly built mirror\n };\n\n try {\n const handlers: listenerHandler[] = [];\n handlers.push(\n on('DOMContentLoaded', () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.DomContentLoaded,\n data: {},\n }),\n );\n }),\n );\n\n const observe = (doc: Document) => {\n return initObservers(\n {\n mutationCb: wrappedMutationEmit,\n mousemoveCb: (positions, source) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source,\n positions,\n },\n }),\n ),\n mouseInteractionCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MouseInteraction,\n ...d,\n },\n }),\n ),\n scrollCb: wrappedScrollEmit,\n viewportResizeCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.ViewportResize,\n ...d,\n },\n }),\n ),\n inputCb: (v) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Input,\n ...v,\n },\n }),\n ),\n mediaInteractionCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MediaInteraction,\n ...p,\n },\n }),\n ),\n styleSheetRuleCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleSheetRule,\n ...r,\n },\n }),\n ),\n styleDeclarationCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleDeclaration,\n ...r,\n },\n }),\n ),\n canvasMutationCb: wrappedCanvasMutationEmit,\n fontCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Font,\n ...p,\n },\n }),\n ),\n blockClass,\n ignoreClass,\n maskTextClass,\n maskTextSelector,\n maskInputOptions,\n inlineStylesheet,\n sampling,\n recordCanvas,\n inlineImages,\n userTriggeredOnInput,\n collectFonts,\n doc,\n maskInputFn,\n maskTextFn,\n blockSelector,\n slimDOMOptions,\n mirror,\n iframeManager,\n shadowDomManager,\n canvasManager,\n plugins:\n plugins\n ?.filter((p) => p.observer)\n ?.map((p) => ({\n observer: p.observer!,\n options: p.options,\n callback: (payload: object) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.Plugin,\n data: {\n plugin: p.name,\n payload,\n },\n }),\n ),\n })) || [],\n },\n hooks,\n );\n };\n\n iframeManager.addLoadListener((iframeEl) => {\n handlers.push(observe(iframeEl.contentDocument!));\n });\n\n const init = () => {\n takeFullSnapshot();\n handlers.push(observe(document));\n };\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n init();\n } else {\n handlers.push(\n on(\n 'load',\n () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Load,\n data: {},\n }),\n );\n init();\n },\n window,\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n } catch (error) {\n // TODO: handle internal error\n console.warn(error);\n }\n}\n\nrecord.addCustomEvent = (tag: string, payload: T) => {\n if (!wrappedEmit) {\n throw new Error('please add custom event after start recording');\n }\n wrappedEmit(\n wrapEvent({\n type: EventType.Custom,\n data: {\n tag,\n payload,\n },\n }),\n );\n};\n\nrecord.freezePage = () => {\n mutationBuffers.forEach((buf) => buf.freeze());\n};\n\nrecord.takeFullSnapshot = (isCheckout?: boolean) => {\n if (!takeFullSnapshot) {\n throw new Error('please take full snapshot after start recording');\n }\n takeFullSnapshot(isCheckout);\n};\n\nrecord.mirror = mirror;\n\nexport default record;\n","import { INode, ICanvas } from 'rrweb-snapshot';\nimport { blockClass, IWindow, listenerHandler } from '../../../types';\nimport { isBlocked, patch } from '../../../utils';\n\nexport default function initCanvasContextObserver(\n win: IWindow,\n blockClass: blockClass,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n try {\n const restoreHandler = patch(\n win.HTMLCanvasElement.prototype,\n 'getContext',\n function (original) {\n return function (\n this: ICanvas,\n contextType: string,\n ...args: Array\n ) {\n if (!isBlocked((this as unknown) as INode, blockClass)) {\n if (!('__context' in this))\n (this as ICanvas).__context = contextType;\n }\n return original.apply(this, [contextType, ...args]);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n console.error('failed to patch HTMLCanvasElement.prototype.getContext');\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\n\nexport default function initCanvas2DMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n const props2D = Object.getOwnPropertyNames(\n win.CanvasRenderingContext2D.prototype,\n );\n for (const prop of props2D) {\n try {\n if (\n typeof win.CanvasRenderingContext2D.prototype[\n prop as keyof CanvasRenderingContext2D\n ] !== 'function'\n ) {\n continue;\n }\n const restoreHandler = patch(\n win.CanvasRenderingContext2D.prototype,\n prop,\n function (original) {\n return function (\n this: CanvasRenderingContext2D,\n ...args: Array\n ) {\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n // Using setTimeout as getImageData + JSON.stringify can be heavy\n // and we'd rather not block the main thread\n setTimeout(() => {\n const recordArgs = [...args];\n if (prop === 'drawImage') {\n if (\n recordArgs[0] &&\n recordArgs[0] instanceof HTMLCanvasElement\n ) {\n const canvas = recordArgs[0];\n const ctx = canvas.getContext('2d');\n let imgd = ctx?.getImageData(\n 0,\n 0,\n canvas.width,\n canvas.height,\n );\n let pix = imgd?.data;\n recordArgs[0] = JSON.stringify(pix);\n }\n }\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: recordArgs,\n });\n }, 0);\n }\n return original.apply(this, args);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(\n win.CanvasRenderingContext2D.prototype,\n prop,\n {\n set(v) {\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: [v],\n setter: true,\n });\n },\n },\n );\n handlers.push(hookHandler);\n }\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","// \n// An event handler can take an optional event argument\n// and should not return a value\n \n \n\n// An array of all currently registered event handlers for a type\n \n \n// A map of event types and their corresponding event handlers.\n \n \n \n \n\n/** Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nfunction mitt(all ) {\n\tall = all || Object.create(null);\n\n\treturn {\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton: function on(type , handler ) {\n\t\t\t(all[type] || (all[type] = [])).push(handler);\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff: function off(type , handler ) {\n\t\t\tif (all[type]) {\n\t\t\t\tall[type].splice(all[type].indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * @param {String} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit: function emit(type , evt ) {\n\t\t\t(all[type] || []).slice().map(function (handler) { handler(evt); });\n\t\t\t(all['*'] || []).slice().map(function (handler) { handler(type, evt); });\n\t\t}\n\t};\n}\n\nexport default mitt;\n//# sourceMappingURL=mitt.es.js.map\n","/**\n * A fork version of https://github.com/iamdustan/smoothscroll\n * Add support of customize target window and document\n */\n\n// @ts-nocheck\n// tslint:disable\nexport function polyfill(w: Window = window, d = document) {\n // return if scroll behavior is supported and polyfill is not forced\n if (\n 'scrollBehavior' in d.documentElement.style &&\n w.__forceSmoothScrollPolyfill__ !== true\n ) {\n return;\n }\n\n // globals\n var Element = w.HTMLElement || w.Element;\n var SCROLL_TIME = 468;\n\n // object gathering original scroll methods\n var original = {\n scroll: w.scroll || w.scrollTo,\n scrollBy: w.scrollBy,\n elementScroll: Element.prototype.scroll || scrollElement,\n scrollIntoView: Element.prototype.scrollIntoView,\n };\n\n // define timing method\n var now =\n w.performance && w.performance.now\n ? w.performance.now.bind(w.performance)\n : Date.now;\n\n /**\n * indicates if a the current browser is made by Microsoft\n * @method isMicrosoftBrowser\n * @param {String} userAgent\n * @returns {Boolean}\n */\n function isMicrosoftBrowser(userAgent) {\n var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];\n\n return new RegExp(userAgentPatterns.join('|')).test(userAgent);\n }\n\n /*\n * IE has rounding bug rounding down clientHeight and clientWidth and\n * rounding up scrollHeight and scrollWidth causing false positives\n * on hasScrollableSpace\n */\n var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;\n\n /**\n * changes scroll position inside an element\n * @method scrollElement\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function scrollElement(x, y) {\n this.scrollLeft = x;\n this.scrollTop = y;\n }\n\n /**\n * returns result of applying ease math function to a number\n * @method ease\n * @param {Number} k\n * @returns {Number}\n */\n function ease(k) {\n return 0.5 * (1 - Math.cos(Math.PI * k));\n }\n\n /**\n * indicates if a smooth behavior should be applied\n * @method shouldBailOut\n * @param {Number|Object} firstArg\n * @returns {Boolean}\n */\n function shouldBailOut(firstArg) {\n if (\n firstArg === null ||\n typeof firstArg !== 'object' ||\n firstArg.behavior === undefined ||\n firstArg.behavior === 'auto' ||\n firstArg.behavior === 'instant'\n ) {\n // first argument is not an object/null\n // or behavior is auto, instant or undefined\n return true;\n }\n\n if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {\n // first argument is an object and behavior is smooth\n return false;\n }\n\n // throw error when behavior is not supported\n throw new TypeError(\n 'behavior member of ScrollOptions ' +\n firstArg.behavior +\n ' is not a valid value for enumeration ScrollBehavior.',\n );\n }\n\n /**\n * indicates if an element has scrollable space in the provided axis\n * @method hasScrollableSpace\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function hasScrollableSpace(el, axis) {\n if (axis === 'Y') {\n return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;\n }\n\n if (axis === 'X') {\n return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;\n }\n }\n\n /**\n * indicates if an element has a scrollable overflow property in the axis\n * @method canOverflow\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function canOverflow(el, axis) {\n var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];\n\n return overflowValue === 'auto' || overflowValue === 'scroll';\n }\n\n /**\n * indicates if an element can be scrolled in either axis\n * @method isScrollable\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function isScrollable(el) {\n var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');\n var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');\n\n return isScrollableY || isScrollableX;\n }\n\n /**\n * finds scrollable parent of an element\n * @method findScrollableParent\n * @param {Node} el\n * @returns {Node} el\n */\n function findScrollableParent(el) {\n while (el !== d.body && isScrollable(el) === false) {\n el = el.parentNode || el.host;\n }\n\n return el;\n }\n\n /**\n * self invoked function that, given a context, steps through scrolling\n * @method step\n * @param {Object} context\n * @returns {undefined}\n */\n function step(context) {\n var time = now();\n var value;\n var currentX;\n var currentY;\n var elapsed = (time - context.startTime) / SCROLL_TIME;\n\n // avoid elapsed times higher than one\n elapsed = elapsed > 1 ? 1 : elapsed;\n\n // apply easing to elapsed time\n value = ease(elapsed);\n\n currentX = context.startX + (context.x - context.startX) * value;\n currentY = context.startY + (context.y - context.startY) * value;\n\n context.method.call(context.scrollable, currentX, currentY);\n\n // scroll more if we have not reached our destination\n if (currentX !== context.x || currentY !== context.y) {\n w.requestAnimationFrame(step.bind(w, context));\n }\n }\n\n /**\n * scrolls window or element with a smooth behavior\n * @method smoothScroll\n * @param {Object|Node} el\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function smoothScroll(el, x, y) {\n var scrollable;\n var startX;\n var startY;\n var method;\n var startTime = now();\n\n // define scroll context\n if (el === d.body) {\n scrollable = w;\n startX = w.scrollX || w.pageXOffset;\n startY = w.scrollY || w.pageYOffset;\n method = original.scroll;\n } else {\n scrollable = el;\n startX = el.scrollLeft;\n startY = el.scrollTop;\n method = scrollElement;\n }\n\n // scroll looping over a frame\n step({\n scrollable: scrollable,\n method: method,\n startTime: startTime,\n startX: startX,\n startY: startY,\n x: x,\n y: y,\n });\n }\n\n // ORIGINAL METHODS OVERRIDES\n // w.scroll and w.scrollTo\n w.scroll = w.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scroll.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : w.scrollX || w.pageXOffset,\n // use top prop, second argument if present or fallback to scrollY\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : w.scrollY || w.pageYOffset,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : w.scrollX || w.pageXOffset,\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : w.scrollY || w.pageYOffset,\n );\n };\n\n // w.scrollBy\n w.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0])) {\n original.scrollBy.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : 0,\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : 0,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n ~~arguments[0].left + (w.scrollX || w.pageXOffset),\n ~~arguments[0].top + (w.scrollY || w.pageYOffset),\n );\n };\n\n // Element.prototype.scroll and Element.prototype.scrollTo\n Element.prototype.scroll = Element.prototype.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n // if one number is passed, throw error to match Firefox implementation\n if (typeof arguments[0] === 'number' && arguments[1] === undefined) {\n throw new SyntaxError('Value could not be converted');\n }\n\n original.elementScroll.call(\n this,\n // use left prop, first number argument or fallback to scrollLeft\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : typeof arguments[0] !== 'object'\n ? ~~arguments[0]\n : this.scrollLeft,\n // use top prop, second argument or fallback to scrollTop\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : arguments[1] !== undefined\n ? ~~arguments[1]\n : this.scrollTop,\n );\n\n return;\n }\n\n var left = arguments[0].left;\n var top = arguments[0].top;\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n this,\n this,\n typeof left === 'undefined' ? this.scrollLeft : ~~left,\n typeof top === 'undefined' ? this.scrollTop : ~~top,\n );\n };\n\n // Element.prototype.scrollBy\n Element.prototype.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.elementScroll.call(\n this,\n arguments[0].left !== undefined\n ? ~~arguments[0].left + this.scrollLeft\n : ~~arguments[0] + this.scrollLeft,\n arguments[0].top !== undefined\n ? ~~arguments[0].top + this.scrollTop\n : ~~arguments[1] + this.scrollTop,\n );\n\n return;\n }\n\n this.scroll({\n left: ~~arguments[0].left + this.scrollLeft,\n top: ~~arguments[0].top + this.scrollTop,\n behavior: arguments[0].behavior,\n });\n };\n\n // Element.prototype.scrollIntoView\n Element.prototype.scrollIntoView = function () {\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scrollIntoView.call(\n this,\n arguments[0] === undefined ? true : arguments[0],\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n var scrollableParent = findScrollableParent(this);\n var parentRects = scrollableParent.getBoundingClientRect();\n var clientRects = this.getBoundingClientRect();\n\n if (scrollableParent !== d.body) {\n // reveal element inside parent\n smoothScroll.call(\n this,\n scrollableParent,\n scrollableParent.scrollLeft + clientRects.left - parentRects.left,\n scrollableParent.scrollTop + clientRects.top - parentRects.top,\n );\n\n // reveal parent in viewport unless is fixed\n if (w.getComputedStyle(scrollableParent).position !== 'fixed') {\n w.scrollBy({\n left: parentRects.left,\n top: parentRects.top,\n behavior: 'smooth',\n });\n }\n } else {\n // reveal element in viewport\n w.scrollBy({\n left: clientRects.left,\n top: clientRects.top,\n behavior: 'smooth',\n });\n }\n };\n}\n","import {\n actionWithDelay,\n eventWithTime,\n EventType,\n IncrementalSource,\n} from '../types';\n\nexport class Timer {\n public timeOffset: number = 0;\n public speed: number;\n\n private actions: actionWithDelay[];\n private raf: number | null = null;\n private liveMode: boolean;\n\n constructor(actions: actionWithDelay[] = [], speed: number) {\n this.actions = actions;\n this.speed = speed;\n }\n /**\n * Add an action after the timer starts.\n * @param action\n */\n public addAction(action: actionWithDelay) {\n const index = this.findActionIndex(action);\n this.actions.splice(index, 0, action);\n }\n /**\n * Add all actions before the timer starts\n * @param actions\n */\n public addActions(actions: actionWithDelay[]) {\n this.actions = this.actions.concat(actions);\n }\n\n public start() {\n this.timeOffset = 0;\n let lastTimestamp = performance.now();\n const { actions } = this;\n const self = this;\n function check() {\n const time = performance.now();\n self.timeOffset += (time - lastTimestamp) * self.speed;\n lastTimestamp = time;\n while (actions.length) {\n const action = actions[0];\n\n if (self.timeOffset >= action.delay) {\n actions.shift();\n action.doAction();\n } else {\n break;\n }\n }\n if (actions.length > 0 || self.liveMode) {\n self.raf = requestAnimationFrame(check);\n }\n }\n this.raf = requestAnimationFrame(check);\n }\n\n public clear() {\n if (this.raf) {\n cancelAnimationFrame(this.raf);\n this.raf = null;\n }\n this.actions.length = 0;\n }\n\n public setSpeed(speed: number) {\n this.speed = speed;\n }\n\n public toggleLiveMode(mode: boolean) {\n this.liveMode = mode;\n }\n\n public isActive() {\n return this.raf !== null;\n }\n\n private findActionIndex(action: actionWithDelay): number {\n let start = 0;\n let end = this.actions.length - 1;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (this.actions[mid].delay < action.delay) {\n start = mid + 1;\n } else if (this.actions[mid].delay > action.delay) {\n end = mid - 1;\n } else {\n // already an action with same delay (timestamp)\n // the plus one will splice the new one after the existing one\n return mid + 1;\n }\n }\n return start;\n }\n}\n\n// TODO: add speed to mouse move timestamp calculation\nexport function addDelay(event: eventWithTime, baselineTime: number): number {\n // Mouse move events was recorded in a throttle function,\n // so we need to find the real timestamp by traverse the time offsets.\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove\n ) {\n const firstOffset = event.data.positions[0].timeOffset;\n // timeOffset is a negative offset to event.timestamp\n const firstTimestamp = event.timestamp + firstOffset;\n event.delay = firstTimestamp - baselineTime;\n return firstTimestamp - baselineTime;\n }\n\n event.delay = event.timestamp - baselineTime;\n return event.delay;\n}\n","/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return{type:\"xstate.assign\",assignment:t}}function i(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){o=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]=\"function\"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o]})),r=n,!1}return!0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})))},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u=\"object\"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}export{n as InterpreterStatus,o as assign,s as createMachine,v as interpret};\n","import { createMachine, interpret, assign, StateMachine } from '@xstate/fsm';\nimport {\n playerConfig,\n eventWithTime,\n actionWithDelay,\n ReplayerEvents,\n EventType,\n Emitter,\n IncrementalSource,\n} from '../types';\nimport { Timer, addDelay } from './timer';\n\nexport type PlayerContext = {\n events: eventWithTime[];\n timer: Timer;\n timeOffset: number;\n baselineTime: number;\n lastPlayedEvent: eventWithTime | null;\n};\nexport type PlayerEvent =\n | {\n type: 'PLAY';\n payload: {\n timeOffset: number;\n };\n }\n | {\n type: 'CAST_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | { type: 'PAUSE' }\n | { type: 'TO_LIVE'; payload: { baselineTime?: number } }\n | {\n type: 'ADD_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | {\n type: 'END';\n };\nexport type PlayerState =\n | {\n value: 'playing';\n context: PlayerContext;\n }\n | {\n value: 'paused';\n context: PlayerContext;\n }\n | {\n value: 'live';\n context: PlayerContext;\n };\n\n/**\n * If the array have multiple meta and fullsnapshot events,\n * return the events from last meta to the end.\n */\nexport function discardPriorSnapshots(\n events: eventWithTime[],\n baselineTime: number,\n): eventWithTime[] {\n for (let idx = events.length - 1; idx >= 0; idx--) {\n const event = events[idx];\n if (event.type === EventType.Meta) {\n if (event.timestamp <= baselineTime) {\n return events.slice(idx);\n }\n }\n }\n return events;\n}\n\ntype PlayerAssets = {\n emitter: Emitter;\n applyEventsSynchronously(events: Array): void;\n getCastFn(event: eventWithTime, isSync: boolean): () => void;\n};\nexport function createPlayerService(\n context: PlayerContext,\n { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets,\n) {\n const playerMachine = createMachine(\n {\n id: 'player',\n context,\n initial: 'paused',\n states: {\n playing: {\n on: {\n PAUSE: {\n target: 'paused',\n actions: ['pause'],\n },\n CAST_EVENT: {\n target: 'playing',\n actions: 'castEvent',\n },\n END: {\n target: 'paused',\n actions: ['resetLastPlayedEvent', 'pause'],\n },\n ADD_EVENT: {\n target: 'playing',\n actions: ['addEvent'],\n },\n },\n },\n paused: {\n on: {\n PLAY: {\n target: 'playing',\n actions: ['recordTimeOffset', 'play'],\n },\n CAST_EVENT: {\n target: 'paused',\n actions: 'castEvent',\n },\n TO_LIVE: {\n target: 'live',\n actions: ['startLive'],\n },\n ADD_EVENT: {\n target: 'paused',\n actions: ['addEvent'],\n },\n },\n },\n live: {\n on: {\n ADD_EVENT: {\n target: 'live',\n actions: ['addEvent'],\n },\n CAST_EVENT: {\n target: 'live',\n actions: ['castEvent'],\n },\n },\n },\n },\n },\n {\n actions: {\n castEvent: assign({\n lastPlayedEvent: (ctx, event) => {\n if (event.type === 'CAST_EVENT') {\n return event.payload.event;\n }\n return ctx.lastPlayedEvent;\n },\n }),\n recordTimeOffset: assign((ctx, event) => {\n let timeOffset = ctx.timeOffset;\n if ('payload' in event && 'timeOffset' in event.payload) {\n timeOffset = event.payload.timeOffset;\n }\n return {\n ...ctx,\n timeOffset,\n baselineTime: ctx.events[0].timestamp + timeOffset,\n };\n }),\n play(ctx) {\n const { timer, events, baselineTime, lastPlayedEvent } = ctx;\n timer.clear();\n\n for (const event of events) {\n // TODO: improve this API\n addDelay(event, baselineTime);\n }\n const neededEvents = discardPriorSnapshots(events, baselineTime);\n\n let lastPlayedTimestamp = lastPlayedEvent?.timestamp;\n if (\n lastPlayedEvent?.type === EventType.IncrementalSnapshot &&\n lastPlayedEvent.data.source === IncrementalSource.MouseMove\n ) {\n lastPlayedTimestamp =\n lastPlayedEvent.timestamp +\n lastPlayedEvent.data.positions[0]?.timeOffset;\n }\n if (baselineTime < (lastPlayedTimestamp || 0)) {\n emitter.emit(ReplayerEvents.PlayBack);\n }\n\n const syncEvents = new Array();\n const actions = new Array();\n for (const event of neededEvents) {\n if (\n lastPlayedTimestamp &&\n lastPlayedTimestamp < baselineTime &&\n (event.timestamp <= lastPlayedTimestamp ||\n event === lastPlayedEvent)\n ) {\n continue;\n }\n if (event.timestamp < baselineTime) {\n syncEvents.push(event);\n } else {\n const castFn = getCastFn(event, false);\n actions.push({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n applyEventsSynchronously(syncEvents);\n emitter.emit(ReplayerEvents.Flush);\n timer.addActions(actions);\n timer.start();\n },\n pause(ctx) {\n ctx.timer.clear();\n },\n resetLastPlayedEvent: assign((ctx) => {\n return {\n ...ctx,\n lastPlayedEvent: null,\n };\n }),\n startLive: assign({\n baselineTime: (ctx, event) => {\n ctx.timer.toggleLiveMode(true);\n ctx.timer.start();\n if (event.type === 'TO_LIVE' && event.payload.baselineTime) {\n return event.payload.baselineTime;\n }\n return Date.now();\n },\n }),\n addEvent: assign((ctx, machineEvent) => {\n const { baselineTime, timer, events } = ctx;\n if (machineEvent.type === 'ADD_EVENT') {\n const { event } = machineEvent.payload;\n addDelay(event, baselineTime);\n\n let end = events.length - 1;\n if (!events[end] || events[end].timestamp <= event.timestamp) {\n // fast track\n events.push(event);\n } else {\n let insertionIndex = -1;\n let start = 0;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (events[mid].timestamp <= event.timestamp) {\n start = mid + 1;\n } else {\n end = mid - 1;\n }\n }\n if (insertionIndex === -1) {\n insertionIndex = start;\n }\n events.splice(insertionIndex, 0, event);\n }\n\n const isSync = event.timestamp < baselineTime;\n const castFn = getCastFn(event, isSync);\n if (isSync) {\n castFn();\n } else if (timer.isActive()) {\n timer.addAction({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n return { ...ctx, events };\n }),\n },\n },\n );\n return interpret(playerMachine);\n}\n\nexport type SpeedContext = {\n normalSpeed: playerConfig['speed'];\n timer: Timer;\n};\n\nexport type SpeedEvent =\n | {\n type: 'FAST_FORWARD';\n payload: { speed: playerConfig['speed'] };\n }\n | {\n type: 'BACK_TO_NORMAL';\n }\n | {\n type: 'SET_SPEED';\n payload: { speed: playerConfig['speed'] };\n };\n\nexport type SpeedState =\n | {\n value: 'normal';\n context: SpeedContext;\n }\n | {\n value: 'skipping';\n context: SpeedContext;\n };\n\nexport function createSpeedService(context: SpeedContext) {\n const speedMachine = createMachine(\n {\n id: 'speed',\n context,\n initial: 'normal',\n states: {\n normal: {\n on: {\n FAST_FORWARD: {\n target: 'skipping',\n actions: ['recordSpeed', 'setSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n skipping: {\n on: {\n BACK_TO_NORMAL: {\n target: 'normal',\n actions: ['restoreSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n },\n },\n {\n actions: {\n setSpeed: (ctx, event) => {\n if ('payload' in event) {\n ctx.timer.setSpeed(event.payload.speed);\n }\n },\n recordSpeed: assign({\n normalSpeed: (ctx) => ctx.timer.speed,\n }),\n restoreSpeed: (ctx) => {\n ctx.timer.setSpeed(ctx.normalSpeed);\n },\n },\n },\n );\n\n return interpret(speedMachine);\n}\n\nexport type PlayerMachineState = StateMachine.State<\n PlayerContext,\n PlayerEvent,\n PlayerState\n>;\n\nexport type SpeedMachineState = StateMachine.State<\n SpeedContext,\n SpeedEvent,\n SpeedState\n>;\n","const rules: (blockClass: string) => string[] = (blockClass: string) => [\n `.${blockClass} { background: currentColor }`,\n 'noscript { display: none !important; }',\n];\n\nexport default rules;\n","import { INode } from 'rrweb-snapshot';\n\nexport enum StyleRuleType {\n Insert,\n Remove,\n Snapshot,\n SetProperty,\n RemoveProperty,\n}\n\ntype InsertRule = {\n cssText: string;\n type: StyleRuleType.Insert;\n index?: number | number[];\n};\ntype RemoveRule = {\n type: StyleRuleType.Remove;\n index: number | number[];\n};\ntype SnapshotRule = {\n type: StyleRuleType.Snapshot;\n cssTexts: string[];\n};\ntype SetPropertyRule = {\n type: StyleRuleType.SetProperty;\n index: number[];\n property: string;\n value: string | null;\n priority: string | undefined;\n};\ntype RemovePropertyRule = {\n type: StyleRuleType.RemoveProperty;\n index: number[];\n property: string;\n};\n\nexport type VirtualStyleRules = Array<\n InsertRule | RemoveRule | SnapshotRule | SetPropertyRule | RemovePropertyRule\n>;\nexport type VirtualStyleRulesMap = Map;\n\nexport function getNestedRule(\n rules: CSSRuleList,\n position: number[],\n): CSSGroupingRule {\n const rule = rules[position[0]] as CSSGroupingRule;\n if (position.length === 1) {\n return rule;\n } else {\n return getNestedRule(\n ((rule as CSSGroupingRule).cssRules[position[1]] as CSSGroupingRule)\n .cssRules,\n position.slice(2),\n );\n }\n}\n\nexport function getPositionsAndIndex(nestedIndex: number[]) {\n const positions = [...nestedIndex];\n const index = positions.pop();\n return { positions, index };\n}\n\nexport function applyVirtualStyleRulesToNode(\n storedRules: VirtualStyleRules,\n styleNode: HTMLStyleElement,\n) {\n const { sheet } = styleNode;\n if (!sheet) {\n // styleNode without sheet means the DOM has been removed\n // so the rules no longer need to be applied\n return;\n }\n\n storedRules.forEach((rule) => {\n if (rule.type === StyleRuleType.Insert) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.insertRule(rule.cssText, index);\n } else {\n sheet.insertRule(rule.cssText, rule.index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n } else if (rule.type === StyleRuleType.Remove) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.deleteRule(index || 0);\n } else {\n sheet.deleteRule(rule.index);\n }\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else if (rule.type === StyleRuleType.Snapshot) {\n restoreSnapshotOfStyleRulesToNode(rule.cssTexts, styleNode);\n } else if (rule.type === StyleRuleType.SetProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.setProperty(rule.property, rule.value, rule.priority);\n } else if (rule.type === StyleRuleType.RemoveProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.removeProperty(rule.property);\n }\n });\n}\n\nfunction restoreSnapshotOfStyleRulesToNode(\n cssTexts: string[],\n styleNode: HTMLStyleElement,\n) {\n try {\n const existingRules = Array.from(styleNode.sheet?.cssRules || []).map(\n (rule) => rule.cssText,\n );\n const existingRulesReversed = Object.entries(existingRules).reverse();\n let lastMatch = existingRules.length;\n existingRulesReversed.forEach(([index, rule]) => {\n const indexOf = cssTexts.indexOf(rule);\n if (indexOf === -1 || indexOf > lastMatch) {\n try {\n styleNode.sheet?.deleteRule(Number(index));\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n }\n lastMatch = indexOf;\n });\n cssTexts.forEach((cssText, index) => {\n try {\n if (styleNode.sheet?.cssRules[index]?.cssText !== cssText) {\n styleNode.sheet?.insertRule(cssText, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n });\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n\nexport function storeCSSRules(\n parentElement: HTMLStyleElement,\n virtualStyleRulesMap: VirtualStyleRulesMap,\n) {\n try {\n const cssTexts = Array.from(\n (parentElement as HTMLStyleElement).sheet?.cssRules || [],\n ).map((rule) => rule.cssText);\n virtualStyleRulesMap.set((parentElement as unknown) as INode, [\n {\n type: StyleRuleType.Snapshot,\n cssTexts,\n },\n ]);\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n","import { decode } from 'base64-arraybuffer';\nimport { Replayer } from '../';\nimport {\n CanvasContext,\n canvasMutationCommand,\n SerializedWebGlArg,\n} from '../../types';\n\n// TODO: add ability to wipe this list\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nfunction getContext(\n target: HTMLCanvasElement,\n type: CanvasContext,\n): WebGLRenderingContext | WebGL2RenderingContext | null {\n // Note to whomever is going to implement support for `contextAttributes`:\n // if `preserveDrawingBuffer` is set to true,\n // you might have to do `ctx.flush()` before every webgl canvas event\n try {\n if (type === CanvasContext.WebGL) {\n return (\n target.getContext('webgl')! || target.getContext('experimental-webgl')\n );\n }\n return target.getContext('webgl2')!;\n } catch (e) {\n return null;\n }\n}\n\nconst WebGLVariableConstructorsNames = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n];\n\nfunction saveToWebGLVarMap(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n result: any,\n) {\n if (!result?.constructor) return; // probably null or undefined\n\n const { name } = result.constructor;\n if (!WebGLVariableConstructorsNames.includes(name)) return; // not a WebGL variable\n\n const variables = variableListFor(ctx, name);\n if (!variables.includes(result)) variables.push(result);\n}\n\nexport function deserializeArg(\n imageMap: Replayer['imageMap'],\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n): (arg: SerializedWebGlArg) => any {\n return (arg: SerializedWebGlArg): any => {\n if (arg && typeof arg === 'object' && 'rr_type' in arg) {\n if ('index' in arg) {\n const { rr_type: name, index } = arg;\n return variableListFor(ctx, name)[index];\n } else if ('args' in arg) {\n const { rr_type: name, args } = arg;\n const ctor = window[name as keyof Window];\n\n return new ctor(...args.map(deserializeArg(imageMap, ctx)));\n } else if ('base64' in arg) {\n return decode(arg.base64);\n } else if ('src' in arg) {\n const image = imageMap.get(arg.src);\n if (image) {\n return image;\n } else {\n const image = new Image();\n image.src = arg.src;\n imageMap.set(arg.src, image);\n return image;\n }\n }\n } else if (Array.isArray(arg)) {\n return arg.map(deserializeArg(imageMap, ctx));\n }\n return arg;\n };\n}\n\nexport default function webglMutation({\n mutation,\n target,\n type,\n imageMap,\n errorHandler,\n}: {\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n type: CanvasContext;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = getContext(target, type);\n if (!ctx) return;\n\n // NOTE: if `preserveDrawingBuffer` is set to true,\n // we must flush the buffers on every new canvas event\n // if (mutation.newFrame) ctx.flush();\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n const args = mutation.args.map(deserializeArg(imageMap, ctx));\n const result = original.apply(ctx, args);\n saveToWebGLVarMap(ctx, result);\n\n // Slows down replay considerably, only use for debugging\n const debugMode = false;\n if (debugMode) {\n if (mutation.property === 'compileShader') {\n if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getShaderInfoLog(args[0]),\n );\n } else if (mutation.property === 'linkProgram') {\n ctx.validateProgram(args[0]);\n if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getProgramInfoLog(args[0]),\n );\n }\n const webglError = ctx.getError();\n if (webglError !== ctx.NO_ERROR) {\n console.warn(\n 'WEBGL ERROR',\n webglError,\n 'on command:',\n mutation.property,\n ...args,\n );\n }\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import {\n rebuild,\n buildNodeWithSN,\n INode,\n NodeType,\n BuildCache,\n createCache,\n} from 'rrweb-snapshot';\nimport * as mittProxy from 'mitt';\nimport { polyfill as smoothscrollPolyfill } from './smoothscroll';\nimport { Timer } from './timer';\nimport { createPlayerService, createSpeedService } from './machine';\nimport {\n EventType,\n IncrementalSource,\n fullSnapshotEvent,\n eventWithTime,\n MouseInteractions,\n playerConfig,\n playerMetaData,\n viewportResizeDimension,\n missingNodeMap,\n addedNodeMutation,\n missingNode,\n incrementalSnapshotEvent,\n incrementalData,\n ReplayerEvents,\n Handler,\n Emitter,\n MediaInteractions,\n metaEvent,\n mutationData,\n scrollData,\n inputData,\n canvasMutationData,\n Mirror,\n ElementState,\n styleAttributeValue,\n styleValueWithPriority,\n mouseMovePos,\n IWindow,\n canvasMutationCommand,\n textMutation,\n} from '../types';\nimport {\n createMirror,\n polyfill,\n TreeIndex,\n queueToResolveTrees,\n iterateResolveTree,\n AppendedIframe,\n isIframeINode,\n getBaseDimension,\n hasShadowRoot,\n} from '../utils';\nimport getInjectStyleRules from './styles/inject-style';\nimport './styles/style.css';\nimport {\n applyVirtualStyleRulesToNode,\n storeCSSRules,\n StyleRuleType,\n VirtualStyleRules,\n VirtualStyleRulesMap,\n getNestedRule,\n getPositionsAndIndex,\n} from './virtual-styles';\nimport canvasMutation from './canvas';\n\nconst SKIP_TIME_THRESHOLD = 10 * 1000;\nconst SKIP_TIME_INTERVAL = 5 * 1000;\n\n// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734\n// tslint:disable-next-line\nconst mitt = (mittProxy as any).default || mittProxy;\n\nconst REPLAY_CONSOLE_PREFIX = '[replayer]';\n\nconst defaultMouseTailConfig = {\n duration: 500,\n lineCap: 'round',\n lineWidth: 3,\n strokeStyle: 'red',\n} as const;\n\nfunction indicatesTouchDevice(e: eventWithTime) {\n return (\n e.type == EventType.IncrementalSnapshot &&\n (e.data.source == IncrementalSource.TouchMove ||\n (e.data.source == IncrementalSource.MouseInteraction &&\n e.data.type == MouseInteractions.TouchStart))\n );\n}\n\nexport class Replayer {\n public wrapper: HTMLDivElement;\n public iframe: HTMLIFrameElement;\n\n public service: ReturnType;\n public speedService: ReturnType;\n public get timer() {\n return this.service.state.context.timer;\n }\n\n public config: playerConfig;\n\n private mouse: HTMLDivElement;\n private mouseTail: HTMLCanvasElement | null = null;\n private tailPositions: Array<{ x: number; y: number }> = [];\n\n private emitter: Emitter = mitt();\n\n private nextUserInteractionEvent: eventWithTime | null;\n\n // tslint:disable-next-line: variable-name\n private legacy_missingNodeRetryMap: missingNodeMap = {};\n\n private treeIndex!: TreeIndex;\n private fragmentParentMap!: Map;\n private elementStateMap!: Map;\n // Hold the list of CSSRules for in-memory state restoration\n private virtualStyleRulesMap!: VirtualStyleRulesMap;\n\n // The replayer uses the cache to speed up replay and scrubbing.\n private cache: BuildCache = createCache();\n\n private imageMap: Map = new Map();\n\n private mirror: Mirror = createMirror();\n\n private firstFullSnapshot: eventWithTime | true | null = null;\n\n private newDocumentQueue: addedNodeMutation[] = [];\n\n private mousePos: mouseMovePos | null = null;\n private touchActive: boolean | null = null;\n\n constructor(\n events: Array,\n config?: Partial,\n ) {\n if (!config?.liveMode && events.length < 2) {\n throw new Error('Replayer need at least 2 events.');\n }\n const defaultConfig: playerConfig = {\n speed: 1,\n maxSpeed: 360,\n root: document.body,\n loadTimeout: 0,\n skipInactive: false,\n showWarning: true,\n showDebug: false,\n blockClass: 'rr-block',\n liveMode: false,\n insertStyleRules: [],\n triggerFocus: true,\n UNSAFE_replayCanvas: false,\n pauseAnimation: true,\n mouseTail: defaultMouseTailConfig,\n };\n this.config = Object.assign({}, defaultConfig, config);\n\n this.handleResize = this.handleResize.bind(this);\n this.getCastFn = this.getCastFn.bind(this);\n this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);\n this.emitter.on(ReplayerEvents.Resize, this.handleResize as Handler);\n\n this.setupDom();\n\n this.treeIndex = new TreeIndex();\n this.fragmentParentMap = new Map();\n this.elementStateMap = new Map();\n this.virtualStyleRulesMap = new Map();\n\n this.emitter.on(ReplayerEvents.Flush, () => {\n const { scrollMap, inputMap, mutationData } = this.treeIndex.flush();\n\n this.fragmentParentMap.forEach((parent, frag) =>\n this.restoreRealParent(frag, parent),\n );\n // apply text needs to happen before virtual style rules gets applied\n // as it can overwrite the contents of a stylesheet\n for (const d of mutationData.texts) {\n this.applyText(d, mutationData);\n }\n\n for (const node of this.virtualStyleRulesMap.keys()) {\n // restore css rules of style elements after they are mounted\n this.restoreNodeSheet(node);\n }\n this.fragmentParentMap.clear();\n this.elementStateMap.clear();\n this.virtualStyleRulesMap.clear();\n\n for (const d of scrollMap.values()) {\n this.applyScroll(d, true);\n }\n for (const d of inputMap.values()) {\n this.applyInput(d);\n }\n });\n this.emitter.on(ReplayerEvents.PlayBack, () => {\n this.firstFullSnapshot = null;\n this.mirror.reset();\n });\n\n const timer = new Timer([], config?.speed || defaultConfig.speed);\n this.service = createPlayerService(\n {\n events: events\n .map((e) => {\n if (config && config.unpackFn) {\n return config.unpackFn(e as string);\n }\n return e as eventWithTime;\n })\n .sort((a1, a2) => a1.timestamp - a2.timestamp),\n timer,\n timeOffset: 0,\n baselineTime: 0,\n lastPlayedEvent: null,\n },\n {\n getCastFn: this.getCastFn,\n applyEventsSynchronously: this.applyEventsSynchronously,\n emitter: this.emitter,\n },\n );\n this.service.start();\n this.service.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n player: state,\n });\n });\n this.speedService = createSpeedService({\n normalSpeed: -1,\n timer,\n });\n this.speedService.start();\n this.speedService.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n speed: state,\n });\n });\n\n // rebuild first full snapshot as the poster of the player\n // maybe we can cache it for performance optimization\n const firstMeta = this.service.state.context.events.find(\n (e) => e.type === EventType.Meta,\n );\n const firstFullsnapshot = this.service.state.context.events.find(\n (e) => e.type === EventType.FullSnapshot,\n );\n if (firstMeta) {\n const { width, height } = firstMeta.data as metaEvent['data'];\n setTimeout(() => {\n this.emitter.emit(ReplayerEvents.Resize, {\n width,\n height,\n });\n }, 0);\n }\n if (firstFullsnapshot) {\n setTimeout(() => {\n // when something has been played, there is no need to rebuild poster\n if (this.firstFullSnapshot) {\n // true if any other fullSnapshot has been executed by Timer already\n return;\n }\n this.firstFullSnapshot = firstFullsnapshot;\n this.rebuildFullSnapshot(\n firstFullsnapshot as fullSnapshotEvent & { timestamp: number },\n );\n this.iframe.contentWindow!.scrollTo(\n (firstFullsnapshot as fullSnapshotEvent).data.initialOffset,\n );\n }, 1);\n }\n if (this.service.state.context.events.find(indicatesTouchDevice)) {\n this.mouse.classList.add('touch-device');\n }\n }\n\n public on(event: string, handler: Handler) {\n this.emitter.on(event, handler);\n return this;\n }\n\n public off(event: string, handler: Handler) {\n this.emitter.off(event, handler);\n return this;\n }\n\n public setConfig(config: Partial) {\n Object.keys(config).forEach((key) => {\n // @ts-ignore\n this.config[key] = config[key];\n });\n if (!this.config.skipInactive) {\n this.backToNormal();\n }\n if (typeof config.speed !== 'undefined') {\n this.speedService.send({\n type: 'SET_SPEED',\n payload: {\n speed: config.speed!,\n },\n });\n }\n if (typeof config.mouseTail !== 'undefined') {\n if (config.mouseTail === false) {\n if (this.mouseTail) {\n this.mouseTail.style.display = 'none';\n }\n } else {\n if (!this.mouseTail) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.width = Number.parseFloat(this.iframe.width);\n this.mouseTail.height = Number.parseFloat(this.iframe.height);\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.wrapper.insertBefore(this.mouseTail, this.iframe);\n }\n this.mouseTail.style.display = 'inherit';\n }\n }\n }\n\n public getMetaData(): playerMetaData {\n const firstEvent = this.service.state.context.events[0];\n const lastEvent = this.service.state.context.events[\n this.service.state.context.events.length - 1\n ];\n return {\n startTime: firstEvent.timestamp,\n endTime: lastEvent.timestamp,\n totalTime: lastEvent.timestamp - firstEvent.timestamp,\n };\n }\n\n public getCurrentTime(): number {\n return this.timer.timeOffset + this.getTimeOffset();\n }\n\n public getTimeOffset(): number {\n const { baselineTime, events } = this.service.state.context;\n return baselineTime - events[0].timestamp;\n }\n\n public getMirror(): Mirror {\n return this.mirror;\n }\n\n /**\n * This API was designed to be used as play at any time offset.\n * Since we minimized the data collected from recorder, we do not\n * have the ability of undo an event.\n * So the implementation of play at any time offset will always iterate\n * all of the events, cast event before the offset synchronously\n * and cast event after the offset asynchronously with timer.\n * @param timeOffset number\n */\n public play(timeOffset = 0) {\n if (this.service.state.matches('paused')) {\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n } else {\n this.service.send({ type: 'PAUSE' });\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.remove('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Start);\n }\n\n public pause(timeOffset?: number) {\n if (timeOffset === undefined && this.service.state.matches('playing')) {\n this.service.send({ type: 'PAUSE' });\n }\n if (typeof timeOffset === 'number') {\n this.play(timeOffset);\n this.service.send({ type: 'PAUSE' });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Pause);\n }\n\n public resume(timeOffset = 0) {\n console.warn(\n `The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.`,\n );\n this.play(timeOffset);\n this.emitter.emit(ReplayerEvents.Resume);\n }\n\n public startLive(baselineTime?: number) {\n this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });\n }\n\n public addEvent(rawEvent: eventWithTime | string) {\n const event = this.config.unpackFn\n ? this.config.unpackFn(rawEvent as string)\n : (rawEvent as eventWithTime);\n if (indicatesTouchDevice(event)) {\n this.mouse.classList.add('touch-device');\n }\n Promise.resolve().then(() =>\n this.service.send({ type: 'ADD_EVENT', payload: { event } }),\n );\n }\n\n public enableInteract() {\n this.iframe.setAttribute('scrolling', 'auto');\n this.iframe.style.pointerEvents = 'auto';\n }\n\n public disableInteract() {\n this.iframe.setAttribute('scrolling', 'no');\n this.iframe.style.pointerEvents = 'none';\n }\n\n /**\n * Empties the replayer's cache and reclaims memory.\n * The replayer will use this cache to speed up the playback.\n */\n public resetCache() {\n this.cache = createCache();\n }\n\n private setupDom() {\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add('replayer-wrapper');\n this.config.root!.appendChild(this.wrapper);\n\n this.mouse = document.createElement('div');\n this.mouse.classList.add('replayer-mouse');\n this.wrapper.appendChild(this.mouse);\n\n if (this.config.mouseTail !== false) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.mouseTail.style.display = 'inherit';\n this.wrapper.appendChild(this.mouseTail);\n }\n\n this.iframe = document.createElement('iframe');\n const attributes = ['allow-same-origin'];\n if (this.config.UNSAFE_replayCanvas) {\n attributes.push('allow-scripts');\n }\n // hide iframe before first meta event\n this.iframe.style.display = 'none';\n this.iframe.setAttribute('sandbox', attributes.join(' '));\n this.disableInteract();\n this.wrapper.appendChild(this.iframe);\n if (this.iframe.contentWindow && this.iframe.contentDocument) {\n smoothscrollPolyfill(\n this.iframe.contentWindow,\n this.iframe.contentDocument,\n );\n\n polyfill(this.iframe.contentWindow as IWindow);\n }\n }\n\n private handleResize(dimension: viewportResizeDimension) {\n this.iframe.style.display = 'inherit';\n for (const el of [this.mouseTail, this.iframe]) {\n if (!el) {\n continue;\n }\n el.setAttribute('width', String(dimension.width));\n el.setAttribute('height', String(dimension.height));\n }\n }\n\n private applyEventsSynchronously(events: Array) {\n for (const event of events) {\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n case EventType.Custom:\n continue;\n case EventType.FullSnapshot:\n case EventType.Meta:\n case EventType.Plugin:\n break;\n case EventType.IncrementalSnapshot:\n switch (event.data.source) {\n case IncrementalSource.MediaInteraction:\n continue;\n default:\n break;\n }\n break;\n default:\n break;\n }\n const castFn = this.getCastFn(event, true);\n castFn();\n }\n if (this.mousePos) {\n this.moveAndHover(\n this.mousePos.x,\n this.mousePos.y,\n this.mousePos.id,\n true,\n this.mousePos.debugData,\n );\n }\n this.mousePos = null;\n if (this.touchActive === true) {\n this.mouse.classList.add('touch-active');\n } else if (this.touchActive === false) {\n this.mouse.classList.remove('touch-active');\n }\n this.touchActive = null;\n }\n\n private getCastFn(event: eventWithTime, isSync = false) {\n let castFn: undefined | (() => void);\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n break;\n case EventType.Custom:\n castFn = () => {\n /**\n * emit custom-event and pass the event object.\n *\n * This will add more value to the custom event and allows the client to react for custom-event.\n */\n this.emitter.emit(ReplayerEvents.CustomEvent, event);\n };\n break;\n case EventType.Meta:\n castFn = () =>\n this.emitter.emit(ReplayerEvents.Resize, {\n width: event.data.width,\n height: event.data.height,\n });\n break;\n case EventType.FullSnapshot:\n castFn = () => {\n if (this.firstFullSnapshot) {\n if (this.firstFullSnapshot === event) {\n // we've already built this exact FullSnapshot when the player was mounted, and haven't built any other FullSnapshot since\n this.firstFullSnapshot = true; // forget as we might need to re-execute this FullSnapshot later e.g. to rebuild after scrubbing\n return;\n }\n } else {\n // Timer (requestAnimationFrame) can be faster than setTimeout(..., 1)\n this.firstFullSnapshot = true;\n }\n this.rebuildFullSnapshot(event, isSync);\n this.iframe.contentWindow!.scrollTo(event.data.initialOffset);\n };\n break;\n case EventType.IncrementalSnapshot:\n castFn = () => {\n this.applyIncremental(event, isSync);\n if (isSync) {\n // do not check skip in sync\n return;\n }\n if (event === this.nextUserInteractionEvent) {\n this.nextUserInteractionEvent = null;\n this.backToNormal();\n }\n if (this.config.skipInactive && !this.nextUserInteractionEvent) {\n for (const _event of this.service.state.context.events) {\n if (_event.timestamp! <= event.timestamp!) {\n continue;\n }\n if (this.isUserInteraction(_event)) {\n if (\n _event.delay! - event.delay! >\n SKIP_TIME_THRESHOLD *\n this.speedService.state.context.timer.speed\n ) {\n this.nextUserInteractionEvent = _event;\n }\n break;\n }\n }\n if (this.nextUserInteractionEvent) {\n const skipTime =\n this.nextUserInteractionEvent.delay! - event.delay!;\n const payload = {\n speed: Math.min(\n Math.round(skipTime / SKIP_TIME_INTERVAL),\n this.config.maxSpeed,\n ),\n };\n this.speedService.send({ type: 'FAST_FORWARD', payload });\n this.emitter.emit(ReplayerEvents.SkipStart, payload);\n }\n }\n };\n break;\n default:\n }\n const wrappedCastFn = () => {\n if (castFn) {\n castFn();\n }\n\n for (const plugin of this.config.plugins || []) {\n plugin.handler(event, isSync, { replayer: this });\n }\n\n this.service.send({ type: 'CAST_EVENT', payload: { event } });\n\n // events are kept sorted by timestamp, check if this is the last event\n let last_index = this.service.state.context.events.length - 1;\n if (event === this.service.state.context.events[last_index]) {\n const finish = () => {\n if (last_index < this.service.state.context.events.length - 1) {\n // more events have been added since the setTimeout\n return;\n }\n this.backToNormal();\n this.service.send('END');\n this.emitter.emit(ReplayerEvents.Finish);\n };\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove &&\n event.data.positions.length\n ) {\n // defer finish event if the last event is a mouse move\n setTimeout(() => {\n finish();\n }, Math.max(0, -event.data.positions[0].timeOffset + 50)); // Add 50 to make sure the timer would check the last mousemove event. Otherwise, the timer may be stopped by the service before checking the last event.\n } else {\n finish();\n }\n }\n\n this.emitter.emit(ReplayerEvents.EventCast, event);\n };\n return wrappedCastFn;\n }\n\n private rebuildFullSnapshot(\n event: fullSnapshotEvent & { timestamp: number },\n isSync: boolean = false,\n ) {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n console.warn(\n 'Found unresolved missing node map',\n this.legacy_missingNodeRetryMap,\n );\n }\n this.legacy_missingNodeRetryMap = {};\n const collected: AppendedIframe[] = [];\n this.mirror.map = rebuild(event.data.node, {\n doc: this.iframe.contentDocument,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n },\n cache: this.cache,\n })[1];\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n const { documentElement, head } = this.iframe.contentDocument;\n this.insertStyleRules(documentElement, head);\n if (!this.service.state.matches('playing')) {\n this.iframe.contentDocument\n .getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n }\n this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);\n if (!isSync) {\n this.waitForStylesheetLoad();\n }\n if (this.config.UNSAFE_replayCanvas) {\n this.preloadAllImages();\n }\n }\n\n private insertStyleRules(\n documentElement: HTMLElement,\n head: HTMLHeadElement,\n ) {\n const styleEl = document.createElement('style');\n documentElement!.insertBefore(styleEl, head);\n const injectStylesRules = getInjectStyleRules(\n this.config.blockClass,\n ).concat(this.config.insertStyleRules);\n if (this.config.pauseAnimation) {\n injectStylesRules.push(\n 'html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }',\n );\n }\n for (let idx = 0; idx < injectStylesRules.length; idx++) {\n (styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);\n }\n }\n\n private attachDocumentToIframe(\n mutation: addedNodeMutation,\n iframeEl: HTMLIFrameElement,\n ) {\n const collected: AppendedIframe[] = [];\n // If iframeEl is detached from dom, iframeEl.contentDocument is null.\n if (!iframeEl.contentDocument) {\n let parent = iframeEl.parentNode;\n while (parent) {\n // The parent of iframeEl is virtual parent and we need to mount it on the dom.\n if (this.fragmentParentMap.has((parent as unknown) as INode)) {\n const frag = (parent as unknown) as INode;\n const realParent = this.fragmentParentMap.get(frag)!;\n this.restoreRealParent(frag, realParent);\n break;\n }\n parent = parent.parentNode;\n }\n }\n buildNodeWithSN(mutation.node, {\n doc: iframeEl.contentDocument!,\n map: this.mirror.map,\n hackCss: true,\n skipChild: false,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n if (\n builtNode.__sn.type === NodeType.Element &&\n builtNode.__sn.tagName.toUpperCase() === 'HTML'\n ) {\n const { documentElement, head } = iframeEl.contentDocument!;\n this.insertStyleRules(documentElement, head);\n }\n },\n cache: this.cache,\n });\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n private collectIframeAndAttachDocument(\n collected: AppendedIframe[],\n builtNode: INode,\n ) {\n if (isIframeINode(builtNode)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === builtNode.__sn.id,\n );\n if (mutationInQueue) {\n collected.push({ mutationInQueue, builtNode });\n }\n }\n }\n\n /**\n * pause when loading style sheet, resume when loaded all timeout exceed\n */\n private waitForStylesheetLoad() {\n const head = this.iframe.contentDocument?.head;\n if (head) {\n const unloadSheets: Set = new Set();\n let timer: ReturnType | -1;\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n const unsubscribe = () => {\n this.emitter.off(ReplayerEvents.Start, stateHandler);\n this.emitter.off(ReplayerEvents.Pause, stateHandler);\n };\n head\n .querySelectorAll('link[rel=\"stylesheet\"]')\n .forEach((css: HTMLLinkElement) => {\n if (!css.sheet) {\n unloadSheets.add(css);\n css.addEventListener('load', () => {\n unloadSheets.delete(css);\n // all loaded and timer not released yet\n if (unloadSheets.size === 0 && timer !== -1) {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);\n if (timer) {\n clearTimeout(timer);\n }\n unsubscribe();\n }\n });\n }\n });\n\n if (unloadSheets.size > 0) {\n // find some unload sheets after iterate\n this.service.send({ type: 'PAUSE' });\n this.emitter.emit(ReplayerEvents.LoadStylesheetStart);\n timer = setTimeout(() => {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n // mark timer was called\n timer = -1;\n unsubscribe();\n }, this.config.loadTimeout);\n }\n }\n }\n\n private hasImageArg(args: any[]): boolean {\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n if (this.hasImageArg(arg.args)) return true;\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n return true; // has image!\n } else if (arg instanceof Array) {\n if (this.hasImageArg(arg)) return true;\n }\n }\n return false;\n }\n\n private getImageArgs(args: any[]): string[] {\n const images: string[] = [];\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n images.push(...this.getImageArgs(arg.args));\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n images.push(arg.src);\n } else if (arg instanceof Array) {\n images.push(...this.getImageArgs(arg));\n }\n }\n return images;\n }\n\n /**\n * pause when there are some canvas drawImage args need to be loaded\n */\n private preloadAllImages() {\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n for (const event of this.service.state.context.events) {\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.CanvasMutation\n )\n if ('commands' in event.data) {\n event.data.commands.forEach((c) => this.preloadImages(c, event));\n } else {\n this.preloadImages(event.data, event);\n }\n }\n }\n\n private preloadImages(data: canvasMutationCommand, event: eventWithTime) {\n if (\n data.property === 'drawImage' &&\n typeof data.args[0] === 'string' &&\n !this.imageMap.has(event)\n ) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const imgd = ctx?.createImageData(canvas.width, canvas.height);\n let d = imgd?.data;\n d = JSON.parse(data.args[0]);\n ctx?.putImageData(imgd!, 0, 0);\n } else if (this.hasImageArg(data.args)) {\n this.getImageArgs(data.args).forEach((url) => {\n const image = new Image();\n image.src = url; // this preloads the image\n this.imageMap.set(url, image);\n });\n }\n }\n\n private applyIncremental(\n e: incrementalSnapshotEvent & { timestamp: number; delay?: number },\n isSync: boolean,\n ) {\n const { data: d } = e;\n switch (d.source) {\n case IncrementalSource.Mutation: {\n if (isSync) {\n d.adds.forEach((m) => this.treeIndex.add(m));\n d.texts.forEach((m) => {\n const target = this.mirror.getNode(m.id);\n const parent = (target?.parentNode as unknown) as INode | null;\n // remove any style rules that pending\n // for stylesheets where the contents get replaced\n if (parent && this.virtualStyleRulesMap.has(parent))\n this.virtualStyleRulesMap.delete(parent);\n\n this.treeIndex.text(m);\n });\n d.attributes.forEach((m) => this.treeIndex.attribute(m));\n d.removes.forEach((m) => this.treeIndex.remove(m, this.mirror));\n }\n try {\n this.applyMutation(d, isSync);\n } catch (error) {\n this.warn(`Exception in mutation ${error.message || error}`, d);\n }\n break;\n }\n case IncrementalSource.Drag:\n case IncrementalSource.TouchMove:\n case IncrementalSource.MouseMove:\n if (isSync) {\n const lastPosition = d.positions[d.positions.length - 1];\n this.mousePos = {\n x: lastPosition.x,\n y: lastPosition.y,\n id: lastPosition.id,\n debugData: d,\n };\n } else {\n d.positions.forEach((p) => {\n const action = {\n doAction: () => {\n this.moveAndHover(p.x, p.y, p.id, isSync, d);\n },\n delay:\n p.timeOffset +\n e.timestamp -\n this.service.state.context.baselineTime,\n };\n this.timer.addAction(action);\n });\n // add a dummy action to keep timer alive\n this.timer.addAction({\n doAction() {},\n delay: e.delay! - d.positions[0]?.timeOffset,\n });\n }\n break;\n case IncrementalSource.MouseInteraction: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n const event = new Event(MouseInteractions[d.type].toLowerCase());\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n this.emitter.emit(ReplayerEvents.MouseInteraction, {\n type: d.type,\n target,\n });\n const { triggerFocus } = this.config;\n switch (d.type) {\n case MouseInteractions.Blur:\n if ('blur' in ((target as Node) as HTMLElement)) {\n ((target as Node) as HTMLElement).blur();\n }\n break;\n case MouseInteractions.Focus:\n if (triggerFocus && ((target as Node) as HTMLElement).focus) {\n ((target as Node) as HTMLElement).focus({\n preventScroll: true,\n });\n }\n break;\n case MouseInteractions.Click:\n case MouseInteractions.TouchStart:\n case MouseInteractions.TouchEnd:\n if (isSync) {\n if (d.type === MouseInteractions.TouchStart) {\n this.touchActive = true;\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.touchActive = false;\n }\n this.mousePos = {\n x: d.x,\n y: d.y,\n id: d.id,\n debugData: d,\n };\n } else {\n if (d.type === MouseInteractions.TouchStart) {\n // don't draw a trail as user has lifted finger and is placing at a new point\n this.tailPositions.length = 0;\n }\n this.moveAndHover(d.x, d.y, d.id, isSync, d);\n if (d.type === MouseInteractions.Click) {\n /*\n * don't want target.click() here as could trigger an iframe navigation\n * instead any effects of the click should already be covered by mutations\n */\n /*\n * removal and addition of .active class (along with void line to trigger repaint)\n * triggers the 'click' css animation in styles/style.css\n */\n this.mouse.classList.remove('active');\n // tslint:disable-next-line\n void this.mouse.offsetWidth;\n this.mouse.classList.add('active');\n } else if (d.type === MouseInteractions.TouchStart) {\n void this.mouse.offsetWidth; // needed for the position update of moveAndHover to apply without the .touch-active transition\n this.mouse.classList.add('touch-active');\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.mouse.classList.remove('touch-active');\n }\n }\n break;\n case MouseInteractions.TouchCancel:\n if (isSync) {\n this.touchActive = false;\n } else {\n this.mouse.classList.remove('touch-active');\n }\n break;\n default:\n target.dispatchEvent(event);\n }\n break;\n }\n case IncrementalSource.Scroll: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.scroll(d);\n break;\n }\n this.applyScroll(d, false);\n break;\n }\n case IncrementalSource.ViewportResize:\n this.emitter.emit(ReplayerEvents.Resize, {\n width: d.width,\n height: d.height,\n });\n break;\n case IncrementalSource.Input: {\n /**\n * Input event on an unserialized node usually means the event\n * was synchrony triggered programmatically after the node was\n * created. This means there was not an user observable interaction\n * and we do not need to replay it.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.input(d);\n break;\n }\n this.applyInput(d);\n break;\n }\n case IncrementalSource.MediaInteraction: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n const mediaEl = (target as Node) as HTMLMediaElement;\n try {\n if (d.currentTime) {\n mediaEl.currentTime = d.currentTime;\n }\n if (d.volume) {\n mediaEl.volume = d.volume;\n }\n if (d.muted) {\n mediaEl.muted = d.muted;\n }\n if (d.type === MediaInteractions.Pause) {\n mediaEl.pause();\n }\n if (d.type === MediaInteractions.Play) {\n // remove listener for 'canplay' event because play() is async and returns a promise\n // i.e. media will evntualy start to play when data is loaded\n // 'canplay' event fires even when currentTime attribute changes which may lead to\n // unexpeted behavior\n mediaEl.play();\n }\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n `Failed to replay media interactions: ${error.message || error}`,\n );\n }\n }\n break;\n }\n case IncrementalSource.StyleSheetRule: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n /**\n * Always use existing DOM node, when it's there.\n * In in-memory replay, there is virtual node, but it's `sheet` is inaccessible.\n * Hence, we buffer all style changes in virtualStyleRulesMap.\n */\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules;\n\n if (!styleSheet) {\n /**\n * styleEl.sheet is only accessible if the styleEl is part of the\n * dom. This doesn't work on DocumentFragments so we have to add the\n * style mutations to the virtualStyleRulesMap.\n */\n\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.adds) {\n d.adds.forEach(({ rule, index: nestedIndex }) => {\n if (styleSheet) {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet.cssRules,\n positions,\n );\n nestedRule.insertRule(rule, index);\n } else {\n const index =\n nestedIndex === undefined\n ? undefined\n : Math.min(nestedIndex, styleSheet.cssRules.length);\n styleSheet.insertRule(rule, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else {\n rules?.push({\n cssText: rule,\n index: nestedIndex,\n type: StyleRuleType.Insert,\n });\n }\n });\n }\n\n if (d.removes) {\n d.removes.forEach(({ index: nestedIndex }) => {\n if (usingVirtualParent) {\n rules?.push({ index: nestedIndex, type: StyleRuleType.Remove });\n } else {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet!.cssRules,\n positions,\n );\n nestedRule.deleteRule(index || 0);\n } else {\n styleSheet?.deleteRule(nestedIndex);\n }\n } catch (e) {\n /**\n * same as insertRule\n */\n }\n }\n });\n }\n break;\n }\n case IncrementalSource.StyleDeclaration: {\n // same with StyleSheetRule\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules = [];\n\n if (!styleSheet) {\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.set) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.setProperty(d.set.property, d.set.value, d.set.priority);\n } else {\n rules.push({\n type: StyleRuleType.SetProperty,\n index: d.index,\n ...d.set,\n });\n }\n }\n\n if (d.remove) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.removeProperty(d.remove.property);\n } else {\n rules.push({\n type: StyleRuleType.RemoveProperty,\n index: d.index,\n ...d.remove,\n });\n }\n }\n break;\n }\n case IncrementalSource.CanvasMutation: {\n if (!this.config.UNSAFE_replayCanvas) {\n return;\n }\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n canvasMutation({\n event: e,\n mutation: d,\n target: (target as unknown) as HTMLCanvasElement,\n imageMap: this.imageMap,\n errorHandler: this.warnCanvasMutationFailed.bind(this),\n });\n\n break;\n }\n case IncrementalSource.Font: {\n try {\n const fontFace = new FontFace(\n d.family,\n d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource,\n d.descriptors,\n );\n this.iframe.contentDocument?.fonts.add(fontFace);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(error);\n }\n }\n break;\n }\n default:\n }\n }\n\n private applyMutation(d: mutationData, useVirtualParent: boolean) {\n d.removes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.parentId)) {\n // no need to warn, parent was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.virtualStyleRulesMap.has(target)) {\n this.virtualStyleRulesMap.delete(target);\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n return this.warnNodeNotFound(d, mutation.parentId);\n }\n if (mutation.isShadow && hasShadowRoot(parent)) {\n parent = parent.shadowRoot;\n }\n // target may be removed with its parents before\n this.mirror.removeNodeFromMap(target);\n if (parent) {\n let realTarget = null;\n const realParent =\n '__sn' in parent ? this.fragmentParentMap.get(parent) : undefined;\n if (realParent && realParent.contains(target)) {\n parent = realParent;\n } else if (this.fragmentParentMap.has(target)) {\n /**\n * the target itself is a fragment document and it's not in the dom\n * so we should remove the real target from its parent\n */\n realTarget = this.fragmentParentMap.get(target)!;\n this.fragmentParentMap.delete(target);\n target = realTarget;\n }\n try {\n parent.removeChild(target);\n } catch (error) {\n if (error instanceof DOMException) {\n this.warn(\n 'parent could not remove child in mutation',\n parent,\n realParent,\n target,\n realTarget,\n d,\n );\n } else {\n throw error;\n }\n }\n }\n });\n\n // tslint:disable-next-line: variable-name\n const legacy_missingNodeMap: missingNodeMap = {\n ...this.legacy_missingNodeRetryMap,\n };\n const queue: addedNodeMutation[] = [];\n\n // next not present at this moment\n const nextNotInDOM = (mutation: addedNodeMutation) => {\n let next: Node | null = null;\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n // next not present at this moment\n if (\n mutation.nextId !== null &&\n mutation.nextId !== undefined &&\n mutation.nextId !== -1 &&\n !next\n ) {\n return true;\n }\n return false;\n };\n\n const appendNode = (mutation: addedNodeMutation) => {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n if (mutation.node.type === NodeType.Document) {\n // is newly added document, maybe the document node of an iframe\n return this.newDocumentQueue.push(mutation);\n }\n return queue.push(mutation);\n }\n\n let parentInDocument = null;\n if (this.iframe.contentDocument.contains) {\n parentInDocument = this.iframe.contentDocument.contains(parent);\n } else if (this.iframe.contentDocument.body.contains) {\n // fix for IE\n // refer 'Internet Explorer notes' at https://developer.mozilla.org/zh-CN/docs/Web/API/Document\n parentInDocument = this.iframe.contentDocument.body.contains(parent);\n }\n\n const hasIframeChild =\n ((parent as unknown) as HTMLElement).getElementsByTagName?.('iframe')\n .length > 0;\n /**\n * Why !isIframeINode(parent)? If parent element is an iframe, iframe document can't be appended to virtual parent.\n * Why !hasIframeChild? If we move iframe elements from dom to fragment document, we will lose the contentDocument of iframe. So we need to disable the virtual dom optimization if a parent node contains iframe elements.\n */\n if (\n useVirtualParent &&\n parentInDocument &&\n !isIframeINode(parent) &&\n !hasIframeChild\n ) {\n const virtualParent = (document.createDocumentFragment() as unknown) as INode;\n this.mirror.map[mutation.parentId] = virtualParent;\n this.fragmentParentMap.set(virtualParent, parent);\n\n // store the state, like scroll position, of child nodes before they are unmounted from dom\n this.storeState(parent);\n\n while (parent.firstChild) {\n virtualParent.appendChild(parent.firstChild);\n }\n parent = virtualParent;\n }\n\n if (mutation.node.isShadow) {\n // If the parent is attached a shadow dom after it's created, it won't have a shadow root.\n if (!hasShadowRoot(parent)) {\n ((parent as Node) as HTMLElement).attachShadow({ mode: 'open' });\n parent = ((parent as Node) as HTMLElement).shadowRoot!;\n } else parent = parent.shadowRoot;\n }\n\n let previous: Node | null = null;\n let next: Node | null = null;\n if (mutation.previousId) {\n previous = this.mirror.getNode(mutation.previousId) as Node;\n }\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n if (nextNotInDOM(mutation)) {\n return queue.push(mutation);\n }\n\n if (mutation.node.rootId && !this.mirror.getNode(mutation.node.rootId)) {\n return;\n }\n\n const targetDoc = mutation.node.rootId\n ? this.mirror.getNode(mutation.node.rootId)\n : this.iframe.contentDocument;\n if (isIframeINode(parent)) {\n this.attachDocumentToIframe(mutation, parent);\n return;\n }\n const target = buildNodeWithSN(mutation.node, {\n doc: targetDoc as Document,\n map: this.mirror.map,\n skipChild: true,\n hackCss: true,\n cache: this.cache,\n }) as INode;\n\n // legacy data, we should not have -1 siblings any more\n if (mutation.previousId === -1 || mutation.nextId === -1) {\n legacy_missingNodeMap[mutation.node.id] = {\n node: target,\n mutation,\n };\n return;\n }\n\n if (\n '__sn' in parent &&\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n mutation.node.type === NodeType.Text\n ) {\n // https://github.com/rrweb-io/rrweb/issues/745\n // parent is textarea, will only keep one child node as the value\n for (const c of Array.from(parent.childNodes)) {\n if (c.nodeType === parent.TEXT_NODE) {\n parent.removeChild(c);\n }\n }\n }\n\n if (previous && previous.nextSibling && previous.nextSibling.parentNode) {\n parent.insertBefore(target, previous.nextSibling);\n } else if (next && next.parentNode) {\n // making sure the parent contains the reference nodes\n // before we insert target before next.\n parent.contains(next)\n ? parent.insertBefore(target, next)\n : parent.insertBefore(target, null);\n } else {\n /**\n * Sometimes the document changes and the MutationObserver is disconnected, so the removal of child elements can't be detected and recorded. After the change of document, we may get another mutation which adds a new html element, while the old html element still exists in the dom, and we need to remove the old html element first to avoid collision.\n */\n if (parent === targetDoc) {\n while (targetDoc.firstChild) {\n targetDoc.removeChild(targetDoc.firstChild);\n }\n }\n\n parent.appendChild(target);\n }\n\n if (isIframeINode(target)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === target.__sn.id,\n );\n if (mutationInQueue) {\n this.attachDocumentToIframe(mutationInQueue, target);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(\n legacy_missingNodeMap,\n parent,\n target,\n mutation,\n );\n }\n };\n\n d.adds.forEach((mutation) => {\n appendNode(mutation);\n });\n\n let startTime = Date.now();\n while (queue.length) {\n // transform queue to resolve tree\n const resolveTrees = queueToResolveTrees(queue);\n queue.length = 0;\n if (Date.now() - startTime > 500) {\n this.warn(\n 'Timeout in the loop, please check the resolve tree data:',\n resolveTrees,\n );\n break;\n }\n for (const tree of resolveTrees) {\n let parent = this.mirror.getNode(tree.value.parentId);\n if (!parent) {\n this.debug(\n 'Drop resolve tree since there is no parent for the root node.',\n tree,\n );\n } else {\n iterateResolveTree(tree, (mutation) => {\n appendNode(mutation);\n });\n }\n }\n }\n\n if (Object.keys(legacy_missingNodeMap).length) {\n Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);\n }\n\n d.texts.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n /**\n * apply text content to real parent directly\n */\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n target.textContent = mutation.value;\n });\n d.attributes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n for (const attributeName in mutation.attributes) {\n if (typeof attributeName === 'string') {\n const value = mutation.attributes[attributeName];\n if (value === null) {\n ((target as Node) as Element).removeAttribute(attributeName);\n } else if (typeof value === 'string') {\n try {\n ((target as Node) as Element).setAttribute(attributeName, value);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n 'An error occurred may due to the checkout feature.',\n error,\n );\n }\n }\n } else if (attributeName === 'style') {\n let styleValues = value as styleAttributeValue;\n const targetEl = (target as Node) as HTMLElement;\n for (var s in styleValues) {\n if (styleValues[s] === false) {\n targetEl.style.removeProperty(s);\n } else if (styleValues[s] instanceof Array) {\n const svp = styleValues[s] as styleValueWithPriority;\n targetEl.style.setProperty(s, svp[0], svp[1]);\n } else {\n const svs = styleValues[s] as string;\n targetEl.style.setProperty(s, svs);\n }\n }\n }\n }\n }\n });\n }\n\n /**\n * Apply the scroll data on real elements.\n * If the replayer is in sync mode, smooth scroll behavior should be disabled.\n * @param d the scroll data\n * @param isSync whether the replayer is in sync mode(fast-forward)\n */\n private applyScroll(d: scrollData, isSync: boolean) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n if ((target as Node) === this.iframe.contentDocument) {\n this.iframe.contentWindow!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else if (target.__sn.type === NodeType.Document) {\n // nest iframe content document\n ((target as unknown) as Document).defaultView!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else {\n try {\n ((target as Node) as Element).scrollTop = d.y;\n ((target as Node) as Element).scrollLeft = d.x;\n } catch (error) {\n /**\n * Seldomly we may found scroll target was removed before\n * its last scroll event.\n */\n }\n }\n }\n\n private applyInput(d: inputData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n try {\n ((target as Node) as HTMLInputElement).checked = d.isChecked;\n ((target as Node) as HTMLInputElement).value = d.text;\n } catch (error) {\n // for safe\n }\n }\n\n private applyText(d: textMutation, mutation: mutationData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(mutation, d.id);\n }\n try {\n ((target as Node) as HTMLElement).textContent = d.value;\n } catch (error) {\n // for safe\n }\n }\n\n private legacy_resolveMissingNode(\n map: missingNodeMap,\n parent: Node,\n target: Node,\n targetMutation: addedNodeMutation,\n ) {\n const { previousId, nextId } = targetMutation;\n const previousInMap = previousId && map[previousId];\n const nextInMap = nextId && map[nextId];\n if (previousInMap) {\n const { node, mutation } = previousInMap as missingNode;\n parent.insertBefore(node, target);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n if (nextInMap) {\n const { node, mutation } = nextInMap as missingNode;\n parent.insertBefore(node, target.nextSibling);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n }\n\n private moveAndHover(\n x: number,\n y: number,\n id: number,\n isSync: boolean,\n debugData: incrementalData,\n ) {\n const target = this.mirror.getNode(id);\n if (!target) {\n return this.debugNodeNotFound(debugData, id);\n }\n\n const base = getBaseDimension(target, this.iframe);\n const _x = x * base.absoluteScale + base.x;\n const _y = y * base.absoluteScale + base.y;\n\n this.mouse.style.left = `${_x}px`;\n this.mouse.style.top = `${_y}px`;\n if (!isSync) {\n this.drawMouseTail({ x: _x, y: _y });\n }\n this.hoverElements((target as Node) as Element);\n }\n\n private drawMouseTail(position: { x: number; y: number }) {\n if (!this.mouseTail) {\n return;\n }\n\n const { lineCap, lineWidth, strokeStyle, duration } =\n this.config.mouseTail === true\n ? defaultMouseTailConfig\n : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);\n\n const draw = () => {\n if (!this.mouseTail) {\n return;\n }\n const ctx = this.mouseTail.getContext('2d');\n if (!ctx || !this.tailPositions.length) {\n return;\n }\n ctx.clearRect(0, 0, this.mouseTail.width, this.mouseTail.height);\n ctx.beginPath();\n ctx.lineWidth = lineWidth;\n ctx.lineCap = lineCap;\n ctx.strokeStyle = strokeStyle;\n ctx.moveTo(this.tailPositions[0].x, this.tailPositions[0].y);\n this.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));\n ctx.stroke();\n };\n\n this.tailPositions.push(position);\n draw();\n setTimeout(() => {\n this.tailPositions = this.tailPositions.filter((p) => p !== position);\n draw();\n }, duration / this.speedService.state.context.timer.speed);\n }\n\n private hoverElements(el: Element) {\n this.iframe.contentDocument\n ?.querySelectorAll('.\\\\:hover')\n .forEach((hoveredEl) => {\n hoveredEl.classList.remove(':hover');\n });\n let currentEl: Element | null = el;\n while (currentEl) {\n if (currentEl.classList) {\n currentEl.classList.add(':hover');\n }\n currentEl = currentEl.parentElement;\n }\n }\n\n private isUserInteraction(event: eventWithTime): boolean {\n if (event.type !== EventType.IncrementalSnapshot) {\n return false;\n }\n return (\n event.data.source > IncrementalSource.Mutation &&\n event.data.source <= IncrementalSource.Input\n );\n }\n\n private backToNormal() {\n this.nextUserInteractionEvent = null;\n if (this.speedService.state.matches('normal')) {\n return;\n }\n this.speedService.send({ type: 'BACK_TO_NORMAL' });\n this.emitter.emit(ReplayerEvents.SkipEnd, {\n speed: this.speedService.state.context.normalSpeed,\n });\n }\n\n /**\n * Replace the virtual parent with the real parent.\n * @param frag fragment document, the virtual parent\n * @param parent real parent element\n */\n private restoreRealParent(frag: INode, parent: INode) {\n this.mirror.map[parent.__sn.id] = parent;\n /**\n * If we have already set value attribute on textarea,\n * then we could not apply text content as default value any more.\n */\n if (\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n frag.textContent\n ) {\n ((parent as unknown) as HTMLTextAreaElement).value = frag.textContent;\n }\n parent.appendChild(frag);\n // restore state of elements after they are mounted\n this.restoreState(parent);\n }\n\n /**\n * store state of elements before unmounted from dom recursively\n * the state should be restored in the handler of event ReplayerEvents.Flush\n * e.g. browser would lose scroll position after the process that we add children of parent node to Fragment Document as virtual dom\n */\n private storeState(parent: INode) {\n if (parent) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (parentElement.scrollLeft || parentElement.scrollTop) {\n // store scroll position state\n this.elementStateMap.set(parent, {\n scroll: [parentElement.scrollLeft, parentElement.scrollTop],\n });\n }\n if (parentElement.tagName === 'STYLE')\n storeCSSRules(\n parentElement as HTMLStyleElement,\n this.virtualStyleRulesMap,\n );\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.storeState((child as unknown) as INode);\n }\n }\n }\n }\n\n /**\n * restore the state of elements recursively, which was stored before elements were unmounted from dom in virtual parent mode\n * this function corresponds to function storeState\n */\n private restoreState(parent: INode) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (this.elementStateMap.has(parent)) {\n const storedState = this.elementStateMap.get(parent)!;\n // restore scroll position\n if (storedState.scroll) {\n parentElement.scrollLeft = storedState.scroll[0];\n parentElement.scrollTop = storedState.scroll[1];\n }\n this.elementStateMap.delete(parent);\n }\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.restoreState((child as unknown) as INode);\n }\n }\n }\n\n private restoreNodeSheet(node: INode) {\n const storedRules = this.virtualStyleRulesMap.get(node);\n if (node.nodeName !== 'STYLE') {\n return;\n }\n\n if (!storedRules) {\n return;\n }\n\n const styleNode = (node as unknown) as HTMLStyleElement;\n\n applyVirtualStyleRulesToNode(storedRules, styleNode);\n }\n\n private warnNodeNotFound(d: incrementalData, id: number) {\n if (this.treeIndex.idRemoved(id)) {\n this.warn(`Node with id '${id}' was previously removed. `, d);\n } else {\n this.warn(`Node with id '${id}' not found. `, d);\n }\n }\n\n private warnCanvasMutationFailed(\n d: canvasMutationData | canvasMutationCommand,\n error: unknown,\n ) {\n this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);\n }\n\n private debugNodeNotFound(d: incrementalData, id: number) {\n /**\n * There maybe some valid scenes of node not being found.\n * Because DOM events are macrotask and MutationObserver callback\n * is microtask, so events fired on a removed DOM may emit\n * snapshots in the reverse order.\n */\n if (this.treeIndex.idRemoved(id)) {\n this.debug(\n REPLAY_CONSOLE_PREFIX,\n `Node with id '${id}' was previously removed. `,\n d,\n );\n } else {\n this.debug(REPLAY_CONSOLE_PREFIX, `Node with id '${id}' not found. `, d);\n }\n }\n\n private warn(...args: Parameters) {\n if (!this.config.showWarning) {\n return;\n }\n console.warn(REPLAY_CONSOLE_PREFIX, ...args);\n }\n\n private debug(...args: Parameters) {\n if (!this.config.showDebug) {\n return;\n }\n // tslint:disable-next-line: no-console\n console.log(REPLAY_CONSOLE_PREFIX, ...args);\n }\n}\n","import { Replayer } from '..';\nimport {\n CanvasContext,\n canvasMutationCommand,\n canvasMutationData,\n} from '../../types';\nimport webglMutation from './webgl';\nimport canvas2DMutation from './2d';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationData;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const mutations: canvasMutationCommand[] =\n 'commands' in mutation ? mutation.commands : [mutation];\n\n if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {\n return mutations.forEach((command) => {\n webglMutation({\n mutation: command,\n type: mutation.type,\n target,\n imageMap,\n errorHandler,\n });\n });\n }\n // default is '2d' for backwards compatibility (rrweb below 1.1.x)\n return mutations.forEach((command) => {\n canvas2DMutation({\n event,\n mutation: command,\n target,\n imageMap,\n errorHandler,\n });\n });\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import { Replayer } from '../';\nimport { canvasMutationCommand } from '../../types';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = ((target as unknown) as HTMLCanvasElement).getContext('2d')!;\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n /**\n * We have serialized the image source into base64 string during recording,\n * which has been preloaded before replay.\n * So we can get call drawImage SYNCHRONOUSLY which avoid some fragile cast.\n */\n if (\n mutation.property === 'drawImage' &&\n typeof mutation.args[0] === 'string'\n ) {\n const image = imageMap.get(event);\n mutation.args[0] = image;\n original.apply(ctx, mutation.args);\n } else {\n original.apply(ctx, mutation.args);\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import record from './record';\nimport { Replayer } from './replay';\nimport { _mirror } from './utils';\nimport * as utils from './utils';\n\nexport {\n EventType,\n IncrementalSource,\n MouseInteractions,\n ReplayerEvents,\n} from './types';\n\nconst { addCustomEvent } = record;\nconst { freezePage } = record;\n\nexport {\n record,\n addCustomEvent,\n freezePage,\n Replayer,\n _mirror as mirror,\n utils,\n};\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isElement","nodeType","ELEMENT_NODE","isShadowRoot","_a","host","Boolean","shadowRoot","maskInputValue","maskInputOptions","tagName","type","maskInputFn","text","toLowerCase","repeat","ORIGINAL_ATTRIBUTE_NAME","canvasService","canvasCtx","_id","tagNameRegex","RegExp","getCssRulesString","rules","cssRules","map","getCssRuleString","join","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","stack","parts","pop","_i","parts_1","part","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","classList","contains","eIndex","className","matches","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","Math","min","data","buffer","some","pixel","is2DCanvasBlank","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","_l","_m","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","commentre","parse","css","lineno","column","updatePosition","str","lines","lastIndexOf","position","start","line","Position","whitespace","end","source","content","errorsList","msg","Error","reason","filename","silent","open","close","comments","atrule","re","selector","declaration","propMatch","prop","val","ret","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","vendor","frame","frames","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","atdocument","sel","selectors","atpage","athost","atfontface","addParent","parsingErrors","obj","parent","isNode","childParent","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cache","cachedStyle","stylesWithHoverClass","get","ast","selectorMatcher","filter","index","sort","b","result","newSelector","set","createCache","Map","buildNode","hackCss","implementation","createDocument","createDocumentType","node_1","getTagName","createElementNS","_loop_1","startsWith","image","setAttribute","play","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","removeChild","appendChild","setAttributeNS","srcset","firstChild","attachShadow","mode","createCDATASection","createComment","buildNodeWithSN","afterAppend","assert","xmlns","write","childN","childNode","rebuild","onVisit","idNodeMap","key","visit","visitedNode","name_2","handleScroll","on","fn","target","capture","passive","removeEventListener","createMirror","getId","getNode","removeNodeFromMap","_this","has","reset","DEPARTED_MIRROR_ACCESS_WARNING","throttle","func","wait","timeout","previous","arg","now","Date","leading","remaining","context","args","trailing","hookSetter","d","isRevoked","original","getOwnPropertyDescriptor","patch","replacement","original_1","wrapped","defineProperties","__rrweb_original__","getWindowHeight","window","innerHeight","documentElement","clientHeight","body","getWindowWidth","innerWidth","clientWidth","isBlocked","needBlock_1","closest","isIgnored","isAncestorRemoved","mirror","isTouchEvent","event","changedTouches","polyfill","NodeList","DOMTokenList","Node","Proxy","Reflect","_mirror","receiver","TreeIndex","mutation","parentTreeNode","indexes","parentId","treeNode","children","texts","tree","deepRemoveFromMirror","removeIdSet","add","deepRemoveFromTreeIndex","_treeNode","_parentTreeNode","delete","removeNodeMutations","textMutations","attributeMutations","scrollMap","inputMap","batchMutationData","Mutation","removes","adds","walk","removed","mutationData","Set","queueToResolveTrees","queue","queueNodeMap","putIntoMap","nodeInTree","queueNodeTrees","queue_1","nextId","nextInTree","idx","splice","parentInTree","iterateResolveTree","cb","isIframeINode","getBaseDimension","rootIframe","frameElement","ownerDocument","defaultView","relativeScale","absoluteScale","frameDimension","frameBaseDimension","hasShadowRoot","isNodeInLinkedList","DoubleLinkedList","current","head","__ln","moveKey","isINode","mutations","processMutation","emit","frozen","locked","addList","getNextId","ns","pushAdd","shadowHost","getRootNode","rootShadowHost","notInDoc","addNode","currentN","iframeManager","addIframe","shadowDomManager","addShadowRoot","iframe","childSn","attachIframe","observeAttachShadow","mapRemoves","shift","movedSet","isParentRemoved","addedSet","isAncestorInSet","droppedSet","candidate","_node","removeNode","payload","attribute","movedMap","mutationCb","oldValue","getAttribute","attributeName","item","old","styleObj","pname","newValue","getPropertyValue","newPriority","getPropertyPriority","addedNodes","genAdds","removedNodes","nodeId","deepDelete","targetId","MutationBuffer","canvasManager","freeze","unfreeze","lock","unlock","addsSet","mutationBuffers","isCSSGroupingRuleSupported","CSSGroupingRule","isCSSMediaRuleSupported","CSSMediaRule","isCSSSupportsRuleSupported","CSSSupportsRule","isCSSConditionRuleSupported","CSSConditionRule","getEventTarget","path","composedPath","initMutationObserver","rootEl","mutationBuffer","init","mutationObserverCtor","MutationObserver","__rrMutationObserver","angularZoneSymbol","Zone","__symbol__","observer","processMutations","bind","observe","attributeOldValue","characterData","characterDataOldValue","childList","subtree","initMouseInteractionObserver","mouseInteractionCb","sampling","mouseInteraction","disableMap","handlers","Number","isNaN","eventKey","eventName","handler","clientX","clientY","getHandler","h","initScrollObserver","scrollCb","evt","scrollEl","scrollingElement","scroll","wrapEventWithUserTriggeredFlag","enable","userTriggered","INPUT_TAGS","lastInputValueMap","WeakMap","getNestedCSSRulePositions","childRule","parentRule","unshift","parentStyleSheet","recurse","initObservers","hooks","currentWindow","mousemoveCb","viewportResizeCb","inputCb","mediaInteractionCb","styleSheetRuleCb","styleDeclarationCb","canvasMutationCb","fontCb","mousemove","viewportResize","input","mediaInteaction","styleSheetRule","styleDeclaration","canvasMutation","font","mergeHooks","mutationObserver","mousemoveHandler","timeBaseline","threshold","callbackThreshold","mousemoveCallback","positions","wrappedCb","totalOffset","timeOffset","DragEvent","Drag","MouseEvent","MouseMove","TouchMove","initMoveObserver","mouseInteractionHandler","scrollHandler","viewportResizeHandler","lastH","lastW","initViewportResizeObserver","inputHandler","ignoreClass","userTriggeredOnInput","eventHandler","isTrusted","parentElement","isChecked","cbWithDedup","querySelectorAll","lastInputValue","propertyDescriptor","HTMLInputElement","hookProperties","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement","initInputObserver","mediaInteractionHandler","volume","muted","initMediaInteractionObserver","styleSheetObserver","insertRule","CSSStyleSheet","ownerNode","deleteRule","supportedNestedCSSRuleTypes","unmodifiedFunctions","entries","typeKey","initStyleSheetObserver","styleDeclarationObserver","setProperty","CSSStyleDeclaration","priority","removeProperty","remove","initStyleDeclarationObserver","fontObserver","collectFonts","fontMap","originalFontFace","FontFace","family","descriptors","fontFace","fontSource","JSON","stringify","Uint8Array","restoreHandler","fonts","initFontObserver","pluginHandlers","plugins","plugin","callback","disconnect","IframeManager","iframes","loadListener","isAttachIframe","manager","restorePatches","HTMLElement","ShadowDomManager","iframeElement","manager_1","restorePatch","lookup","charCodeAt","webGLVarMap","saveWebGLVar","isInstanceOfWebGLObject","list","ctor","contextMap","variableListFor","constructor","serializeArg","Float32Array","Float64Array","Int32Array","Uint16Array","Int16Array","Int8Array","Uint8ClampedArray","rr_type","ArrayBuffer","base64","arraybuffer","bytes","len","encode","DataView","byteOffset","byteLength","HTMLImageElement","ImageData","serializeArgs","supportedWebGLConstructorNames","patchGLPrototype","props","getOwnPropertyNames","recordArgs","hookHandler","setter","props_1","wrappedEmit","takeFullSnapshot","latestId","invokeId","rafStamps","pendingCanvasMutations","initCanvasMutationObserver","CanvasManager","clear","resetObservers","startRAFTimestamping","startPendingCanvasMutationFlusher","canvasContextReset","HTMLCanvasElement","contextType","initCanvasContextObserver","canvas2DReset","props2D","CanvasRenderingContext2D","imgd","pix","props2D_1","initCanvas2DMutationObserver","canvasWebGL1and2Reset","WebGLRenderingContext","WebGL","WebGL2RenderingContext","WebGL2","initCanvasWebGLMutationObserver","requestAnimationFrame","flushPendingCanvasMutations","setLatestRAFTimestamp","timestamp","flushPendingCanvasMutationFor","valuesWithType","getOwnPropertySymbols","propertyIsEnumerable","commands","wrapEvent","record","checkoutEveryNms","checkoutEveryNth","maskAllInputs","_maskInputOptions","_slimDOMOptions","packFn","mousemoveWait","lastFullSnapshotEvent","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","incrementalSnapshotCount","isCheckout","isFrozen","FullSnapshot","IncrementalSnapshot","buf","eventProcessor","exceedCount","exceedTime","wrappedMutationEmit","wrappedScrollEmit","Scroll","wrappedCanvasMutationEmit","CanvasMutation","Meta","slimDOM","snapshot","initialOffset","left","pageXOffset","top","pageYOffset","handlers_1","DomContentLoaded","observe_1","MouseInteraction","ViewportResize","Input","MediaInteraction","StyleSheetRule","StyleDeclaration","Font","Plugin","addLoadListener","init_1","Load","mitt","all","create","off","addCustomEvent","tag","Custom","freezePage","w","__forceSmoothScrollPolyfill__","userAgent","scrollTo","scrollBy","elementScroll","scrollElement","scrollIntoView","performance","ROUNDING_TOLERANCE","navigator","shouldBailOut","smoothScroll","scrollX","scrollY","SyntaxError","behavior","scrollableParent","findScrollableParent","parentRects","clientRects","getComputedStyle","firstArg","hasScrollableSpace","axis","scrollHeight","scrollWidth","canOverflow","overflowValue","isScrollable","isScrollableY","isScrollableX","step","currentX","currentY","k","elapsed","startTime","cos","PI","startX","startY","method","scrollable","actions","speed","Timer","action","findActionIndex","lastTimestamp","self","raf","check","delay","doAction","liveMode","cancelAnimationFrame","mid","floor","addDelay","baselineTime","firstOffset","firstTimestamp","return","NotStarted","Running","Stopped","assignment","u","changed","f","states","initial","entry","config","_options","initialState","transition","g","S","j","E","R","N","cond","O","_","T","q","exit","z","A","B","C","_machine","send","subscribe","unsubscribe","stop","state","status","createPlayerService","getCastFn","applyEventsSynchronously","emitter","interpret","createMachine","playing","PAUSE","CAST_EVENT","END","ADD_EVENT","PLAY","TO_LIVE","live","castEvent","lastPlayedEvent","recordTimeOffset","events","timer","events_1","neededEvents","event_1","discardPriorSnapshots","lastPlayedTimestamp","PlayBack","syncEvents","event_3","castFn_1","neededEvents_1","Flush","addActions","resetLastPlayedEvent","startLive","toggleLiveMode","addEvent","machineEvent","event_4","insertionIndex","isSync","castFn_2","isActive","addAction","StyleRuleType","getNestedRule","getPositionsAndIndex","nestedIndex","applyVirtualStyleRulesToNode","storedRules","styleNode","Insert","Remove","Snapshot","cssTexts","existingRules","existingRulesReversed","reverse","lastMatch_1","restoreSnapshotOfStyleRulesToNode","SetProperty","RemoveProperty","WebGLVariableConstructorsNames","deserializeArg","imageMap","encoded1","encoded2","encoded3","encoded4","bufferLength","decode","Image","webglMutation","errorHandler","includes","variables","saveToWebGLVarMap","mittProxy.default","mittProxy","REPLAY_CONSOLE_PREFIX","defaultMouseTailConfig","duration","lineCap","lineWidth","strokeStyle","indicatesTouchDevice","TouchStart","defaultConfig","maxSpeed","root","loadTimeout","skipInactive","showWarning","showDebug","insertStyleRules","triggerFocus","UNSAFE_replayCanvas","pauseAnimation","mouseTail","handleResize","Resize","setupDom","treeIndex","fragmentParentMap","elementStateMap","virtualStyleRulesMap","flush","frag","restoreRealParent","applyText","restoreNodeSheet","applyScroll","applyInput","firstFullSnapshot","service","unpackFn","a1","a2","StateChange","player","speedService","normalSpeed","normal","FAST_FORWARD","SET_SPEED","skipping","BACK_TO_NORMAL","setSpeed","recordSpeed","restoreSpeed","firstMeta","firstFullsnapshot","width_1","height_1","rebuildFullSnapshot","mouse","Replayer","backToNormal","display","parseFloat","wrapper","insertBefore","firstEvent","lastEvent","endTime","totalTime","getTimeOffset","getElementsByTagName","Start","Pause","Resume","rawEvent","Promise","resolve","then","pointerEvents","disableInteract","smoothscrollPolyfill","dimension","String","castFn","mousePos","moveAndHover","debugData","touchActive","CustomEvent","applyIncremental","nextUserInteractionEvent","_event","isUserInteraction","skipTime","round","SkipStart","replayer","last_index","finish_1","Finish","max","EventCast","legacy_missingNodeRetryMap","collected","builtNode","collectIframeAndAttachDocument","mutationInQueue","this_1","attachDocumentToIframe","newDocumentQueue","collected_1","FullsnapshotRebuilded","waitForStylesheetLoad","preloadAllImages","styleEl","injectStylesRules","parent_1","realParent","toUpperCase","this_2","collected_2","unloadSheets_1","beforeLoadState_1","stateHandler_1","unsubscribe_1","size","getCurrentTime","LoadStylesheetEnd","LoadStylesheetStart","args_1","hasImageArg","images","args_2","getImageArgs","stateHandler","event_2","preloadImages","this_3","createImageData","putImageData","applyMutation","message","lastPosition","Event","debugNodeNotFound","Blur","blur","Focus","focus","preventScroll","Click","TouchEnd","tailPositions","offsetWidth","TouchCancel","dispatchEvent","mediaEl","rules_1","parent_2","usingVirtualParent_1","styleSheet_1","parent_3","command","canvas2DMutation","warnCanvasMutationFailed","useVirtualParent","warnNodeNotFound","realTarget","DOMException","legacy_missingNodeMap","appendNode","parentInDocument","hasIframeChild","virtualParent","createDocumentFragment","storeState","previousId","nextNotInDOM","targetDoc","mutationInQueue_1","legacy_resolveMissingNode","resolveTrees","resolveTrees_1","debug","removeAttribute","styleValues","targetEl","svp","svs","targetMutation","previousInMap","nextInMap","base","_x","_y","drawMouseTail","hoverElements","draw","clearRect","begin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ziB,WAAaynC,EAAY5oB,OAAO,GAC9C4D,EAAcviB,UAAYunC,EAAY5oB,OAAO,IAE/CzrB,KAAKgpC,gBAAgBrnB,OAAOjM,GAE9B,IAAMwL,EAAWmO,EAAcnO,aAC/B,IAAoB,IAAArZ,EAAA5H,EAAAoB,MAAMH,KAAKggB,kCAAW,CAArC,IAAMhG,UACTlb,KAAKm0C,aAAcj5B,wGAKjB8vB,6BAAR,SAAyBrkC,GACvB,IAAM8+B,EAAczlC,KAAKipC,qBAAqB3vB,IAAI3S,GAC5B,UAAlBA,EAAK2tC,WAIJ7O,GAMLD,GAA6BC,EAFV9+B,KAKbqkC,6BAAR,SAAyBxsB,EAAoBlW,GACvCtI,KAAK8oC,UAAUyL,UAAUjsC,GAC3BtI,KAAKoM,KAAK,wBAAiB9D,gCAAgCkW,GAE3Dxe,KAAKoM,KAAK,wBAAiB9D,mBAAmBkW,IAI1CwsB,qCAAR,SACExsB,EACAzd,GAEAf,KAAKoM,KAAK,6BAA8BrL,EAAO,mBAAoByd,IAG7DwsB,8BAAR,SAA0BxsB,EAAoBlW,GAOxCtI,KAAK8oC,UAAUyL,UAAUjsC,GAC3BtI,KAAK4yC,MACHrL,GACA,wBAAiBj/B,gCACjBkW,GAGFxe,KAAK4yC,MAAMrL,GAAuB,wBAAiBj/B,mBAAmBkW,IAIlEwsB,iBAAR,eAAa,aAAAlmC,mBAAAA,IAAAuZ,kBACNre,KAAK+gC,OAAOqH,aAGjBj8B,QAAQC,WAARD,WAAao7B,MAA0BlpB,SAGjC2sB,kBAAR,eAAc,aAAAlmC,mBAAAA,IAAAuZ,kBACPre,KAAK+gC,OAAOsH,WAIjBl8B,QAAQqoC,UAARroC,WAAYo7B,MAA0BlpB,cGl6DlC4d,GAAmB9D,kBACnBiE,GAAejE"} +\ No newline at end of file ++{"version":3,"file":"rrweb.min.js","sources":["../node_modules/tslib/tslib.es6.js","../../rrweb-snapshot/es/rrweb-snapshot.js","../../src/types.ts","../../src/utils.ts","../../src/record/mutation.ts","../../src/record/observer.ts","../../src/record/iframe-manager.ts","../../src/record/shadow-dom-manager.ts","../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../../src/record/observers/canvas/serialize-args.ts","../../src/record/observers/canvas/webgl.ts","../../src/record/observers/canvas/canvas-manager.ts","../../src/record/index.ts","../../src/record/observers/canvas/canvas.ts","../../src/record/observers/canvas/2d.ts","../../../node_modules/mitt/dist/mitt.es.js","../../src/replay/smoothscroll.ts","../../src/replay/timer.ts","../../../node_modules/@xstate/fsm/es/index.js","../../src/replay/machine.ts","../../src/replay/styles/inject-style.ts","../../src/replay/virtual-styles.ts","../../src/replay/canvas/webgl.ts","../../src/replay/index.ts","../../src/replay/canvas/index.ts","../../src/replay/canvas/2d.ts","../../src/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","var NodeType;\n(function (NodeType) {\n NodeType[NodeType[\"Document\"] = 0] = \"Document\";\n NodeType[NodeType[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType[NodeType[\"Element\"] = 2] = \"Element\";\n NodeType[NodeType[\"Text\"] = 3] = \"Text\";\n NodeType[NodeType[\"CDATA\"] = 4] = \"CDATA\";\n NodeType[NodeType[\"Comment\"] = 5] = \"Comment\";\n})(NodeType || (NodeType = {}));\n\nfunction isElement(n) {\n return n.nodeType === n.ELEMENT_NODE;\n}\nfunction isShadowRoot(n) {\n var _a;\n var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\nfunction maskInputValue(_a) {\n var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;\n var text = value || '';\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n if (maskInputOptions[tagName.toLowerCase()] ||\n maskInputOptions[type] ||\n (maskInputSelector && input.matches(maskInputSelector))) {\n if (maskInputFn) {\n text = maskInputFn(text);\n }\n else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\nvar ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\nfunction is2DCanvasBlank(canvas) {\n var ctx = canvas.getContext('2d');\n if (!ctx)\n return true;\n var chunkSize = 50;\n for (var x = 0; x < canvas.width; x += chunkSize) {\n for (var y = 0; y < canvas.height; y += chunkSize) {\n var getImageData = ctx.getImageData;\n var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);\n if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))\n return false;\n }\n }\n return true;\n}\n\nvar _id = 1;\nvar tagNameRegex = new RegExp('[^a-z0-9-_:]');\nvar IGNORED_NODE = -2;\nfunction genId() {\n return _id++;\n}\nfunction getValidTagName(element) {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n var processedTagName = element.tagName.toLowerCase().trim();\n if (tagNameRegex.test(processedTagName)) {\n return 'div';\n }\n return processedTagName;\n}\nfunction getCssRulesString(s) {\n try {\n var rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n }\n catch (error) {\n return null;\n }\n}\nfunction getCssRuleString(rule) {\n var cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n }\n catch (_a) {\n }\n }\n return cssStringified;\n}\nfunction isCSSImportRule(rule) {\n return 'styleSheet' in rule;\n}\nfunction stringifyStyleSheet(sheet) {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map(function (rule) { return rule.cssText || ''; })\n .join('')\n : '';\n}\nfunction extractOrigin(url) {\n var origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n }\n else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\nvar canvasService;\nvar canvasCtx;\nvar URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nvar RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nvar DATA_URI = /^(data:)([^,]*),(.*)/i;\nfunction absoluteToStylesheet(cssText, href) {\n return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {\n var filePath = path1 || path2 || path3;\n var maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (DATA_URI.test(filePath)) {\n return \"url(\" + maybeQuote + filePath + maybeQuote + \")\";\n }\n if (filePath[0] === '/') {\n return \"url(\" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + \")\";\n }\n var stack = href.split('/');\n var parts = filePath.split('/');\n stack.pop();\n for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {\n var part = parts_1[_i];\n if (part === '.') {\n continue;\n }\n else if (part === '..') {\n stack.pop();\n }\n else {\n stack.push(part);\n }\n }\n return \"url(\" + maybeQuote + stack.join('/') + maybeQuote + \")\";\n });\n}\nvar SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/;\nvar SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc, attributeValue) {\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n var pos = 0;\n function collectCharacters(regEx) {\n var chars;\n var match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n var output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n var url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n output.push(url);\n }\n else {\n var descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n var inParens = false;\n while (true) {\n var c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break;\n }\n else if (c === '(') {\n inParens = true;\n }\n }\n else {\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\nfunction absoluteToDoc(doc, attributeValue) {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n var a = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\nfunction isSVGElement(el) {\n return Boolean(el.tagName === 'svg' || el.ownerSVGElement);\n}\nfunction getHref() {\n var a = document.createElement('a');\n a.href = '';\n return a.href;\n}\nfunction transformAttribute(doc, tagName, name, value) {\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'xlink:href' && value && value[0] !== '#') {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')) {\n return absoluteToDoc(doc, value);\n }\n else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n }\n else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n }\n else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n }\n else {\n return value;\n }\n}\nfunction _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {\n var className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n return false;\n}\nfunction needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) {\n return false;\n }\n }\n if (typeof maskTextClass === 'string') {\n if (node.classList.contains(maskTextClass)) {\n return true;\n }\n }\n else {\n for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {\n var className = node.classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if (node.matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\nfunction onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {\n var win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n var fired = false;\n var readyState;\n try {\n readyState = win.document.readyState;\n }\n catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n var timer_1 = setTimeout(function () {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', function () {\n clearTimeout(timer_1);\n fired = true;\n listener();\n });\n return;\n }\n var blankUrl = 'about:blank';\n if (win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === '') {\n setTimeout(listener, 0);\n return;\n }\n iframeEl.addEventListener('load', listener);\n}\nfunction serializeNode(n, options) {\n var _a;\n var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;\n var rootId;\n if (doc.__sn) {\n var docId = doc.__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if (n.compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: n.compatMode,\n rootId: rootId\n };\n }\n else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId: rootId\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: n.name,\n publicId: n.publicId,\n systemId: n.systemId,\n rootId: rootId\n };\n case n.ELEMENT_NODE:\n var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);\n var tagName = getValidTagName(n);\n var attributes_1 = {};\n for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {\n var _e = _d[_i], name_1 = _e.name, value = _e.value;\n attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);\n }\n if (tagName === 'link' && inlineStylesheet) {\n var stylesheet = Array.from(doc.styleSheets).find(function (s) {\n return s.href === n.href;\n });\n var cssText = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet);\n }\n if (cssText) {\n delete attributes_1.rel;\n delete attributes_1.href;\n attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);\n }\n }\n if (tagName === 'style' &&\n n.sheet &&\n !(n.innerText ||\n n.textContent ||\n '').trim().length) {\n var cssText = getCssRulesString(n.sheet);\n if (cssText) {\n attributes_1._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n if (tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select') {\n var value = n.value;\n if (attributes_1.type !== 'radio' &&\n attributes_1.type !== 'checkbox' &&\n attributes_1.type !== 'submit' &&\n attributes_1.type !== 'button' &&\n value) {\n attributes_1.value = maskInputValue({\n input: n,\n type: attributes_1.type,\n tagName: tagName,\n value: value,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskInputFn: maskInputFn\n });\n }\n else if (n.checked) {\n attributes_1.checked = n.checked;\n }\n }\n if (tagName === 'option') {\n if (n.selected && !maskInputOptions['select']) {\n attributes_1.selected = true;\n }\n else {\n delete attributes_1.selected;\n }\n }\n if (tagName === 'canvas' && recordCanvas) {\n if (n.__context === '2d') {\n if (!is2DCanvasBlank(n)) {\n attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n }\n else if (!('__context' in n)) {\n var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n var blankCanvas = document.createElement('canvas');\n blankCanvas.width = n.width;\n blankCanvas.height = n.height;\n var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes_1.rr_dataURL = canvasDataURL;\n }\n }\n }\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n var image_1 = n;\n var oldValue_1 = image_1.crossOrigin;\n image_1.crossOrigin = 'anonymous';\n var recordInlineImage = function () {\n try {\n canvasService.width = image_1.naturalWidth;\n canvasService.height = image_1.naturalHeight;\n canvasCtx.drawImage(image_1, 0, 0);\n attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);\n }\n catch (err) {\n console.warn(\"Cannot inline img src=\" + image_1.currentSrc + \"! Error: \" + err);\n }\n oldValue_1\n ? (attributes_1.crossOrigin = oldValue_1)\n : delete attributes_1.crossOrigin;\n };\n if (image_1.complete && image_1.naturalWidth !== 0)\n recordInlineImage();\n else\n image_1.onload = recordInlineImage;\n }\n if (tagName === 'audio' || tagName === 'video') {\n attributes_1.rr_mediaState = n.paused\n ? 'paused'\n : 'played';\n attributes_1.rr_mediaCurrentTime = n.currentTime;\n }\n if (n.scrollLeft) {\n attributes_1.rr_scrollLeft = n.scrollLeft;\n }\n if (n.scrollTop) {\n attributes_1.rr_scrollTop = n.scrollTop;\n }\n if (needBlock) {\n var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;\n attributes_1 = {\n \"class\": attributes_1[\"class\"],\n rr_width: width + \"px\",\n rr_height: height + \"px\"\n };\n }\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {\n if (!n.contentDocument) {\n attributes_1.rr_src = attributes_1.src;\n }\n delete attributes_1.src;\n }\n return {\n type: NodeType.Element,\n tagName: tagName,\n attributes: attributes_1,\n childNodes: [],\n isSVG: isSVGElement(n) || undefined,\n needBlock: needBlock,\n rootId: rootId\n };\n case n.TEXT_NODE:\n var parentTagName = n.parentNode && n.parentNode.tagName;\n var textContent = n.textContent;\n var isStyle = parentTagName === 'STYLE' ? true : undefined;\n var isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n if (n.nextSibling || n.previousSibling) {\n }\n else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {\n textContent = stringifyStyleSheet(n.parentNode.sheet);\n }\n }\n catch (err) {\n console.warn(\"Cannot get CSS styles from text's parentNode. Error: \" + err, n);\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (!isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle: isStyle,\n rootId: rootId\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId: rootId\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: n.textContent || '',\n rootId: rootId\n };\n default:\n return false;\n }\n}\nfunction lowerIfExists(maybeAttr) {\n if (maybeAttr === undefined) {\n return '';\n }\n else {\n return maybeAttr.toLowerCase();\n }\n}\nfunction slimDOMExcluded(sn, slimDOMOptions) {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n return true;\n }\n else if (sn.type === NodeType.Element) {\n if (slimDOMOptions.script &&\n (sn.tagName === 'script' ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))) {\n return true;\n }\n else if (slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {\n return true;\n }\n else if (sn.tagName === 'meta') {\n if (slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {\n return true;\n }\n else if (slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')) {\n return true;\n }\n else if (slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')) {\n return true;\n }\n else if (slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined) {\n return true;\n }\n else if (slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))) {\n return true;\n }\n else if (slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {\n return true;\n }\n }\n }\n return false;\n}\nfunction serializeNodeWithId(n, options) {\n var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;\n var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;\n var _serializedNode = serializeNode(n, {\n doc: doc,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (!_serializedNode) {\n console.warn(n, 'not serialized');\n return null;\n }\n var id;\n if ('__sn' in n) {\n id = n.__sn.id;\n }\n else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)) {\n id = IGNORED_NODE;\n }\n else {\n id = genId();\n }\n var serializedNode = Object.assign(_serializedNode, { id: id });\n n.__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null;\n }\n map[id] = n;\n if (onSerialize) {\n onSerialize(n);\n }\n var recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n delete serializedNode.needBlock;\n if (n.shadowRoot)\n serializedNode.isShadowHost = true;\n }\n if ((serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild) {\n if (slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head') {\n preserveWhiteSpace = false;\n }\n var bypassOptions = {\n doc: doc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: skipChild,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n };\n for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {\n var childN = _k[_i];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n if (isElement(n) && n.shadowRoot) {\n for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {\n var childN = _m[_l];\n var serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n if (serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe') {\n onceIframeLoaded(n, function () {\n var iframeDoc = n.contentDocument;\n if (iframeDoc && onIframeLoad) {\n var serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map: map,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n });\n if (serializedIframeNode) {\n onIframeLoad(n, serializedIframeNode);\n }\n }\n }, iframeLoadTimeout);\n }\n return serializedNode;\n}\nfunction snapshot(n, options) {\n var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;\n var idNodeMap = {};\n var maskInputOptions = maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true\n }\n : maskAllInputs === false\n ? {\n password: true\n }\n : maskAllInputs;\n var slimDOMOptions = slimDOM === true || slimDOM === 'all'\n ?\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all',\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass: blockClass,\n blockSelector: blockSelector,\n unblockSelector: unblockSelector,\n maskTextClass: maskTextClass,\n maskTextSelector: maskTextSelector,\n unmaskTextSelector: unmaskTextSelector,\n skipChild: false,\n inlineStylesheet: inlineStylesheet,\n maskInputSelector: maskInputSelector,\n unmaskInputSelector: unmaskInputSelector,\n maskInputOptions: maskInputOptions,\n maskTextFn: maskTextFn,\n maskInputFn: maskInputFn,\n slimDOMOptions: slimDOMOptions,\n dataURLOptions: dataURLOptions,\n inlineImages: inlineImages,\n recordCanvas: recordCanvas,\n preserveWhiteSpace: preserveWhiteSpace,\n onSerialize: onSerialize,\n onIframeLoad: onIframeLoad,\n iframeLoadTimeout: iframeLoadTimeout,\n keepIframeSrcFn: keepIframeSrcFn\n }),\n idNodeMap,\n ];\n}\nfunction visitSnapshot(node, onVisit) {\n function walk(current) {\n onVisit(current);\n if (current.type === NodeType.Document ||\n current.type === NodeType.Element) {\n current.childNodes.forEach(walk);\n }\n }\n walk(node);\n}\nfunction cleanupSnapshot() {\n _id = 1;\n}\n\nvar commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\nfunction parse(css, options) {\n if (options === void 0) { options = {}; }\n var lineno = 1;\n var column = 1;\n function updatePosition(str) {\n var lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n var i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n var Position = (function () {\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n return Position;\n }());\n Position.prototype.content = css;\n var errorsList = [];\n function error(msg) {\n var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n if (options.silent) {\n errorsList.push(err);\n }\n else {\n throw err;\n }\n }\n function stylesheet() {\n var rulesList = rules();\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList\n }\n };\n }\n function open() {\n return match(/^{\\s*/);\n }\n function close() {\n return match(/^}/);\n }\n function rules() {\n var node;\n var rules = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n function match(re) {\n var m = re.exec(css);\n if (!m) {\n return;\n }\n var str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n function whitespace() {\n match(/^\\s*/);\n }\n function comments(rules) {\n if (rules === void 0) { rules = []; }\n var c;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n function comment() {\n var pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n var i = 2;\n while ('' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {\n ++i;\n }\n i += 2;\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n var str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n return pos({\n type: 'comment',\n comment: str\n });\n }\n function selector() {\n var m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, function (m) {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map(function (s) {\n return s.replace(/\\u200C/g, ',');\n });\n }\n function declaration() {\n var pos = position();\n var propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n var prop = trim(propMatch[0]);\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n var val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n var ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : ''\n });\n match(/^[;\\s]*/);\n return ret;\n }\n function declarations() {\n var decls = [];\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n function keyframe() {\n var m;\n var vals = [];\n var pos = position();\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n if (!vals.length) {\n return;\n }\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations()\n });\n }\n function atkeyframes() {\n var pos = position();\n var m = match(/^@([-\\w]+)?keyframes\\s*/);\n if (!m) {\n return;\n }\n var vendor = m[1];\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n var name = m[1];\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n var frame;\n var frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n return pos({\n type: 'keyframes',\n name: name,\n vendor: vendor,\n keyframes: frames\n });\n }\n function atsupports() {\n var pos = position();\n var m = match(/^@supports *([^{]+)/);\n if (!m) {\n return;\n }\n var supports = trim(m[1]);\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n return pos({\n type: 'supports',\n supports: supports,\n rules: style\n });\n }\n function athost() {\n var pos = position();\n var m = match(/^@host\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n return pos({\n type: 'host',\n rules: style\n });\n }\n function atmedia() {\n var pos = position();\n var m = match(/^@media *([^{]+)/);\n if (!m) {\n return;\n }\n var media = trim(m[1]);\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n return pos({\n type: 'media',\n media: media,\n rules: style\n });\n }\n function atcustommedia() {\n var pos = position();\n var m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2])\n });\n }\n function atpage() {\n var pos = position();\n var m = match(/^@page */);\n if (!m) {\n return;\n }\n var sel = selector() || [];\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls\n });\n }\n function atdocument() {\n var pos = position();\n var m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n var vendor = trim(m[1]);\n var doc = trim(m[2]);\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n var style = comments().concat(rules());\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n return pos({\n type: 'document',\n document: doc,\n vendor: vendor,\n rules: style\n });\n }\n function atfontface() {\n var pos = position();\n var m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n var decls = comments();\n var decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n return pos({\n type: 'font-face',\n declarations: decls\n });\n }\n var atimport = _compileAtrule('import');\n var atcharset = _compileAtrule('charset');\n var atnamespace = _compileAtrule('namespace');\n function _compileAtrule(name) {\n var re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return function () {\n var pos = position();\n var m = match(re);\n if (!m) {\n return;\n }\n var ret = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n return (atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface());\n }\n function rule() {\n var pos = position();\n var sel = selector();\n if (!sel) {\n return error('selector missing');\n }\n comments();\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations()\n });\n }\n return addParent(stylesheet());\n}\nfunction trim(str) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\nfunction addParent(obj, parent) {\n var isNode = obj && typeof obj.type === 'string';\n var childParent = isNode ? obj : parent;\n for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {\n var k = _a[_i];\n var value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(function (v) {\n addParent(v, childParent);\n });\n }\n else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null\n });\n }\n return obj;\n}\n\nvar tagMap = {\n script: 'noscript',\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient'\n};\nfunction getTagName(n) {\n var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\nfunction escapeRegExp(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\nvar HOVER_SELECTOR = /([^\\\\]):hover/;\nvar HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nfunction addHoverClass(cssText, cache) {\n var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);\n if (cachedStyle)\n return cachedStyle;\n var ast = parse(cssText, {\n silent: true\n });\n if (!ast.stylesheet) {\n return cssText;\n }\n var selectors = [];\n ast.stylesheet.rules.forEach(function (rule) {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach(function (selector) {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n if (selectors.length === 0) {\n return cssText;\n }\n var selectorMatcher = new RegExp(selectors\n .filter(function (selector, index) { return selectors.indexOf(selector) === index; })\n .sort(function (a, b) { return b.length - a.length; })\n .map(function (selector) {\n return escapeRegExp(selector);\n })\n .join('|'), 'g');\n var result = cssText.replace(selectorMatcher, function (selector) {\n var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return selector + \", \" + newSelector;\n });\n cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);\n return result;\n}\nfunction createCache() {\n var stylesWithHoverClass = new Map();\n return {\n stylesWithHoverClass: stylesWithHoverClass\n };\n}\nfunction buildNode(n, options) {\n var doc = options.doc, hackCss = options.hackCss, cache = options.cache;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);\n case NodeType.Element:\n var tagName = getTagName(n);\n var node_1;\n if (n.isSVG) {\n node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n else {\n node_1 = doc.createElement(tagName);\n }\n var _loop_1 = function (name_1) {\n if (!n.attributes.hasOwnProperty(name_1)) {\n return \"continue\";\n }\n var value = n.attributes[name_1];\n if (tagName === 'option' && name_1 === 'selected' && value === false) {\n return \"continue\";\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n if (!name_1.startsWith('rr_')) {\n var isTextarea = tagName === 'textarea' && name_1 === 'value';\n var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n var child = doc.createTextNode(value);\n for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {\n var c = _a[_i];\n if (c.nodeType === node_1.TEXT_NODE) {\n node_1.removeChild(c);\n }\n }\n node_1.appendChild(child);\n return \"continue\";\n }\n try {\n if (n.isSVG && name_1 === 'xlink:href') {\n node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);\n }\n else if (name_1 === 'onload' ||\n name_1 === 'onclick' ||\n name_1.substring(0, 7) === 'onmouse') {\n node_1.setAttribute('_' + name_1, value);\n }\n else if (tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name_1 === 'content') {\n node_1.setAttribute('csp-content', value);\n return \"continue\";\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script') {\n }\n else if (tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')) {\n }\n else if (tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL) {\n node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);\n }\n else {\n node_1.setAttribute(name_1, value);\n }\n }\n catch (error) {\n }\n }\n else {\n if (tagName === 'canvas' && name_1 === 'rr_dataURL') {\n var image_1 = document.createElement('img');\n image_1.src = value;\n image_1.onload = function () {\n var ctx = node_1.getContext('2d');\n if (ctx) {\n ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);\n }\n };\n }\n else if (tagName === 'img' && name_1 === 'rr_dataURL') {\n var image = node_1;\n if (!image.currentSrc.startsWith('data:')) {\n image.setAttribute('rrweb-original-src', n.attributes.src);\n image.src = value;\n }\n }\n if (name_1 === 'rr_width') {\n node_1.style.width = value;\n }\n else if (name_1 === 'rr_height') {\n node_1.style.height = value;\n }\n else if (name_1 === 'rr_mediaCurrentTime') {\n node_1.currentTime = n.attributes\n .rr_mediaCurrentTime;\n }\n else if (name_1 === 'rr_mediaState') {\n switch (value) {\n case 'played':\n node_1\n .play()[\"catch\"](function (e) { return console.warn('media playback error', e); });\n break;\n case 'paused':\n node_1.pause();\n break;\n }\n }\n }\n };\n for (var name_1 in n.attributes) {\n _loop_1(name_1);\n }\n if (n.isShadowHost) {\n if (!node_1.shadowRoot) {\n node_1.attachShadow({ mode: 'open' });\n }\n else {\n while (node_1.shadowRoot.firstChild) {\n node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);\n }\n }\n }\n return node_1;\n case NodeType.Text:\n return doc.createTextNode(n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent);\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\nfunction buildNodeWithSN(n, options) {\n var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;\n var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');\n }\n if (n.type === NodeType.Document) {\n doc.close();\n doc.open();\n if (n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType) {\n if (n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {\n doc.write('');\n }\n else {\n doc.write('');\n }\n }\n node = doc;\n }\n node.__sn = n;\n map[n.id] = node;\n if ((n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild) {\n for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {\n var childN = _c[_i];\n var childNode = buildNodeWithSN(childN, {\n doc: doc,\n map: map,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n }\n else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n return node;\n}\nfunction visit(idNodeMap, onVisit) {\n function walk(node) {\n onVisit(node);\n }\n for (var key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\nfunction handleScroll(node) {\n var n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n var el = node;\n for (var name_2 in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {\n continue;\n }\n var value = n.attributes[name_2];\n if (name_2 === 'rr_scrollLeft') {\n el.scrollLeft = value;\n }\n if (name_2 === 'rr_scrollTop') {\n el.scrollTop = value;\n }\n }\n}\nfunction rebuild(n, options) {\n var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;\n var idNodeMap = {};\n var node = buildNodeWithSN(n, {\n doc: doc,\n map: idNodeMap,\n skipChild: false,\n hackCss: hackCss,\n afterAppend: afterAppend,\n cache: cache\n });\n visit(idNodeMap, function (visitedNode) {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot };\n","import {\n serializedNodeWithId,\n idNodeMap,\n INode,\n MaskInputOptions,\n SlimDOMOptions,\n MaskInputFn,\n MaskTextFn,\n} from 'rrweb-snapshot';\nimport { PackFn, UnpackFn } from './packer/base';\nimport { IframeManager } from './record/iframe-manager';\nimport { ShadowDomManager } from './record/shadow-dom-manager';\nimport type { Replayer } from './replay';\nimport { CanvasManager } from './record/observers/canvas/canvas-manager';\n\nexport enum EventType {\n DomContentLoaded,\n Load,\n FullSnapshot,\n IncrementalSnapshot,\n Meta,\n Custom,\n Plugin,\n}\n\nexport type domContentLoadedEvent = {\n type: EventType.DomContentLoaded;\n data: {};\n};\n\nexport type loadedEvent = {\n type: EventType.Load;\n data: {};\n};\n\nexport type fullSnapshotEvent = {\n type: EventType.FullSnapshot;\n data: {\n node: serializedNodeWithId;\n initialOffset: {\n top: number;\n left: number;\n };\n };\n};\n\nexport type incrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot;\n data: incrementalData;\n};\n\nexport type metaEvent = {\n type: EventType.Meta;\n data: {\n href: string;\n width: number;\n height: number;\n };\n};\n\nexport type customEvent = {\n type: EventType.Custom;\n data: {\n tag: string;\n payload: T;\n };\n};\n\nexport type pluginEvent = {\n type: EventType.Plugin;\n data: {\n plugin: string;\n payload: T;\n };\n};\n\nexport type styleSheetEvent = {};\n\nexport enum IncrementalSource {\n Mutation,\n MouseMove,\n MouseInteraction,\n Scroll,\n ViewportResize,\n Input,\n TouchMove,\n MediaInteraction,\n StyleSheetRule,\n CanvasMutation,\n Font,\n Log,\n Drag,\n StyleDeclaration,\n}\n\nexport type mutationData = {\n source: IncrementalSource.Mutation;\n} & mutationCallbackParam;\n\nexport type mousemoveData = {\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag;\n positions: mousePosition[];\n};\n\nexport type mouseInteractionData = {\n source: IncrementalSource.MouseInteraction;\n} & mouseInteractionParam;\n\nexport type scrollData = {\n source: IncrementalSource.Scroll;\n} & scrollPosition;\n\nexport type viewportResizeData = {\n source: IncrementalSource.ViewportResize;\n} & viewportResizeDimension;\n\nexport type inputData = {\n source: IncrementalSource.Input;\n id: number;\n} & inputValue;\n\nexport type mediaInteractionData = {\n source: IncrementalSource.MediaInteraction;\n} & mediaInteractionParam;\n\nexport type styleSheetRuleData = {\n source: IncrementalSource.StyleSheetRule;\n} & styleSheetRuleParam;\n\nexport type styleDeclarationData = {\n source: IncrementalSource.StyleDeclaration;\n} & styleDeclarationParam;\n\nexport type canvasMutationData = {\n source: IncrementalSource.CanvasMutation;\n} & canvasMutationParam;\n\nexport type fontData = {\n source: IncrementalSource.Font;\n} & fontParam;\n\nexport type incrementalData =\n | mutationData\n | mousemoveData\n | mouseInteractionData\n | scrollData\n | viewportResizeData\n | inputData\n | mediaInteractionData\n | styleSheetRuleData\n | canvasMutationData\n | fontData\n | styleDeclarationData;\n\nexport type event =\n | domContentLoadedEvent\n | loadedEvent\n | fullSnapshotEvent\n | incrementalSnapshotEvent\n | metaEvent\n | customEvent\n | pluginEvent;\n\nexport type eventWithTime = event & {\n timestamp: number;\n delay?: number;\n};\n\nexport type blockClass = string | RegExp;\n\nexport type maskTextClass = string | RegExp;\n\nexport type SamplingStrategy = Partial<{\n /**\n * false means not to record mouse/touch move events\n * number is the throttle threshold of recording mouse/touch move\n */\n mousemove: boolean | number;\n /**\n * number is the throttle threshold of mouse/touch move callback\n */\n mousemoveCallback: number;\n /**\n * false means not to record mouse interaction events\n * can also specify record some kinds of mouse interactions\n */\n mouseInteraction: boolean | Record;\n /**\n * number is the throttle threshold of recording scroll\n */\n scroll: number;\n /**\n * number is the throttle threshold of recording media interactions\n */\n media: number;\n /**\n * 'all' will record all the input events\n * 'last' will only record the last input value while input a sequence of chars\n */\n input: 'all' | 'last';\n}>;\n\nexport type RecordPlugin = {\n name: string;\n observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;\n eventProcessor?: (event: eventWithTime) => eventWithTime & TExtend;\n options: TOptions;\n};\n\nexport type recordOptions = {\n emit?: (e: T, isCheckout?: boolean) => void;\n checkoutEveryNth?: number;\n checkoutEveryNms?: number;\n blockClass?: blockClass;\n blockSelector?: string;\n unblockSelector?: string;\n ignoreClass?: string;\n ignoreSelector?: string;\n maskTextClass?: maskTextClass;\n maskTextSelector?: string;\n maskAllInputs?: boolean;\n maskInputSelector?: string;\n maskInputOptions?: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n unmaskTextSelector?: string;\n unmaskInputSelector?: string;\n slimDOMOptions?: SlimDOMOptions | 'all' | true;\n inlineStylesheet?: boolean;\n hooks?: hooksParam;\n packFn?: PackFn;\n sampling?: SamplingStrategy;\n recordCanvas?: boolean;\n userTriggeredOnInput?: boolean;\n collectFonts?: boolean;\n inlineImages?: boolean;\n plugins?: RecordPlugin[];\n // departed, please use sampling options\n mousemoveWait?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n};\n\nexport type observerParam = {\n mutationCb: mutationCallBack;\n mousemoveCb: mousemoveCallBack;\n mouseInteractionCb: mouseInteractionCallBack;\n scrollCb: scrollCallback;\n viewportResizeCb: viewportResizeCallback;\n inputCb: inputCallback;\n mediaInteractionCb: mediaInteractionCallback;\n blockClass: blockClass;\n blockSelector: string | null;\n unblockSelector: string | null;\n ignoreClass: string;\n ignoreSelector: string | null;\n maskTextClass: maskTextClass;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions: MaskInputOptions;\n maskInputFn?: MaskInputFn;\n maskTextFn?: MaskTextFn;\n inlineStylesheet: boolean;\n styleSheetRuleCb: styleSheetRuleCallback;\n styleDeclarationCb: styleDeclarationCallback;\n canvasMutationCb: canvasMutationCallback;\n fontCb: fontCallback;\n sampling: SamplingStrategy;\n recordCanvas: boolean;\n inlineImages: boolean;\n userTriggeredOnInput: boolean;\n collectFonts: boolean;\n slimDOMOptions: SlimDOMOptions;\n doc: Document;\n mirror: Mirror;\n iframeManager: IframeManager;\n shadowDomManager: ShadowDomManager;\n canvasManager: CanvasManager;\n plugins: Array<{\n observer: Function;\n callback: Function;\n options: unknown;\n }>;\n};\n\nexport type MutationBufferParam = Pick<\n observerParam,\n | 'mutationCb'\n | 'blockClass'\n | 'blockSelector'\n | 'unblockSelector'\n | 'maskTextClass'\n | 'maskTextSelector'\n | 'unmaskTextSelector'\n | 'inlineStylesheet'\n | 'maskInputSelector'\n | 'unmaskInputSelector'\n | 'maskInputOptions'\n | 'maskTextFn'\n | 'maskInputFn'\n | 'recordCanvas'\n | 'inlineImages'\n | 'slimDOMOptions'\n | 'doc'\n | 'mirror'\n | 'iframeManager'\n | 'shadowDomManager'\n | 'canvasManager'\n>;\n\nexport type hooksParam = {\n mutation?: mutationCallBack;\n mousemove?: mousemoveCallBack;\n mouseInteraction?: mouseInteractionCallBack;\n scroll?: scrollCallback;\n viewportResize?: viewportResizeCallback;\n input?: inputCallback;\n mediaInteaction?: mediaInteractionCallback;\n styleSheetRule?: styleSheetRuleCallback;\n styleDeclaration?: styleDeclarationCallback;\n canvasMutation?: canvasMutationCallback;\n font?: fontCallback;\n};\n\n// https://dom.spec.whatwg.org/#interface-mutationrecord\nexport type mutationRecord = {\n type: string;\n target: Node;\n oldValue: string | null;\n addedNodes: NodeList;\n removedNodes: NodeList;\n attributeName: string | null;\n};\n\nexport type textCursor = {\n node: Node;\n value: string | null;\n};\nexport type textMutation = {\n id: number;\n value: string | null;\n};\n\nexport type styleAttributeValue = {\n [key: string]: styleValueWithPriority | string | false;\n};\n\nexport type styleValueWithPriority = [string, string];\n\nexport type attributeCursor = {\n node: Node;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\nexport type attributeMutation = {\n id: number;\n attributes: {\n [key: string]: string | styleAttributeValue | null;\n };\n};\n\nexport type removedNodeMutation = {\n parentId: number;\n id: number;\n isShadow?: boolean;\n};\n\nexport type addedNodeMutation = {\n parentId: number;\n // Newly recorded mutations will not have previousId any more, just for compatibility\n previousId?: number | null;\n nextId: number | null;\n node: serializedNodeWithId;\n};\n\nexport type mutationCallbackParam = {\n texts: textMutation[];\n attributes: attributeMutation[];\n removes: removedNodeMutation[];\n adds: addedNodeMutation[];\n isAttachIframe?: true;\n};\n\nexport type mutationCallBack = (m: mutationCallbackParam) => void;\n\nexport type mousemoveCallBack = (\n p: mousePosition[],\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n) => void;\n\nexport type mousePosition = {\n x: number;\n y: number;\n id: number;\n timeOffset: number;\n};\n\nexport type mouseMovePos = {\n x: number;\n y: number;\n id: number;\n debugData: incrementalData;\n};\n\nexport enum MouseInteractions {\n MouseUp,\n MouseDown,\n Click,\n ContextMenu,\n DblClick,\n Focus,\n Blur,\n TouchStart,\n TouchMove_Departed, // we will start a separate observer for touch move event\n TouchEnd,\n TouchCancel,\n}\n\nexport enum CanvasContext {\n '2D',\n WebGL,\n WebGL2,\n}\n\nexport type SerializedWebGlArg =\n | {\n rr_type: 'ArrayBuffer';\n base64: string; // base64\n }\n | {\n rr_type: string;\n src: string; // url of image\n }\n | {\n rr_type: string;\n args: SerializedWebGlArg[];\n }\n | {\n rr_type: string;\n index: number;\n }\n | string\n | number\n | boolean\n | null\n | SerializedWebGlArg[];\n\ntype mouseInteractionParam = {\n type: MouseInteractions;\n id: number;\n x: number;\n y: number;\n};\n\nexport type mouseInteractionCallBack = (d: mouseInteractionParam) => void;\n\nexport type scrollPosition = {\n id: number;\n x: number;\n y: number;\n};\n\nexport type scrollCallback = (p: scrollPosition) => void;\n\nexport type styleSheetAddRule = {\n rule: string;\n index?: number | number[];\n};\n\nexport type styleSheetDeleteRule = {\n index: number | number[];\n};\n\nexport type styleSheetRuleParam = {\n id: number;\n removes?: styleSheetDeleteRule[];\n adds?: styleSheetAddRule[];\n};\n\nexport type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;\n\nexport type styleDeclarationParam = {\n id: number;\n index: number[];\n set?: {\n property: string;\n value: string | null;\n priority: string | undefined;\n };\n remove?: {\n property: string;\n };\n};\n\nexport type styleDeclarationCallback = (s: styleDeclarationParam) => void;\n\nexport type canvasMutationCommand = {\n property: string;\n args: Array;\n setter?: true;\n};\n\nexport type canvasMutationParam =\n | {\n id: number;\n type: CanvasContext;\n commands: canvasMutationCommand[];\n }\n | ({\n id: number;\n type: CanvasContext;\n } & canvasMutationCommand);\n\nexport type canvasMutationWithType = {\n type: CanvasContext;\n} & canvasMutationCommand;\n\nexport type canvasMutationCallback = (p: canvasMutationParam) => void;\n\nexport type canvasManagerMutationCallback = (\n target: HTMLCanvasElement,\n p: canvasMutationWithType,\n) => void;\n\nexport type fontParam = {\n family: string;\n fontSource: string;\n buffer: boolean;\n descriptors?: FontFaceDescriptors;\n};\n\nexport type fontCallback = (p: fontParam) => void;\n\nexport type viewportResizeDimension = {\n width: number;\n height: number;\n};\n\nexport type viewportResizeCallback = (d: viewportResizeDimension) => void;\n\nexport type inputValue = {\n text: string;\n isChecked: boolean;\n\n // `userTriggered` indicates if this event was triggered directly by user (userTriggered: true)\n // or was triggered indirectly (userTriggered: false)\n // Example of `userTriggered` in action:\n // User clicks on radio element (userTriggered: true) which triggers the other radio element to change (userTriggered: false)\n userTriggered?: boolean;\n};\n\nexport type inputCallback = (v: inputValue & { id: number }) => void;\n\nexport const enum MediaInteractions {\n Play,\n Pause,\n Seeked,\n VolumeChange,\n}\n\nexport type mediaInteractionParam = {\n type: MediaInteractions;\n id: number;\n currentTime?: number;\n volume?: number;\n muted?: boolean;\n};\n\nexport type mediaInteractionCallback = (p: mediaInteractionParam) => void;\n\nexport type DocumentDimension = {\n x: number;\n y: number;\n // scale value relative to its parent iframe\n relativeScale: number;\n // scale value relative to the root iframe\n absoluteScale: number;\n};\n\nexport type Mirror = {\n map: idNodeMap;\n getId: (n: INode) => number;\n getNode: (id: number) => INode | null;\n removeNodeFromMap: (n: INode) => void;\n has: (id: number) => boolean;\n reset: () => void;\n};\n\nexport type throttleOptions = {\n leading?: boolean;\n trailing?: boolean;\n};\n\nexport type listenerHandler = () => void;\nexport type hookResetter = () => void;\n\nexport type ReplayPlugin = {\n handler: (\n event: eventWithTime,\n isSync: boolean,\n context: { replayer: Replayer },\n ) => void;\n};\nexport type playerConfig = {\n speed: number;\n maxSpeed: number;\n root: Element;\n loadTimeout: number;\n skipInactive: boolean;\n showWarning: boolean;\n showDebug: boolean;\n blockClass: string;\n liveMode: boolean;\n insertStyleRules: string[];\n triggerFocus: boolean;\n UNSAFE_replayCanvas: boolean;\n pauseAnimation?: boolean;\n mouseTail:\n | boolean\n | {\n duration?: number;\n lineCap?: string;\n lineWidth?: number;\n strokeStyle?: string;\n };\n unpackFn?: UnpackFn;\n plugins?: ReplayPlugin[];\n};\n\nexport type playerMetaData = {\n startTime: number;\n endTime: number;\n totalTime: number;\n};\n\nexport type missingNode = {\n node: Node;\n mutation: addedNodeMutation;\n};\nexport type missingNodeMap = {\n [id: number]: missingNode;\n};\n\nexport type actionWithDelay = {\n doAction: () => void;\n delay: number;\n};\n\nexport type Handler = (event?: unknown) => void;\n\nexport type Emitter = {\n on(type: string, handler: Handler): void;\n emit(type: string, event?: unknown): void;\n off(type: string, handler: Handler): void;\n};\n\nexport type Arguments = T extends (...payload: infer U) => unknown\n ? U\n : unknown;\n\nexport enum ReplayerEvents {\n Start = 'start',\n Pause = 'pause',\n Resume = 'resume',\n Resize = 'resize',\n Finish = 'finish',\n FullsnapshotRebuilded = 'fullsnapshot-rebuilded',\n LoadStylesheetStart = 'load-stylesheet-start',\n LoadStylesheetEnd = 'load-stylesheet-end',\n SkipStart = 'skip-start',\n SkipEnd = 'skip-end',\n MouseInteraction = 'mouse-interaction',\n EventCast = 'event-cast',\n CustomEvent = 'custom-event',\n Flush = 'flush',\n StateChange = 'state-change',\n PlayBack = 'play-back',\n}\n\n// store the state that would be changed during the process(unmount from dom and mount again)\nexport type ElementState = {\n // [scrollLeft,scrollTop]\n scroll?: [number, number];\n};\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\ndeclare global {\n interface Window {\n FontFace: typeof FontFace;\n }\n}\n\nexport type IWindow = Window & typeof globalThis;\n\nexport type Optional = Pick, K> & Omit;\n","import {\n Mirror,\n throttleOptions,\n listenerHandler,\n hookResetter,\n blockClass,\n IncrementalSource,\n addedNodeMutation,\n removedNodeMutation,\n textMutation,\n attributeMutation,\n mutationData,\n scrollData,\n inputData,\n DocumentDimension,\n IWindow,\n} from './types';\nimport {\n INode,\n IGNORED_NODE,\n serializedNodeWithId,\n NodeType,\n isShadowRoot,\n} from 'rrweb-snapshot';\n\nexport function on(\n type: string,\n fn: EventListenerOrEventListenerObject,\n target: Document | IWindow = document,\n): listenerHandler {\n const options = { capture: true, passive: true };\n target.addEventListener(type, fn, options);\n return () => target.removeEventListener(type, fn, options);\n}\n\nexport function createMirror(): Mirror {\n return {\n map: {},\n getId(n) {\n // if n is not a serialized INode, use -1 as its id.\n if (!n || !n.__sn) {\n return -1;\n }\n return n.__sn.id;\n },\n getNode(id) {\n return this.map[id] || null;\n },\n // TODO: use a weakmap to get rid of manually memory management\n removeNodeFromMap(n) {\n const id = n.__sn && n.__sn.id;\n delete this.map[id];\n if (n.childNodes) {\n n.childNodes.forEach((child) =>\n this.removeNodeFromMap((child as Node) as INode),\n );\n }\n },\n has(id) {\n return this.map.hasOwnProperty(id);\n },\n reset() {\n this.map = {};\n },\n };\n}\n\n// https://github.com/rrweb-io/rrweb/pull/407\nconst DEPARTED_MIRROR_ACCESS_WARNING =\n 'Please stop import mirror directly. Instead of that,' +\n '\\r\\n' +\n 'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +\n '\\r\\n' +\n 'or you can use record.mirror to access the mirror instance during recording.';\nexport let _mirror: Mirror = {\n map: {},\n getId() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return -1;\n },\n getNode() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return null;\n },\n removeNodeFromMap() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n has() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n return false;\n },\n reset() {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n },\n};\nif (typeof window !== 'undefined' && window.Proxy && window.Reflect) {\n _mirror = new Proxy(_mirror, {\n get(target, prop, receiver) {\n if (prop === 'map') {\n console.error(DEPARTED_MIRROR_ACCESS_WARNING);\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n// copy from underscore and modified\nexport function throttle(\n func: (arg: T) => void,\n wait: number,\n options: throttleOptions = {},\n) {\n let timeout: ReturnType | null = null;\n let previous = 0;\n // tslint:disable-next-line: only-arrow-functions\n return function (arg: T) {\n let now = Date.now();\n if (!previous && options.leading === false) {\n previous = now;\n }\n let remaining = wait - (now - previous);\n let context = this;\n let args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n func.apply(context, args);\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(() => {\n previous = options.leading === false ? 0 : Date.now();\n timeout = null;\n func.apply(context, args);\n }, remaining);\n }\n };\n}\n\nexport function hookSetter(\n target: T,\n key: string | number | symbol,\n d: PropertyDescriptor,\n isRevoked?: boolean,\n win = window,\n): hookResetter {\n const original = win.Object.getOwnPropertyDescriptor(target, key);\n win.Object.defineProperty(\n target,\n key,\n isRevoked\n ? d\n : {\n set(value) {\n // put hooked setter into event loop to avoid of set latency\n setTimeout(() => {\n d.set!.call(this, value);\n }, 0);\n if (original && original.set) {\n original.set.call(this, value);\n }\n },\n },\n );\n return () => hookSetter(target, key, original || {}, true);\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n // tslint:disable-next-line:no-any\n source: { [key: string]: any },\n name: string,\n // tslint:disable-next-line:no-any\n replacement: (...args: any[]) => any,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {};\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n // tslint:disable-next-line:strict-type-predicates\n if (typeof wrapped === 'function') {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {};\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function getWindowHeight(): number {\n return (\n window.innerHeight ||\n (document.documentElement && document.documentElement.clientHeight) ||\n (document.body && document.body.clientHeight)\n );\n}\n\nexport function getWindowWidth(): number {\n return (\n window.innerWidth ||\n (document.documentElement && document.documentElement.clientWidth) ||\n (document.body && document.body.clientWidth)\n );\n}\n\nexport function isBlocked(node: Node | null, blockClass: blockClass): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n let needBlock = false;\n if (typeof blockClass === 'string') {\n if ((node as HTMLElement).closest !== undefined) {\n return (node as HTMLElement).closest('.' + blockClass) !== null;\n } else {\n needBlock = (node as HTMLElement).classList.contains(blockClass);\n }\n } else {\n (node as HTMLElement).classList.forEach((className) => {\n if (blockClass.test(className)) {\n needBlock = true;\n }\n });\n }\n return needBlock || isBlocked(node.parentNode, blockClass);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return isBlocked(node.parentNode, blockClass);\n }\n return isBlocked(node.parentNode, blockClass);\n}\n\nexport function isIgnored(n: Node | INode): boolean {\n if ('__sn' in n) {\n return (n as INode).__sn.id === IGNORED_NODE;\n }\n // The main part of the slimDOM check happens in\n // rrweb-snapshot::serializeNodeWithId\n return false;\n}\n\nexport function isAncestorRemoved(target: INode, mirror: Mirror): boolean {\n if (isShadowRoot(target)) {\n return false;\n }\n const id = mirror.getId(target);\n if (!mirror.has(id)) {\n return true;\n }\n if (\n target.parentNode &&\n target.parentNode.nodeType === target.DOCUMENT_NODE\n ) {\n return false;\n }\n // if the root is not document, it means the node is not in the DOM tree anymore\n if (!target.parentNode) {\n return true;\n }\n return isAncestorRemoved((target.parentNode as unknown) as INode, mirror);\n}\n\nexport function isTouchEvent(\n event: MouseEvent | TouchEvent,\n): event is TouchEvent {\n return Boolean((event as TouchEvent).changedTouches);\n}\n\nexport function polyfill(win = window) {\n if ('NodeList' in win && !win.NodeList.prototype.forEach) {\n win.NodeList.prototype.forEach = (Array.prototype\n .forEach as unknown) as NodeList['forEach'];\n }\n\n if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {\n win.DOMTokenList.prototype.forEach = (Array.prototype\n .forEach as unknown) as DOMTokenList['forEach'];\n }\n\n // https://github.com/Financial-Times/polyfill-service/pull/183\n if (!Node.prototype.contains) {\n Node.prototype.contains = function contains(node) {\n if (!(0 in arguments)) {\n throw new TypeError('1 argument is required');\n }\n\n do {\n if (this === node) {\n return true;\n }\n // tslint:disable-next-line: no-conditional-assignment\n } while ((node = node && node.parentNode));\n\n return false;\n };\n }\n}\n\nexport type TreeNode = {\n id: number;\n mutation: addedNodeMutation;\n parent?: TreeNode;\n children: Record;\n texts: textMutation[];\n attributes: attributeMutation[];\n};\nexport class TreeIndex {\n public tree!: Record;\n\n private removeNodeMutations!: removedNodeMutation[];\n private textMutations!: textMutation[];\n private attributeMutations!: attributeMutation[];\n private indexes!: Map;\n private removeIdSet!: Set;\n private scrollMap!: Map;\n private inputMap!: Map;\n\n constructor() {\n this.reset();\n }\n\n public add(mutation: addedNodeMutation) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode: TreeNode = {\n id: mutation.node.id,\n mutation,\n children: [],\n texts: [],\n attributes: [],\n };\n if (!parentTreeNode) {\n this.tree[treeNode.id] = treeNode;\n } else {\n treeNode.parent = parentTreeNode;\n parentTreeNode.children[treeNode.id] = treeNode;\n }\n this.indexes.set(treeNode.id, treeNode);\n }\n\n public remove(mutation: removedNodeMutation, mirror: Mirror) {\n const parentTreeNode = this.indexes.get(mutation.parentId);\n const treeNode = this.indexes.get(mutation.id);\n\n const deepRemoveFromMirror = (id: number) => {\n this.removeIdSet.add(id);\n const node = mirror.getNode(id);\n node?.childNodes.forEach((childNode) => {\n if ('__sn' in childNode) {\n deepRemoveFromMirror(((childNode as unknown) as INode).__sn.id);\n }\n });\n };\n const deepRemoveFromTreeIndex = (node: TreeNode) => {\n this.removeIdSet.add(node.id);\n Object.values(node.children).forEach((n) => deepRemoveFromTreeIndex(n));\n const _treeNode = this.indexes.get(node.id);\n if (_treeNode) {\n const _parentTreeNode = _treeNode.parent;\n if (_parentTreeNode) {\n delete _treeNode.parent;\n delete _parentTreeNode.children[_treeNode.id];\n this.indexes.delete(mutation.id);\n }\n }\n };\n\n if (!treeNode) {\n this.removeNodeMutations.push(mutation);\n deepRemoveFromMirror(mutation.id);\n } else if (!parentTreeNode) {\n delete this.tree[treeNode.id];\n this.indexes.delete(treeNode.id);\n deepRemoveFromTreeIndex(treeNode);\n } else {\n delete treeNode.parent;\n delete parentTreeNode.children[treeNode.id];\n this.indexes.delete(mutation.id);\n deepRemoveFromTreeIndex(treeNode);\n }\n }\n\n public text(mutation: textMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.texts.push(mutation);\n } else {\n this.textMutations.push(mutation);\n }\n }\n\n public attribute(mutation: attributeMutation) {\n const treeNode = this.indexes.get(mutation.id);\n if (treeNode) {\n treeNode.attributes.push(mutation);\n } else {\n this.attributeMutations.push(mutation);\n }\n }\n\n public scroll(d: scrollData) {\n this.scrollMap.set(d.id, d);\n }\n\n public input(d: inputData) {\n this.inputMap.set(d.id, d);\n }\n\n public flush(): {\n mutationData: mutationData;\n scrollMap: TreeIndex['scrollMap'];\n inputMap: TreeIndex['inputMap'];\n } {\n const {\n tree,\n removeNodeMutations,\n textMutations,\n attributeMutations,\n } = this;\n\n const batchMutationData: mutationData = {\n source: IncrementalSource.Mutation,\n removes: removeNodeMutations,\n texts: textMutations,\n attributes: attributeMutations,\n adds: [],\n };\n\n const walk = (treeNode: TreeNode, removed: boolean) => {\n if (removed) {\n this.removeIdSet.add(treeNode.id);\n }\n batchMutationData.texts = batchMutationData.texts\n .concat(removed ? [] : treeNode.texts)\n .filter((m) => !this.removeIdSet.has(m.id));\n batchMutationData.attributes = batchMutationData.attributes\n .concat(removed ? [] : treeNode.attributes)\n .filter((m) => !this.removeIdSet.has(m.id));\n if (\n !this.removeIdSet.has(treeNode.id) &&\n !this.removeIdSet.has(treeNode.mutation.parentId) &&\n !removed\n ) {\n batchMutationData.adds.push(treeNode.mutation);\n if (treeNode.children) {\n Object.values(treeNode.children).forEach((n) => walk(n, false));\n }\n } else {\n Object.values(treeNode.children).forEach((n) => walk(n, true));\n }\n };\n\n Object.values(tree).forEach((n) => walk(n, false));\n\n for (const id of this.scrollMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.scrollMap.delete(id);\n }\n }\n for (const id of this.inputMap.keys()) {\n if (this.removeIdSet.has(id)) {\n this.inputMap.delete(id);\n }\n }\n\n const scrollMap = new Map(this.scrollMap);\n const inputMap = new Map(this.inputMap);\n\n this.reset();\n\n return {\n mutationData: batchMutationData,\n scrollMap,\n inputMap,\n };\n }\n\n private reset() {\n this.tree = [];\n this.indexes = new Map();\n this.removeNodeMutations = [];\n this.textMutations = [];\n this.attributeMutations = [];\n this.removeIdSet = new Set();\n this.scrollMap = new Map();\n this.inputMap = new Map();\n }\n\n public idRemoved(id: number): boolean {\n return this.removeIdSet.has(id);\n }\n}\n\ntype ResolveTree = {\n value: addedNodeMutation;\n children: ResolveTree[];\n parent: ResolveTree | null;\n};\n\nexport function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {\n const queueNodeMap: Record = {};\n const putIntoMap = (\n m: addedNodeMutation,\n parent: ResolveTree | null,\n ): ResolveTree => {\n const nodeInTree: ResolveTree = {\n value: m,\n parent,\n children: [],\n };\n queueNodeMap[m.node.id] = nodeInTree;\n return nodeInTree;\n };\n\n const queueNodeTrees: ResolveTree[] = [];\n for (const mutation of queue) {\n const { nextId, parentId } = mutation;\n if (nextId && nextId in queueNodeMap) {\n const nextInTree = queueNodeMap[nextId];\n if (nextInTree.parent) {\n const idx = nextInTree.parent.children.indexOf(nextInTree);\n nextInTree.parent.children.splice(\n idx,\n 0,\n putIntoMap(mutation, nextInTree.parent),\n );\n } else {\n const idx = queueNodeTrees.indexOf(nextInTree);\n queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));\n }\n continue;\n }\n if (parentId in queueNodeMap) {\n const parentInTree = queueNodeMap[parentId];\n parentInTree.children.push(putIntoMap(mutation, parentInTree));\n continue;\n }\n queueNodeTrees.push(putIntoMap(mutation, null));\n }\n\n return queueNodeTrees;\n}\n\nexport function iterateResolveTree(\n tree: ResolveTree,\n cb: (mutation: addedNodeMutation) => unknown,\n) {\n cb(tree.value);\n /**\n * The resolve tree was designed to reflect the DOM layout,\n * but we need append next sibling first, so we do a reverse\n * loop here.\n */\n for (let i = tree.children.length - 1; i >= 0; i--) {\n iterateResolveTree(tree.children[i], cb);\n }\n}\n\ntype HTMLIFrameINode = HTMLIFrameElement & {\n __sn: serializedNodeWithId;\n};\nexport type AppendedIframe = {\n mutationInQueue: addedNodeMutation;\n builtNode: HTMLIFrameINode;\n};\n\nexport function isIframeINode(\n node: INode | ShadowRoot,\n): node is HTMLIFrameINode {\n if ('__sn' in node) {\n return (\n node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe'\n );\n }\n // node can be document fragment when using the virtual parent feature\n return false;\n}\n\nexport function getBaseDimension(\n node: Node,\n rootIframe: Node,\n): DocumentDimension {\n const frameElement = node.ownerDocument?.defaultView?.frameElement;\n if (!frameElement || frameElement === rootIframe) {\n return {\n x: 0,\n y: 0,\n relativeScale: 1,\n absoluteScale: 1,\n };\n }\n\n const frameDimension = frameElement.getBoundingClientRect();\n const frameBaseDimension = getBaseDimension(frameElement, rootIframe);\n // the iframe element may have a scale transform\n const relativeScale = frameDimension.height / frameElement.clientHeight;\n return {\n x:\n frameDimension.x * frameBaseDimension.relativeScale +\n frameBaseDimension.x,\n y:\n frameDimension.y * frameBaseDimension.relativeScale +\n frameBaseDimension.y,\n relativeScale,\n absoluteScale: frameBaseDimension.absoluteScale * relativeScale,\n };\n}\n\nexport function hasShadowRoot(\n n: T,\n): n is T & { shadowRoot: ShadowRoot } {\n return Boolean(((n as unknown) as Element)?.shadowRoot);\n}\n","import {\n INode,\n serializeNodeWithId,\n transformAttribute,\n IGNORED_NODE,\n isShadowRoot,\n needMaskingText,\n maskInputValue,\n} from 'rrweb-snapshot';\nimport {\n mutationRecord,\n textCursor,\n attributeCursor,\n removedNodeMutation,\n addedNodeMutation,\n Mirror,\n styleAttributeValue,\n observerParam,\n MutationBufferParam,\n Optional,\n} from '../types';\nimport {\n isBlocked,\n isAncestorRemoved,\n isIgnored,\n isIframeINode,\n hasShadowRoot,\n} from '../utils';\n\ntype DoubleLinkedListNode = {\n previous: DoubleLinkedListNode | null;\n next: DoubleLinkedListNode | null;\n value: NodeInLinkedList;\n};\ntype NodeInLinkedList = Node & {\n __ln: DoubleLinkedListNode;\n};\n\nfunction isNodeInLinkedList(n: Node | NodeInLinkedList): n is NodeInLinkedList {\n return '__ln' in n;\n}\nclass DoubleLinkedList {\n public length = 0;\n public head: DoubleLinkedListNode | null = null;\n\n public get(position: number) {\n if (position >= this.length) {\n throw new Error('Position outside of list range');\n }\n\n let current = this.head;\n for (let index = 0; index < position; index++) {\n current = current?.next || null;\n }\n return current;\n }\n\n public addNode(n: Node) {\n const node: DoubleLinkedListNode = {\n value: n as NodeInLinkedList,\n previous: null,\n next: null,\n };\n (n as NodeInLinkedList).__ln = node;\n if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {\n const current = n.previousSibling.__ln.next;\n node.next = current;\n node.previous = n.previousSibling.__ln;\n n.previousSibling.__ln.next = node;\n if (current) {\n current.previous = node;\n }\n } else if (\n n.nextSibling &&\n isNodeInLinkedList(n.nextSibling) &&\n n.nextSibling.__ln.previous\n ) {\n const current = n.nextSibling.__ln.previous;\n node.previous = current;\n node.next = n.nextSibling.__ln;\n n.nextSibling.__ln.previous = node;\n if (current) {\n current.next = node;\n }\n } else {\n if (this.head) {\n this.head.previous = node;\n }\n node.next = this.head;\n this.head = node;\n }\n this.length++;\n }\n\n public removeNode(n: NodeInLinkedList) {\n const current = n.__ln;\n if (!this.head) {\n return;\n }\n\n if (!current.previous) {\n this.head = current.next;\n if (this.head) {\n this.head.previous = null;\n }\n } else {\n current.previous.next = current.next;\n if (current.next) {\n current.next.previous = current.previous;\n }\n }\n if (n.__ln) {\n delete (n as Optional).__ln;\n }\n this.length--;\n }\n}\n\nconst moveKey = (id: number, parentId: number) => `${id}@${parentId}`;\nfunction isINode(n: Node | INode): n is INode {\n return '__sn' in n;\n}\n\n/**\n * controls behaviour of a MutationObserver\n */\nexport default class MutationBuffer {\n private frozen: boolean = false;\n private locked: boolean = false;\n\n private texts: textCursor[] = [];\n private attributes: attributeCursor[] = [];\n private removes: removedNodeMutation[] = [];\n private mapRemoves: Node[] = [];\n\n private movedMap: Record = {};\n\n /**\n * the browser MutationObserver emits multiple mutations after\n * a delay for performance reasons, making tracing added nodes hard\n * in our `processMutations` callback function.\n * For example, if we append an element el_1 into body, and then append\n * another element el_2 into el_1, these two mutations may be passed to the\n * callback function together when the two operations were done.\n * Generally we need to trace child nodes of newly added nodes, but in this\n * case if we count el_2 as el_1's child node in the first mutation record,\n * then we will count el_2 again in the second mutation record which was\n * duplicated.\n * To avoid of duplicate counting added nodes, we use a Set to store\n * added nodes and its child nodes during iterate mutation records. Then\n * collect added nodes from the Set which have no duplicate copy. But\n * this also causes newly added nodes will not be serialized with id ASAP,\n * which means all the id related calculation should be lazy too.\n */\n private addedSet = new Set();\n private movedSet = new Set();\n private droppedSet = new Set();\n\n private mutationCb: observerParam['mutationCb'];\n private blockClass: observerParam['blockClass'];\n private blockSelector: observerParam['blockSelector'];\n private unblockSelector: observerParam['unblockSelector'];\n private maskTextClass: observerParam['maskTextClass'];\n private maskTextSelector: observerParam['maskTextSelector'];\n private unmaskTextSelector: observerParam['unmaskTextSelector'];\n private maskInputSelector: observerParam['maskInputSelector'];\n private unmaskInputSelector: observerParam['unmaskInputSelector'];\n private inlineStylesheet: observerParam['inlineStylesheet'];\n private maskInputOptions: observerParam['maskInputOptions'];\n private maskTextFn: observerParam['maskTextFn'];\n private maskInputFn: observerParam['maskInputFn'];\n private recordCanvas: observerParam['recordCanvas'];\n private inlineImages: observerParam['inlineImages'];\n private slimDOMOptions: observerParam['slimDOMOptions'];\n private doc: observerParam['doc'];\n private mirror: observerParam['mirror'];\n private iframeManager: observerParam['iframeManager'];\n private shadowDomManager: observerParam['shadowDomManager'];\n private canvasManager: observerParam['canvasManager'];\n\n public init(options: MutationBufferParam) {\n ([\n 'mutationCb',\n 'blockClass',\n 'blockSelector',\n 'unblockSelector',\n 'maskTextClass',\n 'maskTextSelector',\n 'unmaskTextSelector',\n 'maskInputSelector',\n 'unmaskInputSelector',\n 'inlineStylesheet',\n 'maskInputOptions',\n 'maskTextFn',\n 'maskInputFn',\n 'recordCanvas',\n 'inlineImages',\n 'slimDOMOptions',\n 'doc',\n 'mirror',\n 'iframeManager',\n 'shadowDomManager',\n 'canvasManager',\n ] as const).forEach((key) => {\n // just a type trick, the runtime result is correct\n this[key] = options[key] as never;\n });\n }\n\n public freeze() {\n this.frozen = true;\n this.canvasManager.freeze();\n }\n\n public unfreeze() {\n this.frozen = false;\n this.canvasManager.unfreeze();\n this.emit();\n }\n\n public isFrozen() {\n return this.frozen;\n }\n\n public lock() {\n this.locked = true;\n this.canvasManager.lock();\n }\n\n public unlock() {\n this.locked = false;\n this.canvasManager.unlock();\n this.emit();\n }\n\n public reset() {\n this.shadowDomManager.reset();\n this.canvasManager.reset();\n }\n\n public processMutations = (mutations: mutationRecord[]) => {\n mutations.forEach(this.processMutation); // adds mutations to the buffer\n this.emit(); // clears buffer if not locked/frozen\n };\n\n public emit = () => {\n if (this.frozen || this.locked) {\n return;\n }\n\n // delay any modification of the mirror until this function\n // so that the mirror for takeFullSnapshot doesn't get mutated while it's event is being processed\n\n const adds: addedNodeMutation[] = [];\n\n /**\n * Sometimes child node may be pushed before its newly added\n * parent, so we init a queue to store these nodes.\n */\n const addList = new DoubleLinkedList();\n const getNextId = (n: Node): number | null => {\n let ns: Node | null = n;\n let nextId: number | null = IGNORED_NODE; // slimDOM: ignored\n while (nextId === IGNORED_NODE) {\n ns = ns && ns.nextSibling;\n nextId = ns && this.mirror.getId((ns as unknown) as INode);\n }\n return nextId;\n };\n const pushAdd = (n: Node) => {\n const shadowHost: Element | null = n.getRootNode\n ? (n.getRootNode() as ShadowRoot)?.host\n : null;\n // If n is in a nested shadow dom.\n let rootShadowHost = shadowHost;\n while ((rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host)\n rootShadowHost =\n (rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host ||\n null;\n // ensure shadowHost is a Node, or doc.contains will throw an error\n const notInDoc =\n !this.doc.contains(n) &&\n (rootShadowHost === null || !this.doc.contains(rootShadowHost));\n if (!n.parentNode || notInDoc) {\n return;\n }\n const parentId = isShadowRoot(n.parentNode)\n ? this.mirror.getId((shadowHost as unknown) as INode)\n : this.mirror.getId((n.parentNode as Node) as INode);\n const nextId = getNextId(n);\n if (parentId === -1 || nextId === -1) {\n return addList.addNode(n);\n }\n let sn = serializeNodeWithId(n, {\n doc: this.doc,\n map: this.mirror.map,\n blockClass: this.blockClass,\n blockSelector: this.blockSelector,\n unblockSelector: this.unblockSelector,\n maskTextClass: this.maskTextClass,\n maskTextSelector: this.maskTextSelector,\n unmaskTextSelector: this.unmaskTextSelector,\n maskInputSelector: this.maskInputSelector,\n unmaskInputSelector: this.unmaskInputSelector,\n skipChild: true,\n inlineStylesheet: this.inlineStylesheet,\n maskInputOptions: this.maskInputOptions,\n maskTextFn: this.maskTextFn,\n maskInputFn: this.maskInputFn,\n slimDOMOptions: this.slimDOMOptions,\n recordCanvas: this.recordCanvas,\n inlineImages: this.inlineImages,\n onSerialize: (currentN) => {\n if (isIframeINode(currentN)) {\n this.iframeManager.addIframe(currentN);\n }\n if (hasShadowRoot(n)) {\n this.shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n this.iframeManager.attachIframe(iframe, childSn);\n this.shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n });\n if (sn) {\n adds.push({\n parentId,\n nextId,\n node: sn,\n });\n }\n };\n\n while (this.mapRemoves.length) {\n this.mirror.removeNodeFromMap(this.mapRemoves.shift() as INode);\n }\n\n for (const n of this.movedSet) {\n if (\n isParentRemoved(this.removes, n, this.mirror) &&\n !this.movedSet.has(n.parentNode!)\n ) {\n continue;\n }\n pushAdd(n);\n }\n\n for (const n of this.addedSet) {\n if (\n !isAncestorInSet(this.droppedSet, n) &&\n !isParentRemoved(this.removes, n, this.mirror)\n ) {\n pushAdd(n);\n } else if (isAncestorInSet(this.movedSet, n)) {\n pushAdd(n);\n } else {\n this.droppedSet.add(n);\n }\n }\n\n let candidate: DoubleLinkedListNode | null = null;\n while (addList.length) {\n let node: DoubleLinkedListNode | null = null;\n if (candidate) {\n const parentId = this.mirror.getId(\n (candidate.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(candidate.value);\n if (parentId !== -1 && nextId !== -1) {\n node = candidate;\n }\n }\n if (!node) {\n for (let index = addList.length - 1; index >= 0; index--) {\n const _node = addList.get(index)!;\n // ensure _node is defined before attempting to find value\n if (_node) {\n const parentId = this.mirror.getId(\n (_node.value.parentNode as Node) as INode,\n );\n const nextId = getNextId(_node.value);\n if (parentId !== -1 && nextId !== -1) {\n node = _node;\n break;\n }\n }\n }\n }\n if (!node) {\n /**\n * If all nodes in queue could not find a serialized parent,\n * it may be a bug or corner case. We need to escape the\n * dead while loop at once.\n */\n while (addList.head) {\n addList.removeNode(addList.head.value);\n }\n break;\n }\n candidate = node.previous;\n addList.removeNode(node.value);\n pushAdd(node.value);\n }\n\n const payload = {\n texts: this.texts\n .map((text) => ({\n id: this.mirror.getId(text.node as INode),\n value: text.value,\n }))\n // text mutation's id was not in the mirror map means the target node has been removed\n .filter((text) => this.mirror.has(text.id)),\n attributes: this.attributes\n .map((attribute) => ({\n id: this.mirror.getId(attribute.node as INode),\n attributes: attribute.attributes,\n }))\n // attribute mutation's id was not in the mirror map means the target node has been removed\n .filter((attribute) => this.mirror.has(attribute.id)),\n removes: this.removes,\n adds,\n };\n // payload may be empty if the mutations happened in some blocked elements\n if (\n !payload.texts.length &&\n !payload.attributes.length &&\n !payload.removes.length &&\n !payload.adds.length\n ) {\n return;\n }\n\n // reset\n this.texts = [];\n this.attributes = [];\n this.removes = [];\n this.addedSet = new Set();\n this.movedSet = new Set();\n this.droppedSet = new Set();\n this.movedMap = {};\n\n this.mutationCb(payload);\n };\n\n private processMutation = (m: mutationRecord) => {\n if (isIgnored(m.target)) {\n return;\n }\n switch (m.type) {\n case 'characterData': {\n const value = m.target.textContent;\n if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {\n this.texts.push({\n value:\n needMaskingText(\n m.target,\n this.maskTextClass,\n this.maskTextSelector,\n this.unmaskTextSelector\n ) && value\n ? this.maskTextFn\n ? this.maskTextFn(value)\n : value.replace(/[\\S]/g, '*')\n : value,\n node: m.target,\n });\n }\n break;\n }\n case 'attributes': {\n const target = m.target as HTMLElement;\n let value = (m.target as HTMLElement).getAttribute(m.attributeName!);\n if (m.attributeName === 'value') {\n value = maskInputValue({\n input: target,\n maskInputSelector: this.maskInputSelector,\n unmaskInputSelector: this.unmaskInputSelector,\n maskInputOptions: this.maskInputOptions,\n tagName: (m.target as HTMLElement).tagName,\n type: (m.target as HTMLElement).getAttribute('type'),\n value,\n maskInputFn: this.maskInputFn,\n });\n }\n if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {\n return;\n }\n let item: attributeCursor | undefined = this.attributes.find(\n (a) => a.node === m.target,\n );\n if (!item) {\n item = {\n node: m.target,\n attributes: {},\n };\n this.attributes.push(item);\n }\n if (m.attributeName === 'style') {\n const old = this.doc.createElement('span');\n if (m.oldValue) {\n old.setAttribute('style', m.oldValue);\n }\n if (\n item.attributes.style === undefined ||\n item.attributes.style === null\n ) {\n item.attributes.style = {};\n }\n const styleObj = item.attributes.style as styleAttributeValue;\n for (const pname of Array.from(target.style)) {\n const newValue = target.style.getPropertyValue(pname);\n const newPriority = target.style.getPropertyPriority(pname);\n if (\n newValue !== old.style.getPropertyValue(pname) ||\n newPriority !== old.style.getPropertyPriority(pname)\n ) {\n if (newPriority === '') {\n styleObj[pname] = newValue;\n } else {\n styleObj[pname] = [newValue, newPriority];\n }\n }\n }\n for (const pname of Array.from(old.style)) {\n if (target.style.getPropertyValue(pname) === '') {\n // \"if not set, returns the empty string\"\n styleObj[pname] = false; // delete\n }\n }\n } else {\n // overwrite attribute if the mutations was triggered in same time\n item.attributes[m.attributeName!] = transformAttribute(\n this.doc,\n (m.target as HTMLElement).tagName,\n m.attributeName!,\n value!,\n );\n }\n break;\n }\n case 'childList': {\n m.addedNodes.forEach((n) => this.genAdds(n, m.target));\n m.removedNodes.forEach((n) => {\n const nodeId = this.mirror.getId(n as INode);\n const parentId = isShadowRoot(m.target)\n ? this.mirror.getId((m.target.host as unknown) as INode)\n : this.mirror.getId(m.target as INode);\n if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {\n return;\n }\n // removed node has not been serialized yet, just remove it from the Set\n if (this.addedSet.has(n)) {\n deepDelete(this.addedSet, n);\n this.droppedSet.add(n);\n } else if (this.addedSet.has(m.target) && nodeId === -1) {\n /**\n * If target was newly added and removed child node was\n * not serialized, it means the child node has been removed\n * before callback fired, so we can ignore it because\n * newly added node will be serialized without child nodes.\n * TODO: verify this\n */\n } else if (isAncestorRemoved(m.target as INode, this.mirror)) {\n /**\n * If parent id was not in the mirror map any more, it\n * means the parent node has already been removed. So\n * the node is also removed which we do not need to track\n * and replay.\n */\n } else if (\n this.movedSet.has(n) &&\n this.movedMap[moveKey(nodeId, parentId)]\n ) {\n deepDelete(this.movedSet, n);\n } else {\n this.removes.push({\n parentId,\n id: nodeId,\n isShadow: isShadowRoot(m.target) ? true : undefined,\n });\n }\n this.mapRemoves.push(n);\n });\n break;\n }\n default:\n break;\n }\n };\n\n private genAdds = (n: Node | INode, target?: Node | INode) => {\n // parent was blocked, so we can ignore this node\n if (target && isBlocked(target, this.blockClass)) {\n return;\n }\n if (isINode(n)) {\n if (isIgnored(n)) {\n return;\n }\n this.movedSet.add(n);\n let targetId: number | null = null;\n if (target && isINode(target)) {\n targetId = target.__sn.id;\n }\n if (targetId) {\n this.movedMap[moveKey(n.__sn.id, targetId)] = true;\n }\n } else {\n this.addedSet.add(n);\n this.droppedSet.delete(n);\n }\n\n // if this node is blocked `serializeNode` will turn it into a placeholder element\n // but we have to remove it's children otherwise they will be added as placeholders too\n if (!isBlocked(n, this.blockClass))\n n.childNodes.forEach((childN) => this.genAdds(childN));\n };\n}\n\n/**\n * Some utils to handle the mutation observer DOM records.\n * It should be more clear to extend the native data structure\n * like Set and Map, but currently Typescript does not support\n * that.\n */\nfunction deepDelete(addsSet: Set, n: Node) {\n addsSet.delete(n);\n n.childNodes.forEach((childN) => deepDelete(addsSet, childN));\n}\n\nfunction isParentRemoved(\n removes: removedNodeMutation[],\n n: Node,\n mirror: Mirror,\n): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n const parentId = mirror.getId((parentNode as Node) as INode);\n if (removes.some((r) => r.id === parentId)) {\n return true;\n }\n return isParentRemoved(removes, parentNode, mirror);\n}\n\nfunction isAncestorInSet(set: Set, n: Node): boolean {\n const { parentNode } = n;\n if (!parentNode) {\n return false;\n }\n if (set.has(parentNode)) {\n return true;\n }\n return isAncestorInSet(set, parentNode);\n}\n","import { INode, MaskInputOptions, maskInputValue } from 'rrweb-snapshot';\nimport { FontFaceSet } from 'css-font-loading-module';\nimport {\n throttle,\n on,\n hookSetter,\n getWindowHeight,\n getWindowWidth,\n isBlocked,\n isTouchEvent,\n patch,\n} from '../utils';\nimport {\n mutationCallBack,\n observerParam,\n mousemoveCallBack,\n mousePosition,\n mouseInteractionCallBack,\n MouseInteractions,\n listenerHandler,\n scrollCallback,\n styleSheetRuleCallback,\n viewportResizeCallback,\n inputValue,\n inputCallback,\n hookResetter,\n IncrementalSource,\n hooksParam,\n Arguments,\n mediaInteractionCallback,\n MediaInteractions,\n canvasMutationCallback,\n fontCallback,\n fontParam,\n styleDeclarationCallback,\n IWindow,\n MutationBufferParam,\n} from '../types';\nimport MutationBuffer from './mutation';\n\ntype WindowWithStoredMutationObserver = IWindow & {\n __rrMutationObserver?: MutationObserver;\n};\ntype WindowWithAngularZone = IWindow & {\n Zone?: {\n __symbol__?: (key: string) => string;\n };\n};\n\nexport const mutationBuffers: MutationBuffer[] = [];\n\nconst isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';\nconst isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';\nconst isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';\nconst isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';\n\n// Event.path is non-standard and used in some older browsers\ntype NonStandardEvent = Omit & {\n path: EventTarget[];\n};\n\nfunction getEventTarget(event: Event | NonStandardEvent): EventTarget | null {\n try {\n if ('composedPath' in event) {\n const path = event.composedPath();\n if (path.length) {\n return path[0];\n }\n } else if ('path' in event && event.path.length) {\n return event.path[0];\n }\n return event.target;\n } catch {\n return event.target;\n }\n}\n\nexport function initMutationObserver(\n options: MutationBufferParam,\n rootEl: Node,\n): MutationObserver {\n const mutationBuffer = new MutationBuffer();\n mutationBuffers.push(mutationBuffer);\n // see mutation.ts for details\n mutationBuffer.init(options);\n let mutationObserverCtor =\n window.MutationObserver ||\n /**\n * Some websites may disable MutationObserver by removing it from the window object.\n * If someone is using rrweb to build a browser extention or things like it, they\n * could not change the website's code but can have an opportunity to inject some\n * code before the website executing its JS logic.\n * Then they can do this to store the native MutationObserver:\n * window.__rrMutationObserver = MutationObserver\n */\n (window as WindowWithStoredMutationObserver).__rrMutationObserver;\n const angularZoneSymbol = (window as WindowWithAngularZone)?.Zone?.__symbol__?.(\n 'MutationObserver',\n );\n if (\n angularZoneSymbol &&\n ((window as unknown) as Record)[\n angularZoneSymbol\n ]\n ) {\n mutationObserverCtor = ((window as unknown) as Record<\n string,\n typeof MutationObserver\n >)[angularZoneSymbol];\n }\n const observer = new mutationObserverCtor(\n mutationBuffer.processMutations.bind(mutationBuffer),\n );\n observer.observe(rootEl, {\n attributes: true,\n attributeOldValue: true,\n characterData: true,\n characterDataOldValue: true,\n childList: true,\n subtree: true,\n });\n return observer;\n}\n\nfunction initMoveObserver({\n mousemoveCb,\n sampling,\n doc,\n mirror,\n}: observerParam): listenerHandler {\n if (sampling.mousemove === false) {\n return () => {};\n }\n\n const threshold =\n typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;\n const callbackThreshold =\n typeof sampling.mousemoveCallback === 'number'\n ? sampling.mousemoveCallback\n : 500;\n\n let positions: mousePosition[] = [];\n let timeBaseline: number | null;\n const wrappedCb = throttle(\n (\n source:\n | IncrementalSource.MouseMove\n | IncrementalSource.TouchMove\n | IncrementalSource.Drag,\n ) => {\n const totalOffset = Date.now() - timeBaseline!;\n mousemoveCb(\n positions.map((p) => {\n p.timeOffset -= totalOffset;\n return p;\n }),\n source,\n );\n positions = [];\n timeBaseline = null;\n },\n callbackThreshold,\n );\n const updatePosition = throttle(\n (evt) => {\n const target = getEventTarget(evt);\n const { clientX, clientY } = isTouchEvent(evt)\n ? evt.changedTouches[0]\n : evt;\n if (!timeBaseline) {\n timeBaseline = Date.now();\n }\n positions.push({\n x: clientX,\n y: clientY,\n id: mirror.getId(target as INode),\n timeOffset: Date.now() - timeBaseline,\n });\n // it is possible DragEvent is undefined even on devices\n // that support event 'drag'\n wrappedCb(\n typeof DragEvent !== 'undefined' && evt instanceof DragEvent\n ? IncrementalSource.Drag\n : evt instanceof MouseEvent\n ? IncrementalSource.MouseMove\n : IncrementalSource.TouchMove,\n );\n },\n threshold,\n {\n trailing: false,\n },\n );\n const handlers = [\n on('mousemove', updatePosition, doc),\n on('touchmove', updatePosition, doc),\n on('drag', updatePosition, doc),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initMouseInteractionObserver({\n mouseInteractionCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: observerParam): listenerHandler {\n if (sampling.mouseInteraction === false) {\n return () => {};\n }\n const disableMap: Record =\n sampling.mouseInteraction === true ||\n sampling.mouseInteraction === undefined\n ? {}\n : sampling.mouseInteraction;\n\n const handlers: listenerHandler[] = [];\n const getHandler = (eventKey: keyof typeof MouseInteractions) => {\n return (event: MouseEvent | TouchEvent) => {\n const target = getEventTarget(event) as Node;\n if (isBlocked(target as Node, blockClass)) {\n return;\n }\n const e = isTouchEvent(event) ? event.changedTouches[0] : event;\n if (!e) {\n return;\n }\n const id = mirror.getId(target as INode);\n const { clientX, clientY } = e;\n mouseInteractionCb({\n type: MouseInteractions[eventKey],\n id,\n x: clientX,\n y: clientY,\n });\n };\n };\n Object.keys(MouseInteractions)\n .filter(\n (key) =>\n Number.isNaN(Number(key)) &&\n !key.endsWith('_Departed') &&\n disableMap[key] !== false,\n )\n .forEach((eventKey: keyof typeof MouseInteractions) => {\n const eventName = eventKey.toLowerCase();\n const handler = getHandler(eventKey);\n handlers.push(on(eventName, handler, doc));\n });\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nexport function initScrollObserver({\n scrollCb,\n doc,\n mirror,\n blockClass,\n sampling,\n}: Pick<\n observerParam,\n 'scrollCb' | 'doc' | 'mirror' | 'blockClass' | 'sampling'\n>): listenerHandler {\n const updatePosition = throttle((evt) => {\n const target = getEventTarget(evt);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const id = mirror.getId(target as INode);\n if (target === doc) {\n const scrollEl = (doc.scrollingElement || doc.documentElement)!;\n scrollCb({\n id,\n x: scrollEl.scrollLeft,\n y: scrollEl.scrollTop,\n });\n } else {\n scrollCb({\n id,\n x: (target as HTMLElement).scrollLeft,\n y: (target as HTMLElement).scrollTop,\n });\n }\n }, sampling.scroll || 100);\n return on('scroll', updatePosition, doc);\n}\n\nfunction initViewportResizeObserver({\n viewportResizeCb,\n}: observerParam): listenerHandler {\n let lastH = -1;\n let lastW = -1;\n const updateDimension = throttle(() => {\n const height = getWindowHeight();\n const width = getWindowWidth();\n if (lastH !== height || lastW !== width) {\n viewportResizeCb({\n width: Number(width),\n height: Number(height),\n });\n lastH = height;\n lastW = width;\n }\n }, 200);\n return on('resize', updateDimension, window);\n}\n\nfunction wrapEventWithUserTriggeredFlag(\n v: inputValue,\n enable: boolean,\n): inputValue {\n const value = { ...v };\n if (!enable) delete value.userTriggered;\n return value;\n}\n\nexport const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];\nconst lastInputValueMap: WeakMap = new WeakMap();\nfunction initInputObserver({\n inputCb,\n doc,\n mirror,\n blockClass,\n ignoreClass,\n ignoreSelector,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskInputFn,\n sampling,\n userTriggeredOnInput,\n}: observerParam): listenerHandler {\n function eventHandler(event: Event) {\n let target = getEventTarget(event);\n const userTriggered = event.isTrusted;\n /**\n * If a site changes the value 'selected' of an option element, the value of its parent element, usually a select element, will be changed as well.\n * We can treat this change as a value change of the select element the current target belongs to.\n */\n if (target && (target as Element).tagName === 'OPTION')\n target = (target as Element).parentElement;\n if (\n !target ||\n !(target as Element).tagName ||\n INPUT_TAGS.indexOf((target as Element).tagName) < 0 ||\n isBlocked(target as Node, blockClass)\n ) {\n return;\n }\n const type: string | undefined = (target as HTMLInputElement).type;\n if ((target as HTMLElement).classList.contains(ignoreClass) || (ignoreSelector && (target as HTMLElement).matches(ignoreSelector))) {\n return;\n }\n let text = (target as HTMLInputElement).value;\n let isChecked = false;\n if (type === 'radio' || type === 'checkbox') {\n isChecked = (target as HTMLInputElement).checked;\n } else if (\n maskInputOptions[\n (target as Element).tagName.toLowerCase() as keyof MaskInputOptions\n ] ||\n maskInputOptions[type as keyof MaskInputOptions]\n ) {\n text = maskInputValue({\n input: (target as HTMLElement),\n maskInputOptions,\n maskInputSelector,\n unmaskInputSelector,\n tagName: (target as HTMLElement).tagName,\n type,\n value: text,\n maskInputFn,\n });\n }\n cbWithDedup(\n target,\n wrapEventWithUserTriggeredFlag(\n { text, isChecked, userTriggered },\n userTriggeredOnInput,\n ),\n );\n // if a radio was checked\n // the other radios with the same name attribute will be unchecked.\n const name: string | undefined = (target as HTMLInputElement).name;\n if (type === 'radio' && name && isChecked) {\n doc\n .querySelectorAll(`input[type=\"radio\"][name=\"${name}\"]`)\n .forEach((el) => {\n if (el !== target) {\n cbWithDedup(\n el,\n wrapEventWithUserTriggeredFlag(\n {\n text: (el as HTMLInputElement).value,\n isChecked: !isChecked,\n userTriggered: false,\n },\n userTriggeredOnInput,\n ),\n );\n }\n });\n }\n }\n function cbWithDedup(target: EventTarget, v: inputValue) {\n const lastInputValue = lastInputValueMap.get(target);\n if (\n !lastInputValue ||\n lastInputValue.text !== v.text ||\n lastInputValue.isChecked !== v.isChecked\n ) {\n lastInputValueMap.set(target, v);\n const id = mirror.getId(target as INode);\n inputCb({\n ...v,\n id,\n });\n }\n }\n const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];\n const handlers: Array<\n listenerHandler | hookResetter\n > = events.map((eventName) => on(eventName, eventHandler, doc));\n const propertyDescriptor = Object.getOwnPropertyDescriptor(\n HTMLInputElement.prototype,\n 'value',\n );\n const hookProperties: Array<[HTMLElement, string]> = [\n [HTMLInputElement.prototype, 'value'],\n [HTMLInputElement.prototype, 'checked'],\n [HTMLSelectElement.prototype, 'value'],\n [HTMLTextAreaElement.prototype, 'value'],\n // Some UI library use selectedIndex to set select value\n [HTMLSelectElement.prototype, 'selectedIndex'],\n [HTMLOptionElement.prototype, 'selected'],\n ];\n if (propertyDescriptor && propertyDescriptor.set) {\n handlers.push(\n ...hookProperties.map((p) =>\n hookSetter(p[0], p[1], {\n set() {\n // mock to a normal event\n eventHandler({ target: this } as Event);\n },\n }),\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\ntype GroupingCSSRule =\n | CSSGroupingRule\n | CSSMediaRule\n | CSSSupportsRule\n | CSSConditionRule;\ntype GroupingCSSRuleTypes =\n | typeof CSSGroupingRule\n | typeof CSSMediaRule\n | typeof CSSSupportsRule\n | typeof CSSConditionRule;\n\nfunction getNestedCSSRulePositions(rule: CSSRule): number[] {\n const positions: number[] = [];\n function recurse(childRule: CSSRule, pos: number[]) {\n if (\n (isCSSGroupingRuleSupported &&\n childRule.parentRule instanceof CSSGroupingRule) ||\n (isCSSMediaRuleSupported &&\n childRule.parentRule instanceof CSSMediaRule) ||\n (isCSSSupportsRuleSupported &&\n childRule.parentRule instanceof CSSSupportsRule) ||\n (isCSSConditionRuleSupported &&\n childRule.parentRule instanceof CSSConditionRule)\n ) {\n const rules = Array.from(\n (childRule.parentRule as GroupingCSSRule).cssRules,\n );\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n } else {\n const rules = Array.from(childRule.parentStyleSheet!.cssRules);\n const index = rules.indexOf(childRule);\n pos.unshift(index);\n }\n return pos;\n }\n return recurse(rule, positions);\n}\n\nfunction initStyleSheetObserver(\n { styleSheetRuleCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {\n // If, for whatever reason, CSSStyleSheet is not available, we skip the observation of stylesheets.\n return () => {};\n }\n\n const insertRule = win.CSSStyleSheet.prototype.insertRule;\n win.CSSStyleSheet.prototype.insertRule = function (\n rule: string,\n index?: number,\n ) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [{ rule, index }],\n });\n }\n return insertRule.apply(this, arguments);\n };\n\n const deleteRule = win.CSSStyleSheet.prototype.deleteRule;\n win.CSSStyleSheet.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index }],\n });\n }\n return deleteRule.apply(this, arguments);\n };\n\n const supportedNestedCSSRuleTypes: {\n [key: string]: GroupingCSSRuleTypes;\n } = {};\n if (isCSSGroupingRuleSupported) {\n supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;\n } else {\n // Some browsers (Safari) don't support CSSGroupingRule\n // https://caniuse.com/?search=cssgroupingrule\n // fall back to monkey patching classes that would have inherited from CSSGroupingRule\n\n if (isCSSMediaRuleSupported) {\n supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;\n }\n if (isCSSConditionRuleSupported) {\n supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;\n }\n if (isCSSSupportsRuleSupported) {\n supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;\n }\n }\n\n const unmodifiedFunctions: {\n [key: string]: {\n insertRule: (rule: string, index?: number) => number;\n deleteRule: (index: number) => void;\n };\n } = {};\n\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n unmodifiedFunctions[typeKey] = {\n insertRule: (type as GroupingCSSRuleTypes).prototype.insertRule,\n deleteRule: (type as GroupingCSSRuleTypes).prototype.deleteRule,\n };\n\n type.prototype.insertRule = function (rule: string, index?: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n adds: [\n {\n rule,\n index: [\n ...getNestedCSSRulePositions(this),\n index || 0, // defaults to 0\n ],\n },\n ],\n });\n }\n return unmodifiedFunctions[typeKey].insertRule.apply(this, arguments);\n };\n\n type.prototype.deleteRule = function (index: number) {\n const id = mirror.getId(this.parentStyleSheet.ownerNode as INode);\n if (id !== -1) {\n styleSheetRuleCb({\n id,\n removes: [{ index: [...getNestedCSSRulePositions(this), index] }],\n });\n }\n return unmodifiedFunctions[typeKey].deleteRule.apply(this, arguments);\n };\n });\n\n return () => {\n win.CSSStyleSheet.prototype.insertRule = insertRule;\n win.CSSStyleSheet.prototype.deleteRule = deleteRule;\n Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;\n type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;\n });\n };\n}\n\nfunction initStyleDeclarationObserver(\n { styleDeclarationCb, mirror }: observerParam,\n { win }: { win: IWindow },\n): listenerHandler {\n const setProperty = win.CSSStyleDeclaration.prototype.setProperty;\n win.CSSStyleDeclaration.prototype.setProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n value: string,\n priority: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n set: {\n property,\n value,\n priority,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return setProperty.apply(this, arguments);\n };\n\n const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = function (\n this: CSSStyleDeclaration,\n property: string,\n ) {\n const id = mirror.getId(\n (this.parentRule?.parentStyleSheet?.ownerNode as unknown) as INode,\n );\n if (id !== -1) {\n styleDeclarationCb({\n id,\n remove: {\n property,\n },\n index: getNestedCSSRulePositions(this.parentRule!),\n });\n }\n return removeProperty.apply(this, arguments);\n };\n\n return () => {\n win.CSSStyleDeclaration.prototype.setProperty = setProperty;\n win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;\n };\n}\n\nfunction initMediaInteractionObserver({\n mediaInteractionCb,\n blockClass,\n mirror,\n sampling,\n}: observerParam): listenerHandler {\n const handler = (type: MediaInteractions) =>\n throttle((event: Event) => {\n const target = getEventTarget(event);\n if (!target || isBlocked(target as Node, blockClass)) {\n return;\n }\n const { currentTime, volume, muted } = target as HTMLMediaElement;\n mediaInteractionCb({\n type,\n id: mirror.getId(target as INode),\n currentTime,\n volume,\n muted,\n });\n }, sampling.media || 500);\n const handlers = [\n on('play', handler(MediaInteractions.Play)),\n on('pause', handler(MediaInteractions.Pause)),\n on('seeked', handler(MediaInteractions.Seeked)),\n on('volumechange', handler(MediaInteractions.VolumeChange)),\n ];\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction initFontObserver({ fontCb, doc }: observerParam): listenerHandler {\n const win = doc.defaultView as IWindow;\n if (!win) {\n return () => {};\n }\n\n const handlers: listenerHandler[] = [];\n\n const fontMap = new WeakMap();\n\n const originalFontFace = win.FontFace;\n win.FontFace = (function FontFace(\n family: string,\n source: string | ArrayBufferView,\n descriptors?: FontFaceDescriptors,\n ) {\n const fontFace = new originalFontFace(family, source, descriptors);\n fontMap.set(fontFace, {\n family,\n buffer: typeof source !== 'string',\n descriptors,\n fontSource:\n typeof source === 'string'\n ? source\n : // tslint:disable-next-line: no-any\n JSON.stringify(Array.from(new Uint8Array(source as any))),\n });\n return fontFace;\n } as unknown) as typeof FontFace;\n\n const restoreHandler = patch(doc.fonts, 'add', function (original) {\n return function (this: FontFaceSet, fontFace: FontFace) {\n setTimeout(() => {\n const p = fontMap.get(fontFace);\n if (p) {\n fontCb(p);\n fontMap.delete(fontFace);\n }\n }, 0);\n return original.apply(this, [fontFace]);\n };\n });\n\n handlers.push(() => {\n win.FontFace = originalFontFace;\n });\n handlers.push(restoreHandler);\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n\nfunction mergeHooks(o: observerParam, hooks: hooksParam) {\n const {\n mutationCb,\n mousemoveCb,\n mouseInteractionCb,\n scrollCb,\n viewportResizeCb,\n inputCb,\n mediaInteractionCb,\n styleSheetRuleCb,\n styleDeclarationCb,\n canvasMutationCb,\n fontCb,\n } = o;\n o.mutationCb = (...p: Arguments) => {\n if (hooks.mutation) {\n hooks.mutation(...p);\n }\n mutationCb(...p);\n };\n o.mousemoveCb = (...p: Arguments) => {\n if (hooks.mousemove) {\n hooks.mousemove(...p);\n }\n mousemoveCb(...p);\n };\n o.mouseInteractionCb = (...p: Arguments) => {\n if (hooks.mouseInteraction) {\n hooks.mouseInteraction(...p);\n }\n mouseInteractionCb(...p);\n };\n o.scrollCb = (...p: Arguments) => {\n if (hooks.scroll) {\n hooks.scroll(...p);\n }\n scrollCb(...p);\n };\n o.viewportResizeCb = (...p: Arguments) => {\n if (hooks.viewportResize) {\n hooks.viewportResize(...p);\n }\n viewportResizeCb(...p);\n };\n o.inputCb = (...p: Arguments) => {\n if (hooks.input) {\n hooks.input(...p);\n }\n inputCb(...p);\n };\n o.mediaInteractionCb = (...p: Arguments) => {\n if (hooks.mediaInteaction) {\n hooks.mediaInteaction(...p);\n }\n mediaInteractionCb(...p);\n };\n o.styleSheetRuleCb = (...p: Arguments) => {\n if (hooks.styleSheetRule) {\n hooks.styleSheetRule(...p);\n }\n styleSheetRuleCb(...p);\n };\n o.styleDeclarationCb = (...p: Arguments) => {\n if (hooks.styleDeclaration) {\n hooks.styleDeclaration(...p);\n }\n styleDeclarationCb(...p);\n };\n o.canvasMutationCb = (...p: Arguments) => {\n if (hooks.canvasMutation) {\n hooks.canvasMutation(...p);\n }\n canvasMutationCb(...p);\n };\n o.fontCb = (...p: Arguments) => {\n if (hooks.font) {\n hooks.font(...p);\n }\n fontCb(...p);\n };\n}\n\nexport function initObservers(\n o: observerParam,\n hooks: hooksParam = {},\n): listenerHandler {\n const currentWindow = o.doc.defaultView; // basically document.window\n if (!currentWindow) {\n return () => {};\n }\n\n mergeHooks(o, hooks);\n const mutationObserver = initMutationObserver(o, o.doc);\n const mousemoveHandler = initMoveObserver(o);\n const mouseInteractionHandler = initMouseInteractionObserver(o);\n const scrollHandler = initScrollObserver(o);\n const viewportResizeHandler = initViewportResizeObserver(o);\n const inputHandler = initInputObserver(o);\n const mediaInteractionHandler = initMediaInteractionObserver(o);\n\n const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });\n const styleDeclarationObserver = initStyleDeclarationObserver(o, {\n win: currentWindow,\n });\n const fontObserver = o.collectFonts ? initFontObserver(o) : () => {};\n // plugins\n const pluginHandlers: listenerHandler[] = [];\n for (const plugin of o.plugins) {\n pluginHandlers.push(\n plugin.observer(plugin.callback, currentWindow, plugin.options),\n );\n }\n\n return () => {\n mutationBuffers.forEach((b) => b.reset());\n mutationObserver.disconnect();\n mousemoveHandler();\n mouseInteractionHandler();\n scrollHandler();\n viewportResizeHandler();\n inputHandler();\n mediaInteractionHandler();\n styleSheetObserver();\n styleDeclarationObserver();\n fontObserver();\n pluginHandlers.forEach((h) => h());\n };\n}\n","import { serializedNodeWithId, INode } from 'rrweb-snapshot';\nimport { mutationCallBack } from '../types';\n\nexport class IframeManager {\n private iframes: WeakMap = new WeakMap();\n private mutationCb: mutationCallBack;\n private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;\n\n constructor(options: { mutationCb: mutationCallBack }) {\n this.mutationCb = options.mutationCb;\n }\n\n public addIframe(iframeEl: HTMLIFrameElement) {\n this.iframes.set(iframeEl, true);\n }\n\n public addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown) {\n this.loadListener = cb;\n }\n\n public attachIframe(iframeEl: INode, childSn: serializedNodeWithId) {\n this.mutationCb({\n adds: [\n {\n parentId: iframeEl.__sn.id,\n nextId: null,\n node: childSn,\n },\n ],\n removes: [],\n texts: [],\n attributes: [],\n isAttachIframe: true,\n });\n this.loadListener?.((iframeEl as unknown) as HTMLIFrameElement);\n }\n}\n","import {\n mutationCallBack,\n Mirror,\n scrollCallback,\n MutationBufferParam,\n SamplingStrategy,\n} from '../types';\nimport { initMutationObserver, initScrollObserver } from './observer';\nimport { patch } from '../utils';\n\ntype BypassOptions = Omit<\n MutationBufferParam,\n 'doc' | 'mutationCb' | 'mirror' | 'shadowDomManager'\n> & {\n sampling: SamplingStrategy;\n};\n\nexport class ShadowDomManager {\n private mutationCb: mutationCallBack;\n private scrollCb: scrollCallback;\n private bypassOptions: BypassOptions;\n private mirror: Mirror;\n private restorePatches: (() => void)[] = [];\n\n constructor(options: {\n mutationCb: mutationCallBack;\n scrollCb: scrollCallback;\n bypassOptions: BypassOptions;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.scrollCb = options.scrollCb;\n this.bypassOptions = options.bypassOptions;\n this.mirror = options.mirror;\n\n // Patch 'attachShadow' to observe newly added shadow doms.\n const manager = this;\n this.restorePatches.push(\n patch(HTMLElement.prototype, 'attachShadow', function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(this.shadowRoot, this.ownerDocument);\n return shadowRoot;\n };\n }),\n );\n }\n\n public addShadowRoot(shadowRoot: ShadowRoot, doc: Document) {\n initMutationObserver(\n {\n ...this.bypassOptions,\n doc,\n mutationCb: this.mutationCb,\n mirror: this.mirror,\n shadowDomManager: this,\n },\n shadowRoot,\n );\n initScrollObserver({\n ...this.bypassOptions,\n scrollCb: this.scrollCb,\n // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813\n // scroll is not allowed to pass the boundary, so we need to listen the shadow document\n doc: (shadowRoot as unknown) as Document,\n mirror: this.mirror,\n });\n }\n\n /**\n * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.\n */\n public observeAttachShadow(iframeElement: HTMLIFrameElement) {\n if (iframeElement.contentWindow) {\n const manager = this;\n this.restorePatches.push(\n patch(\n (iframeElement.contentWindow as Window & {\n HTMLElement: { prototype: HTMLElement };\n }).HTMLElement.prototype,\n 'attachShadow',\n function (original) {\n return function () {\n const shadowRoot = original.apply(this, arguments);\n if (this.shadowRoot)\n manager.addShadowRoot(\n this.shadowRoot,\n iframeElement.contentDocument as Document,\n );\n return shadowRoot;\n };\n },\n ),\n );\n }\n }\n\n public reset() {\n this.restorePatches.forEach((restorePatch) => restorePatch());\n }\n}\n","/*\n * base64-arraybuffer 1.0.1 \n * Copyright (c) 2021 Niklas von Hertzen \n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { encode } from 'base64-arraybuffer';\nimport { IWindow, SerializedWebGlArg } from '../../../types';\n\n// TODO: unify with `replay/webgl.ts`\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nexport const saveWebGLVar = (\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): number | void => {\n if (\n !value ||\n !(isInstanceOfWebGLObject(value, win) || typeof value === 'object')\n )\n return;\n\n const name = value.constructor.name;\n const list = variableListFor(ctx, name);\n let index = list.indexOf(value);\n\n if (index === -1) {\n index = list.length;\n list.push(value);\n }\n return index;\n};\n\n// from webgl-recorder: https://github.com/evanw/webgl-recorder/blob/bef0e65596e981ee382126587e2dcbe0fc7748e2/webgl-recorder.js#L50-L77\nexport function serializeArg(\n value: any,\n win: IWindow,\n ctx: WebGL2RenderingContext | WebGLRenderingContext,\n): SerializedWebGlArg {\n if (value instanceof Array) {\n return value.map((arg) => serializeArg(arg, win, ctx));\n } else if (value === null) {\n return value;\n } else if (\n value instanceof Float32Array ||\n value instanceof Float64Array ||\n value instanceof Int32Array ||\n value instanceof Uint32Array ||\n value instanceof Uint8Array ||\n value instanceof Uint16Array ||\n value instanceof Int16Array ||\n value instanceof Int8Array ||\n value instanceof Uint8ClampedArray\n ) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [Object.values(value)],\n };\n } else if (\n // SharedArrayBuffer disabled on most browsers due to spectre.\n // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer\n // value instanceof SharedArrayBuffer ||\n value instanceof ArrayBuffer\n ) {\n const name = value.constructor.name as 'ArrayBuffer';\n const base64 = encode(value);\n\n return {\n rr_type: name,\n base64,\n };\n } else if (value instanceof DataView) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [\n serializeArg(value.buffer, win, ctx),\n value.byteOffset,\n value.byteLength,\n ],\n };\n } else if (value instanceof HTMLImageElement) {\n const name = value.constructor.name;\n const { src } = value;\n return {\n rr_type: name,\n src,\n };\n } else if (value instanceof ImageData) {\n const name = value.constructor.name;\n return {\n rr_type: name,\n args: [serializeArg(value.data, win, ctx), value.width, value.height],\n };\n } else if (isInstanceOfWebGLObject(value, win) || typeof value === 'object') {\n const name = value.constructor.name;\n const index = saveWebGLVar(value, win, ctx) as number;\n\n return {\n rr_type: name,\n index: index,\n };\n }\n\n return value;\n}\n\nexport const serializeArgs = (\n args: Array,\n win: IWindow,\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n) => {\n return [...args].map((arg) => serializeArg(arg, win, ctx));\n};\n\nexport const isInstanceOfWebGLObject = (\n value: any,\n win: IWindow,\n): value is\n | WebGLActiveInfo\n | WebGLBuffer\n | WebGLFramebuffer\n | WebGLProgram\n | WebGLRenderbuffer\n | WebGLShader\n | WebGLShaderPrecisionFormat\n | WebGLTexture\n | WebGLUniformLocation\n | WebGLVertexArrayObject => {\n const webGLConstructorNames: string[] = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.\n 'WebGLVertexArrayObjectOES',\n ];\n const supportedWebGLConstructorNames = webGLConstructorNames.filter(\n (name: string) => typeof win[name as keyof Window] === 'function',\n );\n return Boolean(\n supportedWebGLConstructorNames.find(\n (name: string) => value instanceof win[name as keyof Window],\n ),\n );\n};\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\nimport { saveWebGLVar, serializeArgs } from './serialize-args';\n\nfunction patchGLPrototype(\n prototype: WebGLRenderingContext | WebGL2RenderingContext,\n type: CanvasContext,\n cb: canvasManagerMutationCallback,\n blockClass: blockClass,\n mirror: Mirror,\n win: IWindow,\n): listenerHandler[] {\n const handlers: listenerHandler[] = [];\n\n const props = Object.getOwnPropertyNames(prototype);\n\n for (const prop of props) {\n try {\n if (typeof prototype[prop as keyof typeof prototype] !== 'function') {\n continue;\n }\n const restoreHandler = patch(prototype, prop, function (original) {\n return function (this: typeof prototype, ...args: Array) {\n const result = original.apply(this, args);\n saveWebGLVar(result, win, prototype);\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n const id = mirror.getId((this.canvas as unknown) as INode);\n\n const recordArgs = serializeArgs([...args], win, prototype);\n const mutation: canvasMutationWithType = {\n type,\n property: prop,\n args: recordArgs,\n };\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, mutation);\n }\n\n return result;\n };\n });\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(prototype, prop, {\n set(v) {\n // TODO: this could potentially also be an OffscreenCanvas as well as HTMLCanvasElement\n cb(this.canvas as HTMLCanvasElement, {\n type,\n property: prop,\n args: [v],\n setter: true,\n });\n },\n });\n handlers.push(hookHandler);\n }\n }\n\n return handlers;\n}\n\nexport default function initCanvasWebGLMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n\n handlers.push(\n ...patchGLPrototype(\n win.WebGLRenderingContext.prototype,\n CanvasContext.WebGL,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n\n if (typeof win.WebGL2RenderingContext !== 'undefined') {\n handlers.push(\n ...patchGLPrototype(\n win.WebGL2RenderingContext.prototype,\n CanvasContext.WebGL2,\n cb,\n blockClass,\n mirror,\n win,\n ),\n );\n }\n\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n canvasManagerMutationCallback,\n canvasMutationCallback,\n canvasMutationCommand,\n canvasMutationWithType,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport initCanvas2DMutationObserver from './2d';\nimport initCanvasContextObserver from './canvas';\nimport initCanvasWebGLMutationObserver from './webgl';\n\nexport type RafStamps = { latestId: number; invokeId: number | null };\n\ntype pendingCanvasMutationsMap = Map<\n HTMLCanvasElement,\n canvasMutationWithType[]\n>;\n\nexport class CanvasManager {\n private pendingCanvasMutations: pendingCanvasMutationsMap = new Map();\n private rafStamps: RafStamps = { latestId: 0, invokeId: null };\n private mirror: Mirror;\n\n private mutationCb: canvasMutationCallback;\n private resetObservers?: listenerHandler;\n private frozen: boolean = false;\n private locked: boolean = false;\n\n public reset() {\n this.pendingCanvasMutations.clear();\n this.resetObservers && this.resetObservers();\n }\n\n public freeze() {\n this.frozen = true;\n }\n\n public unfreeze() {\n this.frozen = false;\n }\n\n public lock() {\n this.locked = true;\n }\n\n public unlock() {\n this.locked = false;\n }\n\n constructor(options: {\n recordCanvas: boolean | number;\n mutationCb: canvasMutationCallback;\n win: IWindow;\n blockClass: blockClass;\n mirror: Mirror;\n }) {\n this.mutationCb = options.mutationCb;\n this.mirror = options.mirror;\n\n if (options.recordCanvas === true)\n this.initCanvasMutationObserver(options.win, options.blockClass);\n }\n\n private processMutation: canvasManagerMutationCallback = function (\n target,\n mutation,\n ) {\n const newFrame =\n this.rafStamps.invokeId &&\n this.rafStamps.latestId !== this.rafStamps.invokeId;\n if (newFrame || !this.rafStamps.invokeId)\n this.rafStamps.invokeId = this.rafStamps.latestId;\n\n if (!this.pendingCanvasMutations.has(target)) {\n this.pendingCanvasMutations.set(target, []);\n }\n\n this.pendingCanvasMutations.get(target)!.push(mutation);\n };\n\n private initCanvasMutationObserver(\n win: IWindow,\n blockClass: blockClass,\n ): void {\n this.startRAFTimestamping();\n this.startPendingCanvasMutationFlusher();\n\n const canvasContextReset = initCanvasContextObserver(win, blockClass);\n const canvas2DReset = initCanvas2DMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(\n this.processMutation.bind(this),\n win,\n blockClass,\n this.mirror,\n );\n\n this.resetObservers = () => {\n canvasContextReset();\n canvas2DReset();\n canvasWebGL1and2Reset();\n };\n }\n\n private startPendingCanvasMutationFlusher() {\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n private startRAFTimestamping() {\n const setLatestRAFTimestamp = (timestamp: DOMHighResTimeStamp) => {\n this.rafStamps.latestId = timestamp;\n requestAnimationFrame(setLatestRAFTimestamp);\n };\n requestAnimationFrame(setLatestRAFTimestamp);\n }\n\n flushPendingCanvasMutations() {\n this.pendingCanvasMutations.forEach(\n (values: canvasMutationCommand[], canvas: HTMLCanvasElement) => {\n const id = this.mirror.getId((canvas as unknown) as INode);\n this.flushPendingCanvasMutationFor(canvas, id);\n },\n );\n requestAnimationFrame(() => this.flushPendingCanvasMutations());\n }\n\n flushPendingCanvasMutationFor(canvas: HTMLCanvasElement, id: number) {\n if (this.frozen || this.locked) {\n return;\n }\n\n const valuesWithType = this.pendingCanvasMutations.get(canvas);\n if (!valuesWithType || id === -1) return;\n\n const values = valuesWithType.map((value) => {\n const { type, ...rest } = value;\n return rest;\n });\n const { type } = valuesWithType[0];\n\n this.mutationCb({ id, type, commands: values });\n\n this.pendingCanvasMutations.delete(canvas);\n }\n}\n","import { snapshot, MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';\nimport { initObservers, mutationBuffers } from './observer';\nimport {\n on,\n getWindowWidth,\n getWindowHeight,\n polyfill,\n isIframeINode,\n hasShadowRoot,\n createMirror,\n} from '../utils';\nimport {\n EventType,\n event,\n eventWithTime,\n recordOptions,\n IncrementalSource,\n listenerHandler,\n mutationCallbackParam,\n scrollCallback,\n canvasMutationParam,\n} from '../types';\nimport { IframeManager } from './iframe-manager';\nimport { ShadowDomManager } from './shadow-dom-manager';\nimport { CanvasManager } from './observers/canvas/canvas-manager';\n\nfunction wrapEvent(e: event): eventWithTime {\n return {\n ...e,\n timestamp: Date.now(),\n };\n}\n\nlet wrappedEmit!: (e: eventWithTime, isCheckout?: boolean) => void;\n\nlet takeFullSnapshot!: (isCheckout?: boolean) => void;\n\nconst mirror = createMirror();\nfunction record(\n options: recordOptions = {},\n): listenerHandler | undefined {\n const {\n emit,\n checkoutEveryNms,\n checkoutEveryNth,\n blockClass = 'rr-block',\n blockSelector = null,\n unblockSelector = null,\n ignoreClass = 'rr-ignore',\n ignoreSelector =null,\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n maskInputSelector = null,\n unmaskTextSelector = null,\n unmaskInputSelector = null,\n inlineStylesheet = true,\n maskAllInputs,\n maskInputOptions: _maskInputOptions,\n slimDOMOptions: _slimDOMOptions,\n maskInputFn,\n maskTextFn,\n hooks,\n packFn,\n sampling = {},\n mousemoveWait,\n recordCanvas = false,\n userTriggeredOnInput = false,\n collectFonts = false,\n inlineImages = false,\n plugins,\n keepIframeSrcFn = () => false,\n } = options;\n // runtime checks for user options\n if (!emit) {\n throw new Error('emit function is required');\n }\n // move departed options to new options\n if (mousemoveWait !== undefined && sampling.mousemove === undefined) {\n sampling.mousemove = mousemoveWait;\n }\n\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : _maskInputOptions !== undefined\n ? _maskInputOptions\n : { password: true };\n\n const slimDOMOptions: SlimDOMOptions =\n _slimDOMOptions === true || _slimDOMOptions === 'all'\n ? {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaVerification: true,\n // the following are off for slimDOMOptions === true,\n // as they destroy some (hidden) info:\n headMetaAuthorship: _slimDOMOptions === 'all',\n headMetaDescKeywords: _slimDOMOptions === 'all',\n }\n : _slimDOMOptions\n ? _slimDOMOptions\n : {};\n\n polyfill();\n\n let lastFullSnapshotEvent: eventWithTime;\n let incrementalSnapshotCount = 0;\n const eventProcessor = (e: eventWithTime): T => {\n for (const plugin of plugins || []) {\n if (plugin.eventProcessor) {\n e = plugin.eventProcessor(e);\n }\n }\n if (packFn) {\n e = (packFn(e) as unknown) as eventWithTime;\n }\n return (e as unknown) as T;\n };\n wrappedEmit = (e: eventWithTime, isCheckout?: boolean) => {\n if (\n mutationBuffers[0]?.isFrozen() &&\n e.type !== EventType.FullSnapshot &&\n !(\n e.type === EventType.IncrementalSnapshot &&\n e.data.source === IncrementalSource.Mutation\n )\n ) {\n // we've got a user initiated event so first we need to apply\n // all DOM changes that have been buffering during paused state\n mutationBuffers.forEach((buf) => buf.unfreeze());\n }\n\n emit(eventProcessor(e), isCheckout);\n if (e.type === EventType.FullSnapshot) {\n lastFullSnapshotEvent = e;\n incrementalSnapshotCount = 0;\n } else if (e.type === EventType.IncrementalSnapshot) {\n // attach iframe should be considered as full snapshot\n if (\n e.data.source === IncrementalSource.Mutation &&\n e.data.isAttachIframe\n ) {\n return;\n }\n\n incrementalSnapshotCount++;\n const exceedCount =\n checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;\n const exceedTime =\n checkoutEveryNms &&\n e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;\n if (exceedCount || exceedTime) {\n takeFullSnapshot(true);\n }\n }\n };\n\n const wrappedMutationEmit = (m: mutationCallbackParam) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Mutation,\n ...m,\n },\n }),\n );\n };\n const wrappedScrollEmit: scrollCallback = (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Scroll,\n ...p,\n },\n }),\n );\n const wrappedCanvasMutationEmit = (p: canvasMutationParam) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.CanvasMutation,\n ...p,\n },\n }),\n );\n\n const iframeManager = new IframeManager({\n mutationCb: wrappedMutationEmit,\n });\n\n const canvasManager = new CanvasManager({\n recordCanvas,\n mutationCb: wrappedCanvasMutationEmit,\n win: window,\n blockClass,\n mirror,\n });\n\n const shadowDomManager = new ShadowDomManager({\n mutationCb: wrappedMutationEmit,\n scrollCb: wrappedScrollEmit,\n bypassOptions: {\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n maskInputSelector,\n unmaskInputSelector,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n recordCanvas,\n inlineImages,\n sampling,\n slimDOMOptions,\n iframeManager,\n canvasManager,\n },\n mirror,\n });\n\n takeFullSnapshot = (isCheckout = false) => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Meta,\n data: {\n href: window.location.href,\n width: getWindowWidth(),\n height: getWindowHeight(),\n },\n }),\n isCheckout,\n );\n\n mutationBuffers.forEach((buf) => buf.lock()); // don't allow any mirror modifications during snapshotting\n const [node, idNodeMap] = snapshot(document, {\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n maskInputSelector,\n unmaskInputSelector,\n inlineStylesheet,\n maskAllInputs: maskInputOptions,\n maskTextFn,\n slimDOM: slimDOMOptions,\n recordCanvas,\n inlineImages,\n onSerialize: (n) => {\n if (isIframeINode(n)) {\n iframeManager.addIframe(n);\n }\n if (hasShadowRoot(n)) {\n shadowDomManager.addShadowRoot(n.shadowRoot, document);\n }\n },\n onIframeLoad: (iframe, childSn) => {\n iframeManager.attachIframe(iframe, childSn);\n shadowDomManager.observeAttachShadow(\n (iframe as Node) as HTMLIFrameElement,\n );\n },\n keepIframeSrcFn,\n });\n\n if (!node) {\n return console.warn('Failed to snapshot the document');\n }\n\n mirror.map = idNodeMap;\n wrappedEmit(\n wrapEvent({\n type: EventType.FullSnapshot,\n data: {\n node,\n initialOffset: {\n left:\n window.pageXOffset !== undefined\n ? window.pageXOffset\n : document?.documentElement.scrollLeft ||\n document?.body?.parentElement?.scrollLeft ||\n document?.body.scrollLeft ||\n 0,\n top:\n window.pageYOffset !== undefined\n ? window.pageYOffset\n : document?.documentElement.scrollTop ||\n document?.body?.parentElement?.scrollTop ||\n document?.body.scrollTop ||\n 0,\n },\n },\n }),\n );\n mutationBuffers.forEach((buf) => buf.unlock()); // generate & emit any mutations that happened during snapshotting, as can now apply against the newly built mirror\n };\n\n try {\n const handlers: listenerHandler[] = [];\n handlers.push(\n on('DOMContentLoaded', () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.DomContentLoaded,\n data: {},\n }),\n );\n }),\n );\n\n const observe = (doc: Document) => {\n return initObservers(\n {\n mutationCb: wrappedMutationEmit,\n mousemoveCb: (positions, source) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source,\n positions,\n },\n }),\n ),\n mouseInteractionCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MouseInteraction,\n ...d,\n },\n }),\n ),\n scrollCb: wrappedScrollEmit,\n viewportResizeCb: (d) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.ViewportResize,\n ...d,\n },\n }),\n ),\n inputCb: (v) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Input,\n ...v,\n },\n }),\n ),\n mediaInteractionCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.MediaInteraction,\n ...p,\n },\n }),\n ),\n styleSheetRuleCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleSheetRule,\n ...r,\n },\n }),\n ),\n styleDeclarationCb: (r) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.StyleDeclaration,\n ...r,\n },\n }),\n ),\n canvasMutationCb: wrappedCanvasMutationEmit,\n fontCb: (p) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.IncrementalSnapshot,\n data: {\n source: IncrementalSource.Font,\n ...p,\n },\n }),\n ),\n blockClass,\n ignoreClass,\n ignoreSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n inlineStylesheet,\n sampling,\n recordCanvas,\n inlineImages,\n userTriggeredOnInput,\n collectFonts,\n doc,\n maskInputFn,\n maskTextFn,\n blockSelector,\n unblockSelector,\n slimDOMOptions,\n mirror,\n iframeManager,\n shadowDomManager,\n canvasManager,\n plugins:\n plugins\n ?.filter((p) => p.observer)\n ?.map((p) => ({\n observer: p.observer!,\n options: p.options,\n callback: (payload: object) =>\n wrappedEmit(\n wrapEvent({\n type: EventType.Plugin,\n data: {\n plugin: p.name,\n payload,\n },\n }),\n ),\n })) || [],\n },\n hooks,\n );\n };\n\n iframeManager.addLoadListener((iframeEl) => {\n try {\n handlers.push(observe(iframeEl.contentDocument!));\n } catch (error) {\n // TODO: handle internal error\n console.warn(error);\n }\n });\n\n const init = () => {\n takeFullSnapshot();\n handlers.push(observe(document));\n };\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n init();\n } else {\n handlers.push(\n on(\n 'load',\n () => {\n wrappedEmit(\n wrapEvent({\n type: EventType.Load,\n data: {},\n }),\n );\n init();\n },\n window,\n ),\n );\n }\n return () => {\n handlers.forEach((h) => h());\n };\n } catch (error) {\n // TODO: handle internal error\n console.warn(error);\n }\n}\n\nrecord.addCustomEvent = (tag: string, payload: T) => {\n if (!wrappedEmit) {\n throw new Error('please add custom event after start recording');\n }\n wrappedEmit(\n wrapEvent({\n type: EventType.Custom,\n data: {\n tag,\n payload,\n },\n }),\n );\n};\n\nrecord.freezePage = () => {\n mutationBuffers.forEach((buf) => buf.freeze());\n};\n\nrecord.takeFullSnapshot = (isCheckout?: boolean) => {\n if (!takeFullSnapshot) {\n throw new Error('please take full snapshot after start recording');\n }\n takeFullSnapshot(isCheckout);\n};\n\nrecord.mirror = mirror;\n\nexport default record;\n","import { INode, ICanvas } from 'rrweb-snapshot';\nimport { blockClass, IWindow, listenerHandler } from '../../../types';\nimport { isBlocked, patch } from '../../../utils';\n\nexport default function initCanvasContextObserver(\n win: IWindow,\n blockClass: blockClass,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n try {\n const restoreHandler = patch(\n win.HTMLCanvasElement.prototype,\n 'getContext',\n function (original) {\n return function (\n this: ICanvas,\n contextType: string,\n ...args: Array\n ) {\n if (!isBlocked((this as unknown) as INode, blockClass)) {\n if (!('__context' in this))\n (this as ICanvas).__context = contextType;\n }\n return original.apply(this, [contextType, ...args]);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n console.error('failed to patch HTMLCanvasElement.prototype.getContext');\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","import { INode } from 'rrweb-snapshot';\nimport {\n blockClass,\n CanvasContext,\n canvasManagerMutationCallback,\n IWindow,\n listenerHandler,\n Mirror,\n} from '../../../types';\nimport { hookSetter, isBlocked, patch } from '../../../utils';\n\nexport default function initCanvas2DMutationObserver(\n cb: canvasManagerMutationCallback,\n win: IWindow,\n blockClass: blockClass,\n mirror: Mirror,\n): listenerHandler {\n const handlers: listenerHandler[] = [];\n const props2D = Object.getOwnPropertyNames(\n win.CanvasRenderingContext2D.prototype,\n );\n for (const prop of props2D) {\n try {\n if (\n typeof win.CanvasRenderingContext2D.prototype[\n prop as keyof CanvasRenderingContext2D\n ] !== 'function'\n ) {\n continue;\n }\n const restoreHandler = patch(\n win.CanvasRenderingContext2D.prototype,\n prop,\n function (original) {\n return function (\n this: CanvasRenderingContext2D,\n ...args: Array\n ) {\n if (!isBlocked((this.canvas as unknown) as INode, blockClass)) {\n // Using setTimeout as getImageData + JSON.stringify can be heavy\n // and we'd rather not block the main thread\n setTimeout(() => {\n const recordArgs = [...args];\n if (prop === 'drawImage') {\n if (\n recordArgs[0] &&\n recordArgs[0] instanceof HTMLCanvasElement\n ) {\n const canvas = recordArgs[0];\n const ctx = canvas.getContext('2d');\n let imgd = ctx?.getImageData(\n 0,\n 0,\n canvas.width,\n canvas.height,\n );\n let pix = imgd?.data;\n recordArgs[0] = JSON.stringify(pix);\n }\n }\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: recordArgs,\n });\n }, 0);\n }\n return original.apply(this, args);\n };\n },\n );\n handlers.push(restoreHandler);\n } catch {\n const hookHandler = hookSetter(\n win.CanvasRenderingContext2D.prototype,\n prop,\n {\n set(v) {\n cb(this.canvas, {\n type: CanvasContext['2D'],\n property: prop,\n args: [v],\n setter: true,\n });\n },\n },\n );\n handlers.push(hookHandler);\n }\n }\n return () => {\n handlers.forEach((h) => h());\n };\n}\n","// \n// An event handler can take an optional event argument\n// and should not return a value\n \n \n\n// An array of all currently registered event handlers for a type\n \n \n// A map of event types and their corresponding event handlers.\n \n \n \n \n\n/** Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nfunction mitt(all ) {\n\tall = all || Object.create(null);\n\n\treturn {\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton: function on(type , handler ) {\n\t\t\t(all[type] || (all[type] = [])).push(handler);\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t *\n\t\t * @param {String} type\tType of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff: function off(type , handler ) {\n\t\t\tif (all[type]) {\n\t\t\t\tall[type].splice(all[type].indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * @param {String} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit: function emit(type , evt ) {\n\t\t\t(all[type] || []).slice().map(function (handler) { handler(evt); });\n\t\t\t(all['*'] || []).slice().map(function (handler) { handler(type, evt); });\n\t\t}\n\t};\n}\n\nexport default mitt;\n//# sourceMappingURL=mitt.es.js.map\n","/**\n * A fork version of https://github.com/iamdustan/smoothscroll\n * Add support of customize target window and document\n */\n\n// @ts-nocheck\n// tslint:disable\nexport function polyfill(w: Window = window, d = document) {\n // return if scroll behavior is supported and polyfill is not forced\n if (\n 'scrollBehavior' in d.documentElement.style &&\n w.__forceSmoothScrollPolyfill__ !== true\n ) {\n return;\n }\n\n // globals\n var Element = w.HTMLElement || w.Element;\n var SCROLL_TIME = 468;\n\n // object gathering original scroll methods\n var original = {\n scroll: w.scroll || w.scrollTo,\n scrollBy: w.scrollBy,\n elementScroll: Element.prototype.scroll || scrollElement,\n scrollIntoView: Element.prototype.scrollIntoView,\n };\n\n // define timing method\n var now =\n w.performance && w.performance.now\n ? w.performance.now.bind(w.performance)\n : Date.now;\n\n /**\n * indicates if a the current browser is made by Microsoft\n * @method isMicrosoftBrowser\n * @param {String} userAgent\n * @returns {Boolean}\n */\n function isMicrosoftBrowser(userAgent) {\n var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];\n\n return new RegExp(userAgentPatterns.join('|')).test(userAgent);\n }\n\n /*\n * IE has rounding bug rounding down clientHeight and clientWidth and\n * rounding up scrollHeight and scrollWidth causing false positives\n * on hasScrollableSpace\n */\n var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;\n\n /**\n * changes scroll position inside an element\n * @method scrollElement\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function scrollElement(x, y) {\n this.scrollLeft = x;\n this.scrollTop = y;\n }\n\n /**\n * returns result of applying ease math function to a number\n * @method ease\n * @param {Number} k\n * @returns {Number}\n */\n function ease(k) {\n return 0.5 * (1 - Math.cos(Math.PI * k));\n }\n\n /**\n * indicates if a smooth behavior should be applied\n * @method shouldBailOut\n * @param {Number|Object} firstArg\n * @returns {Boolean}\n */\n function shouldBailOut(firstArg) {\n if (\n firstArg === null ||\n typeof firstArg !== 'object' ||\n firstArg.behavior === undefined ||\n firstArg.behavior === 'auto' ||\n firstArg.behavior === 'instant'\n ) {\n // first argument is not an object/null\n // or behavior is auto, instant or undefined\n return true;\n }\n\n if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {\n // first argument is an object and behavior is smooth\n return false;\n }\n\n // throw error when behavior is not supported\n throw new TypeError(\n 'behavior member of ScrollOptions ' +\n firstArg.behavior +\n ' is not a valid value for enumeration ScrollBehavior.',\n );\n }\n\n /**\n * indicates if an element has scrollable space in the provided axis\n * @method hasScrollableSpace\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function hasScrollableSpace(el, axis) {\n if (axis === 'Y') {\n return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;\n }\n\n if (axis === 'X') {\n return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;\n }\n }\n\n /**\n * indicates if an element has a scrollable overflow property in the axis\n * @method canOverflow\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function canOverflow(el, axis) {\n var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];\n\n return overflowValue === 'auto' || overflowValue === 'scroll';\n }\n\n /**\n * indicates if an element can be scrolled in either axis\n * @method isScrollable\n * @param {Node} el\n * @param {String} axis\n * @returns {Boolean}\n */\n function isScrollable(el) {\n var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');\n var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');\n\n return isScrollableY || isScrollableX;\n }\n\n /**\n * finds scrollable parent of an element\n * @method findScrollableParent\n * @param {Node} el\n * @returns {Node} el\n */\n function findScrollableParent(el) {\n while (el !== d.body && isScrollable(el) === false) {\n el = el.parentNode || el.host;\n }\n\n return el;\n }\n\n /**\n * self invoked function that, given a context, steps through scrolling\n * @method step\n * @param {Object} context\n * @returns {undefined}\n */\n function step(context) {\n var time = now();\n var value;\n var currentX;\n var currentY;\n var elapsed = (time - context.startTime) / SCROLL_TIME;\n\n // avoid elapsed times higher than one\n elapsed = elapsed > 1 ? 1 : elapsed;\n\n // apply easing to elapsed time\n value = ease(elapsed);\n\n currentX = context.startX + (context.x - context.startX) * value;\n currentY = context.startY + (context.y - context.startY) * value;\n\n context.method.call(context.scrollable, currentX, currentY);\n\n // scroll more if we have not reached our destination\n if (currentX !== context.x || currentY !== context.y) {\n w.requestAnimationFrame(step.bind(w, context));\n }\n }\n\n /**\n * scrolls window or element with a smooth behavior\n * @method smoothScroll\n * @param {Object|Node} el\n * @param {Number} x\n * @param {Number} y\n * @returns {undefined}\n */\n function smoothScroll(el, x, y) {\n var scrollable;\n var startX;\n var startY;\n var method;\n var startTime = now();\n\n // define scroll context\n if (el === d.body) {\n scrollable = w;\n startX = w.scrollX || w.pageXOffset;\n startY = w.scrollY || w.pageYOffset;\n method = original.scroll;\n } else {\n scrollable = el;\n startX = el.scrollLeft;\n startY = el.scrollTop;\n method = scrollElement;\n }\n\n // scroll looping over a frame\n step({\n scrollable: scrollable,\n method: method,\n startTime: startTime,\n startX: startX,\n startY: startY,\n x: x,\n y: y,\n });\n }\n\n // ORIGINAL METHODS OVERRIDES\n // w.scroll and w.scrollTo\n w.scroll = w.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scroll.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : w.scrollX || w.pageXOffset,\n // use top prop, second argument if present or fallback to scrollY\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : w.scrollY || w.pageYOffset,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : w.scrollX || w.pageXOffset,\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : w.scrollY || w.pageYOffset,\n );\n };\n\n // w.scrollBy\n w.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0])) {\n original.scrollBy.call(\n w,\n arguments[0].left !== undefined\n ? arguments[0].left\n : typeof arguments[0] !== 'object'\n ? arguments[0]\n : 0,\n arguments[0].top !== undefined\n ? arguments[0].top\n : arguments[1] !== undefined\n ? arguments[1]\n : 0,\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n w,\n d.body,\n ~~arguments[0].left + (w.scrollX || w.pageXOffset),\n ~~arguments[0].top + (w.scrollY || w.pageYOffset),\n );\n };\n\n // Element.prototype.scroll and Element.prototype.scrollTo\n Element.prototype.scroll = Element.prototype.scrollTo = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n // if one number is passed, throw error to match Firefox implementation\n if (typeof arguments[0] === 'number' && arguments[1] === undefined) {\n throw new SyntaxError('Value could not be converted');\n }\n\n original.elementScroll.call(\n this,\n // use left prop, first number argument or fallback to scrollLeft\n arguments[0].left !== undefined\n ? ~~arguments[0].left\n : typeof arguments[0] !== 'object'\n ? ~~arguments[0]\n : this.scrollLeft,\n // use top prop, second argument or fallback to scrollTop\n arguments[0].top !== undefined\n ? ~~arguments[0].top\n : arguments[1] !== undefined\n ? ~~arguments[1]\n : this.scrollTop,\n );\n\n return;\n }\n\n var left = arguments[0].left;\n var top = arguments[0].top;\n\n // LET THE SMOOTHNESS BEGIN!\n smoothScroll.call(\n this,\n this,\n typeof left === 'undefined' ? this.scrollLeft : ~~left,\n typeof top === 'undefined' ? this.scrollTop : ~~top,\n );\n };\n\n // Element.prototype.scrollBy\n Element.prototype.scrollBy = function () {\n // avoid action when no arguments are passed\n if (arguments[0] === undefined) {\n return;\n }\n\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.elementScroll.call(\n this,\n arguments[0].left !== undefined\n ? ~~arguments[0].left + this.scrollLeft\n : ~~arguments[0] + this.scrollLeft,\n arguments[0].top !== undefined\n ? ~~arguments[0].top + this.scrollTop\n : ~~arguments[1] + this.scrollTop,\n );\n\n return;\n }\n\n this.scroll({\n left: ~~arguments[0].left + this.scrollLeft,\n top: ~~arguments[0].top + this.scrollTop,\n behavior: arguments[0].behavior,\n });\n };\n\n // Element.prototype.scrollIntoView\n Element.prototype.scrollIntoView = function () {\n // avoid smooth behavior if not required\n if (shouldBailOut(arguments[0]) === true) {\n original.scrollIntoView.call(\n this,\n arguments[0] === undefined ? true : arguments[0],\n );\n\n return;\n }\n\n // LET THE SMOOTHNESS BEGIN!\n var scrollableParent = findScrollableParent(this);\n var parentRects = scrollableParent.getBoundingClientRect();\n var clientRects = this.getBoundingClientRect();\n\n if (scrollableParent !== d.body) {\n // reveal element inside parent\n smoothScroll.call(\n this,\n scrollableParent,\n scrollableParent.scrollLeft + clientRects.left - parentRects.left,\n scrollableParent.scrollTop + clientRects.top - parentRects.top,\n );\n\n // reveal parent in viewport unless is fixed\n if (w.getComputedStyle(scrollableParent).position !== 'fixed') {\n w.scrollBy({\n left: parentRects.left,\n top: parentRects.top,\n behavior: 'smooth',\n });\n }\n } else {\n // reveal element in viewport\n w.scrollBy({\n left: clientRects.left,\n top: clientRects.top,\n behavior: 'smooth',\n });\n }\n };\n}\n","import {\n actionWithDelay,\n eventWithTime,\n EventType,\n IncrementalSource,\n} from '../types';\n\nexport class Timer {\n public timeOffset: number = 0;\n public speed: number;\n\n private actions: actionWithDelay[];\n private raf: number | null = null;\n private liveMode: boolean;\n\n constructor(actions: actionWithDelay[] = [], speed: number) {\n this.actions = actions;\n this.speed = speed;\n }\n /**\n * Add an action after the timer starts.\n * @param action\n */\n public addAction(action: actionWithDelay) {\n const index = this.findActionIndex(action);\n this.actions.splice(index, 0, action);\n }\n /**\n * Add all actions before the timer starts\n * @param actions\n */\n public addActions(actions: actionWithDelay[]) {\n this.actions = this.actions.concat(actions);\n }\n\n public start() {\n this.timeOffset = 0;\n let lastTimestamp = performance.now();\n const { actions } = this;\n const self = this;\n function check() {\n const time = performance.now();\n self.timeOffset += (time - lastTimestamp) * self.speed;\n lastTimestamp = time;\n while (actions.length) {\n const action = actions[0];\n\n if (self.timeOffset >= action.delay) {\n actions.shift();\n action.doAction();\n } else {\n break;\n }\n }\n if (actions.length > 0 || self.liveMode) {\n self.raf = requestAnimationFrame(check);\n }\n }\n this.raf = requestAnimationFrame(check);\n }\n\n public clear() {\n if (this.raf) {\n cancelAnimationFrame(this.raf);\n this.raf = null;\n }\n this.actions.length = 0;\n }\n\n public setSpeed(speed: number) {\n this.speed = speed;\n }\n\n public toggleLiveMode(mode: boolean) {\n this.liveMode = mode;\n }\n\n public isActive() {\n return this.raf !== null;\n }\n\n private findActionIndex(action: actionWithDelay): number {\n let start = 0;\n let end = this.actions.length - 1;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (this.actions[mid].delay < action.delay) {\n start = mid + 1;\n } else if (this.actions[mid].delay > action.delay) {\n end = mid - 1;\n } else {\n // already an action with same delay (timestamp)\n // the plus one will splice the new one after the existing one\n return mid + 1;\n }\n }\n return start;\n }\n}\n\n// TODO: add speed to mouse move timestamp calculation\nexport function addDelay(event: eventWithTime, baselineTime: number): number {\n // Mouse move events was recorded in a throttle function,\n // so we need to find the real timestamp by traverse the time offsets.\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove\n ) {\n const firstOffset = event.data.positions[0].timeOffset;\n // timeOffset is a negative offset to event.timestamp\n const firstTimestamp = event.timestamp + firstOffset;\n event.delay = firstTimestamp - baselineTime;\n return firstTimestamp - baselineTime;\n }\n\n event.delay = event.timestamp - baselineTime;\n return event.delay;\n}\n","/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return{type:\"xstate.assign\",assignment:t}}function i(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){o=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]=\"function\"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o]})),r=n,!1}return!0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})))},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u=\"object\"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}export{n as InterpreterStatus,o as assign,s as createMachine,v as interpret};\n","import { createMachine, interpret, assign, StateMachine } from '@xstate/fsm';\nimport {\n playerConfig,\n eventWithTime,\n actionWithDelay,\n ReplayerEvents,\n EventType,\n Emitter,\n IncrementalSource,\n} from '../types';\nimport { Timer, addDelay } from './timer';\n\nexport type PlayerContext = {\n events: eventWithTime[];\n timer: Timer;\n timeOffset: number;\n baselineTime: number;\n lastPlayedEvent: eventWithTime | null;\n};\nexport type PlayerEvent =\n | {\n type: 'PLAY';\n payload: {\n timeOffset: number;\n };\n }\n | {\n type: 'CAST_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | { type: 'PAUSE' }\n | { type: 'TO_LIVE'; payload: { baselineTime?: number } }\n | {\n type: 'ADD_EVENT';\n payload: {\n event: eventWithTime;\n };\n }\n | {\n type: 'END';\n };\nexport type PlayerState =\n | {\n value: 'playing';\n context: PlayerContext;\n }\n | {\n value: 'paused';\n context: PlayerContext;\n }\n | {\n value: 'live';\n context: PlayerContext;\n };\n\n/**\n * If the array have multiple meta and fullsnapshot events,\n * return the events from last meta to the end.\n */\nexport function discardPriorSnapshots(\n events: eventWithTime[],\n baselineTime: number,\n): eventWithTime[] {\n for (let idx = events.length - 1; idx >= 0; idx--) {\n const event = events[idx];\n if (event.type === EventType.Meta) {\n if (event.timestamp <= baselineTime) {\n return events.slice(idx);\n }\n }\n }\n return events;\n}\n\ntype PlayerAssets = {\n emitter: Emitter;\n applyEventsSynchronously(events: Array): void;\n getCastFn(event: eventWithTime, isSync: boolean): () => void;\n};\nexport function createPlayerService(\n context: PlayerContext,\n { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets,\n) {\n const playerMachine = createMachine(\n {\n id: 'player',\n context,\n initial: 'paused',\n states: {\n playing: {\n on: {\n PAUSE: {\n target: 'paused',\n actions: ['pause'],\n },\n CAST_EVENT: {\n target: 'playing',\n actions: 'castEvent',\n },\n END: {\n target: 'paused',\n actions: ['resetLastPlayedEvent', 'pause'],\n },\n ADD_EVENT: {\n target: 'playing',\n actions: ['addEvent'],\n },\n },\n },\n paused: {\n on: {\n PLAY: {\n target: 'playing',\n actions: ['recordTimeOffset', 'play'],\n },\n CAST_EVENT: {\n target: 'paused',\n actions: 'castEvent',\n },\n TO_LIVE: {\n target: 'live',\n actions: ['startLive'],\n },\n ADD_EVENT: {\n target: 'paused',\n actions: ['addEvent'],\n },\n },\n },\n live: {\n on: {\n ADD_EVENT: {\n target: 'live',\n actions: ['addEvent'],\n },\n CAST_EVENT: {\n target: 'live',\n actions: ['castEvent'],\n },\n },\n },\n },\n },\n {\n actions: {\n castEvent: assign({\n lastPlayedEvent: (ctx, event) => {\n if (event.type === 'CAST_EVENT') {\n return event.payload.event;\n }\n return ctx.lastPlayedEvent;\n },\n }),\n recordTimeOffset: assign((ctx, event) => {\n let timeOffset = ctx.timeOffset;\n if ('payload' in event && 'timeOffset' in event.payload) {\n timeOffset = event.payload.timeOffset;\n }\n return {\n ...ctx,\n timeOffset,\n baselineTime: ctx.events[0].timestamp + timeOffset,\n };\n }),\n play(ctx) {\n const { timer, events, baselineTime, lastPlayedEvent } = ctx;\n timer.clear();\n\n for (const event of events) {\n // TODO: improve this API\n addDelay(event, baselineTime);\n }\n const neededEvents = discardPriorSnapshots(events, baselineTime);\n\n let lastPlayedTimestamp = lastPlayedEvent?.timestamp;\n if (\n lastPlayedEvent?.type === EventType.IncrementalSnapshot &&\n lastPlayedEvent.data.source === IncrementalSource.MouseMove\n ) {\n lastPlayedTimestamp =\n lastPlayedEvent.timestamp +\n lastPlayedEvent.data.positions[0]?.timeOffset;\n }\n if (baselineTime < (lastPlayedTimestamp || 0)) {\n emitter.emit(ReplayerEvents.PlayBack);\n }\n\n const syncEvents = new Array();\n const actions = new Array();\n for (const event of neededEvents) {\n if (\n lastPlayedTimestamp &&\n lastPlayedTimestamp < baselineTime &&\n (event.timestamp <= lastPlayedTimestamp ||\n event === lastPlayedEvent)\n ) {\n continue;\n }\n if (event.timestamp < baselineTime) {\n syncEvents.push(event);\n } else {\n const castFn = getCastFn(event, false);\n actions.push({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n applyEventsSynchronously(syncEvents);\n emitter.emit(ReplayerEvents.Flush);\n timer.addActions(actions);\n timer.start();\n },\n pause(ctx) {\n ctx.timer.clear();\n },\n resetLastPlayedEvent: assign((ctx) => {\n return {\n ...ctx,\n lastPlayedEvent: null,\n };\n }),\n startLive: assign({\n baselineTime: (ctx, event) => {\n ctx.timer.toggleLiveMode(true);\n ctx.timer.start();\n if (event.type === 'TO_LIVE' && event.payload.baselineTime) {\n return event.payload.baselineTime;\n }\n return Date.now();\n },\n }),\n addEvent: assign((ctx, machineEvent) => {\n const { baselineTime, timer, events } = ctx;\n if (machineEvent.type === 'ADD_EVENT') {\n const { event } = machineEvent.payload;\n addDelay(event, baselineTime);\n\n let end = events.length - 1;\n if (!events[end] || events[end].timestamp <= event.timestamp) {\n // fast track\n events.push(event);\n } else {\n let insertionIndex = -1;\n let start = 0;\n while (start <= end) {\n let mid = Math.floor((start + end) / 2);\n if (events[mid].timestamp <= event.timestamp) {\n start = mid + 1;\n } else {\n end = mid - 1;\n }\n }\n if (insertionIndex === -1) {\n insertionIndex = start;\n }\n events.splice(insertionIndex, 0, event);\n }\n\n const isSync = event.timestamp < baselineTime;\n const castFn = getCastFn(event, isSync);\n if (isSync) {\n castFn();\n } else if (timer.isActive()) {\n timer.addAction({\n doAction: () => {\n castFn();\n },\n delay: event.delay!,\n });\n }\n }\n return { ...ctx, events };\n }),\n },\n },\n );\n return interpret(playerMachine);\n}\n\nexport type SpeedContext = {\n normalSpeed: playerConfig['speed'];\n timer: Timer;\n};\n\nexport type SpeedEvent =\n | {\n type: 'FAST_FORWARD';\n payload: { speed: playerConfig['speed'] };\n }\n | {\n type: 'BACK_TO_NORMAL';\n }\n | {\n type: 'SET_SPEED';\n payload: { speed: playerConfig['speed'] };\n };\n\nexport type SpeedState =\n | {\n value: 'normal';\n context: SpeedContext;\n }\n | {\n value: 'skipping';\n context: SpeedContext;\n };\n\nexport function createSpeedService(context: SpeedContext) {\n const speedMachine = createMachine(\n {\n id: 'speed',\n context,\n initial: 'normal',\n states: {\n normal: {\n on: {\n FAST_FORWARD: {\n target: 'skipping',\n actions: ['recordSpeed', 'setSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n skipping: {\n on: {\n BACK_TO_NORMAL: {\n target: 'normal',\n actions: ['restoreSpeed'],\n },\n SET_SPEED: {\n target: 'normal',\n actions: ['setSpeed'],\n },\n },\n },\n },\n },\n {\n actions: {\n setSpeed: (ctx, event) => {\n if ('payload' in event) {\n ctx.timer.setSpeed(event.payload.speed);\n }\n },\n recordSpeed: assign({\n normalSpeed: (ctx) => ctx.timer.speed,\n }),\n restoreSpeed: (ctx) => {\n ctx.timer.setSpeed(ctx.normalSpeed);\n },\n },\n },\n );\n\n return interpret(speedMachine);\n}\n\nexport type PlayerMachineState = StateMachine.State<\n PlayerContext,\n PlayerEvent,\n PlayerState\n>;\n\nexport type SpeedMachineState = StateMachine.State<\n SpeedContext,\n SpeedEvent,\n SpeedState\n>;\n","const rules: (blockClass: string) => string[] = (blockClass: string) => [\n `.${blockClass} { background: currentColor }`,\n 'noscript { display: none !important; }',\n];\n\nexport default rules;\n","import { INode } from 'rrweb-snapshot';\n\nexport enum StyleRuleType {\n Insert,\n Remove,\n Snapshot,\n SetProperty,\n RemoveProperty,\n}\n\ntype InsertRule = {\n cssText: string;\n type: StyleRuleType.Insert;\n index?: number | number[];\n};\ntype RemoveRule = {\n type: StyleRuleType.Remove;\n index: number | number[];\n};\ntype SnapshotRule = {\n type: StyleRuleType.Snapshot;\n cssTexts: string[];\n};\ntype SetPropertyRule = {\n type: StyleRuleType.SetProperty;\n index: number[];\n property: string;\n value: string | null;\n priority: string | undefined;\n};\ntype RemovePropertyRule = {\n type: StyleRuleType.RemoveProperty;\n index: number[];\n property: string;\n};\n\nexport type VirtualStyleRules = Array<\n InsertRule | RemoveRule | SnapshotRule | SetPropertyRule | RemovePropertyRule\n>;\nexport type VirtualStyleRulesMap = Map;\n\nexport function getNestedRule(\n rules: CSSRuleList,\n position: number[],\n): CSSGroupingRule {\n const rule = rules[position[0]] as CSSGroupingRule;\n if (position.length === 1) {\n return rule;\n } else {\n return getNestedRule(\n ((rule as CSSGroupingRule).cssRules[position[1]] as CSSGroupingRule)\n .cssRules,\n position.slice(2),\n );\n }\n}\n\nexport function getPositionsAndIndex(nestedIndex: number[]) {\n const positions = [...nestedIndex];\n const index = positions.pop();\n return { positions, index };\n}\n\nexport function applyVirtualStyleRulesToNode(\n storedRules: VirtualStyleRules,\n styleNode: HTMLStyleElement,\n) {\n const { sheet } = styleNode;\n if (!sheet) {\n // styleNode without sheet means the DOM has been removed\n // so the rules no longer need to be applied\n return;\n }\n\n storedRules.forEach((rule) => {\n if (rule.type === StyleRuleType.Insert) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.insertRule(rule.cssText, index);\n } else {\n sheet.insertRule(rule.cssText, rule.index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n } else if (rule.type === StyleRuleType.Remove) {\n try {\n if (Array.isArray(rule.index)) {\n const { positions, index } = getPositionsAndIndex(rule.index);\n const nestedRule = getNestedRule(sheet.cssRules, positions);\n nestedRule.deleteRule(index || 0);\n } else {\n sheet.deleteRule(rule.index);\n }\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else if (rule.type === StyleRuleType.Snapshot) {\n restoreSnapshotOfStyleRulesToNode(rule.cssTexts, styleNode);\n } else if (rule.type === StyleRuleType.SetProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.setProperty(rule.property, rule.value, rule.priority);\n } else if (rule.type === StyleRuleType.RemoveProperty) {\n const nativeRule = (getNestedRule(\n sheet.cssRules,\n rule.index,\n ) as unknown) as CSSStyleRule;\n nativeRule.style.removeProperty(rule.property);\n }\n });\n}\n\nfunction restoreSnapshotOfStyleRulesToNode(\n cssTexts: string[],\n styleNode: HTMLStyleElement,\n) {\n try {\n const existingRules = Array.from(styleNode.sheet?.cssRules || []).map(\n (rule) => rule.cssText,\n );\n const existingRulesReversed = Object.entries(existingRules).reverse();\n let lastMatch = existingRules.length;\n existingRulesReversed.forEach(([index, rule]) => {\n const indexOf = cssTexts.indexOf(rule);\n if (indexOf === -1 || indexOf > lastMatch) {\n try {\n styleNode.sheet?.deleteRule(Number(index));\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n }\n lastMatch = indexOf;\n });\n cssTexts.forEach((cssText, index) => {\n try {\n if (styleNode.sheet?.cssRules[index]?.cssText !== cssText) {\n styleNode.sheet?.insertRule(cssText, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n }\n });\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n\nexport function storeCSSRules(\n parentElement: HTMLStyleElement,\n virtualStyleRulesMap: VirtualStyleRulesMap,\n) {\n try {\n const cssTexts = Array.from(\n (parentElement as HTMLStyleElement).sheet?.cssRules || [],\n ).map((rule) => rule.cssText);\n virtualStyleRulesMap.set((parentElement as unknown) as INode, [\n {\n type: StyleRuleType.Snapshot,\n cssTexts,\n },\n ]);\n } catch (e) {\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n}\n","import { decode } from 'base64-arraybuffer';\nimport { Replayer } from '../';\nimport {\n CanvasContext,\n canvasMutationCommand,\n SerializedWebGlArg,\n} from '../../types';\n\n// TODO: add ability to wipe this list\ntype GLVarMap = Map;\nconst webGLVarMap: Map<\n WebGLRenderingContext | WebGL2RenderingContext,\n GLVarMap\n> = new Map();\nexport function variableListFor(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n ctor: string,\n) {\n let contextMap = webGLVarMap.get(ctx);\n if (!contextMap) {\n contextMap = new Map();\n webGLVarMap.set(ctx, contextMap);\n }\n if (!contextMap.has(ctor)) {\n contextMap.set(ctor, []);\n }\n return contextMap.get(ctor) as any[];\n}\n\nfunction getContext(\n target: HTMLCanvasElement,\n type: CanvasContext,\n): WebGLRenderingContext | WebGL2RenderingContext | null {\n // Note to whomever is going to implement support for `contextAttributes`:\n // if `preserveDrawingBuffer` is set to true,\n // you might have to do `ctx.flush()` before every webgl canvas event\n try {\n if (type === CanvasContext.WebGL) {\n return (\n target.getContext('webgl')! || target.getContext('experimental-webgl')\n );\n }\n return target.getContext('webgl2')!;\n } catch (e) {\n return null;\n }\n}\n\nconst WebGLVariableConstructorsNames = [\n 'WebGLActiveInfo',\n 'WebGLBuffer',\n 'WebGLFramebuffer',\n 'WebGLProgram',\n 'WebGLRenderbuffer',\n 'WebGLShader',\n 'WebGLShaderPrecisionFormat',\n 'WebGLTexture',\n 'WebGLUniformLocation',\n 'WebGLVertexArrayObject',\n];\n\nfunction saveToWebGLVarMap(\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n result: any,\n) {\n if (!result?.constructor) return; // probably null or undefined\n\n const { name } = result.constructor;\n if (!WebGLVariableConstructorsNames.includes(name)) return; // not a WebGL variable\n\n const variables = variableListFor(ctx, name);\n if (!variables.includes(result)) variables.push(result);\n}\n\nexport function deserializeArg(\n imageMap: Replayer['imageMap'],\n ctx: WebGLRenderingContext | WebGL2RenderingContext,\n): (arg: SerializedWebGlArg) => any {\n return (arg: SerializedWebGlArg): any => {\n if (arg && typeof arg === 'object' && 'rr_type' in arg) {\n if ('index' in arg) {\n const { rr_type: name, index } = arg;\n return variableListFor(ctx, name)[index];\n } else if ('args' in arg) {\n const { rr_type: name, args } = arg;\n const ctor = window[name as keyof Window];\n\n return new ctor(...args.map(deserializeArg(imageMap, ctx)));\n } else if ('base64' in arg) {\n return decode(arg.base64);\n } else if ('src' in arg) {\n const image = imageMap.get(arg.src);\n if (image) {\n return image;\n } else {\n const image = new Image();\n image.src = arg.src;\n imageMap.set(arg.src, image);\n return image;\n }\n }\n } else if (Array.isArray(arg)) {\n return arg.map(deserializeArg(imageMap, ctx));\n }\n return arg;\n };\n}\n\nexport default function webglMutation({\n mutation,\n target,\n type,\n imageMap,\n errorHandler,\n}: {\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n type: CanvasContext;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = getContext(target, type);\n if (!ctx) return;\n\n // NOTE: if `preserveDrawingBuffer` is set to true,\n // we must flush the buffers on every new canvas event\n // if (mutation.newFrame) ctx.flush();\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n const args = mutation.args.map(deserializeArg(imageMap, ctx));\n const result = original.apply(ctx, args);\n saveToWebGLVarMap(ctx, result);\n\n // Slows down replay considerably, only use for debugging\n const debugMode = false;\n if (debugMode) {\n if (mutation.property === 'compileShader') {\n if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getShaderInfoLog(args[0]),\n );\n } else if (mutation.property === 'linkProgram') {\n ctx.validateProgram(args[0]);\n if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))\n console.warn(\n 'something went wrong in replay',\n ctx.getProgramInfoLog(args[0]),\n );\n }\n const webglError = ctx.getError();\n if (webglError !== ctx.NO_ERROR) {\n console.warn(\n 'WEBGL ERROR',\n webglError,\n 'on command:',\n mutation.property,\n ...args,\n );\n }\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import {\n rebuild,\n buildNodeWithSN,\n INode,\n NodeType,\n BuildCache,\n createCache,\n} from 'rrweb-snapshot';\nimport * as mittProxy from 'mitt';\nimport { polyfill as smoothscrollPolyfill } from './smoothscroll';\nimport { Timer } from './timer';\nimport { createPlayerService, createSpeedService } from './machine';\nimport {\n EventType,\n IncrementalSource,\n fullSnapshotEvent,\n eventWithTime,\n MouseInteractions,\n playerConfig,\n playerMetaData,\n viewportResizeDimension,\n missingNodeMap,\n addedNodeMutation,\n missingNode,\n incrementalSnapshotEvent,\n incrementalData,\n ReplayerEvents,\n Handler,\n Emitter,\n MediaInteractions,\n metaEvent,\n mutationData,\n scrollData,\n inputData,\n canvasMutationData,\n Mirror,\n ElementState,\n styleAttributeValue,\n styleValueWithPriority,\n mouseMovePos,\n IWindow,\n canvasMutationCommand,\n textMutation,\n} from '../types';\nimport {\n createMirror,\n polyfill,\n TreeIndex,\n queueToResolveTrees,\n iterateResolveTree,\n AppendedIframe,\n isIframeINode,\n getBaseDimension,\n hasShadowRoot,\n} from '../utils';\nimport getInjectStyleRules from './styles/inject-style';\nimport './styles/style.css';\nimport {\n applyVirtualStyleRulesToNode,\n storeCSSRules,\n StyleRuleType,\n VirtualStyleRules,\n VirtualStyleRulesMap,\n getNestedRule,\n getPositionsAndIndex,\n} from './virtual-styles';\nimport canvasMutation from './canvas';\n\nconst SKIP_TIME_THRESHOLD = 10 * 1000;\nconst SKIP_TIME_INTERVAL = 5 * 1000;\n\n// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734\n// tslint:disable-next-line\nconst mitt = (mittProxy as any).default || mittProxy;\n\nconst REPLAY_CONSOLE_PREFIX = '[replayer]';\n\nconst defaultMouseTailConfig = {\n duration: 500,\n lineCap: 'round',\n lineWidth: 3,\n strokeStyle: 'red',\n} as const;\n\nfunction indicatesTouchDevice(e: eventWithTime) {\n return (\n e.type == EventType.IncrementalSnapshot &&\n (e.data.source == IncrementalSource.TouchMove ||\n (e.data.source == IncrementalSource.MouseInteraction &&\n e.data.type == MouseInteractions.TouchStart))\n );\n}\n\nexport class Replayer {\n public wrapper: HTMLDivElement;\n public iframe: HTMLIFrameElement;\n\n public service: ReturnType;\n public speedService: ReturnType;\n public get timer() {\n return this.service.state.context.timer;\n }\n\n public config: playerConfig;\n\n private mouse: HTMLDivElement;\n private mouseTail: HTMLCanvasElement | null = null;\n private tailPositions: Array<{ x: number; y: number }> = [];\n\n private emitter: Emitter = mitt();\n\n private nextUserInteractionEvent: eventWithTime | null;\n\n // tslint:disable-next-line: variable-name\n private legacy_missingNodeRetryMap: missingNodeMap = {};\n\n private treeIndex!: TreeIndex;\n private fragmentParentMap!: Map;\n private elementStateMap!: Map;\n // Hold the list of CSSRules for in-memory state restoration\n private virtualStyleRulesMap!: VirtualStyleRulesMap;\n\n // The replayer uses the cache to speed up replay and scrubbing.\n private cache: BuildCache = createCache();\n\n private imageMap: Map = new Map();\n\n private mirror: Mirror = createMirror();\n\n private firstFullSnapshot: eventWithTime | true | null = null;\n\n private newDocumentQueue: addedNodeMutation[] = [];\n\n private mousePos: mouseMovePos | null = null;\n private touchActive: boolean | null = null;\n\n constructor(\n events: Array,\n config?: Partial,\n ) {\n if (!config?.liveMode && events.length < 2) {\n throw new Error('Replayer need at least 2 events.');\n }\n const defaultConfig: playerConfig = {\n speed: 1,\n maxSpeed: 360,\n root: document.body,\n loadTimeout: 0,\n skipInactive: false,\n showWarning: true,\n showDebug: false,\n blockClass: 'rr-block',\n liveMode: false,\n insertStyleRules: [],\n triggerFocus: true,\n UNSAFE_replayCanvas: false,\n pauseAnimation: true,\n mouseTail: defaultMouseTailConfig,\n };\n this.config = Object.assign({}, defaultConfig, config);\n\n this.handleResize = this.handleResize.bind(this);\n this.getCastFn = this.getCastFn.bind(this);\n this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);\n this.emitter.on(ReplayerEvents.Resize, this.handleResize as Handler);\n\n this.setupDom();\n\n this.treeIndex = new TreeIndex();\n this.fragmentParentMap = new Map();\n this.elementStateMap = new Map();\n this.virtualStyleRulesMap = new Map();\n\n this.emitter.on(ReplayerEvents.Flush, () => {\n const { scrollMap, inputMap, mutationData } = this.treeIndex.flush();\n\n this.fragmentParentMap.forEach((parent, frag) =>\n this.restoreRealParent(frag, parent),\n );\n // apply text needs to happen before virtual style rules gets applied\n // as it can overwrite the contents of a stylesheet\n for (const d of mutationData.texts) {\n this.applyText(d, mutationData);\n }\n\n for (const node of this.virtualStyleRulesMap.keys()) {\n // restore css rules of style elements after they are mounted\n this.restoreNodeSheet(node);\n }\n this.fragmentParentMap.clear();\n this.elementStateMap.clear();\n this.virtualStyleRulesMap.clear();\n\n for (const d of scrollMap.values()) {\n this.applyScroll(d, true);\n }\n for (const d of inputMap.values()) {\n this.applyInput(d);\n }\n });\n this.emitter.on(ReplayerEvents.PlayBack, () => {\n this.firstFullSnapshot = null;\n this.mirror.reset();\n });\n\n const timer = new Timer([], config?.speed || defaultConfig.speed);\n this.service = createPlayerService(\n {\n events: events\n .map((e) => {\n if (config && config.unpackFn) {\n return config.unpackFn(e as string);\n }\n return e as eventWithTime;\n })\n .sort((a1, a2) => a1.timestamp - a2.timestamp),\n timer,\n timeOffset: 0,\n baselineTime: 0,\n lastPlayedEvent: null,\n },\n {\n getCastFn: this.getCastFn,\n applyEventsSynchronously: this.applyEventsSynchronously,\n emitter: this.emitter,\n },\n );\n this.service.start();\n this.service.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n player: state,\n });\n });\n this.speedService = createSpeedService({\n normalSpeed: -1,\n timer,\n });\n this.speedService.start();\n this.speedService.subscribe((state) => {\n this.emitter.emit(ReplayerEvents.StateChange, {\n speed: state,\n });\n });\n\n // rebuild first full snapshot as the poster of the player\n // maybe we can cache it for performance optimization\n const firstMeta = this.service.state.context.events.find(\n (e) => e.type === EventType.Meta,\n );\n const firstFullsnapshot = this.service.state.context.events.find(\n (e) => e.type === EventType.FullSnapshot,\n );\n if (firstMeta) {\n const { width, height } = firstMeta.data as metaEvent['data'];\n setTimeout(() => {\n this.emitter.emit(ReplayerEvents.Resize, {\n width,\n height,\n });\n }, 0);\n }\n if (firstFullsnapshot) {\n setTimeout(() => {\n // when something has been played, there is no need to rebuild poster\n if (this.firstFullSnapshot) {\n // true if any other fullSnapshot has been executed by Timer already\n return;\n }\n this.firstFullSnapshot = firstFullsnapshot;\n this.rebuildFullSnapshot(\n firstFullsnapshot as fullSnapshotEvent & { timestamp: number },\n );\n this.iframe.contentWindow!.scrollTo(\n (firstFullsnapshot as fullSnapshotEvent).data.initialOffset,\n );\n }, 1);\n }\n if (this.service.state.context.events.find(indicatesTouchDevice)) {\n this.mouse.classList.add('touch-device');\n }\n }\n\n public on(event: string, handler: Handler) {\n this.emitter.on(event, handler);\n return this;\n }\n\n public off(event: string, handler: Handler) {\n this.emitter.off(event, handler);\n return this;\n }\n\n public setConfig(config: Partial) {\n Object.keys(config).forEach((key) => {\n // @ts-ignore\n this.config[key] = config[key];\n });\n if (!this.config.skipInactive) {\n this.backToNormal();\n }\n if (typeof config.speed !== 'undefined') {\n this.speedService.send({\n type: 'SET_SPEED',\n payload: {\n speed: config.speed!,\n },\n });\n }\n if (typeof config.mouseTail !== 'undefined') {\n if (config.mouseTail === false) {\n if (this.mouseTail) {\n this.mouseTail.style.display = 'none';\n }\n } else {\n if (!this.mouseTail) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.width = Number.parseFloat(this.iframe.width);\n this.mouseTail.height = Number.parseFloat(this.iframe.height);\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.wrapper.insertBefore(this.mouseTail, this.iframe);\n }\n this.mouseTail.style.display = 'inherit';\n }\n }\n }\n\n public getMetaData(): playerMetaData {\n const firstEvent = this.service.state.context.events[0];\n const lastEvent = this.service.state.context.events[\n this.service.state.context.events.length - 1\n ];\n return {\n startTime: firstEvent.timestamp,\n endTime: lastEvent.timestamp,\n totalTime: lastEvent.timestamp - firstEvent.timestamp,\n };\n }\n\n public getCurrentTime(): number {\n return this.timer.timeOffset + this.getTimeOffset();\n }\n\n public getTimeOffset(): number {\n const { baselineTime, events } = this.service.state.context;\n return baselineTime - events[0].timestamp;\n }\n\n public getMirror(): Mirror {\n return this.mirror;\n }\n\n /**\n * This API was designed to be used as play at any time offset.\n * Since we minimized the data collected from recorder, we do not\n * have the ability of undo an event.\n * So the implementation of play at any time offset will always iterate\n * all of the events, cast event before the offset synchronously\n * and cast event after the offset asynchronously with timer.\n * @param timeOffset number\n */\n public play(timeOffset = 0) {\n if (this.service.state.matches('paused')) {\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n } else {\n this.service.send({ type: 'PAUSE' });\n this.service.send({ type: 'PLAY', payload: { timeOffset } });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.remove('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Start);\n }\n\n public pause(timeOffset?: number) {\n if (timeOffset === undefined && this.service.state.matches('playing')) {\n this.service.send({ type: 'PAUSE' });\n }\n if (typeof timeOffset === 'number') {\n this.play(timeOffset);\n this.service.send({ type: 'PAUSE' });\n }\n this.iframe.contentDocument\n ?.getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n this.emitter.emit(ReplayerEvents.Pause);\n }\n\n public resume(timeOffset = 0) {\n console.warn(\n `The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.`,\n );\n this.play(timeOffset);\n this.emitter.emit(ReplayerEvents.Resume);\n }\n\n public startLive(baselineTime?: number) {\n this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });\n }\n\n public addEvent(rawEvent: eventWithTime | string) {\n const event = this.config.unpackFn\n ? this.config.unpackFn(rawEvent as string)\n : (rawEvent as eventWithTime);\n if (indicatesTouchDevice(event)) {\n this.mouse.classList.add('touch-device');\n }\n Promise.resolve().then(() =>\n this.service.send({ type: 'ADD_EVENT', payload: { event } }),\n );\n }\n\n public enableInteract() {\n this.iframe.setAttribute('scrolling', 'auto');\n this.iframe.style.pointerEvents = 'auto';\n }\n\n public disableInteract() {\n this.iframe.setAttribute('scrolling', 'no');\n this.iframe.style.pointerEvents = 'none';\n }\n\n /**\n * Empties the replayer's cache and reclaims memory.\n * The replayer will use this cache to speed up the playback.\n */\n public resetCache() {\n this.cache = createCache();\n }\n\n private setupDom() {\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add('replayer-wrapper');\n this.config.root!.appendChild(this.wrapper);\n\n this.mouse = document.createElement('div');\n this.mouse.classList.add('replayer-mouse');\n this.wrapper.appendChild(this.mouse);\n\n if (this.config.mouseTail !== false) {\n this.mouseTail = document.createElement('canvas');\n this.mouseTail.classList.add('replayer-mouse-tail');\n this.mouseTail.style.display = 'inherit';\n this.wrapper.appendChild(this.mouseTail);\n }\n\n this.iframe = document.createElement('iframe');\n const attributes = ['allow-same-origin'];\n if (this.config.UNSAFE_replayCanvas) {\n attributes.push('allow-scripts');\n }\n // hide iframe before first meta event\n this.iframe.style.display = 'none';\n this.iframe.setAttribute('sandbox', attributes.join(' '));\n this.disableInteract();\n this.wrapper.appendChild(this.iframe);\n if (this.iframe.contentWindow && this.iframe.contentDocument) {\n smoothscrollPolyfill(\n this.iframe.contentWindow,\n this.iframe.contentDocument,\n );\n\n polyfill(this.iframe.contentWindow as IWindow);\n }\n }\n\n private handleResize(dimension: viewportResizeDimension) {\n this.iframe.style.display = 'inherit';\n for (const el of [this.mouseTail, this.iframe]) {\n if (!el) {\n continue;\n }\n el.setAttribute('width', String(dimension.width));\n el.setAttribute('height', String(dimension.height));\n }\n }\n\n private applyEventsSynchronously(events: Array) {\n for (const event of events) {\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n case EventType.Custom:\n continue;\n case EventType.FullSnapshot:\n case EventType.Meta:\n case EventType.Plugin:\n break;\n case EventType.IncrementalSnapshot:\n switch (event.data.source) {\n case IncrementalSource.MediaInteraction:\n continue;\n default:\n break;\n }\n break;\n default:\n break;\n }\n const castFn = this.getCastFn(event, true);\n castFn();\n }\n if (this.mousePos) {\n this.moveAndHover(\n this.mousePos.x,\n this.mousePos.y,\n this.mousePos.id,\n true,\n this.mousePos.debugData,\n );\n }\n this.mousePos = null;\n if (this.touchActive === true) {\n this.mouse.classList.add('touch-active');\n } else if (this.touchActive === false) {\n this.mouse.classList.remove('touch-active');\n }\n this.touchActive = null;\n }\n\n private getCastFn(event: eventWithTime, isSync = false) {\n let castFn: undefined | (() => void);\n switch (event.type) {\n case EventType.DomContentLoaded:\n case EventType.Load:\n break;\n case EventType.Custom:\n castFn = () => {\n /**\n * emit custom-event and pass the event object.\n *\n * This will add more value to the custom event and allows the client to react for custom-event.\n */\n this.emitter.emit(ReplayerEvents.CustomEvent, event);\n };\n break;\n case EventType.Meta:\n castFn = () =>\n this.emitter.emit(ReplayerEvents.Resize, {\n width: event.data.width,\n height: event.data.height,\n });\n break;\n case EventType.FullSnapshot:\n castFn = () => {\n if (this.firstFullSnapshot) {\n if (this.firstFullSnapshot === event) {\n // we've already built this exact FullSnapshot when the player was mounted, and haven't built any other FullSnapshot since\n this.firstFullSnapshot = true; // forget as we might need to re-execute this FullSnapshot later e.g. to rebuild after scrubbing\n return;\n }\n } else {\n // Timer (requestAnimationFrame) can be faster than setTimeout(..., 1)\n this.firstFullSnapshot = true;\n }\n this.rebuildFullSnapshot(event, isSync);\n this.iframe.contentWindow!.scrollTo(event.data.initialOffset);\n };\n break;\n case EventType.IncrementalSnapshot:\n castFn = () => {\n this.applyIncremental(event, isSync);\n if (isSync) {\n // do not check skip in sync\n return;\n }\n if (event === this.nextUserInteractionEvent) {\n this.nextUserInteractionEvent = null;\n this.backToNormal();\n }\n if (this.config.skipInactive && !this.nextUserInteractionEvent) {\n for (const _event of this.service.state.context.events) {\n if (_event.timestamp! <= event.timestamp!) {\n continue;\n }\n if (this.isUserInteraction(_event)) {\n if (\n _event.delay! - event.delay! >\n SKIP_TIME_THRESHOLD *\n this.speedService.state.context.timer.speed\n ) {\n this.nextUserInteractionEvent = _event;\n }\n break;\n }\n }\n if (this.nextUserInteractionEvent) {\n const skipTime =\n this.nextUserInteractionEvent.delay! - event.delay!;\n const payload = {\n speed: Math.min(\n Math.round(skipTime / SKIP_TIME_INTERVAL),\n this.config.maxSpeed,\n ),\n };\n this.speedService.send({ type: 'FAST_FORWARD', payload });\n this.emitter.emit(ReplayerEvents.SkipStart, payload);\n }\n }\n };\n break;\n default:\n }\n const wrappedCastFn = () => {\n if (castFn) {\n castFn();\n }\n\n for (const plugin of this.config.plugins || []) {\n plugin.handler(event, isSync, { replayer: this });\n }\n\n this.service.send({ type: 'CAST_EVENT', payload: { event } });\n\n // events are kept sorted by timestamp, check if this is the last event\n let last_index = this.service.state.context.events.length - 1;\n if (event === this.service.state.context.events[last_index]) {\n const finish = () => {\n if (last_index < this.service.state.context.events.length - 1) {\n // more events have been added since the setTimeout\n return;\n }\n this.backToNormal();\n this.service.send('END');\n this.emitter.emit(ReplayerEvents.Finish);\n };\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.MouseMove &&\n event.data.positions.length\n ) {\n // defer finish event if the last event is a mouse move\n setTimeout(() => {\n finish();\n }, Math.max(0, -event.data.positions[0].timeOffset + 50)); // Add 50 to make sure the timer would check the last mousemove event. Otherwise, the timer may be stopped by the service before checking the last event.\n } else {\n finish();\n }\n }\n\n this.emitter.emit(ReplayerEvents.EventCast, event);\n };\n return wrappedCastFn;\n }\n\n private rebuildFullSnapshot(\n event: fullSnapshotEvent & { timestamp: number },\n isSync: boolean = false,\n ) {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n console.warn(\n 'Found unresolved missing node map',\n this.legacy_missingNodeRetryMap,\n );\n }\n this.legacy_missingNodeRetryMap = {};\n const collected: AppendedIframe[] = [];\n this.mirror.map = rebuild(event.data.node, {\n doc: this.iframe.contentDocument,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n },\n cache: this.cache,\n })[1];\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n const { documentElement, head } = this.iframe.contentDocument;\n this.insertStyleRules(documentElement, head);\n if (!this.service.state.matches('playing')) {\n this.iframe.contentDocument\n .getElementsByTagName('html')[0]\n .classList.add('rrweb-paused');\n }\n this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);\n if (!isSync) {\n this.waitForStylesheetLoad();\n }\n if (this.config.UNSAFE_replayCanvas) {\n this.preloadAllImages();\n }\n }\n\n private insertStyleRules(\n documentElement: HTMLElement,\n head: HTMLHeadElement,\n ) {\n const styleEl = document.createElement('style');\n documentElement!.insertBefore(styleEl, head);\n const injectStylesRules = getInjectStyleRules(\n this.config.blockClass,\n ).concat(this.config.insertStyleRules);\n if (this.config.pauseAnimation) {\n injectStylesRules.push(\n 'html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }',\n );\n }\n for (let idx = 0; idx < injectStylesRules.length; idx++) {\n (styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);\n }\n }\n\n private attachDocumentToIframe(\n mutation: addedNodeMutation,\n iframeEl: HTMLIFrameElement,\n ) {\n const collected: AppendedIframe[] = [];\n // If iframeEl is detached from dom, iframeEl.contentDocument is null.\n if (!iframeEl.contentDocument) {\n let parent = iframeEl.parentNode;\n while (parent) {\n // The parent of iframeEl is virtual parent and we need to mount it on the dom.\n if (this.fragmentParentMap.has((parent as unknown) as INode)) {\n const frag = (parent as unknown) as INode;\n const realParent = this.fragmentParentMap.get(frag)!;\n this.restoreRealParent(frag, realParent);\n break;\n }\n parent = parent.parentNode;\n }\n }\n buildNodeWithSN(mutation.node, {\n doc: iframeEl.contentDocument!,\n map: this.mirror.map,\n hackCss: true,\n skipChild: false,\n afterAppend: (builtNode) => {\n this.collectIframeAndAttachDocument(collected, builtNode);\n if (\n builtNode.__sn.type === NodeType.Element &&\n builtNode.__sn.tagName.toUpperCase() === 'HTML'\n ) {\n const { documentElement, head } = iframeEl.contentDocument!;\n this.insertStyleRules(documentElement, head);\n }\n },\n cache: this.cache,\n });\n for (const { mutationInQueue, builtNode } of collected) {\n this.attachDocumentToIframe(mutationInQueue, builtNode);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n private collectIframeAndAttachDocument(\n collected: AppendedIframe[],\n builtNode: INode,\n ) {\n if (isIframeINode(builtNode)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === builtNode.__sn.id,\n );\n if (mutationInQueue) {\n collected.push({ mutationInQueue, builtNode });\n }\n }\n }\n\n /**\n * pause when loading style sheet, resume when loaded all timeout exceed\n */\n private waitForStylesheetLoad() {\n const head = this.iframe.contentDocument?.head;\n if (head) {\n const unloadSheets: Set = new Set();\n let timer: ReturnType | -1;\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n const unsubscribe = () => {\n this.emitter.off(ReplayerEvents.Start, stateHandler);\n this.emitter.off(ReplayerEvents.Pause, stateHandler);\n };\n head\n .querySelectorAll('link[rel=\"stylesheet\"]')\n .forEach((css: HTMLLinkElement) => {\n if (!css.sheet) {\n unloadSheets.add(css);\n css.addEventListener('load', () => {\n unloadSheets.delete(css);\n // all loaded and timer not released yet\n if (unloadSheets.size === 0 && timer !== -1) {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);\n if (timer) {\n clearTimeout(timer);\n }\n unsubscribe();\n }\n });\n }\n });\n\n if (unloadSheets.size > 0) {\n // find some unload sheets after iterate\n this.service.send({ type: 'PAUSE' });\n this.emitter.emit(ReplayerEvents.LoadStylesheetStart);\n timer = setTimeout(() => {\n if (beforeLoadState.matches('playing')) {\n this.play(this.getCurrentTime());\n }\n // mark timer was called\n timer = -1;\n unsubscribe();\n }, this.config.loadTimeout);\n }\n }\n }\n\n private hasImageArg(args: any[]): boolean {\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n if (this.hasImageArg(arg.args)) return true;\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n return true; // has image!\n } else if (arg instanceof Array) {\n if (this.hasImageArg(arg)) return true;\n }\n }\n return false;\n }\n\n private getImageArgs(args: any[]): string[] {\n const images: string[] = [];\n for (const arg of args) {\n if (!arg || typeof arg !== 'object') {\n // do nothing\n } else if ('rr_type' in arg && 'args' in arg) {\n images.push(...this.getImageArgs(arg.args));\n } else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {\n images.push(arg.src);\n } else if (arg instanceof Array) {\n images.push(...this.getImageArgs(arg));\n }\n }\n return images;\n }\n\n /**\n * pause when there are some canvas drawImage args need to be loaded\n */\n private preloadAllImages() {\n let beforeLoadState = this.service.state;\n const stateHandler = () => {\n beforeLoadState = this.service.state;\n };\n this.emitter.on(ReplayerEvents.Start, stateHandler);\n this.emitter.on(ReplayerEvents.Pause, stateHandler);\n for (const event of this.service.state.context.events) {\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === IncrementalSource.CanvasMutation\n )\n if ('commands' in event.data) {\n event.data.commands.forEach((c) => this.preloadImages(c, event));\n } else {\n this.preloadImages(event.data, event);\n }\n }\n }\n\n private preloadImages(data: canvasMutationCommand, event: eventWithTime) {\n if (\n data.property === 'drawImage' &&\n typeof data.args[0] === 'string' &&\n !this.imageMap.has(event)\n ) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const imgd = ctx?.createImageData(canvas.width, canvas.height);\n let d = imgd?.data;\n d = JSON.parse(data.args[0]);\n ctx?.putImageData(imgd!, 0, 0);\n } else if (this.hasImageArg(data.args)) {\n this.getImageArgs(data.args).forEach((url) => {\n const image = new Image();\n image.src = url; // this preloads the image\n this.imageMap.set(url, image);\n });\n }\n }\n\n private applyIncremental(\n e: incrementalSnapshotEvent & { timestamp: number; delay?: number },\n isSync: boolean,\n ) {\n const { data: d } = e;\n switch (d.source) {\n case IncrementalSource.Mutation: {\n if (isSync) {\n d.adds.forEach((m) => this.treeIndex.add(m));\n d.texts.forEach((m) => {\n const target = this.mirror.getNode(m.id);\n const parent = (target?.parentNode as unknown) as INode | null;\n // remove any style rules that pending\n // for stylesheets where the contents get replaced\n if (parent && this.virtualStyleRulesMap.has(parent))\n this.virtualStyleRulesMap.delete(parent);\n\n this.treeIndex.text(m);\n });\n d.attributes.forEach((m) => this.treeIndex.attribute(m));\n d.removes.forEach((m) => this.treeIndex.remove(m, this.mirror));\n }\n try {\n this.applyMutation(d, isSync);\n } catch (error) {\n this.warn(`Exception in mutation ${error.message || error}`, d);\n }\n break;\n }\n case IncrementalSource.Drag:\n case IncrementalSource.TouchMove:\n case IncrementalSource.MouseMove:\n if (isSync) {\n const lastPosition = d.positions[d.positions.length - 1];\n this.mousePos = {\n x: lastPosition.x,\n y: lastPosition.y,\n id: lastPosition.id,\n debugData: d,\n };\n } else {\n d.positions.forEach((p) => {\n const action = {\n doAction: () => {\n this.moveAndHover(p.x, p.y, p.id, isSync, d);\n },\n delay:\n p.timeOffset +\n e.timestamp -\n this.service.state.context.baselineTime,\n };\n this.timer.addAction(action);\n });\n // add a dummy action to keep timer alive\n this.timer.addAction({\n doAction() {},\n delay: e.delay! - d.positions[0]?.timeOffset,\n });\n }\n break;\n case IncrementalSource.MouseInteraction: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n const event = new Event(MouseInteractions[d.type].toLowerCase());\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n this.emitter.emit(ReplayerEvents.MouseInteraction, {\n type: d.type,\n target,\n });\n const { triggerFocus } = this.config;\n switch (d.type) {\n case MouseInteractions.Blur:\n if ('blur' in ((target as Node) as HTMLElement)) {\n ((target as Node) as HTMLElement).blur();\n }\n break;\n case MouseInteractions.Focus:\n if (triggerFocus && ((target as Node) as HTMLElement).focus) {\n ((target as Node) as HTMLElement).focus({\n preventScroll: true,\n });\n }\n break;\n case MouseInteractions.Click:\n case MouseInteractions.TouchStart:\n case MouseInteractions.TouchEnd:\n if (isSync) {\n if (d.type === MouseInteractions.TouchStart) {\n this.touchActive = true;\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.touchActive = false;\n }\n this.mousePos = {\n x: d.x,\n y: d.y,\n id: d.id,\n debugData: d,\n };\n } else {\n if (d.type === MouseInteractions.TouchStart) {\n // don't draw a trail as user has lifted finger and is placing at a new point\n this.tailPositions.length = 0;\n }\n this.moveAndHover(d.x, d.y, d.id, isSync, d);\n if (d.type === MouseInteractions.Click) {\n /*\n * don't want target.click() here as could trigger an iframe navigation\n * instead any effects of the click should already be covered by mutations\n */\n /*\n * removal and addition of .active class (along with void line to trigger repaint)\n * triggers the 'click' css animation in styles/style.css\n */\n this.mouse.classList.remove('active');\n // tslint:disable-next-line\n void this.mouse.offsetWidth;\n this.mouse.classList.add('active');\n } else if (d.type === MouseInteractions.TouchStart) {\n void this.mouse.offsetWidth; // needed for the position update of moveAndHover to apply without the .touch-active transition\n this.mouse.classList.add('touch-active');\n } else if (d.type === MouseInteractions.TouchEnd) {\n this.mouse.classList.remove('touch-active');\n }\n }\n break;\n case MouseInteractions.TouchCancel:\n if (isSync) {\n this.touchActive = false;\n } else {\n this.mouse.classList.remove('touch-active');\n }\n break;\n default:\n target.dispatchEvent(event);\n }\n break;\n }\n case IncrementalSource.Scroll: {\n /**\n * Same as the situation of missing input target.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.scroll(d);\n break;\n }\n this.applyScroll(d, false);\n break;\n }\n case IncrementalSource.ViewportResize:\n this.emitter.emit(ReplayerEvents.Resize, {\n width: d.width,\n height: d.height,\n });\n break;\n case IncrementalSource.Input: {\n /**\n * Input event on an unserialized node usually means the event\n * was synchrony triggered programmatically after the node was\n * created. This means there was not an user observable interaction\n * and we do not need to replay it.\n */\n if (d.id === -1) {\n break;\n }\n if (isSync) {\n this.treeIndex.input(d);\n break;\n }\n this.applyInput(d);\n break;\n }\n case IncrementalSource.MediaInteraction: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n const mediaEl = (target as Node) as HTMLMediaElement;\n try {\n if (d.currentTime) {\n mediaEl.currentTime = d.currentTime;\n }\n if (d.volume) {\n mediaEl.volume = d.volume;\n }\n if (d.muted) {\n mediaEl.muted = d.muted;\n }\n if (d.type === MediaInteractions.Pause) {\n mediaEl.pause();\n }\n if (d.type === MediaInteractions.Play) {\n // remove listener for 'canplay' event because play() is async and returns a promise\n // i.e. media will evntualy start to play when data is loaded\n // 'canplay' event fires even when currentTime attribute changes which may lead to\n // unexpeted behavior\n mediaEl.play();\n }\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n `Failed to replay media interactions: ${error.message || error}`,\n );\n }\n }\n break;\n }\n case IncrementalSource.StyleSheetRule: {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n /**\n * Always use existing DOM node, when it's there.\n * In in-memory replay, there is virtual node, but it's `sheet` is inaccessible.\n * Hence, we buffer all style changes in virtualStyleRulesMap.\n */\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules;\n\n if (!styleSheet) {\n /**\n * styleEl.sheet is only accessible if the styleEl is part of the\n * dom. This doesn't work on DocumentFragments so we have to add the\n * style mutations to the virtualStyleRulesMap.\n */\n\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.adds) {\n d.adds.forEach(({ rule, index: nestedIndex }) => {\n if (styleSheet) {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet.cssRules,\n positions,\n );\n nestedRule.insertRule(rule, index);\n } else {\n const index =\n nestedIndex === undefined\n ? undefined\n : Math.min(nestedIndex, styleSheet.cssRules.length);\n styleSheet.insertRule(rule, index);\n }\n } catch (e) {\n /**\n * sometimes we may capture rules with browser prefix\n * insert rule with prefixs in other browsers may cause Error\n */\n /**\n * accessing styleSheet rules may cause SecurityError\n * for specific access control settings\n */\n }\n } else {\n rules?.push({\n cssText: rule,\n index: nestedIndex,\n type: StyleRuleType.Insert,\n });\n }\n });\n }\n\n if (d.removes) {\n d.removes.forEach(({ index: nestedIndex }) => {\n if (usingVirtualParent) {\n rules?.push({ index: nestedIndex, type: StyleRuleType.Remove });\n } else {\n try {\n if (Array.isArray(nestedIndex)) {\n const { positions, index } = getPositionsAndIndex(\n nestedIndex,\n );\n const nestedRule = getNestedRule(\n styleSheet!.cssRules,\n positions,\n );\n nestedRule.deleteRule(index || 0);\n } else {\n styleSheet?.deleteRule(nestedIndex);\n }\n } catch (e) {\n /**\n * same as insertRule\n */\n }\n }\n });\n }\n break;\n }\n case IncrementalSource.StyleDeclaration: {\n // same with StyleSheetRule\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n const styleEl = (target as Node) as HTMLStyleElement;\n const parent = (target.parentNode as unknown) as INode;\n const usingVirtualParent = this.fragmentParentMap.has(parent);\n\n const styleSheet = usingVirtualParent ? null : styleEl.sheet;\n let rules: VirtualStyleRules = [];\n\n if (!styleSheet) {\n if (this.virtualStyleRulesMap.has(target)) {\n rules = this.virtualStyleRulesMap.get(target) as VirtualStyleRules;\n } else {\n rules = [];\n this.virtualStyleRulesMap.set(target, rules);\n }\n }\n\n if (d.set) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.setProperty(d.set.property, d.set.value, d.set.priority);\n } else {\n rules.push({\n type: StyleRuleType.SetProperty,\n index: d.index,\n ...d.set,\n });\n }\n }\n\n if (d.remove) {\n if (styleSheet) {\n const rule = (getNestedRule(\n styleSheet.rules,\n d.index,\n ) as unknown) as CSSStyleRule;\n rule.style.removeProperty(d.remove.property);\n } else {\n rules.push({\n type: StyleRuleType.RemoveProperty,\n index: d.index,\n ...d.remove,\n });\n }\n }\n break;\n }\n case IncrementalSource.CanvasMutation: {\n if (!this.config.UNSAFE_replayCanvas) {\n return;\n }\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n\n canvasMutation({\n event: e,\n mutation: d,\n target: (target as unknown) as HTMLCanvasElement,\n imageMap: this.imageMap,\n errorHandler: this.warnCanvasMutationFailed.bind(this),\n });\n\n break;\n }\n case IncrementalSource.Font: {\n try {\n const fontFace = new FontFace(\n d.family,\n d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource,\n d.descriptors,\n );\n this.iframe.contentDocument?.fonts.add(fontFace);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(error);\n }\n }\n break;\n }\n default:\n }\n }\n\n private applyMutation(d: mutationData, useVirtualParent: boolean) {\n d.removes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.parentId)) {\n // no need to warn, parent was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.virtualStyleRulesMap.has(target)) {\n this.virtualStyleRulesMap.delete(target);\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n return this.warnNodeNotFound(d, mutation.parentId);\n }\n if (mutation.isShadow && hasShadowRoot(parent)) {\n parent = parent.shadowRoot;\n }\n // target may be removed with its parents before\n this.mirror.removeNodeFromMap(target);\n if (parent) {\n let realTarget = null;\n const realParent =\n '__sn' in parent ? this.fragmentParentMap.get(parent) : undefined;\n if (realParent && realParent.contains(target)) {\n parent = realParent;\n } else if (this.fragmentParentMap.has(target)) {\n /**\n * the target itself is a fragment document and it's not in the dom\n * so we should remove the real target from its parent\n */\n realTarget = this.fragmentParentMap.get(target)!;\n this.fragmentParentMap.delete(target);\n target = realTarget;\n }\n try {\n parent.removeChild(target);\n } catch (error) {\n if (error instanceof DOMException) {\n this.warn(\n 'parent could not remove child in mutation',\n parent,\n realParent,\n target,\n realTarget,\n d,\n );\n } else {\n throw error;\n }\n }\n }\n });\n\n // tslint:disable-next-line: variable-name\n const legacy_missingNodeMap: missingNodeMap = {\n ...this.legacy_missingNodeRetryMap,\n };\n const queue: addedNodeMutation[] = [];\n\n // next not present at this moment\n const nextNotInDOM = (mutation: addedNodeMutation) => {\n let next: Node | null = null;\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n // next not present at this moment\n if (\n mutation.nextId !== null &&\n mutation.nextId !== undefined &&\n mutation.nextId !== -1 &&\n !next\n ) {\n return true;\n }\n return false;\n };\n\n const appendNode = (mutation: addedNodeMutation) => {\n if (!this.iframe.contentDocument) {\n return console.warn('Looks like your replayer has been destroyed.');\n }\n let parent: INode | null | ShadowRoot = this.mirror.getNode(\n mutation.parentId,\n );\n if (!parent) {\n if (mutation.node.type === NodeType.Document) {\n // is newly added document, maybe the document node of an iframe\n return this.newDocumentQueue.push(mutation);\n }\n return queue.push(mutation);\n }\n\n let parentInDocument = null;\n if (this.iframe.contentDocument.contains) {\n parentInDocument = this.iframe.contentDocument.contains(parent);\n } else if (this.iframe.contentDocument.body.contains) {\n // fix for IE\n // refer 'Internet Explorer notes' at https://developer.mozilla.org/zh-CN/docs/Web/API/Document\n parentInDocument = this.iframe.contentDocument.body.contains(parent);\n }\n\n const hasIframeChild =\n ((parent as unknown) as HTMLElement).getElementsByTagName?.('iframe')\n .length > 0;\n /**\n * Why !isIframeINode(parent)? If parent element is an iframe, iframe document can't be appended to virtual parent.\n * Why !hasIframeChild? If we move iframe elements from dom to fragment document, we will lose the contentDocument of iframe. So we need to disable the virtual dom optimization if a parent node contains iframe elements.\n */\n if (\n useVirtualParent &&\n parentInDocument &&\n !isIframeINode(parent) &&\n !hasIframeChild\n ) {\n const virtualParent = (document.createDocumentFragment() as unknown) as INode;\n this.mirror.map[mutation.parentId] = virtualParent;\n this.fragmentParentMap.set(virtualParent, parent);\n\n // store the state, like scroll position, of child nodes before they are unmounted from dom\n this.storeState(parent);\n\n while (parent.firstChild) {\n virtualParent.appendChild(parent.firstChild);\n }\n parent = virtualParent;\n }\n\n if (mutation.node.isShadow) {\n // If the parent is attached a shadow dom after it's created, it won't have a shadow root.\n if (!hasShadowRoot(parent)) {\n ((parent as Node) as HTMLElement).attachShadow({ mode: 'open' });\n parent = ((parent as Node) as HTMLElement).shadowRoot!;\n } else parent = parent.shadowRoot;\n }\n\n let previous: Node | null = null;\n let next: Node | null = null;\n if (mutation.previousId) {\n previous = this.mirror.getNode(mutation.previousId) as Node;\n }\n if (mutation.nextId) {\n next = this.mirror.getNode(mutation.nextId) as Node;\n }\n if (nextNotInDOM(mutation)) {\n return queue.push(mutation);\n }\n\n if (mutation.node.rootId && !this.mirror.getNode(mutation.node.rootId)) {\n return;\n }\n\n const targetDoc = mutation.node.rootId\n ? this.mirror.getNode(mutation.node.rootId)\n : this.iframe.contentDocument;\n if (isIframeINode(parent)) {\n this.attachDocumentToIframe(mutation, parent);\n return;\n }\n const target = buildNodeWithSN(mutation.node, {\n doc: targetDoc as Document,\n map: this.mirror.map,\n skipChild: true,\n hackCss: true,\n cache: this.cache,\n }) as INode;\n\n // legacy data, we should not have -1 siblings any more\n if (mutation.previousId === -1 || mutation.nextId === -1) {\n legacy_missingNodeMap[mutation.node.id] = {\n node: target,\n mutation,\n };\n return;\n }\n\n if (\n '__sn' in parent &&\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n mutation.node.type === NodeType.Text\n ) {\n // https://github.com/rrweb-io/rrweb/issues/745\n // parent is textarea, will only keep one child node as the value\n for (const c of Array.from(parent.childNodes)) {\n if (c.nodeType === parent.TEXT_NODE) {\n parent.removeChild(c);\n }\n }\n }\n\n if (previous && previous.nextSibling && previous.nextSibling.parentNode) {\n parent.insertBefore(target, previous.nextSibling);\n } else if (next && next.parentNode) {\n // making sure the parent contains the reference nodes\n // before we insert target before next.\n parent.contains(next)\n ? parent.insertBefore(target, next)\n : parent.insertBefore(target, null);\n } else {\n /**\n * Sometimes the document changes and the MutationObserver is disconnected, so the removal of child elements can't be detected and recorded. After the change of document, we may get another mutation which adds a new html element, while the old html element still exists in the dom, and we need to remove the old html element first to avoid collision.\n */\n if (parent === targetDoc) {\n while (targetDoc.firstChild) {\n targetDoc.removeChild(targetDoc.firstChild);\n }\n }\n\n parent.appendChild(target);\n }\n\n if (isIframeINode(target)) {\n const mutationInQueue = this.newDocumentQueue.find(\n (m) => m.parentId === target.__sn.id,\n );\n if (mutationInQueue) {\n this.attachDocumentToIframe(mutationInQueue, target);\n this.newDocumentQueue = this.newDocumentQueue.filter(\n (m) => m !== mutationInQueue,\n );\n }\n }\n\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(\n legacy_missingNodeMap,\n parent,\n target,\n mutation,\n );\n }\n };\n\n d.adds.forEach((mutation) => {\n appendNode(mutation);\n });\n\n let startTime = Date.now();\n while (queue.length) {\n // transform queue to resolve tree\n const resolveTrees = queueToResolveTrees(queue);\n queue.length = 0;\n if (Date.now() - startTime > 500) {\n this.warn(\n 'Timeout in the loop, please check the resolve tree data:',\n resolveTrees,\n );\n break;\n }\n for (const tree of resolveTrees) {\n let parent = this.mirror.getNode(tree.value.parentId);\n if (!parent) {\n this.debug(\n 'Drop resolve tree since there is no parent for the root node.',\n tree,\n );\n } else {\n iterateResolveTree(tree, (mutation) => {\n appendNode(mutation);\n });\n }\n }\n }\n\n if (Object.keys(legacy_missingNodeMap).length) {\n Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);\n }\n\n d.texts.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n /**\n * apply text content to real parent directly\n */\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n target.textContent = mutation.value;\n });\n d.attributes.forEach((mutation) => {\n let target = this.mirror.getNode(mutation.id);\n if (!target) {\n if (d.removes.find((r) => r.id === mutation.id)) {\n // no need to warn, element was already removed\n return;\n }\n return this.warnNodeNotFound(d, mutation.id);\n }\n if (this.fragmentParentMap.has(target)) {\n target = this.fragmentParentMap.get(target)!;\n }\n for (const attributeName in mutation.attributes) {\n if (typeof attributeName === 'string') {\n const value = mutation.attributes[attributeName];\n if (value === null) {\n ((target as Node) as Element).removeAttribute(attributeName);\n } else if (typeof value === 'string') {\n try {\n ((target as Node) as Element).setAttribute(attributeName, value);\n } catch (error) {\n if (this.config.showWarning) {\n console.warn(\n 'An error occurred may due to the checkout feature.',\n error,\n );\n }\n }\n } else if (attributeName === 'style') {\n let styleValues = value as styleAttributeValue;\n const targetEl = (target as Node) as HTMLElement;\n for (var s in styleValues) {\n if (styleValues[s] === false) {\n targetEl.style.removeProperty(s);\n } else if (styleValues[s] instanceof Array) {\n const svp = styleValues[s] as styleValueWithPriority;\n targetEl.style.setProperty(s, svp[0], svp[1]);\n } else {\n const svs = styleValues[s] as string;\n targetEl.style.setProperty(s, svs);\n }\n }\n }\n }\n }\n });\n }\n\n /**\n * Apply the scroll data on real elements.\n * If the replayer is in sync mode, smooth scroll behavior should be disabled.\n * @param d the scroll data\n * @param isSync whether the replayer is in sync mode(fast-forward)\n */\n private applyScroll(d: scrollData, isSync: boolean) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n if ((target as Node) === this.iframe.contentDocument) {\n this.iframe.contentWindow!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else if (target.__sn.type === NodeType.Document) {\n // nest iframe content document\n ((target as unknown) as Document).defaultView!.scrollTo({\n top: d.y,\n left: d.x,\n behavior: isSync ? 'auto' : 'smooth',\n });\n } else {\n try {\n ((target as Node) as Element).scrollTop = d.y;\n ((target as Node) as Element).scrollLeft = d.x;\n } catch (error) {\n /**\n * Seldomly we may found scroll target was removed before\n * its last scroll event.\n */\n }\n }\n }\n\n private applyInput(d: inputData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(d, d.id);\n }\n try {\n ((target as Node) as HTMLInputElement).checked = d.isChecked;\n ((target as Node) as HTMLInputElement).value = d.text;\n } catch (error) {\n // for safe\n }\n }\n\n private applyText(d: textMutation, mutation: mutationData) {\n const target = this.mirror.getNode(d.id);\n if (!target) {\n return this.debugNodeNotFound(mutation, d.id);\n }\n try {\n ((target as Node) as HTMLElement).textContent = d.value;\n } catch (error) {\n // for safe\n }\n }\n\n private legacy_resolveMissingNode(\n map: missingNodeMap,\n parent: Node,\n target: Node,\n targetMutation: addedNodeMutation,\n ) {\n const { previousId, nextId } = targetMutation;\n const previousInMap = previousId && map[previousId];\n const nextInMap = nextId && map[nextId];\n if (previousInMap) {\n const { node, mutation } = previousInMap as missingNode;\n parent.insertBefore(node, target);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n if (nextInMap) {\n const { node, mutation } = nextInMap as missingNode;\n parent.insertBefore(node, target.nextSibling);\n delete map[mutation.node.id];\n delete this.legacy_missingNodeRetryMap[mutation.node.id];\n if (mutation.previousId || mutation.nextId) {\n this.legacy_resolveMissingNode(map, parent, node as Node, mutation);\n }\n }\n }\n\n private moveAndHover(\n x: number,\n y: number,\n id: number,\n isSync: boolean,\n debugData: incrementalData,\n ) {\n const target = this.mirror.getNode(id);\n if (!target) {\n return this.debugNodeNotFound(debugData, id);\n }\n\n const base = getBaseDimension(target, this.iframe);\n const _x = x * base.absoluteScale + base.x;\n const _y = y * base.absoluteScale + base.y;\n\n this.mouse.style.left = `${_x}px`;\n this.mouse.style.top = `${_y}px`;\n if (!isSync) {\n this.drawMouseTail({ x: _x, y: _y });\n }\n this.hoverElements((target as Node) as Element);\n }\n\n private drawMouseTail(position: { x: number; y: number }) {\n if (!this.mouseTail) {\n return;\n }\n\n const { lineCap, lineWidth, strokeStyle, duration } =\n this.config.mouseTail === true\n ? defaultMouseTailConfig\n : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);\n\n const draw = () => {\n if (!this.mouseTail) {\n return;\n }\n const ctx = this.mouseTail.getContext('2d');\n if (!ctx || !this.tailPositions.length) {\n return;\n }\n ctx.clearRect(0, 0, this.mouseTail.width, this.mouseTail.height);\n ctx.beginPath();\n ctx.lineWidth = lineWidth;\n ctx.lineCap = lineCap;\n ctx.strokeStyle = strokeStyle;\n ctx.moveTo(this.tailPositions[0].x, this.tailPositions[0].y);\n this.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));\n ctx.stroke();\n };\n\n this.tailPositions.push(position);\n draw();\n setTimeout(() => {\n this.tailPositions = this.tailPositions.filter((p) => p !== position);\n draw();\n }, duration / this.speedService.state.context.timer.speed);\n }\n\n private hoverElements(el: Element) {\n this.iframe.contentDocument\n ?.querySelectorAll('.\\\\:hover')\n .forEach((hoveredEl) => {\n hoveredEl.classList.remove(':hover');\n });\n let currentEl: Element | null = el;\n while (currentEl) {\n if (currentEl.classList) {\n currentEl.classList.add(':hover');\n }\n currentEl = currentEl.parentElement;\n }\n }\n\n private isUserInteraction(event: eventWithTime): boolean {\n if (event.type !== EventType.IncrementalSnapshot) {\n return false;\n }\n return (\n event.data.source > IncrementalSource.Mutation &&\n event.data.source <= IncrementalSource.Input\n );\n }\n\n private backToNormal() {\n this.nextUserInteractionEvent = null;\n if (this.speedService.state.matches('normal')) {\n return;\n }\n this.speedService.send({ type: 'BACK_TO_NORMAL' });\n this.emitter.emit(ReplayerEvents.SkipEnd, {\n speed: this.speedService.state.context.normalSpeed,\n });\n }\n\n /**\n * Replace the virtual parent with the real parent.\n * @param frag fragment document, the virtual parent\n * @param parent real parent element\n */\n private restoreRealParent(frag: INode, parent: INode) {\n this.mirror.map[parent.__sn.id] = parent;\n /**\n * If we have already set value attribute on textarea,\n * then we could not apply text content as default value any more.\n */\n if (\n parent.__sn.type === NodeType.Element &&\n parent.__sn.tagName === 'textarea' &&\n frag.textContent\n ) {\n ((parent as unknown) as HTMLTextAreaElement).value = frag.textContent;\n }\n parent.appendChild(frag);\n // restore state of elements after they are mounted\n this.restoreState(parent);\n }\n\n /**\n * store state of elements before unmounted from dom recursively\n * the state should be restored in the handler of event ReplayerEvents.Flush\n * e.g. browser would lose scroll position after the process that we add children of parent node to Fragment Document as virtual dom\n */\n private storeState(parent: INode) {\n if (parent) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (parentElement.scrollLeft || parentElement.scrollTop) {\n // store scroll position state\n this.elementStateMap.set(parent, {\n scroll: [parentElement.scrollLeft, parentElement.scrollTop],\n });\n }\n if (parentElement.tagName === 'STYLE')\n storeCSSRules(\n parentElement as HTMLStyleElement,\n this.virtualStyleRulesMap,\n );\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.storeState((child as unknown) as INode);\n }\n }\n }\n }\n\n /**\n * restore the state of elements recursively, which was stored before elements were unmounted from dom in virtual parent mode\n * this function corresponds to function storeState\n */\n private restoreState(parent: INode) {\n if (parent.nodeType === parent.ELEMENT_NODE) {\n const parentElement = (parent as unknown) as HTMLElement;\n if (this.elementStateMap.has(parent)) {\n const storedState = this.elementStateMap.get(parent)!;\n // restore scroll position\n if (storedState.scroll) {\n parentElement.scrollLeft = storedState.scroll[0];\n parentElement.scrollTop = storedState.scroll[1];\n }\n this.elementStateMap.delete(parent);\n }\n const children = parentElement.children;\n for (const child of Array.from(children)) {\n this.restoreState((child as unknown) as INode);\n }\n }\n }\n\n private restoreNodeSheet(node: INode) {\n const storedRules = this.virtualStyleRulesMap.get(node);\n if (node.nodeName !== 'STYLE') {\n return;\n }\n\n if (!storedRules) {\n return;\n }\n\n const styleNode = (node as unknown) as HTMLStyleElement;\n\n applyVirtualStyleRulesToNode(storedRules, styleNode);\n }\n\n private warnNodeNotFound(d: incrementalData, id: number) {\n if (this.treeIndex.idRemoved(id)) {\n this.warn(`Node with id '${id}' was previously removed. `, d);\n } else {\n this.warn(`Node with id '${id}' not found. `, d);\n }\n }\n\n private warnCanvasMutationFailed(\n d: canvasMutationData | canvasMutationCommand,\n error: unknown,\n ) {\n this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);\n }\n\n private debugNodeNotFound(d: incrementalData, id: number) {\n /**\n * There maybe some valid scenes of node not being found.\n * Because DOM events are macrotask and MutationObserver callback\n * is microtask, so events fired on a removed DOM may emit\n * snapshots in the reverse order.\n */\n if (this.treeIndex.idRemoved(id)) {\n this.debug(\n REPLAY_CONSOLE_PREFIX,\n `Node with id '${id}' was previously removed. `,\n d,\n );\n } else {\n this.debug(REPLAY_CONSOLE_PREFIX, `Node with id '${id}' not found. `, d);\n }\n }\n\n private warn(...args: Parameters) {\n if (!this.config.showWarning) {\n return;\n }\n console.warn(REPLAY_CONSOLE_PREFIX, ...args);\n }\n\n private debug(...args: Parameters) {\n if (!this.config.showDebug) {\n return;\n }\n // tslint:disable-next-line: no-console\n console.log(REPLAY_CONSOLE_PREFIX, ...args);\n }\n}\n","import { Replayer } from '..';\nimport {\n CanvasContext,\n canvasMutationCommand,\n canvasMutationData,\n} from '../../types';\nimport webglMutation from './webgl';\nimport canvas2DMutation from './2d';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationData;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const mutations: canvasMutationCommand[] =\n 'commands' in mutation ? mutation.commands : [mutation];\n\n if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {\n return mutations.forEach((command) => {\n webglMutation({\n mutation: command,\n type: mutation.type,\n target,\n imageMap,\n errorHandler,\n });\n });\n }\n // default is '2d' for backwards compatibility (rrweb below 1.1.x)\n return mutations.forEach((command) => {\n canvas2DMutation({\n event,\n mutation: command,\n target,\n imageMap,\n errorHandler,\n });\n });\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import { Replayer } from '../';\nimport { canvasMutationCommand } from '../../types';\n\nexport default function canvasMutation({\n event,\n mutation,\n target,\n imageMap,\n errorHandler,\n}: {\n event: Parameters[0];\n mutation: canvasMutationCommand;\n target: HTMLCanvasElement;\n imageMap: Replayer['imageMap'];\n errorHandler: Replayer['warnCanvasMutationFailed'];\n}): void {\n try {\n const ctx = ((target as unknown) as HTMLCanvasElement).getContext('2d')!;\n\n if (mutation.setter) {\n // skip some read-only type checks\n // tslint:disable-next-line:no-any\n (ctx as any)[mutation.property] = mutation.args[0];\n return;\n }\n const original = ctx[\n mutation.property as Exclude\n ] as Function;\n\n /**\n * We have serialized the image source into base64 string during recording,\n * which has been preloaded before replay.\n * So we can get call drawImage SYNCHRONOUSLY which avoid some fragile cast.\n */\n if (\n mutation.property === 'drawImage' &&\n typeof mutation.args[0] === 'string'\n ) {\n const image = imageMap.get(event);\n mutation.args[0] = image;\n original.apply(ctx, mutation.args);\n } else {\n original.apply(ctx, mutation.args);\n }\n } catch (error) {\n errorHandler(mutation, error);\n }\n}\n","import record from './record';\nimport { Replayer } from './replay';\nimport { _mirror } from './utils';\nimport * as utils from './utils';\n\nexport {\n EventType,\n IncrementalSource,\n MouseInteractions,\n ReplayerEvents,\n} from './types';\n\nconst { addCustomEvent } = record;\nconst { freezePage } = record;\n\nexport {\n record,\n addCustomEvent,\n freezePage,\n Replayer,\n _mirror as mirror,\n utils,\n};\n"],"names":["NodeType","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__values","o","Symbol","iterator","m","next","value","done","TypeError","__read","r","e","ar","push","error","__spreadArray","to","from","pack","l","Array","slice","concat","isElement","nodeType","ELEMENT_NODE","isShadowRoot","_a","host","Boolean","shadowRoot","maskInputValue","input","maskInputSelector","unmaskInputSelector","maskInputOptions","tagName","type","maskInputFn","text","matches","toLowerCase","repeat","ORIGINAL_ATTRIBUTE_NAME","canvasService","canvasCtx","_id","tagNameRegex","RegExp","getCssRulesString","rules","cssRules","map","getCssRuleString","join","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","stack","parts","pop","_i","parts_1","part","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","unmaskTextSelector","closest","classList","contains","eIndex","className","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","unblockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","Math","min","data","buffer","some","pixel","is2DCanvasBlank","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","_l","_m","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","commentre","parse","css","lineno","column","updatePosition","str","lines","lastIndexOf","position","start","line","Position","whitespace","end","source","content","errorsList","msg","Error","reason","filename","silent","open","close","comments","atrule","re","selector","declaration","propMatch","prop","val","ret","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","vendor","frame","frames","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","atdocument","sel","selectors","atpage","athost","atfontface","addParent","parsingErrors","obj","parent","isNode","childParent","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","EventType","IncrementalSource","MouseInteractions","CanvasContext","MediaInteractions","ReplayerEvents","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cache","cachedStyle","stylesWithHoverClass","get","ast","selectorMatcher","filter","index","sort","b","result","newSelector","set","createCache","Map","buildNode","hackCss","implementation","createDocument","createDocumentType","node_1","getTagName","createElementNS","_loop_1","startsWith","image","setAttribute","play","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","removeChild","appendChild","setAttributeNS","srcset","firstChild","attachShadow","mode","createCDATASection","createComment","buildNodeWithSN","afterAppend","assert","xmlns","write","childN","childNode","rebuild","onVisit","idNodeMap","key","visit","visitedNode","name_2","handleScroll","on","fn","target","capture","passive","removeEventListener","createMirror","getId","getNode","removeNodeFromMap","_this","has","reset","DEPARTED_MIRROR_ACCESS_WARNING","throttle","func","wait","timeout","previous","arg","now","Date","leading","remaining","context","args","trailing","hookSetter","d","isRevoked","original","getOwnPropertyDescriptor","patch","replacement","original_1","wrapped","defineProperties","__rrweb_original__","getWindowHeight","window","innerHeight","documentElement","clientHeight","body","getWindowWidth","innerWidth","clientWidth","isBlocked","needBlock_1","isIgnored","isAncestorRemoved","mirror","isTouchEvent","event","changedTouches","polyfill","NodeList","DOMTokenList","Node","Proxy","Reflect","_mirror","receiver","TreeIndex","mutation","parentTreeNode","indexes","parentId","treeNode","children","texts","tree","deepRemoveFromMirror","removeIdSet","add","deepRemoveFromTreeIndex","_treeNode","_parentTreeNode","delete","removeNodeMutations","textMutations","attributeMutations","scrollMap","inputMap","batchMutationData","Mutation","removes","adds","walk","removed","mutationData","Set","queueToResolveTrees","queue","queueNodeMap","putIntoMap","nodeInTree","queueNodeTrees","queue_1","nextId","nextInTree","idx","splice","parentInTree","iterateResolveTree","cb","isIframeINode","getBaseDimension","rootIframe","frameElement","ownerDocument","defaultView","relativeScale","absoluteScale","frameDimension","frameBaseDimension","hasShadowRoot","isNodeInLinkedList","DoubleLinkedList","current","head","__ln","moveKey","isINode","mutations","processMutation","emit","frozen","locked","addList","getNextId","ns","pushAdd","shadowHost","getRootNode","rootShadowHost","notInDoc","addNode","currentN","iframeManager","addIframe","shadowDomManager","addShadowRoot","iframe","childSn","attachIframe","observeAttachShadow","mapRemoves","shift","movedSet","isParentRemoved","addedSet","isAncestorInSet","droppedSet","candidate","_node","removeNode","payload","attribute","movedMap","mutationCb","oldValue","getAttribute","attributeName","item","old","styleObj","pname","newValue","getPropertyValue","newPriority","getPropertyPriority","addedNodes","genAdds","removedNodes","nodeId","deepDelete","targetId","MutationBuffer","canvasManager","freeze","unfreeze","lock","unlock","addsSet","mutationBuffers","isCSSGroupingRuleSupported","CSSGroupingRule","isCSSMediaRuleSupported","CSSMediaRule","isCSSSupportsRuleSupported","CSSSupportsRule","isCSSConditionRuleSupported","CSSConditionRule","getEventTarget","path","composedPath","initMutationObserver","rootEl","mutationBuffer","init","mutationObserverCtor","MutationObserver","__rrMutationObserver","angularZoneSymbol","Zone","__symbol__","observer","processMutations","bind","observe","attributeOldValue","characterData","characterDataOldValue","childList","subtree","initMouseInteractionObserver","mouseInteractionCb","sampling","mouseInteraction","disableMap","handlers","Number","isNaN","eventKey","eventName","handler","clientX","clientY","getHandler","h","initScrollObserver","scrollCb","evt","scrollEl","scrollingElement","scroll","wrapEventWithUserTriggeredFlag","enable","userTriggered","INPUT_TAGS","lastInputValueMap","WeakMap","getNestedCSSRulePositions","childRule","parentRule","unshift","parentStyleSheet","recurse","initObservers","hooks","currentWindow","mousemoveCb","viewportResizeCb","inputCb","mediaInteractionCb","styleSheetRuleCb","styleDeclarationCb","canvasMutationCb","fontCb","mousemove","viewportResize","mediaInteaction","styleSheetRule","styleDeclaration","canvasMutation","font","mergeHooks","mutationObserver","mousemoveHandler","timeBaseline","threshold","callbackThreshold","mousemoveCallback","positions","wrappedCb","totalOffset","timeOffset","DragEvent","Drag","MouseEvent","MouseMove","TouchMove","initMoveObserver","mouseInteractionHandler","scrollHandler","viewportResizeHandler","lastH","lastW","initViewportResizeObserver","inputHandler","ignoreClass","ignoreSelector","userTriggeredOnInput","eventHandler","isTrusted","parentElement","isChecked","cbWithDedup","querySelectorAll","lastInputValue","propertyDescriptor","HTMLInputElement","hookProperties","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement","initInputObserver","mediaInteractionHandler","volume","muted","initMediaInteractionObserver","styleSheetObserver","CSSStyleSheet","insertRule","ownerNode","deleteRule","supportedNestedCSSRuleTypes","unmodifiedFunctions","entries","typeKey","initStyleSheetObserver","styleDeclarationObserver","setProperty","CSSStyleDeclaration","priority","removeProperty","remove","initStyleDeclarationObserver","fontObserver","collectFonts","fontMap","originalFontFace","FontFace","family","descriptors","fontFace","fontSource","JSON","stringify","Uint8Array","restoreHandler","fonts","initFontObserver","pluginHandlers","plugins","plugin","callback","disconnect","IframeManager","iframes","loadListener","isAttachIframe","manager","restorePatches","HTMLElement","ShadowDomManager","iframeElement","manager_1","restorePatch","lookup","charCodeAt","webGLVarMap","saveWebGLVar","isInstanceOfWebGLObject","list","ctor","contextMap","variableListFor","constructor","serializeArg","Float32Array","Float64Array","Int32Array","Uint16Array","Int16Array","Int8Array","Uint8ClampedArray","rr_type","ArrayBuffer","base64","arraybuffer","bytes","len","encode","DataView","byteOffset","byteLength","HTMLImageElement","ImageData","serializeArgs","supportedWebGLConstructorNames","patchGLPrototype","props","getOwnPropertyNames","recordArgs","hookHandler","setter","props_1","wrappedEmit","takeFullSnapshot","latestId","invokeId","rafStamps","pendingCanvasMutations","initCanvasMutationObserver","CanvasManager","clear","resetObservers","startRAFTimestamping","startPendingCanvasMutationFlusher","canvasContextReset","HTMLCanvasElement","contextType","initCanvasContextObserver","canvas2DReset","props2D","CanvasRenderingContext2D","imgd","pix","props2D_1","initCanvas2DMutationObserver","canvasWebGL1and2Reset","WebGLRenderingContext","WebGL","WebGL2RenderingContext","WebGL2","initCanvasWebGLMutationObserver","requestAnimationFrame","flushPendingCanvasMutations","setLatestRAFTimestamp","timestamp","flushPendingCanvasMutationFor","valuesWithType","getOwnPropertySymbols","propertyIsEnumerable","commands","wrapEvent","record","checkoutEveryNms","checkoutEveryNth","maskAllInputs","_maskInputOptions","_slimDOMOptions","packFn","mousemoveWait","_o","_p","_q","_r","_s","lastFullSnapshotEvent","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","incrementalSnapshotCount","isCheckout","isFrozen","FullSnapshot","IncrementalSnapshot","buf","eventProcessor","exceedCount","exceedTime","wrappedMutationEmit","wrappedScrollEmit","Scroll","wrappedCanvasMutationEmit","CanvasMutation","Meta","slimDOM","snapshot","initialOffset","left","pageXOffset","top","pageYOffset","handlers_1","DomContentLoaded","observe_1","MouseInteraction","ViewportResize","Input","MediaInteraction","StyleSheetRule","StyleDeclaration","Font","Plugin","addLoadListener","init_1","Load","mitt","all","create","off","addCustomEvent","tag","Custom","freezePage","w","__forceSmoothScrollPolyfill__","userAgent","scrollTo","scrollBy","elementScroll","scrollElement","scrollIntoView","performance","ROUNDING_TOLERANCE","navigator","shouldBailOut","smoothScroll","scrollX","scrollY","SyntaxError","behavior","scrollableParent","findScrollableParent","parentRects","clientRects","getComputedStyle","firstArg","hasScrollableSpace","axis","scrollHeight","scrollWidth","canOverflow","overflowValue","isScrollable","isScrollableY","isScrollableX","step","currentX","currentY","k","elapsed","startTime","cos","PI","startX","startY","method","scrollable","actions","speed","Timer","action","findActionIndex","lastTimestamp","self","raf","check","delay","doAction","liveMode","cancelAnimationFrame","mid","floor","addDelay","baselineTime","firstOffset","firstTimestamp","return","NotStarted","Running","Stopped","assignment","u","changed","f","states","initial","entry","config","_options","initialState","transition","g","S","j","E","R","N","cond","O","_","T","q","exit","z","A","B","C","_machine","send","subscribe","unsubscribe","stop","state","status","createPlayerService","getCastFn","applyEventsSynchronously","emitter","interpret","createMachine","playing","PAUSE","CAST_EVENT","END","ADD_EVENT","PLAY","TO_LIVE","live","castEvent","lastPlayedEvent","recordTimeOffset","events","timer","events_1","neededEvents","event_1","discardPriorSnapshots","lastPlayedTimestamp","PlayBack","syncEvents","event_3","castFn_1","neededEvents_1","Flush","addActions","resetLastPlayedEvent","startLive","toggleLiveMode","addEvent","machineEvent","event_4","insertionIndex","isSync","castFn_2","isActive","addAction","StyleRuleType","getNestedRule","getPositionsAndIndex","nestedIndex","applyVirtualStyleRulesToNode","storedRules","styleNode","Insert","Remove","Snapshot","cssTexts","existingRules","existingRulesReversed","reverse","lastMatch_1","restoreSnapshotOfStyleRulesToNode","SetProperty","RemoveProperty","WebGLVariableConstructorsNames","deserializeArg","imageMap","encoded1","encoded2","encoded3","encoded4","bufferLength","decode","Image","webglMutation","errorHandler","includes","variables","saveToWebGLVarMap","mittProxy.default","mittProxy","REPLAY_CONSOLE_PREFIX","defaultMouseTailConfig","duration","lineCap","lineWidth","strokeStyle","indicatesTouchDevice","TouchStart","defaultConfig","maxSpeed","root","loadTimeout","skipInactive","showWarning","showDebug","insertStyleRules","triggerFocus","UNSAFE_replayCanvas","pauseAnimation","mouseTail","handleResize","Resize","setupDom","treeIndex","fragmentParentMap","elementStateMap","virtualStyleRulesMap","flush","frag","restoreRealParent","applyText","restoreNodeSheet","applyScroll","applyInput","firstFullSnapshot","service","unpackFn","a1","a2","StateChange","player","speedService","normalSpeed","normal","FAST_FORWARD","SET_SPEED","skipping","BACK_TO_NORMAL","setSpeed","recordSpeed","restoreSpeed","firstMeta","firstFullsnapshot","width_1","height_1","rebuildFullSnapshot","mouse","Replayer","backToNormal","display","parseFloat","wrapper","insertBefore","firstEvent","lastEvent","endTime","totalTime","getTimeOffset","getElementsByTagName","Start","Pause","Resume","rawEvent","Promise","resolve","then","pointerEvents","disableInteract","smoothscrollPolyfill","dimension","String","castFn","mousePos","moveAndHover","debugData","touchActive","CustomEvent","applyIncremental","nextUserInteractionEvent","_event","isUserInteraction","skipTime","round","SkipStart","replayer","last_index","finish_1","Finish","max","EventCast","legacy_missingNodeRetryMap","collected","builtNode","collectIframeAndAttachDocument","mutationInQueue","this_1","attachDocumentToIframe","newDocumentQueue","collected_1","FullsnapshotRebuilded","waitForStylesheetLoad","preloadAllImages","styleEl","injectStylesRules","parent_1","realParent","toUpperCase","this_2","collected_2","unloadSheets_1","beforeLoadState_1","stateHandler_1","unsubscribe_1","size","getCurrentTime","LoadStylesheetEnd","LoadStylesheetStart","args_1","hasImageArg","images","args_2","getImageArgs","stateHandler","event_2","preloadImages","this_3","createImageData","putImageData","applyMutation","message","lastPosition","Event","debugNodeNotFound","Blur","blur","Focus","focus","preventScroll","Click","TouchEnd","tailPositions","offsetWidth","TouchCancel","dispatchEvent","mediaEl","rules_1","parent_2","usingVirtualParent_1","styleSheet_1","parent_3","command","canvas2DMutation","warnCanvasMutationFailed","useVirtualParent","warnNodeNotFound","realTarget","DOMException","legacy_missingNodeMap","appendNode","parentInDocument","hasIframeChild","virtualParent","createDocumentFragment","storeState","previousId","nextNotInDOM","targetDoc","mutationInQueue_1","legacy_resolveMissingNode","resolveTrees","resolveTrees_1","debug","removeAttribute","styleValues","targetEl","svp","svs","targetMutation","previousInMap","nextInMap","base","_x","_y","drawMouseTail","hoverElements","draw","clearRect","beginPath","moveTo","lineTo","stroke","hoveredEl","currentEl","SkipEnd","restoreState","storeCSSRules","storedState","nodeName","idRemoved","log"],"mappings":";;;;;;;;;;;;;;oFA+BO,IC/BHA,ED+BOC,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,YAgFzB,SAASQ,EAASC,GACrB,IAAIZ,EAAsB,mBAAXa,QAAyBA,OAAOC,SAAUC,EAAIf,GAAKY,EAAEZ,GAAIC,EAAI,EAC5E,GAAIc,EAAG,OAAOA,EAAEP,KAAKI,GACrB,GAAIA,GAAyB,iBAAbA,EAAER,OAAqB,MAAO,CAC1CY,KAAM,WAEF,OADIJ,GAAKX,GAAKW,EAAER,SAAQQ,OAAI,GACrB,CAAEK,MAAOL,GAAKA,EAAEX,KAAMiB,MAAON,KAG5C,MAAM,I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H,KAAKqgB,kCAAW,CAArC,IAAM/F,UACTxb,KAAK60C,aAAcr5B,wGAKjBkwB,6BAAR,SAAyB3kC,GACvB,IAAMo/B,EAAcnmC,KAAK2pC,qBAAqB/vB,IAAI7S,GAC5B,UAAlBA,EAAKiuC,WAIJ7O,GAMLD,GAA6BC,EAFVp/B,KAKb2kC,6BAAR,SAAyB5sB,EAAoBlW,GACvC5I,KAAKwpC,UAAUyL,UAAUrsC,GAC3B5I,KAAK0M,KAAK,wBAAiB9D,gCAAgCkW,GAE3D9e,KAAK0M,KAAK,wBAAiB9D,mBAAmBkW,IAI1C4sB,qCAAR,SACE5sB,EACA/d,GAEAf,KAAK0M,KAAK,6BAA8B3L,EAAO,mBAAoB+d,IAG7D4sB,8BAAR,SAA0B5sB,EAAoBlW,GAOxC5I,KAAKwpC,UAAUyL,UAAUrsC,GAC3B5I,KAAKszC,MACHrL,GACA,wBAAiBr/B,gCACjBkW,GAGF9e,KAAKszC,MAAMrL,GAAuB,wBAAiBr/B,mBAAmBkW,IAIlE4sB,iBAAR,eAAa,aAAAxmC,mBAAAA,IAAAyZ,kBACN3e,KAAKyhC,OAAOqH,aAGjBr8B,QAAQC,WAARD,WAAaw7B,MAA0BtpB,SAGjC+sB,kBAAR,eAAc,aAAAxmC,mBAAAA,IAAAyZ,kBACP3e,KAAKyhC,OAAOsH,WAIjBt8B,QAAQyoC,UAARzoC,WAAYw7B,MAA0BtpB,cGl6DlCge,GAAmBnE,kBACnBsE,GAAetE"} +\ No newline at end of file +diff --git a/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +new file mode 100755 +index 0000000..c41fe28 +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +@@ -0,0 +1,12 @@ ++import { createBase64WorkerFactory as createBase64WorkerFactory$1 } from './_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js'; ++import { createBase64WorkerFactory as createBase64WorkerFactory$2 } from './_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js'; ++import { isNodeJS } from './_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js'; ++ ++function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) { ++ if (isNodeJS()) { ++ return createBase64WorkerFactory$1(base64, sourcemapArg, enableUnicodeArg); ++ } ++ return createBase64WorkerFactory$2(base64, sourcemapArg, enableUnicodeArg); ++} ++ ++export { createBase64WorkerFactory }; +diff --git a/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +new file mode 100755 +index 0000000..f6a92f1 +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +@@ -0,0 +1,7 @@ ++var kIsNodeJS = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; ++ ++function isNodeJS() { ++ return kIsNodeJS; ++} ++ ++export { isNodeJS }; +diff --git a/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +new file mode 100755 +index 0000000..aac3997 +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +@@ -0,0 +1,31 @@ ++function decodeBase64(base64, enableUnicode) { ++ var binaryString = atob(base64); ++ if (enableUnicode) { ++ var binaryView = new Uint8Array(binaryString.length); ++ for (var i = 0, n = binaryString.length; i < n; ++i) { ++ binaryView[i] = binaryString.charCodeAt(i); ++ } ++ return String.fromCharCode.apply(null, new Uint16Array(binaryView.buffer)); ++ } ++ return binaryString; ++} ++ ++function createURL(base64, sourcemapArg, enableUnicodeArg) { ++ var sourcemap = sourcemapArg === undefined ? null : sourcemapArg; ++ var enableUnicode = enableUnicodeArg === undefined ? false : enableUnicodeArg; ++ var source = decodeBase64(base64, enableUnicode); ++ var start = source.indexOf('\n', 10) + 1; ++ var body = source.substring(start) + (sourcemap ? '\/\/# sourceMappingURL=' + sourcemap : ''); ++ var blob = new Blob([body], { type: 'application/javascript' }); ++ return URL.createObjectURL(blob); ++} ++ ++function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) { ++ var url; ++ return function WorkerFactory(options) { ++ url = url || createURL(base64, sourcemapArg, enableUnicodeArg); ++ return new Worker(url, options); ++ }; ++} ++ ++export { createBase64WorkerFactory }; +diff --git a/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +new file mode 100755 +index 0000000..426d9ab +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +@@ -0,0 +1,11 @@ ++var WorkerClass = null; ++ ++try { ++ var WorkerThreads = ++ typeof module !== 'undefined' && typeof module.require === 'function' && module.require('worker_threads') || ++ typeof __non_webpack_require__ === 'function' && __non_webpack_require__('worker_threads') || ++ typeof require === 'function' && require('worker_threads'); ++ WorkerClass = WorkerThreads.Worker; ++} catch(e) {} // eslint-disable-line ++ ++export { WorkerClass }; +diff --git a/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +new file mode 100755 +index 0000000..32840eb +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +@@ -0,0 +1,18 @@ ++import { WorkerClass } from './_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js'; ++ ++function decodeBase64(base64, enableUnicode) { ++ return Buffer.from(base64, 'base64').toString(enableUnicode ? 'utf16' : 'utf8'); ++} ++ ++function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) { ++ var sourcemap = sourcemapArg === undefined ? null : sourcemapArg; ++ var enableUnicode = enableUnicodeArg === undefined ? false : enableUnicodeArg; ++ var source = decodeBase64(base64, enableUnicode); ++ var start = source.indexOf('\n', 10) + 1; ++ var body = source.substring(start) + (sourcemap ? '\/\/# sourceMappingURL=' + sourcemap : ''); ++ return function WorkerFactory(options) { ++ return new WorkerClass(body, Object.assign({}, options, { eval: true })); ++ }; ++} ++ ++export { createBase64WorkerFactory }; +diff --git a/node_modules/rrweb/es/rrweb/_virtual/image-bitmap-data-url-worker.js b/node_modules/rrweb/es/rrweb/_virtual/image-bitmap-data-url-worker.js +new file mode 100755 +index 0000000..895c415 +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/_virtual/image-bitmap-data-url-worker.js +@@ -0,0 +1,6 @@ ++import { createBase64WorkerFactory } from './_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js'; ++ ++var WorkerFactory = createBase64WorkerFactory('Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcH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mFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=', null, false); ++/* eslint-enable */ ++ ++export { WorkerFactory as default }; +diff --git a/node_modules/rrweb/es/rrweb/ext/@xstate/fsm/es/index.js b/node_modules/rrweb/es/rrweb/ext/@xstate/fsm/es/index.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js b/node_modules/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/ext/fflate/esm/browser.js b/node_modules/rrweb/es/rrweb/ext/fflate/esm/browser.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/ext/mitt/dist/mitt.mjs.js b/node_modules/rrweb/es/rrweb/ext/mitt/dist/mitt.mjs.js +new file mode 100755 +index 0000000..bf3d753 +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/ext/mitt/dist/mitt.mjs.js +@@ -0,0 +1,3 @@ ++function mitt(n){return {all:n=n||new Map,on:function(t,e){var i=n.get(t);i?i.push(e):n.set(t,[e]);},off:function(t,e){var i=n.get(t);i&&(e?i.splice(i.indexOf(e)>>>0,1):n.set(t,[]));},emit:function(t,e){var i=n.get(t);i&&i.slice().map(function(n){n(e);}),(i=n.get("*"))&&i.slice().map(function(n){n(t,e);});}}} ++ ++export { mitt as default }; +diff --git a/node_modules/rrweb/es/rrweb/ext/tslib/tslib.es6.js b/node_modules/rrweb/es/rrweb/ext/tslib/tslib.es6.js +old mode 100644 +new mode 100755 +index af2c4fe..afefda9 +--- a/node_modules/rrweb/es/rrweb/ext/tslib/tslib.es6.js ++++ b/node_modules/rrweb/es/rrweb/ext/tslib/tslib.es6.js +@@ -13,17 +13,6 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + +-var __assign = function() { +- __assign = Object.assign || function __assign(t) { +- for (var s, i = 1, n = arguments.length; i < n; i++) { +- s = arguments[i]; +- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; +- } +- return t; +- }; +- return __assign.apply(this, arguments); +-}; +- + function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) +@@ -36,39 +25,14 @@ function __rest(s, e) { + return t; + } + +-function __values(o) { +- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; +- if (m) return m.call(o); +- if (o && typeof o.length === "number") return { +- next: function () { +- if (o && i >= o.length) o = void 0; +- return { value: o && o[i++], done: !o }; +- } +- }; +- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +-} +- +-function __read(o, n) { +- var m = typeof Symbol === "function" && o[Symbol.iterator]; +- if (!m) return o; +- var i = m.call(o), r, ar = [], e; +- try { +- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); +- } +- catch (error) { e = { error: error }; } +- finally { +- try { +- if (r && !r.done && (m = i["return"])) m.call(i); +- } +- finally { if (e) throw e.error; } +- } +- return ar; +-} +- +-function __spread() { +- for (var ar = [], i = 0; i < arguments.length; i++) +- ar = ar.concat(__read(arguments[i])); +- return ar; ++function __awaiter(thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); + } + +-export { __assign, __read, __rest, __spread, __values }; ++export { __awaiter, __rest }; +diff --git a/node_modules/rrweb/es/rrweb/packages/rrdom/es/rrdom.js b/node_modules/rrweb/es/rrweb/packages/rrdom/es/rrdom.js +new file mode 100755 +index 0000000..3308f7b +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/packages/rrdom/es/rrdom.js +@@ -0,0 +1,1121 @@ ++var NodeType$1; ++(function (NodeType) { ++ NodeType[NodeType["Document"] = 0] = "Document"; ++ NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; ++ NodeType[NodeType["Element"] = 2] = "Element"; ++ NodeType[NodeType["Text"] = 3] = "Text"; ++ NodeType[NodeType["CDATA"] = 4] = "CDATA"; ++ NodeType[NodeType["Comment"] = 5] = "Comment"; ++})(NodeType$1 || (NodeType$1 = {})); ++var Mirror$1 = (function () { ++ function Mirror() { ++ this.idNodeMap = new Map(); ++ this.nodeMetaMap = new WeakMap(); ++ } ++ Mirror.prototype.getId = function (n) { ++ var _a; ++ if (!n) ++ return -1; ++ var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id; ++ return id !== null && id !== void 0 ? id : -1; ++ }; ++ Mirror.prototype.getNode = function (id) { ++ return this.idNodeMap.get(id) || null; ++ }; ++ Mirror.prototype.getIds = function () { ++ return Array.from(this.idNodeMap.keys()); ++ }; ++ Mirror.prototype.getMeta = function (n) { ++ return this.nodeMetaMap.get(n) || null; ++ }; ++ Mirror.prototype.removeNodeFromMap = function (n) { ++ var _this = this; ++ var id = this.getId(n); ++ this.idNodeMap["delete"](id); ++ if (n.childNodes) { ++ n.childNodes.forEach(function (childNode) { ++ return _this.removeNodeFromMap(childNode); ++ }); ++ } ++ }; ++ Mirror.prototype.has = function (id) { ++ return this.idNodeMap.has(id); ++ }; ++ Mirror.prototype.hasNode = function (node) { ++ return this.nodeMetaMap.has(node); ++ }; ++ Mirror.prototype.add = function (n, meta) { ++ var id = meta.id; ++ this.idNodeMap.set(id, n); ++ this.nodeMetaMap.set(n, meta); ++ }; ++ Mirror.prototype.replace = function (id, n) { ++ var oldNode = this.getNode(id); ++ if (oldNode) { ++ var meta = this.nodeMetaMap.get(oldNode); ++ if (meta) ++ this.nodeMetaMap.set(n, meta); ++ } ++ this.idNodeMap.set(id, n); ++ }; ++ Mirror.prototype.reset = function () { ++ this.idNodeMap = new Map(); ++ this.nodeMetaMap = new WeakMap(); ++ }; ++ return Mirror; ++}()); ++function createMirror$1() { ++ return new Mirror$1(); ++} ++ ++function parseCSSText(cssText) { ++ const res = {}; ++ const listDelimiter = /;(?![^(]*\))/g; ++ const propertyDelimiter = /:(.+)/; ++ const comment = /\/\*.*?\*\//g; ++ cssText ++ .replace(comment, '') ++ .split(listDelimiter) ++ .forEach(function (item) { ++ if (item) { ++ const tmp = item.split(propertyDelimiter); ++ tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim()); ++ } ++ }); ++ return res; ++} ++function toCSSText(style) { ++ const properties = []; ++ for (const name in style) { ++ const value = style[name]; ++ if (typeof value !== 'string') ++ continue; ++ const normalizedName = hyphenate(name); ++ properties.push(`${normalizedName}: ${value};`); ++ } ++ return properties.join(' '); ++} ++const camelizeRE = /-([a-z])/g; ++const CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; ++const camelize = (str) => { ++ if (CUSTOM_PROPERTY_REGEX.test(str)) ++ return str; ++ return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); ++}; ++const hyphenateRE = /\B([A-Z])/g; ++const hyphenate = (str) => { ++ return str.replace(hyphenateRE, '-$1').toLowerCase(); ++}; ++ ++class BaseRRNode { ++ constructor(..._args) { ++ this.childNodes = []; ++ this.parentElement = null; ++ this.parentNode = null; ++ this.ELEMENT_NODE = NodeType.ELEMENT_NODE; ++ this.TEXT_NODE = NodeType.TEXT_NODE; ++ } ++ get firstChild() { ++ return this.childNodes[0] || null; ++ } ++ get lastChild() { ++ return this.childNodes[this.childNodes.length - 1] || null; ++ } ++ get nextSibling() { ++ const parentNode = this.parentNode; ++ if (!parentNode) ++ return null; ++ const siblings = parentNode.childNodes; ++ const index = siblings.indexOf(this); ++ return siblings[index + 1] || null; ++ } ++ contains(node) { ++ if (node === this) ++ return true; ++ for (const child of this.childNodes) { ++ if (child.contains(node)) ++ return true; ++ } ++ return false; ++ } ++ appendChild(_newChild) { ++ throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.`); ++ } ++ insertBefore(_newChild, _refChild) { ++ throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.`); ++ } ++ removeChild(_node) { ++ throw new Error(`RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.`); ++ } ++ toString() { ++ return 'RRNode'; ++ } ++} ++function BaseRRDocumentImpl(RRNodeClass) { ++ return class BaseRRDocument extends RRNodeClass { ++ constructor() { ++ super(...arguments); ++ this.nodeType = NodeType.DOCUMENT_NODE; ++ this.nodeName = '#document'; ++ this.compatMode = 'CSS1Compat'; ++ this.RRNodeType = NodeType$1.Document; ++ this.textContent = null; ++ } ++ get documentElement() { ++ return (this.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && ++ node.tagName === 'HTML') || null); ++ } ++ get body() { ++ var _a; ++ return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && ++ node.tagName === 'BODY')) || null); ++ } ++ get head() { ++ var _a; ++ return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && ++ node.tagName === 'HEAD')) || null); ++ } ++ get implementation() { ++ return this; ++ } ++ get firstElementChild() { ++ return this.documentElement; ++ } ++ appendChild(childNode) { ++ const nodeType = childNode.RRNodeType; ++ if (nodeType === NodeType$1.Element || ++ nodeType === NodeType$1.DocumentType) { ++ if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { ++ throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); ++ } ++ } ++ childNode.parentElement = null; ++ childNode.parentNode = this; ++ this.childNodes.push(childNode); ++ return childNode; ++ } ++ insertBefore(newChild, refChild) { ++ const nodeType = newChild.RRNodeType; ++ if (nodeType === NodeType$1.Element || ++ nodeType === NodeType$1.DocumentType) { ++ if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { ++ throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); ++ } ++ } ++ if (refChild === null) ++ return this.appendChild(newChild); ++ const childIndex = this.childNodes.indexOf(refChild); ++ if (childIndex == -1) ++ throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode."); ++ this.childNodes.splice(childIndex, 0, newChild); ++ newChild.parentElement = null; ++ newChild.parentNode = this; ++ return newChild; ++ } ++ removeChild(node) { ++ const indexOfChild = this.childNodes.indexOf(node); ++ if (indexOfChild === -1) ++ throw new Error("Failed to execute 'removeChild' on 'RRDocument': The RRNode to be removed is not a child of this RRNode."); ++ this.childNodes.splice(indexOfChild, 1); ++ node.parentElement = null; ++ node.parentNode = null; ++ return node; ++ } ++ open() { ++ this.childNodes = []; ++ } ++ close() { ++ } ++ write(content) { ++ let publicId; ++ if (content === ++ '') ++ publicId = '-//W3C//DTD XHTML 1.0 Transitional//EN'; ++ else if (content === ++ '') ++ publicId = '-//W3C//DTD HTML 4.0 Transitional//EN'; ++ if (publicId) { ++ const doctype = this.createDocumentType('html', publicId, ''); ++ this.open(); ++ this.appendChild(doctype); ++ } ++ } ++ createDocument(_namespace, _qualifiedName, _doctype) { ++ return new BaseRRDocument(); ++ } ++ createDocumentType(qualifiedName, publicId, systemId) { ++ const doctype = new (BaseRRDocumentTypeImpl(BaseRRNode))(qualifiedName, publicId, systemId); ++ doctype.ownerDocument = this; ++ return doctype; ++ } ++ createElement(tagName) { ++ const element = new (BaseRRElementImpl(BaseRRNode))(tagName); ++ element.ownerDocument = this; ++ return element; ++ } ++ createElementNS(_namespaceURI, qualifiedName) { ++ return this.createElement(qualifiedName); ++ } ++ createTextNode(data) { ++ const text = new (BaseRRTextImpl(BaseRRNode))(data); ++ text.ownerDocument = this; ++ return text; ++ } ++ createComment(data) { ++ const comment = new (BaseRRCommentImpl(BaseRRNode))(data); ++ comment.ownerDocument = this; ++ return comment; ++ } ++ createCDATASection(data) { ++ const CDATASection = new (BaseRRCDATASectionImpl(BaseRRNode))(data); ++ CDATASection.ownerDocument = this; ++ return CDATASection; ++ } ++ toString() { ++ return 'RRDocument'; ++ } ++ }; ++} ++function BaseRRDocumentTypeImpl(RRNodeClass) { ++ return class BaseRRDocumentType extends RRNodeClass { ++ constructor(qualifiedName, publicId, systemId) { ++ super(); ++ this.nodeType = NodeType.DOCUMENT_TYPE_NODE; ++ this.RRNodeType = NodeType$1.DocumentType; ++ this.textContent = null; ++ this.name = qualifiedName; ++ this.publicId = publicId; ++ this.systemId = systemId; ++ this.nodeName = qualifiedName; ++ } ++ toString() { ++ return 'RRDocumentType'; ++ } ++ }; ++} ++function BaseRRElementImpl(RRNodeClass) { ++ return class BaseRRElement extends RRNodeClass { ++ constructor(tagName) { ++ super(); ++ this.nodeType = NodeType.ELEMENT_NODE; ++ this.RRNodeType = NodeType$1.Element; ++ this.attributes = {}; ++ this.shadowRoot = null; ++ this.tagName = tagName.toUpperCase(); ++ this.nodeName = tagName.toUpperCase(); ++ } ++ get textContent() { ++ let result = ''; ++ this.childNodes.forEach((node) => (result += node.textContent)); ++ return result; ++ } ++ set textContent(textContent) { ++ this.childNodes = [this.ownerDocument.createTextNode(textContent)]; ++ } ++ get classList() { ++ return new ClassList(this.attributes.class, (newClassName) => { ++ this.attributes.class = newClassName; ++ }); ++ } ++ get id() { ++ return this.attributes.id || ''; ++ } ++ get className() { ++ return this.attributes.class || ''; ++ } ++ get style() { ++ const style = (this.attributes.style ++ ? parseCSSText(this.attributes.style) ++ : {}); ++ const hyphenateRE = /\B([A-Z])/g; ++ style.setProperty = (name, value, priority) => { ++ if (hyphenateRE.test(name)) ++ return; ++ const normalizedName = camelize(name); ++ if (!value) ++ delete style[normalizedName]; ++ else ++ style[normalizedName] = value; ++ if (priority === 'important') ++ style[normalizedName] += ' !important'; ++ this.attributes.style = toCSSText(style); ++ }; ++ style.removeProperty = (name) => { ++ if (hyphenateRE.test(name)) ++ return ''; ++ const normalizedName = camelize(name); ++ const value = style[normalizedName] || ''; ++ delete style[normalizedName]; ++ this.attributes.style = toCSSText(style); ++ return value; ++ }; ++ return style; ++ } ++ getAttribute(name) { ++ return this.attributes[name] || null; ++ } ++ setAttribute(name, attribute) { ++ this.attributes[name] = attribute; ++ } ++ setAttributeNS(_namespace, qualifiedName, value) { ++ this.setAttribute(qualifiedName, value); ++ } ++ removeAttribute(name) { ++ delete this.attributes[name]; ++ } ++ appendChild(newChild) { ++ this.childNodes.push(newChild); ++ newChild.parentNode = this; ++ newChild.parentElement = this; ++ return newChild; ++ } ++ insertBefore(newChild, refChild) { ++ if (refChild === null) ++ return this.appendChild(newChild); ++ const childIndex = this.childNodes.indexOf(refChild); ++ if (childIndex == -1) ++ throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode."); ++ this.childNodes.splice(childIndex, 0, newChild); ++ newChild.parentElement = this; ++ newChild.parentNode = this; ++ return newChild; ++ } ++ removeChild(node) { ++ const indexOfChild = this.childNodes.indexOf(node); ++ if (indexOfChild === -1) ++ throw new Error("Failed to execute 'removeChild' on 'RRElement': The RRNode to be removed is not a child of this RRNode."); ++ this.childNodes.splice(indexOfChild, 1); ++ node.parentElement = null; ++ node.parentNode = null; ++ return node; ++ } ++ attachShadow(_init) { ++ const shadowRoot = this.ownerDocument.createElement('SHADOWROOT'); ++ this.shadowRoot = shadowRoot; ++ return shadowRoot; ++ } ++ dispatchEvent(_event) { ++ return true; ++ } ++ toString() { ++ let attributeString = ''; ++ for (const attribute in this.attributes) { ++ attributeString += `${attribute}="${this.attributes[attribute]}" `; ++ } ++ return `${this.tagName} ${attributeString}`; ++ } ++ }; ++} ++function BaseRRMediaElementImpl(RRElementClass) { ++ return class BaseRRMediaElement extends RRElementClass { ++ attachShadow(_init) { ++ throw new Error(`RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow`); ++ } ++ play() { ++ this.paused = false; ++ } ++ pause() { ++ this.paused = true; ++ } ++ }; ++} ++function BaseRRTextImpl(RRNodeClass) { ++ return class BaseRRText extends RRNodeClass { ++ constructor(data) { ++ super(); ++ this.nodeType = NodeType.TEXT_NODE; ++ this.nodeName = '#text'; ++ this.RRNodeType = NodeType$1.Text; ++ this.data = data; ++ } ++ get textContent() { ++ return this.data; ++ } ++ set textContent(textContent) { ++ this.data = textContent; ++ } ++ toString() { ++ return `RRText text=${JSON.stringify(this.data)}`; ++ } ++ }; ++} ++function BaseRRCommentImpl(RRNodeClass) { ++ return class BaseRRComment extends RRNodeClass { ++ constructor(data) { ++ super(); ++ this.nodeType = NodeType.COMMENT_NODE; ++ this.nodeName = '#comment'; ++ this.RRNodeType = NodeType$1.Comment; ++ this.data = data; ++ } ++ get textContent() { ++ return this.data; ++ } ++ set textContent(textContent) { ++ this.data = textContent; ++ } ++ toString() { ++ return `RRComment text=${JSON.stringify(this.data)}`; ++ } ++ }; ++} ++function BaseRRCDATASectionImpl(RRNodeClass) { ++ return class BaseRRCDATASection extends RRNodeClass { ++ constructor(data) { ++ super(); ++ this.nodeName = '#cdata-section'; ++ this.nodeType = NodeType.CDATA_SECTION_NODE; ++ this.RRNodeType = NodeType$1.CDATA; ++ this.data = data; ++ } ++ get textContent() { ++ return this.data; ++ } ++ set textContent(textContent) { ++ this.data = textContent; ++ } ++ toString() { ++ return `RRCDATASection data=${JSON.stringify(this.data)}`; ++ } ++ }; ++} ++class ClassList { ++ constructor(classText, onChange) { ++ this.classes = []; ++ this.add = (...classNames) => { ++ for (const item of classNames) { ++ const className = String(item); ++ if (this.classes.indexOf(className) >= 0) ++ continue; ++ this.classes.push(className); ++ } ++ this.onChange && this.onChange(this.classes.join(' ')); ++ }; ++ this.remove = (...classNames) => { ++ this.classes = this.classes.filter((item) => classNames.indexOf(item) === -1); ++ this.onChange && this.onChange(this.classes.join(' ')); ++ }; ++ if (classText) { ++ const classes = classText.trim().split(/\s+/); ++ this.classes.push(...classes); ++ } ++ this.onChange = onChange; ++ } ++} ++var NodeType; ++(function (NodeType) { ++ NodeType[NodeType["PLACEHOLDER"] = 0] = "PLACEHOLDER"; ++ NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE"; ++ NodeType[NodeType["ATTRIBUTE_NODE"] = 2] = "ATTRIBUTE_NODE"; ++ NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE"; ++ NodeType[NodeType["CDATA_SECTION_NODE"] = 4] = "CDATA_SECTION_NODE"; ++ NodeType[NodeType["ENTITY_REFERENCE_NODE"] = 5] = "ENTITY_REFERENCE_NODE"; ++ NodeType[NodeType["ENTITY_NODE"] = 6] = "ENTITY_NODE"; ++ NodeType[NodeType["PROCESSING_INSTRUCTION_NODE"] = 7] = "PROCESSING_INSTRUCTION_NODE"; ++ NodeType[NodeType["COMMENT_NODE"] = 8] = "COMMENT_NODE"; ++ NodeType[NodeType["DOCUMENT_NODE"] = 9] = "DOCUMENT_NODE"; ++ NodeType[NodeType["DOCUMENT_TYPE_NODE"] = 10] = "DOCUMENT_TYPE_NODE"; ++ NodeType[NodeType["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE"; ++})(NodeType || (NodeType = {})); ++ ++const NAMESPACES = { ++ svg: 'http://www.w3.org/2000/svg', ++ 'xlink:href': 'http://www.w3.org/1999/xlink', ++ xmlns: 'http://www.w3.org/2000/xmlns/', ++}; ++const SVGTagMap = { ++ altglyph: 'altGlyph', ++ altglyphdef: 'altGlyphDef', ++ altglyphitem: 'altGlyphItem', ++ animatecolor: 'animateColor', ++ animatemotion: 'animateMotion', ++ animatetransform: 'animateTransform', ++ clippath: 'clipPath', ++ feblend: 'feBlend', ++ fecolormatrix: 'feColorMatrix', ++ fecomponenttransfer: 'feComponentTransfer', ++ fecomposite: 'feComposite', ++ feconvolvematrix: 'feConvolveMatrix', ++ fediffuselighting: 'feDiffuseLighting', ++ fedisplacementmap: 'feDisplacementMap', ++ fedistantlight: 'feDistantLight', ++ fedropshadow: 'feDropShadow', ++ feflood: 'feFlood', ++ fefunca: 'feFuncA', ++ fefuncb: 'feFuncB', ++ fefuncg: 'feFuncG', ++ fefuncr: 'feFuncR', ++ fegaussianblur: 'feGaussianBlur', ++ feimage: 'feImage', ++ femerge: 'feMerge', ++ femergenode: 'feMergeNode', ++ femorphology: 'feMorphology', ++ feoffset: 'feOffset', ++ fepointlight: 'fePointLight', ++ fespecularlighting: 'feSpecularLighting', ++ fespotlight: 'feSpotLight', ++ fetile: 'feTile', ++ feturbulence: 'feTurbulence', ++ foreignobject: 'foreignObject', ++ glyphref: 'glyphRef', ++ lineargradient: 'linearGradient', ++ radialgradient: 'radialGradient', ++}; ++function diff(oldTree, newTree, replayer, rrnodeMirror) { ++ const oldChildren = oldTree.childNodes; ++ const newChildren = newTree.childNodes; ++ rrnodeMirror = ++ rrnodeMirror || ++ newTree.mirror || ++ newTree.ownerDocument.mirror; ++ if (oldChildren.length > 0 || newChildren.length > 0) { ++ diffChildren(Array.from(oldChildren), newChildren, oldTree, replayer, rrnodeMirror); ++ } ++ let inputDataToApply = null, scrollDataToApply = null; ++ switch (newTree.RRNodeType) { ++ case NodeType$1.Document: { ++ const newRRDocument = newTree; ++ scrollDataToApply = newRRDocument.scrollData; ++ break; ++ } ++ case NodeType$1.Element: { ++ const oldElement = oldTree; ++ const newRRElement = newTree; ++ diffProps(oldElement, newRRElement, rrnodeMirror); ++ scrollDataToApply = newRRElement.scrollData; ++ inputDataToApply = newRRElement.inputData; ++ switch (newRRElement.tagName) { ++ case 'AUDIO': ++ case 'VIDEO': { ++ const oldMediaElement = oldTree; ++ const newMediaRRElement = newRRElement; ++ if (newMediaRRElement.paused !== undefined) ++ newMediaRRElement.paused ++ ? void oldMediaElement.pause() ++ : void oldMediaElement.play(); ++ if (newMediaRRElement.muted !== undefined) ++ oldMediaElement.muted = newMediaRRElement.muted; ++ if (newMediaRRElement.volume !== undefined) ++ oldMediaElement.volume = newMediaRRElement.volume; ++ if (newMediaRRElement.currentTime !== undefined) ++ oldMediaElement.currentTime = newMediaRRElement.currentTime; ++ if (newMediaRRElement.playbackRate !== undefined) ++ oldMediaElement.playbackRate = newMediaRRElement.playbackRate; ++ break; ++ } ++ case 'CANVAS': ++ { ++ const rrCanvasElement = newTree; ++ if (rrCanvasElement.rr_dataURL !== null) { ++ const image = document.createElement('img'); ++ image.onload = () => { ++ const ctx = oldElement.getContext('2d'); ++ if (ctx) { ++ ctx.drawImage(image, 0, 0, image.width, image.height); ++ } ++ }; ++ image.src = rrCanvasElement.rr_dataURL; ++ } ++ rrCanvasElement.canvasMutations.forEach((canvasMutation) => replayer.applyCanvas(canvasMutation.event, canvasMutation.mutation, oldTree)); ++ } ++ break; ++ case 'STYLE': ++ { ++ const styleSheet = oldElement.sheet; ++ styleSheet && ++ newTree.rules.forEach((data) => replayer.applyStyleSheetMutation(data, styleSheet)); ++ } ++ break; ++ } ++ if (newRRElement.shadowRoot) { ++ if (!oldElement.shadowRoot) ++ oldElement.attachShadow({ mode: 'open' }); ++ const oldChildren = oldElement.shadowRoot.childNodes; ++ const newChildren = newRRElement.shadowRoot.childNodes; ++ if (oldChildren.length > 0 || newChildren.length > 0) ++ diffChildren(Array.from(oldChildren), newChildren, oldElement.shadowRoot, replayer, rrnodeMirror); ++ } ++ break; ++ } ++ case NodeType$1.Text: ++ case NodeType$1.Comment: ++ case NodeType$1.CDATA: ++ if (oldTree.textContent !== ++ newTree.data) ++ oldTree.textContent = newTree.data; ++ break; ++ } ++ scrollDataToApply && replayer.applyScroll(scrollDataToApply, true); ++ inputDataToApply && replayer.applyInput(inputDataToApply); ++ if (newTree.nodeName === 'IFRAME') { ++ const oldContentDocument = oldTree.contentDocument; ++ const newIFrameElement = newTree; ++ if (oldContentDocument) { ++ const sn = rrnodeMirror.getMeta(newIFrameElement.contentDocument); ++ if (sn) { ++ replayer.mirror.add(oldContentDocument, Object.assign({}, sn)); ++ } ++ diff(oldContentDocument, newIFrameElement.contentDocument, replayer, rrnodeMirror); ++ } ++ } ++} ++function diffProps(oldTree, newTree, rrnodeMirror) { ++ const oldAttributes = oldTree.attributes; ++ const newAttributes = newTree.attributes; ++ for (const name in newAttributes) { ++ const newValue = newAttributes[name]; ++ const sn = rrnodeMirror.getMeta(newTree); ++ if (sn && 'isSVG' in sn && sn.isSVG && NAMESPACES[name]) ++ oldTree.setAttributeNS(NAMESPACES[name], name, newValue); ++ else if (newTree.tagName === 'CANVAS' && name === 'rr_dataURL') { ++ const image = document.createElement('img'); ++ image.src = newValue; ++ image.onload = () => { ++ const ctx = oldTree.getContext('2d'); ++ if (ctx) { ++ ctx.drawImage(image, 0, 0, image.width, image.height); ++ } ++ }; ++ } ++ else ++ oldTree.setAttribute(name, newValue); ++ } ++ for (const { name } of Array.from(oldAttributes)) ++ if (!(name in newAttributes)) ++ oldTree.removeAttribute(name); ++ newTree.scrollLeft && (oldTree.scrollLeft = newTree.scrollLeft); ++ newTree.scrollTop && (oldTree.scrollTop = newTree.scrollTop); ++} ++function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirror) { ++ var _a; ++ let oldStartIndex = 0, oldEndIndex = oldChildren.length - 1, newStartIndex = 0, newEndIndex = newChildren.length - 1; ++ let oldStartNode = oldChildren[oldStartIndex], oldEndNode = oldChildren[oldEndIndex], newStartNode = newChildren[newStartIndex], newEndNode = newChildren[newEndIndex]; ++ let oldIdToIndex = undefined, indexInOld; ++ while (oldStartIndex <= oldEndIndex && newStartIndex <= newEndIndex) { ++ const oldStartId = replayer.mirror.getId(oldStartNode); ++ const oldEndId = replayer.mirror.getId(oldEndNode); ++ const newStartId = rrnodeMirror.getId(newStartNode); ++ const newEndId = rrnodeMirror.getId(newEndNode); ++ if (oldStartNode === undefined) { ++ oldStartNode = oldChildren[++oldStartIndex]; ++ } ++ else if (oldEndNode === undefined) { ++ oldEndNode = oldChildren[--oldEndIndex]; ++ } ++ else if (oldStartId !== -1 && ++ oldStartId === newStartId) { ++ diff(oldStartNode, newStartNode, replayer, rrnodeMirror); ++ oldStartNode = oldChildren[++oldStartIndex]; ++ newStartNode = newChildren[++newStartIndex]; ++ } ++ else if (oldEndId !== -1 && ++ oldEndId === newEndId) { ++ diff(oldEndNode, newEndNode, replayer, rrnodeMirror); ++ oldEndNode = oldChildren[--oldEndIndex]; ++ newEndNode = newChildren[--newEndIndex]; ++ } ++ else if (oldStartId !== -1 && ++ oldStartId === newEndId) { ++ parentNode.insertBefore(oldStartNode, oldEndNode.nextSibling); ++ diff(oldStartNode, newEndNode, replayer, rrnodeMirror); ++ oldStartNode = oldChildren[++oldStartIndex]; ++ newEndNode = newChildren[--newEndIndex]; ++ } ++ else if (oldEndId !== -1 && ++ oldEndId === newStartId) { ++ parentNode.insertBefore(oldEndNode, oldStartNode); ++ diff(oldEndNode, newStartNode, replayer, rrnodeMirror); ++ oldEndNode = oldChildren[--oldEndIndex]; ++ newStartNode = newChildren[++newStartIndex]; ++ } ++ else { ++ if (!oldIdToIndex) { ++ oldIdToIndex = {}; ++ for (let i = oldStartIndex; i <= oldEndIndex; i++) { ++ const oldChild = oldChildren[i]; ++ if (oldChild && replayer.mirror.hasNode(oldChild)) ++ oldIdToIndex[replayer.mirror.getId(oldChild)] = i; ++ } ++ } ++ indexInOld = oldIdToIndex[rrnodeMirror.getId(newStartNode)]; ++ if (indexInOld) { ++ const nodeToMove = oldChildren[indexInOld]; ++ parentNode.insertBefore(nodeToMove, oldStartNode); ++ diff(nodeToMove, newStartNode, replayer, rrnodeMirror); ++ oldChildren[indexInOld] = undefined; ++ } ++ else { ++ const newNode = createOrGetNode(newStartNode, replayer.mirror, rrnodeMirror); ++ if (parentNode.nodeName === '#document' && ++ ((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) === NodeType$1.Element && ++ parentNode.documentElement) { ++ parentNode.removeChild(parentNode.documentElement); ++ oldChildren[oldStartIndex] = undefined; ++ oldStartNode = undefined; ++ } ++ parentNode.insertBefore(newNode, oldStartNode || null); ++ diff(newNode, newStartNode, replayer, rrnodeMirror); ++ } ++ newStartNode = newChildren[++newStartIndex]; ++ } ++ } ++ if (oldStartIndex > oldEndIndex) { ++ const referenceRRNode = newChildren[newEndIndex + 1]; ++ let referenceNode = null; ++ if (referenceRRNode) ++ parentNode.childNodes.forEach((child) => { ++ if (replayer.mirror.getId(child) === rrnodeMirror.getId(referenceRRNode)) ++ referenceNode = child; ++ }); ++ for (; newStartIndex <= newEndIndex; ++newStartIndex) { ++ const newNode = createOrGetNode(newChildren[newStartIndex], replayer.mirror, rrnodeMirror); ++ parentNode.insertBefore(newNode, referenceNode); ++ diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror); ++ } ++ } ++ else if (newStartIndex > newEndIndex) { ++ for (; oldStartIndex <= oldEndIndex; oldStartIndex++) { ++ const node = oldChildren[oldStartIndex]; ++ if (node) { ++ parentNode.removeChild(node); ++ replayer.mirror.removeNodeFromMap(node); ++ } ++ } ++ } ++} ++function createOrGetNode(rrNode, domMirror, rrnodeMirror) { ++ const nodeId = rrnodeMirror.getId(rrNode); ++ const sn = rrnodeMirror.getMeta(rrNode); ++ let node = null; ++ if (nodeId > -1) ++ node = domMirror.getNode(nodeId); ++ if (node !== null) ++ return node; ++ switch (rrNode.RRNodeType) { ++ case NodeType$1.Document: ++ node = new Document(); ++ break; ++ case NodeType$1.DocumentType: ++ node = document.implementation.createDocumentType(rrNode.name, rrNode.publicId, rrNode.systemId); ++ break; ++ case NodeType$1.Element: { ++ let tagName = rrNode.tagName.toLowerCase(); ++ tagName = SVGTagMap[tagName] || tagName; ++ if (sn && 'isSVG' in sn && (sn === null || sn === void 0 ? void 0 : sn.isSVG)) { ++ node = document.createElementNS(NAMESPACES['svg'], tagName); ++ } ++ else ++ node = document.createElement(rrNode.tagName); ++ break; ++ } ++ case NodeType$1.Text: ++ node = document.createTextNode(rrNode.data); ++ break; ++ case NodeType$1.Comment: ++ node = document.createComment(rrNode.data); ++ break; ++ case NodeType$1.CDATA: ++ node = document.createCDATASection(rrNode.data); ++ break; ++ } ++ if (sn) ++ domMirror.add(node, Object.assign({}, sn)); ++ return node; ++} ++ ++class RRDocument extends BaseRRDocumentImpl(BaseRRNode) { ++ constructor(mirror) { ++ super(); ++ this.UNSERIALIZED_STARTING_ID = -2; ++ this._unserializedId = this.UNSERIALIZED_STARTING_ID; ++ this.mirror = createMirror(); ++ this.scrollData = null; ++ if (mirror) { ++ this.mirror = mirror; ++ } ++ } ++ get unserializedId() { ++ return this._unserializedId--; ++ } ++ createDocument(_namespace, _qualifiedName, _doctype) { ++ return new RRDocument(); ++ } ++ createDocumentType(qualifiedName, publicId, systemId) { ++ const documentTypeNode = new RRDocumentType(qualifiedName, publicId, systemId); ++ documentTypeNode.ownerDocument = this; ++ return documentTypeNode; ++ } ++ createElement(tagName) { ++ const upperTagName = tagName.toUpperCase(); ++ let element; ++ switch (upperTagName) { ++ case 'AUDIO': ++ case 'VIDEO': ++ element = new RRMediaElement(upperTagName); ++ break; ++ case 'IFRAME': ++ element = new RRIFrameElement(upperTagName, this.mirror); ++ break; ++ case 'CANVAS': ++ element = new RRCanvasElement(upperTagName); ++ break; ++ case 'STYLE': ++ element = new RRStyleElement(upperTagName); ++ break; ++ default: ++ element = new RRElement(upperTagName); ++ break; ++ } ++ element.ownerDocument = this; ++ return element; ++ } ++ createComment(data) { ++ const commentNode = new RRComment(data); ++ commentNode.ownerDocument = this; ++ return commentNode; ++ } ++ createCDATASection(data) { ++ const sectionNode = new RRCDATASection(data); ++ sectionNode.ownerDocument = this; ++ return sectionNode; ++ } ++ createTextNode(data) { ++ const textNode = new RRText(data); ++ textNode.ownerDocument = this; ++ return textNode; ++ } ++ destroyTree() { ++ this.childNodes = []; ++ this.mirror.reset(); ++ } ++ open() { ++ super.open(); ++ this._unserializedId = this.UNSERIALIZED_STARTING_ID; ++ } ++} ++const RRDocumentType = BaseRRDocumentTypeImpl(BaseRRNode); ++class RRElement extends BaseRRElementImpl(BaseRRNode) { ++ constructor() { ++ super(...arguments); ++ this.inputData = null; ++ this.scrollData = null; ++ } ++} ++class RRMediaElement extends BaseRRMediaElementImpl(RRElement) { ++} ++class RRCanvasElement extends RRElement { ++ constructor() { ++ super(...arguments); ++ this.rr_dataURL = null; ++ this.canvasMutations = []; ++ } ++ getContext() { ++ return null; ++ } ++} ++class RRStyleElement extends RRElement { ++ constructor() { ++ super(...arguments); ++ this.rules = []; ++ } ++} ++class RRIFrameElement extends RRElement { ++ constructor(upperTagName, mirror) { ++ super(upperTagName); ++ this.contentDocument = new RRDocument(); ++ this.contentDocument.mirror = mirror; ++ } ++} ++const RRText = BaseRRTextImpl(BaseRRNode); ++const RRComment = BaseRRCommentImpl(BaseRRNode); ++const RRCDATASection = BaseRRCDATASectionImpl(BaseRRNode); ++function getValidTagName(element) { ++ if (element instanceof HTMLFormElement) { ++ return 'FORM'; ++ } ++ return element.tagName.toUpperCase(); ++} ++function buildFromNode(node, rrdom, domMirror, parentRRNode) { ++ let rrNode; ++ switch (node.nodeType) { ++ case NodeType.DOCUMENT_NODE: ++ if (parentRRNode && parentRRNode.nodeName === 'IFRAME') ++ rrNode = parentRRNode.contentDocument; ++ else { ++ rrNode = rrdom; ++ rrNode.compatMode = node.compatMode; ++ } ++ break; ++ case NodeType.DOCUMENT_TYPE_NODE: { ++ const documentType = node; ++ rrNode = rrdom.createDocumentType(documentType.name, documentType.publicId, documentType.systemId); ++ break; ++ } ++ case NodeType.ELEMENT_NODE: { ++ const elementNode = node; ++ const tagName = getValidTagName(elementNode); ++ rrNode = rrdom.createElement(tagName); ++ const rrElement = rrNode; ++ for (const { name, value } of Array.from(elementNode.attributes)) { ++ rrElement.attributes[name] = value; ++ } ++ elementNode.scrollLeft && (rrElement.scrollLeft = elementNode.scrollLeft); ++ elementNode.scrollTop && (rrElement.scrollTop = elementNode.scrollTop); ++ break; ++ } ++ case NodeType.TEXT_NODE: ++ rrNode = rrdom.createTextNode(node.textContent || ''); ++ break; ++ case NodeType.CDATA_SECTION_NODE: ++ rrNode = rrdom.createCDATASection(node.data); ++ break; ++ case NodeType.COMMENT_NODE: ++ rrNode = rrdom.createComment(node.textContent || ''); ++ break; ++ case NodeType.DOCUMENT_FRAGMENT_NODE: ++ rrNode = parentRRNode.attachShadow({ mode: 'open' }); ++ break; ++ default: ++ return null; ++ } ++ let sn = domMirror.getMeta(node); ++ if (rrdom instanceof RRDocument) { ++ if (!sn) { ++ sn = getDefaultSN(rrNode, rrdom.unserializedId); ++ domMirror.add(node, sn); ++ } ++ rrdom.mirror.add(rrNode, Object.assign({}, sn)); ++ } ++ return rrNode; ++} ++function buildFromDom(dom, domMirror = createMirror$1(), rrdom = new RRDocument()) { ++ function walk(node, parentRRNode) { ++ const rrNode = buildFromNode(node, rrdom, domMirror, parentRRNode); ++ if (rrNode === null) ++ return; ++ if ((parentRRNode === null || parentRRNode === void 0 ? void 0 : parentRRNode.nodeName) !== 'IFRAME' && ++ node.nodeType !== NodeType.DOCUMENT_FRAGMENT_NODE) { ++ parentRRNode === null || parentRRNode === void 0 ? void 0 : parentRRNode.appendChild(rrNode); ++ rrNode.parentNode = parentRRNode; ++ rrNode.parentElement = parentRRNode; ++ } ++ if (node.nodeName === 'IFRAME') { ++ const iframeDoc = node.contentDocument; ++ iframeDoc && walk(iframeDoc, rrNode); ++ } ++ else if (node.nodeType === NodeType.DOCUMENT_NODE || ++ node.nodeType === NodeType.ELEMENT_NODE || ++ node.nodeType === NodeType.DOCUMENT_FRAGMENT_NODE) { ++ if (node.nodeType === NodeType.ELEMENT_NODE && ++ node.shadowRoot) ++ walk(node.shadowRoot, rrNode); ++ node.childNodes.forEach((childNode) => walk(childNode, rrNode)); ++ } ++ } ++ walk(dom, null); ++ return rrdom; ++} ++function createMirror() { ++ return new Mirror(); ++} ++class Mirror { ++ constructor() { ++ this.idNodeMap = new Map(); ++ this.nodeMetaMap = new WeakMap(); ++ } ++ getId(n) { ++ var _a; ++ if (!n) ++ return -1; ++ const id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id; ++ return id !== null && id !== void 0 ? id : -1; ++ } ++ getNode(id) { ++ return this.idNodeMap.get(id) || null; ++ } ++ getIds() { ++ return Array.from(this.idNodeMap.keys()); ++ } ++ getMeta(n) { ++ return this.nodeMetaMap.get(n) || null; ++ } ++ removeNodeFromMap(n) { ++ const id = this.getId(n); ++ this.idNodeMap.delete(id); ++ if (n.childNodes) { ++ n.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode)); ++ } ++ } ++ has(id) { ++ return this.idNodeMap.has(id); ++ } ++ hasNode(node) { ++ return this.nodeMetaMap.has(node); ++ } ++ add(n, meta) { ++ const id = meta.id; ++ this.idNodeMap.set(id, n); ++ this.nodeMetaMap.set(n, meta); ++ } ++ replace(id, n) { ++ const oldNode = this.getNode(id); ++ if (oldNode) { ++ const meta = this.nodeMetaMap.get(oldNode); ++ if (meta) ++ this.nodeMetaMap.set(n, meta); ++ } ++ this.idNodeMap.set(id, n); ++ } ++ reset() { ++ this.idNodeMap = new Map(); ++ this.nodeMetaMap = new WeakMap(); ++ } ++} ++function getDefaultSN(node, id) { ++ switch (node.RRNodeType) { ++ case NodeType$1.Document: ++ return { ++ id, ++ type: node.RRNodeType, ++ childNodes: [], ++ }; ++ case NodeType$1.DocumentType: { ++ const doctype = node; ++ return { ++ id, ++ type: node.RRNodeType, ++ name: doctype.name, ++ publicId: doctype.publicId, ++ systemId: doctype.systemId, ++ }; ++ } ++ case NodeType$1.Element: ++ return { ++ id, ++ type: node.RRNodeType, ++ tagName: node.tagName.toLowerCase(), ++ attributes: {}, ++ childNodes: [], ++ }; ++ case NodeType$1.Text: ++ return { ++ id, ++ type: node.RRNodeType, ++ textContent: node.textContent || '', ++ }; ++ case NodeType$1.Comment: ++ return { ++ id, ++ type: node.RRNodeType, ++ textContent: node.textContent || '', ++ }; ++ case NodeType$1.CDATA: ++ return { ++ id, ++ type: node.RRNodeType, ++ textContent: '', ++ }; ++ } ++} ++ ++export { BaseRRCDATASectionImpl, BaseRRCommentImpl, BaseRRDocumentImpl, BaseRRDocumentTypeImpl, BaseRRElementImpl, BaseRRMediaElementImpl, BaseRRNode, BaseRRTextImpl, ClassList, Mirror, NodeType, RRCDATASection, RRCanvasElement, RRComment, RRDocument, RRDocumentType, RRElement, RRIFrameElement, RRMediaElement, BaseRRNode as RRNode, RRStyleElement, RRText, buildFromDom, buildFromNode, createMirror, createOrGetNode, diff, getDefaultSN }; +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js b/node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +old mode 100644 +new mode 100755 +index 2259070..b292b2b +--- a/node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js ++++ b/node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +@@ -17,10 +17,14 @@ function isShadowRoot(n) { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -247,7 +251,10 @@ function transformAttribute(doc, tagName, name, value) { + return value; + } + } +-function _isBlockedElement(element, blockClass, blockSelector) { ++function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -266,11 +273,16 @@ function _isBlockedElement(element, blockClass, blockSelector) { + } + return false; + } +-function needMaskingText(node, maskTextClass, maskTextSelector) { ++function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -289,12 +301,12 @@ function needMaskingText(node, maskTextClass, maskTextSelector) { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -334,7 +346,7 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -366,7 +378,7 @@ function serializeNode(n, options) { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -407,9 +419,12 @@ function serializeNode(n, options) { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -528,7 +543,7 @@ function serializeNode(n, options) { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -636,15 +651,19 @@ function slimDOMExcluded(sn, slimDOMOptions) { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -700,10 +719,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -748,10 +771,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -774,7 +801,7 @@ function serializeNodeWithId(n, options) { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -823,10 +850,14 @@ function snapshot(n, options) { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/entries/all.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/entries/all.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/index.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/index.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/base.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/base.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/pack.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/pack.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/unpack.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/unpack.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/index.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/cross-origin-iframe-mirror.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/cross-origin-iframe-mirror.js +new file mode 100755 +index 0000000..3bb031f +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/cross-origin-iframe-mirror.js +@@ -0,0 +1,63 @@ ++class CrossOriginIframeMirror { ++ constructor(generateIdFn) { ++ this.generateIdFn = generateIdFn; ++ this.iframeIdToRemoteIdMap = new WeakMap(); ++ this.iframeRemoteIdToIdMap = new WeakMap(); ++ } ++ getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) { ++ const idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe); ++ const remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe); ++ let id = idToRemoteIdMap.get(remoteId); ++ if (!id) { ++ id = this.generateIdFn(); ++ idToRemoteIdMap.set(remoteId, id); ++ remoteIdToIdMap.set(id, remoteId); ++ } ++ return id; ++ } ++ getIds(iframe, remoteId) { ++ const idToRemoteIdMap = this.getIdToRemoteIdMap(iframe); ++ const remoteIdToIdMap = this.getRemoteIdToIdMap(iframe); ++ return remoteId.map((id) => this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap)); ++ } ++ getRemoteId(iframe, id, map) { ++ const remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe); ++ if (typeof id !== 'number') ++ return id; ++ const remoteId = remoteIdToIdMap.get(id); ++ if (!remoteId) ++ return -1; ++ return remoteId; ++ } ++ getRemoteIds(iframe, ids) { ++ const remoteIdToIdMap = this.getRemoteIdToIdMap(iframe); ++ return ids.map((id) => this.getRemoteId(iframe, id, remoteIdToIdMap)); ++ } ++ reset(iframe) { ++ if (!iframe) { ++ this.iframeIdToRemoteIdMap = new WeakMap(); ++ this.iframeRemoteIdToIdMap = new WeakMap(); ++ return; ++ } ++ this.iframeIdToRemoteIdMap.delete(iframe); ++ this.iframeRemoteIdToIdMap.delete(iframe); ++ } ++ getIdToRemoteIdMap(iframe) { ++ let idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe); ++ if (!idToRemoteIdMap) { ++ idToRemoteIdMap = new Map(); ++ this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap); ++ } ++ return idToRemoteIdMap; ++ } ++ getRemoteIdToIdMap(iframe) { ++ let remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe); ++ if (!remoteIdToIdMap) { ++ remoteIdToIdMap = new Map(); ++ this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap); ++ } ++ return remoteIdToIdMap; ++ } ++} ++ ++export { CrossOriginIframeMirror as default }; +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/iframe-manager.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/iframe-manager.js +old mode 100644 +new mode 100755 diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js -index 8091399..48e8321 100644 +old mode 100644 +new mode 100755 +index 8091399..68af537 --- a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js +++ b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js -@@ -325,7 +325,11 @@ function record(options) { +@@ -15,7 +15,7 @@ var takeFullSnapshot; + var mirror = createMirror(); + function record(options) { + if (options === void 0) { options = {}; } +- var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.ignoreClass, ignoreClass = _c === void 0 ? 'rr-ignore' : _c, _d = options.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = options.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = options.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _g = options.sampling, sampling = _g === void 0 ? {} : _g, mousemoveWait = options.mousemoveWait, _h = options.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = options.userTriggeredOnInput, userTriggeredOnInput = _j === void 0 ? false : _j, _k = options.collectFonts, collectFonts = _k === void 0 ? false : _k, _l = options.inlineImages, inlineImages = _l === void 0 ? false : _l, plugins = options.plugins, _m = options.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m; ++ var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s; + if (!emit) { + throw new Error('emit function is required'); + } +@@ -146,8 +146,12 @@ function record(options) { + bypassOptions: { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, +@@ -176,8 +180,12 @@ function record(options) { + var _e = __read(snapshot(document, { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskAllInputs: maskInputOptions, + maskTextFn: maskTextFn, +@@ -291,8 +299,12 @@ function record(options) { + }, + blockClass: blockClass, + ignoreClass: ignoreClass, ++ ignoreSelector: ignoreSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + inlineStylesheet: inlineStylesheet, + sampling: sampling, +@@ -304,6 +316,7 @@ function record(options) { + maskInputFn: maskInputFn, + maskTextFn: maskTextFn, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + slimDOMOptions: slimDOMOptions, + mirror: mirror, + iframeManager: iframeManager, +@@ -325,7 +338,12 @@ function record(options) { + }, hooks); + }; + iframeManager.addLoadListener(function (iframeEl) { +- handlers_1.push(observe_1(iframeEl.contentDocument)); ++ try { ++ handlers_1.push(observe_1(iframeEl.contentDocument)); ++ } ++ catch (error) { ++ console.warn(error); ++ } + }); + var init_1 = function () { + takeFullSnapshot(); +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js +old mode 100644 +new mode 100755 +index fd183b9..02ba7b8 +--- a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js ++++ b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js +@@ -144,8 +144,12 @@ var MutationBuffer = (function () { + map: _this.mirror.map, + blockClass: _this.blockClass, + blockSelector: _this.blockSelector, ++ unblockSelector: _this.unblockSelector, + maskTextClass: _this.maskTextClass, + maskTextSelector: _this.maskTextSelector, ++ unmaskTextSelector: _this.unmaskTextSelector, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + skipChild: true, + inlineStylesheet: _this.inlineStylesheet, + maskInputOptions: _this.maskInputOptions, +@@ -291,7 +295,7 @@ var MutationBuffer = (function () { + var value = m.target.textContent; + if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) { + _this.texts.push({ +- value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector) && value ++ value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, _this.unmaskTextSelector) && value + ? _this.maskTextFn + ? _this.maskTextFn(value) + : value.replace(/[\S]/g, '*') +@@ -306,6 +310,9 @@ var MutationBuffer = (function () { + var value = m.target.getAttribute(m.attributeName); + if (m.attributeName === 'value') { + value = maskInputValue({ ++ input: target, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + maskInputOptions: _this.maskInputOptions, + tagName: m.target.tagName, + type: m.target.getAttribute('type'), +@@ -442,8 +449,12 @@ var MutationBuffer = (function () { + 'mutationCb', + 'blockClass', + 'blockSelector', ++ 'unblockSelector', + 'maskTextClass', + 'maskTextSelector', ++ 'unmaskTextSelector', ++ 'maskInputSelector', ++ 'unmaskInputSelector', + 'inlineStylesheet', + 'maskInputOptions', + 'maskTextFn', +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js +old mode 100644 +new mode 100755 +index 9895009..3436ede +--- a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js ++++ b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js +@@ -1,4 +1,4 @@ +-import { __read, __values, __spreadArray, __assign } from '../../ext/tslib/tslib.es6.js'; ++import { __values, __spreadArray, __read, __assign } from '../../ext/tslib/tslib.es6.js'; + import { maskInputValue } from '../../../rrweb-snapshot/es/rrweb-snapshot.js'; + import { on, throttle, isTouchEvent, isBlocked, getWindowHeight, getWindowWidth, hookSetter, patch } from '../utils.js'; + import { IncrementalSource, MouseInteractions } from '../types.js'; +@@ -198,7 +198,7 @@ function wrapEventWithUserTriggeredFlag(v, enable) { + var INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT']; + var lastInputValueMap = new WeakMap(); + function initInputObserver(_a) { +- var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; ++ var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; + function eventHandler(event) { + var target = getEventTarget(event); + var userTriggered = event.isTrusted; +@@ -211,7 +211,7 @@ function initInputObserver(_a) { + return; + } + var type = target.type; +- if (target.classList.contains(ignoreClass)) { ++ if (target.classList.contains(ignoreClass) || (ignoreSelector && target.matches(ignoreSelector))) { + return; + } + var text = target.value; +@@ -222,7 +222,10 @@ function initInputObserver(_a) { + else if (maskInputOptions[target.tagName.toLowerCase()] || + maskInputOptions[type]) { + text = maskInputValue({ ++ input: target, + maskInputOptions: maskInputOptions, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + tagName: target.tagName, + type: type, + value: text, +@@ -306,6 +309,9 @@ function getNestedCSSRulePositions(rule) { + function initStyleSheetObserver(_a, _b) { + var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror; + var win = _b.win; ++ if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) { ++ return function () { }; ++ } + var insertRule = win.CSSStyleSheet.prototype.insertRule; + win.CSSStyleSheet.prototype.insertRule = function (rule, index) { + var id = mirror.getId(this.ownerNode); +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +new file mode 100755 +index 0000000..0165f4b +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +@@ -0,0 +1,72 @@ ++import { getCssRuleString } from '../../../rrweb-snapshot/es/rrweb-snapshot.js'; ++import { StyleSheetMirror } from '../utils.js'; ++ ++class StylesheetManager { ++ constructor(options) { ++ this.trackedLinkElements = new WeakSet(); ++ this.styleMirror = new StyleSheetMirror(); ++ this.mutationCb = options.mutationCb; ++ this.adoptedStyleSheetCb = options.adoptedStyleSheetCb; ++ } ++ attachLinkElement(linkEl, childSn) { ++ if ('_cssText' in childSn.attributes) ++ this.mutationCb({ ++ adds: [], ++ removes: [], ++ texts: [], ++ attributes: [ ++ { ++ id: childSn.id, ++ attributes: childSn ++ .attributes, ++ }, ++ ], ++ }); ++ this.trackLinkElement(linkEl); ++ } ++ trackLinkElement(linkEl) { ++ if (this.trackedLinkElements.has(linkEl)) ++ return; ++ this.trackedLinkElements.add(linkEl); ++ this.trackStylesheetInLinkElement(linkEl); ++ } ++ adoptStyleSheets(sheets, hostId) { ++ if (sheets.length === 0) ++ return; ++ const adoptedStyleSheetData = { ++ id: hostId, ++ styleIds: [], ++ }; ++ const styles = []; ++ for (const sheet of sheets) { ++ let styleId; ++ if (!this.styleMirror.has(sheet)) { ++ styleId = this.styleMirror.add(sheet); ++ const rules = Array.from(sheet.rules || CSSRule); ++ styles.push({ ++ styleId, ++ rules: rules.map((r, index) => { ++ return { ++ rule: getCssRuleString(r), ++ index, ++ }; ++ }), ++ }); ++ } ++ else ++ styleId = this.styleMirror.getId(sheet); ++ adoptedStyleSheetData.styleIds.push(styleId); ++ } ++ if (styles.length > 0) ++ adoptedStyleSheetData.styles = styles; ++ this.adoptedStyleSheetCb(adoptedStyleSheetData); ++ } ++ reset() { ++ this.styleMirror.reset(); ++ this.trackedLinkElements = new WeakSet(); ++ } ++ trackStylesheetInLinkElement(linkEl) { ++ } ++} ++ ++export { StylesheetManager }; +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/2d.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +new file mode 100755 +index 0000000..67cf152 +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +@@ -0,0 +1,67 @@ ++import { __awaiter } from './../../../../../ext/tslib/tslib.es6.js'; ++import { decode } from './../../../../../ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js'; ++ ++const webGLVarMap = new Map(); ++function variableListFor(ctx, ctor) { ++ let contextMap = webGLVarMap.get(ctx); ++ if (!contextMap) { ++ contextMap = new Map(); ++ webGLVarMap.set(ctx, contextMap); ++ } ++ if (!contextMap.has(ctor)) { ++ contextMap.set(ctor, []); ++ } ++ return contextMap.get(ctor); ++} ++function deserializeArg(imageMap, ctx, preload) { ++ return (arg) => __awaiter(this, void 0, void 0, function* () { ++ if (arg && typeof arg === 'object' && 'rr_type' in arg) { ++ if (preload) ++ preload.isUnchanged = false; ++ if (arg.rr_type === 'ImageBitmap' && 'args' in arg) { ++ const args = yield deserializeArg(imageMap, ctx, preload)(arg.args); ++ return yield createImageBitmap.apply(null, args); ++ } ++ else if ('index' in arg) { ++ if (preload || ctx === null) ++ return arg; ++ const { rr_type: name, index } = arg; ++ return variableListFor(ctx, name)[index]; ++ } ++ else if ('args' in arg) { ++ const { rr_type: name, args } = arg; ++ const ctor = window[name]; ++ return new ctor(...(yield Promise.all(args.map(deserializeArg(imageMap, ctx, preload))))); ++ } ++ else if ('base64' in arg) { ++ return decode(arg.base64); ++ } ++ else if ('src' in arg) { ++ const image = imageMap.get(arg.src); ++ if (image) { ++ return image; ++ } ++ else { ++ const image = new Image(); ++ image.src = arg.src; ++ imageMap.set(arg.src, image); ++ return image; ++ } ++ } ++ else if ('data' in arg && arg.rr_type === 'Blob') { ++ const blobContents = yield Promise.all(arg.data.map(deserializeArg(imageMap, ctx, preload))); ++ const blob = new Blob(blobContents, { ++ type: arg.type, ++ }); ++ return blob; ++ } ++ } ++ else if (Array.isArray(arg)) { ++ const result = yield Promise.all(arg.map(deserializeArg(imageMap, ctx, preload))); ++ return result; ++ } ++ return arg; ++ }); ++} ++ ++export { deserializeArg, variableListFor }; +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/index.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/index.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/index.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/index.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/machine.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/machine.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/smoothscroll.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/timer.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/timer.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/utils.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/utils.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/es/rrweb/packages/types/dist/types.js b/node_modules/rrweb/es/rrweb/packages/types/dist/types.js +new file mode 100755 +index 0000000..12675ed +--- /dev/null ++++ b/node_modules/rrweb/es/rrweb/packages/types/dist/types.js +@@ -0,0 +1,71 @@ ++var EventType = /* @__PURE__ */ ((EventType2) => { ++ EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded"; ++ EventType2[EventType2["Load"] = 1] = "Load"; ++ EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot"; ++ EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot"; ++ EventType2[EventType2["Meta"] = 4] = "Meta"; ++ EventType2[EventType2["Custom"] = 5] = "Custom"; ++ EventType2[EventType2["Plugin"] = 6] = "Plugin"; ++ return EventType2; ++})(EventType || {}); ++var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => { ++ IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation"; ++ IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove"; ++ IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction"; ++ IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll"; ++ IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize"; ++ IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input"; ++ IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove"; ++ IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction"; ++ IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule"; ++ IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation"; ++ IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font"; ++ IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log"; ++ IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag"; ++ IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration"; ++ IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection"; ++ IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet"; ++ return IncrementalSource2; ++})(IncrementalSource || {}); ++var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => { ++ MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp"; ++ MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown"; ++ MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click"; ++ MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu"; ++ MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick"; ++ MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus"; ++ MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur"; ++ MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart"; ++ MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed"; ++ MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd"; ++ MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel"; ++ return MouseInteractions2; ++})(MouseInteractions || {}); ++var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => { ++ CanvasContext2[CanvasContext2["2D"] = 0] = "2D"; ++ CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL"; ++ CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2"; ++ return CanvasContext2; ++})(CanvasContext || {}); ++var ReplayerEvents = /* @__PURE__ */ ((ReplayerEvents2) => { ++ ReplayerEvents2["Start"] = "start"; ++ ReplayerEvents2["Pause"] = "pause"; ++ ReplayerEvents2["Resume"] = "resume"; ++ ReplayerEvents2["Resize"] = "resize"; ++ ReplayerEvents2["Finish"] = "finish"; ++ ReplayerEvents2["FullsnapshotRebuilded"] = "fullsnapshot-rebuilded"; ++ ReplayerEvents2["LoadStylesheetStart"] = "load-stylesheet-start"; ++ ReplayerEvents2["LoadStylesheetEnd"] = "load-stylesheet-end"; ++ ReplayerEvents2["SkipStart"] = "skip-start"; ++ ReplayerEvents2["SkipEnd"] = "skip-end"; ++ ReplayerEvents2["MouseInteraction"] = "mouse-interaction"; ++ ReplayerEvents2["EventCast"] = "event-cast"; ++ ReplayerEvents2["CustomEvent"] = "custom-event"; ++ ReplayerEvents2["Flush"] = "flush"; ++ ReplayerEvents2["StateChange"] = "state-change"; ++ ReplayerEvents2["PlayBack"] = "play-back"; ++ ReplayerEvents2["Destroy"] = "destroy"; ++ return ReplayerEvents2; ++})(ReplayerEvents || {}); ++ ++export { CanvasContext, EventType, IncrementalSource, MouseInteractions, ReplayerEvents }; +diff --git a/node_modules/rrweb/lib/plugins/canvas-webrtc-record.js b/node_modules/rrweb/lib/plugins/canvas-webrtc-record.js +new file mode 100755 +index 0000000..c71ccef +--- /dev/null ++++ b/node_modules/rrweb/lib/plugins/canvas-webrtc-record.js +@@ -0,0 +1,1403 @@ ++'use strict'; ++ ++Object.defineProperty(exports, '__esModule', { value: true }); ++ ++/*! simple-peer. MIT License. Feross Aboukhadijeh */ ++const MAX_BUFFERED_AMOUNT = 64 * 1024; ++const ICECOMPLETE_TIMEOUT = 5 * 1000; ++const CHANNEL_CLOSING_TIMEOUT = 5 * 1000; ++ ++function randombytes (size) { ++ const array = new Uint8Array(size); ++ for (let i = 0; i < size; i++) { ++ array[i] = (Math.random() * 256) | 0; ++ } ++ return array ++} ++ ++function getBrowserRTC () { ++ if (typeof globalThis === 'undefined') return null ++ const wrtc = { ++ RTCPeerConnection: ++ globalThis.RTCPeerConnection || ++ globalThis.mozRTCPeerConnection || ++ globalThis.webkitRTCPeerConnection, ++ RTCSessionDescription: ++ globalThis.RTCSessionDescription || ++ globalThis.mozRTCSessionDescription || ++ globalThis.webkitRTCSessionDescription, ++ RTCIceCandidate: ++ globalThis.RTCIceCandidate || ++ globalThis.mozRTCIceCandidate || ++ globalThis.webkitRTCIceCandidate ++ }; ++ if (!wrtc.RTCPeerConnection) return null ++ return wrtc ++} ++ ++function errCode (err, code) { ++ Object.defineProperty(err, 'code', { ++ value: code, ++ enumerable: true, ++ configurable: true ++ }); ++ return err ++} ++ ++// HACK: Filter trickle lines when trickle is disabled #354 ++function filterTrickle (sdp) { ++ return sdp.replace(/a=ice-options:trickle\s\n/g, '') ++} ++ ++function warn (message) { ++ console.warn(message); ++} ++ ++/** ++ * WebRTC peer connection. ++ * @param {Object} opts ++ */ ++class Peer { ++ constructor (opts = {}) { ++ this._map = new Map(); // for event emitter ++ ++ this._id = randombytes(4).toString('hex').slice(0, 7); ++ this._doDebug = opts.debug; ++ this._debug('new peer %o', opts); ++ ++ this.channelName = opts.initiator ++ ? opts.channelName || randombytes(20).toString('hex') ++ : null; ++ ++ this.initiator = opts.initiator || false; ++ this.channelConfig = opts.channelConfig || Peer.channelConfig; ++ this.channelNegotiated = this.channelConfig.negotiated; ++ this.config = Object.assign({}, Peer.config, opts.config); ++ this.offerOptions = opts.offerOptions || {}; ++ this.answerOptions = opts.answerOptions || {}; ++ this.sdpTransform = opts.sdpTransform || (sdp => sdp); ++ this.streams = opts.streams || (opts.stream ? [opts.stream] : []); // support old "stream" option ++ this.trickle = opts.trickle !== undefined ? opts.trickle : true; ++ this.allowHalfTrickle = ++ opts.allowHalfTrickle !== undefined ? opts.allowHalfTrickle : false; ++ this.iceCompleteTimeout = opts.iceCompleteTimeout || ICECOMPLETE_TIMEOUT; ++ ++ this.destroyed = false; ++ this.destroying = false; ++ this._connected = false; ++ ++ this.remoteAddress = undefined; ++ this.remoteFamily = undefined; ++ this.remotePort = undefined; ++ this.localAddress = undefined; ++ this.localFamily = undefined; ++ this.localPort = undefined; ++ ++ this._wrtc = ++ opts.wrtc && typeof opts.wrtc === 'object' ? opts.wrtc : getBrowserRTC(); ++ ++ if (!this._wrtc) { ++ if (typeof window === 'undefined') { ++ throw errCode( ++ new Error( ++ 'No WebRTC support: Specify `opts.wrtc` option in this environment' ++ ), ++ 'ERR_WEBRTC_SUPPORT' ++ ) ++ } else { ++ throw errCode( ++ new Error('No WebRTC support: Not a supported browser'), ++ 'ERR_WEBRTC_SUPPORT' ++ ) ++ } ++ } ++ ++ this._pcReady = false; ++ this._channelReady = false; ++ this._iceComplete = false; // ice candidate trickle done (got null candidate) ++ this._iceCompleteTimer = null; // send an offer/answer anyway after some timeout ++ this._channel = null; ++ this._pendingCandidates = []; ++ ++ this._isNegotiating = false; // is this peer waiting for negotiation to complete? ++ this._firstNegotiation = true; ++ this._batchedNegotiation = false; // batch synchronous negotiations ++ this._queuedNegotiation = false; // is there a queued negotiation request? ++ this._sendersAwaitingStable = []; ++ this._senderMap = new Map(); ++ this._closingInterval = null; ++ ++ this._remoteTracks = []; ++ this._remoteStreams = []; ++ ++ this._chunk = null; ++ this._cb = null; ++ this._interval = null; ++ ++ try { ++ this._pc = new this._wrtc.RTCPeerConnection(this.config); ++ } catch (err) { ++ this.destroy(errCode(err, 'ERR_PC_CONSTRUCTOR')); ++ return ++ } ++ ++ // We prefer feature detection whenever possible, but sometimes that's not ++ // possible for certain implementations. ++ this._isReactNativeWebrtc = typeof this._pc._peerConnectionId === 'number'; ++ ++ this._pc.oniceconnectionstatechange = () => { ++ this._onIceStateChange(); ++ }; ++ this._pc.onicegatheringstatechange = () => { ++ this._onIceStateChange(); ++ }; ++ this._pc.onconnectionstatechange = () => { ++ this._onConnectionStateChange(); ++ }; ++ this._pc.onsignalingstatechange = () => { ++ this._onSignalingStateChange(); ++ }; ++ this._pc.onicecandidate = event => { ++ this._onIceCandidate(event); ++ }; ++ ++ // HACK: Fix for odd Firefox behavior, see: https://github.com/feross/simple-peer/pull/783 ++ if (typeof this._pc.peerIdentity === 'object') { ++ this._pc.peerIdentity.catch(err => { ++ this.destroy(errCode(err, 'ERR_PC_PEER_IDENTITY')); ++ }); ++ } ++ ++ // Other spec events, unused by this implementation: ++ // - onconnectionstatechange ++ // - onicecandidateerror ++ // - onfingerprintfailure ++ // - onnegotiationneeded ++ ++ if (this.initiator || this.channelNegotiated) { ++ this._setupData({ ++ channel: this._pc.createDataChannel( ++ this.channelName, ++ this.channelConfig ++ ) ++ }); ++ } else { ++ this._pc.ondatachannel = event => { ++ this._setupData(event); ++ }; ++ } ++ ++ if (this.streams) { ++ this.streams.forEach(stream => { ++ this.addStream(stream); ++ }); ++ } ++ this._pc.ontrack = event => { ++ this._onTrack(event); ++ }; ++ ++ this._debug('initial negotiation'); ++ this._needsNegotiation(); ++ } ++ ++ get bufferSize () { ++ return (this._channel && this._channel.bufferedAmount) || 0 ++ } ++ ++ // HACK: it's possible channel.readyState is "closing" before peer.destroy() fires ++ // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 ++ get connected () { ++ return this._connected && this._channel.readyState === 'open' ++ } ++ ++ address () { ++ return { ++ port: this.localPort, ++ family: this.localFamily, ++ address: this.localAddress ++ } ++ } ++ ++ signal (data) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_DESTROYED') ++ if (typeof data === 'string') { ++ try { ++ data = JSON.parse(data); ++ } catch (err) { ++ data = {}; ++ } ++ } ++ this._debug('signal()'); ++ ++ if (data.renegotiate && this.initiator) { ++ this._debug('got request to renegotiate'); ++ this._needsNegotiation(); ++ } ++ if (data.transceiverRequest && this.initiator) { ++ this._debug('got request for transceiver'); ++ this.addTransceiver( ++ data.transceiverRequest.kind, ++ data.transceiverRequest.init ++ ); ++ } ++ if (data.candidate) { ++ if (this._pc.remoteDescription && this._pc.remoteDescription.type) { ++ this._addIceCandidate(data.candidate); ++ } else { ++ this._pendingCandidates.push(data.candidate); ++ } ++ } ++ if (data.sdp) { ++ this._pc ++ .setRemoteDescription(new this._wrtc.RTCSessionDescription(data)) ++ .then(() => { ++ if (this.destroyed) return ++ ++ this._pendingCandidates.forEach(candidate => { ++ this._addIceCandidate(candidate); ++ }); ++ this._pendingCandidates = []; ++ ++ if (this._pc.remoteDescription.type === 'offer') this._createAnswer(); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_SET_REMOTE_DESCRIPTION')); ++ }); ++ } ++ if ( ++ !data.sdp && ++ !data.candidate && ++ !data.renegotiate && ++ !data.transceiverRequest ++ ) { ++ this.destroy( ++ errCode( ++ new Error('signal() called with invalid signal data'), ++ 'ERR_SIGNALING' ++ ) ++ ); ++ } ++ } ++ ++ _addIceCandidate (candidate) { ++ const iceCandidateObj = new this._wrtc.RTCIceCandidate(candidate); ++ this._pc.addIceCandidate(iceCandidateObj).catch(err => { ++ if ( ++ !iceCandidateObj.address || ++ iceCandidateObj.address.endsWith('.local') ++ ) { ++ warn('Ignoring unsupported ICE candidate.'); ++ } else { ++ this.destroy(errCode(err, 'ERR_ADD_ICE_CANDIDATE')); ++ } ++ }); ++ } ++ ++ /** ++ * Send text/binary data to the remote peer. ++ * @param {ArrayBufferView|ArrayBuffer|string|Blob} chunk ++ */ ++ send (chunk) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot send after peer is destroyed'), 'ERR_DESTROYED') ++ this._channel.send(chunk); ++ } ++ ++ /** ++ * Add a Transceiver to the connection. ++ * @param {String} kind ++ * @param {Object} init ++ */ ++ addTransceiver (kind, init) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addTransceiver after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addTransceiver()'); ++ ++ if (this.initiator) { ++ try { ++ this._pc.addTransceiver(kind, init); ++ this._needsNegotiation(); ++ } catch (err) { ++ this.destroy(errCode(err, 'ERR_ADD_TRANSCEIVER')); ++ } ++ } else { ++ this.emit('signal', { ++ // request initiator to renegotiate ++ type: 'transceiverRequest', ++ transceiverRequest: { kind, init } ++ }); ++ } ++ } ++ ++ /** ++ * Add a MediaStream to the connection. ++ * @param {MediaStream} stream ++ */ ++ addStream (stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addStream after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addStream()'); ++ ++ stream.getTracks().forEach(track => { ++ this.addTrack(track, stream); ++ }); ++ } ++ ++ /** ++ * Add a MediaStreamTrack to the connection. ++ * @param {MediaStreamTrack} track ++ * @param {MediaStream} stream ++ */ ++ addTrack (track, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addTrack()'); ++ ++ const submap = this._senderMap.get(track) || new Map(); // nested Maps map [track, stream] to sender ++ let sender = submap.get(stream); ++ if (!sender) { ++ sender = this._pc.addTrack(track, stream); ++ submap.set(stream, sender); ++ this._senderMap.set(track, submap); ++ this._needsNegotiation(); ++ } else if (sender.removed) { ++ throw errCode( ++ new Error( ++ 'Track has been removed. You should enable/disable tracks that you want to re-add.' ++ ), ++ 'ERR_SENDER_REMOVED' ++ ) ++ } else { ++ throw errCode( ++ new Error('Track has already been added to that stream.'), ++ 'ERR_SENDER_ALREADY_ADDED' ++ ) ++ } ++ } ++ ++ /** ++ * Replace a MediaStreamTrack by another in the connection. ++ * @param {MediaStreamTrack} oldTrack ++ * @param {MediaStreamTrack} newTrack ++ * @param {MediaStream} stream ++ */ ++ replaceTrack (oldTrack, newTrack, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot replaceTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('replaceTrack()'); ++ ++ const submap = this._senderMap.get(oldTrack); ++ const sender = submap ? submap.get(stream) : null; ++ if (!sender) { ++ throw errCode( ++ new Error('Cannot replace track that was never added.'), ++ 'ERR_TRACK_NOT_ADDED' ++ ) ++ } ++ if (newTrack) this._senderMap.set(newTrack, submap); ++ ++ if (sender.replaceTrack != null) { ++ sender.replaceTrack(newTrack); ++ } else { ++ this.destroy( ++ errCode( ++ new Error('replaceTrack is not supported in this browser'), ++ 'ERR_UNSUPPORTED_REPLACETRACK' ++ ) ++ ); ++ } ++ } ++ ++ /** ++ * Remove a MediaStreamTrack from the connection. ++ * @param {MediaStreamTrack} track ++ * @param {MediaStream} stream ++ */ ++ removeTrack (track, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot removeTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('removeSender()'); ++ ++ const submap = this._senderMap.get(track); ++ const sender = submap ? submap.get(stream) : null; ++ if (!sender) { ++ throw errCode( ++ new Error('Cannot remove track that was never added.'), ++ 'ERR_TRACK_NOT_ADDED' ++ ) ++ } ++ try { ++ sender.removed = true; ++ this._pc.removeTrack(sender); ++ } catch (err) { ++ if (err.name === 'NS_ERROR_UNEXPECTED') { ++ this._sendersAwaitingStable.push(sender); // HACK: Firefox must wait until (signalingState === stable) https://bugzilla.mozilla.org/show_bug.cgi?id=1133874 ++ } else { ++ this.destroy(errCode(err, 'ERR_REMOVE_TRACK')); ++ } ++ } ++ this._needsNegotiation(); ++ } ++ ++ /** ++ * Remove a MediaStream from the connection. ++ * @param {MediaStream} stream ++ */ ++ removeStream (stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot removeStream after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('removeSenders()'); ++ ++ stream.getTracks().forEach(track => { ++ this.removeTrack(track, stream); ++ }); ++ } ++ ++ _needsNegotiation () { ++ this._debug('_needsNegotiation'); ++ if (this._batchedNegotiation) return // batch synchronous renegotiations ++ this._batchedNegotiation = true; ++ queueMicrotask(() => { ++ this._batchedNegotiation = false; ++ if (this.initiator || !this._firstNegotiation) { ++ this._debug('starting batched negotiation'); ++ this.negotiate(); ++ } else { ++ this._debug('non-initiator initial negotiation request discarded'); ++ } ++ this._firstNegotiation = false; ++ }); ++ } ++ ++ negotiate () { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot negotiate after peer is destroyed'), 'ERR_DESTROYED') ++ ++ if (this.initiator) { ++ if (this._isNegotiating) { ++ this._queuedNegotiation = true; ++ this._debug('already negotiating, queueing'); ++ } else { ++ this._debug('start negotiation'); ++ setTimeout(() => { ++ // HACK: Chrome crashes if we immediately call createOffer ++ this._createOffer(); ++ }, 0); ++ } ++ } else { ++ if (this._isNegotiating) { ++ this._queuedNegotiation = true; ++ this._debug('already negotiating, queueing'); ++ } else { ++ this._debug('requesting negotiation from initiator'); ++ this.emit('signal', { ++ // request initiator to renegotiate ++ type: 'renegotiate', ++ renegotiate: true ++ }); ++ } ++ } ++ this._isNegotiating = true; ++ } ++ ++ destroy (err) { ++ if (this.destroyed || this.destroying) return ++ this.destroying = true; ++ ++ this._debug('destroying (error: %s)', err && (err.message || err)); ++ ++ queueMicrotask(() => { ++ // allow events concurrent with the call to _destroy() to fire (see #692) ++ this.destroyed = true; ++ this.destroying = false; ++ ++ this._debug('destroy (error: %s)', err && (err.message || err)); ++ ++ this._connected = false; ++ this._pcReady = false; ++ this._channelReady = false; ++ this._remoteTracks = null; ++ this._remoteStreams = null; ++ this._senderMap = null; ++ ++ clearInterval(this._closingInterval); ++ this._closingInterval = null; ++ ++ clearInterval(this._interval); ++ this._interval = null; ++ this._chunk = null; ++ this._cb = null; ++ ++ if (this._channel) { ++ try { ++ this._channel.close(); ++ } catch (err) {} ++ ++ // allow events concurrent with destruction to be handled ++ this._channel.onmessage = null; ++ this._channel.onopen = null; ++ this._channel.onclose = null; ++ this._channel.onerror = null; ++ } ++ if (this._pc) { ++ try { ++ this._pc.close(); ++ } catch (err) {} ++ ++ // allow events concurrent with destruction to be handled ++ this._pc.oniceconnectionstatechange = null; ++ this._pc.onicegatheringstatechange = null; ++ this._pc.onsignalingstatechange = null; ++ this._pc.onicecandidate = null; ++ this._pc.ontrack = null; ++ this._pc.ondatachannel = null; ++ } ++ this._pc = null; ++ this._channel = null; ++ ++ if (err) this.emit('error', err); ++ this.emit('close'); ++ }); ++ } ++ ++ _setupData (event) { ++ if (!event.channel) { ++ // In some situations `pc.createDataChannel()` returns `undefined` (in wrtc), ++ // which is invalid behavior. Handle it gracefully. ++ // See: https://github.com/feross/simple-peer/issues/163 ++ return this.destroy( ++ errCode( ++ new Error('Data channel event is missing `channel` property'), ++ 'ERR_DATA_CHANNEL' ++ ) ++ ) ++ } ++ ++ this._channel = event.channel; ++ this._channel.binaryType = 'arraybuffer'; ++ ++ if (typeof this._channel.bufferedAmountLowThreshold === 'number') { ++ this._channel.bufferedAmountLowThreshold = MAX_BUFFERED_AMOUNT; ++ } ++ ++ this.channelName = this._channel.label; ++ ++ this._channel.onmessage = event => { ++ this._onChannelMessage(event); ++ }; ++ this._channel.onbufferedamountlow = () => { ++ this._onChannelBufferedAmountLow(); ++ }; ++ this._channel.onopen = () => { ++ this._onChannelOpen(); ++ }; ++ this._channel.onclose = () => { ++ this._onChannelClose(); ++ }; ++ this._channel.onerror = err => { ++ this.destroy(errCode(err, 'ERR_DATA_CHANNEL')); ++ }; ++ ++ // HACK: Chrome will sometimes get stuck in readyState "closing", let's check for this condition ++ // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 ++ let isClosing = false; ++ this._closingInterval = setInterval(() => { ++ // No "onclosing" event ++ if (this._channel && this._channel.readyState === 'closing') { ++ if (isClosing) this._onChannelClose(); // closing timed out: equivalent to onclose firing ++ isClosing = true; ++ } else { ++ isClosing = false; ++ } ++ }, CHANNEL_CLOSING_TIMEOUT); ++ } ++ ++ _startIceCompleteTimeout () { ++ if (this.destroyed) return ++ if (this._iceCompleteTimer) return ++ this._debug('started iceComplete timeout'); ++ this._iceCompleteTimer = setTimeout(() => { ++ if (!this._iceComplete) { ++ this._iceComplete = true; ++ this._debug('iceComplete timeout completed'); ++ this.emit('iceTimeout'); ++ this.emit('_iceComplete'); ++ } ++ }, this.iceCompleteTimeout); ++ } ++ ++ _createOffer () { ++ if (this.destroyed) return ++ ++ this._pc ++ .createOffer(this.offerOptions) ++ .then(offer => { ++ if (this.destroyed) return ++ if (!this.trickle && !this.allowHalfTrickle) { offer.sdp = filterTrickle(offer.sdp); } ++ offer.sdp = this.sdpTransform(offer.sdp); ++ ++ const sendOffer = () => { ++ if (this.destroyed) return ++ const signal = this._pc.localDescription || offer; ++ this._debug('signal'); ++ this.emit('signal', { ++ type: signal.type, ++ sdp: signal.sdp ++ }); ++ }; ++ ++ const onSuccess = () => { ++ this._debug('createOffer success'); ++ if (this.destroyed) return ++ if (this.trickle || this._iceComplete) sendOffer(); ++ else this.once('_iceComplete', sendOffer); // wait for candidates ++ }; ++ ++ const onError = err => { ++ this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION')); ++ }; ++ ++ this._pc.setLocalDescription(offer).then(onSuccess).catch(onError); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_CREATE_OFFER')); ++ }); ++ } ++ ++ _requestMissingTransceivers () { ++ if (this._pc.getTransceivers) { ++ this._pc.getTransceivers().forEach(transceiver => { ++ if ( ++ !transceiver.mid && ++ transceiver.sender.track && ++ !transceiver.requested ++ ) { ++ transceiver.requested = true; // HACK: Safari returns negotiated transceivers with a null mid ++ this.addTransceiver(transceiver.sender.track.kind); ++ } ++ }); ++ } ++ } ++ ++ _createAnswer () { ++ if (this.destroyed) return ++ ++ this._pc ++ .createAnswer(this.answerOptions) ++ .then(answer => { ++ if (this.destroyed) return ++ if (!this.trickle && !this.allowHalfTrickle) { answer.sdp = filterTrickle(answer.sdp); } ++ answer.sdp = this.sdpTransform(answer.sdp); ++ ++ const sendAnswer = () => { ++ if (this.destroyed) return ++ const signal = this._pc.localDescription || answer; ++ this._debug('signal'); ++ this.emit('signal', { ++ type: signal.type, ++ sdp: signal.sdp ++ }); ++ if (!this.initiator) this._requestMissingTransceivers(); ++ }; ++ ++ const onSuccess = () => { ++ if (this.destroyed) return ++ if (this.trickle || this._iceComplete) sendAnswer(); ++ else this.once('_iceComplete', sendAnswer); ++ }; ++ ++ const onError = err => { ++ this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION')); ++ }; ++ ++ this._pc.setLocalDescription(answer).then(onSuccess).catch(onError); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_CREATE_ANSWER')); ++ }); ++ } ++ ++ _onConnectionStateChange () { ++ if (this.destroyed) return ++ if (this._pc.connectionState === 'failed') { ++ this.destroy( ++ errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE') ++ ); ++ } ++ } ++ ++ _onIceStateChange () { ++ if (this.destroyed) return ++ const iceConnectionState = this._pc.iceConnectionState; ++ const iceGatheringState = this._pc.iceGatheringState; ++ ++ this._debug( ++ 'iceStateChange (connection: %s) (gathering: %s)', ++ iceConnectionState, ++ iceGatheringState ++ ); ++ this.emit('iceStateChange', iceConnectionState, iceGatheringState); ++ ++ if ( ++ iceConnectionState === 'connected' || ++ iceConnectionState === 'completed' ++ ) { ++ this._pcReady = true; ++ this._maybeReady(); ++ } ++ if (iceConnectionState === 'failed') { ++ this.destroy( ++ errCode( ++ new Error('Ice connection failed.'), ++ 'ERR_ICE_CONNECTION_FAILURE' ++ ) ++ ); ++ } ++ if (iceConnectionState === 'closed') { ++ this.destroy( ++ errCode( ++ new Error('Ice connection closed.'), ++ 'ERR_ICE_CONNECTION_CLOSED' ++ ) ++ ); ++ } ++ } ++ ++ getStats (cb) { ++ // statreports can come with a value array instead of properties ++ const flattenValues = report => { ++ if (Object.prototype.toString.call(report.values) === '[object Array]') { ++ report.values.forEach(value => { ++ Object.assign(report, value); ++ }); ++ } ++ return report ++ }; ++ ++ // Promise-based getStats() (standard) ++ if (this._pc.getStats.length === 0 || this._isReactNativeWebrtc) { ++ this._pc.getStats().then( ++ res => { ++ const reports = []; ++ res.forEach(report => { ++ reports.push(flattenValues(report)); ++ }); ++ cb(null, reports); ++ }, ++ err => cb(err) ++ ); ++ ++ // Single-parameter callback-based getStats() (non-standard) ++ } else if (this._pc.getStats.length > 0) { ++ this._pc.getStats( ++ res => { ++ // If we destroy connection in `connect` callback this code might happen to run when actual connection is already closed ++ if (this.destroyed) return ++ ++ const reports = []; ++ res.result().forEach(result => { ++ const report = {}; ++ result.names().forEach(name => { ++ report[name] = result.stat(name); ++ }); ++ report.id = result.id; ++ report.type = result.type; ++ report.timestamp = result.timestamp; ++ reports.push(flattenValues(report)); ++ }); ++ cb(null, reports); ++ }, ++ err => cb(err) ++ ); ++ ++ // Unknown browser, skip getStats() since it's anyone's guess which style of ++ // getStats() they implement. ++ } else { ++ cb(null, []); ++ } ++ } ++ ++ _maybeReady () { ++ this._debug( ++ 'maybeReady pc %s channel %s', ++ this._pcReady, ++ this._channelReady ++ ); ++ if ( ++ this._connected || ++ this._connecting || ++ !this._pcReady || ++ !this._channelReady ++ ) { return } ++ ++ this._connecting = true; ++ ++ // HACK: We can't rely on order here, for details see https://github.com/js-platform/node-webrtc/issues/339 ++ const findCandidatePair = () => { ++ if (this.destroyed) return ++ ++ this.getStats((err, items) => { ++ if (this.destroyed) return ++ ++ // Treat getStats error as non-fatal. It's not essential. ++ if (err) items = []; ++ ++ const remoteCandidates = {}; ++ const localCandidates = {}; ++ const candidatePairs = {}; ++ let foundSelectedCandidatePair = false; ++ ++ items.forEach(item => { ++ // TODO: Once all browsers support the hyphenated stats report types, remove ++ // the non-hypenated ones ++ if ( ++ item.type === 'remotecandidate' || ++ item.type === 'remote-candidate' ++ ) { ++ remoteCandidates[item.id] = item; ++ } ++ if ( ++ item.type === 'localcandidate' || ++ item.type === 'local-candidate' ++ ) { ++ localCandidates[item.id] = item; ++ } ++ if (item.type === 'candidatepair' || item.type === 'candidate-pair') { ++ candidatePairs[item.id] = item; ++ } ++ }); ++ ++ const setSelectedCandidatePair = selectedCandidatePair => { ++ foundSelectedCandidatePair = true; ++ ++ let local = localCandidates[selectedCandidatePair.localCandidateId]; ++ ++ if (local && (local.ip || local.address)) { ++ // Spec ++ this.localAddress = local.ip || local.address; ++ this.localPort = Number(local.port); ++ } else if (local && local.ipAddress) { ++ // Firefox ++ this.localAddress = local.ipAddress; ++ this.localPort = Number(local.portNumber); ++ } else if ( ++ typeof selectedCandidatePair.googLocalAddress === 'string' ++ ) { ++ // TODO: remove this once Chrome 58 is released ++ local = selectedCandidatePair.googLocalAddress.split(':'); ++ this.localAddress = local[0]; ++ this.localPort = Number(local[1]); ++ } ++ if (this.localAddress) { ++ this.localFamily = this.localAddress.includes(':') ++ ? 'IPv6' ++ : 'IPv4'; ++ } ++ ++ let remote = ++ remoteCandidates[selectedCandidatePair.remoteCandidateId]; ++ ++ if (remote && (remote.ip || remote.address)) { ++ // Spec ++ this.remoteAddress = remote.ip || remote.address; ++ this.remotePort = Number(remote.port); ++ } else if (remote && remote.ipAddress) { ++ // Firefox ++ this.remoteAddress = remote.ipAddress; ++ this.remotePort = Number(remote.portNumber); ++ } else if ( ++ typeof selectedCandidatePair.googRemoteAddress === 'string' ++ ) { ++ // TODO: remove this once Chrome 58 is released ++ remote = selectedCandidatePair.googRemoteAddress.split(':'); ++ this.remoteAddress = remote[0]; ++ this.remotePort = Number(remote[1]); ++ } ++ if (this.remoteAddress) { ++ this.remoteFamily = this.remoteAddress.includes(':') ++ ? 'IPv6' ++ : 'IPv4'; ++ } ++ ++ this._debug( ++ 'connect local: %s:%s remote: %s:%s', ++ this.localAddress, ++ this.localPort, ++ this.remoteAddress, ++ this.remotePort ++ ); ++ }; ++ ++ items.forEach(item => { ++ // Spec-compliant ++ if (item.type === 'transport' && item.selectedCandidatePairId) { ++ setSelectedCandidatePair( ++ candidatePairs[item.selectedCandidatePairId] ++ ); ++ } ++ ++ // Old implementations ++ if ( ++ (item.type === 'googCandidatePair' && ++ item.googActiveConnection === 'true') || ++ ((item.type === 'candidatepair' || ++ item.type === 'candidate-pair') && ++ item.selected) ++ ) { ++ setSelectedCandidatePair(item); ++ } ++ }); ++ ++ // Ignore candidate pair selection in browsers like Safari 11 that do not have any local or remote candidates ++ // But wait until at least 1 candidate pair is available ++ if ( ++ !foundSelectedCandidatePair && ++ (!Object.keys(candidatePairs).length || ++ Object.keys(localCandidates).length) ++ ) { ++ setTimeout(findCandidatePair, 100); ++ return ++ } else { ++ this._connecting = false; ++ this._connected = true; ++ } ++ ++ if (this._chunk) { ++ try { ++ this.send(this._chunk); ++ } catch (err) { ++ return this.destroy(errCode(err, 'ERR_DATA_CHANNEL')) ++ } ++ this._chunk = null; ++ this._debug('sent chunk from "write before connect"'); ++ ++ const cb = this._cb; ++ this._cb = null; ++ cb(null); ++ } ++ ++ // If `bufferedAmountLowThreshold` and 'onbufferedamountlow' are unsupported, ++ // fallback to using setInterval to implement backpressure. ++ if (typeof this._channel.bufferedAmountLowThreshold !== 'number') { ++ this._interval = setInterval(() => this._onInterval(), 150); ++ if (this._interval.unref) this._interval.unref(); ++ } ++ ++ this._debug('connect'); ++ this.emit('connect'); ++ }); ++ }; ++ findCandidatePair(); ++ } ++ ++ _onInterval () { ++ if ( ++ !this._cb || ++ !this._channel || ++ this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT ++ ) { ++ return ++ } ++ this._onChannelBufferedAmountLow(); ++ } ++ ++ _onSignalingStateChange () { ++ if (this.destroyed) return ++ ++ if (this._pc.signalingState === 'stable') { ++ this._isNegotiating = false; ++ ++ // HACK: Firefox doesn't yet support removing tracks when signalingState !== 'stable' ++ this._debug('flushing sender queue', this._sendersAwaitingStable); ++ this._sendersAwaitingStable.forEach(sender => { ++ this._pc.removeTrack(sender); ++ this._queuedNegotiation = true; ++ }); ++ this._sendersAwaitingStable = []; ++ ++ if (this._queuedNegotiation) { ++ this._debug('flushing negotiation queue'); ++ this._queuedNegotiation = false; ++ this._needsNegotiation(); // negotiate again ++ } else { ++ this._debug('negotiated'); ++ this.emit('negotiated'); ++ } ++ } ++ ++ this._debug('signalingStateChange %s', this._pc.signalingState); ++ this.emit('signalingStateChange', this._pc.signalingState); ++ } ++ ++ _onIceCandidate (event) { ++ if (this.destroyed) return ++ if (event.candidate && this.trickle) { ++ this.emit('signal', { ++ type: 'candidate', ++ candidate: { ++ candidate: event.candidate.candidate, ++ sdpMLineIndex: event.candidate.sdpMLineIndex, ++ sdpMid: event.candidate.sdpMid ++ } ++ }); ++ } else if (!event.candidate && !this._iceComplete) { ++ this._iceComplete = true; ++ this.emit('_iceComplete'); ++ } ++ // as soon as we've received one valid candidate start timeout ++ if (event.candidate) { ++ this._startIceCompleteTimeout(); ++ } ++ } ++ ++ _onChannelMessage (event) { ++ if (this.destroyed) return ++ let data = event.data; ++ if (data instanceof ArrayBuffer) data = new Uint8Array(data); ++ this.emit('data', data); ++ } ++ ++ _onChannelBufferedAmountLow () { ++ if (this.destroyed || !this._cb) return ++ this._debug( ++ 'ending backpressure: bufferedAmount %d', ++ this._channel.bufferedAmount ++ ); ++ const cb = this._cb; ++ this._cb = null; ++ cb(null); ++ } ++ ++ _onChannelOpen () { ++ if (this._connected || this.destroyed) return ++ this._debug('on channel open'); ++ this._channelReady = true; ++ this._maybeReady(); ++ } ++ ++ _onChannelClose () { ++ if (this.destroyed) return ++ this._debug('on channel close'); ++ this.destroy(); ++ } ++ ++ _onTrack (event) { ++ if (this.destroyed) return ++ ++ event.streams.forEach(eventStream => { ++ this._debug('on track'); ++ this.emit('track', event.track, eventStream); ++ ++ this._remoteTracks.push({ ++ track: event.track, ++ stream: eventStream ++ }); ++ ++ if ( ++ this._remoteStreams.some(remoteStream => { ++ return remoteStream.id === eventStream.id ++ }) ++ ) { return } // Only fire one 'stream' event, even though there may be multiple tracks per stream ++ ++ this._remoteStreams.push(eventStream); ++ queueMicrotask(() => { ++ this._debug('on stream'); ++ this.emit('stream', eventStream); // ensure all tracks have been added ++ }); ++ }); ++ } ++ ++ _debug (...args) { ++ if (!this._doDebug) return ++ args[0] = '[' + this._id + '] ' + args[0]; ++ console.log(...args); ++ } ++ ++ // event emitter ++ on (key, listener) { ++ const map = this._map; ++ if (!map.has(key)) map.set(key, new Set()); ++ map.get(key).add(listener); ++ } ++ ++ off (key, listener) { ++ const map = this._map; ++ const listeners = map.get(key); ++ if (!listeners) return ++ listeners.delete(listener); ++ if (listeners.size === 0) map.delete(key); ++ } ++ ++ once (key, listener) { ++ const listener_ = (...args) => { ++ this.off(key, listener_); ++ listener(...args); ++ }; ++ this.on(key, listener_); ++ } ++ ++ emit (key, ...args) { ++ const map = this._map; ++ if (!map.has(key)) return ++ for (const listener of map.get(key)) { ++ try { ++ listener(...args); ++ } catch (err) { ++ console.error(err); ++ } ++ } ++ } ++} ++ ++Peer.WEBRTC_SUPPORT = !!getBrowserRTC(); ++ ++/** ++ * Expose peer and data channel config for overriding all Peer ++ * instances. Otherwise, just set opts.config or opts.channelConfig ++ * when constructing a Peer. ++ */ ++Peer.config = { ++ iceServers: [ ++ { ++ urls: [ ++ 'stun:stun.l.google.com:19302', ++ 'stun:global.stun.twilio.com:3478' ++ ] ++ } ++ ], ++ sdpSemantics: 'unified-plan' ++}; ++ ++Peer.channelConfig = {}; ++ ++const PLUGIN_NAME = 'rrweb/canvas-webrtc@1'; ++class RRWebPluginCanvasWebRTCRecord { ++ constructor({ signalSendCallback, peer, }) { ++ this.peer = null; ++ this.streamMap = new Map(); ++ this.incomingStreams = new Set(); ++ this.outgoingStreams = new Set(); ++ this.streamNodeMap = new Map(); ++ this.canvasWindowMap = new Map(); ++ this.windowPeerMap = new WeakMap(); ++ this.peerWindowMap = new WeakMap(); ++ this.signalSendCallback = signalSendCallback; ++ window.addEventListener('message', this.windowPostMessageHandler.bind(this)); ++ if (peer) ++ this.peer = peer; ++ } ++ initPlugin() { ++ return { ++ name: PLUGIN_NAME, ++ getMirror: ({ nodeMirror, crossOriginIframeMirror }) => { ++ this.mirror = nodeMirror; ++ this.crossOriginIframeMirror = crossOriginIframeMirror; ++ }, ++ options: {}, ++ }; ++ } ++ signalReceive(signal) { ++ var _a; ++ if (!this.peer) ++ this.setupPeer(); ++ (_a = this.peer) === null || _a === void 0 ? void 0 : _a.signal(signal); ++ } ++ signalReceiveFromCrossOriginIframe(signal, source) { ++ const peer = this.setupPeer(source); ++ peer.signal(signal); ++ } ++ startStream(id, stream) { ++ var _a, _b; ++ if (!this.peer) ++ this.setupPeer(); ++ const data = { ++ nodeId: id, ++ streamId: stream.id, ++ }; ++ (_a = this.peer) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(data)); ++ if (!this.outgoingStreams.has(stream)) ++ (_b = this.peer) === null || _b === void 0 ? void 0 : _b.addStream(stream); ++ this.outgoingStreams.add(stream); ++ } ++ setupPeer(source) { ++ let peer; ++ if (!source) { ++ if (this.peer) ++ return this.peer; ++ peer = this.peer = new Peer({ ++ initiator: true, ++ }); ++ } ++ else { ++ const peerFromMap = this.windowPeerMap.get(source); ++ if (peerFromMap) ++ return peerFromMap; ++ peer = new Peer({ ++ initiator: false, ++ }); ++ this.windowPeerMap.set(source, peer); ++ this.peerWindowMap.set(peer, source); ++ } ++ const resetPeer = (source) => { ++ if (!source) ++ return (this.peer = null); ++ this.windowPeerMap.delete(source); ++ this.peerWindowMap.delete(peer); ++ }; ++ peer.on('error', (err) => { ++ resetPeer(source); ++ console.log('error', err); ++ }); ++ peer.on('close', () => { ++ resetPeer(source); ++ console.log('closing'); ++ }); ++ peer.on('signal', (data) => { ++ var _a, _b; ++ if (this.inRootFrame()) { ++ if (peer === this.peer) { ++ this.signalSendCallback(data); ++ } ++ else { ++ (_a = this.peerWindowMap.get(peer)) === null || _a === void 0 ? void 0 : _a.postMessage({ ++ type: 'rrweb-canvas-webrtc', ++ data: { ++ type: 'signal', ++ signal: data, ++ }, ++ }, '*'); ++ } ++ } ++ else { ++ (_b = window.top) === null || _b === void 0 ? void 0 : _b.postMessage({ ++ type: 'rrweb-canvas-webrtc', ++ data: { ++ type: 'signal', ++ signal: data, ++ }, ++ }, '*'); ++ } ++ }); ++ peer.on('connect', () => { ++ if (this.inRootFrame() && peer !== this.peer) ++ return; ++ for (const [id, stream] of this.streamMap) { ++ this.startStream(id, stream); ++ } ++ }); ++ if (!this.inRootFrame()) ++ return peer; ++ peer.on('data', (data) => { ++ try { ++ const json = JSON.parse(data); ++ this.streamNodeMap.set(json.streamId, json.nodeId); ++ } ++ catch (error) { ++ console.error('Could not parse data', error); ++ } ++ this.flushStreams(); ++ }); ++ peer.on('stream', (stream) => { ++ this.incomingStreams.add(stream); ++ this.flushStreams(); ++ }); ++ return peer; ++ } ++ setupStream(id, rootId) { ++ var _a; ++ if (id === -1) ++ return false; ++ let stream = this.streamMap.get(rootId || id); ++ if (stream) ++ return stream; ++ const el = this.mirror.getNode(id); ++ if (!el || !('captureStream' in el)) ++ return this.setupStreamInCrossOriginIframe(id, rootId || id); ++ if (!this.inRootFrame()) { ++ (_a = window.top) === null || _a === void 0 ? void 0 : _a.postMessage({ ++ type: 'rrweb-canvas-webrtc', ++ data: { ++ type: 'i-have-canvas', ++ rootId: rootId || id, ++ }, ++ }, '*'); ++ } ++ stream = el.captureStream(); ++ this.streamMap.set(rootId || id, stream); ++ this.setupPeer(); ++ return stream; ++ } ++ flushStreams() { ++ this.incomingStreams.forEach((stream) => { ++ const nodeId = this.streamNodeMap.get(stream.id); ++ if (!nodeId) ++ return; ++ this.startStream(nodeId, stream); ++ }); ++ } ++ inRootFrame() { ++ return Boolean(window.top && window.top === window); ++ } ++ setupStreamInCrossOriginIframe(id, rootId) { ++ let found = false; ++ document.querySelectorAll('iframe').forEach((iframe) => { ++ var _a; ++ if (found) ++ return; ++ const remoteId = this.crossOriginIframeMirror.getRemoteId(iframe, id); ++ if (remoteId === -1) ++ return; ++ found = true; ++ (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage({ ++ type: 'rrweb-canvas-webrtc', ++ data: { ++ type: 'who-has-canvas', ++ id: remoteId, ++ rootId, ++ }, ++ }, '*'); ++ }); ++ return found; ++ } ++ isCrossOriginIframeMessageEventContent(event) { ++ return Boolean(event.data && ++ typeof event.data === 'object' && ++ 'type' in event.data && ++ 'data' in event.data && ++ event.data.type === ++ 'rrweb-canvas-webrtc' && ++ event.data.data); ++ } ++ windowPostMessageHandler(event) { ++ if (!this.isCrossOriginIframeMessageEventContent(event)) ++ return; ++ const { type } = event.data.data; ++ if (type === 'who-has-canvas') { ++ const { id, rootId } = event.data.data; ++ this.setupStream(id, rootId); ++ } ++ else if (type === 'signal') { ++ const { signal } = event.data.data; ++ const { source } = event; ++ if (!source || !('self' in source)) ++ return; ++ if (this.inRootFrame()) { ++ this.signalReceiveFromCrossOriginIframe(signal, source); ++ } ++ else { ++ this.signalReceive(signal); ++ } ++ } ++ else if (type === 'i-have-canvas') { ++ const { rootId } = event.data.data; ++ const { source } = event; ++ if (!source || !('self' in source)) ++ return; ++ this.canvasWindowMap.set(rootId, source); ++ } ++ } ++} ++ ++exports.PLUGIN_NAME = PLUGIN_NAME; ++exports.RRWebPluginCanvasWebRTCRecord = RRWebPluginCanvasWebRTCRecord; +diff --git a/node_modules/rrweb/lib/plugins/canvas-webrtc-replay.js b/node_modules/rrweb/lib/plugins/canvas-webrtc-replay.js +new file mode 100755 +index 0000000..6381199 +--- /dev/null ++++ b/node_modules/rrweb/lib/plugins/canvas-webrtc-replay.js +@@ -0,0 +1,1290 @@ ++'use strict'; ++ ++Object.defineProperty(exports, '__esModule', { value: true }); ++ ++/*! simple-peer. MIT License. Feross Aboukhadijeh */ ++const MAX_BUFFERED_AMOUNT = 64 * 1024; ++const ICECOMPLETE_TIMEOUT = 5 * 1000; ++const CHANNEL_CLOSING_TIMEOUT = 5 * 1000; ++ ++function randombytes (size) { ++ const array = new Uint8Array(size); ++ for (let i = 0; i < size; i++) { ++ array[i] = (Math.random() * 256) | 0; ++ } ++ return array ++} ++ ++function getBrowserRTC () { ++ if (typeof globalThis === 'undefined') return null ++ const wrtc = { ++ RTCPeerConnection: ++ globalThis.RTCPeerConnection || ++ globalThis.mozRTCPeerConnection || ++ globalThis.webkitRTCPeerConnection, ++ RTCSessionDescription: ++ globalThis.RTCSessionDescription || ++ globalThis.mozRTCSessionDescription || ++ globalThis.webkitRTCSessionDescription, ++ RTCIceCandidate: ++ globalThis.RTCIceCandidate || ++ globalThis.mozRTCIceCandidate || ++ globalThis.webkitRTCIceCandidate ++ }; ++ if (!wrtc.RTCPeerConnection) return null ++ return wrtc ++} ++ ++function errCode (err, code) { ++ Object.defineProperty(err, 'code', { ++ value: code, ++ enumerable: true, ++ configurable: true ++ }); ++ return err ++} ++ ++// HACK: Filter trickle lines when trickle is disabled #354 ++function filterTrickle (sdp) { ++ return sdp.replace(/a=ice-options:trickle\s\n/g, '') ++} ++ ++function warn (message) { ++ console.warn(message); ++} ++ ++/** ++ * WebRTC peer connection. ++ * @param {Object} opts ++ */ ++class Peer { ++ constructor (opts = {}) { ++ this._map = new Map(); // for event emitter ++ ++ this._id = randombytes(4).toString('hex').slice(0, 7); ++ this._doDebug = opts.debug; ++ this._debug('new peer %o', opts); ++ ++ this.channelName = opts.initiator ++ ? opts.channelName || randombytes(20).toString('hex') ++ : null; ++ ++ this.initiator = opts.initiator || false; ++ this.channelConfig = opts.channelConfig || Peer.channelConfig; ++ this.channelNegotiated = this.channelConfig.negotiated; ++ this.config = Object.assign({}, Peer.config, opts.config); ++ this.offerOptions = opts.offerOptions || {}; ++ this.answerOptions = opts.answerOptions || {}; ++ this.sdpTransform = opts.sdpTransform || (sdp => sdp); ++ this.streams = opts.streams || (opts.stream ? [opts.stream] : []); // support old "stream" option ++ this.trickle = opts.trickle !== undefined ? opts.trickle : true; ++ this.allowHalfTrickle = ++ opts.allowHalfTrickle !== undefined ? opts.allowHalfTrickle : false; ++ this.iceCompleteTimeout = opts.iceCompleteTimeout || ICECOMPLETE_TIMEOUT; ++ ++ this.destroyed = false; ++ this.destroying = false; ++ this._connected = false; ++ ++ this.remoteAddress = undefined; ++ this.remoteFamily = undefined; ++ this.remotePort = undefined; ++ this.localAddress = undefined; ++ this.localFamily = undefined; ++ this.localPort = undefined; ++ ++ this._wrtc = ++ opts.wrtc && typeof opts.wrtc === 'object' ? opts.wrtc : getBrowserRTC(); ++ ++ if (!this._wrtc) { ++ if (typeof window === 'undefined') { ++ throw errCode( ++ new Error( ++ 'No WebRTC support: Specify `opts.wrtc` option in this environment' ++ ), ++ 'ERR_WEBRTC_SUPPORT' ++ ) ++ } else { ++ throw errCode( ++ new Error('No WebRTC support: Not a supported browser'), ++ 'ERR_WEBRTC_SUPPORT' ++ ) ++ } ++ } ++ ++ this._pcReady = false; ++ this._channelReady = false; ++ this._iceComplete = false; // ice candidate trickle done (got null candidate) ++ this._iceCompleteTimer = null; // send an offer/answer anyway after some timeout ++ this._channel = null; ++ this._pendingCandidates = []; ++ ++ this._isNegotiating = false; // is this peer waiting for negotiation to complete? ++ this._firstNegotiation = true; ++ this._batchedNegotiation = false; // batch synchronous negotiations ++ this._queuedNegotiation = false; // is there a queued negotiation request? ++ this._sendersAwaitingStable = []; ++ this._senderMap = new Map(); ++ this._closingInterval = null; ++ ++ this._remoteTracks = []; ++ this._remoteStreams = []; ++ ++ this._chunk = null; ++ this._cb = null; ++ this._interval = null; ++ ++ try { ++ this._pc = new this._wrtc.RTCPeerConnection(this.config); ++ } catch (err) { ++ this.destroy(errCode(err, 'ERR_PC_CONSTRUCTOR')); ++ return ++ } ++ ++ // We prefer feature detection whenever possible, but sometimes that's not ++ // possible for certain implementations. ++ this._isReactNativeWebrtc = typeof this._pc._peerConnectionId === 'number'; ++ ++ this._pc.oniceconnectionstatechange = () => { ++ this._onIceStateChange(); ++ }; ++ this._pc.onicegatheringstatechange = () => { ++ this._onIceStateChange(); ++ }; ++ this._pc.onconnectionstatechange = () => { ++ this._onConnectionStateChange(); ++ }; ++ this._pc.onsignalingstatechange = () => { ++ this._onSignalingStateChange(); ++ }; ++ this._pc.onicecandidate = event => { ++ this._onIceCandidate(event); ++ }; ++ ++ // HACK: Fix for odd Firefox behavior, see: https://github.com/feross/simple-peer/pull/783 ++ if (typeof this._pc.peerIdentity === 'object') { ++ this._pc.peerIdentity.catch(err => { ++ this.destroy(errCode(err, 'ERR_PC_PEER_IDENTITY')); ++ }); ++ } ++ ++ // Other spec events, unused by this implementation: ++ // - onconnectionstatechange ++ // - onicecandidateerror ++ // - onfingerprintfailure ++ // - onnegotiationneeded ++ ++ if (this.initiator || this.channelNegotiated) { ++ this._setupData({ ++ channel: this._pc.createDataChannel( ++ this.channelName, ++ this.channelConfig ++ ) ++ }); ++ } else { ++ this._pc.ondatachannel = event => { ++ this._setupData(event); ++ }; ++ } ++ ++ if (this.streams) { ++ this.streams.forEach(stream => { ++ this.addStream(stream); ++ }); ++ } ++ this._pc.ontrack = event => { ++ this._onTrack(event); ++ }; ++ ++ this._debug('initial negotiation'); ++ this._needsNegotiation(); ++ } ++ ++ get bufferSize () { ++ return (this._channel && this._channel.bufferedAmount) || 0 ++ } ++ ++ // HACK: it's possible channel.readyState is "closing" before peer.destroy() fires ++ // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 ++ get connected () { ++ return this._connected && this._channel.readyState === 'open' ++ } ++ ++ address () { ++ return { ++ port: this.localPort, ++ family: this.localFamily, ++ address: this.localAddress ++ } ++ } ++ ++ signal (data) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_DESTROYED') ++ if (typeof data === 'string') { ++ try { ++ data = JSON.parse(data); ++ } catch (err) { ++ data = {}; ++ } ++ } ++ this._debug('signal()'); ++ ++ if (data.renegotiate && this.initiator) { ++ this._debug('got request to renegotiate'); ++ this._needsNegotiation(); ++ } ++ if (data.transceiverRequest && this.initiator) { ++ this._debug('got request for transceiver'); ++ this.addTransceiver( ++ data.transceiverRequest.kind, ++ data.transceiverRequest.init ++ ); ++ } ++ if (data.candidate) { ++ if (this._pc.remoteDescription && this._pc.remoteDescription.type) { ++ this._addIceCandidate(data.candidate); ++ } else { ++ this._pendingCandidates.push(data.candidate); ++ } ++ } ++ if (data.sdp) { ++ this._pc ++ .setRemoteDescription(new this._wrtc.RTCSessionDescription(data)) ++ .then(() => { ++ if (this.destroyed) return ++ ++ this._pendingCandidates.forEach(candidate => { ++ this._addIceCandidate(candidate); ++ }); ++ this._pendingCandidates = []; ++ ++ if (this._pc.remoteDescription.type === 'offer') this._createAnswer(); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_SET_REMOTE_DESCRIPTION')); ++ }); ++ } ++ if ( ++ !data.sdp && ++ !data.candidate && ++ !data.renegotiate && ++ !data.transceiverRequest ++ ) { ++ this.destroy( ++ errCode( ++ new Error('signal() called with invalid signal data'), ++ 'ERR_SIGNALING' ++ ) ++ ); ++ } ++ } ++ ++ _addIceCandidate (candidate) { ++ const iceCandidateObj = new this._wrtc.RTCIceCandidate(candidate); ++ this._pc.addIceCandidate(iceCandidateObj).catch(err => { ++ if ( ++ !iceCandidateObj.address || ++ iceCandidateObj.address.endsWith('.local') ++ ) { ++ warn('Ignoring unsupported ICE candidate.'); ++ } else { ++ this.destroy(errCode(err, 'ERR_ADD_ICE_CANDIDATE')); ++ } ++ }); ++ } ++ ++ /** ++ * Send text/binary data to the remote peer. ++ * @param {ArrayBufferView|ArrayBuffer|string|Blob} chunk ++ */ ++ send (chunk) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot send after peer is destroyed'), 'ERR_DESTROYED') ++ this._channel.send(chunk); ++ } ++ ++ /** ++ * Add a Transceiver to the connection. ++ * @param {String} kind ++ * @param {Object} init ++ */ ++ addTransceiver (kind, init) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addTransceiver after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addTransceiver()'); ++ ++ if (this.initiator) { ++ try { ++ this._pc.addTransceiver(kind, init); ++ this._needsNegotiation(); ++ } catch (err) { ++ this.destroy(errCode(err, 'ERR_ADD_TRANSCEIVER')); ++ } ++ } else { ++ this.emit('signal', { ++ // request initiator to renegotiate ++ type: 'transceiverRequest', ++ transceiverRequest: { kind, init } ++ }); ++ } ++ } ++ ++ /** ++ * Add a MediaStream to the connection. ++ * @param {MediaStream} stream ++ */ ++ addStream (stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addStream after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addStream()'); ++ ++ stream.getTracks().forEach(track => { ++ this.addTrack(track, stream); ++ }); ++ } ++ ++ /** ++ * Add a MediaStreamTrack to the connection. ++ * @param {MediaStreamTrack} track ++ * @param {MediaStream} stream ++ */ ++ addTrack (track, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot addTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('addTrack()'); ++ ++ const submap = this._senderMap.get(track) || new Map(); // nested Maps map [track, stream] to sender ++ let sender = submap.get(stream); ++ if (!sender) { ++ sender = this._pc.addTrack(track, stream); ++ submap.set(stream, sender); ++ this._senderMap.set(track, submap); ++ this._needsNegotiation(); ++ } else if (sender.removed) { ++ throw errCode( ++ new Error( ++ 'Track has been removed. You should enable/disable tracks that you want to re-add.' ++ ), ++ 'ERR_SENDER_REMOVED' ++ ) ++ } else { ++ throw errCode( ++ new Error('Track has already been added to that stream.'), ++ 'ERR_SENDER_ALREADY_ADDED' ++ ) ++ } ++ } ++ ++ /** ++ * Replace a MediaStreamTrack by another in the connection. ++ * @param {MediaStreamTrack} oldTrack ++ * @param {MediaStreamTrack} newTrack ++ * @param {MediaStream} stream ++ */ ++ replaceTrack (oldTrack, newTrack, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot replaceTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('replaceTrack()'); ++ ++ const submap = this._senderMap.get(oldTrack); ++ const sender = submap ? submap.get(stream) : null; ++ if (!sender) { ++ throw errCode( ++ new Error('Cannot replace track that was never added.'), ++ 'ERR_TRACK_NOT_ADDED' ++ ) ++ } ++ if (newTrack) this._senderMap.set(newTrack, submap); ++ ++ if (sender.replaceTrack != null) { ++ sender.replaceTrack(newTrack); ++ } else { ++ this.destroy( ++ errCode( ++ new Error('replaceTrack is not supported in this browser'), ++ 'ERR_UNSUPPORTED_REPLACETRACK' ++ ) ++ ); ++ } ++ } ++ ++ /** ++ * Remove a MediaStreamTrack from the connection. ++ * @param {MediaStreamTrack} track ++ * @param {MediaStream} stream ++ */ ++ removeTrack (track, stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot removeTrack after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('removeSender()'); ++ ++ const submap = this._senderMap.get(track); ++ const sender = submap ? submap.get(stream) : null; ++ if (!sender) { ++ throw errCode( ++ new Error('Cannot remove track that was never added.'), ++ 'ERR_TRACK_NOT_ADDED' ++ ) ++ } ++ try { ++ sender.removed = true; ++ this._pc.removeTrack(sender); ++ } catch (err) { ++ if (err.name === 'NS_ERROR_UNEXPECTED') { ++ this._sendersAwaitingStable.push(sender); // HACK: Firefox must wait until (signalingState === stable) https://bugzilla.mozilla.org/show_bug.cgi?id=1133874 ++ } else { ++ this.destroy(errCode(err, 'ERR_REMOVE_TRACK')); ++ } ++ } ++ this._needsNegotiation(); ++ } ++ ++ /** ++ * Remove a MediaStream from the connection. ++ * @param {MediaStream} stream ++ */ ++ removeStream (stream) { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot removeStream after peer is destroyed'), 'ERR_DESTROYED') ++ this._debug('removeSenders()'); ++ ++ stream.getTracks().forEach(track => { ++ this.removeTrack(track, stream); ++ }); ++ } ++ ++ _needsNegotiation () { ++ this._debug('_needsNegotiation'); ++ if (this._batchedNegotiation) return // batch synchronous renegotiations ++ this._batchedNegotiation = true; ++ queueMicrotask(() => { ++ this._batchedNegotiation = false; ++ if (this.initiator || !this._firstNegotiation) { ++ this._debug('starting batched negotiation'); ++ this.negotiate(); ++ } else { ++ this._debug('non-initiator initial negotiation request discarded'); ++ } ++ this._firstNegotiation = false; ++ }); ++ } ++ ++ negotiate () { ++ if (this.destroying) return ++ if (this.destroyed) throw errCode(new Error('cannot negotiate after peer is destroyed'), 'ERR_DESTROYED') ++ ++ if (this.initiator) { ++ if (this._isNegotiating) { ++ this._queuedNegotiation = true; ++ this._debug('already negotiating, queueing'); ++ } else { ++ this._debug('start negotiation'); ++ setTimeout(() => { ++ // HACK: Chrome crashes if we immediately call createOffer ++ this._createOffer(); ++ }, 0); ++ } ++ } else { ++ if (this._isNegotiating) { ++ this._queuedNegotiation = true; ++ this._debug('already negotiating, queueing'); ++ } else { ++ this._debug('requesting negotiation from initiator'); ++ this.emit('signal', { ++ // request initiator to renegotiate ++ type: 'renegotiate', ++ renegotiate: true ++ }); ++ } ++ } ++ this._isNegotiating = true; ++ } ++ ++ destroy (err) { ++ if (this.destroyed || this.destroying) return ++ this.destroying = true; ++ ++ this._debug('destroying (error: %s)', err && (err.message || err)); ++ ++ queueMicrotask(() => { ++ // allow events concurrent with the call to _destroy() to fire (see #692) ++ this.destroyed = true; ++ this.destroying = false; ++ ++ this._debug('destroy (error: %s)', err && (err.message || err)); ++ ++ this._connected = false; ++ this._pcReady = false; ++ this._channelReady = false; ++ this._remoteTracks = null; ++ this._remoteStreams = null; ++ this._senderMap = null; ++ ++ clearInterval(this._closingInterval); ++ this._closingInterval = null; ++ ++ clearInterval(this._interval); ++ this._interval = null; ++ this._chunk = null; ++ this._cb = null; ++ ++ if (this._channel) { ++ try { ++ this._channel.close(); ++ } catch (err) {} ++ ++ // allow events concurrent with destruction to be handled ++ this._channel.onmessage = null; ++ this._channel.onopen = null; ++ this._channel.onclose = null; ++ this._channel.onerror = null; ++ } ++ if (this._pc) { ++ try { ++ this._pc.close(); ++ } catch (err) {} ++ ++ // allow events concurrent with destruction to be handled ++ this._pc.oniceconnectionstatechange = null; ++ this._pc.onicegatheringstatechange = null; ++ this._pc.onsignalingstatechange = null; ++ this._pc.onicecandidate = null; ++ this._pc.ontrack = null; ++ this._pc.ondatachannel = null; ++ } ++ this._pc = null; ++ this._channel = null; ++ ++ if (err) this.emit('error', err); ++ this.emit('close'); ++ }); ++ } ++ ++ _setupData (event) { ++ if (!event.channel) { ++ // In some situations `pc.createDataChannel()` returns `undefined` (in wrtc), ++ // which is invalid behavior. Handle it gracefully. ++ // See: https://github.com/feross/simple-peer/issues/163 ++ return this.destroy( ++ errCode( ++ new Error('Data channel event is missing `channel` property'), ++ 'ERR_DATA_CHANNEL' ++ ) ++ ) ++ } ++ ++ this._channel = event.channel; ++ this._channel.binaryType = 'arraybuffer'; ++ ++ if (typeof this._channel.bufferedAmountLowThreshold === 'number') { ++ this._channel.bufferedAmountLowThreshold = MAX_BUFFERED_AMOUNT; ++ } ++ ++ this.channelName = this._channel.label; ++ ++ this._channel.onmessage = event => { ++ this._onChannelMessage(event); ++ }; ++ this._channel.onbufferedamountlow = () => { ++ this._onChannelBufferedAmountLow(); ++ }; ++ this._channel.onopen = () => { ++ this._onChannelOpen(); ++ }; ++ this._channel.onclose = () => { ++ this._onChannelClose(); ++ }; ++ this._channel.onerror = err => { ++ this.destroy(errCode(err, 'ERR_DATA_CHANNEL')); ++ }; ++ ++ // HACK: Chrome will sometimes get stuck in readyState "closing", let's check for this condition ++ // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 ++ let isClosing = false; ++ this._closingInterval = setInterval(() => { ++ // No "onclosing" event ++ if (this._channel && this._channel.readyState === 'closing') { ++ if (isClosing) this._onChannelClose(); // closing timed out: equivalent to onclose firing ++ isClosing = true; ++ } else { ++ isClosing = false; ++ } ++ }, CHANNEL_CLOSING_TIMEOUT); ++ } ++ ++ _startIceCompleteTimeout () { ++ if (this.destroyed) return ++ if (this._iceCompleteTimer) return ++ this._debug('started iceComplete timeout'); ++ this._iceCompleteTimer = setTimeout(() => { ++ if (!this._iceComplete) { ++ this._iceComplete = true; ++ this._debug('iceComplete timeout completed'); ++ this.emit('iceTimeout'); ++ this.emit('_iceComplete'); ++ } ++ }, this.iceCompleteTimeout); ++ } ++ ++ _createOffer () { ++ if (this.destroyed) return ++ ++ this._pc ++ .createOffer(this.offerOptions) ++ .then(offer => { ++ if (this.destroyed) return ++ if (!this.trickle && !this.allowHalfTrickle) { offer.sdp = filterTrickle(offer.sdp); } ++ offer.sdp = this.sdpTransform(offer.sdp); ++ ++ const sendOffer = () => { ++ if (this.destroyed) return ++ const signal = this._pc.localDescription || offer; ++ this._debug('signal'); ++ this.emit('signal', { ++ type: signal.type, ++ sdp: signal.sdp ++ }); ++ }; ++ ++ const onSuccess = () => { ++ this._debug('createOffer success'); ++ if (this.destroyed) return ++ if (this.trickle || this._iceComplete) sendOffer(); ++ else this.once('_iceComplete', sendOffer); // wait for candidates ++ }; ++ ++ const onError = err => { ++ this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION')); ++ }; ++ ++ this._pc.setLocalDescription(offer).then(onSuccess).catch(onError); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_CREATE_OFFER')); ++ }); ++ } ++ ++ _requestMissingTransceivers () { ++ if (this._pc.getTransceivers) { ++ this._pc.getTransceivers().forEach(transceiver => { ++ if ( ++ !transceiver.mid && ++ transceiver.sender.track && ++ !transceiver.requested ++ ) { ++ transceiver.requested = true; // HACK: Safari returns negotiated transceivers with a null mid ++ this.addTransceiver(transceiver.sender.track.kind); ++ } ++ }); ++ } ++ } ++ ++ _createAnswer () { ++ if (this.destroyed) return ++ ++ this._pc ++ .createAnswer(this.answerOptions) ++ .then(answer => { ++ if (this.destroyed) return ++ if (!this.trickle && !this.allowHalfTrickle) { answer.sdp = filterTrickle(answer.sdp); } ++ answer.sdp = this.sdpTransform(answer.sdp); ++ ++ const sendAnswer = () => { ++ if (this.destroyed) return ++ const signal = this._pc.localDescription || answer; ++ this._debug('signal'); ++ this.emit('signal', { ++ type: signal.type, ++ sdp: signal.sdp ++ }); ++ if (!this.initiator) this._requestMissingTransceivers(); ++ }; ++ ++ const onSuccess = () => { ++ if (this.destroyed) return ++ if (this.trickle || this._iceComplete) sendAnswer(); ++ else this.once('_iceComplete', sendAnswer); ++ }; ++ ++ const onError = err => { ++ this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION')); ++ }; ++ ++ this._pc.setLocalDescription(answer).then(onSuccess).catch(onError); ++ }) ++ .catch(err => { ++ this.destroy(errCode(err, 'ERR_CREATE_ANSWER')); ++ }); ++ } ++ ++ _onConnectionStateChange () { ++ if (this.destroyed) return ++ if (this._pc.connectionState === 'failed') { ++ this.destroy( ++ errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE') ++ ); ++ } ++ } ++ ++ _onIceStateChange () { ++ if (this.destroyed) return ++ const iceConnectionState = this._pc.iceConnectionState; ++ const iceGatheringState = this._pc.iceGatheringState; ++ ++ this._debug( ++ 'iceStateChange (connection: %s) (gathering: %s)', ++ iceConnectionState, ++ iceGatheringState ++ ); ++ this.emit('iceStateChange', iceConnectionState, iceGatheringState); ++ ++ if ( ++ iceConnectionState === 'connected' || ++ iceConnectionState === 'completed' ++ ) { ++ this._pcReady = true; ++ this._maybeReady(); ++ } ++ if (iceConnectionState === 'failed') { ++ this.destroy( ++ errCode( ++ new Error('Ice connection failed.'), ++ 'ERR_ICE_CONNECTION_FAILURE' ++ ) ++ ); ++ } ++ if (iceConnectionState === 'closed') { ++ this.destroy( ++ errCode( ++ new Error('Ice connection closed.'), ++ 'ERR_ICE_CONNECTION_CLOSED' ++ ) ++ ); ++ } ++ } ++ ++ getStats (cb) { ++ // statreports can come with a value array instead of properties ++ const flattenValues = report => { ++ if (Object.prototype.toString.call(report.values) === '[object Array]') { ++ report.values.forEach(value => { ++ Object.assign(report, value); ++ }); ++ } ++ return report ++ }; ++ ++ // Promise-based getStats() (standard) ++ if (this._pc.getStats.length === 0 || this._isReactNativeWebrtc) { ++ this._pc.getStats().then( ++ res => { ++ const reports = []; ++ res.forEach(report => { ++ reports.push(flattenValues(report)); ++ }); ++ cb(null, reports); ++ }, ++ err => cb(err) ++ ); ++ ++ // Single-parameter callback-based getStats() (non-standard) ++ } else if (this._pc.getStats.length > 0) { ++ this._pc.getStats( ++ res => { ++ // If we destroy connection in `connect` callback this code might happen to run when actual connection is already closed ++ if (this.destroyed) return ++ ++ const reports = []; ++ res.result().forEach(result => { ++ const report = {}; ++ result.names().forEach(name => { ++ report[name] = result.stat(name); ++ }); ++ report.id = result.id; ++ report.type = result.type; ++ report.timestamp = result.timestamp; ++ reports.push(flattenValues(report)); ++ }); ++ cb(null, reports); ++ }, ++ err => cb(err) ++ ); ++ ++ // Unknown browser, skip getStats() since it's anyone's guess which style of ++ // getStats() they implement. ++ } else { ++ cb(null, []); ++ } ++ } ++ ++ _maybeReady () { ++ this._debug( ++ 'maybeReady pc %s channel %s', ++ this._pcReady, ++ this._channelReady ++ ); ++ if ( ++ this._connected || ++ this._connecting || ++ !this._pcReady || ++ !this._channelReady ++ ) { return } ++ ++ this._connecting = true; ++ ++ // HACK: We can't rely on order here, for details see https://github.com/js-platform/node-webrtc/issues/339 ++ const findCandidatePair = () => { ++ if (this.destroyed) return ++ ++ this.getStats((err, items) => { ++ if (this.destroyed) return ++ ++ // Treat getStats error as non-fatal. It's not essential. ++ if (err) items = []; ++ ++ const remoteCandidates = {}; ++ const localCandidates = {}; ++ const candidatePairs = {}; ++ let foundSelectedCandidatePair = false; ++ ++ items.forEach(item => { ++ // TODO: Once all browsers support the hyphenated stats report types, remove ++ // the non-hypenated ones ++ if ( ++ item.type === 'remotecandidate' || ++ item.type === 'remote-candidate' ++ ) { ++ remoteCandidates[item.id] = item; ++ } ++ if ( ++ item.type === 'localcandidate' || ++ item.type === 'local-candidate' ++ ) { ++ localCandidates[item.id] = item; ++ } ++ if (item.type === 'candidatepair' || item.type === 'candidate-pair') { ++ candidatePairs[item.id] = item; ++ } ++ }); ++ ++ const setSelectedCandidatePair = selectedCandidatePair => { ++ foundSelectedCandidatePair = true; ++ ++ let local = localCandidates[selectedCandidatePair.localCandidateId]; ++ ++ if (local && (local.ip || local.address)) { ++ // Spec ++ this.localAddress = local.ip || local.address; ++ this.localPort = Number(local.port); ++ } else if (local && local.ipAddress) { ++ // Firefox ++ this.localAddress = local.ipAddress; ++ this.localPort = Number(local.portNumber); ++ } else if ( ++ typeof selectedCandidatePair.googLocalAddress === 'string' ++ ) { ++ // TODO: remove this once Chrome 58 is released ++ local = selectedCandidatePair.googLocalAddress.split(':'); ++ this.localAddress = local[0]; ++ this.localPort = Number(local[1]); ++ } ++ if (this.localAddress) { ++ this.localFamily = this.localAddress.includes(':') ++ ? 'IPv6' ++ : 'IPv4'; ++ } ++ ++ let remote = ++ remoteCandidates[selectedCandidatePair.remoteCandidateId]; ++ ++ if (remote && (remote.ip || remote.address)) { ++ // Spec ++ this.remoteAddress = remote.ip || remote.address; ++ this.remotePort = Number(remote.port); ++ } else if (remote && remote.ipAddress) { ++ // Firefox ++ this.remoteAddress = remote.ipAddress; ++ this.remotePort = Number(remote.portNumber); ++ } else if ( ++ typeof selectedCandidatePair.googRemoteAddress === 'string' ++ ) { ++ // TODO: remove this once Chrome 58 is released ++ remote = selectedCandidatePair.googRemoteAddress.split(':'); ++ this.remoteAddress = remote[0]; ++ this.remotePort = Number(remote[1]); ++ } ++ if (this.remoteAddress) { ++ this.remoteFamily = this.remoteAddress.includes(':') ++ ? 'IPv6' ++ : 'IPv4'; ++ } ++ ++ this._debug( ++ 'connect local: %s:%s remote: %s:%s', ++ this.localAddress, ++ this.localPort, ++ this.remoteAddress, ++ this.remotePort ++ ); ++ }; ++ ++ items.forEach(item => { ++ // Spec-compliant ++ if (item.type === 'transport' && item.selectedCandidatePairId) { ++ setSelectedCandidatePair( ++ candidatePairs[item.selectedCandidatePairId] ++ ); ++ } ++ ++ // Old implementations ++ if ( ++ (item.type === 'googCandidatePair' && ++ item.googActiveConnection === 'true') || ++ ((item.type === 'candidatepair' || ++ item.type === 'candidate-pair') && ++ item.selected) ++ ) { ++ setSelectedCandidatePair(item); ++ } ++ }); ++ ++ // Ignore candidate pair selection in browsers like Safari 11 that do not have any local or remote candidates ++ // But wait until at least 1 candidate pair is available ++ if ( ++ !foundSelectedCandidatePair && ++ (!Object.keys(candidatePairs).length || ++ Object.keys(localCandidates).length) ++ ) { ++ setTimeout(findCandidatePair, 100); ++ return ++ } else { ++ this._connecting = false; ++ this._connected = true; ++ } ++ ++ if (this._chunk) { ++ try { ++ this.send(this._chunk); ++ } catch (err) { ++ return this.destroy(errCode(err, 'ERR_DATA_CHANNEL')) ++ } ++ this._chunk = null; ++ this._debug('sent chunk from "write before connect"'); ++ ++ const cb = this._cb; ++ this._cb = null; ++ cb(null); ++ } ++ ++ // If `bufferedAmountLowThreshold` and 'onbufferedamountlow' are unsupported, ++ // fallback to using setInterval to implement backpressure. ++ if (typeof this._channel.bufferedAmountLowThreshold !== 'number') { ++ this._interval = setInterval(() => this._onInterval(), 150); ++ if (this._interval.unref) this._interval.unref(); ++ } ++ ++ this._debug('connect'); ++ this.emit('connect'); ++ }); ++ }; ++ findCandidatePair(); ++ } ++ ++ _onInterval () { ++ if ( ++ !this._cb || ++ !this._channel || ++ this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT ++ ) { ++ return ++ } ++ this._onChannelBufferedAmountLow(); ++ } ++ ++ _onSignalingStateChange () { ++ if (this.destroyed) return ++ ++ if (this._pc.signalingState === 'stable') { ++ this._isNegotiating = false; ++ ++ // HACK: Firefox doesn't yet support removing tracks when signalingState !== 'stable' ++ this._debug('flushing sender queue', this._sendersAwaitingStable); ++ this._sendersAwaitingStable.forEach(sender => { ++ this._pc.removeTrack(sender); ++ this._queuedNegotiation = true; ++ }); ++ this._sendersAwaitingStable = []; ++ ++ if (this._queuedNegotiation) { ++ this._debug('flushing negotiation queue'); ++ this._queuedNegotiation = false; ++ this._needsNegotiation(); // negotiate again ++ } else { ++ this._debug('negotiated'); ++ this.emit('negotiated'); ++ } ++ } ++ ++ this._debug('signalingStateChange %s', this._pc.signalingState); ++ this.emit('signalingStateChange', this._pc.signalingState); ++ } ++ ++ _onIceCandidate (event) { ++ if (this.destroyed) return ++ if (event.candidate && this.trickle) { ++ this.emit('signal', { ++ type: 'candidate', ++ candidate: { ++ candidate: event.candidate.candidate, ++ sdpMLineIndex: event.candidate.sdpMLineIndex, ++ sdpMid: event.candidate.sdpMid ++ } ++ }); ++ } else if (!event.candidate && !this._iceComplete) { ++ this._iceComplete = true; ++ this.emit('_iceComplete'); ++ } ++ // as soon as we've received one valid candidate start timeout ++ if (event.candidate) { ++ this._startIceCompleteTimeout(); ++ } ++ } ++ ++ _onChannelMessage (event) { ++ if (this.destroyed) return ++ let data = event.data; ++ if (data instanceof ArrayBuffer) data = new Uint8Array(data); ++ this.emit('data', data); ++ } ++ ++ _onChannelBufferedAmountLow () { ++ if (this.destroyed || !this._cb) return ++ this._debug( ++ 'ending backpressure: bufferedAmount %d', ++ this._channel.bufferedAmount ++ ); ++ const cb = this._cb; ++ this._cb = null; ++ cb(null); ++ } ++ ++ _onChannelOpen () { ++ if (this._connected || this.destroyed) return ++ this._debug('on channel open'); ++ this._channelReady = true; ++ this._maybeReady(); ++ } ++ ++ _onChannelClose () { ++ if (this.destroyed) return ++ this._debug('on channel close'); ++ this.destroy(); ++ } ++ ++ _onTrack (event) { ++ if (this.destroyed) return ++ ++ event.streams.forEach(eventStream => { ++ this._debug('on track'); ++ this.emit('track', event.track, eventStream); ++ ++ this._remoteTracks.push({ ++ track: event.track, ++ stream: eventStream ++ }); ++ ++ if ( ++ this._remoteStreams.some(remoteStream => { ++ return remoteStream.id === eventStream.id ++ }) ++ ) { return } // Only fire one 'stream' event, even though there may be multiple tracks per stream ++ ++ this._remoteStreams.push(eventStream); ++ queueMicrotask(() => { ++ this._debug('on stream'); ++ this.emit('stream', eventStream); // ensure all tracks have been added ++ }); ++ }); ++ } ++ ++ _debug (...args) { ++ if (!this._doDebug) return ++ args[0] = '[' + this._id + '] ' + args[0]; ++ console.log(...args); ++ } ++ ++ // event emitter ++ on (key, listener) { ++ const map = this._map; ++ if (!map.has(key)) map.set(key, new Set()); ++ map.get(key).add(listener); ++ } ++ ++ off (key, listener) { ++ const map = this._map; ++ const listeners = map.get(key); ++ if (!listeners) return ++ listeners.delete(listener); ++ if (listeners.size === 0) map.delete(key); ++ } ++ ++ once (key, listener) { ++ const listener_ = (...args) => { ++ this.off(key, listener_); ++ listener(...args); ++ }; ++ this.on(key, listener_); ++ } ++ ++ emit (key, ...args) { ++ const map = this._map; ++ if (!map.has(key)) return ++ for (const listener of map.get(key)) { ++ try { ++ listener(...args); ++ } catch (err) { ++ console.error(err); ++ } ++ } ++ } ++} ++ ++Peer.WEBRTC_SUPPORT = !!getBrowserRTC(); ++ ++/** ++ * Expose peer and data channel config for overriding all Peer ++ * instances. Otherwise, just set opts.config or opts.channelConfig ++ * when constructing a Peer. ++ */ ++Peer.config = { ++ iceServers: [ ++ { ++ urls: [ ++ 'stun:stun.l.google.com:19302', ++ 'stun:global.stun.twilio.com:3478' ++ ] ++ } ++ ], ++ sdpSemantics: 'unified-plan' ++}; ++ ++Peer.channelConfig = {}; ++ ++class RRWebPluginCanvasWebRTCReplay { ++ constructor({ canvasFoundCallback, signalSendCallback, }) { ++ this.peer = null; ++ this.streamNodeMap = new Map(); ++ this.streams = new Set(); ++ this.runningStreams = new WeakSet(); ++ this.canvasFoundCallback = canvasFoundCallback; ++ this.signalSendCallback = signalSendCallback; ++ } ++ initPlugin() { ++ return { ++ onBuild: (node, context) => { ++ if (node.nodeName === 'CANVAS') { ++ this.canvasFoundCallback(node, context); ++ } ++ }, ++ getMirror: (options) => { ++ this.mirror = options.nodeMirror; ++ }, ++ }; ++ } ++ startStream(target, stream) { ++ if (this.runningStreams.has(stream)) ++ return; ++ if (target.tagName === 'VIDEO') { ++ const remoteVideo = target; ++ remoteVideo.srcObject = stream; ++ void remoteVideo.play(); ++ this.runningStreams.add(stream); ++ return; ++ } ++ if ('MediaStreamTrackProcessor' in window) { ++ const canvas = target; ++ const ctx = canvas.getContext('2d'); ++ if (!ctx) ++ throw new Error(`startStream: Could not get 2d canvas context for ${canvas.outerHTML}`); ++ const track = stream.getVideoTracks()[0]; ++ const processor = new MediaStreamTrackProcessor({ track: track }); ++ const reader = processor.readable.getReader(); ++ const readChunk = function () { ++ void reader.read().then(({ done, value }) => { ++ if (!value) ++ return; ++ if (canvas.width !== value.displayWidth || ++ canvas.height !== value.displayHeight) { ++ canvas.width = value.displayWidth; ++ canvas.height = value.displayHeight; ++ } ++ ctx.clearRect(0, 0, canvas.width, canvas.height); ++ ctx.drawImage(value, 0, 0); ++ value.close(); ++ if (!done) { ++ readChunk(); ++ } ++ }); ++ }; ++ readChunk(); ++ this.runningStreams.add(stream); ++ } ++ else { ++ const remoteVideo = document.createElement('video'); ++ remoteVideo.setAttribute('autoplay', 'true'); ++ remoteVideo.setAttribute('playsinline', 'true'); ++ remoteVideo.setAttribute('width', target.width.toString()); ++ remoteVideo.setAttribute('height', target.height.toString()); ++ target.replaceWith(remoteVideo); ++ this.startStream(remoteVideo, stream); ++ } ++ } ++ signalReceive(msg) { ++ if (!this.peer) { ++ this.peer = new Peer({ ++ initiator: false, ++ }); ++ this.peer.on('error', (err) => { ++ this.peer = null; ++ console.log('error', err); ++ }); ++ this.peer.on('close', () => { ++ this.peer = null; ++ console.log('closing'); ++ }); ++ this.peer.on('signal', (data) => { ++ this.signalSendCallback(data); ++ }); ++ this.peer.on('connect', () => { ++ }); ++ this.peer.on('data', (data) => { ++ try { ++ const json = JSON.parse(data); ++ this.streamNodeMap.set(json.streamId, json.nodeId); ++ } ++ catch (error) { ++ console.error('Could not parse data', error); ++ } ++ this.flushStreams(); ++ }); ++ this.peer.on('stream', (stream) => { ++ this.streams.add(stream); ++ this.flushStreams(); ++ }); ++ } ++ this.peer.signal(msg); ++ } ++ flushStreams() { ++ this.streams.forEach((stream) => { ++ const nodeId = this.streamNodeMap.get(stream.id); ++ if (!nodeId) ++ return; ++ const target = this.mirror.getNode(nodeId); ++ if (target) ++ this.startStream(target, stream); ++ }); ++ } ++} ++ ++exports.RRWebPluginCanvasWebRTCReplay = RRWebPluginCanvasWebRTCReplay; +diff --git a/node_modules/rrweb/lib/plugins/console-record.js b/node_modules/rrweb/lib/plugins/console-record.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/lib/plugins/console-replay.js b/node_modules/rrweb/lib/plugins/console-replay.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/lib/plugins/sequential-id-record.js b/node_modules/rrweb/lib/plugins/sequential-id-record.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/lib/plugins/sequential-id-replay.js b/node_modules/rrweb/lib/plugins/sequential-id-replay.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/lib/record/rrweb-record-pack.js b/node_modules/rrweb/lib/record/rrweb-record-pack.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/lib/record/rrweb-record.js b/node_modules/rrweb/lib/record/rrweb-record.js +old mode 100644 +new mode 100755 +index 2a2a3ca..2264570 +--- a/node_modules/rrweb/lib/record/rrweb-record.js ++++ b/node_modules/rrweb/lib/record/rrweb-record.js +@@ -96,10 +96,14 @@ function isShadowRoot(n) { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -326,7 +330,10 @@ function transformAttribute(doc, tagName, name, value) { + return value; + } + } +-function _isBlockedElement(element, blockClass, blockSelector) { ++function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -345,11 +352,16 @@ function _isBlockedElement(element, blockClass, blockSelector) { + } + return false; + } +-function needMaskingText(node, maskTextClass, maskTextSelector) { ++function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -368,12 +380,12 @@ function needMaskingText(node, maskTextClass, maskTextSelector) { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -413,7 +425,7 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -445,7 +457,7 @@ function serializeNode(n, options) { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -486,9 +498,12 @@ function serializeNode(n, options) { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -607,7 +622,7 @@ function serializeNode(n, options) { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -715,15 +730,19 @@ function slimDOMExcluded(sn, slimDOMOptions) { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -779,10 +798,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -827,10 +850,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -853,7 +880,7 @@ function serializeNodeWithId(n, options) { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -902,10 +929,14 @@ function snapshot(n, options) { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -1381,8 +1412,12 @@ var MutationBuffer = (function () { + map: _this.mirror.map, + blockClass: _this.blockClass, + blockSelector: _this.blockSelector, ++ unblockSelector: _this.unblockSelector, + maskTextClass: _this.maskTextClass, + maskTextSelector: _this.maskTextSelector, ++ unmaskTextSelector: _this.unmaskTextSelector, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + skipChild: true, + inlineStylesheet: _this.inlineStylesheet, + maskInputOptions: _this.maskInputOptions, +@@ -1528,7 +1563,7 @@ var MutationBuffer = (function () { + var value = m.target.textContent; + if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) { + _this.texts.push({ +- value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector) && value ++ value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, _this.unmaskTextSelector) && value + ? _this.maskTextFn + ? _this.maskTextFn(value) + : value.replace(/[\S]/g, '*') +@@ -1543,6 +1578,9 @@ var MutationBuffer = (function () { + var value = m.target.getAttribute(m.attributeName); + if (m.attributeName === 'value') { + value = maskInputValue({ ++ input: target, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + maskInputOptions: _this.maskInputOptions, + tagName: m.target.tagName, + type: m.target.getAttribute('type'), +@@ -1679,8 +1717,12 @@ var MutationBuffer = (function () { + 'mutationCb', + 'blockClass', + 'blockSelector', ++ 'unblockSelector', + 'maskTextClass', + 'maskTextSelector', ++ 'unmaskTextSelector', ++ 'maskInputSelector', ++ 'unmaskInputSelector', + 'inlineStylesheet', + 'maskInputOptions', + 'maskTextFn', +@@ -1944,7 +1986,7 @@ function wrapEventWithUserTriggeredFlag(v, enable) { + var INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT']; + var lastInputValueMap = new WeakMap(); + function initInputObserver(_a) { +- var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; ++ var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; + function eventHandler(event) { + var target = getEventTarget(event); + var userTriggered = event.isTrusted; +@@ -1957,7 +1999,7 @@ function initInputObserver(_a) { + return; + } + var type = target.type; +- if (target.classList.contains(ignoreClass)) { ++ if (target.classList.contains(ignoreClass) || (ignoreSelector && target.matches(ignoreSelector))) { + return; + } + var text = target.value; +@@ -1968,7 +2010,10 @@ function initInputObserver(_a) { + else if (maskInputOptions[target.tagName.toLowerCase()] || + maskInputOptions[type]) { + text = maskInputValue({ ++ input: target, + maskInputOptions: maskInputOptions, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + tagName: target.tagName, + type: type, + value: text, +@@ -2052,6 +2097,9 @@ function getNestedCSSRulePositions(rule) { + function initStyleSheetObserver(_a, _b) { + var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror; + var win = _b.win; ++ if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) { ++ return function () { }; ++ } + var insertRule = win.CSSStyleSheet.prototype.insertRule; + win.CSSStyleSheet.prototype.insertRule = function (rule, index) { + var id = mirror.getId(this.ownerNode); +@@ -2884,7 +2932,7 @@ var takeFullSnapshot; + var mirror = createMirror(); + function record(options) { + if (options === void 0) { options = {}; } +- var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.ignoreClass, ignoreClass = _c === void 0 ? 'rr-ignore' : _c, _d = options.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = options.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = options.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _g = options.sampling, sampling = _g === void 0 ? {} : _g, mousemoveWait = options.mousemoveWait, _h = options.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = options.userTriggeredOnInput, userTriggeredOnInput = _j === void 0 ? false : _j, _k = options.collectFonts, collectFonts = _k === void 0 ? false : _k, _l = options.inlineImages, inlineImages = _l === void 0 ? false : _l, plugins = options.plugins, _m = options.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m; ++ var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s; + if (!emit) { + throw new Error('emit function is required'); + } +@@ -3015,8 +3063,12 @@ function record(options) { + bypassOptions: { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, +@@ -3045,8 +3097,12 @@ function record(options) { + var _e = __read(snapshot(document, { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskAllInputs: maskInputOptions, + maskTextFn: maskTextFn, +@@ -3160,8 +3216,12 @@ function record(options) { + }, + blockClass: blockClass, + ignoreClass: ignoreClass, ++ ignoreSelector: ignoreSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + inlineStylesheet: inlineStylesheet, + sampling: sampling, +@@ -3173,6 +3233,7 @@ function record(options) { + maskInputFn: maskInputFn, + maskTextFn: maskTextFn, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + slimDOMOptions: slimDOMOptions, + mirror: mirror, + iframeManager: iframeManager, +@@ -3194,7 +3255,12 @@ function record(options) { }, hooks); }; iframeManager.addLoadListener(function (iframeEl) { - handlers_1.push(observe_1(iframeEl.contentDocument)); + try { + handlers_1.push(observe_1(iframeEl.contentDocument)); -+ } catch (error) { -+ console.warn('error in rrweb iframe observer', error); ++ } ++ catch (error) { ++ console.warn(error); ++ } + }); + var init_1 = function () { + takeFullSnapshot(); +diff --git a/node_modules/rrweb/lib/replay/rrweb-replay-unpack.js b/node_modules/rrweb/lib/replay/rrweb-replay-unpack.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/lib/replay/rrweb-replay.js b/node_modules/rrweb/lib/replay/rrweb-replay.js +old mode 100644 +new mode 100755 +diff --git a/node_modules/rrweb/lib/rrweb-all.js b/node_modules/rrweb/lib/rrweb-all.js +old mode 100644 +new mode 100755 +index e905195..71bd8e3 +--- a/node_modules/rrweb/lib/rrweb-all.js ++++ b/node_modules/rrweb/lib/rrweb-all.js +@@ -98,10 +98,14 @@ function isShadowRoot(n) { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -328,7 +332,10 @@ function transformAttribute(doc, tagName, name, value) { + return value; + } + } +-function _isBlockedElement(element, blockClass, blockSelector) { ++function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -347,11 +354,16 @@ function _isBlockedElement(element, blockClass, blockSelector) { + } + return false; + } +-function needMaskingText(node, maskTextClass, maskTextSelector) { ++function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -370,12 +382,12 @@ function needMaskingText(node, maskTextClass, maskTextSelector) { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -415,7 +427,7 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -447,7 +459,7 @@ function serializeNode(n, options) { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -488,9 +500,12 @@ function serializeNode(n, options) { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -609,7 +624,7 @@ function serializeNode(n, options) { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -717,15 +732,19 @@ function slimDOMExcluded(sn, slimDOMOptions) { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -781,10 +800,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -829,10 +852,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -855,7 +882,7 @@ function serializeNodeWithId(n, options) { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -904,10 +931,14 @@ function snapshot(n, options) { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -2443,8 +2474,12 @@ var MutationBuffer = (function () { + map: _this.mirror.map, + blockClass: _this.blockClass, + blockSelector: _this.blockSelector, ++ unblockSelector: _this.unblockSelector, + maskTextClass: _this.maskTextClass, + maskTextSelector: _this.maskTextSelector, ++ unmaskTextSelector: _this.unmaskTextSelector, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + skipChild: true, + inlineStylesheet: _this.inlineStylesheet, + maskInputOptions: _this.maskInputOptions, +@@ -2590,7 +2625,7 @@ var MutationBuffer = (function () { + var value = m.target.textContent; + if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) { + _this.texts.push({ +- value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector) && value ++ value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, _this.unmaskTextSelector) && value + ? _this.maskTextFn + ? _this.maskTextFn(value) + : value.replace(/[\S]/g, '*') +@@ -2605,6 +2640,9 @@ var MutationBuffer = (function () { + var value = m.target.getAttribute(m.attributeName); + if (m.attributeName === 'value') { + value = maskInputValue({ ++ input: target, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + maskInputOptions: _this.maskInputOptions, + tagName: m.target.tagName, + type: m.target.getAttribute('type'), +@@ -2741,8 +2779,12 @@ var MutationBuffer = (function () { + 'mutationCb', + 'blockClass', + 'blockSelector', ++ 'unblockSelector', + 'maskTextClass', + 'maskTextSelector', ++ 'unmaskTextSelector', ++ 'maskInputSelector', ++ 'unmaskInputSelector', + 'inlineStylesheet', + 'maskInputOptions', + 'maskTextFn', +@@ -3006,7 +3048,7 @@ function wrapEventWithUserTriggeredFlag(v, enable) { + var INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT']; + var lastInputValueMap = new WeakMap(); + function initInputObserver(_a) { +- var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; ++ var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; + function eventHandler(event) { + var target = getEventTarget(event); + var userTriggered = event.isTrusted; +@@ -3019,7 +3061,7 @@ function initInputObserver(_a) { + return; + } + var type = target.type; +- if (target.classList.contains(ignoreClass)) { ++ if (target.classList.contains(ignoreClass) || (ignoreSelector && target.matches(ignoreSelector))) { + return; + } + var text = target.value; +@@ -3030,7 +3072,10 @@ function initInputObserver(_a) { + else if (maskInputOptions[target.tagName.toLowerCase()] || + maskInputOptions[type]) { + text = maskInputValue({ ++ input: target, + maskInputOptions: maskInputOptions, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + tagName: target.tagName, + type: type, + value: text, +@@ -3114,6 +3159,9 @@ function getNestedCSSRulePositions(rule) { + function initStyleSheetObserver(_a, _b) { + var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror; + var win = _b.win; ++ if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) { ++ return function () { }; ++ } + var insertRule = win.CSSStyleSheet.prototype.insertRule; + win.CSSStyleSheet.prototype.insertRule = function (rule, index) { + var id = mirror.getId(this.ownerNode); +@@ -3966,7 +4014,7 @@ var takeFullSnapshot; + var mirror = createMirror(); + function record(options) { + if (options === void 0) { options = {}; } +- var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.ignoreClass, ignoreClass = _c === void 0 ? 'rr-ignore' : _c, _d = options.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = options.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = options.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _g = options.sampling, sampling = _g === void 0 ? {} : _g, mousemoveWait = options.mousemoveWait, _h = options.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = options.userTriggeredOnInput, userTriggeredOnInput = _j === void 0 ? false : _j, _k = options.collectFonts, collectFonts = _k === void 0 ? false : _k, _l = options.inlineImages, inlineImages = _l === void 0 ? false : _l, plugins = options.plugins, _m = options.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m; ++ var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s; + if (!emit) { + throw new Error('emit function is required'); + } +@@ -4097,8 +4145,12 @@ function record(options) { + bypassOptions: { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, +@@ -4127,8 +4179,12 @@ function record(options) { + var _e = __read(snapshot(document, { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskAllInputs: maskInputOptions, + maskTextFn: maskTextFn, +@@ -4242,8 +4298,12 @@ function record(options) { + }, + blockClass: blockClass, + ignoreClass: ignoreClass, ++ ignoreSelector: ignoreSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + inlineStylesheet: inlineStylesheet, + sampling: sampling, +@@ -4255,6 +4315,7 @@ function record(options) { + maskInputFn: maskInputFn, + maskTextFn: maskTextFn, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + slimDOMOptions: slimDOMOptions, + mirror: mirror, + iframeManager: iframeManager, +@@ -4276,7 +4337,12 @@ function record(options) { + }, hooks); + }; + iframeManager.addLoadListener(function (iframeEl) { +- handlers_1.push(observe_1(iframeEl.contentDocument)); ++ try { ++ handlers_1.push(observe_1(iframeEl.contentDocument)); ++ } ++ catch (error) { ++ console.warn(error); ++ } + }); + var init_1 = function () { + takeFullSnapshot(); +diff --git a/node_modules/rrweb/lib/rrweb.js b/node_modules/rrweb/lib/rrweb.js +old mode 100644 +new mode 100755 +index a6992d6..8aff2a8 +--- a/node_modules/rrweb/lib/rrweb.js ++++ b/node_modules/rrweb/lib/rrweb.js +@@ -98,10 +98,14 @@ function isShadowRoot(n) { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -328,7 +332,10 @@ function transformAttribute(doc, tagName, name, value) { + return value; + } + } +-function _isBlockedElement(element, blockClass, blockSelector) { ++function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -347,11 +354,16 @@ function _isBlockedElement(element, blockClass, blockSelector) { + } + return false; + } +-function needMaskingText(node, maskTextClass, maskTextSelector) { ++function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -370,12 +382,12 @@ function needMaskingText(node, maskTextClass, maskTextSelector) { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -415,7 +427,7 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -447,7 +459,7 @@ function serializeNode(n, options) { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -488,9 +500,12 @@ function serializeNode(n, options) { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -609,7 +624,7 @@ function serializeNode(n, options) { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -717,15 +732,19 @@ function slimDOMExcluded(sn, slimDOMOptions) { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -781,10 +800,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -829,10 +852,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -855,7 +882,7 @@ function serializeNodeWithId(n, options) { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -904,10 +931,14 @@ function snapshot(n, options) { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -2443,8 +2474,12 @@ var MutationBuffer = (function () { + map: _this.mirror.map, + blockClass: _this.blockClass, + blockSelector: _this.blockSelector, ++ unblockSelector: _this.unblockSelector, + maskTextClass: _this.maskTextClass, + maskTextSelector: _this.maskTextSelector, ++ unmaskTextSelector: _this.unmaskTextSelector, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + skipChild: true, + inlineStylesheet: _this.inlineStylesheet, + maskInputOptions: _this.maskInputOptions, +@@ -2590,7 +2625,7 @@ var MutationBuffer = (function () { + var value = m.target.textContent; + if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) { + _this.texts.push({ +- value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector) && value ++ value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, _this.unmaskTextSelector) && value + ? _this.maskTextFn + ? _this.maskTextFn(value) + : value.replace(/[\S]/g, '*') +@@ -2605,6 +2640,9 @@ var MutationBuffer = (function () { + var value = m.target.getAttribute(m.attributeName); + if (m.attributeName === 'value') { + value = maskInputValue({ ++ input: target, ++ maskInputSelector: _this.maskInputSelector, ++ unmaskInputSelector: _this.unmaskInputSelector, + maskInputOptions: _this.maskInputOptions, + tagName: m.target.tagName, + type: m.target.getAttribute('type'), +@@ -2741,8 +2779,12 @@ var MutationBuffer = (function () { + 'mutationCb', + 'blockClass', + 'blockSelector', ++ 'unblockSelector', + 'maskTextClass', + 'maskTextSelector', ++ 'unmaskTextSelector', ++ 'maskInputSelector', ++ 'unmaskInputSelector', + 'inlineStylesheet', + 'maskInputOptions', + 'maskTextFn', +@@ -3006,7 +3048,7 @@ function wrapEventWithUserTriggeredFlag(v, enable) { + var INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT']; + var lastInputValueMap = new WeakMap(); + function initInputObserver(_a) { +- var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; ++ var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput; + function eventHandler(event) { + var target = getEventTarget(event); + var userTriggered = event.isTrusted; +@@ -3019,7 +3061,7 @@ function initInputObserver(_a) { + return; + } + var type = target.type; +- if (target.classList.contains(ignoreClass)) { ++ if (target.classList.contains(ignoreClass) || (ignoreSelector && target.matches(ignoreSelector))) { + return; + } + var text = target.value; +@@ -3030,7 +3072,10 @@ function initInputObserver(_a) { + else if (maskInputOptions[target.tagName.toLowerCase()] || + maskInputOptions[type]) { + text = maskInputValue({ ++ input: target, + maskInputOptions: maskInputOptions, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + tagName: target.tagName, + type: type, + value: text, +@@ -3114,6 +3159,9 @@ function getNestedCSSRulePositions(rule) { + function initStyleSheetObserver(_a, _b) { + var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror; + var win = _b.win; ++ if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) { ++ return function () { }; ++ } + var insertRule = win.CSSStyleSheet.prototype.insertRule; + win.CSSStyleSheet.prototype.insertRule = function (rule, index) { + var id = mirror.getId(this.ownerNode); +@@ -3966,7 +4014,7 @@ var takeFullSnapshot; + var mirror = createMirror(); + function record(options) { + if (options === void 0) { options = {}; } +- var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.ignoreClass, ignoreClass = _c === void 0 ? 'rr-ignore' : _c, _d = options.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = options.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = options.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _g = options.sampling, sampling = _g === void 0 ? {} : _g, mousemoveWait = options.mousemoveWait, _h = options.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = options.userTriggeredOnInput, userTriggeredOnInput = _j === void 0 ? false : _j, _k = options.collectFonts, collectFonts = _k === void 0 ? false : _k, _l = options.inlineImages, inlineImages = _l === void 0 ? false : _l, plugins = options.plugins, _m = options.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m; ++ var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s; + if (!emit) { + throw new Error('emit function is required'); + } +@@ -4097,8 +4145,12 @@ function record(options) { + bypassOptions: { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, +@@ -4127,8 +4179,12 @@ function record(options) { + var _e = __read(snapshot(document, { + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + inlineStylesheet: inlineStylesheet, + maskAllInputs: maskInputOptions, + maskTextFn: maskTextFn, +@@ -4242,8 +4298,12 @@ function record(options) { + }, + blockClass: blockClass, + ignoreClass: ignoreClass, ++ ignoreSelector: ignoreSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + inlineStylesheet: inlineStylesheet, + sampling: sampling, +@@ -4255,6 +4315,7 @@ function record(options) { + maskInputFn: maskInputFn, + maskTextFn: maskTextFn, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + slimDOMOptions: slimDOMOptions, + mirror: mirror, + iframeManager: iframeManager, +@@ -4276,7 +4337,12 @@ function record(options) { + }, hooks); + }; + iframeManager.addLoadListener(function (iframeEl) { +- handlers_1.push(observe_1(iframeEl.contentDocument)); ++ try { ++ handlers_1.push(observe_1(iframeEl.contentDocument)); ++ } ++ catch (error) { ++ console.warn(error); + } }); var init_1 = function () { takeFullSnapshot(); +diff --git a/node_modules/rrweb/typings/record/mutation.d.ts b/node_modules/rrweb/typings/record/mutation.d.ts +index 5f88a66..444ea07 100644 +--- a/node_modules/rrweb/typings/record/mutation.d.ts ++++ b/node_modules/rrweb/typings/record/mutation.d.ts +@@ -13,8 +13,12 @@ export default class MutationBuffer { + private mutationCb; + private blockClass; + private blockSelector; ++ private unblockSelector; + private maskTextClass; + private maskTextSelector; ++ private unmaskTextSelector; ++ private maskInputSelector; ++ private unmaskInputSelector; + private inlineStylesheet; + private maskInputOptions; + private maskTextFn; +diff --git a/node_modules/rrweb/typings/types.d.ts b/node_modules/rrweb/typings/types.d.ts +index ae3aa94..bf529fa 100644 +--- a/node_modules/rrweb/typings/types.d.ts ++++ b/node_modules/rrweb/typings/types.d.ts +@@ -137,13 +137,18 @@ export declare type recordOptions = { + checkoutEveryNms?: number; + blockClass?: blockClass; + blockSelector?: string; ++ unblockSelector?: string; + ignoreClass?: string; ++ ignoreSelector?: string; + maskTextClass?: maskTextClass; + maskTextSelector?: string; + maskAllInputs?: boolean; ++ maskInputSelector?: string; + maskInputOptions?: MaskInputOptions; + maskInputFn?: MaskInputFn; + maskTextFn?: MaskTextFn; ++ unmaskTextSelector?: string; ++ unmaskInputSelector?: string; + slimDOMOptions?: SlimDOMOptions | 'all' | true; + inlineStylesheet?: boolean; + hooks?: hooksParam; +@@ -167,9 +172,14 @@ export declare type observerParam = { + mediaInteractionCb: mediaInteractionCallback; + blockClass: blockClass; + blockSelector: string | null; ++ unblockSelector: string | null; + ignoreClass: string; ++ ignoreSelector: string | null; + maskTextClass: maskTextClass; + maskTextSelector: string | null; ++ unmaskTextSelector: string | null; ++ maskInputSelector: string | null; ++ unmaskInputSelector: string | null; + maskInputOptions: MaskInputOptions; + maskInputFn?: MaskInputFn; + maskTextFn?: MaskTextFn; +@@ -195,7 +205,7 @@ export declare type observerParam = { + options: unknown; + }>; + }; +-export declare type MutationBufferParam = Pick; ++export declare type MutationBufferParam = Pick; + export declare type hooksParam = { + mutation?: mutationCallBack; + mousemove?: mousemoveCallBack; diff --git a/patches/rrweb-snapshot+1.1.14.patch b/patches/rrweb-snapshot+1.1.14.patch new file mode 100644 index 000000000000..102cdb884a0c --- /dev/null +++ b/patches/rrweb-snapshot+1.1.14.patch @@ -0,0 +1,651 @@ +diff --git a/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js b/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js +old mode 100644 +new mode 100755 +index 4ece2ab..86a9b7a +--- a/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js ++++ b/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js +@@ -20,10 +20,14 @@ var rrwebSnapshot = (function (exports) { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -250,7 +254,10 @@ var rrwebSnapshot = (function (exports) { + return value; + } + } +- function _isBlockedElement(element, blockClass, blockSelector) { ++ function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -269,11 +276,16 @@ var rrwebSnapshot = (function (exports) { + } + return false; + } +- function needMaskingText(node, maskTextClass, maskTextSelector) { ++ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -292,12 +304,12 @@ var rrwebSnapshot = (function (exports) { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -337,7 +349,7 @@ var rrwebSnapshot = (function (exports) { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -369,7 +381,7 @@ var rrwebSnapshot = (function (exports) { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -410,9 +422,12 @@ var rrwebSnapshot = (function (exports) { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -531,7 +546,7 @@ var rrwebSnapshot = (function (exports) { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -639,15 +654,19 @@ var rrwebSnapshot = (function (exports) { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -703,10 +722,14 @@ var rrwebSnapshot = (function (exports) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -751,10 +774,14 @@ var rrwebSnapshot = (function (exports) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -777,7 +804,7 @@ var rrwebSnapshot = (function (exports) { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -826,10 +853,14 @@ var rrwebSnapshot = (function (exports) { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +diff --git a/node_modules/rrweb-snapshot/dist/rrweb-snapshot.min.js b/node_modules/rrweb-snapshot/dist/rrweb-snapshot.min.js +old mode 100644 +new mode 100755 +index e1259cb..5bd5559 +--- a/node_modules/rrweb-snapshot/dist/rrweb-snapshot.min.js ++++ b/node_modules/rrweb-snapshot/dist/rrweb-snapshot.min.js +@@ -1,2 +1,2 @@ +-var rrwebSnapshot=function(e){"use strict";var t;function r(e){return e.nodeType===e.ELEMENT_NODE}function n(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}function a(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,i=e.maskInputFn,o=a||"";return(t[r.toLowerCase()]||t[n])&&(o=i?i(o):"*".repeat(o.length)),o}e.NodeType=void 0,(t=e.NodeType||(e.NodeType={}))[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment";var i="__rrweb_original__";function o(e){var t=e.getContext("2d");if(!t)return!0;for(var r=0;r-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)+l+")";var u=t.split("/"),f=c.split("/");u.pop();for(var d=0,p=f;d=t.length);){var i=n(y);if(","===i.slice(-1))i=T(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=T(e,i);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((i+o).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((i+o).trim());break}"("===c&&(s=!0)}o+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?v(n,b()):"object"===t&&"data"===r&&n?T(e,n):n:T(e,n)}function C(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n'):a.write('')),d=a),d.__sn=t,i[t.id]=d,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!s)for(var p=0,m=t.childNodes;p-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)+l+")";var u=t.split("/"),p=c.split("/");u.pop();for(var f=0,m=p;f=t.length);){var o=n(y);if(","===o.slice(-1))o=k(e,o.substring(0,o.length-1)),a.push(o);else{var i="";o=k(e,o);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((o+i).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((o+i).trim());break}"("===c&&(s=!0)}i+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?v(n,T()):"object"===t&&"data"===r&&n?k(e,n):n:k(e,n)}function S(e,t,r,n){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if(n&&(e.matches(n)||e.closest(n)))return!1;if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var a=0;a'):a.write('')),f=a),f.__sn=t,o[t.id]=f,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!s)for(var m=0,d=t.childNodes;m;\n\nexport type SlimDOMOptions = Partial<{\n script: boolean;\n comment: boolean;\n headFavicon: boolean;\n headWhitespace: boolean;\n headMetaDescKeywords: boolean;\n headMetaSocial: boolean;\n headMetaRobots: boolean;\n headMetaHttpEquiv: boolean;\n headMetaAuthorship: boolean;\n headMetaVerification: boolean;\n}>;\n\nexport type DataURLOptions = Partial<{\n type: string;\n quality: number;\n}>;\n\nexport type MaskTextFn = (text: string) => string;\nexport type MaskInputFn = (text: string) => string;\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\nexport type BuildCache = {\n stylesWithHoverClass: Map;\n};\n","import { INode, MaskInputFn, MaskInputOptions } from './types';\n\nexport function isElement(n: Node | INode): n is Element {\n return n.nodeType === n.ELEMENT_NODE;\n}\n\nexport function isShadowRoot(n: Node): n is ShadowRoot {\n const host: Element | null = (n as ShadowRoot)?.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\n\nexport function maskInputValue({\n maskInputOptions,\n tagName,\n type,\n value,\n maskInputFn,\n}: {\n maskInputOptions: MaskInputOptions;\n tagName: string;\n type: string | number | boolean | null;\n value: string | null;\n maskInputFn?: MaskInputFn;\n}): string {\n let text = value || '';\n if (\n maskInputOptions[tagName.toLowerCase() as keyof MaskInputOptions] ||\n maskInputOptions[type as keyof MaskInputOptions]\n ) {\n if (maskInputFn) {\n text = maskInputFn(text);\n } else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedGetImageData = {\n [ORIGINAL_ATTRIBUTE_NAME]: CanvasImageData['getImageData'];\n} & CanvasImageData['getImageData'];\n\nexport function is2DCanvasBlank(canvas: HTMLCanvasElement): boolean {\n const ctx = canvas.getContext('2d');\n if (!ctx) return true;\n\n const chunkSize = 50;\n\n // get chunks of the canvas and check if it is blank\n for (let x = 0; x < canvas.width; x += chunkSize) {\n for (let y = 0; y < canvas.height; y += chunkSize) {\n const getImageData = ctx.getImageData as PatchedGetImageData;\n const originalGetImageData =\n ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n // by getting the canvas in chunks we avoid an expensive\n // `getImageData` call that retrieves everything\n // even if we can already tell from the first chunk(s) that\n // the canvas isn't blank\n const pixelBuffer = new Uint32Array(\n originalGetImageData.call(\n ctx,\n x,\n y,\n Math.min(chunkSize, canvas.width - x),\n Math.min(chunkSize, canvas.height - y),\n ).data.buffer,\n );\n if (pixelBuffer.some((pixel) => pixel !== 0)) return false;\n }\n }\n return true;\n}\n","import {\n serializedNode,\n serializedNodeWithId,\n NodeType,\n attributes,\n INode,\n idNodeMap,\n MaskInputOptions,\n SlimDOMOptions,\n DataURLOptions,\n MaskTextFn,\n MaskInputFn,\n KeepIframeSrcFn,\n ICanvas,\n} from './types';\nimport {\n is2DCanvasBlank,\n isElement,\n isShadowRoot,\n maskInputValue,\n} from './utils';\n\nlet _id = 1;\nconst tagNameRegex = new RegExp('[^a-z0-9-_:]');\n\nexport const IGNORED_NODE = -2;\n\nfunction genId(): number {\n return _id++;\n}\n\nfunction getValidTagName(element: HTMLElement): string {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n\n const processedTagName = element.tagName.toLowerCase().trim();\n\n if (tagNameRegex.test(processedTagName)) {\n // if the tag name is odd and we cannot extract\n // anything from the string, then we return a\n // generic div\n return 'div';\n }\n\n return processedTagName;\n}\n\nfunction getCssRulesString(s: CSSStyleSheet): string | null {\n try {\n const rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n } catch (error) {\n return null;\n }\n}\n\nfunction getCssRuleString(rule: CSSRule): string {\n let cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n } catch {\n // ignore\n }\n }\n return cssStringified;\n}\n\nfunction isCSSImportRule(rule: CSSRule): rule is CSSImportRule {\n return 'styleSheet' in rule;\n}\n\nfunction stringifyStyleSheet(sheet: CSSStyleSheet): string {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map((rule) => rule.cssText || '')\n .join('')\n : '';\n}\n\nfunction extractOrigin(url: string): string {\n let origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n } else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\n\nlet canvasService: HTMLCanvasElement | null;\nlet canvasCtx: CanvasRenderingContext2D | null;\n\nconst URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nconst RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nconst DATA_URI = /^(data:)([^,]*),(.*)/i;\nexport function absoluteToStylesheet(\n cssText: string | null,\n href: string,\n): string {\n return (cssText || '').replace(\n URL_IN_CSS_REF,\n (origin, quote1, path1, quote2, path2, path3) => {\n const filePath = path1 || path2 || path3;\n const maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return `url(${maybeQuote}${filePath}${maybeQuote})`;\n }\n if (DATA_URI.test(filePath)) {\n return `url(${maybeQuote}${filePath}${maybeQuote})`;\n }\n if (filePath[0] === '/') {\n return `url(${maybeQuote}${\n extractOrigin(href) + filePath\n }${maybeQuote})`;\n }\n const stack = href.split('/');\n const parts = filePath.split('/');\n stack.pop();\n for (const part of parts) {\n if (part === '.') {\n continue;\n } else if (part === '..') {\n stack.pop();\n } else {\n stack.push(part);\n }\n }\n return `url(${maybeQuote}${stack.join('/')}${maybeQuote})`;\n },\n );\n}\n\nconst SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/; // Don't use \\s, to avoid matching non-breaking space\nconst SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc: Document, attributeValue: string) {\n /*\n run absoluteToDoc over every url in the srcset\n\n this is adapted from https://github.com/albell/parse-srcset/\n without the parsing of the descriptors (we return these as-is)\n parce-srcset is in turn based on\n https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute\n */\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n\n let pos = 0;\n\n function collectCharacters(regEx: RegExp) {\n let chars: string;\n let match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n\n let output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n // don't split on commas within urls\n let url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n // aside: according to spec more than one comma at the end is a parse error, but we ignore that\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n // the trailing comma splits the srcset, so the interpretion is that\n // another url will follow, and the descriptor is empty\n output.push(url);\n } else {\n let descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n let inParens = false;\n while (true) {\n let c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n } else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break; // parse the next url\n } else if (c === '(') {\n inParens = true;\n }\n } else {\n // in parenthesis; ignore commas\n // (parenthesis may be supported by future additions to spec)\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\n\nexport function absoluteToDoc(doc: Document, attributeValue: string): string {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n const a: HTMLAnchorElement = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\n\nfunction isSVGElement(el: Element): boolean {\n return Boolean(el.tagName === 'svg' || (el as SVGElement).ownerSVGElement);\n}\n\nfunction getHref() {\n // return a href without hash\n const a = document.createElement('a');\n a.href = '';\n return a.href;\n}\n\nexport function transformAttribute(\n doc: Document,\n tagName: string,\n name: string,\n value: string,\n): string {\n // relative path in attribute\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n } else if (name === 'xlink:href' && value && value[0] !== '#') {\n // xlink:href starts with # is an id pointer\n return absoluteToDoc(doc, value);\n } else if (\n name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')\n ) {\n return absoluteToDoc(doc, value);\n } else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n } else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n } else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n } else {\n return value;\n }\n}\n\nexport function _isBlockedElement(\n element: HTMLElement,\n blockClass: string | RegExp,\n blockSelector: string | null,\n): boolean {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n } else {\n // tslint:disable-next-line: prefer-for-of\n for (let eIndex = 0; eIndex < element.classList.length; eIndex++) {\n const className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n\n return false;\n}\n\nexport function needMaskingText(\n node: Node | null,\n maskTextClass: string | RegExp,\n maskTextSelector: string | null,\n): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if ((node as HTMLElement).classList.contains(maskTextClass)) {\n return true;\n }\n } else {\n // tslint:disable-next-line: prefer-for-of\n for (\n let eIndex = 0;\n eIndex < (node as HTMLElement).classList.length;\n eIndex++\n ) {\n const className = (node as HTMLElement).classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if ((node as HTMLElement).matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\n\n// https://stackoverflow.com/a/36155560\nfunction onceIframeLoaded(\n iframeEl: HTMLIFrameElement,\n listener: () => unknown,\n iframeLoadTimeout: number,\n) {\n const win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n // document is loading\n let fired = false;\n\n let readyState: DocumentReadyState;\n try {\n readyState = win.document.readyState;\n } catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n const timer = setTimeout(() => {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', () => {\n clearTimeout(timer);\n fired = true;\n listener();\n });\n return;\n }\n // check blank frame for Chrome\n const blankUrl = 'about:blank';\n if (\n win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === ''\n ) {\n // iframe was already loaded, make sure we wait to trigger the listener\n // till _after_ the mutation that found this iframe has had time to process\n setTimeout(listener, 0);\n return;\n }\n // use default listener\n iframeEl.addEventListener('load', listener);\n}\n\nfunction serializeNode(\n n: Node,\n options: {\n doc: Document;\n blockClass: string | RegExp;\n blockSelector: string | null;\n maskTextClass: string | RegExp;\n maskTextSelector: string | null;\n inlineStylesheet: boolean;\n maskInputOptions: MaskInputOptions;\n maskTextFn: MaskTextFn | undefined;\n maskInputFn: MaskInputFn | undefined;\n dataURLOptions?: DataURLOptions;\n inlineImages: boolean;\n recordCanvas: boolean;\n keepIframeSrcFn: KeepIframeSrcFn;\n },\n): serializedNode | false {\n const {\n doc,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskInputOptions = {},\n maskTextFn,\n maskInputFn,\n dataURLOptions = {},\n inlineImages,\n recordCanvas,\n keepIframeSrcFn,\n } = options;\n // Only record root id when document object is not the base document\n let rootId: number | undefined;\n if (((doc as unknown) as INode).__sn) {\n const docId = ((doc as unknown) as INode).__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if ((n as HTMLDocument).compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: (n as HTMLDocument).compatMode, // probably \"BackCompat\"\n rootId,\n };\n } else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId,\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: (n as DocumentType).name,\n publicId: (n as DocumentType).publicId,\n systemId: (n as DocumentType).systemId,\n rootId,\n };\n case n.ELEMENT_NODE:\n const needBlock = _isBlockedElement(\n n as HTMLElement,\n blockClass,\n blockSelector,\n );\n const tagName = getValidTagName(n as HTMLElement);\n let attributes: attributes = {};\n for (const { name, value } of Array.from((n as HTMLElement).attributes)) {\n attributes[name] = transformAttribute(doc, tagName, name, value);\n }\n // remote css\n if (tagName === 'link' && inlineStylesheet) {\n const stylesheet = Array.from(doc.styleSheets).find((s) => {\n return s.href === (n as HTMLLinkElement).href;\n });\n let cssText: string | null = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet as CSSStyleSheet);\n }\n if (cssText) {\n delete attributes.rel;\n delete attributes.href;\n attributes._cssText = absoluteToStylesheet(\n cssText,\n stylesheet!.href!,\n );\n }\n }\n // dynamic stylesheet\n if (\n tagName === 'style' &&\n (n as HTMLStyleElement).sheet &&\n // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element\n !(\n (n as HTMLElement).innerText ||\n (n as HTMLElement).textContent ||\n ''\n ).trim().length\n ) {\n const cssText = getCssRulesString(\n (n as HTMLStyleElement).sheet as CSSStyleSheet,\n );\n if (cssText) {\n attributes._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n // form fields\n if (\n tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select'\n ) {\n const value = (n as HTMLInputElement | HTMLTextAreaElement).value;\n if (\n attributes.type !== 'radio' &&\n attributes.type !== 'checkbox' &&\n attributes.type !== 'submit' &&\n attributes.type !== 'button' &&\n value\n ) {\n attributes.value = maskInputValue({\n type: attributes.type,\n tagName,\n value,\n maskInputOptions,\n maskInputFn,\n });\n } else if ((n as HTMLInputElement).checked) {\n attributes.checked = (n as HTMLInputElement).checked;\n }\n }\n if (tagName === 'option') {\n if ((n as HTMLOptionElement).selected && !maskInputOptions['select']) {\n attributes.selected = true;\n } else {\n // ignore the html attribute (which corresponds to DOM (n as HTMLOptionElement).defaultSelected)\n // if it's already been changed\n delete attributes.selected;\n }\n }\n // canvas image data\n if (tagName === 'canvas' && recordCanvas) {\n if ((n as ICanvas).__context === '2d') {\n // only record this on 2d canvas\n if (!is2DCanvasBlank(n as HTMLCanvasElement)) {\n attributes.rr_dataURL = (n as HTMLCanvasElement).toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n }\n } else if (!('__context' in n)) {\n // context is unknown, better not call getContext to trigger it\n const canvasDataURL = (n as HTMLCanvasElement).toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n\n // create blank canvas of same dimensions\n const blankCanvas = document.createElement('canvas');\n blankCanvas.width = (n as HTMLCanvasElement).width;\n blankCanvas.height = (n as HTMLCanvasElement).height;\n const blankCanvasDataURL = blankCanvas.toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n\n // no need to save dataURL if it's the same as blank canvas\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes.rr_dataURL = canvasDataURL;\n }\n }\n }\n // save image offline\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n const image = n as HTMLImageElement;\n const oldValue = image.crossOrigin;\n image.crossOrigin = 'anonymous';\n const recordInlineImage = () => {\n try {\n canvasService!.width = image.naturalWidth;\n canvasService!.height = image.naturalHeight;\n canvasCtx!.drawImage(image, 0, 0);\n attributes.rr_dataURL = canvasService!.toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n } catch (err) {\n console.warn(\n `Cannot inline img src=${image.currentSrc}! Error: ${err}`,\n );\n }\n oldValue\n ? (attributes.crossOrigin = oldValue)\n : delete attributes.crossOrigin;\n };\n // The image content may not have finished loading yet.\n if (image.complete && image.naturalWidth !== 0) recordInlineImage();\n else image.onload = recordInlineImage;\n }\n // media elements\n if (tagName === 'audio' || tagName === 'video') {\n attributes.rr_mediaState = (n as HTMLMediaElement).paused\n ? 'paused'\n : 'played';\n attributes.rr_mediaCurrentTime = (n as HTMLMediaElement).currentTime;\n }\n // scroll\n if ((n as HTMLElement).scrollLeft) {\n attributes.rr_scrollLeft = (n as HTMLElement).scrollLeft;\n }\n if ((n as HTMLElement).scrollTop) {\n attributes.rr_scrollTop = (n as HTMLElement).scrollTop;\n }\n // block element\n if (needBlock) {\n const { width, height } = (n as HTMLElement).getBoundingClientRect();\n attributes = {\n class: attributes.class,\n rr_width: `${width}px`,\n rr_height: `${height}px`,\n };\n }\n // iframe\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src as string)) {\n if (!(n as HTMLIFrameElement).contentDocument) {\n // we can't record it directly as we can't see into it\n // preserve the src attribute so a decision can be taken at replay time\n attributes.rr_src = attributes.src;\n }\n delete attributes.src; // prevent auto loading\n }\n return {\n type: NodeType.Element,\n tagName,\n attributes,\n childNodes: [],\n isSVG: isSVGElement(n as Element) || undefined,\n needBlock,\n rootId,\n };\n case n.TEXT_NODE:\n // The parent node may not be a html element which has a tagName attribute.\n // So just let it be undefined which is ok in this use case.\n const parentTagName =\n n.parentNode && (n.parentNode as HTMLElement).tagName;\n let textContent = (n as Text).textContent;\n const isStyle = parentTagName === 'STYLE' ? true : undefined;\n const isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n // try to read style sheet\n if (n.nextSibling || n.previousSibling) {\n // This is not the only child of the stylesheet.\n // We can't read all of the sheet's .cssRules and expect them\n // to _only_ include the current rule(s) added by the text node.\n // So we'll be conservative and keep textContent as-is.\n } else if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) {\n textContent = stringifyStyleSheet(\n (n.parentNode as HTMLStyleElement).sheet!,\n );\n }\n } catch (err) {\n console.warn(\n `Cannot get CSS styles from text's parentNode. Error: ${err}`,\n n,\n );\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (\n !isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent\n ) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle,\n rootId,\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId,\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: (n as Comment).textContent || '',\n rootId,\n };\n default:\n return false;\n }\n}\n\nfunction lowerIfExists(maybeAttr: string | number | boolean): string {\n if (maybeAttr === undefined) {\n return '';\n } else {\n return (maybeAttr as string).toLowerCase();\n }\n}\n\nfunction slimDOMExcluded(\n sn: serializedNode,\n slimDOMOptions: SlimDOMOptions,\n): boolean {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n // TODO: convert IE conditional comments to real nodes\n return true;\n } else if (sn.type === NodeType.Element) {\n if (\n slimDOMOptions.script &&\n // script tag\n (sn.tagName === 'script' ||\n // preload link\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n // prefetch link\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))\n ) {\n return true;\n } else if (\n slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(\n /^msapplication-tile(image|color)$/,\n ) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))\n ) {\n return true;\n } else if (sn.tagName === 'meta') {\n if (\n slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined\n ) {\n // e.g. X-UA-Compatible, Content-Type, Content-Language,\n // cache-control, X-Translated-By\n return true;\n } else if (\n slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')\n ) {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function serializeNodeWithId(\n n: Node | INode,\n options: {\n doc: Document;\n map: idNodeMap;\n blockClass: string | RegExp;\n blockSelector: string | null;\n maskTextClass: string | RegExp;\n maskTextSelector: string | null;\n skipChild: boolean;\n inlineStylesheet: boolean;\n maskInputOptions?: MaskInputOptions;\n maskTextFn: MaskTextFn | undefined;\n maskInputFn: MaskInputFn | undefined;\n slimDOMOptions: SlimDOMOptions;\n dataURLOptions?: DataURLOptions;\n keepIframeSrcFn?: KeepIframeSrcFn;\n inlineImages?: boolean;\n recordCanvas?: boolean;\n preserveWhiteSpace?: boolean;\n onSerialize?: (n: INode) => unknown;\n onIframeLoad?: (iframeINode: INode, node: serializedNodeWithId) => unknown;\n iframeLoadTimeout?: number;\n },\n): serializedNodeWithId | null {\n const {\n doc,\n map,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n skipChild = false,\n inlineStylesheet = true,\n maskInputOptions = {},\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions = {},\n inlineImages = false,\n recordCanvas = false,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout = 5000,\n keepIframeSrcFn = () => false,\n } = options;\n let { preserveWhiteSpace = true } = options;\n const _serializedNode = serializeNode(n, {\n doc,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n keepIframeSrcFn,\n });\n if (!_serializedNode) {\n // TODO: dev only\n console.warn(n, 'not serialized');\n return null;\n }\n\n let id;\n // Try to reuse the previous id\n if ('__sn' in n) {\n id = n.__sn.id;\n } else if (\n slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)\n ) {\n id = IGNORED_NODE;\n } else {\n id = genId();\n }\n const serializedNode = Object.assign(_serializedNode, { id });\n (n as INode).__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null; // slimDOM\n }\n map[id] = n as INode;\n if (onSerialize) {\n onSerialize(n as INode);\n }\n let recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n // this property was not needed in replay side\n delete serializedNode.needBlock;\n if ((n as HTMLElement).shadowRoot) serializedNode.isShadowHost = true;\n }\n if (\n (serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild\n ) {\n if (\n slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head'\n // would impede performance: || getComputedStyle(n)['white-space'] === 'normal'\n ) {\n preserveWhiteSpace = false;\n }\n const bypassOptions = {\n doc,\n map,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n skipChild,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n };\n for (const childN of Array.from(n.childNodes)) {\n const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n\n if (isElement(n) && n.shadowRoot) {\n for (const childN of Array.from(n.shadowRoot.childNodes)) {\n const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n\n if (\n serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe'\n ) {\n onceIframeLoaded(\n n as HTMLIFrameElement,\n () => {\n const iframeDoc = (n as HTMLIFrameElement).contentDocument;\n if (iframeDoc && onIframeLoad) {\n const serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n skipChild: false,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n });\n\n if (serializedIframeNode) {\n onIframeLoad(n as INode, serializedIframeNode);\n }\n }\n },\n iframeLoadTimeout,\n );\n }\n\n return serializedNode;\n}\n\nfunction snapshot(\n n: Document,\n options?: {\n blockClass?: string | RegExp;\n blockSelector?: string | null;\n maskTextClass?: string | RegExp;\n maskTextSelector?: string | null;\n inlineStylesheet?: boolean;\n maskAllInputs?: boolean | MaskInputOptions;\n maskTextFn?: MaskTextFn;\n maskInputFn?: MaskTextFn;\n slimDOM?: boolean | SlimDOMOptions;\n dataURLOptions?: DataURLOptions;\n inlineImages?: boolean;\n recordCanvas?: boolean;\n preserveWhiteSpace?: boolean;\n onSerialize?: (n: INode) => unknown;\n onIframeLoad?: (iframeINode: INode, node: serializedNodeWithId) => unknown;\n iframeLoadTimeout?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n },\n): [serializedNodeWithId | null, idNodeMap] {\n const {\n blockClass = 'rr-block',\n blockSelector = null,\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n inlineStylesheet = true,\n inlineImages = false,\n recordCanvas = false,\n maskAllInputs = false,\n maskTextFn,\n maskInputFn,\n slimDOM = false,\n dataURLOptions,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn = () => false,\n } = options || {};\n const idNodeMap: idNodeMap = {};\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : maskAllInputs === false\n ? {\n password: true,\n }\n : maskAllInputs;\n const slimDOMOptions: SlimDOMOptions =\n slimDOM === true || slimDOM === 'all'\n ? // if true: set of sensible options that should not throw away any information\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all', // destructive\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true,\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n skipChild: false,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n }),\n idNodeMap,\n ];\n}\n\nexport function visitSnapshot(\n node: serializedNodeWithId,\n onVisit: (node: serializedNodeWithId) => unknown,\n) {\n function walk(current: serializedNodeWithId) {\n onVisit(current);\n if (\n current.type === NodeType.Document ||\n current.type === NodeType.Element\n ) {\n current.childNodes.forEach(walk);\n }\n }\n\n walk(node);\n}\n\nexport function cleanupSnapshot() {\n // allow a new recording to start numbering nodes from scratch\n _id = 1;\n}\n\nexport default snapshot;\n","/**\n * This file is a fork of https://github.com/reworkcss/css/blob/master/lib/parse/index.js\n * I fork it because:\n * 1. The css library was built for node.js which does not have tree-shaking supports.\n * 2. Rewrites into typescript give us a better type interface.\n */\n\n/* tslint:disable no-conditional-assignment interface-name no-shadowed-variable */\n\nexport interface ParserOptions {\n /** Silently fail on parse errors */\n silent?: boolean;\n /**\n * The path to the file containing css.\n * Makes errors and source maps more helpful, by letting them know where code comes from.\n */\n source?: string;\n}\n\n/**\n * Error thrown during parsing.\n */\nexport interface ParserError {\n /** The full error message with the source position. */\n message?: string;\n /** The error message without position. */\n reason?: string;\n /** The value of options.source if passed to css.parse. Otherwise undefined. */\n filename?: string;\n line?: number;\n column?: number;\n /** The portion of code that couldn't be parsed. */\n source?: string;\n}\n\nexport interface Loc {\n line?: number;\n column?: number;\n}\n\n/**\n * Base AST Tree Node.\n */\nexport interface Node {\n /** The possible values are the ones listed in the Types section on https://github.com/reworkcss/css page. */\n type?: string;\n /** A reference to the parent node, or null if the node has no parent. */\n parent?: Node;\n /** Information about the position in the source string that corresponds to the node. */\n position?: {\n start?: Loc;\n end?: Loc;\n /** The value of options.source if passed to css.parse. Otherwise undefined. */\n source?: string;\n /** The full source string passed to css.parse. */\n content?: string;\n };\n}\n\nexport interface Rule extends Node {\n /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n selectors?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\nexport interface Declaration extends Node {\n /** The property name, trimmed from whitespace and comments. May not be empty. */\n property?: string;\n /** The value of the property, trimmed from whitespace and comments. Empty values are allowed. */\n value?: string;\n}\n\n/**\n * A rule-level or declaration-level comment. Comments inside selectors, properties and values etc. are lost.\n */\nexport interface Comment extends Node {\n comment?: string;\n}\n\n/**\n * The @charset at-rule.\n */\nexport interface Charset extends Node {\n /** The part following @charset. */\n charset?: string;\n}\n\n/**\n * The @custom-media at-rule\n */\nexport interface CustomMedia extends Node {\n /** The ---prefixed name. */\n name?: string;\n /** The part following the name. */\n media?: string;\n}\n\n/**\n * The @document at-rule.\n */\nexport interface Document extends Node {\n /** The part following @document. */\n document?: string;\n /** The vendor prefix in @document, or undefined if there is none. */\n vendor?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @font-face at-rule.\n */\nexport interface FontFace extends Node {\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @host at-rule.\n */\nexport interface Host extends Node {\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @import at-rule.\n */\nexport interface Import extends Node {\n /** The part following @import. */\n import?: string;\n}\n\n/**\n * The @keyframes at-rule.\n */\nexport interface KeyFrames extends Node {\n /** The name of the keyframes rule. */\n name?: string;\n /** The vendor prefix in @keyframes, or undefined if there is none. */\n vendor?: string;\n /** Array of nodes with the types keyframe and comment. */\n keyframes?: Array;\n}\n\nexport interface KeyFrame extends Node {\n /** The list of \"selectors\" of the keyframe rule, split on commas. Each “selector” is trimmed from whitespace. */\n values?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @media at-rule.\n */\nexport interface Media extends Node {\n /** The part following @media. */\n media?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @namespace at-rule.\n */\nexport interface Namespace extends Node {\n /** The part following @namespace. */\n namespace?: string;\n}\n\n/**\n * The @page at-rule.\n */\nexport interface Page extends Node {\n /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n selectors?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @supports at-rule.\n */\nexport interface Supports extends Node {\n /** The part following @supports. */\n supports?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/** All at-rules. */\nexport type AtRule =\n | Charset\n | CustomMedia\n | Document\n | FontFace\n | Host\n | Import\n | KeyFrames\n | Media\n | Namespace\n | Page\n | Supports;\n\n/**\n * A collection of rules\n */\nexport interface StyleRules {\n source?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules: Array;\n /** Array of Errors. Errors collected during parsing when option silent is true. */\n parsingErrors?: ParserError[];\n}\n\n/**\n * The root node returned by css.parse.\n */\nexport interface Stylesheet extends Node {\n stylesheet?: StyleRules;\n}\n\n// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nconst commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nexport function parse(css: string, options: ParserOptions = {}) {\n /**\n * Positional.\n */\n\n let lineno = 1;\n let column = 1;\n\n /**\n * Update lineno and column based on `str`.\n */\n\n function updatePosition(str: string) {\n const lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n let i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n\n /**\n * Mark position and patch `node.position`.\n */\n\n function position() {\n const start = { line: lineno, column };\n return (\n node: Rule | Declaration | Comment | AtRule | Stylesheet | KeyFrame,\n ) => {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node\n */\n\n class Position {\n public content!: string;\n public start!: Loc;\n public end!: Loc;\n public source?: string;\n\n constructor(start: Loc) {\n this.start = start;\n this.end = { line: lineno, column };\n this.source = options.source;\n }\n }\n\n /**\n * Non-enumerable source string\n */\n\n Position.prototype.content = css;\n\n const errorsList: ParserError[] = [];\n\n function error(msg: string) {\n const err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg,\n ) as ParserError;\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Parse stylesheet.\n */\n\n function stylesheet(): Stylesheet {\n const rulesList = rules();\n\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList,\n },\n };\n }\n\n /**\n * Opening brace.\n */\n\n function open() {\n return match(/^{\\s*/);\n }\n\n /**\n * Closing brace.\n */\n\n function close() {\n return match(/^}/);\n }\n\n /**\n * Parse ruleset.\n */\n\n function rules() {\n let node: Rule | void;\n const rules: Rule[] = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n\n /**\n * Match `re` and return captures.\n */\n\n function match(re: RegExp) {\n const m = re.exec(css);\n if (!m) {\n return;\n }\n const str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n\n function whitespace() {\n match(/^\\s*/);\n }\n\n /**\n * Parse comments;\n */\n\n function comments(rules: Rule[] = []) {\n let c: Comment | void;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n\n /**\n * Parse comment.\n */\n\n function comment() {\n const pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n\n let i = 2;\n while (\n '' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n const str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n\n return pos({\n type: 'comment',\n comment: str,\n });\n }\n\n /**\n * Parse selector.\n */\n\n function selector() {\n const m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n /* @fix Remove all comments from selectors\n * http://ostermiller.org/findcomment.html */\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, (m) => {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map((s) => {\n return s.replace(/\\u200C/g, ',');\n });\n }\n\n /**\n * Parse declaration.\n */\n\n function declaration(): Declaration | void | never {\n const pos = position();\n\n // prop\n let propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n const prop = trim(propMatch[0]);\n\n // :\n if (!match(/^:\\s*/)) {\n return error(`property missing ':'`);\n }\n\n // val\n const val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n\n const ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : '',\n });\n\n // ;\n match(/^[;\\s]*/);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n */\n\n function declarations() {\n const decls: Array = [];\n\n if (!open()) {\n return error(`missing '{'`);\n }\n comments(decls);\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n if ((decl as unknown) !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n\n if (!close()) {\n return error(`missing '}'`);\n }\n return decls;\n }\n\n /**\n * Parse keyframe.\n */\n\n function keyframe() {\n let m;\n const vals = [];\n const pos = position();\n\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n\n if (!vals.length) {\n return;\n }\n\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations() as Declaration[],\n });\n }\n\n /**\n * Parse keyframes.\n */\n\n function atkeyframes() {\n const pos = position();\n let m = match(/^@([-\\w]+)?keyframes\\s*/);\n\n if (!m) {\n return;\n }\n const vendor = m[1];\n\n // identifier\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n const name = m[1];\n\n if (!open()) {\n return error(`@keyframes missing '{'`);\n }\n\n let frame;\n let frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n\n if (!close()) {\n return error(`@keyframes missing '}'`);\n }\n\n return pos({\n type: 'keyframes',\n name,\n vendor,\n keyframes: frames,\n });\n }\n\n /**\n * Parse supports.\n */\n\n function atsupports() {\n const pos = position();\n const m = match(/^@supports *([^{]+)/);\n\n if (!m) {\n return;\n }\n const supports = trim(m[1]);\n\n if (!open()) {\n return error(`@supports missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@supports missing '}'`);\n }\n\n return pos({\n type: 'supports',\n supports,\n rules: style,\n });\n }\n\n /**\n * Parse host.\n */\n\n function athost() {\n const pos = position();\n const m = match(/^@host\\s*/);\n\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(`@host missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@host missing '}'`);\n }\n\n return pos({\n type: 'host',\n rules: style,\n });\n }\n\n /**\n * Parse media.\n */\n\n function atmedia() {\n const pos = position();\n const m = match(/^@media *([^{]+)/);\n\n if (!m) {\n return;\n }\n const media = trim(m[1]);\n\n if (!open()) {\n return error(`@media missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@media missing '}'`);\n }\n\n return pos({\n type: 'media',\n media,\n rules: style,\n });\n }\n\n /**\n * Parse custom-media.\n */\n\n function atcustommedia() {\n const pos = position();\n const m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2]),\n });\n }\n\n /**\n * Parse paged media.\n */\n\n function atpage() {\n const pos = position();\n const m = match(/^@page */);\n if (!m) {\n return;\n }\n\n const sel = selector() || [];\n\n if (!open()) {\n return error(`@page missing '{'`);\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(`@page missing '}'`);\n }\n\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls,\n });\n }\n\n /**\n * Parse document.\n */\n\n function atdocument() {\n const pos = position();\n const m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n\n const vendor = trim(m[1]);\n const doc = trim(m[2]);\n\n if (!open()) {\n return error(`@document missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@document missing '}'`);\n }\n\n return pos({\n type: 'document',\n document: doc,\n vendor,\n rules: style,\n });\n }\n\n /**\n * Parse font-face.\n */\n\n function atfontface() {\n const pos = position();\n const m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(`@font-face missing '{'`);\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(`@font-face missing '}'`);\n }\n\n return pos({\n type: 'font-face',\n declarations: decls,\n });\n }\n\n /**\n * Parse import\n */\n\n const atimport = _compileAtrule('import');\n\n /**\n * Parse charset\n */\n\n const atcharset = _compileAtrule('charset');\n\n /**\n * Parse namespace\n */\n\n const atnamespace = _compileAtrule('namespace');\n\n /**\n * Parse non-block at-rules\n */\n\n function _compileAtrule(name: string) {\n const re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return () => {\n const pos = position();\n const m = match(re);\n if (!m) {\n return;\n }\n const ret: Record = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n\n /**\n * Parse at rule.\n */\n\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n\n return (\n atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface()\n );\n }\n\n /**\n * Parse rule.\n */\n\n function rule() {\n const pos = position();\n const sel = selector();\n\n if (!sel) {\n return error('selector missing');\n }\n comments();\n\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations() as Declaration[],\n });\n }\n\n return addParent(stylesheet());\n}\n\n/**\n * Trim `str`.\n */\n\nfunction trim(str: string) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\n\n/**\n * Adds non-enumerable parent node reference to each node.\n */\n\nfunction addParent(obj: Stylesheet, parent?: Stylesheet) {\n const isNode = obj && typeof obj.type === 'string';\n const childParent = isNode ? obj : parent;\n\n for (const k of Object.keys(obj)) {\n const value = obj[k as keyof Stylesheet];\n if (Array.isArray(value)) {\n value.forEach((v) => {\n addParent(v, childParent);\n });\n } else if (value && typeof value === 'object') {\n addParent((value as unknown) as Stylesheet, childParent);\n }\n }\n\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null,\n });\n }\n\n return obj;\n}\n","import { parse } from './css';\nimport {\n serializedNodeWithId,\n NodeType,\n tagMap,\n elementNode,\n idNodeMap,\n INode,\n BuildCache,\n} from './types';\nimport { isElement } from './utils';\n\nconst tagMap: tagMap = {\n script: 'noscript',\n // camel case svg element tag names\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient',\n};\nfunction getTagName(n: elementNode): string {\n let tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\n\n// based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nfunction escapeRegExp(str: string) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nconst HOVER_SELECTOR = /([^\\\\]):hover/;\nconst HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nexport function addHoverClass(cssText: string, cache: BuildCache): string {\n const cachedStyle = cache?.stylesWithHoverClass.get(cssText);\n if (cachedStyle) return cachedStyle;\n\n const ast = parse(cssText, {\n silent: true,\n });\n\n if (!ast.stylesheet) {\n return cssText;\n }\n\n const selectors: string[] = [];\n ast.stylesheet.rules.forEach((rule) => {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach((selector: string) => {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n\n if (selectors.length === 0) {\n return cssText;\n }\n\n const selectorMatcher = new RegExp(\n selectors\n .filter((selector, index) => selectors.indexOf(selector) === index)\n .sort((a, b) => b.length - a.length)\n .map((selector) => {\n return escapeRegExp(selector);\n })\n .join('|'),\n 'g',\n );\n\n const result = cssText.replace(selectorMatcher, (selector) => {\n const newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return `${selector}, ${newSelector}`;\n });\n cache?.stylesWithHoverClass.set(cssText, result);\n return result;\n}\n\nexport function createCache(): BuildCache {\n const stylesWithHoverClass: Map = new Map();\n return {\n stylesWithHoverClass,\n };\n}\n\nfunction buildNode(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n hackCss: boolean;\n cache: BuildCache;\n },\n): Node | null {\n const { doc, hackCss, cache } = options;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(\n n.name || 'html',\n n.publicId,\n n.systemId,\n );\n case NodeType.Element:\n const tagName = getTagName(n);\n let node: Element;\n if (n.isSVG) {\n node = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n } else {\n node = doc.createElement(tagName);\n }\n for (const name in n.attributes) {\n if (!n.attributes.hasOwnProperty(name)) {\n continue;\n }\n let value = n.attributes[name];\n if (tagName === 'option' && name === 'selected' && value === false) {\n // legacy fix (TODO: if `value === false` can be generated for other attrs, should we also omit those other attrs from build?)\n continue;\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n // attribute names start with rr_ are internal attributes added by rrweb\n if (!name.startsWith('rr_')) {\n const isTextarea = tagName === 'textarea' && name === 'value';\n const isRemoteOrDynamicCss =\n tagName === 'style' && name === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n const child = doc.createTextNode(value);\n // https://github.com/rrweb-io/rrweb/issues/112\n for (const c of Array.from(node.childNodes)) {\n if (c.nodeType === node.TEXT_NODE) {\n node.removeChild(c);\n }\n }\n node.appendChild(child);\n continue;\n }\n\n try {\n if (n.isSVG && name === 'xlink:href') {\n node.setAttributeNS('http://www.w3.org/1999/xlink', name, value);\n } else if (\n name === 'onload' ||\n name === 'onclick' ||\n name.substring(0, 7) === 'onmouse'\n ) {\n // Rename some of the more common atttributes from https://www.w3schools.com/tags/ref_eventattributes.asp\n // as setting them triggers a console.error (which shows up despite the try/catch)\n // Assumption: these attributes are not used to css\n node.setAttribute('_' + name, value);\n } else if (\n tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name === 'content'\n ) {\n // If CSP contains style-src and inline-style is disabled, there will be an error \"Refused to apply inline style because it violates the following Content Security Policy directive: style-src '*'\".\n // And the function insertStyleRules in rrweb replayer will throw an error \"Uncaught TypeError: Cannot read property 'insertRule' of null\".\n node.setAttribute('csp-content', value);\n continue;\n } else if (\n tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script'\n ) {\n // ignore\n } else if (\n tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')\n ) {\n // ignore\n } else if (\n tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL\n ) {\n // backup original img srcset\n node.setAttribute('rrweb-original-srcset', n.attributes.srcset as string);\n } else {\n node.setAttribute(name, value);\n }\n } catch (error) {\n // skip invalid attribute\n }\n } else {\n // handle internal attributes\n if (tagName === 'canvas' && name === 'rr_dataURL') {\n const image = document.createElement('img');\n image.src = value;\n image.onload = () => {\n const ctx = (node as HTMLCanvasElement).getContext('2d');\n if (ctx) {\n ctx.drawImage(image, 0, 0, image.width, image.height);\n }\n };\n } else if (tagName === 'img' && name === 'rr_dataURL') {\n const image = node as HTMLImageElement;\n if (!image.currentSrc.startsWith('data:')) {\n // Backup original img src. It may not have been set yet.\n image.setAttribute(\n 'rrweb-original-src',\n n.attributes.src as string,\n );\n image.src = value;\n }\n }\n\n if (name === 'rr_width') {\n (node as HTMLElement).style.width = value;\n } else if (name === 'rr_height') {\n (node as HTMLElement).style.height = value;\n } else if (name === 'rr_mediaCurrentTime') {\n (node as HTMLMediaElement).currentTime = n.attributes\n .rr_mediaCurrentTime as number;\n } else if (name === 'rr_mediaState') {\n switch (value) {\n case 'played':\n (node as HTMLMediaElement)\n .play()\n .catch((e) => console.warn('media playback error', e));\n break;\n case 'paused':\n (node as HTMLMediaElement).pause();\n break;\n default:\n }\n }\n }\n }\n\n if (n.isShadowHost) {\n /**\n * Since node is newly rebuilt, it should be a normal element\n * without shadowRoot.\n * But if there are some weird situations that has defined\n * custom element in the scope before we rebuild node, it may\n * register the shadowRoot earlier.\n * The logic in the 'else' block is just a try-my-best solution\n * for the corner case, please let we know if it is wrong and\n * we can remove it.\n */\n if (!node.shadowRoot) {\n node.attachShadow({ mode: 'open' });\n } else {\n while (node.shadowRoot.firstChild) {\n node.shadowRoot.removeChild(node.shadowRoot.firstChild);\n }\n }\n }\n return node;\n case NodeType.Text:\n return doc.createTextNode(\n n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent,\n );\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\n\nexport function buildNodeWithSN(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n map: idNodeMap;\n skipChild?: boolean;\n hackCss: boolean;\n afterAppend?: (n: INode) => unknown;\n cache: BuildCache;\n },\n): INode | null {\n const {\n doc,\n map,\n skipChild = false,\n hackCss = true,\n afterAppend,\n cache,\n } = options;\n let node = buildNode(n, { doc, hackCss, cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(\n ((map[n.rootId] as unknown) as Document) === doc,\n 'Target document should has the same root id.',\n );\n }\n // use target document as root document\n if (n.type === NodeType.Document) {\n // close before open to make sure document was closed\n doc.close();\n doc.open();\n if (\n n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType // there isn't one already defined\n ) {\n // Trigger compatMode in the iframe\n // this is needed as document.createElement('iframe') otherwise inherits a CSS1Compat mode from the parent replayer environment\n if (\n n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml'\n ) {\n // might as well use an xhtml doctype if we've got an xhtml namespace\n doc.write(\n '',\n );\n } else {\n doc.write(\n '',\n );\n }\n }\n node = doc;\n }\n\n (node as INode).__sn = n;\n map[n.id] = node as INode;\n\n if (\n (n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild\n ) {\n for (const childN of n.childNodes) {\n const childNode = buildNodeWithSN(childN, {\n doc,\n map,\n skipChild: false,\n hackCss,\n afterAppend,\n cache,\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n } else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n\n return node as INode;\n}\n\nfunction visit(idNodeMap: idNodeMap, onVisit: (node: INode) => void) {\n function walk(node: INode) {\n onVisit(node);\n }\n\n for (const key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\n\nfunction handleScroll(node: INode) {\n const n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n const el = (node as Node) as HTMLElement;\n for (const name in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name) && name.startsWith('rr_'))) {\n continue;\n }\n const value = n.attributes[name];\n if (name === 'rr_scrollLeft') {\n el.scrollLeft = value as number;\n }\n if (name === 'rr_scrollTop') {\n el.scrollTop = value as number;\n }\n }\n}\n\nfunction rebuild(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n onVisit?: (node: INode) => unknown;\n hackCss?: boolean;\n afterAppend?: (n: INode) => unknown;\n cache: BuildCache;\n },\n): [Node | null, idNodeMap] {\n const { doc, onVisit, hackCss = true, afterAppend, cache } = options;\n const idNodeMap: idNodeMap = {};\n const node = buildNodeWithSN(n, {\n doc,\n map: idNodeMap,\n skipChild: false,\n hackCss,\n afterAppend,\n cache,\n });\n visit(idNodeMap, (visitedNode) => {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport default rebuild;\n"],"names":["NodeType","isElement","n","nodeType","ELEMENT_NODE","isShadowRoot","host","Boolean","shadowRoot","maskInputValue","_a","maskInputOptions","tagName","type","value","maskInputFn","text","toLowerCase","repeat","length","ORIGINAL_ATTRIBUTE_NAME","is2DCanvasBlank","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","call","Math","min","data","buffer","some","pixel","canvasService","canvasCtx","_id","tagNameRegex","RegExp","getCssRulesString","s","rules","cssRules","Array","from","map","getCssRuleString","join","error","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","slice","stack","parts","pop","parts_1","_i","part","push","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","classList","contains","eIndex","className","matches","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","Object","assign","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","_m","_l","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","commentre","parse","css","lineno","column","updatePosition","str","lines","i","lastIndexOf","position","start","line","Position","whitespace","this","end","source","prototype","content","errorsList","msg","Error","reason","filename","silent","open","close","comments","atrule","re","m","selector","declaration","propMatch","prop","val","ret","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","vendor","frame","frames","concat","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","atdocument","sel","selectors","atpage","athost","atfontface","addParent","parsingErrors","obj","parent","isNode","childParent","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cache","cachedStyle","stylesWithHoverClass","get","ast","selectorMatcher","filter","index","sort","b","result","newSelector","set","buildNode","hackCss","implementation","createDocument","createDocumentType","node_1","getTagName","createElementNS","hasOwnProperty","startsWith","image","setAttribute","play","e","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","removeChild","appendChild","setAttributeNS","srcset","firstChild","attachShadow","mode","createCDATASection","createComment","buildNodeWithSN","afterAppend","assert","xmlns","write","childN","childNode","Map","onVisit","idNodeMap","key","visit","visitedNode","name_2","handleScroll","maskAllInputs","slimDOM","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","walk","current"],"mappings":"2CAAA,IAAYA,WCEIC,EAAUC,GACxB,OAAOA,EAAEC,WAAaD,EAAEE,sBAGVC,EAAaH,SACrBI,YAAwBJ,wBAAkBI,KAChD,OAAOC,QAAQD,GAAQA,EAAKE,YAAcF,EAAKE,aAAeN,YAGhDO,EAAeC,OAC7BC,qBACAC,YACAC,SACAC,UACAC,gBAQIC,EAAOF,GAAS,GAWpB,OATEH,EAAiBC,EAAQK,gBACzBN,EAAiBE,MAGfG,EADED,EACKA,EAAYC,GAEZ,IAAIE,OAAOF,EAAKG,SAGpBH,qBDnCGhB,EAAAA,aAAAA,yCAEVA,mCACAA,yBACAA,mBACAA,qBACAA,yBCgCF,IAAMoB,EAA0B,8BAKhBC,EAAgBC,GAC9B,IAAMC,EAAMD,EAAOE,WAAW,MAC9B,IAAKD,EAAK,OAAO,EAKjB,IAHA,IAGSE,EAAI,EAAGA,EAAIH,EAAOI,MAAOD,GAHhB,GAIhB,IAAK,IAAIE,EAAI,EAAGA,EAAIL,EAAOM,OAAQD,GAJnB,GAImC,CACjD,IAAME,EAAeN,EAAIM,aACn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"rrweb-snapshot.min.js","sources":["../src/types.ts","../src/utils.ts","../src/snapshot.ts","../src/css.ts","../src/rebuild.ts"],"sourcesContent":["export enum NodeType {\n Document,\n DocumentType,\n Element,\n Text,\n CDATA,\n Comment,\n}\n\nexport type documentNode = {\n type: NodeType.Document;\n childNodes: serializedNodeWithId[];\n compatMode?: string;\n};\n\nexport type documentTypeNode = {\n type: NodeType.DocumentType;\n name: string;\n publicId: string;\n systemId: string;\n};\n\nexport type attributes = {\n [key: string]: string | number | boolean;\n};\nexport type elementNode = {\n type: NodeType.Element;\n tagName: string;\n attributes: attributes;\n childNodes: serializedNodeWithId[];\n isSVG?: true;\n needBlock?: boolean;\n};\n\nexport type textNode = {\n type: NodeType.Text;\n textContent: string;\n isStyle?: true;\n};\n\nexport type cdataNode = {\n type: NodeType.CDATA;\n textContent: '';\n};\n\nexport type commentNode = {\n type: NodeType.Comment;\n textContent: string;\n};\n\nexport type serializedNode = (\n | documentNode\n | documentTypeNode\n | elementNode\n | textNode\n | cdataNode\n | commentNode\n) & {\n rootId?: number;\n isShadowHost?: boolean;\n isShadow?: boolean;\n};\n\nexport type serializedNodeWithId = serializedNode & { id: number };\n\nexport type tagMap = {\n [key: string]: string;\n};\n\nexport interface INode extends Node {\n __sn: serializedNodeWithId;\n}\n\nexport interface ICanvas extends HTMLCanvasElement {\n __context: string;\n}\n\nexport type idNodeMap = {\n [key: number]: INode;\n};\n\nexport type MaskInputOptions = Partial<{\n color: boolean;\n date: boolean;\n 'datetime-local': boolean;\n email: boolean;\n month: boolean;\n number: boolean;\n range: boolean;\n search: boolean;\n tel: boolean;\n text: boolean;\n time: boolean;\n url: boolean;\n week: boolean;\n // unify textarea and select element with text input\n textarea: boolean;\n select: boolean;\n password: boolean;\n}>;\n\nexport type SlimDOMOptions = Partial<{\n script: boolean;\n comment: boolean;\n headFavicon: boolean;\n headWhitespace: boolean;\n headMetaDescKeywords: boolean;\n headMetaSocial: boolean;\n headMetaRobots: boolean;\n headMetaHttpEquiv: boolean;\n headMetaAuthorship: boolean;\n headMetaVerification: boolean;\n}>;\n\nexport type DataURLOptions = Partial<{\n type: string;\n quality: number;\n}>;\n\nexport type MaskTextFn = (text: string) => string;\nexport type MaskInputFn = (text: string) => string;\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\nexport type BuildCache = {\n stylesWithHoverClass: Map;\n};\n","import { INode, MaskInputFn, MaskInputOptions } from './types';\n\nexport function isElement(n: Node | INode): n is Element {\n return n.nodeType === n.ELEMENT_NODE;\n}\n\nexport function isShadowRoot(n: Node): n is ShadowRoot {\n const host: Element | null = (n as ShadowRoot)?.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\n\nexport function maskInputValue({\n input,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n tagName,\n type,\n value,\n maskInputFn,\n}: {\n input: HTMLElement;\n maskInputSelector: string|null;\n unmaskInputSelector: string|null;\n maskInputOptions: MaskInputOptions;\n tagName: string;\n type: string | number | boolean | null;\n value: string | null;\n maskInputFn?: MaskInputFn;\n}): string {\n let text = value || '';\n\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n\n if (\n maskInputOptions[tagName.toLowerCase() as keyof MaskInputOptions] ||\n maskInputOptions[type as keyof MaskInputOptions] ||\n (maskInputSelector && input.matches(maskInputSelector))\n ) {\n if (maskInputFn) {\n text = maskInputFn(text);\n } else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedGetImageData = {\n [ORIGINAL_ATTRIBUTE_NAME]: CanvasImageData['getImageData'];\n} & CanvasImageData['getImageData'];\n\nexport function is2DCanvasBlank(canvas: HTMLCanvasElement): boolean {\n const ctx = canvas.getContext('2d');\n if (!ctx) return true;\n\n const chunkSize = 50;\n\n // get chunks of the canvas and check if it is blank\n for (let x = 0; x < canvas.width; x += chunkSize) {\n for (let y = 0; y < canvas.height; y += chunkSize) {\n const getImageData = ctx.getImageData as PatchedGetImageData;\n const originalGetImageData =\n ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n // by getting the canvas in chunks we avoid an expensive\n // `getImageData` call that retrieves everything\n // even if we can already tell from the first chunk(s) that\n // the canvas isn't blank\n const pixelBuffer = new Uint32Array(\n originalGetImageData.call(\n ctx,\n x,\n y,\n Math.min(chunkSize, canvas.width - x),\n Math.min(chunkSize, canvas.height - y),\n ).data.buffer,\n );\n if (pixelBuffer.some((pixel) => pixel !== 0)) return false;\n }\n }\n return true;\n}\n","import {\n serializedNode,\n serializedNodeWithId,\n NodeType,\n attributes,\n INode,\n idNodeMap,\n MaskInputOptions,\n SlimDOMOptions,\n DataURLOptions,\n MaskTextFn,\n MaskInputFn,\n KeepIframeSrcFn,\n ICanvas,\n} from './types';\nimport {\n is2DCanvasBlank,\n isElement,\n isShadowRoot,\n maskInputValue,\n} from './utils';\n\nlet _id = 1;\nconst tagNameRegex = new RegExp('[^a-z0-9-_:]');\n\nexport const IGNORED_NODE = -2;\n\nfunction genId(): number {\n return _id++;\n}\n\nfunction getValidTagName(element: HTMLElement): string {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n\n const processedTagName = element.tagName.toLowerCase().trim();\n\n if (tagNameRegex.test(processedTagName)) {\n // if the tag name is odd and we cannot extract\n // anything from the string, then we return a\n // generic div\n return 'div';\n }\n\n return processedTagName;\n}\n\nfunction getCssRulesString(s: CSSStyleSheet): string | null {\n try {\n const rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n } catch (error) {\n return null;\n }\n}\n\nfunction getCssRuleString(rule: CSSRule): string {\n let cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n } catch {\n // ignore\n }\n }\n return cssStringified;\n}\n\nfunction isCSSImportRule(rule: CSSRule): rule is CSSImportRule {\n return 'styleSheet' in rule;\n}\n\nfunction stringifyStyleSheet(sheet: CSSStyleSheet): string {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map((rule) => rule.cssText || '')\n .join('')\n : '';\n}\n\nfunction extractOrigin(url: string): string {\n let origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n } else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\n\nlet canvasService: HTMLCanvasElement | null;\nlet canvasCtx: CanvasRenderingContext2D | null;\n\nconst URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nconst RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nconst DATA_URI = /^(data:)([^,]*),(.*)/i;\nexport function absoluteToStylesheet(\n cssText: string | null,\n href: string,\n): string {\n return (cssText || '').replace(\n URL_IN_CSS_REF,\n (origin, quote1, path1, quote2, path2, path3) => {\n const filePath = path1 || path2 || path3;\n const maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return `url(${maybeQuote}${filePath}${maybeQuote})`;\n }\n if (DATA_URI.test(filePath)) {\n return `url(${maybeQuote}${filePath}${maybeQuote})`;\n }\n if (filePath[0] === '/') {\n return `url(${maybeQuote}${\n extractOrigin(href) + filePath\n }${maybeQuote})`;\n }\n const stack = href.split('/');\n const parts = filePath.split('/');\n stack.pop();\n for (const part of parts) {\n if (part === '.') {\n continue;\n } else if (part === '..') {\n stack.pop();\n } else {\n stack.push(part);\n }\n }\n return `url(${maybeQuote}${stack.join('/')}${maybeQuote})`;\n },\n );\n}\n\nconst SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/; // Don't use \\s, to avoid matching non-breaking space\nconst SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc: Document, attributeValue: string) {\n /*\n run absoluteToDoc over every url in the srcset\n\n this is adapted from https://github.com/albell/parse-srcset/\n without the parsing of the descriptors (we return these as-is)\n parce-srcset is in turn based on\n https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute\n */\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n\n let pos = 0;\n\n function collectCharacters(regEx: RegExp) {\n let chars: string;\n let match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n\n let output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n // don't split on commas within urls\n let url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n // aside: according to spec more than one comma at the end is a parse error, but we ignore that\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n // the trailing comma splits the srcset, so the interpretion is that\n // another url will follow, and the descriptor is empty\n output.push(url);\n } else {\n let descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n let inParens = false;\n while (true) {\n let c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n } else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break; // parse the next url\n } else if (c === '(') {\n inParens = true;\n }\n } else {\n // in parenthesis; ignore commas\n // (parenthesis may be supported by future additions to spec)\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\n\nexport function absoluteToDoc(doc: Document, attributeValue: string): string {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n const a: HTMLAnchorElement = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\n\nfunction isSVGElement(el: Element): boolean {\n return Boolean(el.tagName === 'svg' || (el as SVGElement).ownerSVGElement);\n}\n\nfunction getHref() {\n // return a href without hash\n const a = document.createElement('a');\n a.href = '';\n return a.href;\n}\n\nexport function transformAttribute(\n doc: Document,\n tagName: string,\n name: string,\n value: string,\n): string {\n // relative path in attribute\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n } else if (name === 'xlink:href' && value && value[0] !== '#') {\n // xlink:href starts with # is an id pointer\n return absoluteToDoc(doc, value);\n } else if (\n name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')\n ) {\n return absoluteToDoc(doc, value);\n } else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n } else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n } else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n } else {\n return value;\n }\n}\n\nexport function _isBlockedElement(\n element: HTMLElement,\n blockClass: string | RegExp,\n blockSelector: string | null,\n unblockSelector: string | null,\n): boolean {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n } else {\n // tslint:disable-next-line: prefer-for-of\n for (let eIndex = 0; eIndex < element.classList.length; eIndex++) {\n const className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n\n return false;\n}\n\nexport function needMaskingText(\n node: Node | null,\n maskTextClass: string | RegExp,\n maskTextSelector: string | null,\n unmaskTextSelector: string | null,\n): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if ((node as HTMLElement).matches(unmaskTextSelector) || (node as HTMLElement).closest(unmaskTextSelector)) {\n return false;\n }\n }\n\n if (typeof maskTextClass === 'string') {\n if ((node as HTMLElement).classList.contains(maskTextClass)) {\n return true;\n }\n } else {\n // tslint:disable-next-line: prefer-for-of\n for (\n let eIndex = 0;\n eIndex < (node as HTMLElement).classList.length;\n eIndex++\n ) {\n const className = (node as HTMLElement).classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if ((node as HTMLElement).matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\n\n// https://stackoverflow.com/a/36155560\nfunction onceIframeLoaded(\n iframeEl: HTMLIFrameElement,\n listener: () => unknown,\n iframeLoadTimeout: number,\n) {\n const win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n // document is loading\n let fired = false;\n\n let readyState: DocumentReadyState;\n try {\n readyState = win.document.readyState;\n } catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n const timer = setTimeout(() => {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', () => {\n clearTimeout(timer);\n fired = true;\n listener();\n });\n return;\n }\n // check blank frame for Chrome\n const blankUrl = 'about:blank';\n if (\n win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === ''\n ) {\n // iframe was already loaded, make sure we wait to trigger the listener\n // till _after_ the mutation that found this iframe has had time to process\n setTimeout(listener, 0);\n return;\n }\n // use default listener\n iframeEl.addEventListener('load', listener);\n}\n\nfunction serializeNode(\n n: Node,\n options: {\n doc: Document;\n blockClass: string | RegExp;\n blockSelector: string | null;\n unblockSelector: string | null;\n maskTextClass: string | RegExp;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n inlineStylesheet: boolean;\n maskInputOptions: MaskInputOptions;\n maskTextFn: MaskTextFn | undefined;\n maskInputFn: MaskInputFn | undefined;\n dataURLOptions?: DataURLOptions;\n inlineImages: boolean;\n recordCanvas: boolean;\n keepIframeSrcFn: KeepIframeSrcFn;\n },\n): serializedNode | false {\n const {\n doc,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions = {},\n maskTextFn,\n maskInputFn,\n dataURLOptions = {},\n inlineImages,\n recordCanvas,\n keepIframeSrcFn,\n } = options;\n // Only record root id when document object is not the base document\n let rootId: number | undefined;\n if (((doc as unknown) as INode).__sn) {\n const docId = ((doc as unknown) as INode).__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if ((n as HTMLDocument).compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: (n as HTMLDocument).compatMode, // probably \"BackCompat\"\n rootId,\n };\n } else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId,\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: (n as DocumentType).name,\n publicId: (n as DocumentType).publicId,\n systemId: (n as DocumentType).systemId,\n rootId,\n };\n case n.ELEMENT_NODE:\n const needBlock = _isBlockedElement(\n n as HTMLElement,\n blockClass,\n blockSelector,\n unblockSelector\n );\n const tagName = getValidTagName(n as HTMLElement);\n let attributes: attributes = {};\n for (const { name, value } of Array.from((n as HTMLElement).attributes)) {\n attributes[name] = transformAttribute(doc, tagName, name, value);\n }\n // remote css\n if (tagName === 'link' && inlineStylesheet) {\n const stylesheet = Array.from(doc.styleSheets).find((s) => {\n return s.href === (n as HTMLLinkElement).href;\n });\n let cssText: string | null = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet as CSSStyleSheet);\n }\n if (cssText) {\n delete attributes.rel;\n delete attributes.href;\n attributes._cssText = absoluteToStylesheet(\n cssText,\n stylesheet!.href!,\n );\n }\n }\n // dynamic stylesheet\n if (\n tagName === 'style' &&\n (n as HTMLStyleElement).sheet &&\n // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element\n !(\n (n as HTMLElement).innerText ||\n (n as HTMLElement).textContent ||\n ''\n ).trim().length\n ) {\n const cssText = getCssRulesString(\n (n as HTMLStyleElement).sheet as CSSStyleSheet,\n );\n if (cssText) {\n attributes._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n // form fields\n if (\n tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select'\n ) {\n const value = (n as HTMLInputElement | HTMLTextAreaElement).value;\n if (\n attributes.type !== 'radio' &&\n attributes.type !== 'checkbox' &&\n attributes.type !== 'submit' &&\n attributes.type !== 'button' &&\n value\n ) {\n attributes.value = maskInputValue({\n input: n as HTMLElement,\n type: attributes.type,\n tagName,\n value,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskInputFn,\n });\n } else if ((n as HTMLInputElement).checked) {\n attributes.checked = (n as HTMLInputElement).checked;\n }\n }\n if (tagName === 'option') {\n if ((n as HTMLOptionElement).selected && !maskInputOptions['select']) {\n attributes.selected = true;\n } else {\n // ignore the html attribute (which corresponds to DOM (n as HTMLOptionElement).defaultSelected)\n // if it's already been changed\n delete attributes.selected;\n }\n }\n // canvas image data\n if (tagName === 'canvas' && recordCanvas) {\n if ((n as ICanvas).__context === '2d') {\n // only record this on 2d canvas\n if (!is2DCanvasBlank(n as HTMLCanvasElement)) {\n attributes.rr_dataURL = (n as HTMLCanvasElement).toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n }\n } else if (!('__context' in n)) {\n // context is unknown, better not call getContext to trigger it\n const canvasDataURL = (n as HTMLCanvasElement).toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n\n // create blank canvas of same dimensions\n const blankCanvas = document.createElement('canvas');\n blankCanvas.width = (n as HTMLCanvasElement).width;\n blankCanvas.height = (n as HTMLCanvasElement).height;\n const blankCanvasDataURL = blankCanvas.toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n\n // no need to save dataURL if it's the same as blank canvas\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes.rr_dataURL = canvasDataURL;\n }\n }\n }\n // save image offline\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n const image = n as HTMLImageElement;\n const oldValue = image.crossOrigin;\n image.crossOrigin = 'anonymous';\n const recordInlineImage = () => {\n try {\n canvasService!.width = image.naturalWidth;\n canvasService!.height = image.naturalHeight;\n canvasCtx!.drawImage(image, 0, 0);\n attributes.rr_dataURL = canvasService!.toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n } catch (err) {\n console.warn(\n `Cannot inline img src=${image.currentSrc}! Error: ${err}`,\n );\n }\n oldValue\n ? (attributes.crossOrigin = oldValue)\n : delete attributes.crossOrigin;\n };\n // The image content may not have finished loading yet.\n if (image.complete && image.naturalWidth !== 0) recordInlineImage();\n else image.onload = recordInlineImage;\n }\n // media elements\n if (tagName === 'audio' || tagName === 'video') {\n attributes.rr_mediaState = (n as HTMLMediaElement).paused\n ? 'paused'\n : 'played';\n attributes.rr_mediaCurrentTime = (n as HTMLMediaElement).currentTime;\n }\n // scroll\n if ((n as HTMLElement).scrollLeft) {\n attributes.rr_scrollLeft = (n as HTMLElement).scrollLeft;\n }\n if ((n as HTMLElement).scrollTop) {\n attributes.rr_scrollTop = (n as HTMLElement).scrollTop;\n }\n // block element\n if (needBlock) {\n const { width, height } = (n as HTMLElement).getBoundingClientRect();\n attributes = {\n class: attributes.class,\n rr_width: `${width}px`,\n rr_height: `${height}px`,\n };\n }\n // iframe\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src as string)) {\n if (!(n as HTMLIFrameElement).contentDocument) {\n // we can't record it directly as we can't see into it\n // preserve the src attribute so a decision can be taken at replay time\n attributes.rr_src = attributes.src;\n }\n delete attributes.src; // prevent auto loading\n }\n return {\n type: NodeType.Element,\n tagName,\n attributes,\n childNodes: [],\n isSVG: isSVGElement(n as Element) || undefined,\n needBlock,\n rootId,\n };\n case n.TEXT_NODE:\n // The parent node may not be a html element which has a tagName attribute.\n // So just let it be undefined which is ok in this use case.\n const parentTagName =\n n.parentNode && (n.parentNode as HTMLElement).tagName;\n let textContent = (n as Text).textContent;\n const isStyle = parentTagName === 'STYLE' ? true : undefined;\n const isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n // try to read style sheet\n if (n.nextSibling || n.previousSibling) {\n // This is not the only child of the stylesheet.\n // We can't read all of the sheet's .cssRules and expect them\n // to _only_ include the current rule(s) added by the text node.\n // So we'll be conservative and keep textContent as-is.\n } else if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) {\n textContent = stringifyStyleSheet(\n (n.parentNode as HTMLStyleElement).sheet!,\n );\n }\n } catch (err) {\n console.warn(\n `Cannot get CSS styles from text's parentNode. Error: ${err}`,\n n,\n );\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (\n !isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent\n ) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle,\n rootId,\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId,\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: (n as Comment).textContent || '',\n rootId,\n };\n default:\n return false;\n }\n}\n\nfunction lowerIfExists(maybeAttr: string | number | boolean): string {\n if (maybeAttr === undefined) {\n return '';\n } else {\n return (maybeAttr as string).toLowerCase();\n }\n}\n\nfunction slimDOMExcluded(\n sn: serializedNode,\n slimDOMOptions: SlimDOMOptions,\n): boolean {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n // TODO: convert IE conditional comments to real nodes\n return true;\n } else if (sn.type === NodeType.Element) {\n if (\n slimDOMOptions.script &&\n // script tag\n (sn.tagName === 'script' ||\n // preload link\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n // prefetch link\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))\n ) {\n return true;\n } else if (\n slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(\n /^msapplication-tile(image|color)$/,\n ) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))\n ) {\n return true;\n } else if (sn.tagName === 'meta') {\n if (\n slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined\n ) {\n // e.g. X-UA-Compatible, Content-Type, Content-Language,\n // cache-control, X-Translated-By\n return true;\n } else if (\n slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')\n ) {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function serializeNodeWithId(\n n: Node | INode,\n options: {\n doc: Document;\n map: idNodeMap;\n blockClass: string | RegExp;\n blockSelector: string | null;\n unblockSelector: string | null;\n maskTextClass: string | RegExp;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n skipChild: boolean;\n inlineStylesheet: boolean;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions?: MaskInputOptions;\n maskTextFn: MaskTextFn | undefined;\n maskInputFn: MaskInputFn | undefined;\n slimDOMOptions: SlimDOMOptions;\n dataURLOptions?: DataURLOptions;\n keepIframeSrcFn?: KeepIframeSrcFn;\n inlineImages?: boolean;\n recordCanvas?: boolean;\n preserveWhiteSpace?: boolean;\n onSerialize?: (n: INode) => unknown;\n onIframeLoad?: (iframeINode: INode, node: serializedNodeWithId) => unknown;\n iframeLoadTimeout?: number;\n },\n): serializedNodeWithId | null {\n const {\n doc,\n map,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n skipChild = false,\n inlineStylesheet = true,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions = {},\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions = {},\n inlineImages = false,\n recordCanvas = false,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout = 5000,\n keepIframeSrcFn = () => false,\n } = options;\n let { preserveWhiteSpace = true } = options;\n const _serializedNode = serializeNode(n, {\n doc,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n keepIframeSrcFn,\n });\n if (!_serializedNode) {\n // TODO: dev only\n console.warn(n, 'not serialized');\n return null;\n }\n\n let id;\n // Try to reuse the previous id\n if ('__sn' in n) {\n id = n.__sn.id;\n } else if (\n slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)\n ) {\n id = IGNORED_NODE;\n } else {\n id = genId();\n }\n const serializedNode = Object.assign(_serializedNode, { id });\n (n as INode).__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null; // slimDOM\n }\n map[id] = n as INode;\n if (onSerialize) {\n onSerialize(n as INode);\n }\n let recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n // this property was not needed in replay side\n delete serializedNode.needBlock;\n if ((n as HTMLElement).shadowRoot) serializedNode.isShadowHost = true;\n }\n if (\n (serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild\n ) {\n if (\n slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head'\n // would impede performance: || getComputedStyle(n)['white-space'] === 'normal'\n ) {\n preserveWhiteSpace = false;\n }\n const bypassOptions = {\n doc,\n map,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n skipChild,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n };\n for (const childN of Array.from(n.childNodes)) {\n const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n\n if (isElement(n) && n.shadowRoot) {\n for (const childN of Array.from(n.shadowRoot.childNodes)) {\n const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n\n if (\n serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe'\n ) {\n onceIframeLoaded(\n n as HTMLIFrameElement,\n () => {\n const iframeDoc = (n as HTMLIFrameElement).contentDocument;\n if (iframeDoc && onIframeLoad) {\n const serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n skipChild: false,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n });\n\n if (serializedIframeNode) {\n onIframeLoad(n as INode, serializedIframeNode);\n }\n }\n },\n iframeLoadTimeout,\n );\n }\n\n return serializedNode;\n}\n\nfunction snapshot(\n n: Document,\n options?: {\n blockClass?: string | RegExp;\n blockSelector?: string | null;\n unblockSelector?: string | null;\n maskTextClass?: string | RegExp;\n maskTextSelector?: string | null;\n unmaskTextSelector?: string | null;\n maskInputSelector?: string | null;\n unmaskInputSelector?: string | null;\n inlineStylesheet?: boolean;\n maskAllInputs?: boolean | MaskInputOptions;\n maskTextFn?: MaskTextFn;\n maskInputFn?: MaskTextFn;\n slimDOM?: boolean | SlimDOMOptions;\n dataURLOptions?: DataURLOptions;\n inlineImages?: boolean;\n recordCanvas?: boolean;\n preserveWhiteSpace?: boolean;\n onSerialize?: (n: INode) => unknown;\n onIframeLoad?: (iframeINode: INode, node: serializedNodeWithId) => unknown;\n iframeLoadTimeout?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n },\n): [serializedNodeWithId | null, idNodeMap] {\n const {\n blockClass = 'rr-block',\n blockSelector = null,\n unblockSelector = null,\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n unmaskTextSelector = null,\n inlineStylesheet = true,\n inlineImages = false,\n recordCanvas = false,\n maskInputSelector = null,\n unmaskInputSelector = null,\n maskAllInputs = false,\n maskTextFn,\n maskInputFn,\n slimDOM = false,\n dataURLOptions,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn = () => false,\n } = options || {};\n const idNodeMap: idNodeMap = {};\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : maskAllInputs === false\n ? {\n password: true,\n }\n : maskAllInputs;\n const slimDOMOptions: SlimDOMOptions =\n slimDOM === true || slimDOM === 'all'\n ? // if true: set of sensible options that should not throw away any information\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all', // destructive\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true,\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n skipChild: false,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n }),\n idNodeMap,\n ];\n}\n\nexport function visitSnapshot(\n node: serializedNodeWithId,\n onVisit: (node: serializedNodeWithId) => unknown,\n) {\n function walk(current: serializedNodeWithId) {\n onVisit(current);\n if (\n current.type === NodeType.Document ||\n current.type === NodeType.Element\n ) {\n current.childNodes.forEach(walk);\n }\n }\n\n walk(node);\n}\n\nexport function cleanupSnapshot() {\n // allow a new recording to start numbering nodes from scratch\n _id = 1;\n}\n\nexport default snapshot;\n","/**\n * This file is a fork of https://github.com/reworkcss/css/blob/master/lib/parse/index.js\n * I fork it because:\n * 1. The css library was built for node.js which does not have tree-shaking supports.\n * 2. Rewrites into typescript give us a better type interface.\n */\n\n/* tslint:disable no-conditional-assignment interface-name no-shadowed-variable */\n\nexport interface ParserOptions {\n /** Silently fail on parse errors */\n silent?: boolean;\n /**\n * The path to the file containing css.\n * Makes errors and source maps more helpful, by letting them know where code comes from.\n */\n source?: string;\n}\n\n/**\n * Error thrown during parsing.\n */\nexport interface ParserError {\n /** The full error message with the source position. */\n message?: string;\n /** The error message without position. */\n reason?: string;\n /** The value of options.source if passed to css.parse. Otherwise undefined. */\n filename?: string;\n line?: number;\n column?: number;\n /** The portion of code that couldn't be parsed. */\n source?: string;\n}\n\nexport interface Loc {\n line?: number;\n column?: number;\n}\n\n/**\n * Base AST Tree Node.\n */\nexport interface Node {\n /** The possible values are the ones listed in the Types section on https://github.com/reworkcss/css page. */\n type?: string;\n /** A reference to the parent node, or null if the node has no parent. */\n parent?: Node;\n /** Information about the position in the source string that corresponds to the node. */\n position?: {\n start?: Loc;\n end?: Loc;\n /** The value of options.source if passed to css.parse. Otherwise undefined. */\n source?: string;\n /** The full source string passed to css.parse. */\n content?: string;\n };\n}\n\nexport interface Rule extends Node {\n /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n selectors?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\nexport interface Declaration extends Node {\n /** The property name, trimmed from whitespace and comments. May not be empty. */\n property?: string;\n /** The value of the property, trimmed from whitespace and comments. Empty values are allowed. */\n value?: string;\n}\n\n/**\n * A rule-level or declaration-level comment. Comments inside selectors, properties and values etc. are lost.\n */\nexport interface Comment extends Node {\n comment?: string;\n}\n\n/**\n * The @charset at-rule.\n */\nexport interface Charset extends Node {\n /** The part following @charset. */\n charset?: string;\n}\n\n/**\n * The @custom-media at-rule\n */\nexport interface CustomMedia extends Node {\n /** The ---prefixed name. */\n name?: string;\n /** The part following the name. */\n media?: string;\n}\n\n/**\n * The @document at-rule.\n */\nexport interface Document extends Node {\n /** The part following @document. */\n document?: string;\n /** The vendor prefix in @document, or undefined if there is none. */\n vendor?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @font-face at-rule.\n */\nexport interface FontFace extends Node {\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @host at-rule.\n */\nexport interface Host extends Node {\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @import at-rule.\n */\nexport interface Import extends Node {\n /** The part following @import. */\n import?: string;\n}\n\n/**\n * The @keyframes at-rule.\n */\nexport interface KeyFrames extends Node {\n /** The name of the keyframes rule. */\n name?: string;\n /** The vendor prefix in @keyframes, or undefined if there is none. */\n vendor?: string;\n /** Array of nodes with the types keyframe and comment. */\n keyframes?: Array;\n}\n\nexport interface KeyFrame extends Node {\n /** The list of \"selectors\" of the keyframe rule, split on commas. Each “selector” is trimmed from whitespace. */\n values?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @media at-rule.\n */\nexport interface Media extends Node {\n /** The part following @media. */\n media?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @namespace at-rule.\n */\nexport interface Namespace extends Node {\n /** The part following @namespace. */\n namespace?: string;\n}\n\n/**\n * The @page at-rule.\n */\nexport interface Page extends Node {\n /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n selectors?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @supports at-rule.\n */\nexport interface Supports extends Node {\n /** The part following @supports. */\n supports?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/** All at-rules. */\nexport type AtRule =\n | Charset\n | CustomMedia\n | Document\n | FontFace\n | Host\n | Import\n | KeyFrames\n | Media\n | Namespace\n | Page\n | Supports;\n\n/**\n * A collection of rules\n */\nexport interface StyleRules {\n source?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules: Array;\n /** Array of Errors. Errors collected during parsing when option silent is true. */\n parsingErrors?: ParserError[];\n}\n\n/**\n * The root node returned by css.parse.\n */\nexport interface Stylesheet extends Node {\n stylesheet?: StyleRules;\n}\n\n// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nconst commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nexport function parse(css: string, options: ParserOptions = {}) {\n /**\n * Positional.\n */\n\n let lineno = 1;\n let column = 1;\n\n /**\n * Update lineno and column based on `str`.\n */\n\n function updatePosition(str: string) {\n const lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n let i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n\n /**\n * Mark position and patch `node.position`.\n */\n\n function position() {\n const start = { line: lineno, column };\n return (\n node: Rule | Declaration | Comment | AtRule | Stylesheet | KeyFrame,\n ) => {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node\n */\n\n class Position {\n public content!: string;\n public start!: Loc;\n public end!: Loc;\n public source?: string;\n\n constructor(start: Loc) {\n this.start = start;\n this.end = { line: lineno, column };\n this.source = options.source;\n }\n }\n\n /**\n * Non-enumerable source string\n */\n\n Position.prototype.content = css;\n\n const errorsList: ParserError[] = [];\n\n function error(msg: string) {\n const err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg,\n ) as ParserError;\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Parse stylesheet.\n */\n\n function stylesheet(): Stylesheet {\n const rulesList = rules();\n\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList,\n },\n };\n }\n\n /**\n * Opening brace.\n */\n\n function open() {\n return match(/^{\\s*/);\n }\n\n /**\n * Closing brace.\n */\n\n function close() {\n return match(/^}/);\n }\n\n /**\n * Parse ruleset.\n */\n\n function rules() {\n let node: Rule | void;\n const rules: Rule[] = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n\n /**\n * Match `re` and return captures.\n */\n\n function match(re: RegExp) {\n const m = re.exec(css);\n if (!m) {\n return;\n }\n const str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n\n function whitespace() {\n match(/^\\s*/);\n }\n\n /**\n * Parse comments;\n */\n\n function comments(rules: Rule[] = []) {\n let c: Comment | void;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n\n /**\n * Parse comment.\n */\n\n function comment() {\n const pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n\n let i = 2;\n while (\n '' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n const str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n\n return pos({\n type: 'comment',\n comment: str,\n });\n }\n\n /**\n * Parse selector.\n */\n\n function selector() {\n const m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n /* @fix Remove all comments from selectors\n * http://ostermiller.org/findcomment.html */\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, (m) => {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map((s) => {\n return s.replace(/\\u200C/g, ',');\n });\n }\n\n /**\n * Parse declaration.\n */\n\n function declaration(): Declaration | void | never {\n const pos = position();\n\n // prop\n let propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n const prop = trim(propMatch[0]);\n\n // :\n if (!match(/^:\\s*/)) {\n return error(`property missing ':'`);\n }\n\n // val\n const val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n\n const ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : '',\n });\n\n // ;\n match(/^[;\\s]*/);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n */\n\n function declarations() {\n const decls: Array = [];\n\n if (!open()) {\n return error(`missing '{'`);\n }\n comments(decls);\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n if ((decl as unknown) !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n\n if (!close()) {\n return error(`missing '}'`);\n }\n return decls;\n }\n\n /**\n * Parse keyframe.\n */\n\n function keyframe() {\n let m;\n const vals = [];\n const pos = position();\n\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n\n if (!vals.length) {\n return;\n }\n\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations() as Declaration[],\n });\n }\n\n /**\n * Parse keyframes.\n */\n\n function atkeyframes() {\n const pos = position();\n let m = match(/^@([-\\w]+)?keyframes\\s*/);\n\n if (!m) {\n return;\n }\n const vendor = m[1];\n\n // identifier\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n const name = m[1];\n\n if (!open()) {\n return error(`@keyframes missing '{'`);\n }\n\n let frame;\n let frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n\n if (!close()) {\n return error(`@keyframes missing '}'`);\n }\n\n return pos({\n type: 'keyframes',\n name,\n vendor,\n keyframes: frames,\n });\n }\n\n /**\n * Parse supports.\n */\n\n function atsupports() {\n const pos = position();\n const m = match(/^@supports *([^{]+)/);\n\n if (!m) {\n return;\n }\n const supports = trim(m[1]);\n\n if (!open()) {\n return error(`@supports missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@supports missing '}'`);\n }\n\n return pos({\n type: 'supports',\n supports,\n rules: style,\n });\n }\n\n /**\n * Parse host.\n */\n\n function athost() {\n const pos = position();\n const m = match(/^@host\\s*/);\n\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(`@host missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@host missing '}'`);\n }\n\n return pos({\n type: 'host',\n rules: style,\n });\n }\n\n /**\n * Parse media.\n */\n\n function atmedia() {\n const pos = position();\n const m = match(/^@media *([^{]+)/);\n\n if (!m) {\n return;\n }\n const media = trim(m[1]);\n\n if (!open()) {\n return error(`@media missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@media missing '}'`);\n }\n\n return pos({\n type: 'media',\n media,\n rules: style,\n });\n }\n\n /**\n * Parse custom-media.\n */\n\n function atcustommedia() {\n const pos = position();\n const m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2]),\n });\n }\n\n /**\n * Parse paged media.\n */\n\n function atpage() {\n const pos = position();\n const m = match(/^@page */);\n if (!m) {\n return;\n }\n\n const sel = selector() || [];\n\n if (!open()) {\n return error(`@page missing '{'`);\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(`@page missing '}'`);\n }\n\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls,\n });\n }\n\n /**\n * Parse document.\n */\n\n function atdocument() {\n const pos = position();\n const m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n\n const vendor = trim(m[1]);\n const doc = trim(m[2]);\n\n if (!open()) {\n return error(`@document missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@document missing '}'`);\n }\n\n return pos({\n type: 'document',\n document: doc,\n vendor,\n rules: style,\n });\n }\n\n /**\n * Parse font-face.\n */\n\n function atfontface() {\n const pos = position();\n const m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(`@font-face missing '{'`);\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(`@font-face missing '}'`);\n }\n\n return pos({\n type: 'font-face',\n declarations: decls,\n });\n }\n\n /**\n * Parse import\n */\n\n const atimport = _compileAtrule('import');\n\n /**\n * Parse charset\n */\n\n const atcharset = _compileAtrule('charset');\n\n /**\n * Parse namespace\n */\n\n const atnamespace = _compileAtrule('namespace');\n\n /**\n * Parse non-block at-rules\n */\n\n function _compileAtrule(name: string) {\n const re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return () => {\n const pos = position();\n const m = match(re);\n if (!m) {\n return;\n }\n const ret: Record = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n\n /**\n * Parse at rule.\n */\n\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n\n return (\n atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface()\n );\n }\n\n /**\n * Parse rule.\n */\n\n function rule() {\n const pos = position();\n const sel = selector();\n\n if (!sel) {\n return error('selector missing');\n }\n comments();\n\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations() as Declaration[],\n });\n }\n\n return addParent(stylesheet());\n}\n\n/**\n * Trim `str`.\n */\n\nfunction trim(str: string) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\n\n/**\n * Adds non-enumerable parent node reference to each node.\n */\n\nfunction addParent(obj: Stylesheet, parent?: Stylesheet) {\n const isNode = obj && typeof obj.type === 'string';\n const childParent = isNode ? obj : parent;\n\n for (const k of Object.keys(obj)) {\n const value = obj[k as keyof Stylesheet];\n if (Array.isArray(value)) {\n value.forEach((v) => {\n addParent(v, childParent);\n });\n } else if (value && typeof value === 'object') {\n addParent((value as unknown) as Stylesheet, childParent);\n }\n }\n\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null,\n });\n }\n\n return obj;\n}\n","import { parse } from './css';\nimport {\n serializedNodeWithId,\n NodeType,\n tagMap,\n elementNode,\n idNodeMap,\n INode,\n BuildCache,\n} from './types';\nimport { isElement } from './utils';\n\nconst tagMap: tagMap = {\n script: 'noscript',\n // camel case svg element tag names\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient',\n};\nfunction getTagName(n: elementNode): string {\n let tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\n\n// based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nfunction escapeRegExp(str: string) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nconst HOVER_SELECTOR = /([^\\\\]):hover/;\nconst HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nexport function addHoverClass(cssText: string, cache: BuildCache): string {\n const cachedStyle = cache?.stylesWithHoverClass.get(cssText);\n if (cachedStyle) return cachedStyle;\n\n const ast = parse(cssText, {\n silent: true,\n });\n\n if (!ast.stylesheet) {\n return cssText;\n }\n\n const selectors: string[] = [];\n ast.stylesheet.rules.forEach((rule) => {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach((selector: string) => {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n\n if (selectors.length === 0) {\n return cssText;\n }\n\n const selectorMatcher = new RegExp(\n selectors\n .filter((selector, index) => selectors.indexOf(selector) === index)\n .sort((a, b) => b.length - a.length)\n .map((selector) => {\n return escapeRegExp(selector);\n })\n .join('|'),\n 'g',\n );\n\n const result = cssText.replace(selectorMatcher, (selector) => {\n const newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return `${selector}, ${newSelector}`;\n });\n cache?.stylesWithHoverClass.set(cssText, result);\n return result;\n}\n\nexport function createCache(): BuildCache {\n const stylesWithHoverClass: Map = new Map();\n return {\n stylesWithHoverClass,\n };\n}\n\nfunction buildNode(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n hackCss: boolean;\n cache: BuildCache;\n },\n): Node | null {\n const { doc, hackCss, cache } = options;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(\n n.name || 'html',\n n.publicId,\n n.systemId,\n );\n case NodeType.Element:\n const tagName = getTagName(n);\n let node: Element;\n if (n.isSVG) {\n node = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n } else {\n node = doc.createElement(tagName);\n }\n for (const name in n.attributes) {\n if (!n.attributes.hasOwnProperty(name)) {\n continue;\n }\n let value = n.attributes[name];\n if (tagName === 'option' && name === 'selected' && value === false) {\n // legacy fix (TODO: if `value === false` can be generated for other attrs, should we also omit those other attrs from build?)\n continue;\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n // attribute names start with rr_ are internal attributes added by rrweb\n if (!name.startsWith('rr_')) {\n const isTextarea = tagName === 'textarea' && name === 'value';\n const isRemoteOrDynamicCss =\n tagName === 'style' && name === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n const child = doc.createTextNode(value);\n // https://github.com/rrweb-io/rrweb/issues/112\n for (const c of Array.from(node.childNodes)) {\n if (c.nodeType === node.TEXT_NODE) {\n node.removeChild(c);\n }\n }\n node.appendChild(child);\n continue;\n }\n\n try {\n if (n.isSVG && name === 'xlink:href') {\n node.setAttributeNS('http://www.w3.org/1999/xlink', name, value);\n } else if (\n name === 'onload' ||\n name === 'onclick' ||\n name.substring(0, 7) === 'onmouse'\n ) {\n // Rename some of the more common atttributes from https://www.w3schools.com/tags/ref_eventattributes.asp\n // as setting them triggers a console.error (which shows up despite the try/catch)\n // Assumption: these attributes are not used to css\n node.setAttribute('_' + name, value);\n } else if (\n tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name === 'content'\n ) {\n // If CSP contains style-src and inline-style is disabled, there will be an error \"Refused to apply inline style because it violates the following Content Security Policy directive: style-src '*'\".\n // And the function insertStyleRules in rrweb replayer will throw an error \"Uncaught TypeError: Cannot read property 'insertRule' of null\".\n node.setAttribute('csp-content', value);\n continue;\n } else if (\n tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script'\n ) {\n // ignore\n } else if (\n tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')\n ) {\n // ignore\n } else if (\n tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL\n ) {\n // backup original img srcset\n node.setAttribute('rrweb-original-srcset', n.attributes.srcset as string);\n } else {\n node.setAttribute(name, value);\n }\n } catch (error) {\n // skip invalid attribute\n }\n } else {\n // handle internal attributes\n if (tagName === 'canvas' && name === 'rr_dataURL') {\n const image = document.createElement('img');\n image.src = value;\n image.onload = () => {\n const ctx = (node as HTMLCanvasElement).getContext('2d');\n if (ctx) {\n ctx.drawImage(image, 0, 0, image.width, image.height);\n }\n };\n } else if (tagName === 'img' && name === 'rr_dataURL') {\n const image = node as HTMLImageElement;\n if (!image.currentSrc.startsWith('data:')) {\n // Backup original img src. It may not have been set yet.\n image.setAttribute(\n 'rrweb-original-src',\n n.attributes.src as string,\n );\n image.src = value;\n }\n }\n\n if (name === 'rr_width') {\n (node as HTMLElement).style.width = value;\n } else if (name === 'rr_height') {\n (node as HTMLElement).style.height = value;\n } else if (name === 'rr_mediaCurrentTime') {\n (node as HTMLMediaElement).currentTime = n.attributes\n .rr_mediaCurrentTime as number;\n } else if (name === 'rr_mediaState') {\n switch (value) {\n case 'played':\n (node as HTMLMediaElement)\n .play()\n .catch((e) => console.warn('media playback error', e));\n break;\n case 'paused':\n (node as HTMLMediaElement).pause();\n break;\n default:\n }\n }\n }\n }\n\n if (n.isShadowHost) {\n /**\n * Since node is newly rebuilt, it should be a normal element\n * without shadowRoot.\n * But if there are some weird situations that has defined\n * custom element in the scope before we rebuild node, it may\n * register the shadowRoot earlier.\n * The logic in the 'else' block is just a try-my-best solution\n * for the corner case, please let we know if it is wrong and\n * we can remove it.\n */\n if (!node.shadowRoot) {\n node.attachShadow({ mode: 'open' });\n } else {\n while (node.shadowRoot.firstChild) {\n node.shadowRoot.removeChild(node.shadowRoot.firstChild);\n }\n }\n }\n return node;\n case NodeType.Text:\n return doc.createTextNode(\n n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent,\n );\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\n\nexport function buildNodeWithSN(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n map: idNodeMap;\n skipChild?: boolean;\n hackCss: boolean;\n afterAppend?: (n: INode) => unknown;\n cache: BuildCache;\n },\n): INode | null {\n const {\n doc,\n map,\n skipChild = false,\n hackCss = true,\n afterAppend,\n cache,\n } = options;\n let node = buildNode(n, { doc, hackCss, cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(\n ((map[n.rootId] as unknown) as Document) === doc,\n 'Target document should has the same root id.',\n );\n }\n // use target document as root document\n if (n.type === NodeType.Document) {\n // close before open to make sure document was closed\n doc.close();\n doc.open();\n if (\n n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType // there isn't one already defined\n ) {\n // Trigger compatMode in the iframe\n // this is needed as document.createElement('iframe') otherwise inherits a CSS1Compat mode from the parent replayer environment\n if (\n n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml'\n ) {\n // might as well use an xhtml doctype if we've got an xhtml namespace\n doc.write(\n '',\n );\n } else {\n doc.write(\n '',\n );\n }\n }\n node = doc;\n }\n\n (node as INode).__sn = n;\n map[n.id] = node as INode;\n\n if (\n (n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild\n ) {\n for (const childN of n.childNodes) {\n const childNode = buildNodeWithSN(childN, {\n doc,\n map,\n skipChild: false,\n hackCss,\n afterAppend,\n cache,\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n } else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n\n return node as INode;\n}\n\nfunction visit(idNodeMap: idNodeMap, onVisit: (node: INode) => void) {\n function walk(node: INode) {\n onVisit(node);\n }\n\n for (const key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\n\nfunction handleScroll(node: INode) {\n const n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n const el = (node as Node) as HTMLElement;\n for (const name in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name) && name.startsWith('rr_'))) {\n continue;\n }\n const value = n.attributes[name];\n if (name === 'rr_scrollLeft') {\n el.scrollLeft = value as number;\n }\n if (name === 'rr_scrollTop') {\n el.scrollTop = value as number;\n }\n }\n}\n\nfunction rebuild(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n onVisit?: (node: INode) => unknown;\n hackCss?: boolean;\n afterAppend?: (n: INode) => unknown;\n cache: BuildCache;\n },\n): [Node | null, idNodeMap] {\n const { doc, onVisit, hackCss = true, afterAppend, cache } = options;\n const idNodeMap: idNodeMap = {};\n const node = buildNodeWithSN(n, {\n doc,\n map: idNodeMap,\n skipChild: false,\n hackCss,\n afterAppend,\n cache,\n });\n visit(idNodeMap, (visitedNode) => {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport default rebuild;\n"],"names":["NodeType","isElement","n","nodeType","ELEMENT_NODE","isShadowRoot","host","Boolean","shadowRoot","maskInputValue","_a","input","maskInputSelector","unmaskInputSelector","maskInputOptions","tagName","type","value","maskInputFn","text","matches","toLowerCase","repeat","length","ORIGINAL_ATTRIBUTE_NAME","is2DCanvasBlank","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","call","Math","min","data","buffer","some","pixel","canvasService","canvasCtx","_id","tagNameRegex","RegExp","getCssRulesString","s","rules","cssRules","Array","from","map","getCssRuleString","join","error","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","slice","stack","parts","pop","parts_1","_i","part","push","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","unmaskTextSelector","closest","classList","contains","eIndex","className","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","unblockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","Object","assign","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","_m","_l","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","commentre","parse","css","lineno","column","updatePosition","str","lines","i","lastIndexOf","position","start","line","Position","whitespace","this","end","source","prototype","content","errorsList","msg","Error","reason","filename","silent","open","close","comments","atrule","re","m","selector","declaration","propMatch","prop","val","ret","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","vendor","frame","frames","concat","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","atdocument","sel","selectors","atpage","athost","atfontface","addParent","parsingErrors","obj","parent","isNode","childParent","keys","isArray","forEach","v","defineProperty","configurable","writable","enumerable","tagMap","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cache","cachedStyle","stylesWithHoverClass","get","ast","selectorMatcher","filter","index","sort","b","result","newSelector","set","buildNode","hackCss","implementation","createDocument","createDocumentType","node_1","getTagName","createElementNS","hasOwnProperty","startsWith","image","setAttribute","play","e","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","removeChild","appendChild","setAttributeNS","srcset","firstChild","attachShadow","mode","createCDATASection","createComment","buildNodeWithSN","afterAppend","assert","xmlns","write","childN","childNode","Map","onVisit","idNodeMap","key","visit","visitedNode","name_2","handleScroll","_o","maskAllInputs","_p","slimDOM","_q","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","walk","current"],"mappings":"2CAAA,IAAYA,WCEIC,EAAUC,GACxB,OAAOA,EAAEC,WAAaD,EAAEE,sBAGVC,EAAaH,SACrBI,YAAwBJ,wBAAkBI,KAChD,OAAOC,QAAQD,GAAQA,EAAKE,YAAcF,EAAKE,aAAeN,YAGhDO,EAAeC,OAC7BC,UACAC,sBACAC,wBACAC,qBACAC,YACAC,SACAC,UACAC,gBAWIC,EAAOF,GAAS,GAEpB,OAAIJ,GAAuBF,EAAMS,QAAQP,KAKvCC,EAAiBC,EAAQM,gBACzBP,EAAiBE,IAChBJ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AAAC,gBACA9T,mBACA+F,uBACAN,gBACAC,iBACAE,sBACAmO,oBAEIV,EAAuB,GA4C7B,MAAO,CACL/N,EAAoB9N,EAAG,CACrB0F,IAAK1F,EACLoD,IAAKyY,EACL5T,aACAC,gBACAC,kBACAjB,gBACAC,mBACAC,qBACA2G,WAAW,EACX3F,mBACA1H,oBACAC,sBACAC,kBAxDgB,IAAlBwb,EACI,CACEI,OAAO,EACPC,MAAM,EACN,kBAAkB,EAClBC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,OAAO,EACPC,QAAQ,EACRC,KAAK,EACL9b,MAAM,EACN+b,MAAM,EACNvY,KAAK,EACLwY,MAAM,EACNC,UAAU,EACVC,QAAQ,EACRC,UAAU,IAEM,IAAlBhB,EACA,CACEgB,UAAU,GAEZhB,EAkCF9T,aACAtH,cACAgN,gBAlCU,IAAZsO,GAAgC,QAAZA,EAEhB,CACE3N,QAAQ,EACRD,SAAS,EACTI,aAAa,EACbc,gBAAgB,EAChBb,qBAAkC,QAAZuN,EACtBtN,gBAAgB,EAChBE,gBAAgB,EAChBC,mBAAmB,EACnBC,oBAAoB,EACpBC,sBAAsB,IAEZ,IAAZiN,EACA,GACAA,EAmBF9T,iBACAC,eACAC,eACA6F,qBACAN,cACAC,eACAE,oBACAzF,2BAvEgB,WAAM,OAAA,OAyExBkT,oDAKF5U,EACA2U,IAEA,SAASyB,EAAKC,GACZ1B,EAAQ0B,GAENA,EAAQxc,OAAShB,WAASoJ,UAC1BoU,EAAQxc,OAAShB,WAASiN,SAE1BuQ,EAAQnU,WAAW0M,QAAQwH,GAI/BA,CAAKpW"} +\ No newline at end of file +diff --git a/node_modules/rrweb-snapshot/es/rrweb-snapshot.js b/node_modules/rrweb-snapshot/es/rrweb-snapshot.js +old mode 100644 +new mode 100755 +index f0c4ce2..831c6c8 +--- a/node_modules/rrweb-snapshot/es/rrweb-snapshot.js ++++ b/node_modules/rrweb-snapshot/es/rrweb-snapshot.js +@@ -17,10 +17,14 @@ function isShadowRoot(n) { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -247,7 +251,10 @@ function transformAttribute(doc, tagName, name, value) { + return value; + } + } +-function _isBlockedElement(element, blockClass, blockSelector) { ++function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -266,11 +273,16 @@ function _isBlockedElement(element, blockClass, blockSelector) { + } + return false; + } +-function needMaskingText(node, maskTextClass, maskTextSelector) { ++function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -289,12 +301,12 @@ function needMaskingText(node, maskTextClass, maskTextSelector) { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -334,7 +346,7 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -366,7 +378,7 @@ function serializeNode(n, options) { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -407,9 +419,12 @@ function serializeNode(n, options) { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -528,7 +543,7 @@ function serializeNode(n, options) { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -636,15 +651,19 @@ function slimDOMExcluded(sn, slimDOMOptions) { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -700,10 +719,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -748,10 +771,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -774,7 +801,7 @@ function serializeNodeWithId(n, options) { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -823,10 +850,14 @@ function snapshot(n, options) { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +diff --git a/node_modules/rrweb-snapshot/es/rrweb-snapshot.min.js b/node_modules/rrweb-snapshot/es/rrweb-snapshot.min.js +old mode 100644 +new mode 100755 +index 432f88d..90fdb88 +--- a/node_modules/rrweb-snapshot/es/rrweb-snapshot.min.js ++++ b/node_modules/rrweb-snapshot/es/rrweb-snapshot.min.js +@@ -1,2 +1,2 @@ +-var e;function t(e){return e.nodeType===e.ELEMENT_NODE}function r(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}function n(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,i=e.maskInputFn,o=a||"";return(t[r.toLowerCase()]||t[n])&&(o=i?i(o):"*".repeat(o.length)),o}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(e||(e={}));function a(e){var t=e.getContext("2d");if(!t)return!0;for(var r=0;r-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)+l+")";var u=t.split("/"),f=c.split("/");u.pop();for(var m=0,h=f;m=t.length);){var i=n(v);if(","===i.slice(-1))i=y(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=y(e,i);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((i+o).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((i+o).trim());break}"("===c&&(s=!0)}o+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?h(n,b()):"object"===t&&"data"===r&&n?y(e,n):n:y(e,n)}function C(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n'):a.write('')),m=a),m.__sn=r,i[r.id]=m,(r.type===e.Document||r.type===e.Element)&&!s)for(var d=0,p=r.childNodes;d-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)+l+")";var u=t.split("/"),f=c.split("/");u.pop();for(var m=0,h=f;m=t.length);){var i=n(v);if(","===i.slice(-1))i=y(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=y(e,i);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((i+o).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((i+o).trim());break}"("===c&&(s=!0)}o+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?h(n,k()):"object"===t&&"data"===r&&n?y(e,n):n:y(e,n)}function S(e,t,r,n){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if(n&&(e.matches(n)||e.closest(n)))return!1;if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var a=0;a'):a.write('')),m=a),m.__sn=r,i[r.id]=m,(r.type===e.Document||r.type===e.Element)&&!s)for(var p=0,d=r.childNodes;p;\n\nexport type SlimDOMOptions = Partial<{\n script: boolean;\n comment: boolean;\n headFavicon: boolean;\n headWhitespace: boolean;\n headMetaDescKeywords: boolean;\n headMetaSocial: boolean;\n headMetaRobots: boolean;\n headMetaHttpEquiv: boolean;\n headMetaAuthorship: boolean;\n headMetaVerification: boolean;\n}>;\n\nexport type DataURLOptions = Partial<{\n type: string;\n quality: number;\n}>;\n\nexport type MaskTextFn = (text: string) => string;\nexport type MaskInputFn = (text: string) => string;\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\nexport type BuildCache = {\n stylesWithHoverClass: Map;\n};\n","import { INode, MaskInputFn, MaskInputOptions } from './types';\n\nexport function isElement(n: Node | INode): n is Element {\n return n.nodeType === n.ELEMENT_NODE;\n}\n\nexport function isShadowRoot(n: Node): n is ShadowRoot {\n const host: Element | null = (n as ShadowRoot)?.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\n\nexport function maskInputValue({\n maskInputOptions,\n tagName,\n type,\n value,\n maskInputFn,\n}: {\n maskInputOptions: MaskInputOptions;\n tagName: string;\n type: string | number | boolean | null;\n value: string | null;\n maskInputFn?: MaskInputFn;\n}): string {\n let text = value || '';\n if (\n maskInputOptions[tagName.toLowerCase() as keyof MaskInputOptions] ||\n maskInputOptions[type as keyof MaskInputOptions]\n ) {\n if (maskInputFn) {\n text = maskInputFn(text);\n } else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedGetImageData = {\n [ORIGINAL_ATTRIBUTE_NAME]: CanvasImageData['getImageData'];\n} & CanvasImageData['getImageData'];\n\nexport function is2DCanvasBlank(canvas: HTMLCanvasElement): boolean {\n const ctx = canvas.getContext('2d');\n if (!ctx) return true;\n\n const chunkSize = 50;\n\n // get chunks of the canvas and check if it is blank\n for (let x = 0; x < canvas.width; x += chunkSize) {\n for (let y = 0; y < canvas.height; y += chunkSize) {\n const getImageData = ctx.getImageData as PatchedGetImageData;\n const originalGetImageData =\n ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n // by getting the canvas in chunks we avoid an expensive\n // `getImageData` call that retrieves everything\n // even if we can already tell from the first chunk(s) that\n // the canvas isn't blank\n const pixelBuffer = new Uint32Array(\n originalGetImageData.call(\n ctx,\n x,\n y,\n Math.min(chunkSize, canvas.width - x),\n Math.min(chunkSize, canvas.height - y),\n ).data.buffer,\n );\n if (pixelBuffer.some((pixel) => pixel !== 0)) return false;\n }\n }\n return true;\n}\n","import {\n serializedNode,\n serializedNodeWithId,\n NodeType,\n attributes,\n INode,\n idNodeMap,\n MaskInputOptions,\n SlimDOMOptions,\n DataURLOptions,\n MaskTextFn,\n MaskInputFn,\n KeepIframeSrcFn,\n ICanvas,\n} from './types';\nimport {\n is2DCanvasBlank,\n isElement,\n isShadowRoot,\n maskInputValue,\n} from './utils';\n\nlet _id = 1;\nconst tagNameRegex = new RegExp('[^a-z0-9-_:]');\n\nexport const IGNORED_NODE = -2;\n\nfunction genId(): number {\n return _id++;\n}\n\nfunction getValidTagName(element: HTMLElement): string {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n\n const processedTagName = element.tagName.toLowerCase().trim();\n\n if (tagNameRegex.test(processedTagName)) {\n // if the tag name is odd and we cannot extract\n // anything from the string, then we return a\n // generic div\n return 'div';\n }\n\n return processedTagName;\n}\n\nfunction getCssRulesString(s: CSSStyleSheet): string | null {\n try {\n const rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n } catch (error) {\n return null;\n }\n}\n\nfunction getCssRuleString(rule: CSSRule): string {\n let cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n } catch {\n // ignore\n }\n }\n return cssStringified;\n}\n\nfunction isCSSImportRule(rule: CSSRule): rule is CSSImportRule {\n return 'styleSheet' in rule;\n}\n\nfunction stringifyStyleSheet(sheet: CSSStyleSheet): string {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map((rule) => rule.cssText || '')\n .join('')\n : '';\n}\n\nfunction extractOrigin(url: string): string {\n let origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n } else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\n\nlet canvasService: HTMLCanvasElement | null;\nlet canvasCtx: CanvasRenderingContext2D | null;\n\nconst URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nconst RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nconst DATA_URI = /^(data:)([^,]*),(.*)/i;\nexport function absoluteToStylesheet(\n cssText: string | null,\n href: string,\n): string {\n return (cssText || '').replace(\n URL_IN_CSS_REF,\n (origin, quote1, path1, quote2, path2, path3) => {\n const filePath = path1 || path2 || path3;\n const maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return `url(${maybeQuote}${filePath}${maybeQuote})`;\n }\n if (DATA_URI.test(filePath)) {\n return `url(${maybeQuote}${filePath}${maybeQuote})`;\n }\n if (filePath[0] === '/') {\n return `url(${maybeQuote}${\n extractOrigin(href) + filePath\n }${maybeQuote})`;\n }\n const stack = href.split('/');\n const parts = filePath.split('/');\n stack.pop();\n for (const part of parts) {\n if (part === '.') {\n continue;\n } else if (part === '..') {\n stack.pop();\n } else {\n stack.push(part);\n }\n }\n return `url(${maybeQuote}${stack.join('/')}${maybeQuote})`;\n },\n );\n}\n\nconst SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/; // Don't use \\s, to avoid matching non-breaking space\nconst SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc: Document, attributeValue: string) {\n /*\n run absoluteToDoc over every url in the srcset\n\n this is adapted from https://github.com/albell/parse-srcset/\n without the parsing of the descriptors (we return these as-is)\n parce-srcset is in turn based on\n https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute\n */\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n\n let pos = 0;\n\n function collectCharacters(regEx: RegExp) {\n let chars: string;\n let match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n\n let output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n // don't split on commas within urls\n let url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n // aside: according to spec more than one comma at the end is a parse error, but we ignore that\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n // the trailing comma splits the srcset, so the interpretion is that\n // another url will follow, and the descriptor is empty\n output.push(url);\n } else {\n let descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n let inParens = false;\n while (true) {\n let c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n } else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break; // parse the next url\n } else if (c === '(') {\n inParens = true;\n }\n } else {\n // in parenthesis; ignore commas\n // (parenthesis may be supported by future additions to spec)\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\n\nexport function absoluteToDoc(doc: Document, attributeValue: string): string {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n const a: HTMLAnchorElement = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\n\nfunction isSVGElement(el: Element): boolean {\n return Boolean(el.tagName === 'svg' || (el as SVGElement).ownerSVGElement);\n}\n\nfunction getHref() {\n // return a href without hash\n const a = document.createElement('a');\n a.href = '';\n return a.href;\n}\n\nexport function transformAttribute(\n doc: Document,\n tagName: string,\n name: string,\n value: string,\n): string {\n // relative path in attribute\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n } else if (name === 'xlink:href' && value && value[0] !== '#') {\n // xlink:href starts with # is an id pointer\n return absoluteToDoc(doc, value);\n } else if (\n name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')\n ) {\n return absoluteToDoc(doc, value);\n } else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n } else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n } else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n } else {\n return value;\n }\n}\n\nexport function _isBlockedElement(\n element: HTMLElement,\n blockClass: string | RegExp,\n blockSelector: string | null,\n): boolean {\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n } else {\n // tslint:disable-next-line: prefer-for-of\n for (let eIndex = 0; eIndex < element.classList.length; eIndex++) {\n const className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n\n return false;\n}\n\nexport function needMaskingText(\n node: Node | null,\n maskTextClass: string | RegExp,\n maskTextSelector: string | null,\n): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (typeof maskTextClass === 'string') {\n if ((node as HTMLElement).classList.contains(maskTextClass)) {\n return true;\n }\n } else {\n // tslint:disable-next-line: prefer-for-of\n for (\n let eIndex = 0;\n eIndex < (node as HTMLElement).classList.length;\n eIndex++\n ) {\n const className = (node as HTMLElement).classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if ((node as HTMLElement).matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);\n}\n\n// https://stackoverflow.com/a/36155560\nfunction onceIframeLoaded(\n iframeEl: HTMLIFrameElement,\n listener: () => unknown,\n iframeLoadTimeout: number,\n) {\n const win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n // document is loading\n let fired = false;\n\n let readyState: DocumentReadyState;\n try {\n readyState = win.document.readyState;\n } catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n const timer = setTimeout(() => {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', () => {\n clearTimeout(timer);\n fired = true;\n listener();\n });\n return;\n }\n // check blank frame for Chrome\n const blankUrl = 'about:blank';\n if (\n win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === ''\n ) {\n // iframe was already loaded, make sure we wait to trigger the listener\n // till _after_ the mutation that found this iframe has had time to process\n setTimeout(listener, 0);\n return;\n }\n // use default listener\n iframeEl.addEventListener('load', listener);\n}\n\nfunction serializeNode(\n n: Node,\n options: {\n doc: Document;\n blockClass: string | RegExp;\n blockSelector: string | null;\n maskTextClass: string | RegExp;\n maskTextSelector: string | null;\n inlineStylesheet: boolean;\n maskInputOptions: MaskInputOptions;\n maskTextFn: MaskTextFn | undefined;\n maskInputFn: MaskInputFn | undefined;\n dataURLOptions?: DataURLOptions;\n inlineImages: boolean;\n recordCanvas: boolean;\n keepIframeSrcFn: KeepIframeSrcFn;\n },\n): serializedNode | false {\n const {\n doc,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskInputOptions = {},\n maskTextFn,\n maskInputFn,\n dataURLOptions = {},\n inlineImages,\n recordCanvas,\n keepIframeSrcFn,\n } = options;\n // Only record root id when document object is not the base document\n let rootId: number | undefined;\n if (((doc as unknown) as INode).__sn) {\n const docId = ((doc as unknown) as INode).__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if ((n as HTMLDocument).compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: (n as HTMLDocument).compatMode, // probably \"BackCompat\"\n rootId,\n };\n } else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId,\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: (n as DocumentType).name,\n publicId: (n as DocumentType).publicId,\n systemId: (n as DocumentType).systemId,\n rootId,\n };\n case n.ELEMENT_NODE:\n const needBlock = _isBlockedElement(\n n as HTMLElement,\n blockClass,\n blockSelector,\n );\n const tagName = getValidTagName(n as HTMLElement);\n let attributes: attributes = {};\n for (const { name, value } of Array.from((n as HTMLElement).attributes)) {\n attributes[name] = transformAttribute(doc, tagName, name, value);\n }\n // remote css\n if (tagName === 'link' && inlineStylesheet) {\n const stylesheet = Array.from(doc.styleSheets).find((s) => {\n return s.href === (n as HTMLLinkElement).href;\n });\n let cssText: string | null = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet as CSSStyleSheet);\n }\n if (cssText) {\n delete attributes.rel;\n delete attributes.href;\n attributes._cssText = absoluteToStylesheet(\n cssText,\n stylesheet!.href!,\n );\n }\n }\n // dynamic stylesheet\n if (\n tagName === 'style' &&\n (n as HTMLStyleElement).sheet &&\n // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element\n !(\n (n as HTMLElement).innerText ||\n (n as HTMLElement).textContent ||\n ''\n ).trim().length\n ) {\n const cssText = getCssRulesString(\n (n as HTMLStyleElement).sheet as CSSStyleSheet,\n );\n if (cssText) {\n attributes._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n // form fields\n if (\n tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select'\n ) {\n const value = (n as HTMLInputElement | HTMLTextAreaElement).value;\n if (\n attributes.type !== 'radio' &&\n attributes.type !== 'checkbox' &&\n attributes.type !== 'submit' &&\n attributes.type !== 'button' &&\n value\n ) {\n attributes.value = maskInputValue({\n type: attributes.type,\n tagName,\n value,\n maskInputOptions,\n maskInputFn,\n });\n } else if ((n as HTMLInputElement).checked) {\n attributes.checked = (n as HTMLInputElement).checked;\n }\n }\n if (tagName === 'option') {\n if ((n as HTMLOptionElement).selected && !maskInputOptions['select']) {\n attributes.selected = true;\n } else {\n // ignore the html attribute (which corresponds to DOM (n as HTMLOptionElement).defaultSelected)\n // if it's already been changed\n delete attributes.selected;\n }\n }\n // canvas image data\n if (tagName === 'canvas' && recordCanvas) {\n if ((n as ICanvas).__context === '2d') {\n // only record this on 2d canvas\n if (!is2DCanvasBlank(n as HTMLCanvasElement)) {\n attributes.rr_dataURL = (n as HTMLCanvasElement).toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n }\n } else if (!('__context' in n)) {\n // context is unknown, better not call getContext to trigger it\n const canvasDataURL = (n as HTMLCanvasElement).toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n\n // create blank canvas of same dimensions\n const blankCanvas = document.createElement('canvas');\n blankCanvas.width = (n as HTMLCanvasElement).width;\n blankCanvas.height = (n as HTMLCanvasElement).height;\n const blankCanvasDataURL = blankCanvas.toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n\n // no need to save dataURL if it's the same as blank canvas\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes.rr_dataURL = canvasDataURL;\n }\n }\n }\n // save image offline\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n const image = n as HTMLImageElement;\n const oldValue = image.crossOrigin;\n image.crossOrigin = 'anonymous';\n const recordInlineImage = () => {\n try {\n canvasService!.width = image.naturalWidth;\n canvasService!.height = image.naturalHeight;\n canvasCtx!.drawImage(image, 0, 0);\n attributes.rr_dataURL = canvasService!.toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n } catch (err) {\n console.warn(\n `Cannot inline img src=${image.currentSrc}! Error: ${err}`,\n );\n }\n oldValue\n ? (attributes.crossOrigin = oldValue)\n : delete attributes.crossOrigin;\n };\n // The image content may not have finished loading yet.\n if (image.complete && image.naturalWidth !== 0) recordInlineImage();\n else image.onload = recordInlineImage;\n }\n // media elements\n if (tagName === 'audio' || tagName === 'video') {\n attributes.rr_mediaState = (n as HTMLMediaElement).paused\n ? 'paused'\n : 'played';\n attributes.rr_mediaCurrentTime = (n as HTMLMediaElement).currentTime;\n }\n // scroll\n if ((n as HTMLElement).scrollLeft) {\n attributes.rr_scrollLeft = (n as HTMLElement).scrollLeft;\n }\n if ((n as HTMLElement).scrollTop) {\n attributes.rr_scrollTop = (n as HTMLElement).scrollTop;\n }\n // block element\n if (needBlock) {\n const { width, height } = (n as HTMLElement).getBoundingClientRect();\n attributes = {\n class: attributes.class,\n rr_width: `${width}px`,\n rr_height: `${height}px`,\n };\n }\n // iframe\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src as string)) {\n if (!(n as HTMLIFrameElement).contentDocument) {\n // we can't record it directly as we can't see into it\n // preserve the src attribute so a decision can be taken at replay time\n attributes.rr_src = attributes.src;\n }\n delete attributes.src; // prevent auto loading\n }\n return {\n type: NodeType.Element,\n tagName,\n attributes,\n childNodes: [],\n isSVG: isSVGElement(n as Element) || undefined,\n needBlock,\n rootId,\n };\n case n.TEXT_NODE:\n // The parent node may not be a html element which has a tagName attribute.\n // So just let it be undefined which is ok in this use case.\n const parentTagName =\n n.parentNode && (n.parentNode as HTMLElement).tagName;\n let textContent = (n as Text).textContent;\n const isStyle = parentTagName === 'STYLE' ? true : undefined;\n const isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n // try to read style sheet\n if (n.nextSibling || n.previousSibling) {\n // This is not the only child of the stylesheet.\n // We can't read all of the sheet's .cssRules and expect them\n // to _only_ include the current rule(s) added by the text node.\n // So we'll be conservative and keep textContent as-is.\n } else if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) {\n textContent = stringifyStyleSheet(\n (n.parentNode as HTMLStyleElement).sheet!,\n );\n }\n } catch (err) {\n console.warn(\n `Cannot get CSS styles from text's parentNode. Error: ${err}`,\n n,\n );\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (\n !isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector) &&\n textContent\n ) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle,\n rootId,\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId,\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: (n as Comment).textContent || '',\n rootId,\n };\n default:\n return false;\n }\n}\n\nfunction lowerIfExists(maybeAttr: string | number | boolean): string {\n if (maybeAttr === undefined) {\n return '';\n } else {\n return (maybeAttr as string).toLowerCase();\n }\n}\n\nfunction slimDOMExcluded(\n sn: serializedNode,\n slimDOMOptions: SlimDOMOptions,\n): boolean {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n // TODO: convert IE conditional comments to real nodes\n return true;\n } else if (sn.type === NodeType.Element) {\n if (\n slimDOMOptions.script &&\n // script tag\n (sn.tagName === 'script' ||\n // preload link\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n // prefetch link\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))\n ) {\n return true;\n } else if (\n slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(\n /^msapplication-tile(image|color)$/,\n ) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))\n ) {\n return true;\n } else if (sn.tagName === 'meta') {\n if (\n slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined\n ) {\n // e.g. X-UA-Compatible, Content-Type, Content-Language,\n // cache-control, X-Translated-By\n return true;\n } else if (\n slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')\n ) {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function serializeNodeWithId(\n n: Node | INode,\n options: {\n doc: Document;\n map: idNodeMap;\n blockClass: string | RegExp;\n blockSelector: string | null;\n maskTextClass: string | RegExp;\n maskTextSelector: string | null;\n skipChild: boolean;\n inlineStylesheet: boolean;\n maskInputOptions?: MaskInputOptions;\n maskTextFn: MaskTextFn | undefined;\n maskInputFn: MaskInputFn | undefined;\n slimDOMOptions: SlimDOMOptions;\n dataURLOptions?: DataURLOptions;\n keepIframeSrcFn?: KeepIframeSrcFn;\n inlineImages?: boolean;\n recordCanvas?: boolean;\n preserveWhiteSpace?: boolean;\n onSerialize?: (n: INode) => unknown;\n onIframeLoad?: (iframeINode: INode, node: serializedNodeWithId) => unknown;\n iframeLoadTimeout?: number;\n },\n): serializedNodeWithId | null {\n const {\n doc,\n map,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n skipChild = false,\n inlineStylesheet = true,\n maskInputOptions = {},\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions = {},\n inlineImages = false,\n recordCanvas = false,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout = 5000,\n keepIframeSrcFn = () => false,\n } = options;\n let { preserveWhiteSpace = true } = options;\n const _serializedNode = serializeNode(n, {\n doc,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n keepIframeSrcFn,\n });\n if (!_serializedNode) {\n // TODO: dev only\n console.warn(n, 'not serialized');\n return null;\n }\n\n let id;\n // Try to reuse the previous id\n if ('__sn' in n) {\n id = n.__sn.id;\n } else if (\n slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)\n ) {\n id = IGNORED_NODE;\n } else {\n id = genId();\n }\n const serializedNode = Object.assign(_serializedNode, { id });\n (n as INode).__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null; // slimDOM\n }\n map[id] = n as INode;\n if (onSerialize) {\n onSerialize(n as INode);\n }\n let recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n // this property was not needed in replay side\n delete serializedNode.needBlock;\n if ((n as HTMLElement).shadowRoot) serializedNode.isShadowHost = true;\n }\n if (\n (serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild\n ) {\n if (\n slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head'\n // would impede performance: || getComputedStyle(n)['white-space'] === 'normal'\n ) {\n preserveWhiteSpace = false;\n }\n const bypassOptions = {\n doc,\n map,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n skipChild,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n };\n for (const childN of Array.from(n.childNodes)) {\n const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n\n if (isElement(n) && n.shadowRoot) {\n for (const childN of Array.from(n.shadowRoot.childNodes)) {\n const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n\n if (\n serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe'\n ) {\n onceIframeLoaded(\n n as HTMLIFrameElement,\n () => {\n const iframeDoc = (n as HTMLIFrameElement).contentDocument;\n if (iframeDoc && onIframeLoad) {\n const serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n skipChild: false,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n });\n\n if (serializedIframeNode) {\n onIframeLoad(n as INode, serializedIframeNode);\n }\n }\n },\n iframeLoadTimeout,\n );\n }\n\n return serializedNode;\n}\n\nfunction snapshot(\n n: Document,\n options?: {\n blockClass?: string | RegExp;\n blockSelector?: string | null;\n maskTextClass?: string | RegExp;\n maskTextSelector?: string | null;\n inlineStylesheet?: boolean;\n maskAllInputs?: boolean | MaskInputOptions;\n maskTextFn?: MaskTextFn;\n maskInputFn?: MaskTextFn;\n slimDOM?: boolean | SlimDOMOptions;\n dataURLOptions?: DataURLOptions;\n inlineImages?: boolean;\n recordCanvas?: boolean;\n preserveWhiteSpace?: boolean;\n onSerialize?: (n: INode) => unknown;\n onIframeLoad?: (iframeINode: INode, node: serializedNodeWithId) => unknown;\n iframeLoadTimeout?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n },\n): [serializedNodeWithId | null, idNodeMap] {\n const {\n blockClass = 'rr-block',\n blockSelector = null,\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n inlineStylesheet = true,\n inlineImages = false,\n recordCanvas = false,\n maskAllInputs = false,\n maskTextFn,\n maskInputFn,\n slimDOM = false,\n dataURLOptions,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn = () => false,\n } = options || {};\n const idNodeMap: idNodeMap = {};\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : maskAllInputs === false\n ? {\n password: true,\n }\n : maskAllInputs;\n const slimDOMOptions: SlimDOMOptions =\n slimDOM === true || slimDOM === 'all'\n ? // if true: set of sensible options that should not throw away any information\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all', // destructive\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true,\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass,\n blockSelector,\n maskTextClass,\n maskTextSelector,\n skipChild: false,\n inlineStylesheet,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n }),\n idNodeMap,\n ];\n}\n\nexport function visitSnapshot(\n node: serializedNodeWithId,\n onVisit: (node: serializedNodeWithId) => unknown,\n) {\n function walk(current: serializedNodeWithId) {\n onVisit(current);\n if (\n current.type === NodeType.Document ||\n current.type === NodeType.Element\n ) {\n current.childNodes.forEach(walk);\n }\n }\n\n walk(node);\n}\n\nexport function cleanupSnapshot() {\n // allow a new recording to start numbering nodes from scratch\n _id = 1;\n}\n\nexport default snapshot;\n","/**\n * This file is a fork of https://github.com/reworkcss/css/blob/master/lib/parse/index.js\n * I fork it because:\n * 1. The css library was built for node.js which does not have tree-shaking supports.\n * 2. Rewrites into typescript give us a better type interface.\n */\n\n/* tslint:disable no-conditional-assignment interface-name no-shadowed-variable */\n\nexport interface ParserOptions {\n /** Silently fail on parse errors */\n silent?: boolean;\n /**\n * The path to the file containing css.\n * Makes errors and source maps more helpful, by letting them know where code comes from.\n */\n source?: string;\n}\n\n/**\n * Error thrown during parsing.\n */\nexport interface ParserError {\n /** The full error message with the source position. */\n message?: string;\n /** The error message without position. */\n reason?: string;\n /** The value of options.source if passed to css.parse. Otherwise undefined. */\n filename?: string;\n line?: number;\n column?: number;\n /** The portion of code that couldn't be parsed. */\n source?: string;\n}\n\nexport interface Loc {\n line?: number;\n column?: number;\n}\n\n/**\n * Base AST Tree Node.\n */\nexport interface Node {\n /** The possible values are the ones listed in the Types section on https://github.com/reworkcss/css page. */\n type?: string;\n /** A reference to the parent node, or null if the node has no parent. */\n parent?: Node;\n /** Information about the position in the source string that corresponds to the node. */\n position?: {\n start?: Loc;\n end?: Loc;\n /** The value of options.source if passed to css.parse. Otherwise undefined. */\n source?: string;\n /** The full source string passed to css.parse. */\n content?: string;\n };\n}\n\nexport interface Rule extends Node {\n /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n selectors?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\nexport interface Declaration extends Node {\n /** The property name, trimmed from whitespace and comments. May not be empty. */\n property?: string;\n /** The value of the property, trimmed from whitespace and comments. Empty values are allowed. */\n value?: string;\n}\n\n/**\n * A rule-level or declaration-level comment. Comments inside selectors, properties and values etc. are lost.\n */\nexport interface Comment extends Node {\n comment?: string;\n}\n\n/**\n * The @charset at-rule.\n */\nexport interface Charset extends Node {\n /** The part following @charset. */\n charset?: string;\n}\n\n/**\n * The @custom-media at-rule\n */\nexport interface CustomMedia extends Node {\n /** The ---prefixed name. */\n name?: string;\n /** The part following the name. */\n media?: string;\n}\n\n/**\n * The @document at-rule.\n */\nexport interface Document extends Node {\n /** The part following @document. */\n document?: string;\n /** The vendor prefix in @document, or undefined if there is none. */\n vendor?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @font-face at-rule.\n */\nexport interface FontFace extends Node {\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @host at-rule.\n */\nexport interface Host extends Node {\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @import at-rule.\n */\nexport interface Import extends Node {\n /** The part following @import. */\n import?: string;\n}\n\n/**\n * The @keyframes at-rule.\n */\nexport interface KeyFrames extends Node {\n /** The name of the keyframes rule. */\n name?: string;\n /** The vendor prefix in @keyframes, or undefined if there is none. */\n vendor?: string;\n /** Array of nodes with the types keyframe and comment. */\n keyframes?: Array;\n}\n\nexport interface KeyFrame extends Node {\n /** The list of \"selectors\" of the keyframe rule, split on commas. Each “selector” is trimmed from whitespace. */\n values?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @media at-rule.\n */\nexport interface Media extends Node {\n /** The part following @media. */\n media?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @namespace at-rule.\n */\nexport interface Namespace extends Node {\n /** The part following @namespace. */\n namespace?: string;\n}\n\n/**\n * The @page at-rule.\n */\nexport interface Page extends Node {\n /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n selectors?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @supports at-rule.\n */\nexport interface Supports extends Node {\n /** The part following @supports. */\n supports?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/** All at-rules. */\nexport type AtRule =\n | Charset\n | CustomMedia\n | Document\n | FontFace\n | Host\n | Import\n | KeyFrames\n | Media\n | Namespace\n | Page\n | Supports;\n\n/**\n * A collection of rules\n */\nexport interface StyleRules {\n source?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules: Array;\n /** Array of Errors. Errors collected during parsing when option silent is true. */\n parsingErrors?: ParserError[];\n}\n\n/**\n * The root node returned by css.parse.\n */\nexport interface Stylesheet extends Node {\n stylesheet?: StyleRules;\n}\n\n// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nconst commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nexport function parse(css: string, options: ParserOptions = {}) {\n /**\n * Positional.\n */\n\n let lineno = 1;\n let column = 1;\n\n /**\n * Update lineno and column based on `str`.\n */\n\n function updatePosition(str: string) {\n const lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n let i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n\n /**\n * Mark position and patch `node.position`.\n */\n\n function position() {\n const start = { line: lineno, column };\n return (\n node: Rule | Declaration | Comment | AtRule | Stylesheet | KeyFrame,\n ) => {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node\n */\n\n class Position {\n public content!: string;\n public start!: Loc;\n public end!: Loc;\n public source?: string;\n\n constructor(start: Loc) {\n this.start = start;\n this.end = { line: lineno, column };\n this.source = options.source;\n }\n }\n\n /**\n * Non-enumerable source string\n */\n\n Position.prototype.content = css;\n\n const errorsList: ParserError[] = [];\n\n function error(msg: string) {\n const err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg,\n ) as ParserError;\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Parse stylesheet.\n */\n\n function stylesheet(): Stylesheet {\n const rulesList = rules();\n\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList,\n },\n };\n }\n\n /**\n * Opening brace.\n */\n\n function open() {\n return match(/^{\\s*/);\n }\n\n /**\n * Closing brace.\n */\n\n function close() {\n return match(/^}/);\n }\n\n /**\n * Parse ruleset.\n */\n\n function rules() {\n let node: Rule | void;\n const rules: Rule[] = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n\n /**\n * Match `re` and return captures.\n */\n\n function match(re: RegExp) {\n const m = re.exec(css);\n if (!m) {\n return;\n }\n const str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n\n function whitespace() {\n match(/^\\s*/);\n }\n\n /**\n * Parse comments;\n */\n\n function comments(rules: Rule[] = []) {\n let c: Comment | void;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n\n /**\n * Parse comment.\n */\n\n function comment() {\n const pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n\n let i = 2;\n while (\n '' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n const str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n\n return pos({\n type: 'comment',\n comment: str,\n });\n }\n\n /**\n * Parse selector.\n */\n\n function selector() {\n const m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n /* @fix Remove all comments from selectors\n * http://ostermiller.org/findcomment.html */\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, (m) => {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map((s) => {\n return s.replace(/\\u200C/g, ',');\n });\n }\n\n /**\n * Parse declaration.\n */\n\n function declaration(): Declaration | void | never {\n const pos = position();\n\n // prop\n let propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n const prop = trim(propMatch[0]);\n\n // :\n if (!match(/^:\\s*/)) {\n return error(`property missing ':'`);\n }\n\n // val\n const val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n\n const ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : '',\n });\n\n // ;\n match(/^[;\\s]*/);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n */\n\n function declarations() {\n const decls: Array = [];\n\n if (!open()) {\n return error(`missing '{'`);\n }\n comments(decls);\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n if ((decl as unknown) !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n\n if (!close()) {\n return error(`missing '}'`);\n }\n return decls;\n }\n\n /**\n * Parse keyframe.\n */\n\n function keyframe() {\n let m;\n const vals = [];\n const pos = position();\n\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n\n if (!vals.length) {\n return;\n }\n\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations() as Declaration[],\n });\n }\n\n /**\n * Parse keyframes.\n */\n\n function atkeyframes() {\n const pos = position();\n let m = match(/^@([-\\w]+)?keyframes\\s*/);\n\n if (!m) {\n return;\n }\n const vendor = m[1];\n\n // identifier\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n const name = m[1];\n\n if (!open()) {\n return error(`@keyframes missing '{'`);\n }\n\n let frame;\n let frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n\n if (!close()) {\n return error(`@keyframes missing '}'`);\n }\n\n return pos({\n type: 'keyframes',\n name,\n vendor,\n keyframes: frames,\n });\n }\n\n /**\n * Parse supports.\n */\n\n function atsupports() {\n const pos = position();\n const m = match(/^@supports *([^{]+)/);\n\n if (!m) {\n return;\n }\n const supports = trim(m[1]);\n\n if (!open()) {\n return error(`@supports missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@supports missing '}'`);\n }\n\n return pos({\n type: 'supports',\n supports,\n rules: style,\n });\n }\n\n /**\n * Parse host.\n */\n\n function athost() {\n const pos = position();\n const m = match(/^@host\\s*/);\n\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(`@host missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@host missing '}'`);\n }\n\n return pos({\n type: 'host',\n rules: style,\n });\n }\n\n /**\n * Parse media.\n */\n\n function atmedia() {\n const pos = position();\n const m = match(/^@media *([^{]+)/);\n\n if (!m) {\n return;\n }\n const media = trim(m[1]);\n\n if (!open()) {\n return error(`@media missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@media missing '}'`);\n }\n\n return pos({\n type: 'media',\n media,\n rules: style,\n });\n }\n\n /**\n * Parse custom-media.\n */\n\n function atcustommedia() {\n const pos = position();\n const m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2]),\n });\n }\n\n /**\n * Parse paged media.\n */\n\n function atpage() {\n const pos = position();\n const m = match(/^@page */);\n if (!m) {\n return;\n }\n\n const sel = selector() || [];\n\n if (!open()) {\n return error(`@page missing '{'`);\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(`@page missing '}'`);\n }\n\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls,\n });\n }\n\n /**\n * Parse document.\n */\n\n function atdocument() {\n const pos = position();\n const m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n\n const vendor = trim(m[1]);\n const doc = trim(m[2]);\n\n if (!open()) {\n return error(`@document missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@document missing '}'`);\n }\n\n return pos({\n type: 'document',\n document: doc,\n vendor,\n rules: style,\n });\n }\n\n /**\n * Parse font-face.\n */\n\n function atfontface() {\n const pos = position();\n const m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(`@font-face missing '{'`);\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(`@font-face missing '}'`);\n }\n\n return pos({\n type: 'font-face',\n declarations: decls,\n });\n }\n\n /**\n * Parse import\n */\n\n const atimport = _compileAtrule('import');\n\n /**\n * Parse charset\n */\n\n const atcharset = _compileAtrule('charset');\n\n /**\n * Parse namespace\n */\n\n const atnamespace = _compileAtrule('namespace');\n\n /**\n * Parse non-block at-rules\n */\n\n function _compileAtrule(name: string) {\n const re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return () => {\n const pos = position();\n const m = match(re);\n if (!m) {\n return;\n }\n const ret: Record = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n\n /**\n * Parse at rule.\n */\n\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n\n return (\n atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface()\n );\n }\n\n /**\n * Parse rule.\n */\n\n function rule() {\n const pos = position();\n const sel = selector();\n\n if (!sel) {\n return error('selector missing');\n }\n comments();\n\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations() as Declaration[],\n });\n }\n\n return addParent(stylesheet());\n}\n\n/**\n * Trim `str`.\n */\n\nfunction trim(str: string) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\n\n/**\n * Adds non-enumerable parent node reference to each node.\n */\n\nfunction addParent(obj: Stylesheet, parent?: Stylesheet) {\n const isNode = obj && typeof obj.type === 'string';\n const childParent = isNode ? obj : parent;\n\n for (const k of Object.keys(obj)) {\n const value = obj[k as keyof Stylesheet];\n if (Array.isArray(value)) {\n value.forEach((v) => {\n addParent(v, childParent);\n });\n } else if (value && typeof value === 'object') {\n addParent((value as unknown) as Stylesheet, childParent);\n }\n }\n\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null,\n });\n }\n\n return obj;\n}\n","import { parse } from './css';\nimport {\n serializedNodeWithId,\n NodeType,\n tagMap,\n elementNode,\n idNodeMap,\n INode,\n BuildCache,\n} from './types';\nimport { isElement } from './utils';\n\nconst tagMap: tagMap = {\n script: 'noscript',\n // camel case svg element tag names\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient',\n};\nfunction getTagName(n: elementNode): string {\n let tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\n\n// based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nfunction escapeRegExp(str: string) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nconst HOVER_SELECTOR = /([^\\\\]):hover/;\nconst HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nexport function addHoverClass(cssText: string, cache: BuildCache): string {\n const cachedStyle = cache?.stylesWithHoverClass.get(cssText);\n if (cachedStyle) return cachedStyle;\n\n const ast = parse(cssText, {\n silent: true,\n });\n\n if (!ast.stylesheet) {\n return cssText;\n }\n\n const selectors: string[] = [];\n ast.stylesheet.rules.forEach((rule) => {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach((selector: string) => {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n\n if (selectors.length === 0) {\n return cssText;\n }\n\n const selectorMatcher = new RegExp(\n selectors\n .filter((selector, index) => selectors.indexOf(selector) === index)\n .sort((a, b) => b.length - a.length)\n .map((selector) => {\n return escapeRegExp(selector);\n })\n .join('|'),\n 'g',\n );\n\n const result = cssText.replace(selectorMatcher, (selector) => {\n const newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return `${selector}, ${newSelector}`;\n });\n cache?.stylesWithHoverClass.set(cssText, result);\n return result;\n}\n\nexport function createCache(): BuildCache {\n const stylesWithHoverClass: Map = new Map();\n return {\n stylesWithHoverClass,\n };\n}\n\nfunction buildNode(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n hackCss: boolean;\n cache: BuildCache;\n },\n): Node | null {\n const { doc, hackCss, cache } = options;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(\n n.name || 'html',\n n.publicId,\n n.systemId,\n );\n case NodeType.Element:\n const tagName = getTagName(n);\n let node: Element;\n if (n.isSVG) {\n node = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n } else {\n node = doc.createElement(tagName);\n }\n for (const name in n.attributes) {\n if (!n.attributes.hasOwnProperty(name)) {\n continue;\n }\n let value = n.attributes[name];\n if (tagName === 'option' && name === 'selected' && value === false) {\n // legacy fix (TODO: if `value === false` can be generated for other attrs, should we also omit those other attrs from build?)\n continue;\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n // attribute names start with rr_ are internal attributes added by rrweb\n if (!name.startsWith('rr_')) {\n const isTextarea = tagName === 'textarea' && name === 'value';\n const isRemoteOrDynamicCss =\n tagName === 'style' && name === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n const child = doc.createTextNode(value);\n // https://github.com/rrweb-io/rrweb/issues/112\n for (const c of Array.from(node.childNodes)) {\n if (c.nodeType === node.TEXT_NODE) {\n node.removeChild(c);\n }\n }\n node.appendChild(child);\n continue;\n }\n\n try {\n if (n.isSVG && name === 'xlink:href') {\n node.setAttributeNS('http://www.w3.org/1999/xlink', name, value);\n } else if (\n name === 'onload' ||\n name === 'onclick' ||\n name.substring(0, 7) === 'onmouse'\n ) {\n // Rename some of the more common atttributes from https://www.w3schools.com/tags/ref_eventattributes.asp\n // as setting them triggers a console.error (which shows up despite the try/catch)\n // Assumption: these attributes are not used to css\n node.setAttribute('_' + name, value);\n } else if (\n tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name === 'content'\n ) {\n // If CSP contains style-src and inline-style is disabled, there will be an error \"Refused to apply inline style because it violates the following Content Security Policy directive: style-src '*'\".\n // And the function insertStyleRules in rrweb replayer will throw an error \"Uncaught TypeError: Cannot read property 'insertRule' of null\".\n node.setAttribute('csp-content', value);\n continue;\n } else if (\n tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script'\n ) {\n // ignore\n } else if (\n tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')\n ) {\n // ignore\n } else if (\n tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL\n ) {\n // backup original img srcset\n node.setAttribute('rrweb-original-srcset', n.attributes.srcset as string);\n } else {\n node.setAttribute(name, value);\n }\n } catch (error) {\n // skip invalid attribute\n }\n } else {\n // handle internal attributes\n if (tagName === 'canvas' && name === 'rr_dataURL') {\n const image = document.createElement('img');\n image.src = value;\n image.onload = () => {\n const ctx = (node as HTMLCanvasElement).getContext('2d');\n if (ctx) {\n ctx.drawImage(image, 0, 0, image.width, image.height);\n }\n };\n } else if (tagName === 'img' && name === 'rr_dataURL') {\n const image = node as HTMLImageElement;\n if (!image.currentSrc.startsWith('data:')) {\n // Backup original img src. It may not have been set yet.\n image.setAttribute(\n 'rrweb-original-src',\n n.attributes.src as string,\n );\n image.src = value;\n }\n }\n\n if (name === 'rr_width') {\n (node as HTMLElement).style.width = value;\n } else if (name === 'rr_height') {\n (node as HTMLElement).style.height = value;\n } else if (name === 'rr_mediaCurrentTime') {\n (node as HTMLMediaElement).currentTime = n.attributes\n .rr_mediaCurrentTime as number;\n } else if (name === 'rr_mediaState') {\n switch (value) {\n case 'played':\n (node as HTMLMediaElement)\n .play()\n .catch((e) => console.warn('media playback error', e));\n break;\n case 'paused':\n (node as HTMLMediaElement).pause();\n break;\n default:\n }\n }\n }\n }\n\n if (n.isShadowHost) {\n /**\n * Since node is newly rebuilt, it should be a normal element\n * without shadowRoot.\n * But if there are some weird situations that has defined\n * custom element in the scope before we rebuild node, it may\n * register the shadowRoot earlier.\n * The logic in the 'else' block is just a try-my-best solution\n * for the corner case, please let we know if it is wrong and\n * we can remove it.\n */\n if (!node.shadowRoot) {\n node.attachShadow({ mode: 'open' });\n } else {\n while (node.shadowRoot.firstChild) {\n node.shadowRoot.removeChild(node.shadowRoot.firstChild);\n }\n }\n }\n return node;\n case NodeType.Text:\n return doc.createTextNode(\n n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent,\n );\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\n\nexport function buildNodeWithSN(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n map: idNodeMap;\n skipChild?: boolean;\n hackCss: boolean;\n afterAppend?: (n: INode) => unknown;\n cache: BuildCache;\n },\n): INode | null {\n const {\n doc,\n map,\n skipChild = false,\n hackCss = true,\n afterAppend,\n cache,\n } = options;\n let node = buildNode(n, { doc, hackCss, cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(\n ((map[n.rootId] as unknown) as Document) === doc,\n 'Target document should has the same root id.',\n );\n }\n // use target document as root document\n if (n.type === NodeType.Document) {\n // close before open to make sure document was closed\n doc.close();\n doc.open();\n if (\n n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType // there isn't one already defined\n ) {\n // Trigger compatMode in the iframe\n // this is needed as document.createElement('iframe') otherwise inherits a CSS1Compat mode from the parent replayer environment\n if (\n n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml'\n ) {\n // might as well use an xhtml doctype if we've got an xhtml namespace\n doc.write(\n '',\n );\n } else {\n doc.write(\n '',\n );\n }\n }\n node = doc;\n }\n\n (node as INode).__sn = n;\n map[n.id] = node as INode;\n\n if (\n (n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild\n ) {\n for (const childN of n.childNodes) {\n const childNode = buildNodeWithSN(childN, {\n doc,\n map,\n skipChild: false,\n hackCss,\n afterAppend,\n cache,\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n } else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n\n return node as INode;\n}\n\nfunction visit(idNodeMap: idNodeMap, onVisit: (node: INode) => void) {\n function walk(node: INode) {\n onVisit(node);\n }\n\n for (const key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\n\nfunction handleScroll(node: INode) {\n const n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n const el = (node as Node) as HTMLElement;\n for (const name in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name) && name.startsWith('rr_'))) {\n continue;\n }\n const value = n.attributes[name];\n if (name === 'rr_scrollLeft') {\n el.scrollLeft = value as number;\n }\n if (name === 'rr_scrollTop') {\n el.scrollTop = value as number;\n }\n }\n}\n\nfunction rebuild(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n onVisit?: (node: INode) => unknown;\n hackCss?: boolean;\n afterAppend?: (n: INode) => unknown;\n cache: BuildCache;\n },\n): [Node | null, idNodeMap] {\n const { doc, onVisit, hackCss = true, afterAppend, cache } = options;\n const idNodeMap: idNodeMap = {};\n const node = buildNodeWithSN(n, {\n doc,\n map: idNodeMap,\n skipChild: false,\n hackCss,\n afterAppend,\n cache,\n });\n visit(idNodeMap, (visitedNode) => {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport default rebuild;\n"],"names":["NodeType","isElement","n","nodeType","ELEMENT_NODE","isShadowRoot","host","Boolean","shadowRoot","maskInputValue","_a","maskInputOptions","tagName","type","value","maskInputFn","text","toLowerCase","repeat","length","is2DCanvasBlank","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","call","Math","min","data","buffer","some","pixel","canvasService","canvasCtx","_id","tagNameRegex","RegExp","IGNORED_NODE","getCssRulesString","s","rules","cssRules","Array","from","map","getCssRuleString","join","error","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","slice","stack","parts","pop","parts_1","_i","part","push","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","classList","contains","eIndex","className","matches","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","Object","assign","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","_m","_l","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","snapshot","maskAllInputs","slimDOM","idNodeMap","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","visitSnapshot","onVisit","walk","current","forEach","cleanupSnapshot","commentre","parse","css","lineno","column","updatePosition","str","lines","i","lastIndexOf","position","start","line","Position","whitespace","this","end","source","prototype","content","errorsList","msg","Error","reason","filename","silent","open","close","comments","atrule","re","m","selector","declaration","propMatch","prop","val","ret","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","vendor","frame","frames","concat","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","atdocument","sel","selectors","atpage","athost","atfontface","addParent","parsingErrors","obj","parent","isNode","childParent","keys","isArray","v","defineProperty","configurable","writable","enumerable","tagMap","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cache","cachedStyle","stylesWithHoverClass","get","ast","selectorMatcher","filter","index","sort","b","result","newSelector","set","createCache","Map","buildNode","hackCss","implementation","createDocument","createDocumentType","node_1","getTagName","createElementNS","hasOwnProperty","startsWith","image","setAttribute","play","e","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","removeChild","appendChild","setAttributeNS","srcset","firstChild","attachShadow","mode","createCDATASection","createComment","buildNodeWithSN","afterAppend","assert","xmlns","write","childN","childNode","rebuild","key","visit","visitedNode","name_2","handleScroll"],"mappings":"IAAYA,WCEIC,EAAUC,GACx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AtC,IAAK+N,EACLtD,WAAW,EACXkN,sBACA4B,YAP2D/U,cAQ3DmS,MAR2DnS,UAgB7D,OA1DF,SAAeuJ,EAAsBe,GAKnC,IAAK,IAAMgL,KAAO/L,EACZA,EAAU+L,KALFjW,EAMLkK,EAAU+L,GALjBhL,EAAQjL,IADV,IAAcA,EAmDdkW,CAAMhM,GAAW,SAACiM,GACZlL,GACFA,EAAQkL,GA1Cd,SAAsBnW,GACpB,IAAM7G,EAAI6G,EAAKyB,KACf,GAAItI,EAAEW,OAASb,EAAS2M,QAAxB,CAGA,IAAM9E,EAAMd,EACZ,IAAK,IAAMoW,KAAQjd,EAAE0J,WACnB,GAAM1J,EAAE0J,WAAWwR,eAAe+B,IAASA,EAAK9B,WAAW,OAA3D,CAGA,IAAMva,EAAQZ,EAAE0J,WAAWuT,GACd,kBAATA,IACFtV,EAAGkE,WAAajL,GAEL,iBAATqc,IACFtV,EAAGoE,UAAYnL,KA6BjBsc,CAAaF,MAER,CAACnW,EAAMkK"} +\ No newline at end of file ++{"version":3,"file":"rrweb-snapshot.min.js","sources":["../src/types.ts","../src/utils.ts","../src/snapshot.ts","../src/css.ts","../src/rebuild.ts"],"sourcesContent":["export enum NodeType {\n Document,\n DocumentType,\n Element,\n Text,\n CDATA,\n Comment,\n}\n\nexport type documentNode = {\n type: NodeType.Document;\n childNodes: serializedNodeWithId[];\n compatMode?: string;\n};\n\nexport type documentTypeNode = {\n type: NodeType.DocumentType;\n name: string;\n publicId: string;\n systemId: string;\n};\n\nexport type attributes = {\n [key: string]: string | number | boolean;\n};\nexport type elementNode = {\n type: NodeType.Element;\n tagName: string;\n attributes: attributes;\n childNodes: serializedNodeWithId[];\n isSVG?: true;\n needBlock?: boolean;\n};\n\nexport type textNode = {\n type: NodeType.Text;\n textContent: string;\n isStyle?: true;\n};\n\nexport type cdataNode = {\n type: NodeType.CDATA;\n textContent: '';\n};\n\nexport type commentNode = {\n type: NodeType.Comment;\n textContent: string;\n};\n\nexport type serializedNode = (\n | documentNode\n | documentTypeNode\n | elementNode\n | textNode\n | cdataNode\n | commentNode\n) & {\n rootId?: number;\n isShadowHost?: boolean;\n isShadow?: boolean;\n};\n\nexport type serializedNodeWithId = serializedNode & { id: number };\n\nexport type tagMap = {\n [key: string]: string;\n};\n\nexport interface INode extends Node {\n __sn: serializedNodeWithId;\n}\n\nexport interface ICanvas extends HTMLCanvasElement {\n __context: string;\n}\n\nexport type idNodeMap = {\n [key: number]: INode;\n};\n\nexport type MaskInputOptions = Partial<{\n color: boolean;\n date: boolean;\n 'datetime-local': boolean;\n email: boolean;\n month: boolean;\n number: boolean;\n range: boolean;\n search: boolean;\n tel: boolean;\n text: boolean;\n time: boolean;\n url: boolean;\n week: boolean;\n // unify textarea and select element with text input\n textarea: boolean;\n select: boolean;\n password: boolean;\n}>;\n\nexport type SlimDOMOptions = Partial<{\n script: boolean;\n comment: boolean;\n headFavicon: boolean;\n headWhitespace: boolean;\n headMetaDescKeywords: boolean;\n headMetaSocial: boolean;\n headMetaRobots: boolean;\n headMetaHttpEquiv: boolean;\n headMetaAuthorship: boolean;\n headMetaVerification: boolean;\n}>;\n\nexport type DataURLOptions = Partial<{\n type: string;\n quality: number;\n}>;\n\nexport type MaskTextFn = (text: string) => string;\nexport type MaskInputFn = (text: string) => string;\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\nexport type BuildCache = {\n stylesWithHoverClass: Map;\n};\n","import { INode, MaskInputFn, MaskInputOptions } from './types';\n\nexport function isElement(n: Node | INode): n is Element {\n return n.nodeType === n.ELEMENT_NODE;\n}\n\nexport function isShadowRoot(n: Node): n is ShadowRoot {\n const host: Element | null = (n as ShadowRoot)?.host;\n return Boolean(host && host.shadowRoot && host.shadowRoot === n);\n}\n\nexport function maskInputValue({\n input,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n tagName,\n type,\n value,\n maskInputFn,\n}: {\n input: HTMLElement;\n maskInputSelector: string|null;\n unmaskInputSelector: string|null;\n maskInputOptions: MaskInputOptions;\n tagName: string;\n type: string | number | boolean | null;\n value: string | null;\n maskInputFn?: MaskInputFn;\n}): string {\n let text = value || '';\n\n if (unmaskInputSelector && input.matches(unmaskInputSelector)) {\n return text;\n }\n\n if (\n maskInputOptions[tagName.toLowerCase() as keyof MaskInputOptions] ||\n maskInputOptions[type as keyof MaskInputOptions] ||\n (maskInputSelector && input.matches(maskInputSelector))\n ) {\n if (maskInputFn) {\n text = maskInputFn(text);\n } else {\n text = '*'.repeat(text.length);\n }\n }\n return text;\n}\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedGetImageData = {\n [ORIGINAL_ATTRIBUTE_NAME]: CanvasImageData['getImageData'];\n} & CanvasImageData['getImageData'];\n\nexport function is2DCanvasBlank(canvas: HTMLCanvasElement): boolean {\n const ctx = canvas.getContext('2d');\n if (!ctx) return true;\n\n const chunkSize = 50;\n\n // get chunks of the canvas and check if it is blank\n for (let x = 0; x < canvas.width; x += chunkSize) {\n for (let y = 0; y < canvas.height; y += chunkSize) {\n const getImageData = ctx.getImageData as PatchedGetImageData;\n const originalGetImageData =\n ORIGINAL_ATTRIBUTE_NAME in getImageData\n ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n : getImageData;\n // by getting the canvas in chunks we avoid an expensive\n // `getImageData` call that retrieves everything\n // even if we can already tell from the first chunk(s) that\n // the canvas isn't blank\n const pixelBuffer = new Uint32Array(\n originalGetImageData.call(\n ctx,\n x,\n y,\n Math.min(chunkSize, canvas.width - x),\n Math.min(chunkSize, canvas.height - y),\n ).data.buffer,\n );\n if (pixelBuffer.some((pixel) => pixel !== 0)) return false;\n }\n }\n return true;\n}\n","import {\n serializedNode,\n serializedNodeWithId,\n NodeType,\n attributes,\n INode,\n idNodeMap,\n MaskInputOptions,\n SlimDOMOptions,\n DataURLOptions,\n MaskTextFn,\n MaskInputFn,\n KeepIframeSrcFn,\n ICanvas,\n} from './types';\nimport {\n is2DCanvasBlank,\n isElement,\n isShadowRoot,\n maskInputValue,\n} from './utils';\n\nlet _id = 1;\nconst tagNameRegex = new RegExp('[^a-z0-9-_:]');\n\nexport const IGNORED_NODE = -2;\n\nfunction genId(): number {\n return _id++;\n}\n\nfunction getValidTagName(element: HTMLElement): string {\n if (element instanceof HTMLFormElement) {\n return 'form';\n }\n\n const processedTagName = element.tagName.toLowerCase().trim();\n\n if (tagNameRegex.test(processedTagName)) {\n // if the tag name is odd and we cannot extract\n // anything from the string, then we return a\n // generic div\n return 'div';\n }\n\n return processedTagName;\n}\n\nfunction getCssRulesString(s: CSSStyleSheet): string | null {\n try {\n const rules = s.rules || s.cssRules;\n return rules ? Array.from(rules).map(getCssRuleString).join('') : null;\n } catch (error) {\n return null;\n }\n}\n\nfunction getCssRuleString(rule: CSSRule): string {\n let cssStringified = rule.cssText;\n if (isCSSImportRule(rule)) {\n try {\n cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;\n } catch {\n // ignore\n }\n }\n return cssStringified;\n}\n\nfunction isCSSImportRule(rule: CSSRule): rule is CSSImportRule {\n return 'styleSheet' in rule;\n}\n\nfunction stringifyStyleSheet(sheet: CSSStyleSheet): string {\n return sheet.cssRules\n ? Array.from(sheet.cssRules)\n .map((rule) => rule.cssText || '')\n .join('')\n : '';\n}\n\nfunction extractOrigin(url: string): string {\n let origin = '';\n if (url.indexOf('//') > -1) {\n origin = url.split('/').slice(0, 3).join('/');\n } else {\n origin = url.split('/')[0];\n }\n origin = origin.split('?')[0];\n return origin;\n}\n\nlet canvasService: HTMLCanvasElement | null;\nlet canvasCtx: CanvasRenderingContext2D | null;\n\nconst URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nconst RELATIVE_PATH = /^(?!www\\.|(?:http|ftp)s?:\\/\\/|[A-Za-z]:\\\\|\\/\\/|#).*/;\nconst DATA_URI = /^(data:)([^,]*),(.*)/i;\nexport function absoluteToStylesheet(\n cssText: string | null,\n href: string,\n): string {\n return (cssText || '').replace(\n URL_IN_CSS_REF,\n (origin, quote1, path1, quote2, path2, path3) => {\n const filePath = path1 || path2 || path3;\n const maybeQuote = quote1 || quote2 || '';\n if (!filePath) {\n return origin;\n }\n if (!RELATIVE_PATH.test(filePath)) {\n return `url(${maybeQuote}${filePath}${maybeQuote})`;\n }\n if (DATA_URI.test(filePath)) {\n return `url(${maybeQuote}${filePath}${maybeQuote})`;\n }\n if (filePath[0] === '/') {\n return `url(${maybeQuote}${\n extractOrigin(href) + filePath\n }${maybeQuote})`;\n }\n const stack = href.split('/');\n const parts = filePath.split('/');\n stack.pop();\n for (const part of parts) {\n if (part === '.') {\n continue;\n } else if (part === '..') {\n stack.pop();\n } else {\n stack.push(part);\n }\n }\n return `url(${maybeQuote}${stack.join('/')}${maybeQuote})`;\n },\n );\n}\n\nconst SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/; // Don't use \\s, to avoid matching non-breaking space\nconst SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc: Document, attributeValue: string) {\n /*\n run absoluteToDoc over every url in the srcset\n\n this is adapted from https://github.com/albell/parse-srcset/\n without the parsing of the descriptors (we return these as-is)\n parce-srcset is in turn based on\n https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute\n */\n if (attributeValue.trim() === '') {\n return attributeValue;\n }\n\n let pos = 0;\n\n function collectCharacters(regEx: RegExp) {\n let chars: string;\n let match = regEx.exec(attributeValue.substring(pos));\n if (match) {\n chars = match[0];\n pos += chars.length;\n return chars;\n }\n return '';\n }\n\n let output = [];\n while (true) {\n collectCharacters(SRCSET_COMMAS_OR_SPACES);\n if (pos >= attributeValue.length) {\n break;\n }\n // don't split on commas within urls\n let url = collectCharacters(SRCSET_NOT_SPACES);\n if (url.slice(-1) === ',') {\n // aside: according to spec more than one comma at the end is a parse error, but we ignore that\n url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n // the trailing comma splits the srcset, so the interpretion is that\n // another url will follow, and the descriptor is empty\n output.push(url);\n } else {\n let descriptorsStr = '';\n url = absoluteToDoc(doc, url);\n let inParens = false;\n while (true) {\n let c = attributeValue.charAt(pos);\n if (c === '') {\n output.push((url + descriptorsStr).trim());\n break;\n } else if (!inParens) {\n if (c === ',') {\n pos += 1;\n output.push((url + descriptorsStr).trim());\n break; // parse the next url\n } else if (c === '(') {\n inParens = true;\n }\n } else {\n // in parenthesis; ignore commas\n // (parenthesis may be supported by future additions to spec)\n if (c === ')') {\n inParens = false;\n }\n }\n descriptorsStr += c;\n pos += 1;\n }\n }\n }\n return output.join(', ');\n}\n\nexport function absoluteToDoc(doc: Document, attributeValue: string): string {\n if (!attributeValue || attributeValue.trim() === '') {\n return attributeValue;\n }\n const a: HTMLAnchorElement = doc.createElement('a');\n a.href = attributeValue;\n return a.href;\n}\n\nfunction isSVGElement(el: Element): boolean {\n return Boolean(el.tagName === 'svg' || (el as SVGElement).ownerSVGElement);\n}\n\nfunction getHref() {\n // return a href without hash\n const a = document.createElement('a');\n a.href = '';\n return a.href;\n}\n\nexport function transformAttribute(\n doc: Document,\n tagName: string,\n name: string,\n value: string,\n): string {\n // relative path in attribute\n if (name === 'src' || (name === 'href' && value)) {\n return absoluteToDoc(doc, value);\n } else if (name === 'xlink:href' && value && value[0] !== '#') {\n // xlink:href starts with # is an id pointer\n return absoluteToDoc(doc, value);\n } else if (\n name === 'background' &&\n value &&\n (tagName === 'table' || tagName === 'td' || tagName === 'th')\n ) {\n return absoluteToDoc(doc, value);\n } else if (name === 'srcset' && value) {\n return getAbsoluteSrcsetString(doc, value);\n } else if (name === 'style' && value) {\n return absoluteToStylesheet(value, getHref());\n } else if (tagName === 'object' && name === 'data' && value) {\n return absoluteToDoc(doc, value);\n } else {\n return value;\n }\n}\n\nexport function _isBlockedElement(\n element: HTMLElement,\n blockClass: string | RegExp,\n blockSelector: string | null,\n unblockSelector: string | null,\n): boolean {\n if (unblockSelector && element.matches(unblockSelector)) {\n return false;\n }\n\n if (typeof blockClass === 'string') {\n if (element.classList.contains(blockClass)) {\n return true;\n }\n } else {\n // tslint:disable-next-line: prefer-for-of\n for (let eIndex = 0; eIndex < element.classList.length; eIndex++) {\n const className = element.classList[eIndex];\n if (blockClass.test(className)) {\n return true;\n }\n }\n }\n if (blockSelector) {\n return element.matches(blockSelector);\n }\n\n return false;\n}\n\nexport function needMaskingText(\n node: Node | null,\n maskTextClass: string | RegExp,\n maskTextSelector: string | null,\n unmaskTextSelector: string | null,\n): boolean {\n if (!node) {\n return false;\n }\n if (node.nodeType === node.ELEMENT_NODE) {\n if (unmaskTextSelector) {\n if ((node as HTMLElement).matches(unmaskTextSelector) || (node as HTMLElement).closest(unmaskTextSelector)) {\n return false;\n }\n }\n\n if (typeof maskTextClass === 'string') {\n if ((node as HTMLElement).classList.contains(maskTextClass)) {\n return true;\n }\n } else {\n // tslint:disable-next-line: prefer-for-of\n for (\n let eIndex = 0;\n eIndex < (node as HTMLElement).classList.length;\n eIndex++\n ) {\n const className = (node as HTMLElement).classList[eIndex];\n if (maskTextClass.test(className)) {\n return true;\n }\n }\n }\n if (maskTextSelector) {\n if ((node as HTMLElement).matches(maskTextSelector)) {\n return true;\n }\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n\n if (node.nodeType === node.TEXT_NODE) {\n // check parent node since text node do not have class name\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n }\n return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);\n}\n\n// https://stackoverflow.com/a/36155560\nfunction onceIframeLoaded(\n iframeEl: HTMLIFrameElement,\n listener: () => unknown,\n iframeLoadTimeout: number,\n) {\n const win = iframeEl.contentWindow;\n if (!win) {\n return;\n }\n // document is loading\n let fired = false;\n\n let readyState: DocumentReadyState;\n try {\n readyState = win.document.readyState;\n } catch (error) {\n return;\n }\n if (readyState !== 'complete') {\n const timer = setTimeout(() => {\n if (!fired) {\n listener();\n fired = true;\n }\n }, iframeLoadTimeout);\n iframeEl.addEventListener('load', () => {\n clearTimeout(timer);\n fired = true;\n listener();\n });\n return;\n }\n // check blank frame for Chrome\n const blankUrl = 'about:blank';\n if (\n win.location.href !== blankUrl ||\n iframeEl.src === blankUrl ||\n iframeEl.src === ''\n ) {\n // iframe was already loaded, make sure we wait to trigger the listener\n // till _after_ the mutation that found this iframe has had time to process\n setTimeout(listener, 0);\n return;\n }\n // use default listener\n iframeEl.addEventListener('load', listener);\n}\n\nfunction serializeNode(\n n: Node,\n options: {\n doc: Document;\n blockClass: string | RegExp;\n blockSelector: string | null;\n unblockSelector: string | null;\n maskTextClass: string | RegExp;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n inlineStylesheet: boolean;\n maskInputOptions: MaskInputOptions;\n maskTextFn: MaskTextFn | undefined;\n maskInputFn: MaskInputFn | undefined;\n dataURLOptions?: DataURLOptions;\n inlineImages: boolean;\n recordCanvas: boolean;\n keepIframeSrcFn: KeepIframeSrcFn;\n },\n): serializedNode | false {\n const {\n doc,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions = {},\n maskTextFn,\n maskInputFn,\n dataURLOptions = {},\n inlineImages,\n recordCanvas,\n keepIframeSrcFn,\n } = options;\n // Only record root id when document object is not the base document\n let rootId: number | undefined;\n if (((doc as unknown) as INode).__sn) {\n const docId = ((doc as unknown) as INode).__sn.id;\n rootId = docId === 1 ? undefined : docId;\n }\n switch (n.nodeType) {\n case n.DOCUMENT_NODE:\n if ((n as HTMLDocument).compatMode !== 'CSS1Compat') {\n return {\n type: NodeType.Document,\n childNodes: [],\n compatMode: (n as HTMLDocument).compatMode, // probably \"BackCompat\"\n rootId,\n };\n } else {\n return {\n type: NodeType.Document,\n childNodes: [],\n rootId,\n };\n }\n case n.DOCUMENT_TYPE_NODE:\n return {\n type: NodeType.DocumentType,\n name: (n as DocumentType).name,\n publicId: (n as DocumentType).publicId,\n systemId: (n as DocumentType).systemId,\n rootId,\n };\n case n.ELEMENT_NODE:\n const needBlock = _isBlockedElement(\n n as HTMLElement,\n blockClass,\n blockSelector,\n unblockSelector\n );\n const tagName = getValidTagName(n as HTMLElement);\n let attributes: attributes = {};\n for (const { name, value } of Array.from((n as HTMLElement).attributes)) {\n attributes[name] = transformAttribute(doc, tagName, name, value);\n }\n // remote css\n if (tagName === 'link' && inlineStylesheet) {\n const stylesheet = Array.from(doc.styleSheets).find((s) => {\n return s.href === (n as HTMLLinkElement).href;\n });\n let cssText: string | null = null;\n if (stylesheet) {\n cssText = getCssRulesString(stylesheet as CSSStyleSheet);\n }\n if (cssText) {\n delete attributes.rel;\n delete attributes.href;\n attributes._cssText = absoluteToStylesheet(\n cssText,\n stylesheet!.href!,\n );\n }\n }\n // dynamic stylesheet\n if (\n tagName === 'style' &&\n (n as HTMLStyleElement).sheet &&\n // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element\n !(\n (n as HTMLElement).innerText ||\n (n as HTMLElement).textContent ||\n ''\n ).trim().length\n ) {\n const cssText = getCssRulesString(\n (n as HTMLStyleElement).sheet as CSSStyleSheet,\n );\n if (cssText) {\n attributes._cssText = absoluteToStylesheet(cssText, getHref());\n }\n }\n // form fields\n if (\n tagName === 'input' ||\n tagName === 'textarea' ||\n tagName === 'select'\n ) {\n const value = (n as HTMLInputElement | HTMLTextAreaElement).value;\n if (\n attributes.type !== 'radio' &&\n attributes.type !== 'checkbox' &&\n attributes.type !== 'submit' &&\n attributes.type !== 'button' &&\n value\n ) {\n attributes.value = maskInputValue({\n input: n as HTMLElement,\n type: attributes.type,\n tagName,\n value,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskInputFn,\n });\n } else if ((n as HTMLInputElement).checked) {\n attributes.checked = (n as HTMLInputElement).checked;\n }\n }\n if (tagName === 'option') {\n if ((n as HTMLOptionElement).selected && !maskInputOptions['select']) {\n attributes.selected = true;\n } else {\n // ignore the html attribute (which corresponds to DOM (n as HTMLOptionElement).defaultSelected)\n // if it's already been changed\n delete attributes.selected;\n }\n }\n // canvas image data\n if (tagName === 'canvas' && recordCanvas) {\n if ((n as ICanvas).__context === '2d') {\n // only record this on 2d canvas\n if (!is2DCanvasBlank(n as HTMLCanvasElement)) {\n attributes.rr_dataURL = (n as HTMLCanvasElement).toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n }\n } else if (!('__context' in n)) {\n // context is unknown, better not call getContext to trigger it\n const canvasDataURL = (n as HTMLCanvasElement).toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n\n // create blank canvas of same dimensions\n const blankCanvas = document.createElement('canvas');\n blankCanvas.width = (n as HTMLCanvasElement).width;\n blankCanvas.height = (n as HTMLCanvasElement).height;\n const blankCanvasDataURL = blankCanvas.toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n\n // no need to save dataURL if it's the same as blank canvas\n if (canvasDataURL !== blankCanvasDataURL) {\n attributes.rr_dataURL = canvasDataURL;\n }\n }\n }\n // save image offline\n if (tagName === 'img' && inlineImages) {\n if (!canvasService) {\n canvasService = doc.createElement('canvas');\n canvasCtx = canvasService.getContext('2d');\n }\n const image = n as HTMLImageElement;\n const oldValue = image.crossOrigin;\n image.crossOrigin = 'anonymous';\n const recordInlineImage = () => {\n try {\n canvasService!.width = image.naturalWidth;\n canvasService!.height = image.naturalHeight;\n canvasCtx!.drawImage(image, 0, 0);\n attributes.rr_dataURL = canvasService!.toDataURL(\n dataURLOptions.type,\n dataURLOptions.quality,\n );\n } catch (err) {\n console.warn(\n `Cannot inline img src=${image.currentSrc}! Error: ${err}`,\n );\n }\n oldValue\n ? (attributes.crossOrigin = oldValue)\n : delete attributes.crossOrigin;\n };\n // The image content may not have finished loading yet.\n if (image.complete && image.naturalWidth !== 0) recordInlineImage();\n else image.onload = recordInlineImage;\n }\n // media elements\n if (tagName === 'audio' || tagName === 'video') {\n attributes.rr_mediaState = (n as HTMLMediaElement).paused\n ? 'paused'\n : 'played';\n attributes.rr_mediaCurrentTime = (n as HTMLMediaElement).currentTime;\n }\n // scroll\n if ((n as HTMLElement).scrollLeft) {\n attributes.rr_scrollLeft = (n as HTMLElement).scrollLeft;\n }\n if ((n as HTMLElement).scrollTop) {\n attributes.rr_scrollTop = (n as HTMLElement).scrollTop;\n }\n // block element\n if (needBlock) {\n const { width, height } = (n as HTMLElement).getBoundingClientRect();\n attributes = {\n class: attributes.class,\n rr_width: `${width}px`,\n rr_height: `${height}px`,\n };\n }\n // iframe\n if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src as string)) {\n if (!(n as HTMLIFrameElement).contentDocument) {\n // we can't record it directly as we can't see into it\n // preserve the src attribute so a decision can be taken at replay time\n attributes.rr_src = attributes.src;\n }\n delete attributes.src; // prevent auto loading\n }\n return {\n type: NodeType.Element,\n tagName,\n attributes,\n childNodes: [],\n isSVG: isSVGElement(n as Element) || undefined,\n needBlock,\n rootId,\n };\n case n.TEXT_NODE:\n // The parent node may not be a html element which has a tagName attribute.\n // So just let it be undefined which is ok in this use case.\n const parentTagName =\n n.parentNode && (n.parentNode as HTMLElement).tagName;\n let textContent = (n as Text).textContent;\n const isStyle = parentTagName === 'STYLE' ? true : undefined;\n const isScript = parentTagName === 'SCRIPT' ? true : undefined;\n if (isStyle && textContent) {\n try {\n // try to read style sheet\n if (n.nextSibling || n.previousSibling) {\n // This is not the only child of the stylesheet.\n // We can't read all of the sheet's .cssRules and expect them\n // to _only_ include the current rule(s) added by the text node.\n // So we'll be conservative and keep textContent as-is.\n } else if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) {\n textContent = stringifyStyleSheet(\n (n.parentNode as HTMLStyleElement).sheet!,\n );\n }\n } catch (err) {\n console.warn(\n `Cannot get CSS styles from text's parentNode. Error: ${err}`,\n n,\n );\n }\n textContent = absoluteToStylesheet(textContent, getHref());\n }\n if (isScript) {\n textContent = 'SCRIPT_PLACEHOLDER';\n }\n if (\n !isStyle &&\n !isScript &&\n needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&\n textContent\n ) {\n textContent = maskTextFn\n ? maskTextFn(textContent)\n : textContent.replace(/[\\S]/g, '*');\n }\n return {\n type: NodeType.Text,\n textContent: textContent || '',\n isStyle,\n rootId,\n };\n case n.CDATA_SECTION_NODE:\n return {\n type: NodeType.CDATA,\n textContent: '',\n rootId,\n };\n case n.COMMENT_NODE:\n return {\n type: NodeType.Comment,\n textContent: (n as Comment).textContent || '',\n rootId,\n };\n default:\n return false;\n }\n}\n\nfunction lowerIfExists(maybeAttr: string | number | boolean): string {\n if (maybeAttr === undefined) {\n return '';\n } else {\n return (maybeAttr as string).toLowerCase();\n }\n}\n\nfunction slimDOMExcluded(\n sn: serializedNode,\n slimDOMOptions: SlimDOMOptions,\n): boolean {\n if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n // TODO: convert IE conditional comments to real nodes\n return true;\n } else if (sn.type === NodeType.Element) {\n if (\n slimDOMOptions.script &&\n // script tag\n (sn.tagName === 'script' ||\n // preload link\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'preload' &&\n sn.attributes.as === 'script') ||\n // prefetch link\n (sn.tagName === 'link' &&\n sn.attributes.rel === 'prefetch' &&\n typeof sn.attributes.href === 'string' &&\n sn.attributes.href.endsWith('.js')))\n ) {\n return true;\n } else if (\n slimDOMOptions.headFavicon &&\n ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n (sn.tagName === 'meta' &&\n (lowerIfExists(sn.attributes.name).match(\n /^msapplication-tile(image|color)$/,\n ) ||\n lowerIfExists(sn.attributes.name) === 'application-name' ||\n lowerIfExists(sn.attributes.rel) === 'icon' ||\n lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n lowerIfExists(sn.attributes.rel) === 'shortcut icon')))\n ) {\n return true;\n } else if (sn.tagName === 'meta') {\n if (\n slimDOMOptions.headMetaDescKeywords &&\n lowerIfExists(sn.attributes.name).match(/^description|keywords$/)\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaSocial &&\n (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)\n lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n lowerIfExists(sn.attributes.name) === 'pinterest')\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaRobots &&\n (lowerIfExists(sn.attributes.name) === 'robots' ||\n lowerIfExists(sn.attributes.name) === 'googlebot' ||\n lowerIfExists(sn.attributes.name) === 'bingbot')\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaHttpEquiv &&\n sn.attributes['http-equiv'] !== undefined\n ) {\n // e.g. X-UA-Compatible, Content-Type, Content-Language,\n // cache-control, X-Translated-By\n return true;\n } else if (\n slimDOMOptions.headMetaAuthorship &&\n (lowerIfExists(sn.attributes.name) === 'author' ||\n lowerIfExists(sn.attributes.name) === 'generator' ||\n lowerIfExists(sn.attributes.name) === 'framework' ||\n lowerIfExists(sn.attributes.name) === 'publisher' ||\n lowerIfExists(sn.attributes.name) === 'progid' ||\n lowerIfExists(sn.attributes.property).match(/^article:/) ||\n lowerIfExists(sn.attributes.property).match(/^product:/))\n ) {\n return true;\n } else if (\n slimDOMOptions.headMetaVerification &&\n (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n lowerIfExists(sn.attributes.name) === 'verification' ||\n lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')\n ) {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function serializeNodeWithId(\n n: Node | INode,\n options: {\n doc: Document;\n map: idNodeMap;\n blockClass: string | RegExp;\n blockSelector: string | null;\n unblockSelector: string | null;\n maskTextClass: string | RegExp;\n maskTextSelector: string | null;\n unmaskTextSelector: string | null;\n skipChild: boolean;\n inlineStylesheet: boolean;\n maskInputSelector: string | null;\n unmaskInputSelector: string | null;\n maskInputOptions?: MaskInputOptions;\n maskTextFn: MaskTextFn | undefined;\n maskInputFn: MaskInputFn | undefined;\n slimDOMOptions: SlimDOMOptions;\n dataURLOptions?: DataURLOptions;\n keepIframeSrcFn?: KeepIframeSrcFn;\n inlineImages?: boolean;\n recordCanvas?: boolean;\n preserveWhiteSpace?: boolean;\n onSerialize?: (n: INode) => unknown;\n onIframeLoad?: (iframeINode: INode, node: serializedNodeWithId) => unknown;\n iframeLoadTimeout?: number;\n },\n): serializedNodeWithId | null {\n const {\n doc,\n map,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n skipChild = false,\n inlineStylesheet = true,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions = {},\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions = {},\n inlineImages = false,\n recordCanvas = false,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout = 5000,\n keepIframeSrcFn = () => false,\n } = options;\n let { preserveWhiteSpace = true } = options;\n const _serializedNode = serializeNode(n, {\n doc,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n keepIframeSrcFn,\n });\n if (!_serializedNode) {\n // TODO: dev only\n console.warn(n, 'not serialized');\n return null;\n }\n\n let id;\n // Try to reuse the previous id\n if ('__sn' in n) {\n id = n.__sn.id;\n } else if (\n slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n (!preserveWhiteSpace &&\n _serializedNode.type === NodeType.Text &&\n !_serializedNode.isStyle &&\n !_serializedNode.textContent.replace(/^\\s+|\\s+$/gm, '').length)\n ) {\n id = IGNORED_NODE;\n } else {\n id = genId();\n }\n const serializedNode = Object.assign(_serializedNode, { id });\n (n as INode).__sn = serializedNode;\n if (id === IGNORED_NODE) {\n return null; // slimDOM\n }\n map[id] = n as INode;\n if (onSerialize) {\n onSerialize(n as INode);\n }\n let recordChild = !skipChild;\n if (serializedNode.type === NodeType.Element) {\n recordChild = recordChild && !serializedNode.needBlock;\n // this property was not needed in replay side\n delete serializedNode.needBlock;\n if ((n as HTMLElement).shadowRoot) serializedNode.isShadowHost = true;\n }\n if (\n (serializedNode.type === NodeType.Document ||\n serializedNode.type === NodeType.Element) &&\n recordChild\n ) {\n if (\n slimDOMOptions.headWhitespace &&\n _serializedNode.type === NodeType.Element &&\n _serializedNode.tagName === 'head'\n // would impede performance: || getComputedStyle(n)['white-space'] === 'normal'\n ) {\n preserveWhiteSpace = false;\n }\n const bypassOptions = {\n doc,\n map,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n skipChild,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n };\n for (const childN of Array.from(n.childNodes)) {\n const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n\n if (isElement(n) && n.shadowRoot) {\n for (const childN of Array.from(n.shadowRoot.childNodes)) {\n const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n if (serializedChildNode) {\n serializedChildNode.isShadow = true;\n serializedNode.childNodes.push(serializedChildNode);\n }\n }\n }\n }\n\n if (n.parentNode && isShadowRoot(n.parentNode)) {\n serializedNode.isShadow = true;\n }\n\n if (\n serializedNode.type === NodeType.Element &&\n serializedNode.tagName === 'iframe'\n ) {\n onceIframeLoaded(\n n as HTMLIFrameElement,\n () => {\n const iframeDoc = (n as HTMLIFrameElement).contentDocument;\n if (iframeDoc && onIframeLoad) {\n const serializedIframeNode = serializeNodeWithId(iframeDoc, {\n doc: iframeDoc,\n map,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n skipChild: false,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n });\n\n if (serializedIframeNode) {\n onIframeLoad(n as INode, serializedIframeNode);\n }\n }\n },\n iframeLoadTimeout,\n );\n }\n\n return serializedNode;\n}\n\nfunction snapshot(\n n: Document,\n options?: {\n blockClass?: string | RegExp;\n blockSelector?: string | null;\n unblockSelector?: string | null;\n maskTextClass?: string | RegExp;\n maskTextSelector?: string | null;\n unmaskTextSelector?: string | null;\n maskInputSelector?: string | null;\n unmaskInputSelector?: string | null;\n inlineStylesheet?: boolean;\n maskAllInputs?: boolean | MaskInputOptions;\n maskTextFn?: MaskTextFn;\n maskInputFn?: MaskTextFn;\n slimDOM?: boolean | SlimDOMOptions;\n dataURLOptions?: DataURLOptions;\n inlineImages?: boolean;\n recordCanvas?: boolean;\n preserveWhiteSpace?: boolean;\n onSerialize?: (n: INode) => unknown;\n onIframeLoad?: (iframeINode: INode, node: serializedNodeWithId) => unknown;\n iframeLoadTimeout?: number;\n keepIframeSrcFn?: KeepIframeSrcFn;\n },\n): [serializedNodeWithId | null, idNodeMap] {\n const {\n blockClass = 'rr-block',\n blockSelector = null,\n unblockSelector = null,\n maskTextClass = 'rr-mask',\n maskTextSelector = null,\n unmaskTextSelector = null,\n inlineStylesheet = true,\n inlineImages = false,\n recordCanvas = false,\n maskInputSelector = null,\n unmaskInputSelector = null,\n maskAllInputs = false,\n maskTextFn,\n maskInputFn,\n slimDOM = false,\n dataURLOptions,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn = () => false,\n } = options || {};\n const idNodeMap: idNodeMap = {};\n const maskInputOptions: MaskInputOptions =\n maskAllInputs === true\n ? {\n color: true,\n date: true,\n 'datetime-local': true,\n email: true,\n month: true,\n number: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n time: true,\n url: true,\n week: true,\n textarea: true,\n select: true,\n password: true,\n }\n : maskAllInputs === false\n ? {\n password: true,\n }\n : maskAllInputs;\n const slimDOMOptions: SlimDOMOptions =\n slimDOM === true || slimDOM === 'all'\n ? // if true: set of sensible options that should not throw away any information\n {\n script: true,\n comment: true,\n headFavicon: true,\n headWhitespace: true,\n headMetaDescKeywords: slimDOM === 'all', // destructive\n headMetaSocial: true,\n headMetaRobots: true,\n headMetaHttpEquiv: true,\n headMetaAuthorship: true,\n headMetaVerification: true,\n }\n : slimDOM === false\n ? {}\n : slimDOM;\n return [\n serializeNodeWithId(n, {\n doc: n,\n map: idNodeMap,\n blockClass,\n blockSelector,\n unblockSelector,\n maskTextClass,\n maskTextSelector,\n unmaskTextSelector,\n skipChild: false,\n inlineStylesheet,\n maskInputSelector,\n unmaskInputSelector,\n maskInputOptions,\n maskTextFn,\n maskInputFn,\n slimDOMOptions,\n dataURLOptions,\n inlineImages,\n recordCanvas,\n preserveWhiteSpace,\n onSerialize,\n onIframeLoad,\n iframeLoadTimeout,\n keepIframeSrcFn,\n }),\n idNodeMap,\n ];\n}\n\nexport function visitSnapshot(\n node: serializedNodeWithId,\n onVisit: (node: serializedNodeWithId) => unknown,\n) {\n function walk(current: serializedNodeWithId) {\n onVisit(current);\n if (\n current.type === NodeType.Document ||\n current.type === NodeType.Element\n ) {\n current.childNodes.forEach(walk);\n }\n }\n\n walk(node);\n}\n\nexport function cleanupSnapshot() {\n // allow a new recording to start numbering nodes from scratch\n _id = 1;\n}\n\nexport default snapshot;\n","/**\n * This file is a fork of https://github.com/reworkcss/css/blob/master/lib/parse/index.js\n * I fork it because:\n * 1. The css library was built for node.js which does not have tree-shaking supports.\n * 2. Rewrites into typescript give us a better type interface.\n */\n\n/* tslint:disable no-conditional-assignment interface-name no-shadowed-variable */\n\nexport interface ParserOptions {\n /** Silently fail on parse errors */\n silent?: boolean;\n /**\n * The path to the file containing css.\n * Makes errors and source maps more helpful, by letting them know where code comes from.\n */\n source?: string;\n}\n\n/**\n * Error thrown during parsing.\n */\nexport interface ParserError {\n /** The full error message with the source position. */\n message?: string;\n /** The error message without position. */\n reason?: string;\n /** The value of options.source if passed to css.parse. Otherwise undefined. */\n filename?: string;\n line?: number;\n column?: number;\n /** The portion of code that couldn't be parsed. */\n source?: string;\n}\n\nexport interface Loc {\n line?: number;\n column?: number;\n}\n\n/**\n * Base AST Tree Node.\n */\nexport interface Node {\n /** The possible values are the ones listed in the Types section on https://github.com/reworkcss/css page. */\n type?: string;\n /** A reference to the parent node, or null if the node has no parent. */\n parent?: Node;\n /** Information about the position in the source string that corresponds to the node. */\n position?: {\n start?: Loc;\n end?: Loc;\n /** The value of options.source if passed to css.parse. Otherwise undefined. */\n source?: string;\n /** The full source string passed to css.parse. */\n content?: string;\n };\n}\n\nexport interface Rule extends Node {\n /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n selectors?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\nexport interface Declaration extends Node {\n /** The property name, trimmed from whitespace and comments. May not be empty. */\n property?: string;\n /** The value of the property, trimmed from whitespace and comments. Empty values are allowed. */\n value?: string;\n}\n\n/**\n * A rule-level or declaration-level comment. Comments inside selectors, properties and values etc. are lost.\n */\nexport interface Comment extends Node {\n comment?: string;\n}\n\n/**\n * The @charset at-rule.\n */\nexport interface Charset extends Node {\n /** The part following @charset. */\n charset?: string;\n}\n\n/**\n * The @custom-media at-rule\n */\nexport interface CustomMedia extends Node {\n /** The ---prefixed name. */\n name?: string;\n /** The part following the name. */\n media?: string;\n}\n\n/**\n * The @document at-rule.\n */\nexport interface Document extends Node {\n /** The part following @document. */\n document?: string;\n /** The vendor prefix in @document, or undefined if there is none. */\n vendor?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @font-face at-rule.\n */\nexport interface FontFace extends Node {\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @host at-rule.\n */\nexport interface Host extends Node {\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @import at-rule.\n */\nexport interface Import extends Node {\n /** The part following @import. */\n import?: string;\n}\n\n/**\n * The @keyframes at-rule.\n */\nexport interface KeyFrames extends Node {\n /** The name of the keyframes rule. */\n name?: string;\n /** The vendor prefix in @keyframes, or undefined if there is none. */\n vendor?: string;\n /** Array of nodes with the types keyframe and comment. */\n keyframes?: Array;\n}\n\nexport interface KeyFrame extends Node {\n /** The list of \"selectors\" of the keyframe rule, split on commas. Each “selector” is trimmed from whitespace. */\n values?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @media at-rule.\n */\nexport interface Media extends Node {\n /** The part following @media. */\n media?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/**\n * The @namespace at-rule.\n */\nexport interface Namespace extends Node {\n /** The part following @namespace. */\n namespace?: string;\n}\n\n/**\n * The @page at-rule.\n */\nexport interface Page extends Node {\n /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n selectors?: string[];\n /** Array of nodes with the types declaration and comment. */\n declarations?: Array;\n}\n\n/**\n * The @supports at-rule.\n */\nexport interface Supports extends Node {\n /** The part following @supports. */\n supports?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules?: Array;\n}\n\n/** All at-rules. */\nexport type AtRule =\n | Charset\n | CustomMedia\n | Document\n | FontFace\n | Host\n | Import\n | KeyFrames\n | Media\n | Namespace\n | Page\n | Supports;\n\n/**\n * A collection of rules\n */\nexport interface StyleRules {\n source?: string;\n /** Array of nodes with the types rule, comment and any of the at-rule types. */\n rules: Array;\n /** Array of Errors. Errors collected during parsing when option silent is true. */\n parsingErrors?: ParserError[];\n}\n\n/**\n * The root node returned by css.parse.\n */\nexport interface Stylesheet extends Node {\n stylesheet?: StyleRules;\n}\n\n// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nconst commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nexport function parse(css: string, options: ParserOptions = {}) {\n /**\n * Positional.\n */\n\n let lineno = 1;\n let column = 1;\n\n /**\n * Update lineno and column based on `str`.\n */\n\n function updatePosition(str: string) {\n const lines = str.match(/\\n/g);\n if (lines) {\n lineno += lines.length;\n }\n let i = str.lastIndexOf('\\n');\n column = i === -1 ? column + str.length : str.length - i;\n }\n\n /**\n * Mark position and patch `node.position`.\n */\n\n function position() {\n const start = { line: lineno, column };\n return (\n node: Rule | Declaration | Comment | AtRule | Stylesheet | KeyFrame,\n ) => {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node\n */\n\n class Position {\n public content!: string;\n public start!: Loc;\n public end!: Loc;\n public source?: string;\n\n constructor(start: Loc) {\n this.start = start;\n this.end = { line: lineno, column };\n this.source = options.source;\n }\n }\n\n /**\n * Non-enumerable source string\n */\n\n Position.prototype.content = css;\n\n const errorsList: ParserError[] = [];\n\n function error(msg: string) {\n const err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg,\n ) as ParserError;\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = css;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Parse stylesheet.\n */\n\n function stylesheet(): Stylesheet {\n const rulesList = rules();\n\n return {\n type: 'stylesheet',\n stylesheet: {\n source: options.source,\n rules: rulesList,\n parsingErrors: errorsList,\n },\n };\n }\n\n /**\n * Opening brace.\n */\n\n function open() {\n return match(/^{\\s*/);\n }\n\n /**\n * Closing brace.\n */\n\n function close() {\n return match(/^}/);\n }\n\n /**\n * Parse ruleset.\n */\n\n function rules() {\n let node: Rule | void;\n const rules: Rule[] = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node !== false) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n\n /**\n * Match `re` and return captures.\n */\n\n function match(re: RegExp) {\n const m = re.exec(css);\n if (!m) {\n return;\n }\n const str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n\n function whitespace() {\n match(/^\\s*/);\n }\n\n /**\n * Parse comments;\n */\n\n function comments(rules: Rule[] = []) {\n let c: Comment | void;\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n c = comment();\n }\n return rules;\n }\n\n /**\n * Parse comment.\n */\n\n function comment() {\n const pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n\n let i = 2;\n while (\n '' !== css.charAt(i) &&\n ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if ('' === css.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n const str = css.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n css = css.slice(i);\n column += 2;\n\n return pos({\n type: 'comment',\n comment: str,\n });\n }\n\n /**\n * Parse selector.\n */\n\n function selector() {\n const m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n /* @fix Remove all comments from selectors\n * http://ostermiller.org/findcomment.html */\n return trim(m[0])\n .replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g, '')\n .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, (m) => {\n return m.replace(/,/g, '\\u200C');\n })\n .split(/\\s*(?![^(]*\\)),\\s*/)\n .map((s) => {\n return s.replace(/\\u200C/g, ',');\n });\n }\n\n /**\n * Parse declaration.\n */\n\n function declaration(): Declaration | void | never {\n const pos = position();\n\n // prop\n let propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n const prop = trim(propMatch[0]);\n\n // :\n if (!match(/^:\\s*/)) {\n return error(`property missing ':'`);\n }\n\n // val\n const val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n\n const ret = pos({\n type: 'declaration',\n property: prop.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : '',\n });\n\n // ;\n match(/^[;\\s]*/);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n */\n\n function declarations() {\n const decls: Array = [];\n\n if (!open()) {\n return error(`missing '{'`);\n }\n comments(decls);\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n if ((decl as unknown) !== false) {\n decls.push(decl);\n comments(decls);\n }\n decl = declaration();\n }\n\n if (!close()) {\n return error(`missing '}'`);\n }\n return decls;\n }\n\n /**\n * Parse keyframe.\n */\n\n function keyframe() {\n let m;\n const vals = [];\n const pos = position();\n\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n\n if (!vals.length) {\n return;\n }\n\n return pos({\n type: 'keyframe',\n values: vals,\n declarations: declarations() as Declaration[],\n });\n }\n\n /**\n * Parse keyframes.\n */\n\n function atkeyframes() {\n const pos = position();\n let m = match(/^@([-\\w]+)?keyframes\\s*/);\n\n if (!m) {\n return;\n }\n const vendor = m[1];\n\n // identifier\n m = match(/^([-\\w]+)\\s*/);\n if (!m) {\n return error('@keyframes missing name');\n }\n const name = m[1];\n\n if (!open()) {\n return error(`@keyframes missing '{'`);\n }\n\n let frame;\n let frames = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n\n if (!close()) {\n return error(`@keyframes missing '}'`);\n }\n\n return pos({\n type: 'keyframes',\n name,\n vendor,\n keyframes: frames,\n });\n }\n\n /**\n * Parse supports.\n */\n\n function atsupports() {\n const pos = position();\n const m = match(/^@supports *([^{]+)/);\n\n if (!m) {\n return;\n }\n const supports = trim(m[1]);\n\n if (!open()) {\n return error(`@supports missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@supports missing '}'`);\n }\n\n return pos({\n type: 'supports',\n supports,\n rules: style,\n });\n }\n\n /**\n * Parse host.\n */\n\n function athost() {\n const pos = position();\n const m = match(/^@host\\s*/);\n\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(`@host missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@host missing '}'`);\n }\n\n return pos({\n type: 'host',\n rules: style,\n });\n }\n\n /**\n * Parse media.\n */\n\n function atmedia() {\n const pos = position();\n const m = match(/^@media *([^{]+)/);\n\n if (!m) {\n return;\n }\n const media = trim(m[1]);\n\n if (!open()) {\n return error(`@media missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@media missing '}'`);\n }\n\n return pos({\n type: 'media',\n media,\n rules: style,\n });\n }\n\n /**\n * Parse custom-media.\n */\n\n function atcustommedia() {\n const pos = position();\n const m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n\n return pos({\n type: 'custom-media',\n name: trim(m[1]),\n media: trim(m[2]),\n });\n }\n\n /**\n * Parse paged media.\n */\n\n function atpage() {\n const pos = position();\n const m = match(/^@page */);\n if (!m) {\n return;\n }\n\n const sel = selector() || [];\n\n if (!open()) {\n return error(`@page missing '{'`);\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(`@page missing '}'`);\n }\n\n return pos({\n type: 'page',\n selectors: sel,\n declarations: decls,\n });\n }\n\n /**\n * Parse document.\n */\n\n function atdocument() {\n const pos = position();\n const m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n\n const vendor = trim(m[1]);\n const doc = trim(m[2]);\n\n if (!open()) {\n return error(`@document missing '{'`);\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(`@document missing '}'`);\n }\n\n return pos({\n type: 'document',\n document: doc,\n vendor,\n rules: style,\n });\n }\n\n /**\n * Parse font-face.\n */\n\n function atfontface() {\n const pos = position();\n const m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(`@font-face missing '{'`);\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(`@font-face missing '}'`);\n }\n\n return pos({\n type: 'font-face',\n declarations: decls,\n });\n }\n\n /**\n * Parse import\n */\n\n const atimport = _compileAtrule('import');\n\n /**\n * Parse charset\n */\n\n const atcharset = _compileAtrule('charset');\n\n /**\n * Parse namespace\n */\n\n const atnamespace = _compileAtrule('namespace');\n\n /**\n * Parse non-block at-rules\n */\n\n function _compileAtrule(name: string) {\n const re = new RegExp('^@' + name + '\\\\s*([^;]+);');\n return () => {\n const pos = position();\n const m = match(re);\n if (!m) {\n return;\n }\n const ret: Record = { type: name };\n ret[name] = m[1].trim();\n return pos(ret);\n };\n }\n\n /**\n * Parse at rule.\n */\n\n function atrule() {\n if (css[0] !== '@') {\n return;\n }\n\n return (\n atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface()\n );\n }\n\n /**\n * Parse rule.\n */\n\n function rule() {\n const pos = position();\n const sel = selector();\n\n if (!sel) {\n return error('selector missing');\n }\n comments();\n\n return pos({\n type: 'rule',\n selectors: sel,\n declarations: declarations() as Declaration[],\n });\n }\n\n return addParent(stylesheet());\n}\n\n/**\n * Trim `str`.\n */\n\nfunction trim(str: string) {\n return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\n\n/**\n * Adds non-enumerable parent node reference to each node.\n */\n\nfunction addParent(obj: Stylesheet, parent?: Stylesheet) {\n const isNode = obj && typeof obj.type === 'string';\n const childParent = isNode ? obj : parent;\n\n for (const k of Object.keys(obj)) {\n const value = obj[k as keyof Stylesheet];\n if (Array.isArray(value)) {\n value.forEach((v) => {\n addParent(v, childParent);\n });\n } else if (value && typeof value === 'object') {\n addParent((value as unknown) as Stylesheet, childParent);\n }\n }\n\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null,\n });\n }\n\n return obj;\n}\n","import { parse } from './css';\nimport {\n serializedNodeWithId,\n NodeType,\n tagMap,\n elementNode,\n idNodeMap,\n INode,\n BuildCache,\n} from './types';\nimport { isElement } from './utils';\n\nconst tagMap: tagMap = {\n script: 'noscript',\n // camel case svg element tag names\n altglyph: 'altGlyph',\n altglyphdef: 'altGlyphDef',\n altglyphitem: 'altGlyphItem',\n animatecolor: 'animateColor',\n animatemotion: 'animateMotion',\n animatetransform: 'animateTransform',\n clippath: 'clipPath',\n feblend: 'feBlend',\n fecolormatrix: 'feColorMatrix',\n fecomponenttransfer: 'feComponentTransfer',\n fecomposite: 'feComposite',\n feconvolvematrix: 'feConvolveMatrix',\n fediffuselighting: 'feDiffuseLighting',\n fedisplacementmap: 'feDisplacementMap',\n fedistantlight: 'feDistantLight',\n fedropshadow: 'feDropShadow',\n feflood: 'feFlood',\n fefunca: 'feFuncA',\n fefuncb: 'feFuncB',\n fefuncg: 'feFuncG',\n fefuncr: 'feFuncR',\n fegaussianblur: 'feGaussianBlur',\n feimage: 'feImage',\n femerge: 'feMerge',\n femergenode: 'feMergeNode',\n femorphology: 'feMorphology',\n feoffset: 'feOffset',\n fepointlight: 'fePointLight',\n fespecularlighting: 'feSpecularLighting',\n fespotlight: 'feSpotLight',\n fetile: 'feTile',\n feturbulence: 'feTurbulence',\n foreignobject: 'foreignObject',\n glyphref: 'glyphRef',\n lineargradient: 'linearGradient',\n radialgradient: 'radialGradient',\n};\nfunction getTagName(n: elementNode): string {\n let tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n if (tagName === 'link' && n.attributes._cssText) {\n tagName = 'style';\n }\n return tagName;\n}\n\n// based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nfunction escapeRegExp(str: string) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nconst HOVER_SELECTOR = /([^\\\\]):hover/;\nconst HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nexport function addHoverClass(cssText: string, cache: BuildCache): string {\n const cachedStyle = cache?.stylesWithHoverClass.get(cssText);\n if (cachedStyle) return cachedStyle;\n\n const ast = parse(cssText, {\n silent: true,\n });\n\n if (!ast.stylesheet) {\n return cssText;\n }\n\n const selectors: string[] = [];\n ast.stylesheet.rules.forEach((rule) => {\n if ('selectors' in rule) {\n (rule.selectors || []).forEach((selector: string) => {\n if (HOVER_SELECTOR.test(selector)) {\n selectors.push(selector);\n }\n });\n }\n });\n\n if (selectors.length === 0) {\n return cssText;\n }\n\n const selectorMatcher = new RegExp(\n selectors\n .filter((selector, index) => selectors.indexOf(selector) === index)\n .sort((a, b) => b.length - a.length)\n .map((selector) => {\n return escapeRegExp(selector);\n })\n .join('|'),\n 'g',\n );\n\n const result = cssText.replace(selectorMatcher, (selector) => {\n const newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n return `${selector}, ${newSelector}`;\n });\n cache?.stylesWithHoverClass.set(cssText, result);\n return result;\n}\n\nexport function createCache(): BuildCache {\n const stylesWithHoverClass: Map = new Map();\n return {\n stylesWithHoverClass,\n };\n}\n\nfunction buildNode(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n hackCss: boolean;\n cache: BuildCache;\n },\n): Node | null {\n const { doc, hackCss, cache } = options;\n switch (n.type) {\n case NodeType.Document:\n return doc.implementation.createDocument(null, '', null);\n case NodeType.DocumentType:\n return doc.implementation.createDocumentType(\n n.name || 'html',\n n.publicId,\n n.systemId,\n );\n case NodeType.Element:\n const tagName = getTagName(n);\n let node: Element;\n if (n.isSVG) {\n node = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n } else {\n node = doc.createElement(tagName);\n }\n for (const name in n.attributes) {\n if (!n.attributes.hasOwnProperty(name)) {\n continue;\n }\n let value = n.attributes[name];\n if (tagName === 'option' && name === 'selected' && value === false) {\n // legacy fix (TODO: if `value === false` can be generated for other attrs, should we also omit those other attrs from build?)\n continue;\n }\n value =\n typeof value === 'boolean' || typeof value === 'number' ? '' : value;\n // attribute names start with rr_ are internal attributes added by rrweb\n if (!name.startsWith('rr_')) {\n const isTextarea = tagName === 'textarea' && name === 'value';\n const isRemoteOrDynamicCss =\n tagName === 'style' && name === '_cssText';\n if (isRemoteOrDynamicCss && hackCss) {\n value = addHoverClass(value, cache);\n }\n if (isTextarea || isRemoteOrDynamicCss) {\n const child = doc.createTextNode(value);\n // https://github.com/rrweb-io/rrweb/issues/112\n for (const c of Array.from(node.childNodes)) {\n if (c.nodeType === node.TEXT_NODE) {\n node.removeChild(c);\n }\n }\n node.appendChild(child);\n continue;\n }\n\n try {\n if (n.isSVG && name === 'xlink:href') {\n node.setAttributeNS('http://www.w3.org/1999/xlink', name, value);\n } else if (\n name === 'onload' ||\n name === 'onclick' ||\n name.substring(0, 7) === 'onmouse'\n ) {\n // Rename some of the more common atttributes from https://www.w3schools.com/tags/ref_eventattributes.asp\n // as setting them triggers a console.error (which shows up despite the try/catch)\n // Assumption: these attributes are not used to css\n node.setAttribute('_' + name, value);\n } else if (\n tagName === 'meta' &&\n n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n name === 'content'\n ) {\n // If CSP contains style-src and inline-style is disabled, there will be an error \"Refused to apply inline style because it violates the following Content Security Policy directive: style-src '*'\".\n // And the function insertStyleRules in rrweb replayer will throw an error \"Uncaught TypeError: Cannot read property 'insertRule' of null\".\n node.setAttribute('csp-content', value);\n continue;\n } else if (\n tagName === 'link' &&\n n.attributes.rel === 'preload' &&\n n.attributes.as === 'script'\n ) {\n // ignore\n } else if (\n tagName === 'link' &&\n n.attributes.rel === 'prefetch' &&\n typeof n.attributes.href === 'string' &&\n n.attributes.href.endsWith('.js')\n ) {\n // ignore\n } else if (\n tagName === 'img' &&\n n.attributes.srcset &&\n n.attributes.rr_dataURL\n ) {\n // backup original img srcset\n node.setAttribute('rrweb-original-srcset', n.attributes.srcset as string);\n } else {\n node.setAttribute(name, value);\n }\n } catch (error) {\n // skip invalid attribute\n }\n } else {\n // handle internal attributes\n if (tagName === 'canvas' && name === 'rr_dataURL') {\n const image = document.createElement('img');\n image.src = value;\n image.onload = () => {\n const ctx = (node as HTMLCanvasElement).getContext('2d');\n if (ctx) {\n ctx.drawImage(image, 0, 0, image.width, image.height);\n }\n };\n } else if (tagName === 'img' && name === 'rr_dataURL') {\n const image = node as HTMLImageElement;\n if (!image.currentSrc.startsWith('data:')) {\n // Backup original img src. It may not have been set yet.\n image.setAttribute(\n 'rrweb-original-src',\n n.attributes.src as string,\n );\n image.src = value;\n }\n }\n\n if (name === 'rr_width') {\n (node as HTMLElement).style.width = value;\n } else if (name === 'rr_height') {\n (node as HTMLElement).style.height = value;\n } else if (name === 'rr_mediaCurrentTime') {\n (node as HTMLMediaElement).currentTime = n.attributes\n .rr_mediaCurrentTime as number;\n } else if (name === 'rr_mediaState') {\n switch (value) {\n case 'played':\n (node as HTMLMediaElement)\n .play()\n .catch((e) => console.warn('media playback error', e));\n break;\n case 'paused':\n (node as HTMLMediaElement).pause();\n break;\n default:\n }\n }\n }\n }\n\n if (n.isShadowHost) {\n /**\n * Since node is newly rebuilt, it should be a normal element\n * without shadowRoot.\n * But if there are some weird situations that has defined\n * custom element in the scope before we rebuild node, it may\n * register the shadowRoot earlier.\n * The logic in the 'else' block is just a try-my-best solution\n * for the corner case, please let we know if it is wrong and\n * we can remove it.\n */\n if (!node.shadowRoot) {\n node.attachShadow({ mode: 'open' });\n } else {\n while (node.shadowRoot.firstChild) {\n node.shadowRoot.removeChild(node.shadowRoot.firstChild);\n }\n }\n }\n return node;\n case NodeType.Text:\n return doc.createTextNode(\n n.isStyle && hackCss\n ? addHoverClass(n.textContent, cache)\n : n.textContent,\n );\n case NodeType.CDATA:\n return doc.createCDATASection(n.textContent);\n case NodeType.Comment:\n return doc.createComment(n.textContent);\n default:\n return null;\n }\n}\n\nexport function buildNodeWithSN(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n map: idNodeMap;\n skipChild?: boolean;\n hackCss: boolean;\n afterAppend?: (n: INode) => unknown;\n cache: BuildCache;\n },\n): INode | null {\n const {\n doc,\n map,\n skipChild = false,\n hackCss = true,\n afterAppend,\n cache,\n } = options;\n let node = buildNode(n, { doc, hackCss, cache });\n if (!node) {\n return null;\n }\n if (n.rootId) {\n console.assert(\n ((map[n.rootId] as unknown) as Document) === doc,\n 'Target document should has the same root id.',\n );\n }\n // use target document as root document\n if (n.type === NodeType.Document) {\n // close before open to make sure document was closed\n doc.close();\n doc.open();\n if (\n n.compatMode === 'BackCompat' &&\n n.childNodes &&\n n.childNodes[0].type !== NodeType.DocumentType // there isn't one already defined\n ) {\n // Trigger compatMode in the iframe\n // this is needed as document.createElement('iframe') otherwise inherits a CSS1Compat mode from the parent replayer environment\n if (\n n.childNodes[0].type === NodeType.Element &&\n 'xmlns' in n.childNodes[0].attributes &&\n n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml'\n ) {\n // might as well use an xhtml doctype if we've got an xhtml namespace\n doc.write(\n '',\n );\n } else {\n doc.write(\n '',\n );\n }\n }\n node = doc;\n }\n\n (node as INode).__sn = n;\n map[n.id] = node as INode;\n\n if (\n (n.type === NodeType.Document || n.type === NodeType.Element) &&\n !skipChild\n ) {\n for (const childN of n.childNodes) {\n const childNode = buildNodeWithSN(childN, {\n doc,\n map,\n skipChild: false,\n hackCss,\n afterAppend,\n cache,\n });\n if (!childNode) {\n console.warn('Failed to rebuild', childN);\n continue;\n }\n\n if (childN.isShadow && isElement(node) && node.shadowRoot) {\n node.shadowRoot.appendChild(childNode);\n } else {\n node.appendChild(childNode);\n }\n if (afterAppend) {\n afterAppend(childNode);\n }\n }\n }\n\n return node as INode;\n}\n\nfunction visit(idNodeMap: idNodeMap, onVisit: (node: INode) => void) {\n function walk(node: INode) {\n onVisit(node);\n }\n\n for (const key in idNodeMap) {\n if (idNodeMap[key]) {\n walk(idNodeMap[key]);\n }\n }\n}\n\nfunction handleScroll(node: INode) {\n const n = node.__sn;\n if (n.type !== NodeType.Element) {\n return;\n }\n const el = (node as Node) as HTMLElement;\n for (const name in n.attributes) {\n if (!(n.attributes.hasOwnProperty(name) && name.startsWith('rr_'))) {\n continue;\n }\n const value = n.attributes[name];\n if (name === 'rr_scrollLeft') {\n el.scrollLeft = value as number;\n }\n if (name === 'rr_scrollTop') {\n el.scrollTop = value as number;\n }\n }\n}\n\nfunction rebuild(\n n: serializedNodeWithId,\n options: {\n doc: Document;\n onVisit?: (node: INode) => unknown;\n hackCss?: boolean;\n afterAppend?: (n: INode) => unknown;\n cache: BuildCache;\n },\n): [Node | null, idNodeMap] {\n const { doc, onVisit, hackCss = true, afterAppend, cache } = options;\n const idNodeMap: idNodeMap = {};\n const node = buildNodeWithSN(n, {\n doc,\n map: idNodeMap,\n skipChild: false,\n hackCss,\n afterAppend,\n cache,\n });\n visit(idNodeMap, (visitedNode) => {\n if (onVisit) {\n onVisit(visitedNode);\n }\n handleScroll(visitedNode);\n });\n return [node, idNodeMap];\n}\n\nexport default rebuild;\n"],"names":["NodeType","isElement","n","nodeType","ELEMENT_NODE","isShadowRoot","host","Boolean","shadowRoot","maskInputValue","_a","input","maskInputSelector","unmaskInputSelector","maskInputOptions","tagName","type","value","maskInputFn","text","matches","toLowerCase","repeat","length","is2DCanvasBlank","canvas","ctx","getContext","x","width","y","height","getImageData","originalGetImageData","Uint32Array","call","Math","min","data","buffer","some","pixel","canvasService","canvasCtx","_id","tagNameRegex","RegExp","IGNORED_NODE","getCssRulesString","s","rules","cssRules","Array","from","map","getCssRuleString","join","error","rule","cssStringified","cssText","isCSSImportRule","styleSheet","URL_IN_CSS_REF","RELATIVE_PATH","DATA_URI","absoluteToStylesheet","href","replace","origin","quote1","path1","quote2","path2","path3","url","filePath","maybeQuote","test","indexOf","split","slice","stack","parts","pop","parts_1","_i","part","push","SRCSET_NOT_SPACES","SRCSET_COMMAS_OR_SPACES","absoluteToDoc","doc","attributeValue","trim","a","createElement","getHref","document","transformAttribute","name","pos","collectCharacters","regEx","chars","match","exec","substring","output","descriptorsStr","inParens","c","charAt","getAbsoluteSrcsetString","needMaskingText","node","maskTextClass","maskTextSelector","unmaskTextSelector","closest","classList","contains","eIndex","className","parentNode","TEXT_NODE","serializeNode","options","rootId","sheet","el","blockClass","blockSelector","unblockSelector","inlineStylesheet","_b","maskTextFn","_c","dataURLOptions","inlineImages","recordCanvas","keepIframeSrcFn","__sn","docId","id","undefined","DOCUMENT_NODE","compatMode","Document","childNodes","DOCUMENT_TYPE_NODE","DocumentType","publicId","systemId","needBlock","element","_isBlockedElement","HTMLFormElement","processedTagName","getValidTagName","attributes_1","_d","attributes","_e","name_1","stylesheet","styleSheets","find","rel","_cssText","innerText","textContent","checked","selected","__context","rr_dataURL","toDataURL","quality","canvasDataURL","blankCanvas","image_1","oldValue_1","crossOrigin","recordInlineImage","naturalWidth","naturalHeight","drawImage","err","console","warn","currentSrc","complete","onload","rr_mediaState","paused","rr_mediaCurrentTime","currentTime","scrollLeft","rr_scrollLeft","scrollTop","rr_scrollTop","_f","getBoundingClientRect","class","rr_width","rr_height","src","contentDocument","rr_src","Element","isSVG","ownerSVGElement","parentTagName","isStyle","isScript","nextSibling","previousSibling","Text","CDATA_SECTION_NODE","CDATA","COMMENT_NODE","Comment","lowerIfExists","maybeAttr","serializeNodeWithId","skipChild","slimDOMOptions","onSerialize","onIframeLoad","_g","iframeLoadTimeout","_h","_j","preserveWhiteSpace","_serializedNode","sn","comment","script","as","endsWith","headFavicon","headMetaDescKeywords","headMetaSocial","property","headMetaRobots","headMetaHttpEquiv","headMetaAuthorship","headMetaVerification","slimDOMExcluded","serializedNode","Object","assign","recordChild","isShadowHost","headWhitespace","bypassOptions","_k","serializedChildNode","_m","_l","isShadow","iframeEl","listener","win","contentWindow","readyState","fired","blankUrl","location","addEventListener","setTimeout","timer_1","clearTimeout","onceIframeLoaded","iframeDoc","serializedIframeNode","snapshot","_o","maskAllInputs","_p","slimDOM","_q","idNodeMap","color","date","email","month","number","range","search","tel","time","week","textarea","select","password","visitSnapshot","onVisit","walk","current","forEach","cleanupSnapshot","commentre","parse","css","lineno","column","updatePosition","str","lines","i","lastIndexOf","position","start","line","Position","whitespace","this","end","source","prototype","content","errorsList","msg","Error","reason","filename","silent","open","close","comments","atrule","re","m","selector","declaration","propMatch","prop","val","ret","declarations","decl","decls","keyframe","vals","values","rulesList","atimport","_compileAtrule","atcharset","atnamespace","vendor","frame","frames","concat","keyframes","atkeyframes","media","style","atmedia","atcustommedia","supports","atsupports","atdocument","sel","selectors","atpage","athost","atfontface","addParent","parsingErrors","obj","parent","isNode","childParent","keys","isArray","v","defineProperty","configurable","writable","enumerable","tagMap","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","clippath","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","foreignobject","glyphref","lineargradient","radialgradient","HOVER_SELECTOR","HOVER_SELECTOR_GLOBAL","addHoverClass","cache","cachedStyle","stylesWithHoverClass","get","ast","selectorMatcher","filter","index","sort","b","result","newSelector","set","createCache","Map","buildNode","hackCss","implementation","createDocument","createDocumentType","node_1","getTagName","createElementNS","hasOwnProperty","startsWith","image","setAttribute","play","e","pause","isTextarea","isRemoteOrDynamicCss","child","createTextNode","removeChild","appendChild","setAttributeNS","srcset","firstChild","attachShadow","mode","createCDATASection","createComment","buildNodeWithSN","afterAppend","assert","xmlns","write","childN","childNode","rebuild","key","visit","visitedNode","name_2","handleScroll"],"mappings":"IAAYA,WCEIC,EAAUC,GACxB,OAAOA,EAAEC,WAAaD,EAAEE,sBAGVC,EAAaH,SACrBI,YAAwBJ,wBAAkBI,KAChD,OAAOC,QAAQD,GAAQA,EAAKE,YAAcF,EAAKE,aAAeN,YAGhDO,EAAeC,OAC7BC,UACAC,sBACAC,wBACAC,qBACAC,YACAC,SACAC,UACAC,gBAWIC,EAAOF,GAAS,GAEpB,OAAIJ,GAAuBF,EAAMS,QAAQP,KAKvCC,EAAiBC,EAAQM,gBACzBP,EAAiBE,IAChBJ,GAAqBD,EAAMS,QAAQR,MAGlCO,EADED,EACKA,EAAYC,GAEZ,IAAIG,OAAOH,EAAKI,SAXlBJ,GDjCX,SAAYnB,GACVA,2BACAA,mCACAA,yBACAA,mBACAA,qBACAA,yBANF,CAAYA,IAAAA,gBCuDIwB,EAAgBC,GAC9B,IAAMC,EAAMD,EAAOE,WAAW,MAC9B,IAAKD,EAAK,OAAO,EAKjB,IAHA,IAGSE,EAAI,EAAGA,EAAIH,EAAOI,MAAOD,GAHhB,GAIhB,IAAK,IAAIE,EAAI,EAAGA,EAAIL,EAAOM,OAAQD,GAJnB,GAImC,CACjD,IAAME,EAAeN,EAAIM,aACnBC,EAfoB,uBAgBGD,EACvBA,EAAoC,mBACpCA,EAcN,GAToB,IAAIE,YACtBD,EAAqBE,KACnBT,EACAE,EACAE,EACAM,KAAKC,IAnBK,GAmBUZ,EAAOI,MAAQD,GACnCQ,KAAK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,EAAU+L,GALjBhL,EAAQtL,IADV,IAAcA,EAmDduW,CAAMhM,GAAW,SAACiM,GACZlL,GACFA,EAAQkL,GA1Cd,SAAsBxW,GACpB,IAAMjH,EAAIiH,EAAK2B,KACf,GAAI5I,EAAEc,OAAShB,EAASiN,QAAxB,CAGA,IAAM/E,EAAMf,EACZ,IAAK,IAAMyW,KAAQ1d,EAAEgK,WACnB,GAAMhK,EAAEgK,WAAW2R,eAAe+B,IAASA,EAAK9B,WAAW,OAA3D,CAGA,IAAM7a,EAAQf,EAAEgK,WAAW0T,GACd,kBAATA,IACF1V,EAAGmE,WAAapL,GAEL,iBAAT2c,IACF1V,EAAGqE,UAAYtL,KA6BjB4c,CAAaF,MAER,CAACxW,EAAMuK"} +\ No newline at end of file +diff --git a/node_modules/rrweb-snapshot/lib/rrweb-snapshot.js b/node_modules/rrweb-snapshot/lib/rrweb-snapshot.js +old mode 100644 +new mode 100755 +index 3040b7d..8ce75cf +--- a/node_modules/rrweb-snapshot/lib/rrweb-snapshot.js ++++ b/node_modules/rrweb-snapshot/lib/rrweb-snapshot.js +@@ -21,10 +21,14 @@ function isShadowRoot(n) { + return Boolean(host && host.shadowRoot && host.shadowRoot === n); + } + function maskInputValue(_a) { +- var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; ++ var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; + var text = value || ''; ++ if (unmaskInputSelector && input.matches(unmaskInputSelector)) { ++ return text; ++ } + if (maskInputOptions[tagName.toLowerCase()] || +- maskInputOptions[type]) { ++ maskInputOptions[type] || ++ (maskInputSelector && input.matches(maskInputSelector))) { + if (maskInputFn) { + text = maskInputFn(text); + } +@@ -251,7 +255,10 @@ function transformAttribute(doc, tagName, name, value) { + return value; + } + } +-function _isBlockedElement(element, blockClass, blockSelector) { ++function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) { ++ if (unblockSelector && element.matches(unblockSelector)) { ++ return false; ++ } + if (typeof blockClass === 'string') { + if (element.classList.contains(blockClass)) { + return true; +@@ -270,11 +277,16 @@ function _isBlockedElement(element, blockClass, blockSelector) { + } + return false; + } +-function needMaskingText(node, maskTextClass, maskTextSelector) { ++function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) { + if (!node) { + return false; + } + if (node.nodeType === node.ELEMENT_NODE) { ++ if (unmaskTextSelector) { ++ if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) { ++ return false; ++ } ++ } + if (typeof maskTextClass === 'string') { + if (node.classList.contains(maskTextClass)) { + return true; +@@ -293,12 +305,12 @@ function needMaskingText(node, maskTextClass, maskTextSelector) { + return true; + } + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + if (node.nodeType === node.TEXT_NODE) { +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } +- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); ++ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector); + } + function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + var win = iframeEl.contentWindow; +@@ -338,7 +350,7 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { + } + function serializeNode(n, options) { + var _a; +- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; ++ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; + var rootId; + if (doc.__sn) { + var docId = doc.__sn.id; +@@ -370,7 +382,7 @@ function serializeNode(n, options) { + rootId: rootId + }; + case n.ELEMENT_NODE: +- var needBlock = _isBlockedElement(n, blockClass, blockSelector); ++ var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector); + var tagName = getValidTagName(n); + var attributes_1 = {}; + for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { +@@ -411,9 +423,12 @@ function serializeNode(n, options) { + attributes_1.type !== 'button' && + value) { + attributes_1.value = maskInputValue({ ++ input: n, + type: attributes_1.type, + tagName: tagName, + value: value, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskInputFn: maskInputFn + }); +@@ -532,7 +547,7 @@ function serializeNode(n, options) { + } + if (!isStyle && + !isScript && +- needMaskingText(n, maskTextClass, maskTextSelector) && ++ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) && + textContent) { + textContent = maskTextFn + ? maskTextFn(textContent) +@@ -640,15 +655,19 @@ function slimDOMExcluded(sn, slimDOMOptions) { + return false; + } + function serializeNodeWithId(n, options) { +- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; ++ var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; + var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; + var _serializedNode = serializeNode(n, { + doc: doc, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -704,10 +723,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: skipChild, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -752,10 +775,14 @@ function serializeNodeWithId(n, options) { + map: map, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +@@ -778,7 +805,7 @@ function serializeNodeWithId(n, options) { + return serializedNode; + } + function snapshot(n, options) { +- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; ++ var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q; + var idNodeMap = {}; + var maskInputOptions = maskAllInputs === true + ? { +@@ -827,10 +854,14 @@ function snapshot(n, options) { + map: idNodeMap, + blockClass: blockClass, + blockSelector: blockSelector, ++ unblockSelector: unblockSelector, + maskTextClass: maskTextClass, + maskTextSelector: maskTextSelector, ++ unmaskTextSelector: unmaskTextSelector, + skipChild: false, + inlineStylesheet: inlineStylesheet, ++ maskInputSelector: maskInputSelector, ++ unmaskInputSelector: unmaskInputSelector, + maskInputOptions: maskInputOptions, + maskTextFn: maskTextFn, + maskInputFn: maskInputFn, +diff --git a/node_modules/rrweb-snapshot/typings/snapshot.d.ts b/node_modules/rrweb-snapshot/typings/snapshot.d.ts +index b970f75..a49fa7d 100644 +--- a/node_modules/rrweb-snapshot/typings/snapshot.d.ts ++++ b/node_modules/rrweb-snapshot/typings/snapshot.d.ts +@@ -3,17 +3,21 @@ export declare const IGNORED_NODE = -2; + export declare function absoluteToStylesheet(cssText: string | null, href: string): string; + export declare function absoluteToDoc(doc: Document, attributeValue: string): string; + export declare function transformAttribute(doc: Document, tagName: string, name: string, value: string): string; +-export declare function _isBlockedElement(element: HTMLElement, blockClass: string | RegExp, blockSelector: string | null): boolean; +-export declare function needMaskingText(node: Node | null, maskTextClass: string | RegExp, maskTextSelector: string | null): boolean; ++export declare function _isBlockedElement(element: HTMLElement, blockClass: string | RegExp, blockSelector: string | null, unblockSelector: string | null): boolean; ++export declare function needMaskingText(node: Node | null, maskTextClass: string | RegExp, maskTextSelector: string | null, unmaskTextSelector: string | null): boolean; + export declare function serializeNodeWithId(n: Node | INode, options: { + doc: Document; + map: idNodeMap; + blockClass: string | RegExp; + blockSelector: string | null; ++ unblockSelector: string | null; + maskTextClass: string | RegExp; + maskTextSelector: string | null; ++ unmaskTextSelector: string | null; + skipChild: boolean; + inlineStylesheet: boolean; ++ maskInputSelector: string | null; ++ unmaskInputSelector: string | null; + maskInputOptions?: MaskInputOptions; + maskTextFn: MaskTextFn | undefined; + maskInputFn: MaskInputFn | undefined; +@@ -30,8 +34,12 @@ export declare function serializeNodeWithId(n: Node | INode, options: { + declare function snapshot(n: Document, options?: { + blockClass?: string | RegExp; + blockSelector?: string | null; ++ unblockSelector?: string | null; + maskTextClass?: string | RegExp; + maskTextSelector?: string | null; ++ unmaskTextSelector?: string | null; ++ maskInputSelector?: string | null; ++ unmaskInputSelector?: string | null; + inlineStylesheet?: boolean; + maskAllInputs?: boolean | MaskInputOptions; + maskTextFn?: MaskTextFn; +diff --git a/node_modules/rrweb-snapshot/typings/utils.d.ts b/node_modules/rrweb-snapshot/typings/utils.d.ts +index 6572ab8..708fb96 100644 +--- a/node_modules/rrweb-snapshot/typings/utils.d.ts ++++ b/node_modules/rrweb-snapshot/typings/utils.d.ts +@@ -1,7 +1,10 @@ + import { INode, MaskInputFn, MaskInputOptions } from './types'; + export declare function isElement(n: Node | INode): n is Element; + export declare function isShadowRoot(n: Node): n is ShadowRoot; +-export declare function maskInputValue({ maskInputOptions, tagName, type, value, maskInputFn, }: { ++export declare function maskInputValue({ input, maskInputSelector, unmaskInputSelector, maskInputOptions, tagName, type, value, maskInputFn, }: { ++ input: HTMLElement; ++ maskInputSelector: string | null; ++ unmaskInputSelector: string | null; + maskInputOptions: MaskInputOptions; + tagName: string; + type: string | number | boolean | null;