SKYLINK WEB SDK 2.1.5
+SKYLINK WEB SDK 2.2.0
@@ -114,7 +114,7 @@Temasys SkylinkJS Web SDK is an open-source client-side library for your web-browser that enables any website to easily leverage the capabilities of WebRTC and its direct data streaming powers between peers for audio/video conferencing or file transfer.
Supported Browsers
Current versions and stability
- We recommend that you always use the latest versions of the Temasys SkylinkJS Web SDK as WebRTC is still evolving and we adapt to changes very frequently.
How to build your own Temasys SkylinkJS Web SDK
Using Git command line tools, execute the following:
# 1. Clone or download this repository via git terminal.
diff --git a/docs/index.js.html b/docs/index.js.html
index af2d3d1c0..5a3cd6085 100644
--- a/docs/index.js.html
+++ b/docs/index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/logger_index.js.html b/docs/logger_index.js.html
index 5c79c7951..b36f02672 100644
--- a/docs/logger_index.js.html
+++ b/docs/logger_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/media-stream_helpers_getStreamSources.js.html b/docs/media-stream_helpers_getStreamSources.js.html
index 61fec62bd..81e8e67cf 100644
--- a/docs/media-stream_helpers_getStreamSources.js.html
+++ b/docs/media-stream_helpers_getStreamSources.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/media-stream_helpers_getStreams.js.html b/docs/media-stream_helpers_getStreams.js.html
index d92070a94..43e91784f 100644
--- a/docs/media-stream_helpers_getStreams.js.html
+++ b/docs/media-stream_helpers_getStreams.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/media-stream_helpers_muteStreams.js.html b/docs/media-stream_helpers_muteStreams.js.html
index 7de92454d..0ac514825 100644
--- a/docs/media-stream_helpers_muteStreams.js.html
+++ b/docs/media-stream_helpers_muteStreams.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/media-stream_helpers_onStreamAccessError.js.html b/docs/media-stream_helpers_onStreamAccessError.js.html
index bdcc62b3f..7776fc4c2 100644
--- a/docs/media-stream_helpers_onStreamAccessError.js.html
+++ b/docs/media-stream_helpers_onStreamAccessError.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/media-stream_helpers_prepMediaAccessRequest.js.html b/docs/media-stream_helpers_prepMediaAccessRequest.js.html
index ab823cb7c..2994af176 100644
--- a/docs/media-stream_helpers_prepMediaAccessRequest.js.html
+++ b/docs/media-stream_helpers_prepMediaAccessRequest.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/media-stream_helpers_sendStream.js.html b/docs/media-stream_helpers_sendStream.js.html
index 7f79490c9..ae20f7fd2 100644
--- a/docs/media-stream_helpers_sendStream.js.html
+++ b/docs/media-stream_helpers_sendStream.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -168,7 +168,7 @@
return Promise.all(usePrefetchedStreamsPromises)
.then((results) => {
- restartFn(roomState, results, true, resolve, reject);
+ restartFn(roomState, results, resolve, reject);
})
.catch((error) => {
reject(error);
diff --git a/docs/media-stream_helpers_stopStream_dispatchEvents.js.html b/docs/media-stream_helpers_stopStream_dispatchEvents.js.html
index c19e06fcb..fe899e1d8 100644
--- a/docs/media-stream_helpers_stopStream_dispatchEvents.js.html
+++ b/docs/media-stream_helpers_stopStream_dispatchEvents.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/media-stream_helpers_stopStream_removeTracks.js.html b/docs/media-stream_helpers_stopStream_removeTracks.js.html
index 1d90eab38..fca21f80f 100644
--- a/docs/media-stream_helpers_stopStream_removeTracks.js.html
+++ b/docs/media-stream_helpers_stopStream_removeTracks.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/media-stream_index.js.html b/docs/media-stream_index.js.html
index b5a3eef68..d22cc229a 100644
--- a/docs/media-stream_index.js.html
+++ b/docs/media-stream_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -98,7 +98,7 @@
import stopStreamHelpers from './helpers/stopStream/index';
import logger from '../logger';
import MESSAGES from '../messages';
-import { isAObj } from '../utils/helpers';
+import { isAObj, isEmptyArray } from '../utils/helpers';
import { TAGS, TRACK_KIND } from '../constants';
/**
@@ -224,20 +224,58 @@
return helpers.getStreams(roomState, includeSelf);
}
- static usePrefetchedStream(roomKey, stream, options = null) {
+ static usePrefetchedStream(roomKey, prefetchedStream) {
return new Promise((resolve) => {
- if (!stream && (options.id && options.active)) {
- // eslint-disable-next-line no-param-reassign
- stream = options;
- }
-
- const streamOptions = { audio: stream.getAudioTracks().length !== 0, video: stream.getVideoTracks().length !== 0 };
+ const streamOptions = { audio: prefetchedStream.getAudioTracks().length !== 0, video: prefetchedStream.getVideoTracks().length !== 0 };
const audioSettings = helpers.parseStreamSettings(streamOptions, TRACK_KIND.AUDIO);
const videoSettings = helpers.parseStreamSettings(streamOptions, TRACK_KIND.VIDEO);
const isAudioFallback = false;
- const streams = helpers.onStreamAccessSuccess(roomKey, stream, audioSettings, videoSettings, isAudioFallback, false, true);
+ const stream = helpers.onStreamAccessSuccess(roomKey, prefetchedStream, audioSettings, videoSettings, isAudioFallback, false, true);
+
+ resolve(stream);
+ });
+ }
+
+ static processPrefetchedStreams(roomKey, prefetchedStreams, options = null) {
+ return new Promise((resolve, reject) => {
+ const streams = [];
+ if (prefetchedStreams && options.id) {
+ reject(MESSAGES.MEDIA_STREAM.ERRORS.INVALID_PREFETCHED_STREAMS);
+ return;
+ }
+
+ if (!prefetchedStreams) {
+ if (options.id && options.active) { // mediaStream as first argument
+ streams.push(options);
+ } else if (Array.isArray(options)) { // array of mediaStreams as first argument
+ options.forEach((mediaStream) => {
+ if (mediaStream && mediaStream.id && mediaStream.active) {
+ streams.push(mediaStream);
+ }
+ });
+ }
+ } else if (Array.isArray(prefetchedStreams)) { // array of mediaStreams as prefetchedStreams param
+ prefetchedStreams.forEach((mediaStream) => {
+ if (mediaStream && mediaStream.id && mediaStream.active) {
+ streams.push(mediaStream);
+ }
+ });
+ } else {
+ streams.push(prefetchedStreams); // mediaStream as prefetchedStreams param
+ }
+
+ if (isEmptyArray(streams)) {
+ reject(MESSAGES.MEDIA_STREAM.ERRORS.INVALID_PREFETCHED_STREAMS);
+ return;
+ }
+
+ const usePrefetchedStreamPromises = [];
+ streams.forEach((stream) => {
+ usePrefetchedStreamPromises.push(MediaStream.usePrefetchedStream(roomKey, stream));
+ });
- resolve(streams);
+ Promise.all(usePrefetchedStreamPromises)
+ .then(result => resolve(result));
});
}
diff --git a/docs/models_api-response.js.html b/docs/models_api-response.js.html
index 98fc90c1c..2cbe585ae 100644
--- a/docs/models_api-response.js.html
+++ b/docs/models_api-response.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/models_skylink-room.js.html b/docs/models_skylink-room.js.html
index 638d2e131..4b6c8284f 100644
--- a/docs/models_skylink-room.js.html
+++ b/docs/models_skylink-room.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/models_skylink-user.js.html b/docs/models_skylink-user.js.html
index aaaa72c8d..567bf15ce 100644
--- a/docs/models_skylink-user.js.html
+++ b/docs/models_skylink-user.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_createAnswer.js.html b/docs/peer-connection_helpers_createAnswer.js.html
index e15e0c88a..add257285 100644
--- a/docs/peer-connection_helpers_createAnswer.js.html
+++ b/docs/peer-connection_helpers_createAnswer.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_createOffer.js.html b/docs/peer-connection_helpers_createOffer.js.html
index 56b582ffc..be5787b93 100644
--- a/docs/peer-connection_helpers_createOffer.js.html
+++ b/docs/peer-connection_helpers_createOffer.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_callbacks_onbufferedamountlow.js.html b/docs/peer-connection_helpers_data-channel_callbacks_onbufferedamountlow.js.html
index 50bc7a976..5ea7029d6 100644
--- a/docs/peer-connection_helpers_data-channel_callbacks_onbufferedamountlow.js.html
+++ b/docs/peer-connection_helpers_data-channel_callbacks_onbufferedamountlow.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_callbacks_onclose.js.html b/docs/peer-connection_helpers_data-channel_callbacks_onclose.js.html
index 80779da29..3c1823732 100644
--- a/docs/peer-connection_helpers_data-channel_callbacks_onclose.js.html
+++ b/docs/peer-connection_helpers_data-channel_callbacks_onclose.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_callbacks_onerror.js.html b/docs/peer-connection_helpers_data-channel_callbacks_onerror.js.html
index efd734e8d..4baf25be8 100644
--- a/docs/peer-connection_helpers_data-channel_callbacks_onerror.js.html
+++ b/docs/peer-connection_helpers_data-channel_callbacks_onerror.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_callbacks_onmessage.js.html b/docs/peer-connection_helpers_data-channel_callbacks_onmessage.js.html
index 82e60b82f..940c90463 100644
--- a/docs/peer-connection_helpers_data-channel_callbacks_onmessage.js.html
+++ b/docs/peer-connection_helpers_data-channel_callbacks_onmessage.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_callbacks_onopen.js.html b/docs/peer-connection_helpers_data-channel_callbacks_onopen.js.html
index b2d6f805f..64d6adb7d 100644
--- a/docs/peer-connection_helpers_data-channel_callbacks_onopen.js.html
+++ b/docs/peer-connection_helpers_data-channel_callbacks_onopen.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_closeDataChannel.js.html b/docs/peer-connection_helpers_data-channel_closeDataChannel.js.html
index 7d7bfb5a7..5f34da758 100644
--- a/docs/peer-connection_helpers_data-channel_closeDataChannel.js.html
+++ b/docs/peer-connection_helpers_data-channel_closeDataChannel.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_createDataChannel.js.html b/docs/peer-connection_helpers_data-channel_createDataChannel.js.html
index 1b82a32cf..7e7a318e4 100644
--- a/docs/peer-connection_helpers_data-channel_createDataChannel.js.html
+++ b/docs/peer-connection_helpers_data-channel_createDataChannel.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_getDataChannelBuffer.js.html b/docs/peer-connection_helpers_data-channel_getDataChannelBuffer.js.html
index fefcad3b8..7d8fb7c90 100644
--- a/docs/peer-connection_helpers_data-channel_getDataChannelBuffer.js.html
+++ b/docs/peer-connection_helpers_data-channel_getDataChannelBuffer.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_refreshDataChannel.js.html b/docs/peer-connection_helpers_data-channel_refreshDataChannel.js.html
index c7ca71ce4..005f8793f 100644
--- a/docs/peer-connection_helpers_data-channel_refreshDataChannel.js.html
+++ b/docs/peer-connection_helpers_data-channel_refreshDataChannel.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_data-channel_sendP2PMessage.js.html b/docs/peer-connection_helpers_data-channel_sendP2PMessage.js.html
index 71679f3b5..c9e1dbb04 100644
--- a/docs/peer-connection_helpers_data-channel_sendP2PMessage.js.html
+++ b/docs/peer-connection_helpers_data-channel_sendP2PMessage.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_peer-addition_addPeer.js.html b/docs/peer-connection_helpers_peer-addition_addPeer.js.html
index d9312cd9a..34959fb63 100644
--- a/docs/peer-connection_helpers_peer-addition_addPeer.js.html
+++ b/docs/peer-connection_helpers_peer-addition_addPeer.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_peer-addition_callbacks_ondatachannel.js.html b/docs/peer-connection_helpers_peer-addition_callbacks_ondatachannel.js.html
index 4c90595ea..03a50f059 100644
--- a/docs/peer-connection_helpers_peer-addition_callbacks_ondatachannel.js.html
+++ b/docs/peer-connection_helpers_peer-addition_callbacks_ondatachannel.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_peer-addition_callbacks_onicecandidate.js.html b/docs/peer-connection_helpers_peer-addition_callbacks_onicecandidate.js.html
index cbe8eeff9..ecb7c76a1 100644
--- a/docs/peer-connection_helpers_peer-addition_callbacks_onicecandidate.js.html
+++ b/docs/peer-connection_helpers_peer-addition_callbacks_onicecandidate.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_peer-addition_callbacks_oniceconnectionstatechange.js.html b/docs/peer-connection_helpers_peer-addition_callbacks_oniceconnectionstatechange.js.html
index b3b2b48f9..0b1b02872 100644
--- a/docs/peer-connection_helpers_peer-addition_callbacks_oniceconnectionstatechange.js.html
+++ b/docs/peer-connection_helpers_peer-addition_callbacks_oniceconnectionstatechange.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -123,6 +123,7 @@
const { ICE_CONNECTION_STATE, PEER_CONNECTION_STATE, BROWSER_AGENT } = constants;
const state = Skylink.getSkylinkState(currentRoomState.room.id);
const { peerStreams, user, enableStatsGathering } = state;
+ const initOptions = Skylink.getInitOptions();
let statsInterval = null;
const pcIceConnectionState = peerConnection.iceConnectionState;
@@ -165,6 +166,7 @@
statsInterval = setInterval(() => {
const currentState = Skylink.getSkylinkState(state.room.id);
if (!currentState || !currentState.room.inRoom) {
+ clearInterval(statsInterval);
return;
}
if (peerConnection.connectionState === PEER_CONNECTION_STATE.CLOSED || peerConnection.iceConnectionState === ICE_CONNECTION_STATE.CLOSED) {
@@ -190,7 +192,7 @@
} else {
new HandleBandwidthStats().send(state.room.id, peerConnection, targetMid);
}
- }, 20000);
+ }, initOptions.statsInterval * 1000);
});
}
diff --git a/docs/peer-connection_helpers_peer-addition_callbacks_onicegatheringstatechange.js.html b/docs/peer-connection_helpers_peer-addition_callbacks_onicegatheringstatechange.js.html
index d854ef7f1..2d734d1f9 100644
--- a/docs/peer-connection_helpers_peer-addition_callbacks_onicegatheringstatechange.js.html
+++ b/docs/peer-connection_helpers_peer-addition_callbacks_onicegatheringstatechange.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_peer-addition_callbacks_onremovetrack.js.html b/docs/peer-connection_helpers_peer-addition_callbacks_onremovetrack.js.html
index c26eb4f67..a1e90239a 100644
--- a/docs/peer-connection_helpers_peer-addition_callbacks_onremovetrack.js.html
+++ b/docs/peer-connection_helpers_peer-addition_callbacks_onremovetrack.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -112,10 +112,11 @@
}));
};
-const updateMediaStatus = (state, peerId, streamId) => {
+const updatePeerStreamsAndMediaStatus = (state, peerId, streamId) => {
const updatedState = state;
delete updatedState.peerInformations[peerId].mediaStatus[streamId];
+ PeerStream.deleteStream(peerId, updatedState.room, streamId);
Skylink.setSkylinkState(updatedState, updatedState.room.id);
};
@@ -163,7 +164,7 @@
return;
}
- updateMediaStatus(state, peerId, stream.id);
+ updatePeerStreamsAndMediaStatus(state, peerId, stream.id);
dispatchStreamEndedEvent(state, peerId, isScreensharing, rtcTrackEvent, stream);
dispatchPeerUpdated(state, peerId);
};
diff --git a/docs/peer-connection_helpers_peer-addition_callbacks_onsenderadded.js.html b/docs/peer-connection_helpers_peer-addition_callbacks_onsenderadded.js.html
index 3c1db44a7..ed66ebad0 100644
--- a/docs/peer-connection_helpers_peer-addition_callbacks_onsenderadded.js.html
+++ b/docs/peer-connection_helpers_peer-addition_callbacks_onsenderadded.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_peer-addition_callbacks_onsignalingstatechange.js.html b/docs/peer-connection_helpers_peer-addition_callbacks_onsignalingstatechange.js.html
index 3df542f24..4799dac4c 100644
--- a/docs/peer-connection_helpers_peer-addition_callbacks_onsignalingstatechange.js.html
+++ b/docs/peer-connection_helpers_peer-addition_callbacks_onsignalingstatechange.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_peer-addition_callbacks_ontrack.js.html b/docs/peer-connection_helpers_peer-addition_callbacks_ontrack.js.html
index d6014b564..bc7e09aee 100644
--- a/docs/peer-connection_helpers_peer-addition_callbacks_ontrack.js.html
+++ b/docs/peer-connection_helpers_peer-addition_callbacks_ontrack.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -101,6 +101,7 @@
import PeerMedia from '../../../../peer-media';
import PeerConnection from '../../../index';
import PeerStream from '../../../../peer-stream';
+import HandleUserMediaStats from '../../../../skylink-stats/handleUserMediaStats';
const matchPeerIdWithTransceiverMid = (state, transceiver) => {
const { peerMedias, user } = state;
@@ -159,6 +160,7 @@
PeerMedia.updateStreamIdFromOntrack(state.room, peerId, transceiver.mid, stream.id);
PeerConnection.updatePeerInformationsMediaStatus(state.room, peerId, transceiver, stream);
PeerStream.addStream(peerId, stream, room.id);
+ new HandleUserMediaStats().send(room.id);
MediaStream.onRemoteTrackAdded(stream, currentRoomState, peerId, isScreensharing, track.kind === TRACK_KIND.VIDEO, track.kind === TRACK_KIND.AUDIO);
return null;
diff --git a/docs/peer-connection_helpers_peer-addition_createPeerConnection.js.html b/docs/peer-connection_helpers_peer-addition_createPeerConnection.js.html
index 0ca8567ea..9bae18956 100644
--- a/docs/peer-connection_helpers_peer-addition_createPeerConnection.js.html
+++ b/docs/peer-connection_helpers_peer-addition_createPeerConnection.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_refresh-connection_refreshConnection.js.html b/docs/peer-connection_helpers_refresh-connection_refreshConnection.js.html
index ba2a144f9..812d35eed 100644
--- a/docs/peer-connection_helpers_refresh-connection_refreshConnection.js.html
+++ b/docs/peer-connection_helpers_refresh-connection_refreshConnection.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_refresh-connection_refreshPeerConnection.js.html b/docs/peer-connection_helpers_refresh-connection_refreshPeerConnection.js.html
index 776d5743a..8f0638181 100644
--- a/docs/peer-connection_helpers_refresh-connection_refreshPeerConnection.js.html
+++ b/docs/peer-connection_helpers_refresh-connection_refreshPeerConnection.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_refresh-connection_restartMCUConnection.js.html b/docs/peer-connection_helpers_refresh-connection_restartMCUConnection.js.html
index bc57d6745..539c1dc2b 100644
--- a/docs/peer-connection_helpers_refresh-connection_restartMCUConnection.js.html
+++ b/docs/peer-connection_helpers_refresh-connection_restartMCUConnection.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_refresh-connection_restartPeerConnection.js.html b/docs/peer-connection_helpers_refresh-connection_restartPeerConnection.js.html
index fa71df5cf..193099887 100644
--- a/docs/peer-connection_helpers_refresh-connection_restartPeerConnection.js.html
+++ b/docs/peer-connection_helpers_refresh-connection_restartPeerConnection.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_signalingEndOfCandidates.js.html b/docs/peer-connection_helpers_signalingEndOfCandidates.js.html
index 0581fac0a..83fa18ad6 100644
--- a/docs/peer-connection_helpers_signalingEndOfCandidates.js.html
+++ b/docs/peer-connection_helpers_signalingEndOfCandidates.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_statistics_index.js.html b/docs/peer-connection_helpers_statistics_index.js.html
index b3352e577..b0d298cfe 100644
--- a/docs/peer-connection_helpers_statistics_index.js.html
+++ b/docs/peer-connection_helpers_statistics_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_statistics_parsers_parseAudio.js.html b/docs/peer-connection_helpers_statistics_parsers_parseAudio.js.html
index adac555a3..98d42b345 100644
--- a/docs/peer-connection_helpers_statistics_parsers_parseAudio.js.html
+++ b/docs/peer-connection_helpers_statistics_parsers_parseAudio.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -175,17 +175,24 @@
const parseReceiving = (output, value, prevStats) => {
const parsedStats = output.audio.receiving;
- const packetsReceived = parseInt(value.packetsReceived || '0', 10);
- parsedStats.totalPackets = packetsReceived;
- parsedStats.packets = parsers.tabulateStats(prevStats, value, 'packetsReceived');
+ parsedStats.bytes = parsedStats.bytes || 0;
+ if (value.bytesReceived) {
+ const bytesReceived = parseInt(value.bytesReceived || '0', 10);
+ parsedStats.totalBytes = bytesReceived;
+ parsedStats.bytes += parsers.tabulateStats(prevStats, value, 'bytesReceived');
+ }
- const bytesReceived = parseInt(value.bytesReceived || '0', 10);
- parsedStats.totalBytes = bytesReceived;
- parsedStats.bytes = parsers.tabulateStats(prevStats, value, 'bytesReceived');
+ if (value.packetsReceived) {
+ const packetsReceived = parseInt(value.packetsReceived || '0', 10);
+ parsedStats.totalPackets = packetsReceived;
+ parsedStats.packets = parsers.tabulateStats(prevStats, value, 'packetsReceived');
+ }
- const packetsLost = parseInt(value.packetsLost || '0', 10);
- parsedStats.totalPacketsLost = packetsLost;
- parsedStats.packetsLost = parsers.tabulateStats(prevStats, value, 'packetsLost');
+ if (Number.isInteger(value.packetsLost)) {
+ const packetsLost = parseInt(value.packetsLost || '0', 10);
+ parsedStats.totalPacketsLost = packetsLost;
+ parsedStats.packetsLost = parsers.tabulateStats(prevStats, value, 'packetsLost');
+ }
parsedStats.jitter = parseInt(value.jitter || '0', 10);
parsedStats.ssrc = value.ssrc;
@@ -194,7 +201,7 @@
const audioReceiver = output.raw[trackId];
if (audioReceiver) {
- parsedStats.audioLevel = parseFloat(audioReceiver.audioLevel).toFixed(5);
+ parsedStats.audioLevel = audioReceiver.audioLevel ? parseFloat(audioReceiver.audioLevel).toFixed(5) : '0';
parsedStats.totalSamplesReceived = parseInt(audioReceiver.totalSamplesReceived || '0', 10);
parsedStats.totalSamplesDuration = parseInt(audioReceiver.totalSamplesDuration || '0', 10);
@@ -213,10 +220,12 @@
const parseSending = (output, value, prevStats) => {
const parsedStats = output.audio.sending;
+ parsedStats.bytes = parsedStats.bytes || 0;
if (value.bytesSent) {
+ parsedStats.bytes = parsedStats.bytes ? parsedStats.bytes : 0;
const bytesSent = parseInt(value.bytesSent || '0', 10);
parsedStats.totalBytes = bytesSent;
- parsedStats.bytes = parsers.tabulateStats(prevStats, value, 'bytesSent');
+ parsedStats.bytes += parsers.tabulateStats(prevStats, value, 'bytesSent');
}
if (value.packetsSent) {
@@ -260,7 +269,7 @@
const audioSource = output.raw[mediaSourceId];
if (audioSource) {
- parsedStats.audioLevel = parseFloat(audioSource.audioLevel).toFixed(5);
+ parsedStats.audioLevel = audioSource.audioLevel ? parseFloat(audioSource.audioLevel).toFixed(5) : '0';
parsedStats.totalSamplesDuration = parseInt(audioSource.totalSamplesDuration || '0', 10);
}
};
diff --git a/docs/peer-connection_helpers_statistics_parsers_parseCertificates.js.html b/docs/peer-connection_helpers_statistics_parsers_parseCertificates.js.html
index 972db8cfc..43a2638c0 100644
--- a/docs/peer-connection_helpers_statistics_parsers_parseCertificates.js.html
+++ b/docs/peer-connection_helpers_statistics_parsers_parseCertificates.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_statistics_parsers_parseSelectedCandidatePair.js.html b/docs/peer-connection_helpers_statistics_parsers_parseSelectedCandidatePair.js.html
index 0687e2ce3..3ab74bdd1 100644
--- a/docs/peer-connection_helpers_statistics_parsers_parseSelectedCandidatePair.js.html
+++ b/docs/peer-connection_helpers_statistics_parsers_parseSelectedCandidatePair.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-connection_helpers_statistics_parsers_parseVideo.js.html b/docs/peer-connection_helpers_statistics_parsers_parseVideo.js.html
index 0308e4fc1..9c387f0a4 100644
--- a/docs/peer-connection_helpers_statistics_parsers_parseVideo.js.html
+++ b/docs/peer-connection_helpers_statistics_parsers_parseVideo.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -207,10 +207,11 @@
const parseReceiving = (output, value, prevStats) => {
const parsedStats = output.video.receiving;
+ parsedStats.bytes = parsedStats.bytes || 0;
if (value.bytesReceived) {
const bytesReceived = parseInt(value.bytesReceived || '0', 10);
parsedStats.totalBytes = bytesReceived;
- parsedStats.bytes = parsers.tabulateStats(prevStats, value, 'bytesReceived');
+ parsedStats.bytes += parsers.tabulateStats(prevStats, value, 'bytesReceived');
}
if (value.packetsReceived) {
@@ -262,10 +263,11 @@
const parseSending = (output, value, prevStats) => {
const parsedStats = output.video.sending;
+ parsedStats.bytes = parsedStats.bytes || 0;
if (value.bytesSent) {
const bytesSent = parseInt(value.bytesSent || '0', 10);
parsedStats.totalBytes = bytesSent;
- parsedStats.bytes = parsers.tabulateStats(prevStats, value, 'bytesSent');
+ parsedStats.bytes += parsers.tabulateStats(prevStats, value, 'bytesSent');
}
if (value.packetsSent) {
diff --git a/docs/peer-connection_helpers_statistics_parsers_tabulateStats.js.html b/docs/peer-connection_helpers_statistics_parsers_tabulateStats.js.html
index 51cd65f83..8aa138cf0 100644
--- a/docs/peer-connection_helpers_statistics_parsers_tabulateStats.js.html
+++ b/docs/peer-connection_helpers_statistics_parsers_tabulateStats.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -104,9 +104,13 @@
*/
const tabulateStats = (prevStats = null, stats, prop) => {
const nTime = stats.timestamp;
- const oTime = prevStats ? prevStats.timestamp || 0 : 0;
+ const oTime = prevStats ? prevStats.timestamp || (new Date(stats.timestamp).getTime() - 20000) : (new Date(stats.timestamp).getTime() - 20000);
const nVal = parseFloat(stats[prop] || '0', 10);
- const oVal = parseFloat(prevStats ? prevStats[prop] || '0' : '0', 10);
+ let oVal = parseFloat(prevStats ? prevStats[prop] || '0' : '0', 10);
+
+ if (nVal < oVal) {
+ oVal = 0;
+ }
if ((new Date(nTime).getTime()) === (new Date(oTime).getTime())) {
return nVal;
diff --git a/docs/peer-connection_index.js.html b/docs/peer-connection_index.js.html
index 72f0eacbd..c7f79915e 100644
--- a/docs/peer-connection_index.js.html
+++ b/docs/peer-connection_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-data_helpers_getPeersCustomSettings.js.html b/docs/peer-data_helpers_getPeersCustomSettings.js.html
index 7d99aad63..b87c12830 100644
--- a/docs/peer-data_helpers_getPeersCustomSettings.js.html
+++ b/docs/peer-data_helpers_getPeersCustomSettings.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-data_index.js.html b/docs/peer-data_index.js.html
index 25a87dd83..5885c4c4a 100644
--- a/docs/peer-data_index.js.html
+++ b/docs/peer-data_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-media_index.js.html b/docs/peer-media_index.js.html
index b45265069..7fca7318a 100644
--- a/docs/peer-media_index.js.html
+++ b/docs/peer-media_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/peer-privileged_index.js.html b/docs/peer-privileged_index.js.html
index fd460e8e2..d6e46bfc1 100644
--- a/docs/peer-privileged_index.js.html
+++ b/docs/peer-privileged_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/public_index.js.html b/docs/public_index.js.html
index 22225ae37..b83d3b619 100644
--- a/docs/public_index.js.html
+++ b/docs/public_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -99,6 +99,7 @@
} from '../utils/helpers';
import { dispatchEvent } from '../utils/skylinkEventManager';
import { streamEnded } from '../skylink-events';
+import { SDK_VERSION } from '../constants';
import PeerConnection from '../peer-connection/index';
import PeerData from '../peer-data/index';
import PeerPrivileged from '../peer-privileged/index';
@@ -153,9 +154,16 @@
* Example 2: Retrieving a pre-fetched stream before calling joinRoom
*
* // REF: {@link Skylink#getUserMedia|getUserMedia}
- * const prefetchedStream = skylink.getUserMedia();
+ * const prefetchedStreams = skylink.getUserMedia();
*
- * skylink.joinRoom(prefetchedStream)
+ * const joinRoomOptions = {
+ * roomName: "Room_1",
+ * userData: {
+ * username: "GuestUser_1"
+ * },
+ * };
+ *
+ * skylink.joinRoom(joinRoomOptions, prefetchedStreams)
* .catch((error) => {
* // handle error
* });
@@ -774,33 +782,6 @@
* video: true,
* }).then((streams) => // do something)
* .catch((error) => // handle error);
- * @example
- * Example 6: Get media sources before joinRoom - only available on Chrome browsers
- *
- * const audioInputDevices = [];
- * const videoInputDevices = [];
- *
- * navigator.mediaDevices.enumerateDevices().then((devices) => {
- * devices.forEach((device) => {
- * if (device.kind === "audioinput") {
- * audioInputDevices.push(device);
- * }
- *
- * if (device.kind === "videoinput") {
- * videoInputDevices.push(device);
- * }
- * })
- * }).catch((error) => // handle error);
- *
- * skylink.getUserMedia(roomName, {
- * audio: {
- * deviceId: audioInputDevices[0].deviceId,
- * },
- * video: {
- * deviceId: videoInputDevices[0].deviceId,
- * }
- * }).then((streams) => // do something)
- * .catch((error) => // handle error);
* @fires <b>If retrieval of fallback audio stream is successful:</b> <br/> - {@link SkylinkEvents.event:MEDIA_ACCESS_SUCCESS|MEDIA ACCESS SUCCESS} event with parameter payload <code>isScreensharing=false</code> and <code>isAudioFallback=false</code> if initial retrieval is successful.
* @fires <b>If initial retrieval is unsuccessful:</b> <br/> Fallback to retrieve audio only stream is triggered (configured in {@link initOptions} <code>audioFallback</code>) <br/>  - {@link SkylinkEvents.event:MEDIA_ACCESS_SUCCESS|MEDIA ACCESS SUCCESS} event{@link SkylinkEvents.event:MEDIA_ACCESS_FALLBACK|MEDIA ACCESS FALLBACK} event with parameter payload <code>state=FALLBACKING</code>, <code>isScreensharing=false</code> and <code>isAudioFallback=true</code> and <code>options.video=true</code> and <code>options.audio=true</code>. <br/> No fallback to retrieve audio only stream <br/> - {@link SkylinkEvents.event:MEDIA_ACCESS_ERROR|MEDIA ACCESS ERROR} event with parameter payload <code>isScreensharing=false</code> and <code>isAudioFallbackError=false</code>.
* @fires <b>If retrieval of fallback audio stream is successful:</b> <br/> - {@link SkylinkEvents.event:MEDIA_ACCESS_SUCCESS|MEDIA ACCESS SUCCESS} event with parameter payload <code>isScreensharing=false</code> and <code>isAudioFallback=true</code>.
@@ -1247,6 +1228,26 @@
* @description Method that returns the camera and microphone sources.
* @return {Promise.<streamSources>} outputSources
* @alias Skylink#getStreamSources
+ * @example
+ * Example 1: Get media sources before joinRoom - only available on Chrome browsers
+ *
+ * const audioInputDevices = [];
+ * const videoInputDevices = [];
+ *
+ * skylink.getStreamSources.then((sources) => {
+ * audioInputDevices = sources.audio.input;
+ * videoInputDevices = sources.video.input;
+ * }).catch((error) => // handle error);
+ *
+ * skylink.getUserMedia(roomName, {
+ * audio: {
+ * deviceId: audioInputDevices[0].deviceId,
+ * },
+ * video: {
+ * deviceId: videoInputDevices[0].deviceId,
+ * }
+ * }).then((streams) => // do something)
+ * .catch((error) => // handle error);
*/
getStreamSources() {
return MediaStream.getStreamSources();
@@ -1254,10 +1255,12 @@
/**
* @description Method that sends a new <code>userMedia</code> stream to all connected peers in a room.
- * <p>Resolves with an array of <code>MediaStreams</code>. First item in array is <code>MediaStream</code> of kind audio and second item is
- * <code>MediaStream</code> of kind video.</p>
+ * <p>If options are passed as argument into the method, it resolves with an array of <code>MediaStreams</code>. First item in array is
+ * <code>MediaStream</code> of kind audio and second item is <code>MediaStream</code> of kind video. Otherwise it resolves with the array or
+ * <code>MediaStream</code></p>
* @param {String} roomName - The room name.
- * @param {JSON|MediaStream} options - The {@link Skylink#getUserMedia|getUserMedia} <code>options</code> parameter settings. The MediaStream to send to the remote peer.
+ * @param {JSON|MediaStream|Array.<MediaStream>} options - The {@link Skylink#getUserMedia|getUserMedia} <code>options</code> parameter
+ * settings. The MediaStream to send to the remote peer or array of MediaStreams.
* - When provided as a <code>MediaStream</code> object, this configures the <code>options.audio</code> and
* <code>options.video</code> based on the tracks available in the <code>MediaStream</code> object.
* Object signature matches the <code>options</code> parameter in the
@@ -1458,6 +1461,15 @@
const asyncMessaging = new AsyncMessaging(roomState);
return asyncMessaging.getMessagePersistence();
}
+
+ /**
+ * @description Method that retrieves the sdk version.
+ * @alias Skylink#getSdkVersion
+ * @since 2.1.6
+ */
+ getSdkVersion() {
+ return SDK_VERSION;
+ }
}
export default SkylinkPublicInterface;
diff --git a/docs/room_getRoomInfo.js.html b/docs/room_getRoomInfo.js.html
index 4e04e7bef..2fc121cfe 100644
--- a/docs/room_getRoomInfo.js.html
+++ b/docs/room_getRoomInfo.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_api-server_defaultOptions.js.html b/docs/server-communication_api-server_defaultOptions.js.html
index 640f97be2..8501d53b2 100644
--- a/docs/server-communication_api-server_defaultOptions.js.html
+++ b/docs/server-communication_api-server_defaultOptions.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -117,7 +117,7 @@
* /solutions/articles/12000002811-using-the-persistent-room-feature-to-configure-meetings">Persistent Room article here
* </a> for more information.</small>
*/
- defaultRoom: new Date().valueOf(),
+ defaultRoom: null,
appKey: null,
roomServer: '//api.temasys.io',
enableDataChannel: true,
@@ -169,6 +169,7 @@
},
beSilentOnStatsLogs: false,
beSilentOnParseLogs: false,
+ statsInterval: 20, // sec
};
/**
diff --git a/docs/server-communication_signaling-server_index.js.html b/docs/server-communication_signaling-server_index.js.html
index e6e09e6e0..19ff1a55f 100644
--- a/docs/server-communication_signaling-server_index.js.html
+++ b/docs/server-communication_signaling-server_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -206,15 +206,19 @@
}
tryCreateSocket(roomKey, resolve, reject) {
- const roomState = Skylink.getSkylinkState(roomKey);
- const { socketSession } = roomState;
+ try {
+ const roomState = Skylink.getSkylinkState(roomKey);
+ const { socketSession } = roomState;
- this.socket = createSocket({
- config: socketSession,
- roomKey,
- });
+ this.socket = createSocket({
+ config: socketSession,
+ roomKey,
+ });
- setSocketCallbacks(roomKey, this, resolve, reject);
+ setSocketCallbacks(roomKey, this, resolve);
+ } catch (error) {
+ reject(error);
+ }
}
// eslint-disable-next-line class-methods-use-this
diff --git a/docs/server-communication_signaling-server_message-builder_builders_getPeerListMessage.js.html b/docs/server-communication_signaling-server_message-builder_builders_getPeerListMessage.js.html
index 68e6efa33..49f01a55c 100644
--- a/docs/server-communication_signaling-server_message-builder_builders_getPeerListMessage.js.html
+++ b/docs/server-communication_signaling-server_message-builder_builders_getPeerListMessage.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-builder_builders_setUserDataMessage.js.html b/docs/server-communication_signaling-server_message-builder_builders_setUserDataMessage.js.html
index 9d70e5289..a66f67699 100644
--- a/docs/server-communication_signaling-server_message-builder_builders_setUserDataMessage.js.html
+++ b/docs/server-communication_signaling-server_message-builder_builders_setUserDataMessage.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-builder_builders_streamMessage.js.html b/docs/server-communication_signaling-server_message-builder_builders_streamMessage.js.html
index 2355d4a46..1c409d8a9 100644
--- a/docs/server-communication_signaling-server_message-builder_builders_streamMessage.js.html
+++ b/docs/server-communication_signaling-server_message-builder_builders_streamMessage.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-handler_handlers_candidateHandler.js.html b/docs/server-communication_signaling-server_message-handler_handlers_candidateHandler.js.html
index 1b6cf533c..ced65e214 100644
--- a/docs/server-communication_signaling-server_message-handler_handlers_candidateHandler.js.html
+++ b/docs/server-communication_signaling-server_message-handler_handlers_candidateHandler.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-handler_handlers_commons_enterAndWelcome.js.html b/docs/server-communication_signaling-server_message-handler_handlers_commons_enterAndWelcome.js.html
index 9719ced6f..330ff58b5 100644
--- a/docs/server-communication_signaling-server_message-handler_handlers_commons_enterAndWelcome.js.html
+++ b/docs/server-communication_signaling-server_message-handler_handlers_commons_enterAndWelcome.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-handler_handlers_commons_offerAndAnswer.js.html b/docs/server-communication_signaling-server_message-handler_handlers_commons_offerAndAnswer.js.html
index 880eeb952..3d95f5662 100644
--- a/docs/server-communication_signaling-server_message-handler_handlers_commons_offerAndAnswer.js.html
+++ b/docs/server-communication_signaling-server_message-handler_handlers_commons_offerAndAnswer.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-handler_handlers_commons_processPeer.js.html b/docs/server-communication_signaling-server_message-handler_handlers_commons_processPeer.js.html
index 95db5d3d7..8c6bc987c 100644
--- a/docs/server-communication_signaling-server_message-handler_handlers_commons_processPeer.js.html
+++ b/docs/server-communication_signaling-server_message-handler_handlers_commons_processPeer.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-handler_handlers_getPeerListHandler.js.html b/docs/server-communication_signaling-server_message-handler_handlers_getPeerListHandler.js.html
index 7cdf196d7..249b67032 100644
--- a/docs/server-communication_signaling-server_message-handler_handlers_getPeerListHandler.js.html
+++ b/docs/server-communication_signaling-server_message-handler_handlers_getPeerListHandler.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-handler_handlers_inRoomHandler.js.html b/docs/server-communication_signaling-server_message-handler_handlers_inRoomHandler.js.html
index f53cf7fff..2486241c1 100644
--- a/docs/server-communication_signaling-server_message-handler_handlers_inRoomHandler.js.html
+++ b/docs/server-communication_signaling-server_message-handler_handlers_inRoomHandler.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -106,6 +106,7 @@
import logger from '../../../../logger';
import { TAGS } from '../../../../constants';
import MESSAGES from '../../../../messages';
+import HandleUserMediaStats from '../../../../skylink-stats/handleUserMediaStats';
const dispatchIncomingStream = (room, sid) => {
const state = Skylink.getSkylinkState(room.id);
@@ -127,6 +128,22 @@
});
};
+const startUserMediaStatsInterval = (roomKey, peerId) => {
+ const initOptions = Skylink.getInitOptions();
+ new HandleUserMediaStats().send(roomKey); // send first stat
+
+ const interval = setInterval(() => {
+ const currentState = Skylink.getSkylinkState(roomKey);
+ const userId = currentState ? currentState.user.sid : null;
+
+ if (!currentState || userId !== peerId) { // user has left the room or there is a new socket connection, so stop sending stats
+ clearInterval(interval);
+ } else {
+ new HandleUserMediaStats().send(currentState.room.id);
+ }
+ }, initOptions.statsInterval * 1000);
+};
+
/**
* Function that handles the "inRoom" socket message received.
* @param {JSON} message
@@ -163,6 +180,7 @@
}));
dispatchIncomingStream(roomState.room, sid);
+ startUserMediaStatsInterval(roomState.room.id, sid);
signaling.enterRoom(roomState);
};
diff --git a/docs/server-communication_signaling-server_message-handler_handlers_introduceErrorHandler.js.html b/docs/server-communication_signaling-server_message-handler_handlers_introduceErrorHandler.js.html
index d10e35cd2..4a00a2f65 100644
--- a/docs/server-communication_signaling-server_message-handler_handlers_introduceErrorHandler.js.html
+++ b/docs/server-communication_signaling-server_message-handler_handlers_introduceErrorHandler.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-handler_handlers_storedMessagesHandler.js.html b/docs/server-communication_signaling-server_message-handler_handlers_storedMessagesHandler.js.html
index 65785f007..f9bb6a74d 100644
--- a/docs/server-communication_signaling-server_message-handler_handlers_storedMessagesHandler.js.html
+++ b/docs/server-communication_signaling-server_message-handler_handlers_storedMessagesHandler.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/server-communication_signaling-server_message-handler_handlers_streamHandler.js.html b/docs/server-communication_signaling-server_message-handler_handlers_streamHandler.js.html
index f96390b60..f504fbf3c 100644
--- a/docs/server-communication_signaling-server_message-handler_handlers_streamHandler.js.html
+++ b/docs/server-communication_signaling-server_message-handler_handlers_streamHandler.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/skylink-events_candidate-events.js.html b/docs/skylink-events_candidate-events.js.html
index c31daf429..e1ab8fc87 100644
--- a/docs/skylink-events_candidate-events.js.html
+++ b/docs/skylink-events_candidate-events.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/skylink-events_datachannel-events.js.html b/docs/skylink-events_datachannel-events.js.html
index 0c68ed011..73d7ba117 100644
--- a/docs/skylink-events_datachannel-events.js.html
+++ b/docs/skylink-events_datachannel-events.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/skylink-events_index.js.html b/docs/skylink-events_index.js.html
index e64b71cae..320dbd759 100644
--- a/docs/skylink-events_index.js.html
+++ b/docs/skylink-events_index.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -221,11 +221,9 @@
* <strong>SOCKET EVENTS</strong> </br>
* <ul>
* <li>{@link SkylinkEvents.event:CHANNEL_OPEN|CHANNEL_OPEN}</li>
- * <li>{@link SkylinkEvents.event:CHANNEL_REOPEN|CHANNEL_REOPEN}</li>
* <li>{@link SkylinkEvents.event:CHANNEL_CLOSE|CHANNEL_CLOSE}</li>
* <li>{@link SkylinkEvents.event:CHANNEL_ERROR|CHANNEL_ERROR}</li>
* <li>{@link SkylinkEvents.event:CHANNEL_MESSAGE|CHANNEL_MESSAGE}</li>
- * <li>{@link SkylinkEvents.event:CHANNEL_RETRY|CHANNEL_RETRY}</li>
* <li>{@link SkylinkEvents.event:CHANNEL_OPEN|CHANNEL_OPEN}</li>
* <li>{@link SkylinkEvents.event:SOCKET_ERROR|SOCKET_ERROR}</li>
* <li>{@link SkylinkEvents.event:SYSTEM_ACTION|SYSTEM_ACTION}</li>
diff --git a/docs/skylink-events_init-events.js.html b/docs/skylink-events_init-events.js.html
index 07de2e6fe..b07fbd199 100644
--- a/docs/skylink-events_init-events.js.html
+++ b/docs/skylink-events_init-events.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/skylink-events_media-events.js.html b/docs/skylink-events_media-events.js.html
index c74dfe65a..94d7b955c 100644
--- a/docs/skylink-events_media-events.js.html
+++ b/docs/skylink-events_media-events.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/skylink-events_peer-events.js.html b/docs/skylink-events_peer-events.js.html
index 3805c6138..e10317c4a 100644
--- a/docs/skylink-events_peer-events.js.html
+++ b/docs/skylink-events_peer-events.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -140,6 +140,7 @@
* @param {String} detail.peerId - The Peer ID.
* @param {peerInfo} detail.peerInfo - The Peer session information. Object signature matches the <code>peerInfo</code> parameter payload received in the<code>peerJoined</code> event.
* @param {boolean} detail.isSelf - The flag if Peer is User.
+ * @param {roomInfo} detail.room - The room.
*/
export const peerLeft = (detail = {}) => new SkylinkEvent(PEER_LEFT, { detail });
@@ -199,6 +200,17 @@
* @param {Object} detail - Event's payload.
* @param {String} detail.peerId - The User's Room session Peer ID
* @param {peerInfo} detail.peerInfo - The User's Room session information. Object signature matches the <code>peerInfo</code> parameter payload received in the<code> {@link SkylinkEvents.event:PEER_JOINED|PEER JOINED}</code> event.
+ * @param {peerInfo} detail.reason - Reason for the disconnect
+ * @example
+ * Example 1: Listen on sessionDisconnect to reconnect
+ * SkylinkEventManager.addEventListener(SkylinkConstants.EVENTS.SESSION_DISCONNECT, evt => {
+ * skylink.leaveRoom() // call leaveRoom to ensure that previous peer information will be removed
+ * .then(() => skylink.joinRoom(joinRoomOptions))
+ * .then((streams) => {
+ * window.attachMediaStream(audioEl, streams[0]);
+ * window.attachMediaStream(videoEl, streams[1]);
+ * })
+ * });
*/
export const sessionDisconnect = (detail = {}) => new SkylinkEvent(SESSION_DISCONNECT, { detail });
diff --git a/docs/skylink-events_peer-handshake-events.js.html b/docs/skylink-events_peer-handshake-events.js.html
index 928b27d15..4d549dcc7 100644
--- a/docs/skylink-events_peer-handshake-events.js.html
+++ b/docs/skylink-events_peer-handshake-events.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/skylink-events_room-events.js.html b/docs/skylink-events_room-events.js.html
index 8ab6e0ade..6c7e0df20 100644
--- a/docs/skylink-events_room-events.js.html
+++ b/docs/skylink-events_room-events.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -109,6 +109,8 @@
* @param {String} detail.peerId The Peer ID.
* @param {peerInfo} detail.peerInfo The Peer session information. Object signature matches the <code>peerInfo</code> parameter payload received in the <code> {@link SkylinkEvents.event:PEER_JOINED|PEER JOINED}</code> event.
* @param {Boolean} detail.isSelf The flag if User changed the Room locked status.
+ * @param {roomInfo} detail.room The room.
+ *
*/
export const roomLock = (detail = {}) => new SkylinkEvent(ROOM_LOCK, { detail });
diff --git a/docs/skylink-events_socket-events.js.html b/docs/skylink-events_socket-events.js.html
index 6d96ebb74..c72e3159a 100644
--- a/docs/skylink-events_socket-events.js.html
+++ b/docs/skylink-events_socket-events.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -115,23 +115,15 @@
*/
export const channelOpen = detail => new SkylinkEvent(CHANNEL_OPEN, { detail });
+// Ref: ESS-2024
/**
* @event SkylinkEvents.CHANNEL_REOPEN
- * @description Event triggered when socket connection to Signaling server has re-opened.
+ * @description [DEPRECATED] Event triggered when socket connection to Signaling server has re-opened.
+ * <blockquote class="info">
+ * This event has been replaced with {@link SkylinkEvents.event:SESSION_DISCONNECT|SESSION_DISCONNECT}. Implementation of reconnecting back to a
+ * room remains the same.</blockquote>
* @param {Object} detail - Event's payload.
* @param {socketSession} detail.session The socket connection session information.
- * @example
- * Example 1: Listen on channelReopen to handle successful socket reconnection if socket was disconnected
- * (channelClose event emitted).
- * SkylinkEventManager.addEventListener(SkylinkConstants.EVENTS.CHANNEL_REOPEN, evt => {
- * const { detail } = evt;
- * skylink.leaveRoom() // call leaveRoom to ensure that previous peer information will be removed
- * .then(() => skylink.joinRoom(joinRoomOptions))
- * .then((streams) => {
- * window.attachMediaStream(audioEl, streams[0]);
- * window.attachMediaStream(videoEl, streams[1]);
- * })
- * });
*/
export const channelReopen = detail => new SkylinkEvent(CHANNEL_REOPEN, { detail });
@@ -164,6 +156,7 @@
*/
export const channelMessage = detail => new SkylinkEvent(CHANNEL_MESSAGE, { detail });
+// Ref: ESS-2024
/**
* @description Event triggered when attempting to establish socket connection to Signaling server when failed.
* @event SkylinkEvents.CHANNEL_RETRY
diff --git a/docs/skylink-events_stream-events.js.html b/docs/skylink-events_stream-events.js.html
index 66e34f83b..43ee6228a 100644
--- a/docs/skylink-events_stream-events.js.html
+++ b/docs/skylink-events_stream-events.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/skylink-states.js.html b/docs/skylink-states.js.html
index 1d4965494..1a6e90e88 100644
--- a/docs/skylink-states.js.html
+++ b/docs/skylink-states.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/docs/typedefs.js.html b/docs/typedefs.js.html
index c80e24a2a..3dac94d63 100644
--- a/docs/typedefs.js.html
+++ b/docs/typedefs.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
@@ -196,7 +196,8 @@
* @property {boolean} [enableStatsGathering=true] Configure the anonymous performance and connectivity statistic collection function.
* Temasys collects encrypted, anonymous performance and connectivity statistics to allow us to improve performance for our customers and identify regional or ISP specific connectivity issues.
* This data does not contain any personal information or session content.
- * To enable the configuration of this option, you need to "Collect Quality Statistics" option on the Temasys console Website under App key settings section.
+ * To enable the configuration of this option, you need to enable the "Collect Quality Statistics" option on the Temasys console Website under
+ * App key settings section.
* @property {boolean} [enableDataChannel=true] The flag if Datachannel connections should be enabled.
* @property {boolean} [enableTURNServer=true] The flag if TURN ICE servers should
* be used when constructing Peer connections to allow TURN connections when required and enabled for the App Key.
@@ -274,6 +275,7 @@
* If not defined, it will use the default protocol specified.
* @property {boolean} [beSilentOnStatsLogs=false] The flag if all logs triggered by the statistics module should be silent.
* @property {boolean} [beSilentOnParseLogs=false] The flag if media and codec parsing logs should be silent.
+ * @property {String} [statsInterval=20] The frequency of posting stats logs in seconds.
*/
/**
diff --git a/docs/utils_helpers.js.html b/docs/utils_helpers.js.html
index 487ee79a8..a94045ead 100644
--- a/docs/utils_helpers.js.html
+++ b/docs/utils_helpers.js.html
@@ -78,7 +78,7 @@
- Classes
Namespaces
Global
+ Classes
Namespaces
Global
diff --git a/package-lock.json b/package-lock.json
index 3aaadd680..5efbf9a1c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "skylinkjs",
- "version": "2.1.2",
+ "version": "2.1.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -803,6 +803,52 @@
"fastq": "^1.6.0"
}
},
+ "@rollup/plugin-replace": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-2.3.3.tgz",
+ "integrity": "sha512-XPmVXZ7IlaoWaJLkSCDaa0Y6uVo5XQYHhiMFzOd5qSv5rE+t/UJToPIOE56flKIxBFQI27ONsxb7dqHnwSsjKQ==",
+ "dev": true,
+ "requires": {
+ "@rollup/pluginutils": "^3.0.8",
+ "magic-string": "^0.25.5"
+ },
+ "dependencies": {
+ "magic-string": {
+ "version": "0.25.7",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
+ "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==",
+ "dev": true,
+ "requires": {
+ "sourcemap-codec": "^1.4.4"
+ }
+ }
+ }
+ },
+ "@rollup/pluginutils": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz",
+ "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==",
+ "dev": true,
+ "requires": {
+ "@types/estree": "0.0.39",
+ "estree-walker": "^1.0.1",
+ "picomatch": "^2.2.2"
+ },
+ "dependencies": {
+ "estree-walker": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz",
+ "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==",
+ "dev": true
+ },
+ "picomatch": {
+ "version": "2.2.2",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
+ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",
+ "dev": true
+ }
+ }
+ },
"@sindresorhus/is": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
diff --git a/package.json b/package.json
index 70c6553d9..70629b61e 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "skylinkjs",
"description": "Temasys Web SDK is an open-source client-side library for your web-browser that enables any website to easily leverage the capabilities of WebRTC and its direct data streaming powers between peers for audio/video conferencing or file transfer.",
- "version": "2.1.5",
+ "version": "2.2.0",
"homepage": "https://temasys.io/",
"author": {
"name": "Temasys Communications Pte. Ltd.",
@@ -47,6 +47,7 @@
"@babel/core": "^7.2.2",
"@babel/preset-env": "7.2.3",
"@babel/register": "7.0.0",
+ "@rollup/plugin-replace": "^2.3.3",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5",
"eslint": "^5.2.0",
diff --git a/publish/2.1.5/gzip/skylink.complete.js b/publish/2.1.5/gzip/skylink.complete.js
deleted file mode 100644
index 83c3b0fbc..000000000
Binary files a/publish/2.1.5/gzip/skylink.complete.js and /dev/null differ
diff --git a/publish/2.1.5/gzip/skylink.complete.min.js b/publish/2.1.5/gzip/skylink.complete.min.js
deleted file mode 100644
index 01323d6a9..000000000
Binary files a/publish/2.1.5/gzip/skylink.complete.min.js and /dev/null differ
diff --git a/publish/2.1.5/gzip/skylink.complete.min.umd.js b/publish/2.1.5/gzip/skylink.complete.min.umd.js
deleted file mode 100644
index 27cea4a98..000000000
Binary files a/publish/2.1.5/gzip/skylink.complete.min.umd.js and /dev/null differ
diff --git a/publish/2.1.5/gzip/skylink.complete.umd.js b/publish/2.1.5/gzip/skylink.complete.umd.js
deleted file mode 100644
index 3c3943e7d..000000000
Binary files a/publish/2.1.5/gzip/skylink.complete.umd.js and /dev/null differ
diff --git a/publish/2.1.5/skylink.complete.min.js b/publish/2.1.5/skylink.complete.min.js
deleted file mode 100644
index bad64dd85..000000000
--- a/publish/2.1.5/skylink.complete.min.js
+++ /dev/null
@@ -1,21 +0,0 @@
-let e=!0,t=!0;function r(e,t,r){const n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function n(e,t,r){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,s=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return s.apply(this,arguments);const i=e=>{const t=r(e);t&&n(t);};return this._eventMap=this._eventMap||{},this._eventMap[n]=i,s.apply(this,[e,i])};const i=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[r])return i.apply(this,arguments);const n=this._eventMap[r];return delete this._eventMap[r],i.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e);},enumerable:!0,configurable:!0});}function s(t){return "boolean"!=typeof t?new Error("Argument type: "+typeof t+". Please use a boolean."):(e=t,t?"adapter.js logging disabled":"adapter.js logging enabled")}function i(e){return "boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(t=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function o(){if("object"==typeof window){if(e)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments);}}function a(e,r){t&&console.warn(e+" is deprecated, please use "+r+" instead.");}function c(e){const{navigator:t}=e,n={browser:null,version:null};if(void 0===e||!e.navigator)return n.browser="Not a browser.",n;if(t.mozGetUserMedia)n.browser="firefox",n.version=r(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)n.browser="chrome",n.version=r(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))n.browser="edge",n.version=r(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return n.browser="Not a supported browser.",n;n.browser="safari",n.version=r(t.userAgent,/AppleWebKit\/(\d+)\./,1),n.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype;}return n}function d(e){return "[object Object]"===Object.prototype.toString.call(e)}function l(e){return d(e)?Object.keys(e).reduce((function(t,r){const n=d(e[r]),s=n?l(e[r]):e[r],i=n&&!Object.keys(s).length;return void 0===s||i?t:Object.assign(t,{[r]:s})}),{}):e}function p(e,t,r){const n=r?"outbound-rtp":"inbound-rtp",s=new Map;if(null===t)return s;const i=[];return e.forEach(e=>{"track"===e.type&&e.trackIdentifier===t.id&&i.push(e);}),i.forEach(t=>{e.forEach(r=>{r.type===n&&r.trackId===t.id&&function e(t,r,n){r&&!n.has(r.id)&&(n.set(r.id,r),Object.keys(r).forEach(s=>{s.endsWith("Id")?e(t,t.get(r[s]),n):s.endsWith("Ids")&&r[s].forEach(r=>{e(t,t.get(r),n);});}));}(e,r,s);});}),s}const u=o;function S(e){const t=e&&e.navigator;if(!t.mediaDevices)return;const r=c(e),n=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const s=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[s("min",r)]=n.ideal,t.optional.push(e),e={},e[s("max",r)]=n.ideal,t.optional.push(e)):(e[s("",r)]=n.ideal,t.optional.push(e));}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[s("",r)]=n.exact):["min","max"].forEach(e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[s(e,r)]=n[e]);});}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},s=function(e,s){if(r.version>=61)return s(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t]);};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio);}if(e&&"object"==typeof e.video){let i=e.video.facingMode;i=i&&("object"==typeof i?i:{ideal:i});const o=r.version<66;if(i&&("user"===i.exact||"environment"===i.exact||"user"===i.ideal||"environment"===i.ideal)&&(!t.mediaDevices.getSupportedConstraints||!t.mediaDevices.getSupportedConstraints().facingMode||o)){let r;if(delete e.video.facingMode,"environment"===i.exact||"environment"===i.ideal?r=["back","rear"]:"user"!==i.exact&&"user"!==i.ideal||(r=["front"]),r)return t.mediaDevices.enumerateDevices().then(t=>{let o=(t=t.filter(e=>"videoinput"===e.kind)).find(e=>r.some(t=>e.label.toLowerCase().includes(t)));return !o&&t.length&&r.includes("back")&&(o=t[t.length-1]),o&&(e.video.deviceId=i.exact?{exact:o.deviceId}:{ideal:o.deviceId}),e.video=n(e.video),u("chrome: "+JSON.stringify(e)),s(e)})}e.video=n(e.video);}return u("chrome: "+JSON.stringify(e)),s(e)},i=function(e){return r.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(t.getUserMedia=function(e,r,n){s(e,e=>{t.webkitGetUserMedia(e,r,e=>{n&&n(i(e));});});}.bind(t),t.mediaDevices.getUserMedia){const e=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(t){return s(t,t=>e(t).then(e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(e=>{e.stop();}),new DOMException("","NotFoundError");return e},e=>Promise.reject(i(e))))};}}function E(e){e.MediaStream=e.MediaStream||e.webkitMediaStream;}function h(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e);},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.track.id):{track:r.track};const s=new Event("track");s.track=r.track,s.receiver=n,s.transceiver={receiver:n},s.streams=[t.stream],this.dispatchEvent(s);}),t.stream.getTracks().forEach(r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.id):{track:r};const s=new Event("track");s.track=r,s.receiver=n,s.transceiver={receiver:n},s.streams=[t.stream],this.dispatchEvent(s);});},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)};}else n(e,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e));}function m(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return {track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let s=r.apply(this,arguments);return s||(s=t(this,e),this._senders.push(s)),s};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1);};}const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e));});};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach(e=>{const t=this._senders.find(t=>t.track===e);t&&this._senders.splice(this._senders.indexOf(t),1);});};}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}});}}function g(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,n]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const s=function(e){const t={};return e.result().forEach(e=>{const r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(t=>{r[t]=e.stat(t);}),t[r.id]=r;}),t},i=function(e){return new Map(Object.keys(e).map(t=>[t,e[t]]))};if(arguments.length>=2){const n=function(e){r(i(s(e)));};return t.apply(this,[n,e])}return new Promise((e,r)=>{t.apply(this,[function(t){e(i(s(t)));},r]);}).then(r,n)};}function R(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>p(t,e.track,!0))};}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),n(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>p(t,e.track,!1))};}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,r,n;return this.getSenders().forEach(r=>{r.track===e&&(t?n=!0:t=r);}),this.getReceivers().forEach(t=>(t.track===e&&(r?n=!0:r=t),t.track===e)),n||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)};}function f(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(e=>this._shimmedLocalStreams[e][0])};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")});const t=this.getSenders();r.apply(this,arguments);const n=this.getSenders().filter(e=>-1===t.indexOf(e));this._shimmedLocalStreams[e.id]=[e].concat(n);};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};const s=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(t=>{const r=this._shimmedLocalStreams[t].indexOf(e);-1!==r&&this._shimmedLocalStreams[t].splice(r,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t];}),s.apply(this,arguments)};}function T(e){if(!e.RTCPeerConnection)return;const t=c(e);if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return f(e);const r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=r.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){const r=new e.MediaStream(t.getTracks());this._streams[t.id]=r,this._reverseStreams[r.id]=t,t=r;}n.apply(this,[t]);};const s=e.RTCPeerConnection.prototype.removeStream;function i(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const n=e._reverseStreams[t],s=e._streams[n.id];r=r.replace(new RegExp(s.id,"g"),n.id);}),new RTCSessionDescription({type:t.type,sdp:r})}function o(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const n=e._reverseStreams[t],s=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),s.id);}),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},s.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id];},e.RTCPeerConnection.prototype.addTrack=function(t,r){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find(e=>e===t))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const s=this.getSenders().find(e=>e.track===t);if(s)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const i=this._streams[r.id];if(i)i.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"));});else{const n=new e.MediaStream([t]);this._streams[r.id]=n,this._reverseStreams[n.id]=r,this.addStream(n);}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=i(this,t);e[0].apply(null,[r]);},t=>{e[1]&&e[1].apply(null,t);},arguments[2]]):r.apply(this,arguments).then(e=>i(this,e))}};e.RTCPeerConnection.prototype[t]=n[t];}));const a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=o(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};const d=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=d.get.apply(this);return ""===e.type?e:i(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach(r=>{this._streams[r].getTracks().find(t=>e.track===t)&&(t=this._streams[r]);}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")));};}function _(e){const t=c(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),!e.RTCPeerConnection)return;const r=0===e.RTCPeerConnection.prototype.addIceCandidate.length;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t];}));const n=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return r||arguments[0]?t.version<78&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())};}function I(e){n(e,"negotiationneeded",e=>{if("stable"===e.target.signalingState)return e});}var C=Object.freeze({shimMediaStream:E,shimOnTrack:h,shimGetSendersWithDtmf:m,shimGetStats:g,shimSenderReceiverGetStats:R,shimAddTrackRemoveTrackWithNative:f,shimAddTrackRemoveTrack:T,shimPeerConnection:_,fixNegotiationNeeded:I,shimGetUserMedia:S,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then(t=>{const n=r.video&&r.video.width,s=r.video&&r.video.height,i=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:i||3}},n&&(r.video.mandatory.maxWidth=n),s&&(r.video.mandatory.maxHeight=s),e.navigator.mediaDevices.getUserMedia(r)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"));}});function O(e,t){return e(t={exports:{}},t.exports),t.exports}var A=O((function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return (t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){var r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter((function(e){return 0===e.indexOf(r)}))},t.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return "a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),s=0;s-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return {semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return {algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,r){return {role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n";})),r},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return {tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return "a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return {keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){var n=t.matchPrefix(e+r,"a=ice-ufrag:")[0],s=t.matchPrefix(e+r,"a=ice-pwd:")[0];return n&&s?{usernameFragment:n.substr(12),password:s.substr(10)}:null},t.writeIceParameters=function(e){return "a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" "),s=3;s0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=r.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach((function(e){n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e);}));var s=0;return r.codecs.forEach((function(e){e.maxptime>s&&(s=e.maxptime);})),s>0&&(n+="a=maxptime:"+s+"\r\n"),n+="a=rtcp-mux\r\n",r.headerExtensions&&r.headerExtensions.forEach((function(e){n+=t.writeExtmap(e);})),n},t.parseRtpEncodingParameters=function(e){var r,n=[],s=t.parseRtpParameters(e),i=-1!==s.fecMechanisms.indexOf("RED"),o=-1!==s.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return "cname"===e.attribute})),c=a.length>0&&a[0].ssrc,d=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));d.length>0&&d[0].length>1&&d[0][0]===c&&(r=d[0][1]),s.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&r&&(t.rtx={ssrc:r}),n.push(t),i&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},n.push(t));}})),0===n.length&&c&&n.push({ssrc:c});var l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substr(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substr(5),10)*.95-16e3:void 0,n.forEach((function(e){e.maxBitrate=l;}))),n},t.parseRtcpParameters=function(e){var r={},n=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return "cname"===e.attribute}))[0];n&&(r.cname=n.value,r.ssrc=n.ssrc);var s=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=s.length>0,r.compound=0===s.length;var i=t.matchPrefix(e,"a=rtcp-mux");return r.mux=i.length>0,r},t.parseMsid=function(e){var r,n=t.matchPrefix(e,"a=msid:");if(1===n.length)return {stream:(r=n[0].substr(7).split(" "))[0],track:r[1]};var s=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return "msid"===e.attribute}));return s.length>0?{stream:(r=s[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(e){var r,n=t.parseMLine(e),s=t.matchPrefix(e,"a=max-message-size:");s.length>0&&(r=parseInt(s[0].substr(19),10)),isNaN(r)&&(r=65536);var i=t.matchPrefix(e,"a=sctp-port:");if(i.length>0)return {port:parseInt(i[0].substr(12),10),protocol:n.fmt,maxMessageSize:r};if(t.matchPrefix(e,"a=sctpmap:").length>0){var o=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return {port:parseInt(o[0],10),protocol:o[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,r,n){var s=void 0!==r?r:2;return "v=0\r\no="+(n||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+s+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,r,n,s){var i=t.writeRtpDescription(e.kind,r);if(i+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),i+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),i+="a=mid:"+e.mid+"\r\n",e.direction?i+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?i+="a=sendrecv\r\n":e.rtpSender?i+="a=sendonly\r\n":e.rtpReceiver?i+="a=recvonly\r\n":i+="a=inactive\r\n",e.rtpSender){var o="msid:"+s.id+" "+e.rtpSender.track.id+"\r\n";i+="a="+o,i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,i+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n");}return i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),i},t.getDirection=function(e,r){for(var n=t.splitLines(e),s=0;s=14393&&-1===e.indexOf("?transport=udp")})),delete e.url,e.urls=s?n[0]:n,!!n.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var i=r.iceCandidatePoolSize;i>0;i--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=A.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1;};Object.defineProperty(s.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(s.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),s.prototype.onicecandidate=null,s.prototype.onaddstream=null,s.prototype.ontrack=null,s.prototype.onremovestream=null,s.prototype.onsignalingstatechange=null,s.prototype.oniceconnectionstatechange=null,s.prototype.onconnectionstatechange=null,s.prototype.onicegatheringstatechange=null,s.prototype.onnegotiationneeded=null,s.prototype.ondatachannel=null,s.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t));},s.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e);},s.prototype.getConfiguration=function(){return this._config},s.prototype.getLocalStreams=function(){return this.localStreams},s.prototype.getRemoteStreams=function(){return this.remoteStreams},s.prototype._createTransceiver=function(e,t){var r=this.transceivers.length>0,n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&r)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var s=this._createIceAndDtlsTransports();n.iceTransport=s.iceTransport,n.dtlsTransport=s.dtlsTransport;}return t||this.transceivers.push(n),n},s.prototype.addTrack=function(t,r){if(this._isClosed)throw P("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var n;if(this.transceivers.find((function(e){return e.track===t})))throw P("InvalidAccessError","Track already exists.");for(var s=0;s=15025)e.getTracks().forEach((function(t){r.addTrack(t,e);}));else{var n=e.clone();e.getTracks().forEach((function(e,t){var r=n.getTracks()[t];e.addEventListener("enabled",(function(e){r.enabled=e.enabled;}));})),n.getTracks().forEach((function(e){r.addTrack(e,n);}));}},s.prototype.removeTrack=function(t){if(this._isClosed)throw P("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var r=this.transceivers.find((function(e){return e.rtpSender===t}));if(!r)throw P("InvalidAccessError","Sender was not created by this connection.");var n=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(n)&&this.localStreams.indexOf(n)>-1&&this.localStreams.splice(this.localStreams.indexOf(n),1),this._maybeFireNegotiationNeeded();},s.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var r=t.getSenders().find((function(t){return t.track===e}));r&&t.removeTrack(r);}));},s.prototype.getSenders=function(){return this.transceivers.filter((function(e){return !!e.rtpSender})).map((function(e){return e.rtpSender}))},s.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return !!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},s.prototype._createIceGatherer=function(t,r){var n=this;if(r&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var s=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(s,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;s.state=r?"completed":"gathering",null!==n.transceivers[t].bufferedCandidateEvents&&n.transceivers[t].bufferedCandidateEvents.push(e);},s.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),s},s.prototype._gather=function(t,r){var n=this,s=this.transceivers[r].iceGatherer;if(!s.onlocalcandidate){var i=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,s.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),s.onlocalcandidate=function(e){if(!(n.usingBundle&&r>0)){var i=new Event("icecandidate");i.candidate={sdpMid:t,sdpMLineIndex:r};var o=e.candidate,a=!o||0===Object.keys(o).length;if(a)"new"!==s.state&&"gathering"!==s.state||(s.state="completed");else{"new"===s.state&&(s.state="gathering"),o.component=1,o.ufrag=s.getLocalParameters().usernameFragment;var c=A.writeCandidate(o);i.candidate=Object.assign(i.candidate,A.parseCandidate(c)),i.candidate.candidate=c,i.candidate.toJSON=function(){return {candidate:i.candidate.candidate,sdpMid:i.candidate.sdpMid,sdpMLineIndex:i.candidate.sdpMLineIndex,usernameFragment:i.candidate.usernameFragment}};}var d=A.getMediaSections(n._localDescription.sdp);d[i.candidate.sdpMLineIndex]+=a?"a=end-of-candidates\r\n":"a="+i.candidate.candidate+"\r\n",n._localDescription.sdp=A.getDescription(n._localDescription.sdp)+d.join("");var l=n.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==n.iceGatheringState&&(n.iceGatheringState="gathering",n._emitGatheringStateChange()),a||n._dispatchEvent("icecandidate",i),l&&(n._dispatchEvent("icecandidate",new Event("icecandidate")),n.iceGatheringState="complete",n._emitGatheringStateChange());}},e.setTimeout((function(){i.forEach((function(e){s.onlocalcandidate(e);}));}),0);}},s.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState();};var n=new e.RTCDtlsTransport(r);return n.ondtlsstatechange=function(){t._updateConnectionState();},n.onerror=function(){Object.defineProperty(n,"state",{value:"failed",writable:!0}),t._updateConnectionState();},{iceTransport:r,dtlsTransport:n}},s.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var n=this.transceivers[e].dtlsTransport;n&&(delete n.ondtlsstatechange,delete n.onerror,delete this.transceivers[e].dtlsTransport);},s.prototype._transceive=function(e,r,n){var s=N(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(s.encodings=e.sendEncodingParameters,s.rtcp={cname:A.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(s.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(s)),n&&e.rtpReceiver&&s.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx;})),e.recvEncodingParameters.length?s.encodings=e.recvEncodingParameters:s.encodings=[{}],s.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(s.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(s.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(s));},s.prototype.setLocalDescription=function(e){var t,r,n=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(P("TypeError",'Unsupported type "'+e.type+'"'));if(!D("setLocalDescription",e.type,n.signalingState)||n._isClosed)return Promise.reject(P("InvalidStateError","Can not set local "+e.type+" in state "+n.signalingState));if("offer"===e.type)t=A.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=A.parseRtpParameters(e);n.transceivers[t].localCapabilities=r;})),n.transceivers.forEach((function(e,t){n._gather(e.mid,t);}));else if("answer"===e.type){t=A.splitSections(n._remoteDescription.sdp),r=t.shift();var s=A.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var i=n.transceivers[t],o=i.iceGatherer,a=i.iceTransport,c=i.dtlsTransport,d=i.localCapabilities,l=i.remoteCapabilities;if(!(A.isRejected(e)&&0===A.matchPrefix(e,"a=bundle-only").length)&&!i.rejected){var p=A.getIceParameters(e,r),u=A.getDtlsParameters(e,r);s&&(u.role="server"),n.usingBundle&&0!==t||(n._gather(i.mid,t),"new"===a.state&&a.start(o,p,s?"controlling":"controlled"),"new"===c.state&&c.start(u));var S=N(d,l);n._transceive(i,S.codecs.length>0,!1);}}));}return n._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?n._updateSignalingState("have-local-offer"):n._updateSignalingState("stable"),Promise.resolve()},s.prototype.setRemoteDescription=function(s){var i=this;if(-1===["offer","answer"].indexOf(s.type))return Promise.reject(P("TypeError",'Unsupported type "'+s.type+'"'));if(!D("setRemoteDescription",s.type,i.signalingState)||i._isClosed)return Promise.reject(P("InvalidStateError","Can not set remote "+s.type+" in state "+i.signalingState));var o={};i.remoteStreams.forEach((function(e){o[e.id]=e;}));var a=[],c=A.splitSections(s.sdp),d=c.shift(),l=A.matchPrefix(d,"a=ice-lite").length>0,p=A.matchPrefix(d,"a=group:BUNDLE ").length>0;i.usingBundle=p;var u=A.matchPrefix(d,"a=ice-options:")[0];return i.canTrickleIceCandidates=!!u&&u.substr(14).split(" ").indexOf("trickle")>=0,c.forEach((function(n,c){var u=A.splitLines(n),S=A.getKind(n),E=A.isRejected(n)&&0===A.matchPrefix(n,"a=bundle-only").length,h=u[0].substr(2).split(" ")[2],m=A.getDirection(n,d),g=A.parseMsid(n),R=A.getMid(n)||A.generateIdentifier();if(E||"application"===S&&("DTLS/SCTP"===h||"UDP/DTLS/SCTP"===h))i.transceivers[c]={mid:R,kind:S,protocol:h,rejected:!0};else{var f,T,_,I,C,O,v,D,P;!E&&i.transceivers[c]&&i.transceivers[c].rejected&&(i.transceivers[c]=i._createTransceiver(S,!0));var M,k,w=A.parseRtpParameters(n);E||(M=A.getIceParameters(n,d),(k=A.getDtlsParameters(n,d)).role="client"),v=A.parseRtpEncodingParameters(n);var b=A.parseRtcpParameters(n),L=A.matchPrefix(n,"a=end-of-candidates",d).length>0,G=A.matchPrefix(n,"a=candidate:").map((function(e){return A.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===s.type||"answer"===s.type)&&!E&&p&&c>0&&i.transceivers[c]&&(i._disposeIceAndDtlsTransports(c),i.transceivers[c].iceGatherer=i.transceivers[0].iceGatherer,i.transceivers[c].iceTransport=i.transceivers[0].iceTransport,i.transceivers[c].dtlsTransport=i.transceivers[0].dtlsTransport,i.transceivers[c].rtpSender&&i.transceivers[c].rtpSender.setTransport(i.transceivers[0].dtlsTransport),i.transceivers[c].rtpReceiver&&i.transceivers[c].rtpReceiver.setTransport(i.transceivers[0].dtlsTransport)),"offer"!==s.type||E){if("answer"===s.type&&!E){T=(f=i.transceivers[c]).iceGatherer,_=f.iceTransport,I=f.dtlsTransport,C=f.rtpReceiver,O=f.sendEncodingParameters,D=f.localCapabilities,i.transceivers[c].recvEncodingParameters=v,i.transceivers[c].remoteCapabilities=w,i.transceivers[c].rtcpParameters=b,G.length&&"new"===_.state&&(!l&&!L||p&&0!==c?G.forEach((function(e){y(f.iceTransport,e);})):_.setRemoteCandidates(G)),p&&0!==c||("new"===_.state&&_.start(T,M,"controlling"),"new"===I.state&&I.start(k)),!N(f.localCapabilities,f.remoteCapabilities).codecs.filter((function(e){return "rtx"===e.name.toLowerCase()})).length&&f.sendEncodingParameters[0].rtx&&delete f.sendEncodingParameters[0].rtx,i._transceive(f,"sendrecv"===m||"recvonly"===m,"sendrecv"===m||"sendonly"===m),!C||"sendrecv"!==m&&"sendonly"!==m?delete f.rtpReceiver:(P=C.track,g?(o[g.stream]||(o[g.stream]=new e.MediaStream),r(P,o[g.stream]),a.push([P,C,o[g.stream]])):(o.default||(o.default=new e.MediaStream),r(P,o.default),a.push([P,C,o.default])));}}else{(f=i.transceivers[c]||i._createTransceiver(S)).mid=R,f.iceGatherer||(f.iceGatherer=i._createIceGatherer(c,p)),G.length&&"new"===f.iceTransport.state&&(!L||p&&0!==c?G.forEach((function(e){y(f.iceTransport,e);})):f.iceTransport.setRemoteCandidates(G)),D=e.RTCRtpReceiver.getCapabilities(S),t<15019&&(D.codecs=D.codecs.filter((function(e){return "rtx"!==e.name}))),O=f.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var U,F=!1;if("sendrecv"===m||"sendonly"===m){if(F=!f.rtpReceiver,C=f.rtpReceiver||new e.RTCRtpReceiver(f.dtlsTransport,S),F)P=C.track,g&&"-"===g.stream||(g?(o[g.stream]||(o[g.stream]=new e.MediaStream,Object.defineProperty(o[g.stream],"id",{get:function(){return g.stream}})),Object.defineProperty(P,"id",{get:function(){return g.track}}),U=o[g.stream]):(o.default||(o.default=new e.MediaStream),U=o.default)),U&&(r(P,U),f.associatedRemoteMediaStreams.push(U)),a.push([P,C,U]);}else f.rtpReceiver&&f.rtpReceiver.track&&(f.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===f.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}));}(r,t);})),f.associatedRemoteMediaStreams=[]);f.localCapabilities=D,f.remoteCapabilities=w,f.rtpReceiver=C,f.rtcpParameters=b,f.sendEncodingParameters=O,f.recvEncodingParameters=v,i._transceive(i.transceivers[c],!1,F);}}})),void 0===i._dtlsRole&&(i._dtlsRole="offer"===s.type?"active":"passive"),i._remoteDescription={type:s.type,sdp:s.sdp},"offer"===s.type?i._updateSignalingState("have-remote-offer"):i._updateSignalingState("stable"),Object.keys(o).forEach((function(t){var r=o[t];if(r.getTracks().length){if(-1===i.remoteStreams.indexOf(r)){i.remoteStreams.push(r);var s=new Event("addstream");s.stream=r,e.setTimeout((function(){i._dispatchEvent("addstream",s);}));}a.forEach((function(e){var t=e[0],s=e[1];r.id===e[2].id&&n(i,t,s,[r]);}));}})),a.forEach((function(e){e[2]||n(i,e[0],e[1],[]);})),e.setTimeout((function(){i&&i.transceivers&&i.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}));}));}),4e3),Promise.resolve()},s.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop();})),this._isClosed=!0,this._updateSignalingState("closed");},s.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t);},s.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e);}}),0));},s.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++;})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r);}},s.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++);})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r);}},s.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(P("InvalidStateError","Can not call createOffer after close"));var n=r.transceivers.filter((function(e){return "audio"===e.kind})).length,s=r.transceivers.filter((function(e){return "video"===e.kind})).length,i=arguments[0];if(i){if(i.mandatory||i.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==i.offerToReceiveAudio&&(n=!0===i.offerToReceiveAudio?1:!1===i.offerToReceiveAudio?0:i.offerToReceiveAudio),void 0!==i.offerToReceiveVideo&&(s=!0===i.offerToReceiveVideo?1:!1===i.offerToReceiveVideo?0:i.offerToReceiveVideo);}for(r.transceivers.forEach((function(e){"audio"===e.kind?--n<0&&(e.wantReceive=!1):"video"===e.kind&&--s<0&&(e.wantReceive=!1);}));n>0||s>0;)n>0&&(r._createTransceiver("audio"),n--),s>0&&(r._createTransceiver("video"),s--);var o=A.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(n,s){var i=n.track,o=n.kind,a=n.mid||A.generateIdentifier();n.mid=a,n.iceGatherer||(n.iceGatherer=r._createIceGatherer(s,r.usingBundle));var c=e.RTCRtpSender.getCapabilities(o);t<15019&&(c.codecs=c.codecs.filter((function(e){return "rtx"!==e.name}))),c.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),n.remoteCapabilities&&n.remoteCapabilities.codecs&&n.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType);}));})),c.headerExtensions.forEach((function(e){(n.remoteCapabilities&&n.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id);}));}));var d=n.sendEncodingParameters||[{ssrc:1001*(2*s+1)}];i&&t>=15019&&"video"===o&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),n.wantReceive&&(n.rtpReceiver=new e.RTCRtpReceiver(n.dtlsTransport,o)),n.localCapabilities=c,n.sendEncodingParameters=d;})),"max-compat"!==r._config.bundlePolicy&&(o+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),o+="a=ice-options:trickle\r\n",r.transceivers.forEach((function(e,t){o+=v(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),o+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,o+="a="+A.writeCandidate(e)+"\r\n";})),"completed"===e.iceGatherer.state&&(o+="a=end-of-candidates\r\n"));}));var a=new e.RTCSessionDescription({type:"offer",sdp:o});return Promise.resolve(a)},s.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(P("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(P("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var n=A.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(n+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),n+="a=ice-options:trickle\r\n";var s=A.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,i){if(!(i+1>s)){if(e.rejected)return "application"===e.kind?"DTLS/SCTP"===e.protocol?n+="m=application 0 DTLS/SCTP 5000\r\n":n+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?n+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(n+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(n+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var o;if(e.stream)"audio"===e.kind?o=e.stream.getAudioTracks()[0]:"video"===e.kind&&(o=e.stream.getVideoTracks()[0]),o&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var a=N(e.localCapabilities,e.remoteCapabilities);!a.codecs.filter((function(e){return "rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,n+=v(e,a,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(n+="a=rtcp-rsize\r\n");}}));var i=new e.RTCSessionDescription({type:"answer",sdp:n});return Promise.resolve(i)},s.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(n,s){if(!r._remoteDescription)return s(P("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var i=e.sdpMLineIndex;if(e.sdpMid)for(var o=0;o0?A.parseCandidate(e.candidate):{};if("tcp"===c.protocol&&(0===c.port||9===c.port))return n();if(c.component&&1!==c.component)return n();if((0===i||i>0&&a.iceTransport!==r.transceivers[0].iceTransport)&&!y(a.iceTransport,c))return s(P("OperationError","Can not add ICE candidate"));var d=e.candidate.trim();0===d.indexOf("a=")&&(d=d.substr(2)),(t=A.getMediaSections(r._remoteDescription.sdp))[i]+="a="+(c.type?d:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=A.getDescription(r._remoteDescription.sdp)+t.join("");}else for(var l=0;lPromise.reject(function(e){return {name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e)))};}function w(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)));}function b(e){const t=c(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const r=new Event("enabled");r.enabled=e,this.dispatchEvent(r);}});}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const r=M(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e,t){let r=!1;return (e=JSON.parse(JSON.stringify(e))).filter(e=>{if(e&&(e.urls||e.url)){var t=e.urls||e.url;e.url&&!e.urls&&a("RTCIceServer.url","RTCIceServer.urls");const n="string"==typeof t;return n&&(t=[t]),t=t.filter(e=>{if(0===e.indexOf("stun:"))return !1;const t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!r?(r=!0,!0):t&&!r}),delete e.url,e.urls=n?t[0]:t,!!t.length}})}(e.iceServers,t.version),o("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype;}function L(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack);}var G=Object.freeze({shimPeerConnection:b,shimReplaceTrack:L,shimGetUserMedia:k,shimGetDisplayMedia:w});function U(e){const t=c(e),r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){a("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n);},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t]);},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return "object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r};}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(r){return "audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])};}}}function F(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return {receiver:this.receiver}}});}function B(e){const t=c(e);if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;if(!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t];})),t.version<68){const t=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?arguments[0]&&""===arguments[0].candidate?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())};}const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,s,i]=arguments;return n.apply(this,[e||null]).then(e=>{if(t.version<53&&!s)try{e.forEach(e=>{e.type=r[e.type]||e.type;});}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,n)=>{e.set(n,Object.assign({},t,{type:r[t.type]||t.type}));});}return e}).then(s,i)};}function x(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)};}function V(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),n(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)};}function H(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){a("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t);});});}function j(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel);}function W(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const n=t.apply(this,arguments);if(r){const{sender:t}=n,r=t.getParameters();"encodings"in r||(r.encodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).catch(()=>{})));}return n});}function K(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[];}):t.apply(this,arguments)};}function $(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[];}):t.apply(this,arguments)};}var Y=Object.freeze({shimOnTrack:F,shimPeerConnection:B,shimSenderGetStats:x,shimReceiverGetStats:V,shimRemoveStream:H,shimRTCDataChannel:j,shimAddTransceiver:W,shimCreateOffer:K,shimCreateAnswer:$,shimGetUserMedia:U,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return !0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)});}});function z(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(r=>t.call(this,r,e)),e.getVideoTracks().forEach(r=>t.call(this,r,e));},e.RTCPeerConnection.prototype.addTrack=function(e,...r){return r&&r.forEach(e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e];}),t.apply(this,arguments)};}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach(e=>{r.includes(e.track)&&this.removeTrack(e);});});}}function J(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t);});});}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const r=new Event("addstream");r.stream=t,e.dispatchEvent(r);});}),t.apply(e,arguments)};}}function Q(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,s=t.setLocalDescription,i=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:e,s=r.apply(this,[n]);return t?(s.then(e,t),Promise.resolve()):s},t.createAnswer=function(e,t){const r=arguments.length>=2?arguments[2]:e,s=n.apply(this,[r]);return t?(s.then(e,t),Promise.resolve()):s};let a=function(e,t,r){const n=s.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=a,a=function(e,t,r){const n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=a,a=function(e,t,r){const n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=a;}function X(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r(q(e));}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n);}.bind(t));}function q(e){return e&&void 0!==e.video?Object.assign({},e,{video:l(e.video)}):e}function Z(e){const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;rt.generateCertificate});}function ee(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return {receiver:this.receiver}}});}function te(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find(e=>"audio"===e.receiver.track.kind);!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const r=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video");}return t.apply(this,arguments)};}var re=Object.freeze({shimLocalStreamsAPI:z,shimRemoteStreamsAPI:J,shimCallbacksAPI:Q,shimGetUserMedia:X,shimConstraints:q,shimRTCIceServerUrls:Z,shimTrackEventTransceiver:ee,shimCreateOfferLegacy:te});function ne(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const r=new t(e),n=A.parseCandidate(e.candidate),s=Object.assign(r,n);return s.toJSON=function(){return {candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,n(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t));}function se(e){if(!e.RTCPeerConnection)return;const t=c(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const r=function(e){if(!e||!e.sdp)return !1;const t=A.splitSections(e.sdp);return t.shift(),t.some(e=>{const t=A.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})},n=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return -1;const r=parseInt(t[1],10);return r!=r?-1:r},s=function(e){let r=65536;return "firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},i=function(e,r){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const s=A.matchPrefix(e.sdp,"a=max-message-size:");return s.length>0?n=parseInt(s[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},o=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0});}if(r(arguments[0])){const e=n(arguments[0]),t=s(e),r=i(arguments[0],e);let o;o=0===t&&0===r?Number.POSITIVE_INFINITY:0===t||0===r?Math.max(t,r):Math.min(t,r);const a={};Object.defineProperty(a,"maxMessageSize",{get:()=>o}),this._sctp=a;}return o.apply(this,arguments)};}function ie(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const r=e.send;e.send=function(){const n=arguments[0],s=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&s>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)};}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},n(e,"datachannel",e=>(t(e.channel,e.target),e));}function oe(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return {completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e);},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const r=new Event("connectionstatechange",e);t.dispatchEvent(r);}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)};});}function ae(e){if(!e.RTCPeerConnection)return;const t=c(e);if("chrome"===t.browser&&t.version>=71)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(e){return e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")&&(e.sdp=e.sdp.split("\n").filter(e=>"a=extmap-allow-mixed"!==e.trim()).join("\n")),r.apply(this,arguments)};}var ce=Object.freeze({shimRTCIceCandidate:ne,shimMaxMessageSize:se,shimSendThrowTypeError:ie,shimConnectionState:oe,removeAllowExtmapMixed:ae});const de=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const n=o,a=c(e),d={browserDetails:a,commonShim:ce,extractVersion:r,disableLog:s,disableWarnings:i};switch(a.browser){case"chrome":if(!C||!_||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),d;n("adapter.js shimming chrome."),d.browserShim=C,S(e),E(e),_(e),h(e),T(e),m(e),g(e),R(e),I(e),ne(e),oe(e),se(e),ie(e),ae(e);break;case"firefox":if(!Y||!B||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),d;n("adapter.js shimming firefox."),d.browserShim=Y,U(e),B(e),F(e),H(e),x(e),V(e),j(e),W(e),K(e),$(e),ne(e),oe(e),se(e),ie(e);break;case"edge":if(!G||!b||!t.shimEdge)return n("MS edge shim is not included in this adapter release."),d;n("adapter.js shimming edge."),d.browserShim=G,k(e),w(e),b(e),L(e),se(e),ie(e);break;case"safari":if(!re||!t.shimSafari)return n("Safari shim is not included in this adapter release."),d;n("adapter.js shimming safari."),d.browserShim=re,Z(e),te(e),Q(e),z(e),J(e),ee(e),X(e),ne(e),se(e),ie(e),ae(e);break;default:n("Unsupported browser!");}return d}({window:window});de.options=de.options||{},de.onwebrtcreadyDone=!1,de.WebRTCPlugin={plugin:null},de._onwebrtcreadies=[],de.webRTCReady=function(e){if("function"!=typeof e)throw new Error("Callback provided is not a function");var t=function(){"function"==typeof window.require&&"function"==typeof de._defineMediaSourcePolyfill&&de._defineMediaSourcePolyfill(),e(null!==de.WebRTCPlugin.plugin);};!0===de.onwebrtcreadyDone?t():de._onwebrtcreadies.push(t);},de.maybeThroughWebRTCReady=function(){de.onwebrtcreadyDone||(de.onwebrtcreadyDone=!0,de._onwebrtcreadies.length?de._onwebrtcreadies.forEach((function(e){"function"==typeof e&&e(null!==de.WebRTCPlugin.plugin);})):"function"==typeof de.onwebrtcready&&de.onwebrtcready(null!==de.WebRTCPlugin.plugin));},window.webrtcDetectedBrowser=null,window.webrtcDetectedVersion=null,window.webrtcMinimumVersion=null,window.webrtcDetectedDCSupport=null,de.parseWebrtcDetectedBrowser=function(){var e=null;if(window.navigator.userAgent.match(/React-Native/gi)||navigator.userAgent.match(/React-Native/gi))window.webrtcDetectedBrowser="react-native",window.webrtcDetectedVersion="",window.webrtcMinimumVersion=0,window.webrtcDetectedType="react-native",window.webrtcDetectedDCSupport=null;else if(window.opr&&opr.addons||window.opera||navigator.userAgent.indexOf(" OPR/")>=0)e=navigator.userAgent.match(/OPR\/(\d+)/i)||[],window.webrtcDetectedBrowser="opera",window.webrtcDetectedVersion=parseInt(e[1]||"0",10),window.webrtcMinimumVersion=26,window.webrtcDetectedType="webkit",window.webrtcDetectedDCSupport="SCTP";else if(navigator.userAgent.match(/Bowser\/[0-9.]*/g)){e=navigator.userAgent.match(/Bowser\/[0-9.]*/g)||[];var t=parseInt((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./i)||[])[2]||"0",10);window.webrtcDetectedBrowser="bowser",window.webrtcDetectedVersion=parseFloat((e[0]||"0/0").split("/")[1],10),window.webrtcMinimumVersion=0,window.webrtcDetectedType="webkit",window.webrtcDetectedDCSupport=t>30?"SCTP":"RTP";}else if(navigator.userAgent.indexOf("OPiOS")>0)e=navigator.userAgent.match(/OPiOS\/([0-9]+)\./),window.webrtcDetectedBrowser="opera",window.webrtcDetectedVersion=parseInt(e[1]||"0",10),window.webrtcMinimumVersion=0,window.webrtcDetectedType=null,window.webrtcDetectedDCSupport=null;else if(navigator.userAgent.indexOf("CriOS")>0)e=navigator.userAgent.match(/CriOS\/([0-9]+)\./)||[],window.webrtcDetectedVersion=parseInt(e[1]||"0",10),window.webrtcMinimumVersion=0,window.webrtcDetectedType=null,window.webrtcDetectedBrowser="chrome",window.webrtcDetectedDCSupport=null;else if(navigator.userAgent.indexOf("FxiOS")>0)e=navigator.userAgent.match(/FxiOS\/([0-9]+)\./)||[],window.webrtcDetectedBrowser="firefox",window.webrtcDetectedVersion=parseInt(e[1]||"0",10),window.webrtcMinimumVersion=0,window.webrtcDetectedType=null,window.webrtcDetectedDCSupport=null;else if(document.documentMode)e=/\brv[ :]+(\d+)/g.exec(navigator.userAgent)||[],window.webrtcDetectedBrowser="IE",window.webrtcDetectedVersion=parseInt(e[1],10),window.webrtcMinimumVersion=9,window.webrtcDetectedType="plugin",window.webrtcDetectedDCSupport="SCTP",webrtcDetectedVersion||(e=/\bMSIE[ :]+(\d+)/g.exec(navigator.userAgent)||[],window.webrtcDetectedVersion=parseInt(e[1]||"0",10));else if(window.StyleMedia||navigator.userAgent.match(/Edge\/(\d+).(\d+)$/))e=navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)||[],window.webrtcDetectedBrowser="edge",window.webrtcDetectedVersion=parseFloat((e[0]||"0/0").split("/")[1],10),window.webrtcMinimumVersion=13.10547,window.webrtcDetectedType="ms",window.webrtcDetectedDCSupport=null;else if("undefined"!=typeof InstallTrigger||navigator.userAgent.indexOf("irefox")>0)e=navigator.userAgent.match(/Firefox\/([0-9]+)\./)||[],window.webrtcDetectedBrowser="firefox",window.webrtcDetectedVersion=parseInt(e[1]||"0",10),window.webrtcMinimumVersion=33,window.webrtcDetectedType="moz",window.webrtcDetectedDCSupport="SCTP";else if(window.chrome&&window.chrome.webstore||navigator.userAgent.indexOf("Chrom")>0)e=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./i)||[],window.webrtcDetectedBrowser="chrome",window.webrtcDetectedVersion=parseInt(e[2]||"0",10),window.webrtcMinimumVersion=38,window.webrtcDetectedType="webkit",window.webrtcDetectedDCSupport=window.webrtcDetectedVersion>30?"SCTP":"RTP";else if(/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||safari.pushNotification).toString()||navigator.userAgent.match(/AppleWebKit\/(\d+)\./)||navigator.userAgent.match(/Version\/(\d+).(\d+)/)){e=navigator.userAgent.match(/version\/(\d+)\.(\d+)/i)||[];var r=navigator.userAgent.match(/AppleWebKit\/(\d+)/i)||[],n=navigator.userAgent.match(/(iPhone|iPad)/gi),s=r.length>=1&&r[1]>=604;if(window.webrtcDetectedBrowser="safari",window.webrtcDetectedVersion=parseInt(e[1]||"0",10),window.webrtcMinimumVersion=7,n)window.webrtcDetectedType=s?"AppleWebKit":null;else{var i=window.webrtcDetectedVersion,o=parseInt(e[2]||"0",10),a=11==i&&o<2;window.webrtcDetectedType=!s||de.options.forceSafariPlugin&&a?"plugin":"AppleWebKit";}window.webrtcDetectedDCSupport="SCTP";}de.webrtcDetectedBrowser=window.webrtcDetectedBrowser,de.webrtcDetectedVersion=window.webrtcDetectedVersion,de.webrtcMinimumVersion=window.webrtcMinimumVersion,de.webrtcDetectedType=window.webrtcDetectedType,de.webrtcDetectedDCSupport=window.webrtcDetectedDCSupport;},de.addExtensions=function(){var e=null,t=null;navigator.mozGetUserMedia?(e=function(e,t){return e.srcObject=t,e},t=function(e,t){return e.srcObject=t.srcObject,e}):navigator.webkitGetUserMedia?(e=function(e,t){return de.webrtcDetectedVersion>=43?e.srcObject=t:void 0!==e.src?e.src=URL.createObjectURL(t):console.error("Error attaching stream to element."),e},t=function(e,t){return de.webrtcDetectedVersion>=43?e.srcObject=t.srcObject:e.src=t.src,e}):"AppleWebKit"===de.webrtcDetectedType&&(e=function(e,t){return e.srcObject=t,e},t=function(e,t){return e.srcObject=t.srcObject,e}),window.attachMediaStream=e,window.reattachMediaStream=t,de.attachMediaStream=e,de.reattachMediaStream=t;},de.parseWebrtcDetectedBrowser(),de.addExtensions(),de.maybeThroughWebRTCReady();var le=Object.freeze({ON_INCOMING_STREAM:"onIncomingStream",ON_INCOMING_SCREEN_STREAM:"onIncomingScreenStream",STREAM_ENDED:"streamEnded",PEER_UPDATED:"peerUpdated",PEER_JOINED:"peerJoined",PEER_LEFT:"peerLeft",PEER_CONNECTION_STATE:"peerConnectionState",DATA_CHANNEL_STATE:"dataChannelState",ON_INCOMING_MESSAGE:"onIncomingMessage",HANDSHAKE_PROGRESS:"handshakeProgress",SERVER_PEER_JOINED:"serverPeerJoined",SERVER_PEER_LEFT:"serverPeerLeft",CANDIDATE_PROCESSING_STATE:"candidateProcessingState",CANDIDATE_GENERATION_STATE:"candidateGenerationState",CANDIDATES_GATHERED:"candidatesGathered",DATA_STREAM_STATE:"dataStreamState",DATA_TRANSFER_STATE:"dataTransferState",ON_INCOMING_DATA:"onIncomingData",ON_INCOMING_DATA_REQUEST:"onIncomingDataRequest",ON_INCOMING_DATA_STREAM:"onIncomingDataStream",ON_INCOMING_DATA_STREAM_STARTED:"onIncomingDataStreamStarted",ON_INCOMING_DATA_STREAM_STOPPED:"onIncomingDataStreamStopped",GET_PEERS_STATE_CHANGE:"getPeersStateChange",SESSION_DISCONNECT:"sessionDisconnect",STREAM_MUTED:"streamMuted",CHANNEL_OPEN:"channelOpen",CHANNEL_REOPEN:"channelReopen",CHANNEL_CLOSE:"channelClose",CHANNEL_MESSAGE:"channelMessage",CHANNEL_ERROR:"channelError",CHANNEL_RETRY:"channelRetry",SOCKET_ERROR:"socketError",SYSTEM_ACTION:"systemAction",MEDIA_ACCESS_FALLBACK:"mediaAccessFallback",MEDIA_ACCESS_REQUIRED:"mediaAccessRequired",MEDIA_ACCESS_STOPPED:"mediaAccessStopped",MEDIA_ACCESS_SUCCESS:"mediaAccessSuccess",RECORDING_STATE:"recordingState",LOCAL_MEDIA_MUTED:"localMediaMuted",MEDIA_ACCESS_ERROR:"mediaAccessError",GET_CONNECTION_STATUS_STATE_CHANGE:"getConnectionStatusStateChange",READY_STATE_CHANGE:"readyStateChange",ROOM_LOCK:"roomLock",INTRODUCE_STATE_CHANGE:"introduceStateChange",ICE_CONNECTION_STATE:"iceConnectionState",BYE:"bye",RTMP_STATE:"rtmpState",LOGGED_ON_CONSOLE:"loggedOnConsole",MEDIA_INFO_DELETED:"mediaInfoDeleted",STORED_MESSAGES:"storedMessages",ENCRYPT_SECRETS_UPDATED:"encryptSecretsUpdated",PERSISTENT_MESSAGE_STATE:"persistentMessageState",ROOM_REJOIN:"roomRejoin"});class pe{constructor(e,t){this.name=e,this.detail=t;}}const ue=(e={})=>new pe("onIncomingStream",{detail:e}),Se=(e={})=>new pe("onIncomingScreenStream",{detail:e}),Ee=(e={})=>new pe("streamEnded",{detail:e}),he=(e={})=>new pe("streamMuted",{detail:e}),me=(e={})=>new pe("dataChannelState",{detail:e}),ge=(e={})=>new pe("onIncomingMessage",{detail:e}),Re=(e={})=>new pe("handshakeProgress",{detail:e}),fe=(e={})=>new pe("readyStateChange",{detail:e}),Te=e=>new pe("candidateProcessingState",{detail:e}),_e=e=>new pe("candidateGenerationState",{detail:e}),Ie=e=>new pe("iceConnectionState",{detail:e}),Ce=(e={})=>new pe("peerUpdated",{detail:e}),Oe=(e={})=>new pe("peerJoined",{detail:e}),Ae=(e={})=>new pe("peerLeft",{detail:e}),ve=(e={})=>new pe("serverPeerLeft",{detail:e}),Ne=(e={})=>new pe("getPeersStateChange",{detail:e}),De=(e={})=>new pe("peerConnectionState",{detail:e}),ye=(e={})=>new pe("getConnectionStatusStateChange",{detail:e}),Pe=e=>new pe("socketError",{detail:e}),Me=(e={})=>new pe("mediaAccessFallback",{detail:e}),ke=(e={})=>new pe("rtmpState",{detail:e}),we=(e={})=>new pe("mediaAccessError",{detail:e}),be={CONNECTING:"connecting",OPEN:"open",CLOSING:"closing",CLOSED:"closed",ERROR:"error",CREATE_ERROR:"createError",BUFFERED_AMOUNT_LOW:"bufferedAmountLow",SEND_MESSAGE_ERROR:"sendMessageError"},Le={MESSAGING:"messaging",DATA:"data"},Ge={MESSAGE:"message",TRANSFER:"transfer"},Ue={REQUEST:"request",SUCCESS:"success",ERROR:"error"},Fe={NEW:"new",GATHERING:"gathering",COMPLETED:"complete"},Be={RECEIVED:"received",DROPPED:"dropped",BUFFERED:"buffered",PROCESSING:"processing",PROCESS_SUCCESS:"processSuccess",PROCESS_ERROR:"processError"},xe={STARTING:"starting",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",CLOSED:"closed",FAILED:"failed",DISCONNECTED:"disconnected"},Ve={UDP:"udp",TCP:"tcp",ANY:"any",NONE:"none",ALL:"all"},He={STABLE:"stable",HAVE_LOCAL_OFFER:"have-local-offer",HAVE_REMOTE_OFFER:"have-remote-offer",CLOSED:"closed",CONNECTING:"connecting",FAILED:"failed",DISCONNECTED:"disconnected",CONNECTED:"connected"},je={RETRIEVING:0,RETRIEVE_SUCCESS:1,RETRIEVE_ERROR:-1},We={MCU:"mcu"},Ke={MAX_COMPAT:"max-compat",BALANCED:"balanced",MAX_BUNDLE:"max-bundle",NONE:"none"},$e={REQUIRE:"require",NEGOTIATE:"negotiate"},Ye={ENTER:"enter",WELCOME:"welcome",OFFER:"offer",ANSWER:"answer",ANSWER_ACK:"answerAck",ERROR:"error"},ze={ENQUIRED:"enquired",DISPATCHED:"dispatched",RECEIVED:"received"},Je={WARNING:"warning",REJECT:"reject",LOCKED:"locked"},Qe={INIT:0,LOADING:1,COMPLETED:2,ERROR:-1},Xe={API_INVALID:4001,API_DOMAIN_NOT_MATCH:4002,API_CORS_DOMAIN_NOT_MATCH:4003,API_CREDENTIALS_INVALID:4004,API_CREDENTIALS_NOT_MATCH:4005,API_INVALID_PARENT_KEY:4006,API_NO_MEETING_RECORD_FOUND:4010,API_OVER_SEAT_LIMIT:4020,API_RETRIEVAL_FAILED:4021,API_WRONG_ACCESS_DOMAIN:5005,XML_HTTP_REQUEST_ERROR:-1,XML_HTTP_NO_REPONSE_ERROR:-2,NO_SOCKET_IO:1,NO_XMLHTTPREQUEST_SUPPORT:2,NO_WEBRTC_SUPPORT:3,NO_PATH:4,ADAPTER_NO_LOADED:7,PARSE_CODECS:8},qe={CONNECTION_FAILED:0,RECONNECTION_FAILED:-1,CONNECTION_ABORTED:-2,RECONNECTION_ABORTED:-3,RECONNECTION_ATTEMPT:-4},Ze={NON_FALLBACK:"nonfallback",FALLBACK_PORT:"fallbackPortNonSSL",FALLBACK_SSL_PORT:"fallbackPortSSL",LONG_POLLING:"fallbackLongPollingNonSSL",LONG_POLLING_SSL:"fallbackLongPollingSSL"},et={AUTO:"auto",VP8:"VP8",H264:"H264",VP9:"VP9"},tt={AUTO:"auto",ISAC:"ISAC",OPUS:"opus",ILBC:"ILBC",G722:"G722",PCMU:"PCMU",PCMA:"PCMA"},rt={QQVGA:{width:160,height:120},HQVGA:{width:240,height:160},QVGA:{width:320,height:240},WQVGA:{width:384,height:240},HVGA:{width:480,height:320},VGA:{width:640,height:480},WVGA:{width:768,height:480},FWVGA:{width:854,height:480},SVGA:{width:800,height:600},DVGA:{width:960,height:640},WSVGA:{width:1024,height:576},HD:{width:1280,height:720},HDPLUS:{width:1600,height:900},FHD:{width:1920,height:1080},QHD:{width:2560,height:1440},WQXGAPLUS:{width:3200,height:1800},UHD:{width:3840,height:2160},UHDPLUS:{width:5120,height:2880},FUHD:{width:7680,height:4320},QUHD:{width:15360,height:8640}},nt={FALLBACKING:0,FALLBACKED:1,ERROR:-1},st={START:0,STOP:1,LINK:2,ERROR:-1},it={WRQ:"WRQ",ACK:"ACK",ERROR:"ERROR",CANCEL:"CANCEL",MESSAGE:"MESSAGE"},ot={JOIN_ROOM:"joinRoom",IN_ROOM:"inRoom",ENTER:"enter",WELCOME:"welcome",OFFER:"offer",ANSWER:"answer",ANSWER_ACK:"answerAck",CANDIDATE:"candidate",BYE:"bye",REDIRECT:"redirect",UPDATE_USER:"updateUserEvent",ROOM_LOCK:"roomLockEvent",PUBLIC_MESSAGE:"public",PRIVATE_MESSAGE:"private",STREAM:"stream",GROUP:"group",GET_PEERS:"getPeers",PEER_LIST:"peerList",INTRODUCE:"introduce",INTRODUCE_ERROR:"introduceError",APPROACH:"approach",START_RECORDING:"startRecordingRoom",STOP_RECORDING:"stopRecordingRoom",RECORDING:"recordingEvent",END_OF_CANDIDATES:"endOfCandidates",START_SCREENSHARE:"startScreenshare",START_RTMP:"startRTMP",STOP_RTMP:"stopRTMP",RTMP:"rtmpEvent",MEDIA_INFO_EVENT:"mediaInfoEvent",MESSAGE:"message",GET_STORED_MESSAGES:"getStoredMessages",STORED_MESSAGES:"storedMessages",RESTART:"restart"},at={ENDED:"ended"},ct=[ot.STREAM,ot.UPDATE_USER,ot.PUBLIC_MESSAGE],dt={PLAN_B:"plan-b",UNIFIED:"unified-plan"},lt={START:0,STOP:1,ERROR:-1},pt={MUTED:0,ACTIVE:1,UNAVAILABLE:-1},ut={SKYLINK_EVENT:"SKYLINK EVENT",SKYLINK_ERROR:"SKYLINK ERROR",STATS_MODULE:"RTCStatsReport",SESSION_DESCRIPTION:"RTCSessionDescription",PEER_CONNECTION:"RTCPeerConnection",CANDIDATE_HANDLER:"RTCIceCandidate",DATA_CHANNEL:"RTCDataChannel",SIG_SERVER:"SIG SERVER",PEER_MEDIA:"PEER MEDIA",PEER_INFORMATION:"PEER INFORMATION",ROOM:"ROOM",RECORDING:"RECORDING",MEDIA_STREAM:"MEDIA STREAM",MESSAGING:"MESSAGING",ASYNC_MESSAGING:"ASYNC MESSAGING",ENCRYPTED_MESSAGING:"ENCRYPTED MESSAGING",STATS:"STATS"},St={AUDIO_MIC:"audioMic",VIDEO_CAMERA:"videoCamera",VIDEO_SCREEN:"videoScreen",VIDEO_OTHER:"videoOther",AUDIO:"audio",VIDEO:"video"},Et={LIVE:"live",ENDED:"ended"},ht={AUDIO:"audio",VIDEO:"video"},mt={MUTED:"muted",ACTIVE:"active",STOPPED:"stopped",UNAVAILABLE:"unavailable"},gt={PUBLISHER_ID:"publisherId",MEDIA_ID:"mediaId",MEDIA_TYPE:"mediaType",MEDIA_STATE:"mediaState",TRANSCEIVER_MID:"transceiverMid",MEDIA_META_DATA:"mediaMetaData",SIMULCAST:"simulcast",STREAM_ID:"streamId"},Rt={WEB:"Web SDK",ANDROID:"Android SDK",IOS:"iOS SDK",CPP:"C++ SDK"},ft={CHROME:"chrome",FIREFOX:"firefox",SAFARI:"safari",REACT_NATIVE:"react-native"},Tt={MCU:"MCU"},_t={CONNECT:"connect",DISCONNECT:"disconnect",RECONNECT_ATTEMPT:"reconnect_attempt",RECONNECT_SUCCESS:"reconnect_success",RECONNECT_FAILED:"reconnect_failed",RECONNECT_ERROR:"reconnect_error",MESSAGE:"message",ERROR:"error"},It={POLLING:"Polling",WEBSOCKET:"WebSocket",XHR_POLLING:"xhr-polling",JSONP_POLLING:"jsonp-polling"},Ct={SIGNALING:_t},Ot=le;var At=Object.freeze({DATA_CHANNEL_STATE:be,DATA_CHANNEL_TYPE:Le,DATA_CHANNEL_MESSAGE_ERROR:Ge,DATA_TRANSFER_DATA_TYPE:{BINARY_STRING:"binaryString",ARRAY_BUFFER:"arrayBuffer",BLOB:"blob",STRING:"string"},DT_PROTOCOL_VERSION:"0.1.3",DATA_TRANSFER_TYPE:{UPLOAD:"upload",DOWNLOAD:"download"},DATA_TRANSFER_SESSION_TYPE:{BLOB:"blob",DATA_URL:"dataURL"},DATA_TRANSFER_STATE:{UPLOAD_REQUEST:"request",UPLOAD_STARTED:"uploadStarted",DOWNLOAD_STARTED:"downloadStarted",REJECTED:"rejected",CANCEL:"cancel",ERROR:"error",UPLOADING:"uploading",DOWNLOADING:"downloading",UPLOAD_COMPLETED:"uploadCompleted",DOWNLOAD_COMPLETED:"downloadCompleted",USER_REJECTED:"userRejected",USER_UPLOAD_REQUEST:"userRequest",START_ERROR:"startError"},AUTH_STATE:Ue,DATA_STREAM_STATE:{SENDING_STARTED:"sendStart",SENDING_STOPPED:"sendStop",RECEIVING_STARTED:"receiveStart",RECEIVING_STOPPED:"receiveStop",RECEIVED:"received",SENT:"sent",ERROR:"error",START_ERROR:"startError"},CANDIDATE_GENERATION_STATE:Fe,CANDIDATE_PROCESSING_STATE:Be,ICE_CONNECTION_STATE:xe,TURN_TRANSPORT:Ve,PEER_CONNECTION_STATE:He,GET_CONNECTION_STATUS_STATE:je,SERVER_PEER_TYPE:We,BUNDLE_POLICY:Ke,RTCP_MUX_POLICY:$e,PEER_CERTIFICATE:{RSA:"RSA",ECDSA:"ECDSA",AUTO:"AUTO"},HANDSHAKE_PROGRESS:Ye,GET_PEERS_STATE:ze,INTRODUCE_STATE:{INTRODUCING:"introducing",ERROR:"error"},SYSTEM_ACTION:Je,SYSTEM_ACTION_REASON:{CREDENTIALS_EXPIRED:"oldTimeStamp",CREDENTIALS_ERROR:"credentialError",DUPLICATED_LOGIN:"duplicatedLogin",ROOM_NOT_STARTED:"notStart",EXPIRED:"expired",ROOM_LOCKED:"locked",FAST_MESSAGE:"fastmsg",ROOM_CLOSING:"toclose",ROOM_CLOSED:"roomclose",SERVER_ERROR:"serverError",KEY_ERROR:"keyFailed"},READY_STATE_CHANGE:Qe,READY_STATE_CHANGE_ERROR:Xe,REGIONAL_SERVER:{APAC1:"",US1:""},LOG_LEVEL:{DEBUG:4,LOG:3,INFO:2,WARN:1,ERROR:0,NONE:-1},SOCKET_ERROR:qe,SOCKET_FALLBACK:Ze,SM_PROTOCOL_VERSION:"2.1.0",VIDEO_CODEC:et,AUDIO_CODEC:tt,MEDIA_SOURCE:{SCREEN:"screen",WINDOW:"window",TAB:"tab",TAB_AUDIO:"audio",APPLICATION:"application",BROWSER:"browser",CAMERA:"camera"},VIDEO_RESOLUTION:rt,MEDIA_ACCESS_FALLBACK_STATE:nt,RECORDING_STATE:st,CHUNK_FILE_SIZE:49152,MOZ_CHUNK_FILE_SIZE:12288,BINARY_FILE_SIZE:65456,MOZ_BINARY_FILE_SIZE:16384,CHUNK_DATAURL_SIZE:1212,DC_PROTOCOL_TYPE:it,SIG_MESSAGE_TYPE:ot,STREAM_STATUS:at,GROUP_MESSAGE_LIST:ct,VIDEO_QUALITY:{HD:{video:3200,audio:150},HQ:{video:1200,audio:80},SQ:{video:800,audio:30},LQ:{video:400,audio:20}},SDP_SEMANTICS:dt,RTMP_STATE:lt,MEDIA_STATUS:pt,TAGS:ut,MEDIA_TYPE:St,TRACK_READY_STATE:Et,TRACK_KIND:ht,MEDIA_STATE:mt,MEDIA_INFO:gt,SDK_VERSION:"2.x.x",SDK_NAME:Rt,API_VERSION:"9.0.0",SIGNALING_VERSION:"sig-v2",BROWSER_AGENT:ft,PEER_TYPE:Tt,SOCKET_EVENTS:_t,SOCKET_TYPE:It,STATES:Ct,EVENTS:Ot});const vt={INIT:{ERRORS:{NO_ADAPTER:"AdapterJS dependency is not loaded or incorrect AdapterJS dependency is used",NO_SOCKET_IO:"Socket.io not loaded - Please load socket.io",NO_FETCH_SUPPORT:"Fetch API is not supported in your browser. Please make sure you are using a modern browser: https://caniuse.com/#search=fetch",NO_APP_KEY:"Please provide an App Key - Get one at console.temasys.io!",AUTH_CORS:"Promise rejected due to CORS forbidden request - Please visit: http://support.temasys.com.sg/support/solutions/articles/12000006761-i-get-a-403-forbidden-access-is-denied-when-i-load-the-application-why-",AUTH_GENERAL:"Promise rejected due to network issue",SOCKET_CREATE_FAILED:"Failed creating socket connection object ->",SOCKET_ERROR_ABORT:"Reconnection aborted as the connection timed out or there no more available ports, transports and final attempts left"},INCOMPATIBLE_BROWSER:"Incompatible browser agent detected",INFO:{API_SUCCESS:"Promise resolved: APP Authenticated Successfully!"}},SOCKET:{ABORT_RECONNECT:"Aborting socket reconnect"},JOIN_ROOM:{ERRORS:{CODEC_SUPPORT:"No audio/video codecs available to start connection"}},ROOM:{ERRORS:{STOP:{SCREEN_SHARE:"Error stopping screenshare"},NOT_IN_ROOM:"User is not in room",NO_PEERS:"No peers in room"},LEAVE_ROOM:{ERROR:"Leave room error --\x3e",NO_PEERS:"No peers in room",DROPPING_HANGUP:"Dropping hang-up from remote peer",LEAVE_ALL_ROOMS:{SUCCESS:"Successfully left all rooms",ERROR:"Leave all rooms error --\x3e"},PEER_LEFT:{START:"Initiating peer left process",SUCCESS:"Successfully completed peer left process",ERROR:"Failed peer left process"},SENDING_BYE:"Sending bye message to all peers",DISCONNECT_SOCKET:{SUCCESS:"Successfully disconnected socket"},REMOVE_STATE:{SUCCESS:"Successfully removed room state"}}},ROOM_STATE:{NOT_FOUND:"Could not retrieve room state for room name/key",LEFT:"Peer left room",NO_ROOM_NAME:"No room name specified"},PEER_INFORMATIONS:{NO_PEER_INFO:"Not able to retrieve Peer Information for peerId:",UPDATE_USER_DATA:"Peer updated userData: ",OUTDATED_MSG:"Dropping outdated status ->",USER_DATA_NOT_JSON:"UserData is not JSON",SET_PEER_PRIORITY_WEIGHT:"Setting peerPriorityWeight with tiebreaker value from inRoom signalling message"},PEER_CONNECTION:{NOT_INITIALISED:"Peer Connection not initialised",CREATE_NEW:"Creating new Peer Connection",NO_PEER_CONNECTION:"No Peer Connection detected",PEER_ID_NOT_FOUND:"Peer Id not found",STATE_CHANGE:"Peer connection state changed ->",STATS_API_UNAVAILABLE:"getStats() API is not available",MCU:"MCU connected",FAILED_STATE:"Peer Connection state: failed",ADD_TRANSCEIVER:"Adding empty transceiver",ERRORS:{REMOVE_TRACK:"Error removing track from peer connection",NOT_FOUND:"Peer Connection not found"},REFRESH_CONNECTION:{START:"Refreshing peer connections",SUCCESS:"Peer Connection refreshed successfully",FAILED:"Peer Connection failed to refresh",COMPLETED:"All Peer Connections refreshed with resolve or errors",RESTART_ICE_UNAVAILABLE:"Dropping iceRestart option as it is not available on the peer connection",NOT_SUPPORTED:"Refresh connection not supported by browser",SEND_RESTART_OFFER:"Sending restart offer message to signaling server",NO_LOCAL_DESCRIPTION:"No localDescription set to connection. There could be a handshaking step error."}},PEER_PRIVILEGED:{not_privileged:"Please upgrade your key to privileged to use this function",no_appkey:"App key is not defined - Please authenticate again",getPeerListFromServer:"Enquired server for peers within the App space"},ICE_CONNECTION:{END_OF_CANDIDATES_SUCCESS:"Signaling of end-of-candidates remote ICE gathering",END_OF_CANDIDATES_FAILURE:"Failed signaling of end-of-candidates remote ICE gathering",ICE_GATHERING_STARTED:"ICE gathering has started",ICE_GATHERING_COMPLETED:"ICE gathering has completed",DROP_EOC:"Dropping of sending ICE candidate end-of-candidates signal or unused ICE candidates ->",STATE_CHANGE:"Ice connection state changed ->"},ICE_CANDIDATE:{DROPPING_CANDIDATE:"Dropping ICE candidate",INVALID_CANDIDATE:"Received invalid ICE candidate message ->",VALID_CANDIDATE:"Received ICE candidate ->",FILTERED_CANDIDATE:"Dropping received ICE candidate as it matches ICE candidate filtering flag ->",FILTERING_FLAG_NOT_HONOURED:"Not dropping received ICE candidate as TURN connections are enforced as MCU is present (and act as a TURN itself) so filtering of ICE candidate flags are not honoured ->",CANDIDATE_ADDED:"Added ICE candidate successfully",ADDING_CANDIDATE:"Adding ICE Candidate",FAILED_ADDING_CANDIDATE:"Failed adding ICE candidate ->",ADD_BUFFERED_CANDIDATE:"Adding buffered ICE candidate",ADD_CANDIDATE_TO_BUFFER:"Adding ICE candidate to buffer",CANDIDATE_GENERATED:"Generated ICE candidate ->",SENDING_CANDIDATE:"Sending ICE candidate ->"},SESSION_DESCRIPTION:{parsing_media_ssrc:"Parsing session description media SSRCs ->"},DATA_CHANNEL:{reviving_dataChannel:"Reviving Datachannel connection",refresh_error:"Not a valid Datachannel connection",CLOSING:"Closing DataChannel",closed:"Datachannel has closed",onclose_error:"Error in data-channel onclose callback",NO_REMOTE_DATA_CHANNEL:"Remote peer does not have data channel",ERRORS:{FAILED_CLOSING:"Failed closing DataChannels --\x3e ",NO_SESSIONS:"Peer Connection does not have DataChannel sessions"}},NEGOTIATION_PROGRESS:{SET_LOCAL_DESCRIPTION:"Successfully set local description --\x3e",SET_REMOTE_DESCRIPTION:"Successfully set remote description --\x3e",APPLYING_BUFFERED_REMOTE_OFFER:"Applying buffered remote offer",ERRORS:{FAILED_SET_LOCAL_DESCRIPTION:"Failed setting local description --\x3e",FAILED_SET_REMOTE_DESCRIPTION:"Failed setting remote description",FAILED_SET_REMOTE_ANSWER:"Peer failed to set remote answer.",FAILED_RENEGOTIATION:"Failed renegotiation after answerAck",NOT_STABLE:"Dropping of message as signaling state is not stable",PROCESSING_EXISTING_SDP:"Dropping message as there is another sessionDescription being processed --\x3e",OFFER_TIEBREAKER:"Dropping the received offer: self weight is greater than incoming offer weight --\x3e",NO_LOCAL_BUFFERED_OFFER:"FATAL: No buffered local offer found - Unable to setLocalDescription",ADDING_REMOTE_OFFER_TO_BUFFER:"Adding remote offer received to buffer as current negotiation has not completed"}},SIGNALING:{MESSAGE_ADDED_TO_BUFFER:"Message buffered as enter message has not been sent",ENTER_LISTENER:"Enter listener initialized",BUFFERED_MESSAGES_SENT:"Buffered messages sent",BUFFERED_MESSAGES_DROPPED:"Buffered messages dropped - no mid",OUTDATED_MSG:"Dropping outdated status ->",DROPPING_MUTE_EVENT:"Dropping mute audio / video event message as it is processed by mediaInfoEvent",BUFFER_NOT_NEEDED:"Enter message sent. Messages do not need to be buffered",ABORTING_OFFER:"Aborting offer as current negotiation has not completed"},MESSAGING:{PRIVATE_MESSAGE:"Sending private message to Peer",BROADCAST_MESSAGE:"Broadcasting message to Peers",RECEIVED_MESSAGE:"Received message from Peer",PERSISTENCE:{SEND_MESSAGE:"Sending persisted message",NOT_PERSISTED:"Message will not be persisted as persistent flag is set to false",STORED_MESSAGES:"Received stored messages for room",IS_PERSISTENT_CONFIG:"Persistent message flag is set to",ERRORS:{FAILED_SETTING_PERSISTENCE:"Failed setting persistent message flag",INVALID_TYPE:"Persistent message flag must be of type boolean",PRIVATE_MESSAGE:"Cannot persist private messages",PERSISTENT_MESSAGE_FEATURE_NOT_ENABLED:"Persistent Message feature is not enabled. Enable this feature on the key under 'Advanced Settings' in the Temasys Console"}},ENCRYPTION:{SEND_MESSAGE:"Sending encrypted message",DELETE_ALL:"Deleting all stored secrets",ERRORS:{FAILED_DECRYPTING_MESSAGE:"Failed decrypting message",ENCRYPT_SECRET:"Incorrect secret provided",INVALID_SECRETS:"No or invalid secret and secret id provided",SET_SELECTED_SECRET:"Failed setting selected secret",DELETE_ENCRYPT_SECRETS:"Failed deleting secret",SET_ENCRYPT_SECRET:"Failed setting secret",SECRET_ID_NOT_FOUND:"Secret id not found",NO_SECRET_OR_SECRET_ID:"Secret and / or secret id not provided",INVALID_TYPE:"Secret and secret id must be of type string and not empty",SECRET_ID_NOT_UNIQUE:"Secret id provided is not unique",SECRET_ID_NOT_SELECTED:"Secret id not selected",SECRET_ID_NOT_PROVIDED:"Secret id not provided",SECRETS_NOT_PROVIDED:"Secrets not provided"}},ERRORS:{DROPPING_MESSAGE:"Dropping message",FAILED_SENDING_MESSAGE:"Failed to send user message"}},MEDIA_INFO:{UPDATE_SUCCESS:"Successfully updated media info",ERRORS:{NO_ASSOCIATED_STREAM_ID:"There is no streamId associated with the mediaId and transceiverMid pair",FAILED_PROCESSING_MEDIA_INFO_EVENT:"Failed to process mediaInfoEvent message",FAILED_UPDATING:"Failed to update media info",FAILED_PROCESSING_PEER_MEDIA:"Failed to process media info",FAILED_UPDATING_TRANSCEIVER_MID:"Failed updating media info transceiverMid after setLocalDescription",FAILED_SETTING_PEER_MEDIA_INFO:"Failed setting peer media at offer / answer",STREAM_ID_NOT_MATCHED:"There is no mediaInfo associated with the streamId"},WARN:{READ_ONLY_VALUE:"Attempting to change media info read only value: ",INVALID_MEDIA_TYPE:"Invalid media info media type: "},VIDEO_STATE_CHANGE:"Peers's video state changed to ->",AUDIO_STATE_CHANGE:"Peers's audio state changed to ->",VIDEO_SCREEN_STATE_CHANGE:"Peers's video screen state changed to ->"},MEDIA_STREAM:{STOP_SETTINGS:"Stopped streams with settings:",STOP_SUCCESS:"Successfully stopped stream",REMOTE_TRACK_REMOVED:"Remote MediaStreamTrack removed",START_FALLBACK:"Fall back to retrieve audio only stream",NO_OPTIONS:"No user media options provided",DEFAULT_OPTIONS:"Using default options",FALLBACK_SUCCESS:"Successfully retrieved audio fallback stream",START_SCREEN_SUCCESS:"Successfully retrieved screen share stream",STOP_SCREEN_SUCCESS:"Successfully stopped screen share stream",UPDATE_MUTED_SETTINGS:"Updated stream muted setting",UPDATE_MEDIA_STATUS:"Updated stream media status",AUDIO_MUTED:"Peers's audio muted: ",VIDEO_MUTED:"Peers's video muted: ",ERRORS:{STOP_SCREEN:"Error stopping screen share stream",START_SCREEN:"Error starting screen share stream",STOP_ADDED_STREAM:"Error stopping added stream",STOP_USER_MEDIA:"Error stopping user media",STOP_AUDIO_TRACK:"Error stopping audio tracks in stream",STOP_VIDEO_TRACK:"Error stopping video tracks in stream",STOP_MEDIA_TRACK:"Error stopping MediaTrack",STOP_SCREEN_TRACK:"Error stopping screen track in stream",DROPPING_ONREMOVETRACK:"Dropping onremovetrack",NO_STREAM:"No stream to process",INVALID_STREAM_ID:"No stream detected with stream id",NO_USER_MEDIA_STREAMS:"No user media streams detected",INVALID_STREAM_ID_TYPE:"Stream id is not a string",NO_STREAM_ID:"No stream id provided",PEER_SCREEN_ACTIVE:"Peer has existing screen share",FALLBACK:"Error retrieving fallback audio stream",INVALID_GUM_OPTIONS:"Invalid user media options",INVALID_GDM_OPTIONS:"Invalid display media options",GET_USER_MEDIA:"Error retrieving stream from 'getUserMedia' method",INVALID_MUTE_OPTIONS:"Invalid muteStreams options provided",NO_STREAMS_MUTED:"No streams to mute",SEND_STREAM:"Error sending stream",INVALID_MEDIA_STREAM_ARRAY:"Array is not of type MediaStream",ACTIVE_STREAMS:"There are currently active streams being sent to remote peers. Please stop streams."}},STATS_MODULE:{NOT_INITIATED:"Stats Module is not initiated",STATS_DISCARDED:"Stats report discarded as peer has left the room",ERRORS:{RETRIEVE_STATS_FAILED:"Failed retrieving stats",POST_FAILED:"Failed posting to stats api",PARSE_FAILED:"Failed parsing stats report",STATS_IS_NULL:"Stats object is null",INVALID_TRACK_KIND:"Media kind is not audio or video"},HANDLE_ICE_GATHERING_STATS:{PROCESS_FAILED:"process_failed",PROCESS_SUCCESS:"process_success",PROCESSING:"processing",DROPPED:"dropped",BUFFERED:"buffered"},HANDLE_NEGOTIATION_STATS:{OFFER:{create:"create_offer",create_error:"error_create_offer",set:"set_offer",set_error:"error_set_offer",offer:"offer",dropped:"dropped_offer"},ANSWER:{create:"create_answer",create_error:"error_create_answer",set:"set_answer",set_error:"error_set_ANSWER",answer:"answer",dropped:"dropped_answer"}},HANDLE_DATA_CHANNEL_STATS:{open:"open",closed:"closed",reconnecting:"reconnecting"},HANDLE_CONNECTION_STATS:{},HANDLE_BANDWIDTH_STATS:{RETRIEVE_FAILED:"Failed posting bandwidth stats: ",NO_STATE:"No room state"},HANDLE_ICE_CONNECTION_STATS:{RETRIEVE_FAILED:"Failed retrieving stats: ",SEND_FAILED:"Failed sending ice connection stats: "},HANDLE_RECORDING_STATS:{START:"start",STOP:"stop",REQUEST_START:"request-start",REQUEST_STOP:"request-stop",ERROR_NO_MCU_START:"error-no-mcu-start",ERROR_NO_MCU_STOP:"error-no-mcu-stop",ERROR_START_ACTIVE:"error-start-when-active",ERROR_STOP_ACTIVE:"error-stop-when-active",ERROR_MIN_STOP:"error-min-stop",MCU_RECORDING_ERROR:"mcu-recording-error"}},RECORDING:{START_SUCCESS:"Started recording",STOP_SUCCESS:"Stopped recording",START_FAILED:"Failed to start recording",STOP_FAILED:"Failed to stop recording",MIN_RECORDING_TIME_REACHED:"4 seconds has been recorded - Recording can be stopped now",ERRORS:{MCU_NOT_CONNECTED:"MCU is not connected",EXISTING_RECORDING_IN_PROGRESS:"There is an existing recording in-progress",NO_RECORDING_IN_PROGRESS:"There is no existing recording in-progress",MIN_RECORDING_TIME:"4 seconds has not been recorded yet",STOP_ABRUPT:"Recording stopped abruptly before 4 seconds",SESSION_EMPTY:'Received request of "off" but the session is empty',MCU_RECORDING_ERROR:"Recording error received from MCU"}},RTMP:{start_no_mcu:"Unable to start RTMP session as MCU is not connected",stop_no_mcu:"Unable to stop RTMP as MCU is not connected",start_no_stream_id:"Unable to start RTMP Session stream id is missing",start_no_endpoint:"Unable to start RTMP Session as Endpoint is missing",starting_rtmp:"Starting RTMP Session",stopping_rtmp:"Stopping RTMP Session",message_received_from_sig:"Received RTMP Session message ->",stop_session_empty:'Received request of "off" but the session is empty',stopped_success:"Stopped RTMP Session",started_success:"Started RTMP Session",error_session_empty:"Received error but the session is empty ->",error_session:"RTMP session failure ->",error_Session_abrupt:"Stopped RTMP session abruptly"},PERSISTENT_MESSAGE:{ERRORS:{NO_DEPENDENCY:"CryptoJS is not available"}},UTILS:{INVALID_BROWSER_AGENT:"Invalid browser agent"},LOGGER:{EVENT_DISPATCHED:"Event dispatched",EVENT_REGISTERED:"Event successfully registered",EVENT_UNREGISTERED:"Event successfully unregistered",EVENT_DISPATCH_ERROR:"Error dispatching event",EVENT_REGISTER_ERROR:"Error registering event",EVENT_UNREGISTER_ERROR:"Error unregistering event",LOGS_NOT_STORED:"Store logs feature is not enabled. Enable it via SkylinkLogger.setLevel(logLevel, storeLogs)",LOGS_CLEARED:"Stored logs cleared",INVALID_CB:"Dropping listener as it is not a function"},BROWSER_AGENT:{REACT_NATIVE:{ERRORS:{DROPPING_ONREMOVETRACK:"Dropping onremovetrack as trackInfo is malformed"}}}};const Nt=new class{constructor(){this.events={},this.privateEvents={};}addPrivateEventListener(e,t){this.addListener(e,t,!0);}addEventListener(e,t){this.addListener(e,t,!1);}addListener(e,t,r){try{const n=r?"privateEvents":"events";if(!mi(t))return void Lt.log.DEBUG([null,ut.SKYLINK_EVENT,e,vt.LOGGER.INVALID_CB]);this[n][e]||(this[n][e]={}),this[n][e].callbacks||(this[n][e].callbacks=[]),this[n][e].callbacks.push(t),r||Lt.log.DEBUG([null,ut.SKYLINK_EVENT,e,vt.LOGGER.EVENT_REGISTERED]);}catch(t){Lt.log.ERROR([null,ut.SKYLINK_EVENT,e,vt.LOGGER.EVENT_REGISTER_ERROR],t);}}dispatchEvent(e){if(e.name===Ot.LOGGED_ON_CONSOLE)return;let t=[];if(this.events[e.name]){const r=this.events[e.name].callbacks;t=t.concat(r);}else Lt.log.DEBUG([null,ut.SKYLINK_EVENT,e.name,vt.LOGGER.EVENT_DISPATCHED]);if(this.privateEvents[e.name]){const r=this.privateEvents[e.name]?this.privateEvents[e.name].callbacks:[];t=t.concat(r);}t.forEach(t=>{try{t(e.detail);}catch(t){Lt.log.ERROR([null,ut.SKYLINK_EVENT,e.name,vt.LOGGER.EVENT_DISPATCH_ERROR],t);}});}removeEventListener(e,t){this.removeListener(e,t,!1);}removePrivateEventListener(e,t){this.removeListener(e,t,!0);}removeListener(e,t,r){const n=r?"privateEvents":"events";if(r||this.events[e]&&this.events[e].callbacks)try{this[n][e].callbacks.forEach((s,i)=>{s===t&&(delete this[n][e].callbacks[i],r||Lt.log.DEBUG([null,ut.SKYLINK_EVENT,e,vt.LOGGER.EVENT_UNREGISTERED]));});}catch(t){Lt.log.ERROR([null,ut.SKYLINK_EVENT,e,vt.LOGGER.EVENT_DISPATCH_ERROR],t);}else Lt.log.WARN([null,ut.SKYLINK_EVENT,e,vt.LOGGER.EVENT_UNREGISTERED]);}},Dt=Nt.addPrivateEventListener.bind(Nt),yt=Nt.removePrivateEventListener.bind(Nt),Pt=Nt.dispatchEvent.bind(Nt),Mt=["trace","debug","info","warn","error"],kt=e=>{let t=!0;return ("undefined"==typeof console||void 0===console[e])&&(t=!1),t},wt=(e,t,r,n=null)=>{const s=`[${(new Date).toISOString()}]`,i=e.level,{logLevels:o}=e;if(i<=t&&i!==o.SILENT){const e=Mt[t];if(!kt(e))return;const i=(e=>{let t="SkylinkJS -";if(Array.isArray(e)){const[r,n,s,i]=e;if(t+=r?` [${r}]`:" -",t+=n?` <<${n}>>`:r?"":" <>",s)if(Array.isArray(s))for(let e=0;enew pe("loggedOnConsole",{detail:e}))({level:e,message:i,debugObject:n}))),Lt.storeLogs){const t=[s,e.toUpperCase(),i];n&&t.push(n),Lt.storedLogs.push(t);}}};class bt{constructor(){this.logLevels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},this.level=(e=>{const t=window.localStorage.getItem("loglevel:skylinkjs");return null===t||Number.isNaN(+t)?e.ERROR:+t})(this.logLevels),this.storeLogs=!1,this.storedLogs=[];}setLevel(e=this.levels.ERROR,t){hi(e)?(this.level=e,(e=>{window.localStorage.setItem("loglevel:skylinkjs",e);})(this.level)):this.level=this.levels.ERROR,t&&(this.storeLogs=t);}enableAll(){this.setLevel(this.logLevels.TRACE);}disableAll(){this.setLevel(this.logLevels.SILENT);}getLogs(){return this.storeLogs?this.storedLogs:(this.log.WARN(vt.LOGGER.LOGS_NOT_STORED),null)}clearLogs(){this.log.INFO(vt.LOGGER.LOGS_CLEARED),this.storedLogs=[];}}const Lt=new bt;bt.prototype.log={TRACE:(...e)=>{wt(Lt,Lt.logLevels.TRACE,...e);},DEBUG:(...e)=>{wt(Lt,Lt.logLevels.DEBUG,...e);},INFO:(...e)=>{wt(Lt,Lt.logLevels.INFO,...e);},WARN:(...e)=>{wt(Lt,Lt.logLevels.WARN,...e);},ERROR:(...e)=>{wt(Lt,Lt.logLevels.ERROR,...e);}};var Gt=O((function(e){var t=function(){function e(e,t){return null!=t&&e instanceof t}var t,r,n;try{t=Map;}catch(e){t=function(){};}try{r=Set;}catch(e){r=function(){};}try{n=Promise;}catch(e){n=function(){};}function s(i,a,c,d,l){"object"==typeof a&&(c=a.depth,d=a.prototype,l=a.includeNonEnumerable,a=a.circular);var p=[],u=[],S="undefined"!=typeof Buffer;return void 0===a&&(a=!0),void 0===c&&(c=1/0),function i(c,E){if(null===c)return null;if(0===E)return c;var h,m;if("object"!=typeof c)return c;if(e(c,t))h=new t;else if(e(c,r))h=new r;else if(e(c,n))h=new n((function(e,t){c.then((function(t){e(i(t,E-1));}),(function(e){t(i(e,E-1));}));}));else if(s.__isArray(c))h=[];else if(s.__isRegExp(c))h=new RegExp(c.source,o(c)),c.lastIndex&&(h.lastIndex=c.lastIndex);else if(s.__isDate(c))h=new Date(c.getTime());else{if(S&&Buffer.isBuffer(c))return h=Buffer.allocUnsafe?Buffer.allocUnsafe(c.length):new Buffer(c.length),c.copy(h),h;e(c,Error)?h=Object.create(c):void 0===d?(m=Object.getPrototypeOf(c),h=Object.create(m)):(h=Object.create(d),m=d);}if(a){var g=p.indexOf(c);if(-1!=g)return u[g];p.push(c),u.push(h);}for(var R in e(c,t)&&c.forEach((function(e,t){var r=i(t,E-1),n=i(e,E-1);h.set(r,n);})),e(c,r)&&c.forEach((function(e){var t=i(e,E-1);h.add(t);})),c){var f;m&&(f=Object.getOwnPropertyDescriptor(m,R)),f&&null==f.set||(h[R]=i(c[R],E-1));}if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(c);for(R=0;R({forceNew:!0,reconnection:!0,timeout:e.socketTimeout,path:e.socketServerPath,reconnectionAttempts:Ut.RECONNECTION_ATTEMPTS.WEBSOCKET,reconnectionDelayMax:Ut.RECONNECTION_DELAY_MAX,reconnectionDelay:Ut.RECONNECTION_DELAY,transports:[It.WEBSOCKET.toLowerCase()],query:{Skylink_SDK_type:Rt.WEB,Skylink_SDK_version:"2.x.x",Skylink_API_version:"9.0.0","X-Server-Select":"sig-v2"},extraHeaders:{Skylink_SDK_type:Rt.WEB,Skylink_SDK_version:"2.x.x",Skylink_API_version:"9.0.0","X-Server-Select":"sig-v2"}}),PEER_CONNECTION:{bundlePolicy:Ke.BALANCED,rtcpMuxPolicy:$e.REQUIRE,iceTransportPolicy:"all",iceCandidatePoolSize:0}},Bt={SOCKET:Ut,MEDIA_OPTIONS:{AUDIO:{stereo:!1,echoCancellation:!0,exactConstraints:!1},VIDEO:{resolution:rt.VGA,frameRate:30,exactConstraints:!1},SCREENSHARE:{video:!0}}},xt=(e,t)=>t?Ft[e](t):Ft[e],Vt={defaultRoom:(new Date).valueOf(),appKey:null,roomServer:"//api.temasys.io",enableDataChannel:!0,enableSTUNServer:!0,enableTURNServer:!0,socketServerPath:null,enableStatsGathering:!0,audioFallback:!0,socketTimeout:7e3,forceTURNSSL:!1,forceTURN:!1,forceSSL:!0,usePublicSTUN:!1,mcuUseRenegoRestart:!0,useEdgeWebRTC:!1,enableSimultaneousTransfers:!0,TURNServerTransport:Ve.ANY,credentials:null,iceServer:null,socketServer:null,audioCodec:tt.AUTO,videoCodec:et.AUTO,codecParams:{audio:{opus:{stereo:null,"sprop-stereo":null,usedtx:null,useinbandfec:null,maxplaybackrate:null,minptime:null}},video:{h264:{profileLevelId:null,levelAsymmetryAllowed:null,packetizationMode:null},vp8:{maxFs:null,maxFr:null},vp9:{maxFs:null,maxFr:null}}},beSilentOnStatsLogs:!1,beSilentOnParseLogs:!1};class Ht{constructor(e){this.id=e.room_key,this.token=e.roomCred,this.startDateTime=e.start,this.duration=e.len,this.roomName=e.roomName,this.connection={peerConstraints:JSON.parse(e.pc_constraints),offerConstraints:JSON.parse(e.offer_constraints),sdpConstraints:{},peerConfig:{iceServers:[]},mediaConstraints:JSON.parse(e.media_constraints)},this.isLocked=!1;}}class jt{constructor(e){this.uid=e.username,this.token=e.userCred,this.timeStamp=e.timeStamp,this.sid=null,this.bufferMessage=null;}}const Wt={};class Kt{constructor(e,t){if(Ri(t)&&Wt[t])return Wt[t];const{offer_constraints:r,pc_constraints:n,cid:s,apiOwner:i,ipSigserver:o,isPrivileged:a,autoIntroduce:c,httpPortList:d,httpsPortList:l,hasMCU:p,ipSigserverPath:u,hasPersistentMessage:S,room_key:E,enable_stats_config:h}=e;r||n||Lt.log.ERROR(["API",null,"init","pc_constraints or offer_constraints are null"]),Lt.log.DEBUG(["API",null,"init","Parsed Peer Connection constraints:"],JSON.parse(n)),Lt.log.DEBUG(["API",null,"init","Parsed Offer constraints"],JSON.parse(r)),this.key=s,this.appKeyOwner=i,this.isPrivileged=a,this.autoIntroduce=c,this.room=new Ht(e),this.user=new jt(e),this.hasMCU=p,this.socketServer=o,this.socketServerPath=u,this.socketPorts={"http:":Array.isArray(d)&&d.length>0?d:[80,3e3],"https:":Array.isArray(l)&&l.length>0?l:[443,3443]},this.hasPersistentMessage=S,this.enableStatsGathering=h,Wt[E]=this;}deleteApiResponseInstance(e){delete Wt[e];}}const $t={apiBase:"https://api.temasys.io",stats:{endPoints:{client:"/client",session:"/session",auth:"/auth",signaling:"/signaling",iceConnection:"/client/iceconnection",iceCandidate:"/client/icecandidate",iceGathering:"/client/icegathering",negotiation:"/client/negotiation",bandwidth:"/client/bandwidth",recording:"/client/recording",dataChannel:"/client/datachannel"}}};$t.stats.statsBase=$t.apiBase+"/rest/stats";class Yt{constructor(){this.endpoints=$t.stats.endPoints,this.stats_buffer={},this.bufferTimeout=!1;}postStats(e,t){const{STATS_MODULE:r}=vt,n=ao.getInitOptions().beSilentOnStatsLogs;try{const r=this.processData(t);this.postStatObj(e,n,r);}catch(e){Lt.log.WARN(r.ERRORS.POST_FAILED,e);}}processData(e){return Array.isArray(e)?{client_id:e[0].client_id,data:e}:e}async postStatObj(e,t,r){const{fetch:n}=window,s=await n(`${$t.stats.statsBase}${e}`,{method:"POST",mode:"cors",headers:{"Content-type":"application/json"},body:JSON.stringify(r)});t||s.json().then(t=>{Lt.log.INFO([null,ut.STATS,null,""+e],t);});}addToStatsBuffer(e,t,r){this.stats_buffer[e]||(this.stats_buffer[e]={},this.stats_buffer[e].url=r,this.stats_buffer[e].data=[]);const n=Object.assign({},t);this.stats_buffer[e].data.push(n);}manageStatsBuffer(){this.bufferTimeout||(this.bufferTimeout=!0,setInterval(()=>{const e=Object.keys(this.stats_buffer);for(let t=0;t0&&(this.postStats(this.stats_buffer[e[t]].url,this.stats_buffer[e[t]].data),this.stats_buffer[e[t]].data=[]);},5e3));}}class zt extends Yt{constructor(){super(),this.model={client_id:null,app_key:null,timestamp:null,room_id:null,state:null,http_status:null,http_error:null,api_url:null,api_result:null};}send(e,t,r,n){this.model.room_id=e,this.model.http_status=n?-1:r&&r.status?r.status:null,this.model.http_error=("string"==typeof n?n:n&&n.message)||null,this.model.api_url=r&&r.endpoint?r.endpoint:r.url,this.model.client_id=ao.getInitOptions().clientId,this.model.app_key=ao.getInitOptions().appKey,this.model.state=t,this.model.timestamp=(new Date).toISOString(),this.postStats(this.endpoints.auth,this.model);}}const Jt=e=>{const{appKey:t}=e,r={isValid:!0,message:""};return Lt.log.INFO(["API",null,"init","API initialised with options:"],e),t||(r.isValid=!1,r.message=vt.INIT.ERRORS.NO_APP_KEY,Pt(fe({readyState:Qe.ERROR,error:{status:-2,content:new Error(vt.INIT.ERRORS.NO_APP_KEY),errorCode:Xe.NO_PATH},room:null}))),r.isValid||Lt.log.ERROR(["API",null,"init",r.message]),r},Qt=e=>{const{ok:t}=e;return (e=>{const{status:t,ok:r}=e,n=r?"INFO":"ERROR";let s=vt.INIT.INFO.API_SUCCESS;r||(s=vt.INIT.ERRORS.AUTH_GENERAL,403===t&&(s=vt.INIT.ERRORS.AUTH_CORS)),Lt.log[n](["API",null,"auth",s],e);})(e),t},Xt=e=>{const t=e;return !0===t.forceTURN&&(t.enableTURNServer=!0,t.enableSTUNServer=!1),t},qt=async e=>{const{fetch:t}=window,r=(e=>{const{roomServer:t,appKey:r,defaultRoom:n,credentials:s,forceSSL:i}=e;let o=`${t}/api/${r}/${n}`,a="?";if(o=i?"https:"+o:`${window.location.protocol}${o}`,s){const{startDateTime:e,duration:t}=s;o+=`/${e}/${t}?cred=${s.credentials}`,a="&";}return o+=`${a}rand=${Date.now()}`,o})(e);(new zt).send(e.defaultRoom,Ue.REQUEST,{endpoint:r});return {endpoint:r,response:await t(r,{headers:{Skylink_SDK_type:Rt.WEB,Skylink_SDK_version:"2.x.x",Skylink_API_version:"9.0.0","X-Server-Select":"sig-v2"}})}},Zt=()=>{const e={ready:!0,message:""};return (()=>{try{const e=new window.RTCPeerConnection(null);return ["object","function"].indexOf(typeof e.createOffer)>-1&&null!==e.createOffer}catch(e){return !1}})()||(e.message="WebRTC not supported. Please upgrade your browser",e.ready=!1,Pt(fe({readyState:Qe.ERROR,error:{status:-2,content:new Error(e.message),errorCode:Xe.NO_WEBRTC_SUPPORT},room:null}))),e};let er=null;class tr{constructor(){return er||(er=this),this.options={},er}init(e=Vt){e&&(e.socketServer&&!e.socketServerPath&&(e.socketServerPath=""),e.clientId=Oi(),ao.setUserInitOptions(e)),Pt(fe({readyState:Qe.INIT,error:null,room:null}));const t=(()=>{const e={fulfilled:!0,message:""},{AdapterJS:t,io:r,fetch:n}=window,s="Validating Dependencies";return "function"!=typeof(t||window.AdapterJS||window.AdapterJS||{}).webRTCReady?(e.message=vt.INIT.ERRORS.NO_ADAPTER,e.fulfilled=!1,e.readyStateChangeErrorCode=Xe.ADAPTER_NO_LOADED):r||window.io?n&&window.fetch||(e.message=vt.INIT.ERRORS.NO_FETCH_SUPPORT,e.fulfilled=!1,e.readyStateChangeErrorCode=Xe.NO_XMLHTTPREQUEST_SUPPORT):(e.message=vt.INIT.ERRORS.NO_SOCKET_IO,e.fulfilled=!1,e.readyStateChangeErrorCode=Xe.NO_SOCKET_IO),Pi(ft.FIREFOX)&&"moz"===t.webrtcDetectedType||Pi(ft.SAFARI)||Pi(ft.CHROME)&&"webkit"===t.webrtcDetectedType||Pi(ft.REACT_NATIVE)||Lt.log.WARN([s,null,null,vt.INIT.INCOMPATIBLE_BROWSER]),e.fulfilled||Lt.log.ERROR([s,null,null,e.message]),e})(),{AdapterJS:r}=window;if(!t.fulfilled)throw Pt(fe({readyState:Qe.ERROR,error:{status:-2,content:new Error(t.message),errorCode:t.readyStateChangeErrorCode},room:null})),new Error(t.message);let n=Object.assign({},Vt,e);const s=Jt(n);if(!s.isValid)throw new Error(s.message);return r.webRTCReady(()=>{const e=Zt();if(!e.ready)throw new Error(e.message)}),n=Xt(n),n}createRoom(e){return new Promise((t,r)=>{const n=ao.getInitOptions();n.defaultRoom=e,qt(n).then(n=>{const{endpoint:s,response:i}=n;Qt(i)?(Pt(fe({readyState:Qe.COMPLETED,error:null,room:e})),i.json().then(e=>{(new zt).send(e.room_key,Ue.SUCCESS,i),t({endpoint:s,response:e});})):(Pt(fe({readyState:Qe.ERROR,error:{status:i.status,content:new Error(i.info||"XMLHttpRequest status not OK\nStatus was: "+i.status),errorCode:i.error||i.status},room:e})),i.json().then(t=>{(new zt).send(e,Ue.ERROR,i,t.info),r(t);}));}).catch(t=>{Pt(fe({readyState:Qe.ERROR,error:{status:t.status||-1,content:new Error(t.message||"Network error occurred"),errorCode:Xe.XML_HTTP_REQUEST_ERROR},room:e}));});})}checkCodecSupport(e){return (e=>new Promise((t,r)=>{Li.getCodecsSupport(e).then(n=>{const s=ao.getSkylinkState(e),{room:i}=s;0===Object.keys(n.audio).length&&0===Object.keys(n.video).length?(Lt.log.ERROR(vt.JOIN_ROOM.ERRORS.CODEC_SUPPORT),Pt(fe({readyState:Qe.ERROR,error:{status:-2,content:new Error(vt.JOIN_ROOM.ERRORS.CODEC_SUPPORT),errorCode:Xe.PARSE_CODECS},room:$s.getRoomInfo(i.id)})),r(new Error(vt.JOIN_ROOM.ERRORS.CODEC_SUPPORT))):t(!0),s.currentCodecSupport=n,ao.setSkylinkState(s);}).catch(t=>{const n=ao.getSkylinkState(e),{room:s}=n;Lt.log.ERROR(t),Pt(fe({readyState:Qe.ERROR,error:{status:-2,content:new Error(t.message||t.toString()),errorCode:Xe.PARSE_CODECS},room:$s.getRoomInfo(s.id)})),r(new Error(t.message||t.toString()));});}))(e)}static parseAPIResponseBody(e){return new Kt(e)}enforceUserInitOptions(e){return (e=>{const t=ao.getUserInitOptions(),r=ao.getInitOptions();let n=Object.assign(r,e,t);const s=Jt(n);if(!s.isValid)throw new Error(s.message);return n=Xt(n),ao.setInitOptions(n),n})(e)}static getRoomNameFromParams(e){const t=ao.getInitOptions(),{roomName:r}=e,{defaultRoom:n}=t;let s=null;return s=void 0!==r&&""!==r&&n!==r?r:n,s}static getStateByKey(e){return _i(e)}}const rr=e=>{const t=ao.getSkylinkState(e.roomKey),r=ao.getInitOptions(),{config:n}=e,{socketServer:s,socketTimeout:i,socketServerPath:o}=r,{socketPorts:a}=new Kt(null,e.roomKey),c=xt("SOCKET",{socketTimeout:i,socketServerPath:o});let d=[];s&&Si(s)&&Array.isArray(s.ports)&&s.ports.length?({ports:d}=s):d=a[n.signalingServerProtocol],(e=>!e.signalingServerPort)(n)?(n.signalingServerPort=d[0],n.fallbackType=Ze.NON_FALLBACK):((e,t)=>e.indexOf(t.signalingServerPort)===e.length-1)(d,n)||Ri(r.socketServer)?n.socketType===It.WEBSOCKET?(n.socketType=It.POLLING,n.signalingServerPort=d[0]):(n.socketSession.finalAttempts+=1,n.signalingServerPort=d[0]):n.signalingServerPort=d[d.indexOf(n.signalingServerPort)+1],n.socketType===It.POLLING&&(c.reconnectionDelayMax=Bt.SOCKET.RECONNECTION_DELAY_MAX,c.reconnectionAttempts=Bt.SOCKET.RECONNECTION_ATTEMPTS.POLLING,c.transports=[It.XHR_POLLING,It.JSONP_POLLING,It.POLLING.toLowerCase()]);const l=(e=>{const{signalingServerProtocol:t,signalingServer:r,signalingServerPort:n,socketServer:s}=e;let i="";return i=Ri(r)?`${t}//${r}`:r&&Si(r)&&r.protocol?`${r.protocol}//${s.url}:${n}?rand=${Date.now()}`:`${t}//${r}:${n}?rand=${Date.now()}`,i})({signalingServerProtocol:n.signalingServerProtocol,signalingServer:t.socketServer,signalingServerPort:n.signalingServerPort,socketServer:s});return n.socketServer=s,n.socketServerPath=o,t.socketSession=n,ao.setSkylinkState(t,e.roomKey),window.io(l,c)},nr=(e,t)=>{const r=ao.getSkylinkState(e)||Object.values(ao.getSkylinkState())[0],{socketSession:n,room:s,user:i}=r;var o;Lt.log.INFO([null,"Socket",null,"Channel closed. Reason - "+t]),r.channelOpen=!1,ao.setSkylinkState(r,e),Pt((o={socketSession:Gt(n)},new pe("channelClose",{detail:o}))),s.inRoom&&i&&i.sid&&Pt(((e={})=>new pe("sessionDisconnect",{detail:e}))({peerId:i.sid,peerInfo:Qs.getCurrentSessionInfo(s)}));};class sr extends Yt{constructor(){super(),this.model={client_id:null,app_key:null,timestamp:null,room_id:null,user_id:null,state:null,signaling_url:null,signaling_transport:null,attempts:null,error:null};}send(e,t,r){const n=ao.getSkylinkState(e),{socketSession:s}=n;this.model.room_id=e,this.model.user_id=n&&n.user&&n.user.sid||null,this.model.client_id=n.clientId,this.model.state=t,this.model.signaling_url=n.socketSession.socketServer,this.model.signaling_transport=n.socketSession.socketType.toLowerCase(),this.model.attempts=0===s.socketSession.finalAttempts?s.socketSession.attempts:2*s.socketSession.finalAttempts+s.socketSession.attempts,this.model.app_key=ao.getInitOptions().appKey,this.model.timestamp=(new Date).toISOString(),this.attempts="number"==typeof r?r:null,this.model.error=("string"==typeof r?r:r&&r.message)||null,this.postStats(this.endpoints.signaling,this.model);}}const ir=e=>{const{peerConnections:t}=e,r=Object.keys(t);let n=!0;return r.forEach(e=>{t[e].connectionState===He.FAILED&&(n=!1);}),n},or={onConnection:(e,t)=>{const r=ao.getSkylinkState(t),{socketSession:n}=r;var s;(new sr).send(t,Ct.SIGNALING.CONNECT,null),r.channelOpen||(r.channelOpen=!0,ao.setSkylinkState(r,t)),0!==n.socketSession.finalAttempts||0!==n.socketSession.attempts?(Pt((s={socketSession:Gt(n)},new pe("channelReopen",{detail:s}))),(new sr).send(t,Ct.SIGNALING.RECONNECT_SUCCESS)):Pt((e=>new pe("channelOpen",{detail:e}))({socketSession:Gt(n)})),e();},onDisconnect:(e,t)=>{const r=ao.getSkylinkState(e)||Object.values(ao.getSkylinkState())[0],n=r.channelOpen,{room:s}=r;(new sr).send(s.id,Ct.SIGNALING.DISCONNECT,null),(n||!n&&e!==s.roomName)&&pr(s.id,t);},onError:(e,t)=>{const r=ao.getSkylinkState(e),{socketSession:n}=r;var s;(new sr).send(e,Ct.SIGNALING.ERROR,t),Lt.log.ERROR([null,"Socket",null,"Exception occurred ->"],t),Pt((s={error:t,socketSession:Gt(n)},new pe("channelError",{detail:s})));},onReconnectAttempt:(e,t)=>{const r=ao.getSkylinkState(e);if(!r)return;const{socketSession:n}=r;let s=0;var i;(new Ls).updateAttempts(e,"attempts",t),s=0===n.socketSession.finalAttempts?t:2*n.socketSession.finalAttempts+n.socketSession.attempts,(new sr).send(e,Ct.SIGNALING.RECONNECT_ATTEMPT,s),Pt((i={fallbackType:n.fallbackType,currentAttempt:s,session:Gt(ao.getSkylinkState(e).socketSession)},new pe("channelRetry",{detail:i})));},onReconnectFailed:(e,t,r)=>{const n=ao.getSkylinkState(r),{socketSession:s}=n,i=new Ls;ir(n)&&s.socketSession.attempts===Bt.SOCKET.RECONNECTION_ATTEMPTS.WEBSOCKET&&s.socketSession.finalAttempts{const r=ao.getSkylinkState(e),{socketSession:n}=r;(new sr).send(e,Ct.SIGNALING.RECONNECT_ERROR,t),!n.socketTimeout&&t&&"timeout"===t&&(Lt.log.ERROR([null,"Socket",null,n.socketType+" connection timed out."]),n.socketTimeout=!0,ao.setSkylinkState(r,e));}},ar=e=>gi(e)&&e,cr=(e,t)=>{const r=ao.getSkylinkState(e),{detail:n}=t;if(n.state===Ye.ENTER){const e=Gt(r.socketMessageQueue);r.user.bufferMessage=!1,r.socketMessageQueue=[],ao.setSkylinkState(r,r.room.id),Lt.log.DEBUG([r.user.sid,ut.SIG_SERVER,null,`${vt.SIGNALING.BUFFERED_MESSAGES_SENT}: ${e.length}`]),((e,t)=>{const r=new Ls;for(let n=t.length-1;n>=0;n-=1){const s=t[n];if(!s.mid){if(!e.user.sid)return void Lt.log.DEBUG([e.user.sid,ut.SIG_SERVER,null,""+vt.SIGNALING.BUFFERED_MESSAGES_DROPPED]);s.mid=e.user.sid;}r.sendMessage(s),t.splice(n,1);}})(r,e),Nt.removeEventListener(Ot.HANDSHAKE_PROGRESS,cr);}},dr=e=>{const{rid:t}=e,r=ao.getSkylinkState(t),{user:n,room:s}=r;return !Ei(n.bufferMessage)&&!ar(n.bufferMessage)||(e=>{const{JOIN_ROOM:t,ENTER:r,WELCOME:n,OFFER:s,ANSWER:i,ANSWER_ACK:o,CANDIDATE:a,END_OF_CANDIDATES:c}=ot;return [t,r,n,s,i,o,a,c].indexOf(e.type)>-1})(e)?(e.type===Ye.ENTER&&Ei(n.bufferMessage)&&(Lt.log.DEBUG([n.sid,ut.SIG_SERVER,null,vt.SIGNALING.BUFFER_NOT_NEEDED]),r.user.bufferMessage=!1,r.socketMessageQueue=[],ao.setSkylinkState(r,r.room.id)),!1):(Lt.log.DEBUG([n.sid,ut.SIG_SERVER,null,vt.SIGNALING.MESSAGE_ADDED_TO_BUFFER]),r.socketMessageQueue.unshift(e),ar(n.bufferMessage)||(r.user.bufferMessage=!0,Lt.log.DEBUG([n.sid,ut.SIG_SERVER,null,vt.SIGNALING.ENTER_LISTENER]),Nt.addEventListener(Ot.HANDSHAKE_PROGRESS,cr.bind(void 0,t))),ao.setSkylinkState(r,s.id),!0)},lr=(e,t)=>{((e,t)=>{const{type:r}=t;switch(Lt.log.INFO(["SIG SERVER",null,r,"received"]),r){case ot.IN_ROOM:e.inRoomHandler(t);break;case ot.ENTER:e.enterRoomHandler(t);break;case ot.OFFER:e.offerHandler(t);break;case ot.WELCOME:e.welcomeHandler(t);break;case ot.ANSWER:e.answerHandler(t);break;case ot.ANSWER_ACK:e.answerAckHandler(t);break;case ot.CANDIDATE:e.candidateHandler(t);break;case ot.PEER_LIST:e.getPeerListHandler(t);break;case ot.INTRODUCE_ERROR:e.introduceError(t);break;case ot.BYE:e.byeHandler(t);break;case ot.STREAM:e.streamHandler(t);break;case ot.RECORDING:e.recordingHandler(t);break;case ot.REDIRECT:e.redirectHandler(t);break;case ot.RTMP:e.rtmpHandler(t);break;case ot.UPDATE_USER:e.setUserDataHandler(t);break;case ot.MEDIA_INFO_EVENT:e.mediaInfoEventHandler(t);break;case ot.MESSAGE:e.userMessageHandler(t,null);break;case ot.STORED_MESSAGES:e.storedMessagesHandler(t);break;case ot.PUBLIC_MESSAGE:e.userMessageHandler(t,!0);break;case ot.PRIVATE_MESSAGE:e.userMessageHandler(t,!1);}})(e,t);},pr=(e,t)=>{nr(e,t);},ur=(e,t,r,n)=>{((e,t,r,n)=>{t.socket.on(_t.CONNECT,or.onConnection.bind(t,r,e)),t.socket.on(_t.MESSAGE,t.onMessage.bind(t)),t.socket.on(_t.DISCONNECT,or.onDisconnect.bind(t,e)),t.socket.on(_t.ERROR,or.onError.bind(t,e)),t.socket.on(_t.RECONNECT_ATTEMPT,or.onReconnectAttempt.bind(t,e)),t.socket.on(_t.RECONNECT_ERROR,or.onReconnectError.bind(t,e)),t.socket.on(_t.RECONNECT_FAILED,or.onReconnectFailed.bind(t,r,n,e));})(e,t,r,n);};var Sr=O((function(e,t){var r;e.exports=(r=r||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},s=n.lib={},i=s.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments);}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString);},clone:function(){return this.init.prototype.extend(this)}},o=s.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length;},toString:function(e){return (e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,s=e.sigBytes;if(this.clamp(),n%4)for(var i=0;i>>2]>>>24-i%4*8&255;t[n+i>>>2]|=o<<24-(n+i)%4*8;}else for(i=0;i>>2]=r[i>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4);},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],s=function(t){t=t;var r=987654321,n=4294967295;return function(){var s=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return s/=4294967296,(s+=.5)*(e.random()>.5?1:-1)}},i=0;i>>2]>>>24-s%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16));}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new o.init(r,t/2)}},d=a.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],s=0;s>>2]>>>24-s%4*8&255;n.push(String.fromCharCode(i));}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new o.init(r,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},p=s.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0;},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes;},_process:function(t){var r=this._data,n=r.words,s=r.sigBytes,i=this.blockSize,a=s/(4*i),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,d=e.min(4*c,s);if(c){for(var l=0;l>>2]|=e[s]<<24-s%4*8;t.call(this,n,r);}else t.apply(this,arguments);}).prototype=e;}}(),r.lib.WordArray);})),O((function(e,t){var r;e.exports=(r=Sr,function(){var e=r,t=e.lib.WordArray,n=e.enc;function s(e){return e<<8&4278255360|e>>>8&16711935}n.Utf16=n.Utf16BE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],s=0;s>>2]>>>16-s%4*8&65535;n.push(String.fromCharCode(i));}return n.join("")},parse:function(e){for(var r=e.length,n=[],s=0;s>>1]|=e.charCodeAt(s)<<16-s%2*16;return t.create(n,2*r)}},n.Utf16LE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535);n.push(String.fromCharCode(o));}return n.join("")},parse:function(e){for(var r=e.length,n=[],i=0;i>>1]|=s(e.charCodeAt(i)<<16-i%2*16);return t.create(n,2*r)}};}(),r.enc.Utf16);})),O((function(e,t){var r,n,s;e.exports=(n=(r=s=Sr).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var s=[],i=0;i>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;s.length%4;)s.push(c);return s.join("")},parse:function(e){var t=e.length,r=this._map,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var i=0;i>>6-o%4*2;s[i>>>2]|=(a|c)<<24-i%4*8,i++;}return n.create(s,i)}(e,t,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},s.enc.Base64);})),O((function(e,t){var r;e.exports=(r=Sr,function(e){var t=r,n=t.lib,s=n.WordArray,i=n.Hasher,o=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0;}();var c=o.MD5=i.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878]);},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,s=e[n];e[n]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8);}var i=this._hash.words,o=e[t+0],c=e[t+1],S=e[t+2],E=e[t+3],h=e[t+4],m=e[t+5],g=e[t+6],R=e[t+7],f=e[t+8],T=e[t+9],_=e[t+10],I=e[t+11],C=e[t+12],O=e[t+13],A=e[t+14],v=e[t+15],N=i[0],D=i[1],y=i[2],P=i[3];N=d(N,D,y,P,o,7,a[0]),P=d(P,N,D,y,c,12,a[1]),y=d(y,P,N,D,S,17,a[2]),D=d(D,y,P,N,E,22,a[3]),N=d(N,D,y,P,h,7,a[4]),P=d(P,N,D,y,m,12,a[5]),y=d(y,P,N,D,g,17,a[6]),D=d(D,y,P,N,R,22,a[7]),N=d(N,D,y,P,f,7,a[8]),P=d(P,N,D,y,T,12,a[9]),y=d(y,P,N,D,_,17,a[10]),D=d(D,y,P,N,I,22,a[11]),N=d(N,D,y,P,C,7,a[12]),P=d(P,N,D,y,O,12,a[13]),y=d(y,P,N,D,A,17,a[14]),N=l(N,D=d(D,y,P,N,v,22,a[15]),y,P,c,5,a[16]),P=l(P,N,D,y,g,9,a[17]),y=l(y,P,N,D,I,14,a[18]),D=l(D,y,P,N,o,20,a[19]),N=l(N,D,y,P,m,5,a[20]),P=l(P,N,D,y,_,9,a[21]),y=l(y,P,N,D,v,14,a[22]),D=l(D,y,P,N,h,20,a[23]),N=l(N,D,y,P,T,5,a[24]),P=l(P,N,D,y,A,9,a[25]),y=l(y,P,N,D,E,14,a[26]),D=l(D,y,P,N,f,20,a[27]),N=l(N,D,y,P,O,5,a[28]),P=l(P,N,D,y,S,9,a[29]),y=l(y,P,N,D,R,14,a[30]),N=p(N,D=l(D,y,P,N,C,20,a[31]),y,P,m,4,a[32]),P=p(P,N,D,y,f,11,a[33]),y=p(y,P,N,D,I,16,a[34]),D=p(D,y,P,N,A,23,a[35]),N=p(N,D,y,P,c,4,a[36]),P=p(P,N,D,y,h,11,a[37]),y=p(y,P,N,D,R,16,a[38]),D=p(D,y,P,N,_,23,a[39]),N=p(N,D,y,P,O,4,a[40]),P=p(P,N,D,y,o,11,a[41]),y=p(y,P,N,D,E,16,a[42]),D=p(D,y,P,N,g,23,a[43]),N=p(N,D,y,P,T,4,a[44]),P=p(P,N,D,y,C,11,a[45]),y=p(y,P,N,D,v,16,a[46]),N=u(N,D=p(D,y,P,N,S,23,a[47]),y,P,o,6,a[48]),P=u(P,N,D,y,R,10,a[49]),y=u(y,P,N,D,A,15,a[50]),D=u(D,y,P,N,m,21,a[51]),N=u(N,D,y,P,C,6,a[52]),P=u(P,N,D,y,E,10,a[53]),y=u(y,P,N,D,_,15,a[54]),D=u(D,y,P,N,c,21,a[55]),N=u(N,D,y,P,f,6,a[56]),P=u(P,N,D,y,v,10,a[57]),y=u(y,P,N,D,g,15,a[58]),D=u(D,y,P,N,O,21,a[59]),N=u(N,D,y,P,h,6,a[60]),P=u(P,N,D,y,I,10,a[61]),y=u(y,P,N,D,S,15,a[62]),D=u(D,y,P,N,T,21,a[63]),i[0]=i[0]+N|0,i[1]=i[1]+D|0,i[2]=i[2]+y|0,i[3]=i[3]+P|0;},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,s=8*t.sigBytes;r[s>>>5]|=128<<24-s%32;var i=e.floor(n/4294967296),o=n;r[15+(s+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),r[14+(s+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,d=0;d<4;d++){var l=c[d];c[d]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8);}return a},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function d(e,t,r,n,s,i,o){var a=e+(t&r|~t&n)+s+o;return (a<>>32-i)+t}function l(e,t,r,n,s,i,o){var a=e+(t&n|r&~n)+s+o;return (a<>>32-i)+t}function p(e,t,r,n,s,i,o){var a=e+(t^r^n)+s+o;return (a<>>32-i)+t}function u(e,t,r,n,s,i,o){var a=e+(r^(t|~n))+s+o;return (a<>>32-i)+t}t.MD5=i._createHelper(c),t.HmacMD5=i._createHmacHelper(c);}(Math),r.MD5);})),O((function(e,t){var r,n,s,i,o,a,c,d;e.exports=(n=(r=d=Sr).lib,s=n.WordArray,i=n.Hasher,o=r.algo,a=[],c=o.SHA1=i.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],s=r[1],i=r[2],o=r[3],c=r[4],d=0;d<80;d++){if(d<16)a[d]=0|e[t+d];else{var l=a[d-3]^a[d-8]^a[d-14]^a[d-16];a[d]=l<<1|l>>>31;}var p=(n<<5|n>>>27)+c+a[d];p+=d<20?1518500249+(s&i|~s&o):d<40?1859775393+(s^i^o):d<60?(s&i|s&o|i&o)-1894007588:(s^i^o)-899497514,c=o,o=i,i=s<<30|s>>>2,s=n,n=p;}r[0]=r[0]+n|0,r[1]=r[1]+s|0,r[2]=r[2]+i|0,r[3]=r[3]+o|0,r[4]=r[4]+c|0;},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=i._createHelper(c),r.HmacSHA1=i._createHmacHelper(c),d.SHA1);})),O((function(e,t){var r;e.exports=(r=Sr,function(e){var t=r,n=t.lib,s=n.WordArray,i=n.Hasher,o=t.algo,a=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return !1;return !0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,s=0;s<64;)t(n)&&(s<8&&(a[s]=r(e.pow(n,.5))),c[s]=r(e.pow(n,1/3)),s++),n++;}();var d=[],l=o.SHA256=i.extend({_doReset:function(){this._hash=new s.init(a.slice(0));},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],s=r[1],i=r[2],o=r[3],a=r[4],l=r[5],p=r[6],u=r[7],S=0;S<64;S++){if(S<16)d[S]=0|e[t+S];else{var E=d[S-15],h=(E<<25|E>>>7)^(E<<14|E>>>18)^E>>>3,m=d[S-2],g=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;d[S]=h+d[S-7]+g+d[S-16];}var R=n&s^n&i^s&i,f=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),T=u+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&p)+c[S]+d[S];u=p,p=l,l=a,a=o+T|0,o=i,i=s,s=n,n=T+(f+R)|0;}r[0]=r[0]+n|0,r[1]=r[1]+s|0,r[2]=r[2]+i|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+p|0,r[7]=r[7]+u|0;},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,s=8*t.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=e.floor(n/4294967296),r[15+(s+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(l),t.HmacSHA256=i._createHmacHelper(l);}(Math),r.SHA256);})),O((function(e,t){var r,n,s,i,o,a;e.exports=(n=(r=a=Sr).lib.WordArray,s=r.algo,i=s.SHA256,o=s.SHA224=i.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);},_doFinalize:function(){var e=i._doFinalize.call(this);return e.sigBytes-=4,e}}),r.SHA224=i._createHelper(o),r.HmacSHA224=i._createHmacHelper(o),a.SHA224);})),O((function(e,t){var r;e.exports=(r=Sr,function(){var e=r,t=e.lib.Hasher,n=e.x64,s=n.Word,i=n.WordArray,o=e.algo;function a(){return s.create.apply(s,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],d=[];!function(){for(var e=0;e<80;e++)d[e]=a();}();var l=o.SHA512=t.extend({_doReset:function(){this._hash=new i.init([new s.init(1779033703,4089235720),new s.init(3144134277,2227873595),new s.init(1013904242,4271175723),new s.init(2773480762,1595750129),new s.init(1359893119,2917565137),new s.init(2600822924,725511199),new s.init(528734635,4215389547),new s.init(1541459225,327033209)]);},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],s=r[1],i=r[2],o=r[3],a=r[4],l=r[5],p=r[6],u=r[7],S=n.high,E=n.low,h=s.high,m=s.low,g=i.high,R=i.low,f=o.high,T=o.low,_=a.high,I=a.low,C=l.high,O=l.low,A=p.high,v=p.low,N=u.high,D=u.low,y=S,P=E,M=h,k=m,w=g,b=R,L=f,G=T,U=_,F=I,B=C,x=O,V=A,H=v,j=N,W=D,K=0;K<80;K++){var $=d[K];if(K<16)var Y=$.high=0|e[t+2*K],z=$.low=0|e[t+2*K+1];else{var J=d[K-15],Q=J.high,X=J.low,q=(Q>>>1|X<<31)^(Q>>>8|X<<24)^Q>>>7,Z=(X>>>1|Q<<31)^(X>>>8|Q<<24)^(X>>>7|Q<<25),ee=d[K-2],te=ee.high,re=ee.low,ne=(te>>>19|re<<13)^(te<<3|re>>>29)^te>>>6,se=(re>>>19|te<<13)^(re<<3|te>>>29)^(re>>>6|te<<26),ie=d[K-7],oe=ie.high,ae=ie.low,ce=d[K-16],de=ce.high,le=ce.low;Y=(Y=(Y=q+oe+((z=Z+ae)>>>0>>0?1:0))+ne+((z+=se)>>>0>>0?1:0))+de+((z+=le)>>>0>>0?1:0),$.high=Y,$.low=z;}var pe,ue=U&B^~U&V,Se=F&x^~F&H,Ee=y&M^y&w^M&w,he=P&k^P&b^k&b,me=(y>>>28|P<<4)^(y<<30|P>>>2)^(y<<25|P>>>7),ge=(P>>>28|y<<4)^(P<<30|y>>>2)^(P<<25|y>>>7),Re=(U>>>14|F<<18)^(U>>>18|F<<14)^(U<<23|F>>>9),fe=(F>>>14|U<<18)^(F>>>18|U<<14)^(F<<23|U>>>9),Te=c[K],_e=Te.high,Ie=Te.low,Ce=j+Re+((pe=W+fe)>>>0>>0?1:0),Oe=ge+he;j=V,W=H,V=B,H=x,B=U,x=F,U=L+(Ce=(Ce=(Ce=Ce+ue+((pe+=Se)>>>0>>0?1:0))+_e+((pe+=Ie)>>>0>>0?1:0))+Y+((pe+=z)>>>0>>0?1:0))+((F=G+pe|0)>>>0>>0?1:0)|0,L=w,G=b,w=M,b=k,M=y,k=P,y=Ce+(me+Ee+(Oe>>>0>>0?1:0))+((P=pe+Oe|0)>>>0>>0?1:0)|0;}E=n.low=E+P,n.high=S+y+(E>>>0