Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@100mslive/hms-video-store

Package Overview
Dependencies
Maintainers
16
Versions
730
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@100mslive/hms-video-store - npm Package Compare versions

Comparing version 0.2.16 to 0.2.17

9

dist/core/hmsSDKStore/common/mapping.d.ts

@@ -1,6 +0,7 @@

interface notifcationMap {
[key: number]: string;
import { HMSNotificationTypes } from '../../schema';
interface notificationMap {
[key: number]: HMSNotificationTypes;
}
export declare const PEER_NOTIFICATION_TYPES: notifcationMap;
export declare const TRACK_NOTIFICATION_TYPES: notifcationMap;
export declare const PEER_NOTIFICATION_TYPES: notificationMap;
export declare const TRACK_NOTIFICATION_TYPES: notificationMap;
export {};
import { IHMSNotifications } from '../IHMSNotifications';
import { IHMSStore } from '../IHMSStore';
import * as sdkTypes from './sdkTypes';
import { HMSNotification, HMSPeer, HMSException, HMSMessage, HMSChangeTrackStateRequest, HMSLeaveRoomRequest } from '../schema';
import { HMSNotification, HMSNotificationTypes, HMSPeer, HMSException, HMSMessage, HMSChangeTrackStateRequest, HMSLeaveRoomRequest } from '../schema';
export declare class HMSNotifications implements IHMSNotifications {

@@ -10,3 +10,3 @@ private id;

constructor(store: IHMSStore);
onNotification: (cb: (notification: HMSNotification) => void) => (() => void);
onNotification: (cb: (notification: HMSNotification<HMSNotificationTypes>) => void) => (() => void);
sendLeaveRoom(request: HMSLeaveRoomRequest): void;

@@ -13,0 +13,0 @@ sendPeerUpdate(type: sdkTypes.HMSPeerUpdate, peer: HMSPeer | null): void;

@@ -5,3 +5,3 @@ import { HMSMessage, HMSTrackID, HMSTrackSource } from '../schema';

import { HMSRoleChangeRequest } from '../selectors';
import { HMSSdk, HMSVideoPlugin, HMSTrack as SDKHMSTrack, HMSException as SDKHMSException, HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest, HMSSimulcastLayer, HMSLogLevel } from '@100mslive/hms-video';
import { HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest, HMSException as SDKHMSException, HMSLogLevel, HMSSdk, HMSSimulcastLayer, HMSTrack as SDKHMSTrack, HMSVideoPlugin } from '@100mslive/hms-video';
import { IHMSStore } from '../IHMSStore';

@@ -34,3 +34,2 @@ import { HMSNotifications } from './HMSNotifications';

private readonly store;
private isRoomJoinCalled;
private hmsNotifications;

@@ -37,0 +36,0 @@ constructor(store: IHMSStore, sdk: HMSSdk, notificationManager: HMSNotifications);

@@ -1,3 +0,3 @@

import { HMSNotification } from './schema/notification';
declare type NotificationCallback = (notification: HMSNotification) => void;
import { HMSNotification, HMSNotificationTypes } from './schema/notification';
declare type NotificationCallback = (notification: HMSNotification<HMSNotificationTypes>) => void;
/**

@@ -4,0 +4,0 @@ * @category Core

@@ -1,16 +0,10 @@

export interface HMSNotification {
id: number;
type: string;
message: string;
/**
* HMSPeer | HMSTrack | HMSMessage | HMSException
*/
data?: any;
severity?: HMSNotificationSeverity;
}
export declare enum HMSNotificationSeverity {
INFO = "info",
ERROR = "error",
CRITICAL = "critical"
}
import { HMSPeer, HMSTrack } from './peer';
import { HMSMessage } from './message';
import { HMSException } from './error';
import { HMSRole } from '@100mslive/hms-video';
import { HMSChangeTrackStateRequest, HMSLeaveRoomRequest } from './requests';
/**
* @privateRemarks
* if you add a new field here add it to NotificationDataTypeMap too
*/
export declare enum HMSNotificationTypes {

@@ -27,3 +21,2 @@ PEER_JOINED = "PEER_JOINED",

TRACK_UNMUTED = "TRACK_UNMUTED",
ROLE_CHANGE_REQUEST = "ROLE_CHANGE_REQUEST",
ROLE_UPDATED = "ROLE_UPDATED",

@@ -34,1 +27,40 @@ CHANGE_TRACK_STATE_REQUEST = "CHANGE_TRACK_STATE_REQUEST",

}
/**
* this map is to give proper types for notification.data, repeating is not good, but there doesn't seem to be
* any other way at the time of writing. A enum has to be provided so UI can refer types using it and ts interfaces
* don't allow for dynamic keys.
*/
export interface NotificationDataTypeMap {
PEER_JOINED: HMSPeer;
PEER_LEFT: HMSPeer;
NEW_MESSAGE: HMSMessage;
ERROR: HMSException;
RECONNECTING: HMSException;
RECONNECTED: null;
TRACK_ADDED: HMSTrack;
TRACK_REMOVED: HMSTrack;
TRACK_MUTED: HMSTrack;
TRACK_UNMUTED: HMSTrack;
ROLE_UPDATED: HMSRole;
CHANGE_TRACK_STATE_REQUEST: HMSChangeTrackStateRequest;
ROOM_ENDED: HMSLeaveRoomRequest;
REMOVED_FROM_ROOM: HMSLeaveRoomRequest;
}
/**
* error is used to notify about mid call errors. info is for informational messages which can be used to show
* notifications to the user.
*/
export declare enum HMSNotificationSeverity {
INFO = "info",
ERROR = "error"
}
export interface HMSNotification<K extends keyof NotificationDataTypeMap> {
id: number;
type: K;
message: string;
/**
* HMSPeer | HMSTrack | HMSMessage | HMSException
*/
data?: NotificationDataTypeMap[K];
severity?: HMSNotificationSeverity;
}

@@ -140,2 +140,6 @@ import { HMSMessage, HMSPeer, HMSPeerID, HMSRoom, HMSRoomState, HMSStore } from '../schema';

export declare const selectIsInPreview: import("reselect").OutputSelector<HMSStore, boolean, (res: HMSRoomState) => boolean>;
/**
* This would be true if either of preview/join call has happened, and the process of joining the room has started.
* This would become false after leave or a terminal error.
*/
export declare const selectRoomStarted: import("reselect").OutputSelector<HMSStore, boolean, (res: HMSRoom) => boolean>;

@@ -166,2 +170,5 @@ /**

muteAll: boolean;
/**
* @internal
*/
askToUnmute: boolean;

@@ -175,2 +182,5 @@ muteSelective: boolean;

muteAll: boolean;
/**
* @internal
*/
askToUnmute: boolean;

@@ -177,0 +187,0 @@ muteSelective: boolean;

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("immer")),r=e(require("zustand/vanilla")),n=e(require("zustand/shallow")),o=require("@100mslive/hms-video"),i=require("reselect"),s=e(require("events"));function a(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){a(i,n,o,s,c,"next",e)}function c(e){a(i,n,o,s,c,"throw",e)}s(void 0)}))}}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,h,p=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new x(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=y(s,r);if(a){if(a===l)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,i),o}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function d(){}function f(){}function h(){}var p={};p[o]=function(){return this};var v=Object.getPrototypeOf,S=v&&v(v(b([])));S&&S!==t&&r.call(S,o)&&(p=S);var m=h.prototype=d.prototype=Object.create(p);function g(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){var n;this._invoke=function(o,i){function s(){return new t((function(n,s){!function n(o,i,s,a){var c=u(e[o],e,i);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(c.arg)}(o,i,n,s)}))}return n=n?n.then(s,s):s()}}function y(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,y(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function b(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return f.prototype=m.constructor=h,h.constructor=f,f.displayName=a(h,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,a(e,s,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(k.prototype),k.prototype[i]=function(){return this},e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new k(c(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},g(m),a(m,s,"Generator"),m[o]=function(){return this},m.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=b,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),R(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;R(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:b(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(h={exports:{}}),h.exports);(f=exports.HMSRoomState||(exports.HMSRoomState={})).Disconnected="Disconnected",f.Preview="Preview",f.Connecting="Connecting",f.Connected="Connected",f.Reconnecting="Reconnecting",f.Failed="Failed";var v,S,m=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1,roomState:exports.HMSRoomState.Disconnected},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:""},devices:{audioInput:[],audioOutput:[],videoInput:[]},roles:{},roleChangeRequests:[],errors:[]}};(exports.HMSMessageType||(exports.HMSMessageType={})).CHAT="chat",(v=exports.HMSNotificationSeverity||(exports.HMSNotificationSeverity={})).INFO="info",v.ERROR="error",v.CRITICAL="critical",(S=exports.HMSNotificationTypes||(exports.HMSNotificationTypes={})).PEER_JOINED="PEER_JOINED",S.PEER_LEFT="PEER_LEFT",S.NEW_MESSAGE="NEW_MESSAGE",S.ERROR="ERROR",S.RECONNECTING="RECONNECTING",S.RECONNECTED="RECONNECTED",S.TRACK_ADDED="TRACK_ADDED",S.TRACK_REMOVED="TRACK_REMOVED",S.TRACK_MUTED="TRACK_MUTED",S.TRACK_UNMUTED="TRACK_UNMUTED",S.ROLE_CHANGE_REQUEST="ROLE_CHANGE_REQUEST",S.ROLE_UPDATED="ROLE_UPDATED",S.CHANGE_TRACK_STATE_REQUEST="CHANGE_TRACK_STATE_REQUEST",S.ROOM_ENDED="ROOM_ENDED",S.REMOVED_FROM_ROOM="REMOVED_FROM_ROOM";var g=function(e,t){return e&&t},k=function(e,t){return e&&!t},y=function(e,t){return!e&&t},T=function(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},R=function(e,t){for(var r,n=new Set,o=d(e);!(r=o()).done;)n.add(r.value);for(var i,s=d(t);!(i=s()).done;)n.add(i.value);return Array.from(n)};function x(e,t,r,n){e.isLocal&&e.videoTrack&&t.videoTrack&&e.videoTrack!==t.videoTrack&&(n[e.videoTrack]=n[t.videoTrack],delete n[t.videoTrack],r[e.videoTrack]=r[t.videoTrack],r[e.videoTrack].id=e.videoTrack,delete r[t.videoTrack],t.videoTrack=e.videoTrack)}var b=function(){function e(){}return e.convertPeer=function(e){var t,r,n;return{id:e.peerId,name:e.name,roleName:null==(t=e.role)?void 0:t.name,isLocal:e.isLocal,videoTrack:null==(r=e.videoTrack)?void 0:r.trackId,audioTrack:null==(n=e.audioTrack)?void 0:n.trackId,auxiliaryTracks:e.auxiliaryTracks.map((function(e){return e.trackId})),customerUserId:e.customerUserId,customerDescription:e.customerDescription}},e.convertTrack=function(e){var t={id:e.trackId,source:e.source,type:e.type,enabled:e.enabled,displayEnabled:e.enabled};return this.enrichTrack(t,e),t},e.enrichTrack=function(t,r){var n=r.getMediaTrackSettings();if(t.height=n.height,t.width=n.width,t.deviceID=n.deviceId,r instanceof o.HMSRemoteAudioTrack){var i=r.getVolume();i&&(t.volume=i)}e.enrichVideoTrack(t,r)},e.enrichVideoTrack=function(e,t){t instanceof o.HMSRemoteVideoTrack&&(e.layer=t.getSimulcastLayer(),e.degraded=t.degraded,T(t.getSimulcastDefinitions(),e.layerDefinitions)||(e.layerDefinitions=t.getSimulcastDefinitions())),t instanceof o.HMSLocalVideoTrack&&(T(t.getPlugins(),e.plugins)||(e.plugins=t.getPlugins()))},e.convertRoom=function(e){return{id:e.id,name:e.name,hasWaitingRoom:e.hasWaitingRoom,shareableLink:e.shareableLink}},e.convertMessage=function(e){var t,r,n;return{sender:e.sender.peerId,senderName:e.sender.name,senderRole:null==(t=e.sender.role)?void 0:t.name,senderUserId:e.sender.customerUserId,recipientPeer:null==(r=e.recipientPeer)?void 0:r.peerId,recipientRoles:null==(n=e.recipientRoles)?void 0:n.map((function(e){return e.name})),time:e.time,type:e.type,message:e.message}},e.convertRoles=function(e){var t={};return e&&e.forEach((function(e){t[e.name]=e})),t},e.convertRoleChangeRequest=function(e){return{requestedBy:e.requestedBy.peerId,roleName:e.role.name,token:e.token}},e.convertException=function(e){return{code:e.code,action:e.action,name:e.name,message:e.message,description:e.description,isTerminal:e.isTerminal,timestamp:new Date}},e}();function E(e,t){return t&&t.auxiliaryTracks.some((function(t){return!(!t||!e.tracks[t])&&D(e.tracks[t])}))}function I(e){return e&&"audio"===e.type}function D(e){return e&&"screen"===e.source}function M(e){return Boolean(null==e?void 0:e.degraded)}function w(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].enabled}var P=function(e){return e.room},L=function(e){return e.peers},O=function(e){return e.messages.byID},N=function(e){return e.messages.allIDs},A=function(e){return e.tracks},C=function(e){return e.speakers},_=i.createSelector([P],(function(e){return e&&e.isConnected})),H=i.createSelector([P,L],(function(e,t){return e.peers.map((function(e){return t[e]}))})),U=i.createSelector(A,(function(e){return Object.values(e)})),K=i.createSelector(H,(function(e){return e.filter((function(e){return e.isLocal}))[0]})),V=i.createSelector(K,(function(e){return null==e?void 0:e.id})),B=i.createSelector(K,(function(e){return null==e?void 0:e.audioTrack})),q=i.createSelector(K,(function(e){return null==e?void 0:e.videoTrack})),j=i.createSelector([B,q,i.createSelector(K,(function(e){return null==e?void 0:e.auxiliaryTracks}))],(function(e,t,r){var n=[].concat(r);return e&&n.unshift(e),t&&n.unshift(t),n})),F=i.createSelector(H,(function(e){return e.filter((function(e){return!e.isLocal}))})),G=i.createSelector(L,C,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,o=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>o?1:-1}));if(r.length>0&&r[0][1].audioLevel&&r[0][1].audioLevel>0){var n=r[0][1].peerID;if(n in e)return e[n]}return null})),J=function(e){var t=K(e);return w(e,null==t?void 0:t.videoTrack)},W=function(e){var t=K(e);return function(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].displayEnabled}(e,null==t?void 0:t.videoTrack)},Q=function(e){return E(e,K(e))},X=i.createSelector(U,(function(e){return e.filter(M)})),Y=i.createSelector(N,(function(e){return e.length})),z=i.createSelector(O,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),$=i.createSelector(N,O,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r})),Z=i.createSelector([P],(function(e){return e&&e.roomState})),ee=i.createSelector(Z,(function(e){return e===exports.HMSRoomState.Preview})),te=i.createSelector(P,(function(e){return e.roomState!==exports.HMSRoomState.Disconnected})),re=function(e){return e.roles},ne=i.createSelector([re],(function(e){return Object.keys(e)})),oe=i.createSelector([K,re],(function(e,t){return null!=e&&e.roleName?t[e.roleName]:null})),ie=i.createSelector([oe],(function(e){var t;return!(null==e||null==(t=e.subscribeParams)||!t.subscribeToRoles)&&e.subscribeParams.subscribeToRoles.length>0})),se=i.createSelector(oe,(function(e){return null==e?void 0:e.permissions})),ae="HMS-Store:",ce=function(){function e(){}return e.v=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.log.apply(this,[o.HMSLogLevel.VERBOSE,e].concat(r))},e.d=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[o.HMSLogLevel.DEBUG].concat(t))},e.i=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[o.HMSLogLevel.INFO].concat(t))},e.w=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[o.HMSLogLevel.WARN].concat(t))},e.e=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[o.HMSLogLevel.ERROR].concat(t))},e.log=function(e){if(!(this.level.valueOf()>e.valueOf())){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];switch(e){case o.HMSLogLevel.VERBOSE:var i;(i=console).log.apply(i,[ae].concat(r));break;case o.HMSLogLevel.DEBUG:var s;(s=console).debug.apply(s,[ae].concat(r));break;case o.HMSLogLevel.INFO:var a;(a=console).info.apply(a,[ae].concat(r));break;case o.HMSLogLevel.WARN:var c;(c=console).warn.apply(c,[ae].concat(r));break;case o.HMSLogLevel.ERROR:var u;(u=console).error.apply(u,[ae].concat(r))}}},e}();function ue(e){return function(t){return function(r){return e(r,t)}}}ce.level=o.HMSLogLevel.VERBOSE;var le,de,fe=function(e,t){return t},he=function(e,t){return t},pe=i.createSelector([L,fe],(function(e,t){return t?e[t]:null})),ve=i.createSelector([A,function(e,t){return t}],(function(e,t){return t?e[t]:null})),Se=ue(pe),me=ue(i.createSelector(pe,(function(e){return null==e?void 0:e.name}))),ge=ue(ve),ke=ue((function(e,t){var r=pe(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),ye=ue((function(e,t){var r=pe(e,t);if(r&&r.audioTrack&&""!==r.audioTrack)return e.tracks[r.audioTrack]})),Te=ke,Re=ue((function(e,t){var r=pe(e,t);return(null==r?void 0:r.auxiliaryTracks.map((function(t){return e.tracks[t]})))||[]})),xe=function(e,t){return t?e.speakers[t]:null},be=ue(i.createSelector(xe,(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ee=ue(i.createSelector((function(e,t){var r=ye(t)(e);return xe(e,null==r?void 0:r.id)}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ie=ue((function(e,t){var r=pe(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return I(e.tracks[t])}));return n?e.tracks[n]:void 0}})),De=ue((function(e,t){var r=pe(e,t);if(r&&E(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){var r=e.tracks[t];return function(e){return e&&"video"===e.type}(r)&&D(r)}));return n?e.tracks[n]:void 0}})),Me=ue((function(e,t){var r=pe(e,t);if(r&&E(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){var r=e.tracks[t];return I(r)&&D(r)}));return n?e.tracks[n]:void 0}})),we=ue((function(e,t){var r=pe(e,t);return w(e,null==r?void 0:r.audioTrack)})),Pe=ue((function(e,t){var r=pe(e,t);return w(e,null==r?void 0:r.videoTrack)})),Le=ue((function(e,t){if(t&&e.tracks[t])return 0===e.tracks[t].volume})),Oe=ue((function(e,t){var r=pe(e,t);return Le(null==r?void 0:r.audioTrack)(e)})),Ne=ue((function(e,t){var r=Me(t)(e);return Le(null==r?void 0:r.id)(e)})),Ae=ue((function(e,t){var r=ve(e,t);if(r)return"audio"!==r.type?void ce.w("Please pass audio track here"):r.volume})),Ce=ue((function(e,t){var r=pe(e,t);return Ae(null==r?void 0:r.audioTrack)(e)})),_e=ue((function(e,t){var r=Me(t)(e);return Ae(null==r?void 0:r.id)(e)})),He=ue((function(e,t){var r=ve(e,t);if(r)return"video"!==r.type?void ce.w("Please pass video track here"):r.layer})),Ue=i.createSelector([$,V,fe],(function(e,t,r){if(r)return e.filter((function(e){var n;return!!(e.recipientPeer||null!=(n=e.recipientRoles)&&n.length)&&!![t,r].includes(e.sender)&&[t,r].includes(e.recipientPeer)}))})),Ke=i.createSelector([$,he],(function(e,t){if(t)return e.filter((function(e){var r,n;return!!(e.recipientPeer||null!=(r=e.recipientRoles)&&r.length)&&((null==(n=e.recipientRoles)?void 0:n.includes(t))||e.senderRole===t)}))})),Ve=i.createSelector($,(function(e){return e.filter((function(e){var t;return!(e.recipientPeer||null!=(t=e.recipientRoles)&&t.length)}))})),Be=i.createSelector([Ke,he],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),qe=i.createSelector([Ue,fe],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),je=i.createSelector(Ve,(function(e){return e.filter((function(e){return!e.read})).length})),Fe=ue(Ue),Ge=ue(Ke),Je=ue(Be),We=ue(qe),Qe=i.createSelector([L,A],(function(e,t){return Object.values(e).map((function(e){var r;return{peer:e,isAudioEnabled:!!e.audioTrack&&(null==(r=t[e.audioTrack])?void 0:r.enabled)}}))})),Xe=i.createSelector([function(e){return e.roleChangeRequests[0]||null},L,re],(function(e,t,r){return e?{requestedBy:t[e.requestedBy],role:r[e.roleName],token:e.token}:null})),Ye=i.createSelector([oe],(function(e){var t,r=!1,n=!1,o=!1;return null!=e&&null!=(t=e.publishParams)&&t.allowed&&(r=e.publishParams.allowed.includes("video"),n=e.publishParams.allowed.includes("audio"),o=e.publishParams.allowed.includes("screen")),{video:r,audio:n,screen:o}})),ze=i.createSelector([q,A],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]})),$e=function(){function e(e,t,r){var n=this;this.hmsSDKTracks={},this.hmsSDKPeers={},this.isRoomJoinCalled=!1,this.setState=function(e,t){return n.store.namedSetState(e,t)},this.store=e,this.sdk=t,this.hmsNotifications=r}var t=e.prototype;return t.unblockAudio=function(){var e=c(p.mark((function e(){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.getAudioOutput().unblockAutoplay();case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setVolume=function(e,t){t?this.setTrackVolume(e,t):(this.sdk.getAudioOutput().setVolume(e),this.syncRoomState("setVolume"))},t.setAudioOutputDevice=function(e){this.sdk.getAudioOutput().setDevice(e),this.syncRoomState("setAudioOutput")},t.setPreferredLayer=function(e,t){var r=this.hmsSDKTracks[e];r?r instanceof o.HMSRemoteVideoTrack?(r.preferLayer(t),this.syncRoomState("setPreferredLayer")):ce.w("track "+e+" is not an video track"):this.logPossibleInconsistency("track "+e+" not present, unable to set preffer layer")},t.preview=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isRoomJoinCalled){e.next=3;break}return this.logPossibleInconsistency("attempting to call preview after join was called"),e.abrupt("return");case 3:return e.prev=3,e.next=6,this.sdkPreviewWithListeners(t);case 6:this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"preview"),e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(3),ce.e("Cannot show preview. Failed to connect to room - ",e.t0),e.t0;case 13:case"end":return e.stop()}}),e,this,[[3,9]])})));return function(t){return e.apply(this,arguments)}}(),t.join=function(e){if(this.isRoomJoinCalled)this.logPossibleInconsistency("room join is called again");else try{this.sdkJoinWithListeners(e),this.isRoomJoinCalled=!0,this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"join")}catch(e){throw this.isRoomJoinCalled=!1,ce.e("Failed to connect to room - ",e),e}},t.leave=function(){var e=c(p.mark((function e(){var t=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(te)){e.next=4;break}return this.logPossibleInconsistency("room leave is called when no room is connected"),e.abrupt("return");case 4:return e.abrupt("return",this.sdk.leave().then((function(){t.resetState(),ce.i("left room")})).catch((function(e){ce.e("error in leaving room - ",e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setScreenShareEnabled=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=5;break}return e.next=3,this.startScreenShare();case 3:e.next=7;break;case 5:return e.next=7,this.stopScreenShare();case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.addTrack=function(){var e=c(p.mark((function e(t,r){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r="regular"),e.next=3,this.sdk.addTrack(t,r);case 3:this.syncRoomState("addTrack");case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removeTrack=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.removeTrack(t);case 2:this.syncRoomState("removeTrack");case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalAudioEnabled=function(){var e=c(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(B))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalVideoEnabled=function(){var e=c(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(q))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setEnabledTrack=function(){var e=c(p.mark((function e(t,r){var n,i=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null==(n=this.store.getState().tracks[t])?void 0:n.enabled)!==r){e.next=4;break}return this.logPossibleInconsistency("local track["+t+"] enabled state - "+r),e.abrupt("return");case 4:return this.setState((function(e){e.tracks[t]?e.tracks[t].displayEnabled=r:i.logPossibleInconsistency("track id not found for setEnabled")}),"displayEnabled"),e.prev=5,e.next=8,this.setEnabledSDKTrack(t,r);case 8:this.syncRoomState("setEnabled"),e.next=15;break;case 11:throw e.prev=11,e.t0=e.catch(5),this.setState((function(e){e.tracks[t].displayEnabled=!r}),"rollbackDisplayEnabled"),e.t0;case 15:this.hmsNotifications.sendTrackUpdate(r?o.HMSTrackUpdate.TRACK_UNMUTED:o.HMSTrackUpdate.TRACK_MUTED,t);case 17:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),t.setAudioSettings=function(){var e=c(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(B))){e.next=5;break}return e.next=4,this.setSDKLocalAudioTrackSettings(r,t);case 4:this.syncRoomState("setAudioSettings");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setVideoSettings=function(){var e=c(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(q))){e.next=5;break}return e.next=4,this.setSDKLocalVideoTrackSettings(r,t);case 4:this.syncRoomState("setVideoSettings");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.sendMessage=function(e){this.sendBroadcastMessage(e)},t.sendBroadcastMessage=function(){var e=c(p.mark((function e(t,r){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.sendBroadcastMessage(t,r);case 2:this.updateMessageInStore(e.sent,{message:t,type:r});case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.sendGroupMessage=function(){var e=c(p.mark((function e(t,r,n){var o,i;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.store.getState(re),i=r.map((function(e){return o[e]})),e.next=4,this.sdk.sendGroupMessage(t,i,n);case 4:this.updateMessageInStore(e.sent,{message:t,recipientRoles:r,type:n});case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.sendDirectMessage=function(){var e=c(p.mark((function e(t,r,n){var o;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.hmsSDKPeers[r],e.next=3,this.sdk.sendDirectMessage(t,o);case 3:this.updateMessageInStore(e.sent,{message:t,recipientPeer:o.peerId,type:n});case 5:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.updateMessageInStore=function(e,t){if(!e)throw ce.w("sendMessage","Failed to send message",t),Error("sendMessage Failed - "+JSON.stringify(t));var r=b.convertMessage(e);return r.read=!0,r.senderName="You",this.onHMSMessage(r),r},t.setMessageRead=function(e,t){var r=this;this.setState((function(n){t?n.messages.byID[t]?n.messages.byID[t].read=e:r.logPossibleInconsistency("no message with id is found"):n.messages.allIDs.forEach((function(t){n.messages.byID[t].read=e}))}),"setMessageRead")},t.attachVideo=function(){var e=c(p.mark((function e(t,r){var n=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localAndVideoUnmuting(t)){e.next=4;break}return e.abrupt("return",new Promise((function(e){var o=n.store.subscribe(function(){var i=c(p.mark((function i(s){return p.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!s){i.next=5;break}return i.next=3,n.attachVideoInternal(t,r);case 3:o(),e();case 5:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}(),J)})));case 4:return e.next=6,this.attachVideoInternal(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.detachVideo=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=6;break}return e.next=4,n.removeSink(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("no video track found to remove sink");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addPluginToVideoTrack=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"add"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.removePluginFromVideoTrack=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"remove"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.changeRole=function(e,t,r){void 0===r&&(r=!1);var n=this.hmsSDKPeers[e];n?n.isLocal?ce.w("changing role for local peer is not yet supported"):this.sdk.changeRole(n,t,r):this.logPossibleInconsistency("Unknown peer ID given "+e+" for changerole")},t.acceptChangeRole=function(e){var t=this.hmsSDKPeers[e.requestedBy.id];t?(this.sdk.acceptChangeRole({requestedBy:t,role:e.role,token:e.token}),this.removeRoleChangeRequest(e)):ce.w("peer for which role change is requested no longer available - "+e.requestedBy)},t.rejectChangeRole=function(e){this.removeRoleChangeRequest(e)},t.endRoom=function(e,t){var r=this.store.getState(se);null!=r&&r.endRoom?this.sdk.endRoom(e,t):ce.w("You are not allowed to perform this action - endRoom")},t.removePeer=function(e,t){var r=this.hmsSDKPeers[e];r&&!r.isLocal?this.sdk.removePeer(r,t):this.logPossibleInconsistency("No remote peer found for peerID - "+e)},t.setRemoteTrackEnabled=function(e,t){var r=this;if("string"==typeof e){var n=this.hmsSDKTracks[e];n&&function(e){return e instanceof o.HMSRemoteAudioTrack||e instanceof o.HMSRemoteVideoTrack}(n)?this.sdk.changeTrackState(n,t):this.logPossibleInconsistency("No remote track with ID "+e+" found for change track state")}else Array.isArray(e)&&e.forEach((function(e){return r.setRemoteTrackEnabled(e,t)}))},t.setLogLevel=function(e){ce.level=e,this.sdk.setLogLevel(e)},t.resetState=function(){this.setState((function(e){Object.assign(e,m())}),"resetState"),this.isRoomJoinCalled=!1,this.hmsSDKTracks={}},t.sdkJoinWithListeners=function(e){this.sdk.join(e,{onJoin:this.onJoin.bind(this),onRoomUpdate:this.onRoomUpdate.bind(this),onPeerUpdate:this.onPeerUpdate.bind(this),onTrackUpdate:this.onTrackUpdate.bind(this),onMessageReceived:this.onMessageReceived.bind(this),onError:this.onError.bind(this),onReconnected:this.onReconnected.bind(this),onReconnecting:this.onReconnecting.bind(this),onRoleChangeRequest:this.onRoleChangeRequest.bind(this),onRoleUpdate:this.onRoleUpdate.bind(this),onDeviceChange:this.onDeviceChange.bind(this),onChangeTrackStateRequest:this.onChangeTrackStateRequest.bind(this),onRemovedFromRoom:this.onRemovedFromRoom.bind(this)}),this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)})},t.onRemovedFromRoom=function(e){var t=this.store.getState(Se(e.requestedBy.peerId));t?this.hmsNotifications.sendLeaveRoom(u({},e,{requestedBy:t})):this.logPossibleInconsistency("Not found peer who requested leave room, "+e.requestedBy)},t.onDeviceChange=function(e){this.setState((function(t){T(t.devices.audioInput,e.audioInput)||(t.devices.audioInput=e.audioInput),T(t.devices.videoInput,e.videoInput)||(t.devices.videoInput=e.videoInput),T(t.devices.audioOutput,e.audioOutput)||(t.devices.audioOutput=e.audioOutput)}),"deviceChange"),this.syncRoomState("deviceChangeSync")},t.sdkPreviewWithListeners=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.preview(t,{onPreview:this.onPreview.bind(this),onError:this.onError.bind(this),onDeviceChange:this.onDeviceChange.bind(this)});case 2:this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)});case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.startScreenShare=function(){var e=c(p.mark((function e(){var t=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(Q)){e.next=7;break}return e.next=4,this.sdk.startScreenShare((function(){return t.syncRoomState("screenshareStopped")}));case 4:this.syncRoomState("startScreenShare"),e.next=8;break;case 7:this.logPossibleInconsistency("start screenshare is called while it's on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.stopScreenShare=function(){var e=c(p.mark((function e(){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.store.getState(Q)){e.next=7;break}return e.next=4,this.sdk.stopScreenShare();case 4:this.syncRoomState("stopScreenShare"),e.next=8;break;case 7:this.logPossibleInconsistency("stop screenshare is called while it's not on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.attachVideoInternal=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=7;break}return e.next=4,n.addSink(r);case 4:n instanceof o.HMSRemoteVideoTrack&&n.getSimulcastDefinitions().length>0&&this.setState((function(e){var r=n.getSimulcastLayer();e.tracks[t].layer=r}),"updateLayerOnAttach"),e.next=8;break;case 7:this.logPossibleInconsistency("no video track found to add sink");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.syncRoomState=function(e){for(var t,r=this,n={},o=[],i={},s={},a={},c=d(this.sdk.getPeers());!(t=c()).done;){var u=t.value,l=b.convertPeer(u);n[l.id]=l,o.push(l.id),this.hmsSDKPeers[l.id]=u;for(var f,h=d([u.audioTrack,u.videoTrack].concat(u.auxiliaryTracks));!(f=h()).done;){var p=f.value;if(p){var v=b.convertTrack(p);i[v.id]=v,s[p.trackId]=p}}l.isLocal&&Object.assign(a,this.getMediaSettings(u))}this.setState((function(e){e.room.peers=o;var t=e.tracks;!function(e,t,r,n){for(var o,i=d(R(Object.keys(e),Object.keys(t)));!(o=i()).done;){var s=o.value,a=e[s],c=t[s];g(a,c)?(T(a.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=a.auxiliaryTracks),x(a,c,r,n),Object.assign(a,c)):k(a,c)?delete e[s]:y(a,c)&&(e[s]=c)}}(e.peers,n,i,s),function(e,t){for(var r,n=d(R(Object.keys(e),Object.keys(t)));!(r=n()).done;){var o=r.value,i=e[o],s=t[o];g(i,s)?Object.assign(i,s):k(i,s)?delete e[o]:y(i,s)&&(e[o]=s)}}(t,i),Object.assign(e.settings,a),r.hmsSDKTracks=s,Object.assign(e.roles,b.convertRoles(r.sdk.getRoles()))}),e)},t.onPreview=function(e){this.setState((function(t){Object.assign(t.room,b.convertRoom(e)),t.room.roomState=exports.HMSRoomState.Preview}),"previewStart"),this.syncRoomState("previewSync")},t.onJoin=function(e){this.setState((function(t){Object.assign(t.room,b.convertRoom(e)),t.room.isConnected=!0,t.room.roomState=exports.HMSRoomState.Connected}),"joined"),this.syncRoomState("joinSync")},t.onRoomUpdate=function(){this.syncRoomState("roomUpdate")},t.onPeerUpdate=function(e,t){if(e!==o.HMSPeerUpdate.BECAME_DOMINANT_SPEAKER&&e!==o.HMSPeerUpdate.RESIGNED_DOMINANT_SPEAKER){var r=this.store.getState(Se(t.peerId)),n="peerUpdate";e===o.HMSPeerUpdate.PEER_JOINED?n="peerJoined":e===o.HMSPeerUpdate.PEER_LEFT&&(n="peerLeft"),this.syncRoomState(n),r||(r=this.store.getState(Se(t.peerId))),this.hmsNotifications.sendPeerUpdate(e,r)}},t.onTrackUpdate=function(e,t,r){e===o.HMSTrackUpdate.TRACK_REMOVED?(this.hmsNotifications.sendTrackUpdate(e,t.trackId),this.handleTrackRemove(t,r)):(this.syncRoomState(e===o.HMSTrackUpdate.TRACK_ADDED?"trackAdded":"trackUpdate"),this.hmsNotifications.sendTrackUpdate(e,t.trackId))},t.onMessageReceived=function(e){var t=b.convertMessage(e);t.read=!1,this.onHMSMessage(t),this.hmsNotifications.sendMessageReceived(t)},t.onHMSMessage=function(e){var t=this;this.setState((function(r){e.id=String(t.store.getState(Y)+1),r.messages.byID[e.id]=e,r.messages.allIDs.push(e.id)}),"newMessage")},t.onAudioLevelUpdate=function(e){this.setState((function(t){var r={};e.forEach((function(e){if(e.track){var n=e.track.trackId;r[n]=e.audioLevel,t.speakers[n]||(t.speakers[n]={audioLevel:e.audioLevel,peerID:e.peer.peerId,trackID:n})}}));for(var n=0,o=Object.entries(t.speakers);n<o.length;n++){var i=o[n],s=i[0],a=i[1];a.audioLevel=r[s]||0,0===a.audioLevel&&delete t.speakers[s]}}),"audioLevel")},t.onChangeTrackStateRequest=function(e){var t=this.store.getState(Se(e.requestedBy.peerId)),r=this.getStoreLocalTrackIDfromSDKTrack(e.track),n=this.store.getState(ge(r));return t?n?(e.enabled||this.syncRoomState("changeTrackStateRequest"),void this.hmsNotifications.sendChangeTrackStateRequest({requestedBy:t,track:n,enabled:e.enabled})):this.logPossibleInconsistency("Not found track for which track state change was requested, "+e.track):this.logPossibleInconsistency("Not found peer who requested track state change, "+e.requestedBy)},t.onReconnected=function(){this.syncRoomState("reconnectedSync"),this.hmsNotifications.sendReconnected(),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connected}),"reconnected")},t.onReconnecting=function(e){var t=b.convertException(e);ce.e("Reconnection: received error from sdk",t),this.hmsNotifications.sendReconnecting(t),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Reconnecting,e.errors.push(t)}),"reconnecting")},t.onError=function(e){var t=b.convertException(e);t.isTerminal?(this.leave().then((function(){return console.log("error from SDK, left room.")})),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Failed,e.errors.push(t)}),"errorTerminal")):this.store.getState().errors.length<50&&this.setState((function(e){e.errors.push(t)}),"error"),this.hmsNotifications.sendError(t),ce.e("received error from sdk",t)},t.handleTrackRemove=function(e,t){var r=this;this.setState((function(n){var o=n.peers[t.peerId],i=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,o.audioTrack))delete o.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,o.videoTrack))delete o.videoTrack;else{var s=o.auxiliaryTracks.indexOf(e.trackId);s>-1&&r.isSameStoreSDKTrack(e.trackId,o.auxiliaryTracks[s])&&o.auxiliaryTracks.splice(s,1)}delete i[e.trackId],delete r.hmsSDKTracks[e.trackId]}),"trackRemoved")},t.setEnabledSDKTrack=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setEnabled(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("track "+t+" not present, unable to enabled/disable");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalVideoTrackSettings=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalAudioTrackSettings=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.getMediaSettings=function(e){var t,r,n,o,i;return{audioInputDeviceId:null==(t=e.audioTrack)||null==(r=t.getMediaTrackSettings())?void 0:r.deviceId,videoInputDeviceId:null==(n=e.videoTrack)||null==(o=n.getMediaTrackSettings())?void 0:o.deviceId,audioOutputDeviceId:null==(i=this.sdk.getAudioOutput().getDevice())?void 0:i.deviceId}},t.setTrackVolume=function(e,t){var r=this.hmsSDKTracks[t];r?r instanceof o.HMSAudioTrack?(r.setVolume(e),this.syncRoomState("trackVolume")):ce.w("track "+t+" is not an audio track"):this.logPossibleInconsistency("track "+t+" not present, unable to set volume")},t.localAndVideoUnmuting=function(e){if(this.store.getState(K).videoTrack!==e)return!1;var t=this.store.getState(W),r=this.store.getState(J);return t&&!r},t.logPossibleInconsistency=function(e){ce.w("possible inconsistency detected - ",e)},t.addRemoveVideoPlugin=function(){var e=c(p.mark((function e(t,r){var n,o;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return ce.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(n=this.store.getState(q))){e.next=19;break}if(!(o=this.hmsSDKTracks[n])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,o.addPlugin(t);case 10:e.next=15;break;case 12:if("remove"!==r){e.next=15;break}return e.next=15,o.removePlugin(t);case 15:this.syncRoomState(r+"VideoPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+n+" not present, unable to remove plugin");case 19:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.isSameStoreSDKTrack=function(e,t){var r;return!!t&&(null==(r=this.hmsSDKTracks[t])?void 0:r.trackId)===e},t.onRoleChangeRequest=function(e){this.setState((function(t){0===t.roleChangeRequests.length&&t.roleChangeRequests.push(b.convertRoleChangeRequest(e))}),"roleChangeRequest")},t.removeRoleChangeRequest=function(e){this.setState((function(t){var r=t.roleChangeRequests.findIndex((function(t){return t.requestedBy===e.requestedBy.id&&t.roleName===e.role.name&&t.token===e.token}));-1!==r&&t.roleChangeRequests.splice(r,1)}),"removeRoleChangeRequest")},t.onRoleUpdate=function(){this.syncRoomState("roleUpdate")},t.getStoreLocalTrackIDfromSDKTrack=function(e){var t=this;return this.store.getState(j).find((function(r){return t.hmsSDKTracks[r].trackId===e.trackId}))},e}(),Ze=((le={})[o.HMSPeerUpdate.PEER_JOINED]=exports.HMSNotificationTypes.PEER_JOINED,le[o.HMSPeerUpdate.PEER_LEFT]=exports.HMSNotificationTypes.PEER_LEFT,le[o.HMSPeerUpdate.ROLE_UPDATED]=exports.HMSNotificationTypes.ROLE_UPDATED,le[o.HMSPeerUpdate.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",le[o.HMSPeerUpdate.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",le),et=((de={})[o.HMSTrackUpdate.TRACK_ADDED]=exports.HMSNotificationTypes.TRACK_ADDED,de[o.HMSTrackUpdate.TRACK_REMOVED]=exports.HMSNotificationTypes.TRACK_REMOVED,de[o.HMSTrackUpdate.TRACK_MUTED]=exports.HMSNotificationTypes.TRACK_MUTED,de[o.HMSTrackUpdate.TRACK_UNMUTED]=exports.HMSNotificationTypes.TRACK_UNMUTED,de),tt=function(){function e(e){var t=this;this.id=0,this.onNotification=function(e){return t.eventEmitter.addListener("hmsNotification",e),function(){t.eventEmitter.removeListener("hmsNotification",e)}},this.store=e,this.eventEmitter=new s}var t=e.prototype;return t.sendLeaveRoom=function(e){var t=this.createNotification(e.roomEnded?exports.HMSNotificationTypes.ROOM_ENDED:exports.HMSNotificationTypes.REMOVED_FROM_ROOM,e,exports.HMSNotificationSeverity.INFO,(e.roomEnded?"Room ended":"Removed from room")+" by "+e.requestedBy.name);this.emitEvent(t)},t.sendPeerUpdate=function(e,t){var r=this.store.getState(Se(null==t?void 0:t.id))||t,n=Ze[e];if(n){var o=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(o)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState(ge(t)),n=et[e];if(n){var o=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(o)}},t.sendMessageReceived=function(e){var t=this.createNotification(exports.HMSNotificationTypes.NEW_MESSAGE,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.sendError=function(e){var t=this.createNotification(exports.HMSNotificationTypes.ERROR,e,exports.HMSNotificationSeverity.ERROR);this.emitEvent(t)},t.sendReconnecting=function(e){var t=this.createNotification(exports.HMSNotificationTypes.RECONNECTING,e,exports.HMSNotificationSeverity.ERROR);this.emitEvent(t)},t.sendReconnected=function(){var e=this.createNotification(exports.HMSNotificationTypes.RECONNECTED,null,exports.HMSNotificationSeverity.INFO);this.emitEvent(e)},t.sendChangeTrackStateRequest=function(e){var t=this.createNotification(exports.HMSNotificationTypes.CHANGE_TRACK_STATE_REQUEST,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.emitEvent=function(e){this.eventEmitter.emit("hmsNotification",e)},t.createNotification=function(e,t,r,n){return void 0===n&&(n=""),this.id++,{id:this.id,type:e,message:n,data:t,severity:r}},e}(),rt=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new tt(this.store),this.actions=r||new $e(this.store,new o.HMSSdk,this.notifications),this.initialTriggerOnSubscribe=!1}var i=e.prototype;return i.triggerOnSubscribe=function(){this.initialTriggerOnSubscribe||(e.makeStoreTriggerOnSubscribe(this.store),this.initialTriggerOnSubscribe=!0)},i.getStore=function(){return this.store},i.getHMSActions=function(){return this.actions},i.getNotifications=function(){return{onNotification:this.notifications.onNotification}},e.createNewHMSStore=function(){var n=r((function(){return m()})),o=n.setState;n.setState=function(e){var r="function"==typeof e?t(e):e;o(r)};var i=n.getState;return n.getState=function(e){return e?e(i()):i()},e.useShallowCheckInSubscribe(n),u({},n,{namedSetState:e.setUpDevtools(n,"HMSStore")})},e.makeStoreTriggerOnSubscribe=function(e){var t=e.subscribe;e.subscribe=function(r,n,o){return r(e.getState(n),void 0),t(r,n,o)}},e.useShallowCheckInSubscribe=function(e){var t=e.subscribe;e.subscribe=function(e,r,o){return r||(r=function(e){return e}),t(e,r,o=o||n)}},e.setUpDevtools=function(t,r){var n;try{n=window.__REDUX_DEVTOOLS_EXTENSION__||window.top.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}if(!n)return function(e){t.setState(e)};var o=n.connect(e.devtoolsOptions(r));o.prefix=r?r+" > ":"";var i=t.setState;return t.setState=function(e){i(e),o.send(o.prefix+"setState",t.getState())},o.subscribe(e.devtoolsSubscribe(o,t,i)),o.send("setUpStore",t.getState()),function(e,r){i(e),o.send(r||o.prefix+"action",t.getState())}},e.devtoolsOptions=function(e){return{name:e,actionsBlacklist:"audioLevel"}},e.devtoolsSubscribe=function(e,t,r){return function(n){var o,i;if("DISPATCH"===n.type&&n.state)["JUMP_TO_ACTION","JUMP_TO_STATE"].includes(n.payload.type)?r(JSON.parse(n.state)):t.setState(JSON.parse(n.state));else if("DISPATCH"===n.type&&"COMMIT"===(null==(o=n.payload)?void 0:o.type))e.init(t.getState());else if("DISPATCH"===n.type&&"IMPORT_STATE"===(null==(i=n.payload)?void 0:i.type)){var s,a,c=null==(s=n.payload.nextLiftedState)?void 0:s.actionsById;((null==(a=n.payload.nextLiftedState)?void 0:a.computedStates)||[]).forEach((function(n,o){var i=n.state,s=c[o]||e.prefix+"setState";0===o?e.init(i):(r(i),e.send(s,t.getState()))}))}}},e}();Object.defineProperty(exports,"HMSSimulcastLayer",{enumerable:!0,get:function(){return o.HMSSimulcastLayer}}),exports.HMSReactiveStore=rt,exports.createDefaultStoreState=m,exports.selectAudioTrackByPeerID=ye,exports.selectAudioTrackVolume=Ae,exports.selectAudioVolumeByPeerID=Ce,exports.selectAuxiliaryAudioByPeerID=Ie,exports.selectAuxiliaryTracksByPeerID=Re,exports.selectAvailableRoleNames=ne,exports.selectBroadcastMessages=Ve,exports.selectBroadcastMessagesUnreadCount=je,exports.selectCameraStreamByPeerID=Te,exports.selectDegradedTracks=X,exports.selectDevices=function(e){return e.devices},exports.selectDominantSpeaker=G,exports.selectHMSMessages=$,exports.selectHMSMessagesCount=Y,exports.selectIsAllowedToPublish=Ye,exports.selectIsAllowedToSubscribe=ie,exports.selectIsAudioLocallyMuted=Le,exports.selectIsConnectedToRoom=_,exports.selectIsInPreview=ee,exports.selectIsLocalAudioEnabled=function(e){var t=K(e);return w(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalScreenShared=Q,exports.selectIsLocalVideoDisplayEnabled=W,exports.selectIsLocalVideoEnabled=J,exports.selectIsLocalVideoPluginPresent=function(e){return i.createSelector([ze],(function(t){return t.includes(e)}))},exports.selectIsLocallyMutedByPeerID=Oe,exports.selectIsPeerAudioEnabled=we,exports.selectIsPeerVideoEnabled=Pe,exports.selectIsScreenShareLocallyMutedByPeerID=Ne,exports.selectIsSomeoneScreenSharing=function(e){return H(e).some((function(t){return E(e,t)}))},exports.selectLocalAudioTrackID=B,exports.selectLocalMediaSettings=function(e){return e.settings},exports.selectLocalPeer=K,exports.selectLocalPeerID=V,exports.selectLocalPeerRole=oe,exports.selectLocalTrackIDs=j,exports.selectLocalVideoTrackID=q,exports.selectMessageIDsInOrder=N,exports.selectMessagesByPeerID=Fe,exports.selectMessagesByRole=Ge,exports.selectMessagesMap=O,exports.selectMessagesUnreadCountByPeerID=We,exports.selectMessagesUnreadCountByRole=Je,exports.selectPeerAudioByID=Ee,exports.selectPeerByID=Se,exports.selectPeerNameByID=me,exports.selectPeerScreenSharing=function(e){return H(e).find((function(t){return E(e,t)}))},exports.selectPeers=H,exports.selectPeersMap=L,exports.selectPeersScreenSharing=function(e){return H(e).filter((function(t){return E(e,t)}))},exports.selectPeersWithAudioStatus=Qe,exports.selectPermissions=se,exports.selectRemotePeers=F,exports.selectRoleByRoleName=function(e){return i.createSelector([re],(function(t){return t[e]}))},exports.selectRoleChangeRequest=Xe,exports.selectRolesMap=re,exports.selectRoom=P,exports.selectRoomStarted=te,exports.selectRoomState=Z,exports.selectScreenShareAudioByPeerID=Me,exports.selectScreenShareByPeerID=De,exports.selectScreenshareAudioVolumeByPeerID=_e,exports.selectSimulcastLayerByTrack=He,exports.selectSpeakers=C,exports.selectTrackAudioByID=be,exports.selectTrackByID=ge,exports.selectTracksMap=A,exports.selectUnreadHMSMessagesCount=z,exports.selectVideoTrackByPeerID=ke;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("immer")),r=e(require("zustand/vanilla")),n=e(require("zustand/shallow")),o=require("@100mslive/hms-video"),i=require("reselect"),s=e(require("events"));function a(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){a(i,n,o,s,c,"next",e)}function c(e){a(i,n,o,s,c,"throw",e)}s(void 0)}))}}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,h,p=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new x(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=y(s,r);if(a){if(a===l)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,i),o}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function d(){}function f(){}function h(){}var p={};p[o]=function(){return this};var v=Object.getPrototypeOf,S=v&&v(v(b([])));S&&S!==t&&r.call(S,o)&&(p=S);var m=h.prototype=d.prototype=Object.create(p);function g(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){var n;this._invoke=function(o,i){function s(){return new t((function(n,s){!function n(o,i,s,a){var c=u(e[o],e,i);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(c.arg)}(o,i,n,s)}))}return n=n?n.then(s,s):s()}}function y(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,y(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function b(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return f.prototype=m.constructor=h,h.constructor=f,f.displayName=a(h,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,a(e,s,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(k.prototype),k.prototype[i]=function(){return this},e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new k(c(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},g(m),a(m,s,"Generator"),m[o]=function(){return this},m.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=b,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),R(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;R(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:b(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(h={exports:{}}),h.exports);(f=exports.HMSRoomState||(exports.HMSRoomState={})).Disconnected="Disconnected",f.Preview="Preview",f.Connecting="Connecting",f.Connected="Connected",f.Reconnecting="Reconnecting",f.Failed="Failed";var v,S,m=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1,roomState:exports.HMSRoomState.Disconnected},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:""},devices:{audioInput:[],audioOutput:[],videoInput:[]},roles:{},roleChangeRequests:[],errors:[]}};(exports.HMSMessageType||(exports.HMSMessageType={})).CHAT="chat",(v=exports.HMSNotificationTypes||(exports.HMSNotificationTypes={})).PEER_JOINED="PEER_JOINED",v.PEER_LEFT="PEER_LEFT",v.NEW_MESSAGE="NEW_MESSAGE",v.ERROR="ERROR",v.RECONNECTING="RECONNECTING",v.RECONNECTED="RECONNECTED",v.TRACK_ADDED="TRACK_ADDED",v.TRACK_REMOVED="TRACK_REMOVED",v.TRACK_MUTED="TRACK_MUTED",v.TRACK_UNMUTED="TRACK_UNMUTED",v.ROLE_UPDATED="ROLE_UPDATED",v.CHANGE_TRACK_STATE_REQUEST="CHANGE_TRACK_STATE_REQUEST",v.ROOM_ENDED="ROOM_ENDED",v.REMOVED_FROM_ROOM="REMOVED_FROM_ROOM",(S=exports.HMSNotificationSeverity||(exports.HMSNotificationSeverity={})).INFO="info",S.ERROR="error";var g=function(e,t){return e&&t},k=function(e,t){return e&&!t},y=function(e,t){return!e&&t},T=function(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},R=function(e,t){for(var r,n=new Set,o=d(e);!(r=o()).done;)n.add(r.value);for(var i,s=d(t);!(i=s()).done;)n.add(i.value);return Array.from(n)};function x(e,t,r,n){e.isLocal&&e.videoTrack&&t.videoTrack&&e.videoTrack!==t.videoTrack&&(n[e.videoTrack]=n[t.videoTrack],delete n[t.videoTrack],r[e.videoTrack]=r[t.videoTrack],r[e.videoTrack].id=e.videoTrack,delete r[t.videoTrack],t.videoTrack=e.videoTrack)}var b=function(){function e(){}return e.convertPeer=function(e){var t,r,n;return{id:e.peerId,name:e.name,roleName:null==(t=e.role)?void 0:t.name,isLocal:e.isLocal,videoTrack:null==(r=e.videoTrack)?void 0:r.trackId,audioTrack:null==(n=e.audioTrack)?void 0:n.trackId,auxiliaryTracks:e.auxiliaryTracks.map((function(e){return e.trackId})),customerUserId:e.customerUserId,customerDescription:e.customerDescription}},e.convertTrack=function(e){var t={id:e.trackId,source:e.source,type:e.type,enabled:e.enabled,displayEnabled:e.enabled};return this.enrichTrack(t,e),t},e.enrichTrack=function(t,r){var n=r.getMediaTrackSettings();if(t.height=n.height,t.width=n.width,t.deviceID=n.deviceId,r instanceof o.HMSRemoteAudioTrack){var i=r.getVolume();i&&(t.volume=i)}e.enrichVideoTrack(t,r)},e.enrichVideoTrack=function(e,t){t instanceof o.HMSRemoteVideoTrack&&(e.layer=t.getSimulcastLayer(),e.degraded=t.degraded,T(t.getSimulcastDefinitions(),e.layerDefinitions)||(e.layerDefinitions=t.getSimulcastDefinitions())),t instanceof o.HMSLocalVideoTrack&&(T(t.getPlugins(),e.plugins)||(e.plugins=t.getPlugins()))},e.convertRoom=function(e){return{id:e.id,name:e.name,hasWaitingRoom:e.hasWaitingRoom,shareableLink:e.shareableLink}},e.convertMessage=function(e){var t,r,n;return{sender:e.sender.peerId,senderName:e.sender.name,senderRole:null==(t=e.sender.role)?void 0:t.name,senderUserId:e.sender.customerUserId,recipientPeer:null==(r=e.recipientPeer)?void 0:r.peerId,recipientRoles:null==(n=e.recipientRoles)?void 0:n.map((function(e){return e.name})),time:e.time,type:e.type,message:e.message}},e.convertRoles=function(e){var t={};return e&&e.forEach((function(e){t[e.name]=e})),t},e.convertRoleChangeRequest=function(e){return{requestedBy:e.requestedBy.peerId,roleName:e.role.name,token:e.token}},e.convertException=function(e){return{code:e.code,action:e.action,name:e.name,message:e.message,description:e.description,isTerminal:e.isTerminal,timestamp:new Date}},e}();function E(e,t){return t&&t.auxiliaryTracks.some((function(t){return!(!t||!e.tracks[t])&&M(e.tracks[t])}))}function I(e){return e&&"audio"===e.type}function M(e){return e&&"screen"===e.source}function w(e){return Boolean(null==e?void 0:e.degraded)}function D(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].enabled}var P=function(e){return e.room},L=function(e){return e.peers},N=function(e){return e.messages.byID},O=function(e){return e.messages.allIDs},A=function(e){return e.tracks},C=function(e){return e.speakers},H=i.createSelector([P],(function(e){return e&&e.isConnected})),_=i.createSelector([P,L],(function(e,t){return e.peers.map((function(e){return t[e]}))})),U=i.createSelector(A,(function(e){return Object.values(e)})),K=i.createSelector(_,(function(e){return e.filter((function(e){return e.isLocal}))[0]})),V=i.createSelector(K,(function(e){return null==e?void 0:e.id})),B=i.createSelector(K,(function(e){return null==e?void 0:e.audioTrack})),q=i.createSelector(K,(function(e){return null==e?void 0:e.videoTrack})),j=i.createSelector([B,q,i.createSelector(K,(function(e){return null==e?void 0:e.auxiliaryTracks}))],(function(e,t,r){var n=[].concat(r);return e&&n.unshift(e),t&&n.unshift(t),n})),F=i.createSelector(_,(function(e){return e.filter((function(e){return!e.isLocal}))})),G=i.createSelector(L,C,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,o=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>o?1:-1}));if(r.length>0&&r[0][1].audioLevel&&r[0][1].audioLevel>0){var n=r[0][1].peerID;if(n in e)return e[n]}return null})),J=function(e){var t=K(e);return D(e,null==t?void 0:t.videoTrack)},W=function(e){var t=K(e);return function(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].displayEnabled}(e,null==t?void 0:t.videoTrack)},X=function(e){return E(e,K(e))},Y=i.createSelector(U,(function(e){return e.filter(w)})),Q=i.createSelector(O,(function(e){return e.length})),z=i.createSelector(N,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),$=i.createSelector(O,N,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r})),Z=i.createSelector([P],(function(e){return e&&e.roomState})),ee=i.createSelector(Z,(function(e){return e===exports.HMSRoomState.Preview})),te=i.createSelector(P,(function(e){return e.roomState!==exports.HMSRoomState.Disconnected&&e.roomState!==exports.HMSRoomState.Failed})),re=function(e){return e.roles},ne=i.createSelector([re],(function(e){return Object.keys(e)})),oe=i.createSelector([K,re],(function(e,t){return null!=e&&e.roleName?t[e.roleName]:null})),ie=i.createSelector([oe],(function(e){var t;return!(null==e||null==(t=e.subscribeParams)||!t.subscribeToRoles)&&e.subscribeParams.subscribeToRoles.length>0})),se=i.createSelector(oe,(function(e){return null==e?void 0:e.permissions})),ae="HMS-Store:",ce=function(){function e(){}return e.v=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.log.apply(this,[o.HMSLogLevel.VERBOSE,e].concat(r))},e.d=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[o.HMSLogLevel.DEBUG].concat(t))},e.i=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[o.HMSLogLevel.INFO].concat(t))},e.w=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[o.HMSLogLevel.WARN].concat(t))},e.e=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[o.HMSLogLevel.ERROR].concat(t))},e.log=function(e){if(!(this.level.valueOf()>e.valueOf())){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];switch(e){case o.HMSLogLevel.VERBOSE:var i;(i=console).log.apply(i,[ae].concat(r));break;case o.HMSLogLevel.DEBUG:var s;(s=console).debug.apply(s,[ae].concat(r));break;case o.HMSLogLevel.INFO:var a;(a=console).info.apply(a,[ae].concat(r));break;case o.HMSLogLevel.WARN:var c;(c=console).warn.apply(c,[ae].concat(r));break;case o.HMSLogLevel.ERROR:var u;(u=console).error.apply(u,[ae].concat(r))}}},e}();function ue(e){return function(t){return function(r){return e(r,t)}}}ce.level=o.HMSLogLevel.VERBOSE;var le,de,fe=function(e,t){return t},he=function(e,t){return t},pe=i.createSelector([L,fe],(function(e,t){return t?e[t]:null})),ve=i.createSelector([A,function(e,t){return t}],(function(e,t){return t?e[t]:null})),Se=ue(pe),me=ue(i.createSelector(pe,(function(e){return null==e?void 0:e.name}))),ge=ue(ve),ke=ue((function(e,t){var r=pe(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),ye=ue((function(e,t){var r=pe(e,t);if(r&&r.audioTrack&&""!==r.audioTrack)return e.tracks[r.audioTrack]})),Te=ke,Re=ue((function(e,t){var r=pe(e,t);return(null==r?void 0:r.auxiliaryTracks.map((function(t){return e.tracks[t]})))||[]})),xe=function(e,t){return t?e.speakers[t]:null},be=ue(i.createSelector(xe,(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ee=ue(i.createSelector((function(e,t){var r=ye(t)(e);return xe(e,null==r?void 0:r.id)}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ie=ue((function(e,t){var r=pe(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return I(e.tracks[t])}));return n?e.tracks[n]:void 0}})),Me=ue((function(e,t){var r=pe(e,t);if(r&&E(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){var r=e.tracks[t];return function(e){return e&&"video"===e.type}(r)&&M(r)}));return n?e.tracks[n]:void 0}})),we=ue((function(e,t){var r=pe(e,t);if(r&&E(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){var r=e.tracks[t];return I(r)&&M(r)}));return n?e.tracks[n]:void 0}})),De=ue((function(e,t){var r=pe(e,t);return D(e,null==r?void 0:r.audioTrack)})),Pe=ue((function(e,t){var r=pe(e,t);return D(e,null==r?void 0:r.videoTrack)})),Le=ue((function(e,t){if(t&&e.tracks[t])return 0===e.tracks[t].volume})),Ne=ue((function(e,t){var r=pe(e,t);return Le(null==r?void 0:r.audioTrack)(e)})),Oe=ue((function(e,t){var r=we(t)(e);return Le(null==r?void 0:r.id)(e)})),Ae=ue((function(e,t){var r=ve(e,t);if(r)return"audio"!==r.type?void ce.w("Please pass audio track here"):r.volume})),Ce=ue((function(e,t){var r=pe(e,t);return Ae(null==r?void 0:r.audioTrack)(e)})),He=ue((function(e,t){var r=we(t)(e);return Ae(null==r?void 0:r.id)(e)})),_e=ue((function(e,t){var r=ve(e,t);if(r)return"video"!==r.type?void ce.w("Please pass video track here"):r.layer})),Ue=i.createSelector([$,V,fe],(function(e,t,r){if(r)return e.filter((function(e){var n;return!!(e.recipientPeer||null!=(n=e.recipientRoles)&&n.length)&&!![t,r].includes(e.sender)&&[t,r].includes(e.recipientPeer)}))})),Ke=i.createSelector([$,he],(function(e,t){if(t)return e.filter((function(e){var r,n;return!!(e.recipientPeer||null!=(r=e.recipientRoles)&&r.length)&&((null==(n=e.recipientRoles)?void 0:n.includes(t))||e.senderRole===t)}))})),Ve=i.createSelector($,(function(e){return e.filter((function(e){var t;return!(e.recipientPeer||null!=(t=e.recipientRoles)&&t.length)}))})),Be=i.createSelector([Ke,he],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),qe=i.createSelector([Ue,fe],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),je=i.createSelector(Ve,(function(e){return e.filter((function(e){return!e.read})).length})),Fe=ue(Ue),Ge=ue(Ke),Je=ue(Be),We=ue(qe),Xe=i.createSelector([L,A],(function(e,t){return Object.values(e).map((function(e){var r;return{peer:e,isAudioEnabled:!!e.audioTrack&&(null==(r=t[e.audioTrack])?void 0:r.enabled)}}))})),Ye=i.createSelector([function(e){return e.roleChangeRequests[0]||null},L,re],(function(e,t,r){return e?{requestedBy:t[e.requestedBy],role:r[e.roleName],token:e.token}:null})),Qe=i.createSelector([oe],(function(e){var t,r=!1,n=!1,o=!1;return null!=e&&null!=(t=e.publishParams)&&t.allowed&&(r=e.publishParams.allowed.includes("video"),n=e.publishParams.allowed.includes("audio"),o=e.publishParams.allowed.includes("screen")),{video:r,audio:n,screen:o}})),ze=i.createSelector([q,A],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]})),$e=function(){function e(e,t,r){var n=this;this.hmsSDKTracks={},this.hmsSDKPeers={},this.setState=function(e,t){return n.store.namedSetState(e,t)},this.store=e,this.sdk=t,this.hmsNotifications=r}var t=e.prototype;return t.unblockAudio=function(){var e=c(p.mark((function e(){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.getAudioOutput().unblockAutoplay();case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setVolume=function(e,t){t?this.setTrackVolume(e,t):(this.sdk.getAudioOutput().setVolume(e),this.syncRoomState("setVolume"))},t.setAudioOutputDevice=function(e){this.sdk.getAudioOutput().setDevice(e),this.syncRoomState("setAudioOutput")},t.setPreferredLayer=function(e,t){var r=this.hmsSDKTracks[e];r?r instanceof o.HMSRemoteVideoTrack?(r.preferLayer(t),this.syncRoomState("setPreferredLayer")):ce.w("track "+e+" is not an video track"):this.logPossibleInconsistency("track "+e+" not present, unable to set preffer layer")},t.preview=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.store.getState(te)){e.next=3;break}return this.logPossibleInconsistency("ignoring preview call as room is not in disconnected state."),e.abrupt("return");case 3:return e.prev=3,this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"preview"),e.next=7,this.sdkPreviewWithListeners(t);case 7:e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(3),this.resetState(),ce.e("Cannot show preview. Failed to connect to room - ",e.t0),e.t0;case 14:case"end":return e.stop()}}),e,this,[[3,9]])})));return function(t){return e.apply(this,arguments)}}(),t.join=function(e){var t=this.store.getState(te),r=this.store.getState(te);if(!t||r)try{this.sdkJoinWithListeners(e),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"join")}catch(e){throw this.resetState(),ce.e("Failed to connect to room - ",e),e}else this.logPossibleInconsistency("ignoring join call, room not in disconnected/preview state.")},t.leave=function(){var e=c(p.mark((function e(){var t=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(te)){e.next=4;break}return this.logPossibleInconsistency("room leave is called when no room is connected"),e.abrupt("return");case 4:return e.abrupt("return",this.sdk.leave().then((function(){ce.i("left room")})).catch((function(e){ce.e("error in leaving room - ",e)})).finally((function(){t.resetState()})));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setScreenShareEnabled=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=5;break}return e.next=3,this.startScreenShare();case 3:e.next=7;break;case 5:return e.next=7,this.stopScreenShare();case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.addTrack=function(){var e=c(p.mark((function e(t,r){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r="regular"),e.next=3,this.sdk.addTrack(t,r);case 3:this.syncRoomState("addTrack");case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removeTrack=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.removeTrack(t);case 2:this.syncRoomState("removeTrack");case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalAudioEnabled=function(){var e=c(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(B))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalVideoEnabled=function(){var e=c(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(q))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setEnabledTrack=function(){var e=c(p.mark((function e(t,r){var n,i=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null==(n=this.store.getState().tracks[t])?void 0:n.enabled)!==r){e.next=4;break}return this.logPossibleInconsistency("local track["+t+"] enabled state - "+r),e.abrupt("return");case 4:return this.setState((function(e){e.tracks[t]?e.tracks[t].displayEnabled=r:i.logPossibleInconsistency("track id not found for setEnabled")}),"displayEnabled"),e.prev=5,e.next=8,this.setEnabledSDKTrack(t,r);case 8:this.syncRoomState("setEnabled"),e.next=15;break;case 11:throw e.prev=11,e.t0=e.catch(5),this.setState((function(e){e.tracks[t].displayEnabled=!r}),"rollbackDisplayEnabled"),e.t0;case 15:this.hmsNotifications.sendTrackUpdate(r?o.HMSTrackUpdate.TRACK_UNMUTED:o.HMSTrackUpdate.TRACK_MUTED,t);case 17:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),t.setAudioSettings=function(){var e=c(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(B))){e.next=5;break}return e.next=4,this.setSDKLocalAudioTrackSettings(r,t);case 4:this.syncRoomState("setAudioSettings");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setVideoSettings=function(){var e=c(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(q))){e.next=5;break}return e.next=4,this.setSDKLocalVideoTrackSettings(r,t);case 4:this.syncRoomState("setVideoSettings");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.sendMessage=function(e){this.sendBroadcastMessage(e)},t.sendBroadcastMessage=function(){var e=c(p.mark((function e(t,r){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.sendBroadcastMessage(t,r);case 2:this.updateMessageInStore(e.sent,{message:t,type:r});case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.sendGroupMessage=function(){var e=c(p.mark((function e(t,r,n){var o,i;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.store.getState(re),i=r.map((function(e){return o[e]})),e.next=4,this.sdk.sendGroupMessage(t,i,n);case 4:this.updateMessageInStore(e.sent,{message:t,recipientRoles:r,type:n});case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.sendDirectMessage=function(){var e=c(p.mark((function e(t,r,n){var o;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.hmsSDKPeers[r],e.next=3,this.sdk.sendDirectMessage(t,o);case 3:this.updateMessageInStore(e.sent,{message:t,recipientPeer:o.peerId,type:n});case 5:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.updateMessageInStore=function(e,t){if(!e)throw ce.w("sendMessage","Failed to send message",t),Error("sendMessage Failed - "+JSON.stringify(t));var r=b.convertMessage(e);return r.read=!0,r.senderName="You",this.onHMSMessage(r),r},t.setMessageRead=function(e,t){var r=this;this.setState((function(n){t?n.messages.byID[t]?n.messages.byID[t].read=e:r.logPossibleInconsistency("no message with id is found"):n.messages.allIDs.forEach((function(t){n.messages.byID[t].read=e}))}),"setMessageRead")},t.attachVideo=function(){var e=c(p.mark((function e(t,r){var n=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localAndVideoUnmuting(t)){e.next=4;break}return e.abrupt("return",new Promise((function(e){var o=n.store.subscribe(function(){var i=c(p.mark((function i(s){return p.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!s){i.next=5;break}return i.next=3,n.attachVideoInternal(t,r);case 3:o(),e();case 5:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}(),J)})));case 4:return e.next=6,this.attachVideoInternal(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.detachVideo=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=6;break}return e.next=4,n.removeSink(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("no video track found to remove sink");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addPluginToVideoTrack=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"add"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.removePluginFromVideoTrack=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"remove"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.changeRole=function(e,t,r){void 0===r&&(r=!1);var n=this.hmsSDKPeers[e];n?n.isLocal?ce.w("changing role for local peer is not yet supported"):this.sdk.changeRole(n,t,r):this.logPossibleInconsistency("Unknown peer ID given "+e+" for changerole")},t.acceptChangeRole=function(e){var t=this.hmsSDKPeers[e.requestedBy.id];t?(this.sdk.acceptChangeRole({requestedBy:t,role:e.role,token:e.token}),this.removeRoleChangeRequest(e)):ce.w("peer for which role change is requested no longer available - "+e.requestedBy)},t.rejectChangeRole=function(e){this.removeRoleChangeRequest(e)},t.endRoom=function(e,t){var r=this.store.getState(se);null!=r&&r.endRoom?this.sdk.endRoom(e,t):ce.w("You are not allowed to perform this action - endRoom")},t.removePeer=function(e,t){var r=this.hmsSDKPeers[e];r&&!r.isLocal?this.sdk.removePeer(r,t):this.logPossibleInconsistency("No remote peer found for peerID - "+e)},t.setRemoteTrackEnabled=function(e,t){var r=this;if("string"==typeof e){var n=this.hmsSDKTracks[e];n&&function(e){return e instanceof o.HMSRemoteAudioTrack||e instanceof o.HMSRemoteVideoTrack}(n)?this.sdk.changeTrackState(n,t):this.logPossibleInconsistency("No remote track with ID "+e+" found for change track state")}else Array.isArray(e)&&e.forEach((function(e){return r.setRemoteTrackEnabled(e,t)}))},t.setLogLevel=function(e){ce.level=e,this.sdk.setLogLevel(e)},t.resetState=function(){this.setState((function(e){Object.assign(e,m())}),"resetState"),this.hmsSDKTracks={}},t.sdkJoinWithListeners=function(e){this.sdk.join(e,{onJoin:this.onJoin.bind(this),onRoomUpdate:this.onRoomUpdate.bind(this),onPeerUpdate:this.onPeerUpdate.bind(this),onTrackUpdate:this.onTrackUpdate.bind(this),onMessageReceived:this.onMessageReceived.bind(this),onError:this.onError.bind(this),onReconnected:this.onReconnected.bind(this),onReconnecting:this.onReconnecting.bind(this),onRoleChangeRequest:this.onRoleChangeRequest.bind(this),onRoleUpdate:this.onRoleUpdate.bind(this),onDeviceChange:this.onDeviceChange.bind(this),onChangeTrackStateRequest:this.onChangeTrackStateRequest.bind(this),onRemovedFromRoom:this.onRemovedFromRoom.bind(this)}),this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)})},t.onRemovedFromRoom=function(e){var t=this.store.getState(Se(e.requestedBy.peerId));t?this.hmsNotifications.sendLeaveRoom(u({},e,{requestedBy:t})):this.logPossibleInconsistency("Not found peer who requested leave room, "+e.requestedBy)},t.onDeviceChange=function(e){this.setState((function(t){T(t.devices.audioInput,e.audioInput)||(t.devices.audioInput=e.audioInput),T(t.devices.videoInput,e.videoInput)||(t.devices.videoInput=e.videoInput),T(t.devices.audioOutput,e.audioOutput)||(t.devices.audioOutput=e.audioOutput)}),"deviceChange"),this.syncRoomState("deviceChangeSync")},t.sdkPreviewWithListeners=function(){var e=c(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.preview(t,{onPreview:this.onPreview.bind(this),onError:this.onError.bind(this),onDeviceChange:this.onDeviceChange.bind(this)});case 2:this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)});case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.startScreenShare=function(){var e=c(p.mark((function e(){var t=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(X)){e.next=7;break}return e.next=4,this.sdk.startScreenShare((function(){return t.syncRoomState("screenshareStopped")}));case 4:this.syncRoomState("startScreenShare"),e.next=8;break;case 7:this.logPossibleInconsistency("start screenshare is called while it's on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.stopScreenShare=function(){var e=c(p.mark((function e(){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.store.getState(X)){e.next=7;break}return e.next=4,this.sdk.stopScreenShare();case 4:this.syncRoomState("stopScreenShare"),e.next=8;break;case 7:this.logPossibleInconsistency("stop screenshare is called while it's not on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.attachVideoInternal=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=7;break}return e.next=4,n.addSink(r);case 4:n instanceof o.HMSRemoteVideoTrack&&n.getSimulcastDefinitions().length>0&&this.setState((function(e){var r=n.getSimulcastLayer();e.tracks[t].layer=r}),"updateLayerOnAttach"),e.next=8;break;case 7:this.logPossibleInconsistency("no video track found to add sink");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.syncRoomState=function(e){for(var t,r=this,n={},o=[],i={},s={},a={},c=d(this.sdk.getPeers());!(t=c()).done;){var u=t.value,l=b.convertPeer(u);n[l.id]=l,o.push(l.id),this.hmsSDKPeers[l.id]=u;for(var f,h=d([u.audioTrack,u.videoTrack].concat(u.auxiliaryTracks));!(f=h()).done;){var p=f.value;if(p){var v=b.convertTrack(p);i[v.id]=v,s[p.trackId]=p}}l.isLocal&&Object.assign(a,this.getMediaSettings(u))}this.setState((function(e){e.room.peers=o;var t=e.tracks;!function(e,t,r,n){for(var o,i=d(R(Object.keys(e),Object.keys(t)));!(o=i()).done;){var s=o.value,a=e[s],c=t[s];g(a,c)?(T(a.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=a.auxiliaryTracks),x(a,c,r,n),Object.assign(a,c)):k(a,c)?delete e[s]:y(a,c)&&(e[s]=c)}}(e.peers,n,i,s),function(e,t){for(var r,n=d(R(Object.keys(e),Object.keys(t)));!(r=n()).done;){var o=r.value,i=e[o],s=t[o];g(i,s)?Object.assign(i,s):k(i,s)?delete e[o]:y(i,s)&&(e[o]=s)}}(t,i),Object.assign(e.settings,a),r.hmsSDKTracks=s,Object.assign(e.roles,b.convertRoles(r.sdk.getRoles()))}),e)},t.onPreview=function(e){this.setState((function(t){Object.assign(t.room,b.convertRoom(e)),t.room.roomState=exports.HMSRoomState.Preview}),"previewStart"),this.syncRoomState("previewSync")},t.onJoin=function(e){this.setState((function(t){Object.assign(t.room,b.convertRoom(e)),t.room.isConnected=!0,t.room.roomState=exports.HMSRoomState.Connected}),"joined"),this.syncRoomState("joinSync")},t.onRoomUpdate=function(){this.syncRoomState("roomUpdate")},t.onPeerUpdate=function(e,t){if(e!==o.HMSPeerUpdate.BECAME_DOMINANT_SPEAKER&&e!==o.HMSPeerUpdate.RESIGNED_DOMINANT_SPEAKER){var r=this.store.getState(Se(t.peerId)),n="peerUpdate";e===o.HMSPeerUpdate.PEER_JOINED?n="peerJoined":e===o.HMSPeerUpdate.PEER_LEFT&&(n="peerLeft"),this.syncRoomState(n),r||(r=this.store.getState(Se(t.peerId))),this.hmsNotifications.sendPeerUpdate(e,r)}},t.onTrackUpdate=function(e,t,r){e===o.HMSTrackUpdate.TRACK_REMOVED?(this.hmsNotifications.sendTrackUpdate(e,t.trackId),this.handleTrackRemove(t,r)):(this.syncRoomState(e===o.HMSTrackUpdate.TRACK_ADDED?"trackAdded":"trackUpdate"),this.hmsNotifications.sendTrackUpdate(e,t.trackId))},t.onMessageReceived=function(e){var t=b.convertMessage(e);t.read=!1,this.onHMSMessage(t),this.hmsNotifications.sendMessageReceived(t)},t.onHMSMessage=function(e){var t=this;this.setState((function(r){e.id=String(t.store.getState(Q)+1),r.messages.byID[e.id]=e,r.messages.allIDs.push(e.id)}),"newMessage")},t.onAudioLevelUpdate=function(e){this.setState((function(t){var r={};e.forEach((function(e){if(e.track){var n=e.track.trackId;r[n]=e.audioLevel,t.speakers[n]||(t.speakers[n]={audioLevel:e.audioLevel,peerID:e.peer.peerId,trackID:n})}}));for(var n=0,o=Object.entries(t.speakers);n<o.length;n++){var i=o[n],s=i[0],a=i[1];a.audioLevel=r[s]||0,0===a.audioLevel&&delete t.speakers[s]}}),"audioLevel")},t.onChangeTrackStateRequest=function(e){var t=this.store.getState(Se(e.requestedBy.peerId)),r=this.getStoreLocalTrackIDfromSDKTrack(e.track),n=this.store.getState(ge(r));return t?n?(e.enabled||this.syncRoomState("changeTrackStateRequest"),void this.hmsNotifications.sendChangeTrackStateRequest({requestedBy:t,track:n,enabled:e.enabled})):this.logPossibleInconsistency("Not found track for which track state change was requested, "+e.track):this.logPossibleInconsistency("Not found peer who requested track state change, "+e.requestedBy)},t.onReconnected=function(){this.syncRoomState("reconnectedSync"),this.hmsNotifications.sendReconnected(),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connected}),"reconnected")},t.onReconnecting=function(e){var t=b.convertException(e);ce.e("Reconnection: received error from sdk",t),this.hmsNotifications.sendReconnecting(t),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Reconnecting,e.errors.push(t)}),"reconnecting")},t.onError=function(e){var t=b.convertException(e);t.isTerminal?(this.leave().then((function(){return console.log("error from SDK, left room.")})),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Failed,e.errors.push(t)}),"errorTerminal")):this.store.getState().errors.length<50&&this.setState((function(e){e.errors.push(t)}),"error"),this.hmsNotifications.sendError(t),ce.e("received error from sdk",t)},t.handleTrackRemove=function(e,t){var r=this;this.setState((function(n){var o=n.peers[t.peerId],i=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,o.audioTrack))delete o.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,o.videoTrack))delete o.videoTrack;else{var s=o.auxiliaryTracks.indexOf(e.trackId);s>-1&&r.isSameStoreSDKTrack(e.trackId,o.auxiliaryTracks[s])&&o.auxiliaryTracks.splice(s,1)}delete i[e.trackId],delete r.hmsSDKTracks[e.trackId]}),"trackRemoved")},t.setEnabledSDKTrack=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setEnabled(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("track "+t+" not present, unable to enabled/disable");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalVideoTrackSettings=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalAudioTrackSettings=function(){var e=c(p.mark((function e(t,r){var n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.getMediaSettings=function(e){var t,r,n,o,i;return{audioInputDeviceId:null==(t=e.audioTrack)||null==(r=t.getMediaTrackSettings())?void 0:r.deviceId,videoInputDeviceId:null==(n=e.videoTrack)||null==(o=n.getMediaTrackSettings())?void 0:o.deviceId,audioOutputDeviceId:null==(i=this.sdk.getAudioOutput().getDevice())?void 0:i.deviceId}},t.setTrackVolume=function(e,t){var r=this.hmsSDKTracks[t];r?r instanceof o.HMSAudioTrack?(r.setVolume(e),this.syncRoomState("trackVolume")):ce.w("track "+t+" is not an audio track"):this.logPossibleInconsistency("track "+t+" not present, unable to set volume")},t.localAndVideoUnmuting=function(e){if(this.store.getState(K).videoTrack!==e)return!1;var t=this.store.getState(W),r=this.store.getState(J);return t&&!r},t.logPossibleInconsistency=function(e){ce.w("possible inconsistency detected - ",e)},t.addRemoveVideoPlugin=function(){var e=c(p.mark((function e(t,r){var n,o;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return ce.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(n=this.store.getState(q))){e.next=19;break}if(!(o=this.hmsSDKTracks[n])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,o.addPlugin(t);case 10:e.next=15;break;case 12:if("remove"!==r){e.next=15;break}return e.next=15,o.removePlugin(t);case 15:this.syncRoomState(r+"VideoPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+n+" not present, unable to remove plugin");case 19:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.isSameStoreSDKTrack=function(e,t){var r;return!!t&&(null==(r=this.hmsSDKTracks[t])?void 0:r.trackId)===e},t.onRoleChangeRequest=function(e){this.setState((function(t){0===t.roleChangeRequests.length&&t.roleChangeRequests.push(b.convertRoleChangeRequest(e))}),"roleChangeRequest")},t.removeRoleChangeRequest=function(e){this.setState((function(t){var r=t.roleChangeRequests.findIndex((function(t){return t.requestedBy===e.requestedBy.id&&t.roleName===e.role.name&&t.token===e.token}));-1!==r&&t.roleChangeRequests.splice(r,1)}),"removeRoleChangeRequest")},t.onRoleUpdate=function(){this.syncRoomState("roleUpdate")},t.getStoreLocalTrackIDfromSDKTrack=function(e){var t=this;return this.store.getState(j).find((function(r){return t.hmsSDKTracks[r].trackId===e.trackId}))},e}(),Ze=((le={})[o.HMSPeerUpdate.PEER_JOINED]=exports.HMSNotificationTypes.PEER_JOINED,le[o.HMSPeerUpdate.PEER_LEFT]=exports.HMSNotificationTypes.PEER_LEFT,le[o.HMSPeerUpdate.ROLE_UPDATED]=exports.HMSNotificationTypes.ROLE_UPDATED,le),et=((de={})[o.HMSTrackUpdate.TRACK_ADDED]=exports.HMSNotificationTypes.TRACK_ADDED,de[o.HMSTrackUpdate.TRACK_REMOVED]=exports.HMSNotificationTypes.TRACK_REMOVED,de[o.HMSTrackUpdate.TRACK_MUTED]=exports.HMSNotificationTypes.TRACK_MUTED,de[o.HMSTrackUpdate.TRACK_UNMUTED]=exports.HMSNotificationTypes.TRACK_UNMUTED,de),tt=function(){function e(e){var t=this;this.id=0,this.onNotification=function(e){return t.eventEmitter.addListener("hmsNotification",e),function(){t.eventEmitter.removeListener("hmsNotification",e)}},this.store=e,this.eventEmitter=new s}var t=e.prototype;return t.sendLeaveRoom=function(e){var t=this.createNotification(e.roomEnded?exports.HMSNotificationTypes.ROOM_ENDED:exports.HMSNotificationTypes.REMOVED_FROM_ROOM,e,exports.HMSNotificationSeverity.INFO,(e.roomEnded?"Room ended":"Removed from room")+" by "+e.requestedBy.name);this.emitEvent(t)},t.sendPeerUpdate=function(e,t){var r=this.store.getState(Se(null==t?void 0:t.id))||t,n=Ze[e];if(n){var o=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(o)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState(ge(t)),n=et[e];if(n){var o=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(o)}},t.sendMessageReceived=function(e){var t=this.createNotification(exports.HMSNotificationTypes.NEW_MESSAGE,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.sendError=function(e){var t=this.createNotification(exports.HMSNotificationTypes.ERROR,e,exports.HMSNotificationSeverity.ERROR);this.emitEvent(t)},t.sendReconnecting=function(e){var t=this.createNotification(exports.HMSNotificationTypes.RECONNECTING,e,exports.HMSNotificationSeverity.ERROR);this.emitEvent(t)},t.sendReconnected=function(){var e=this.createNotification(exports.HMSNotificationTypes.RECONNECTED,null,exports.HMSNotificationSeverity.INFO);this.emitEvent(e)},t.sendChangeTrackStateRequest=function(e){var t=this.createNotification(exports.HMSNotificationTypes.CHANGE_TRACK_STATE_REQUEST,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.emitEvent=function(e){this.eventEmitter.emit("hmsNotification",e)},t.createNotification=function(e,t,r,n){return void 0===n&&(n=""),this.id++,{id:this.id,type:e,message:n,data:t,severity:r}},e}(),rt=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new tt(this.store),this.actions=r||new $e(this.store,new o.HMSSdk,this.notifications),this.initialTriggerOnSubscribe=!1}var i=e.prototype;return i.triggerOnSubscribe=function(){this.initialTriggerOnSubscribe||(e.makeStoreTriggerOnSubscribe(this.store),this.initialTriggerOnSubscribe=!0)},i.getStore=function(){return this.store},i.getHMSActions=function(){return this.actions},i.getNotifications=function(){return{onNotification:this.notifications.onNotification}},e.createNewHMSStore=function(){var n=r((function(){return m()})),o=n.setState;n.setState=function(e){var r="function"==typeof e?t(e):e;o(r)};var i=n.getState;return n.getState=function(e){return e?e(i()):i()},e.useShallowCheckInSubscribe(n),u({},n,{namedSetState:e.setUpDevtools(n,"HMSStore")})},e.makeStoreTriggerOnSubscribe=function(e){var t=e.subscribe;e.subscribe=function(r,n,o){return r(e.getState(n),void 0),t(r,n,o)}},e.useShallowCheckInSubscribe=function(e){var t=e.subscribe;e.subscribe=function(e,r,o){return r||(r=function(e){return e}),t(e,r,o=o||n)}},e.setUpDevtools=function(t,r){var n;try{n=window.__REDUX_DEVTOOLS_EXTENSION__||window.top.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}if(!n)return function(e){t.setState(e)};var o=n.connect(e.devtoolsOptions(r));o.prefix=r?r+" > ":"";var i=t.setState;return t.setState=function(e){i(e),o.send(o.prefix+"setState",t.getState())},o.subscribe(e.devtoolsSubscribe(o,t,i)),o.send("setUpStore",t.getState()),function(e,r){i(e),o.send(r||o.prefix+"action",t.getState())}},e.devtoolsOptions=function(e){return{name:e,actionsBlacklist:"audioLevel"}},e.devtoolsSubscribe=function(e,t,r){return function(n){var o,i;if("DISPATCH"===n.type&&n.state)["JUMP_TO_ACTION","JUMP_TO_STATE"].includes(n.payload.type)?r(JSON.parse(n.state)):t.setState(JSON.parse(n.state));else if("DISPATCH"===n.type&&"COMMIT"===(null==(o=n.payload)?void 0:o.type))e.init(t.getState());else if("DISPATCH"===n.type&&"IMPORT_STATE"===(null==(i=n.payload)?void 0:i.type)){var s,a,c=null==(s=n.payload.nextLiftedState)?void 0:s.actionsById;((null==(a=n.payload.nextLiftedState)?void 0:a.computedStates)||[]).forEach((function(n,o){var i=n.state,s=c[o]||e.prefix+"setState";0===o?e.init(i):(r(i),e.send(s,t.getState()))}))}}},e}();Object.defineProperty(exports,"HMSSimulcastLayer",{enumerable:!0,get:function(){return o.HMSSimulcastLayer}}),exports.HMSReactiveStore=rt,exports.createDefaultStoreState=m,exports.selectAudioTrackByPeerID=ye,exports.selectAudioTrackVolume=Ae,exports.selectAudioVolumeByPeerID=Ce,exports.selectAuxiliaryAudioByPeerID=Ie,exports.selectAuxiliaryTracksByPeerID=Re,exports.selectAvailableRoleNames=ne,exports.selectBroadcastMessages=Ve,exports.selectBroadcastMessagesUnreadCount=je,exports.selectCameraStreamByPeerID=Te,exports.selectDegradedTracks=Y,exports.selectDevices=function(e){return e.devices},exports.selectDominantSpeaker=G,exports.selectHMSMessages=$,exports.selectHMSMessagesCount=Q,exports.selectIsAllowedToPublish=Qe,exports.selectIsAllowedToSubscribe=ie,exports.selectIsAudioLocallyMuted=Le,exports.selectIsConnectedToRoom=H,exports.selectIsInPreview=ee,exports.selectIsLocalAudioEnabled=function(e){var t=K(e);return D(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalScreenShared=X,exports.selectIsLocalVideoDisplayEnabled=W,exports.selectIsLocalVideoEnabled=J,exports.selectIsLocalVideoPluginPresent=function(e){return i.createSelector([ze],(function(t){return t.includes(e)}))},exports.selectIsLocallyMutedByPeerID=Ne,exports.selectIsPeerAudioEnabled=De,exports.selectIsPeerVideoEnabled=Pe,exports.selectIsScreenShareLocallyMutedByPeerID=Oe,exports.selectIsSomeoneScreenSharing=function(e){return _(e).some((function(t){return E(e,t)}))},exports.selectLocalAudioTrackID=B,exports.selectLocalMediaSettings=function(e){return e.settings},exports.selectLocalPeer=K,exports.selectLocalPeerID=V,exports.selectLocalPeerRole=oe,exports.selectLocalTrackIDs=j,exports.selectLocalVideoTrackID=q,exports.selectMessageIDsInOrder=O,exports.selectMessagesByPeerID=Fe,exports.selectMessagesByRole=Ge,exports.selectMessagesMap=N,exports.selectMessagesUnreadCountByPeerID=We,exports.selectMessagesUnreadCountByRole=Je,exports.selectPeerAudioByID=Ee,exports.selectPeerByID=Se,exports.selectPeerNameByID=me,exports.selectPeerScreenSharing=function(e){return _(e).find((function(t){return E(e,t)}))},exports.selectPeers=_,exports.selectPeersMap=L,exports.selectPeersScreenSharing=function(e){return _(e).filter((function(t){return E(e,t)}))},exports.selectPeersWithAudioStatus=Xe,exports.selectPermissions=se,exports.selectRemotePeers=F,exports.selectRoleByRoleName=function(e){return i.createSelector([re],(function(t){return t[e]}))},exports.selectRoleChangeRequest=Ye,exports.selectRolesMap=re,exports.selectRoom=P,exports.selectRoomStarted=te,exports.selectRoomState=Z,exports.selectScreenShareAudioByPeerID=we,exports.selectScreenShareByPeerID=Me,exports.selectScreenshareAudioVolumeByPeerID=He,exports.selectSimulcastLayerByTrack=_e,exports.selectSpeakers=C,exports.selectTrackAudioByID=be,exports.selectTrackByID=ge,exports.selectTracksMap=A,exports.selectUnreadHMSMessagesCount=z,exports.selectVideoTrackByPeerID=ke;
//# sourceMappingURL=hms-video-store.cjs.production.min.js.map
{
"version": "0.2.16",
"version": "0.2.17",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -0,0 +0,0 @@ # 100ms Reactive Store

@@ -0,0 +0,0 @@ import { HMSLogLevel } from '../core/hmsSDKStore/sdkTypes';

@@ -0,0 +0,0 @@ import {

import * as sdkTypes from '../sdkTypes';
import { HMSNotificationTypes } from '../../schema';
interface notifcationMap {
[key: number]: string;
interface notificationMap {
[key: number]: HMSNotificationTypes;
}
export const PEER_NOTIFICATION_TYPES: notifcationMap = {
export const PEER_NOTIFICATION_TYPES: notificationMap = {
[sdkTypes.HMSPeerUpdate.PEER_JOINED]: HMSNotificationTypes.PEER_JOINED,
[sdkTypes.HMSPeerUpdate.PEER_LEFT]: HMSNotificationTypes.PEER_LEFT,
[sdkTypes.HMSPeerUpdate.ROLE_UPDATED]: HMSNotificationTypes.ROLE_UPDATED,
[sdkTypes.HMSPeerUpdate.AUDIO_TOGGLED]: 'PEER_AUDIO_UPDATED',
[sdkTypes.HMSPeerUpdate.VIDEO_TOGGLED]: 'PEER_VIDEO_UPDATED',
};
export const TRACK_NOTIFICATION_TYPES: notifcationMap = {
export const TRACK_NOTIFICATION_TYPES: notificationMap = {
[sdkTypes.HMSTrackUpdate.TRACK_ADDED]: HMSNotificationTypes.TRACK_ADDED,

@@ -18,0 +16,0 @@ [sdkTypes.HMSTrackUpdate.TRACK_REMOVED]: HMSNotificationTypes.TRACK_REMOVED,

@@ -14,5 +14,5 @@ import EventEmitter from 'events';

HMSMessage,
HMSTrack,
HMSChangeTrackStateRequest,
HMSLeaveRoomRequest,
NotificationDataTypeMap,
} from '../schema';

@@ -31,3 +31,5 @@

onNotification = (cb: (notification: HMSNotification) => void): (() => void) => {
onNotification = (
cb: (notification: HMSNotification<HMSNotificationTypes>) => void,
): (() => void) => {
this.eventEmitter.addListener(HMS_NOTIFICATION_EVENT, cb);

@@ -120,19 +122,12 @@ return () => {

private emitEvent(notification: HMSNotification) {
private emitEvent(notification: HMSNotification<HMSNotificationTypes>) {
this.eventEmitter.emit(HMS_NOTIFICATION_EVENT, notification);
}
private createNotification(
type: string,
data?:
| HMSPeer
| HMSTrack
| HMSMessage
| HMSException
| HMSChangeTrackStateRequest
| HMSLeaveRoomRequest
| null,
private createNotification<K extends keyof NotificationDataTypeMap>(
type: K,
data?: NotificationDataTypeMap[K],
severity?: HMSNotificationSeverity,
message: string = '',
): HMSNotification {
): HMSNotification<K> {
this.id++;

@@ -139,0 +134,0 @@ return {

@@ -0,0 +0,0 @@ import produce from 'immer';

@@ -18,36 +18,36 @@ import {

import {
HMSRoleChangeRequest,
selectHMSMessagesCount,
selectIsLocalScreenShared,
selectIsLocalVideoDisplayEnabled,
selectIsLocalVideoEnabled,
selectLocalAudioTrackID,
selectLocalPeer,
selectLocalTrackIDs,
selectLocalVideoTrackID,
selectHMSMessagesCount,
selectIsLocalVideoDisplayEnabled,
selectLocalPeer,
selectPeerByID,
HMSRoleChangeRequest,
selectTrackByID,
selectRoomStarted,
selectPermissions,
selectRolesMap,
selectLocalTrackIDs,
selectRoomStarted,
selectTrackByID,
} from '../selectors';
import { HMSLogger } from '../../common/ui-logger';
import {
HMSSdk,
HMSVideoPlugin,
HMSTrack as SDKHMSTrack,
DeviceMap,
HMSAudioTrack as SDKHMSAudioTrack,
HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest,
HMSException as SDKHMSException,
HMSLeaveRoomRequest as SDKHMSLeaveRoomRequest,
HMSLocalAudioTrack as SDKHMSLocalAudioTrack,
HMSLocalTrack as SDKHMSLocalTrack,
HMSRemoteVideoTrack as SDKHMSRemoteVideoTrack,
HMSLocalAudioTrack as SDKHMSLocalAudioTrack,
HMSLocalVideoTrack as SDKHMSLocalVideoTrack,
HMSLogLevel,
HMSRemoteTrack as SDKHMSRemoteTrack,
HMSAudioTrack as SDKHMSAudioTrack,
HMSVideoTrack as SDKHMSVideoTrack,
HMSException as SDKHMSException,
DeviceMap,
HMSRemoteVideoTrack as SDKHMSRemoteVideoTrack,
HMSRoleChangeRequest as SDKHMSRoleChangeRequest,
HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest,
HMSSdk,
HMSSimulcastLayer,
HMSLeaveRoomRequest as SDKHMSLeaveRoomRequest,
HMSLogLevel,
HMSTrack as SDKHMSTrack,
HMSVideoPlugin,
HMSVideoTrack as SDKHMSVideoTrack,
} from '@100mslive/hms-video';

@@ -57,5 +57,5 @@ import { IHMSStore } from '../IHMSStore';

import {
areArraysEqual,
mergeNewPeersInDraft,
mergeNewTracksInDraft,
areArraysEqual,
} from './sdkUtils/storeMergeUtils';

@@ -91,3 +91,2 @@ import { HMSNotifications } from './HMSNotifications';

private readonly store: IHMSStore;
private isRoomJoinCalled: boolean = false;
private hmsNotifications: HMSNotifications;

@@ -134,13 +133,13 @@

async preview(config: sdkTypes.HMSConfig) {
if (this.isRoomJoinCalled) {
this.logPossibleInconsistency('attempting to call preview after join was called');
if (this.store.getState(selectRoomStarted)) {
this.logPossibleInconsistency('ignoring preview call as room is not in disconnected state.');
return; // ignore
}
try {
await this.sdkPreviewWithListeners(config);
this.setState(store => {
store.room.roomState = HMSRoomState.Connecting;
}, 'preview');
await this.sdkPreviewWithListeners(config);
} catch (err) {
this.resetState(); // so preview can be called again if needed
HMSLogger.e('Cannot show preview. Failed to connect to room - ', err);

@@ -152,4 +151,6 @@ throw err;

join(config: sdkTypes.HMSConfig) {
if (this.isRoomJoinCalled) {
this.logPossibleInconsistency('room join is called again');
const hasRoomStarted = this.store.getState(selectRoomStarted);
const isInPreview = this.store.getState(selectRoomStarted);
if (hasRoomStarted && !isInPreview) {
this.logPossibleInconsistency('ignoring join call, room not in disconnected/preview state.');
return; // ignore

@@ -159,3 +160,2 @@ }

this.sdkJoinWithListeners(config);
this.isRoomJoinCalled = true;
this.setState(store => {

@@ -165,3 +165,3 @@ store.room.roomState = HMSRoomState.Connecting;

} catch (err) {
this.isRoomJoinCalled = false; // so it can be called again if needed
this.resetState(); // so join can be called again if needed
HMSLogger.e('Failed to connect to room - ', err);

@@ -181,3 +181,2 @@ throw err;

.then(() => {
this.resetState();
HMSLogger.i('left room');

@@ -187,2 +186,5 @@ })

HMSLogger.e('error in leaving room - ', err);
})
.finally(() => {
this.resetState();
});

@@ -442,3 +444,2 @@ }

}, 'resetState');
this.isRoomJoinCalled = false;
this.hmsSDKTracks = {};

@@ -445,0 +446,0 @@ }

@@ -0,0 +0,0 @@ import { PartialState, State } from 'zustand/vanilla';

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import { HMSTrack, HMSRemoteAudioTrack, HMSRemoteVideoTrack } from '@100mslive/hms-video';

@@ -0,0 +0,0 @@ import { HMSPeer, HMSPeerID, HMSTrack, HMSTrackID } from '../../schema';

@@ -0,0 +0,0 @@ import {

@@ -1,4 +0,4 @@

import { HMSNotification } from './schema/notification';
import { HMSNotification, HMSNotificationTypes } from './schema/notification';
type NotificationCallback = (notification: HMSNotification) => void;
type NotificationCallback = (notification: HMSNotification<HMSNotificationTypes>) => void;

@@ -5,0 +5,0 @@ /**

@@ -0,0 +0,0 @@ import { HMSStore } from './schema';

@@ -0,0 +0,0 @@ export { IHMSStore, IHMSStoreReadOnly as HMSStoreWrapper } from './IHMSStore';

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ export * from './schema';

@@ -0,0 +0,0 @@ import { HMSPeerID } from './peer';

@@ -1,17 +0,11 @@

export interface HMSNotification {
id: number;
type: string;
message: string;
/**
* HMSPeer | HMSTrack | HMSMessage | HMSException
*/
data?: any;
severity?: HMSNotificationSeverity;
}
export enum HMSNotificationSeverity {
INFO = 'info',
ERROR = 'error',
CRITICAL = 'critical',
}
import { HMSPeer, HMSTrack } from './peer';
import { HMSMessage } from './message';
import { HMSException } from './error';
import { HMSRole } from '@100mslive/hms-video';
import { HMSChangeTrackStateRequest, HMSLeaveRoomRequest } from './requests';
/**
* @privateRemarks
* if you add a new field here add it to NotificationDataTypeMap too
*/
export enum HMSNotificationTypes {

@@ -28,3 +22,2 @@ PEER_JOINED = 'PEER_JOINED',

TRACK_UNMUTED = 'TRACK_UNMUTED',
ROLE_CHANGE_REQUEST = 'ROLE_CHANGE_REQUEST',
ROLE_UPDATED = 'ROLE_UPDATED',

@@ -35,1 +28,43 @@ CHANGE_TRACK_STATE_REQUEST = 'CHANGE_TRACK_STATE_REQUEST',

}
/**
* this map is to give proper types for notification.data, repeating is not good, but there doesn't seem to be
* any other way at the time of writing. A enum has to be provided so UI can refer types using it and ts interfaces
* don't allow for dynamic keys.
*/
export interface NotificationDataTypeMap {
PEER_JOINED: HMSPeer;
PEER_LEFT: HMSPeer;
NEW_MESSAGE: HMSMessage;
ERROR: HMSException;
RECONNECTING: HMSException;
RECONNECTED: null;
TRACK_ADDED: HMSTrack;
TRACK_REMOVED: HMSTrack;
TRACK_MUTED: HMSTrack;
TRACK_UNMUTED: HMSTrack;
ROLE_UPDATED: HMSRole;
CHANGE_TRACK_STATE_REQUEST: HMSChangeTrackStateRequest;
ROOM_ENDED: HMSLeaveRoomRequest;
REMOVED_FROM_ROOM: HMSLeaveRoomRequest;
}
/**
* error is used to notify about mid call errors. info is for informational messages which can be used to show
* notifications to the user.
*/
export enum HMSNotificationSeverity {
INFO = 'info',
ERROR = 'error',
}
export interface HMSNotification<K extends keyof NotificationDataTypeMap> {
id: number;
type: K;
message: string;
/**
* HMSPeer | HMSTrack | HMSMessage | HMSException
*/
data?: NotificationDataTypeMap[K];
severity?: HMSNotificationSeverity;
}

@@ -0,0 +0,0 @@ import { SimulcastLayerDefinition } from '@100mslive/hms-video';

@@ -0,0 +0,0 @@ import { HMSPeer, HMSPeerID, HMSTrack } from './peer';

@@ -0,0 +0,0 @@ import { HMSRole } from '@100mslive/hms-video';

@@ -0,0 +0,0 @@ import { HMSPeerID } from './peer';

@@ -0,0 +0,0 @@ import { HMSPeer, HMSPeerID, HMSTrackID, HMSTrack, HMSSpeaker } from './peer';

@@ -0,0 +0,0 @@ export interface HMSMediaSettings {

@@ -0,0 +0,0 @@ export interface HMSComponentsStyle {

@@ -0,0 +0,0 @@ import { HMSPeer, HMSStore } from '../schema';

@@ -0,0 +0,0 @@ export * from './selectors';

@@ -277,5 +277,9 @@ import { HMSMessage, HMSPeer, HMSPeerID, HMSRoom, HMSRoomState, HMSStore } from '../schema';

/**
* This would be true if either of preview/join call has happened, and the process of joining the room has started.
* This would become false after leave or a terminal error.
*/
export const selectRoomStarted = createSelector(
selectRoom,
room => room.roomState !== HMSRoomState.Disconnected,
room => room.roomState !== HMSRoomState.Disconnected && room.roomState !== HMSRoomState.Failed,
);

@@ -282,0 +286,0 @@

@@ -0,0 +0,0 @@ import { createSelector } from 'reselect';

@@ -0,0 +0,0 @@ import { createSelector } from 'reselect';

@@ -0,0 +0,0 @@ import { HMSPeer, HMSStore, HMSTrack } from '../schema';

export * from './core';

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import { HMSPeer, HMSTrack, HMSTrackType } from '../core';

@@ -0,0 +0,0 @@ import { HMSReactiveStore, HMSStore, IHMSStore, selectLocalPeer, selectPeers } from '../../core';

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import { localVideo, makeFakeStore } from '../fakeStore';

@@ -0,0 +0,0 @@ import { HMSTrack as SDKTrack } from '@100mslive/hms-video';

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc