@100mslive/hms-video-store
Advanced tools
Comparing version 0.2.36 to 0.2.37
@@ -103,15 +103,19 @@ import { HMSMessage, HMSPeer, HMSPeerID, HMSRoom, HMSRoomState, HMSStore } from '../schema'; | ||
*/ | ||
export declare const selectIsLocalScreenShared: (store: HMSStore) => boolean; | ||
export declare const selectIsLocalScreenShared: import("reselect").OutputSelector<HMSStore, boolean, (res1: HMSPeer, res2: Record<string, import("../schema").HMSTrack>) => boolean>; | ||
/** | ||
* Select the first peer who is currently sharing their screen. | ||
*/ | ||
export declare const selectPeerScreenSharing: import("reselect").OutputSelector<HMSStore, HMSPeer | undefined, (res1: Record<string, HMSPeer>, res2: Record<string, import("../schema").HMSTrack>) => HMSPeer | undefined>; | ||
/** | ||
* Select a boolean denoting whether someone is sharing screen in the room. | ||
*/ | ||
export declare const selectIsSomeoneScreenSharing: (store: HMSStore) => boolean; | ||
export declare const selectIsSomeoneScreenSharing: import("reselect").OutputSelector<HMSStore, boolean, (res: HMSPeer | undefined) => boolean>; | ||
/** | ||
* Select the first peer who is currently sharing their screen. | ||
* Select the first peer who is currently sharing their audio only screen | ||
*/ | ||
export declare const selectPeerScreenSharing: (store: HMSStore) => HMSPeer | undefined; | ||
export declare const selectPeerSharingAudio: import("reselect").OutputSelector<HMSStore, HMSPeer | undefined, (res1: Record<string, HMSPeer>, res2: Record<string, import("../schema").HMSTrack>) => HMSPeer | undefined>; | ||
/** | ||
* Select an array of peers who are currently sharing their screen. | ||
*/ | ||
export declare const selectPeersScreenSharing: (store: HMSStore) => HMSPeer[]; | ||
export declare const selectPeersScreenSharing: import("reselect").OutputSelector<HMSStore, HMSPeer[], (res1: Record<string, HMSPeer>, res2: Record<string, import("../schema").HMSTrack>) => HMSPeer[]>; | ||
/** | ||
@@ -118,0 +122,0 @@ * Select an array of tracks that have been degraded(receiving lower video quality/no video) due to bad network locally. |
@@ -1,3 +0,4 @@ | ||
import { HMSPeer, HMSStore, HMSTrack } from '../schema'; | ||
export declare function isScreenSharing(store: HMSStore, peer: HMSPeer): boolean; | ||
import { HMSPeer, HMSStore, HMSTrack, HMSTrackID } from '../schema'; | ||
export declare function isScreenSharing(tracks: Record<HMSTrackID, HMSTrack>, peer: HMSPeer): boolean; | ||
export declare function getScreenshareTracks(tracks: Record<HMSTrackID, HMSTrack>, peer: HMSPeer): (HMSTrack | undefined)[]; | ||
export declare function isAudio(track: HMSTrack | undefined): boolean | undefined; | ||
@@ -4,0 +5,0 @@ export declare function isVideo(track: HMSTrack | undefined): boolean | undefined; |
@@ -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"),a=e(require("events"));function s(e,t,r,n,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void r(e)}s.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 a(e){s(i,n,o,a,c,"next",e)}function c(e){s(i,n,o,a,c,"throw",e)}a(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",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=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 R(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 a=r.delegate;if(a){var s=y(a,r);if(s){if(s===l)continue;return s}}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={};s(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){s(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){var n;this._invoke=function(o,i){function a(){return new t((function(n,a){!function n(o,i,a,s){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,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(d).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}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 x(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 T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,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=h,s(m,"constructor",h),s(h,"constructor",f),f.displayName=s(h,a,"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,s(e,a,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(k.prototype),s(k.prototype,i,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(c(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(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,R.prototype={constructor:R,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(T),!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 a.type="throw",a.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],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){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 a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},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),T(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;T(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){"object"==typeof globalThis?globalThis.regeneratorRuntime=t: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",S.DEVICE_CHANGE_UPDATE="DEVICE_CHANGE_UPDATE";var g=function(e,t){return e&&t},k=function(e,t){return e&&!t},y=function(e,t){return!e&&t},x=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},T=function(e,t){for(var r,n=new Set,o=d(e);!(r=o()).done;)n.add(r.value);for(var i,a=d(t);!(i=a()).done;)n.add(i.value);return Array.from(n)};function R(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,x(t.getSimulcastDefinitions(),e.layerDefinitions)||(e.layerDefinitions=t.getSimulcastDefinitions())),(t instanceof o.HMSLocalVideoTrack||t instanceof o.HMSLocalAudioTrack)&&(x(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.convertDeviceChangeUpdate=function(e){var t={devices:e.devices,selection:e.selection,type:e.type};return e.error&&(t.error=this.convertException(e.error)),t},e}();function E(e,t){return t&&t.auxiliaryTracks.some((function(t){return!(!t||!e.tracks[t])&&w(e.tracks[t])}))}function D(e){return e&&"audio"===e.type}function w(e){return e&&"screen"===e.source}function I(e){return Boolean(null==e?void 0:e.degraded)}function M(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},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 M(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(I)})),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})),ae=i.createSelector(oe,(function(e){return null==e?void 0:e.permissions})),se="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,[se].concat(r));break;case o.HMSLogLevel.DEBUG:var a;(a=console).debug.apply(a,[se].concat(r));break;case o.HMSLogLevel.INFO:var s;(s=console).info.apply(s,[se].concat(r));break;case o.HMSLogLevel.WARN:var c;(c=console).warn.apply(c,[se].concat(r));break;case o.HMSLogLevel.ERROR:var u;(u=console).error.apply(u,[se].concat(r))}}},e}();function ue(e){return function(t){return function(r){return e(r,t)}}}ce.level=o.HMSLogLevel.VERBOSE;var le=function(e,t){return t},de=function(e,t){return t},fe=i.createSelector([L,le],(function(e,t){return t?e[t]:null})),he=i.createSelector([A,function(e,t){return t}],(function(e,t){return t?e[t]:null})),pe=ue(fe),ve=ue(i.createSelector(fe,(function(e){return null==e?void 0:e.name}))),Se=ue(he),me=ue((function(e,t){var r=fe(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),ge=ue((function(e,t){var r=fe(e,t);if(r&&r.audioTrack&&""!==r.audioTrack)return e.tracks[r.audioTrack]})),ke=me,ye=ue((function(e,t){var r=fe(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},Te=ue(i.createSelector(xe,(function(e){return(null==e?void 0:e.audioLevel)||0}))),Re=ue(i.createSelector((function(e,t){var r=ge(t)(e);return xe(e,null==r?void 0:r.id)}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),be=ue((function(e,t){var r=fe(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return D(e.tracks[t])}));return n?e.tracks[n]:void 0}})),Ee=ue((function(e,t){var r=fe(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)&&w(r)}));return n?e.tracks[n]:void 0}})),De=ue((function(e,t){var r=fe(e,t);if(r&&E(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){var r=e.tracks[t];return D(r)&&w(r)}));return n?e.tracks[n]:void 0}})),we=ue((function(e,t){var r=fe(e,t);return M(e,null==r?void 0:r.audioTrack)})),Ie=ue((function(e,t){var r=fe(e,t);return M(e,null==r?void 0:r.videoTrack)})),Me=ue((function(e,t){if(t&&e.tracks[t])return 0===e.tracks[t].volume})),Pe=ue((function(e,t){var r=fe(e,t);return Me(null==r?void 0:r.audioTrack)(e)})),Le=ue((function(e,t){var r=De(t)(e);return Me(null==r?void 0:r.id)(e)})),Oe=ue((function(e,t){var r=he(e,t);if(r)return"audio"!==r.type?void ce.w("Please pass audio track here"):r.volume})),Ne=ue((function(e,t){var r=fe(e,t);return Oe(null==r?void 0:r.audioTrack)(e)})),Ae=ue((function(e,t){var r=De(t)(e);return Oe(null==r?void 0:r.id)(e)})),Ce=ue((function(e,t){var r=he(e,t);if(r)return"video"!==r.type?void ce.w("Please pass video track here"):r.layer})),He=i.createSelector([$,V,le],(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)}))})),_e=i.createSelector([$,de],(function(e,t){if(t)return e.filter((function(e){var r,n;return!(null==(r=e.recipientRoles)||!r.length)&&(null==(n=e.recipientRoles)?void 0:n.includes(t))}))})),Ue=i.createSelector($,(function(e){return e.filter((function(e){var t;return!(e.recipientPeer||null!=(t=e.recipientRoles)&&t.length)}))})),Ke=i.createSelector([_e,de],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),Ve=i.createSelector([He,le],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),Be=i.createSelector(Ue,(function(e){return e.filter((function(e){return!e.read})).length})),qe=ue(He),je=ue(_e),Fe=ue(Ke),Ge=ue(Ve),Je=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)}}))})),We=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}})),Xe=i.createSelector([q,A],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]})),Ye=i.createSelector([B,A],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]}));function ze(e){return e instanceof o.HMSRemoteAudioTrack||e instanceof o.HMSRemoteVideoTrack}var $e,Ze,et=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("leave"),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,r){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(r);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,r){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(a){return p.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!a){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,r){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"add",r));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addPluginToAudioTrack=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.addRemoveAudioPlugin(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.removePluginFromAudioTrack=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.addRemoveAudioPlugin(t,"remove"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.changeRole=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:if(void 0===n&&(n=!1),o=this.hmsSDKPeers[t]){e.next=5;break}return this.logPossibleInconsistency("Unknown peer ID given "+t+" for changerole"),e.abrupt("return");case 5:return e.next=7,this.sdk.changeRole(o,r,n);case 7:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.acceptChangeRole=function(){var e=c(p.mark((function e(t){var r,n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=t.requestedBy?this.hmsSDKPeers[t.requestedBy.id]:void 0)||ce.w("peer for which role change is requested no longer available - "+t.requestedBy),n={requestedBy:r,role:t.role,token:t.token},e.next=5,this.sdk.acceptChangeRole(n);case 5:this.removeRoleChangeRequest(t);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.rejectChangeRole=function(e){this.removeRoleChangeRequest(e)},t.endRoom=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(null!=(n=this.store.getState(ae))&&n.endRoom){e.next=4;break}return ce.w("You are not allowed to perform this action - endRoom"),e.abrupt("return");case 4:return e.next=6,this.sdk.endRoom(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removePeer=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.hmsSDKPeers[t])||n.isLocal){e.next=6;break}return e.next=4,this.sdk.removePeer(n,r);case 4:e.next=8;break;case 6:return this.logPossibleInconsistency("No remote peer found for peerID - "+t),e.abrupt("return");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setRemoteTrackEnabled=function(){var e=c(p.mark((function e(t,r){var n,o=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=10;break}if(!(n=this.hmsSDKTracks[t])||!ze(n)){e.next=7;break}return e.next=5,this.sdk.changeTrackState(n,r);case 5:e.next=8;break;case 7:this.logPossibleInconsistency("No remote track with ID "+t+" found for change track state");case 8:e.next=11;break;case 10:Array.isArray(t)&&t.forEach((function(e){return o.setRemoteTrackEnabled(e,r)}));case 11:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setLogLevel=function(e){ce.level=e,this.sdk.setLogLevel(e)},t.resetState=function(e){void 0===e&&(e="resetState"),this.setState((function(e){Object.assign(e,m())}),e),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(pe(e.requestedBy.peerId));t?(this.hmsNotifications.sendLeaveRoom(u({},e,{requestedBy:t})),ce.i("resetting state after peer removed",e),this.resetState(e.roomEnded?"roomEnded":"removedFromRoom")):this.logPossibleInconsistency("Not found peer who requested leave room, "+e.requestedBy)},t.onDeviceChange=function(e){var t=e.devices;if(t&&(this.setState((function(e){x(e.devices.audioInput,t.audioInput)||(e.devices.audioInput=t.audioInput),x(e.devices.videoInput,t.videoInput)||(e.devices.videoInput=t.videoInput),x(e.devices.audioOutput,t.audioOutput)||(e.devices.audioOutput=t.audioOutput)}),"deviceChange"),this.syncRoomState("deviceChangeSync"),e.selection)){var r=b.convertDeviceChangeUpdate(e);this.hmsNotifications.sendDeviceChange(r)}},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(t){var r=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 r.syncRoomState("screenshareStopped")}),t);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(t){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={},a={},s={},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,a[p.trackId]=p}}l.isLocal&&Object.assign(s,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(T(Object.keys(e),Object.keys(t)));!(o=i()).done;){var a=o.value,s=e[a],c=t[a];g(s,c)?(x(s.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=s.auxiliaryTracks),R(s,c,r,n),Object.assign(s,c)):k(s,c)?delete e[a]:y(s,c)&&(e[a]=c)}}(e.peers,n,i,a),function(e,t){for(var r,n=d(T(Object.keys(e),Object.keys(t)));!(r=n()).done;){var o=r.value,i=e[o],a=t[o];g(i,a)?Object.assign(i,a):k(i,a)?delete e[o]:y(i,a)&&(e[o]=a)}}(t,i),Object.assign(e.settings,s),r.hmsSDKTracks=a,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(pe(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(pe(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],a=i[0],s=i[1];s.audioLevel=r[a]||0,0===s.audioLevel&&delete t.speakers[a]}}),"audioLevel")},t.onChangeTrackStateRequest=function(e){var t=this.store.getState(pe(e.requestedBy.peerId)),r=this.getStoreLocalTrackIDfromSDKTrack(e.track),n=this.store.getState(Se(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,null==o?void 0:o.audioTrack))null==o||delete o.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.videoTrack))null==o||delete o.videoTrack;else{var a=null==o?void 0:o.auxiliaryTracks.indexOf(e.trackId);a>-1&&r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.auxiliaryTracks[a])&&(null==o||o.auxiliaryTracks.splice(a,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,n){var o,i;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(!(o=this.store.getState(q))){e.next=19;break}if(!(i=this.hmsSDKTracks[o])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,i.addPlugin(t,n);case 10:e.next=15;break;case 12:if("remove"!==r){e.next=15;break}return e.next=15,i.removePlugin(t);case 15:this.syncRoomState(r+"VideoPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+o+" not present, unable to remove plugin");case 19:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.addRemoveAudioPlugin=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(B))){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+"AudioPlugin"),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.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}(),tt=(($e={})[o.HMSPeerUpdate.PEER_JOINED]=exports.HMSNotificationTypes.PEER_JOINED,$e[o.HMSPeerUpdate.PEER_LEFT]=exports.HMSNotificationTypes.PEER_LEFT,$e[o.HMSPeerUpdate.ROLE_UPDATED]=exports.HMSNotificationTypes.ROLE_UPDATED,$e[o.HMSPeerUpdate.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",$e[o.HMSPeerUpdate.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",$e),rt=((Ze={})[o.HMSTrackUpdate.TRACK_ADDED]=exports.HMSNotificationTypes.TRACK_ADDED,Ze[o.HMSTrackUpdate.TRACK_REMOVED]=exports.HMSNotificationTypes.TRACK_REMOVED,Ze[o.HMSTrackUpdate.TRACK_MUTED]=exports.HMSNotificationTypes.TRACK_MUTED,Ze[o.HMSTrackUpdate.TRACK_UNMUTED]=exports.HMSNotificationTypes.TRACK_UNMUTED,Ze),nt=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 a}var t=e.prototype;return t.sendDeviceChange=function(e){var t,r=this.createNotification(exports.HMSNotificationTypes.DEVICE_CHANGE_UPDATE,e,e.error?exports.HMSNotificationSeverity.ERROR:exports.HMSNotificationSeverity.INFO,"Selected "+e.type+" device - "+(null==(t=e.selection)?void 0:t.label));this.emitEvent(r)},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(pe(null==t?void 0:t.id))||t,n=tt[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(Se(t)),n=rt[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}(),ot=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new nt(this.store),this.actions=r||new et(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 a,s,c=null==(a=n.payload.nextLiftedState)?void 0:a.actionsById;((null==(s=n.payload.nextLiftedState)?void 0:s.computedStates)||[]).forEach((function(n,o){var i=n.state,a=c[o]||e.prefix+"setState";0===o?e.init(i):(r(i),e.send(a,t.getState()))}))}}},e}();Object.defineProperty(exports,"HMSLogLevel",{enumerable:!0,get:function(){return o.HMSLogLevel}}),Object.defineProperty(exports,"HMSSimulcastLayer",{enumerable:!0,get:function(){return o.HMSSimulcastLayer}}),exports.HMSReactiveStore=ot,exports.createDefaultStoreState=m,exports.selectAudioTrackByPeerID=ge,exports.selectAudioTrackVolume=Oe,exports.selectAudioVolumeByPeerID=Ne,exports.selectAuxiliaryAudioByPeerID=be,exports.selectAuxiliaryTracksByPeerID=ye,exports.selectAvailableRoleNames=ne,exports.selectBroadcastMessages=Ue,exports.selectBroadcastMessagesUnreadCount=Be,exports.selectCameraStreamByPeerID=ke,exports.selectDegradedTracks=X,exports.selectDevices=function(e){return e.devices},exports.selectDominantSpeaker=G,exports.selectHMSMessages=$,exports.selectHMSMessagesCount=Y,exports.selectIsAllowedToPublish=Qe,exports.selectIsAllowedToSubscribe=ie,exports.selectIsAudioLocallyMuted=Me,exports.selectIsConnectedToRoom=H,exports.selectIsInPreview=ee,exports.selectIsLocalAudioEnabled=function(e){var t=K(e);return M(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalAudioPluginPresent=function(e){return i.createSelector([Ye],(function(t){return t.includes(e)}))},exports.selectIsLocalScreenShared=Q,exports.selectIsLocalVideoDisplayEnabled=W,exports.selectIsLocalVideoEnabled=J,exports.selectIsLocalVideoPluginPresent=function(e){return i.createSelector([Xe],(function(t){return t.includes(e)}))},exports.selectIsLocallyMutedByPeerID=Pe,exports.selectIsPeerAudioEnabled=we,exports.selectIsPeerVideoEnabled=Ie,exports.selectIsScreenShareLocallyMutedByPeerID=Le,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=N,exports.selectMessagesByPeerID=qe,exports.selectMessagesByRole=je,exports.selectMessagesMap=O,exports.selectMessagesUnreadCountByPeerID=Ge,exports.selectMessagesUnreadCountByRole=Fe,exports.selectPeerAudioByID=Re,exports.selectPeerByID=pe,exports.selectPeerNameByID=ve,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=Je,exports.selectPermissions=ae,exports.selectRemotePeers=F,exports.selectRoleByRoleName=function(e){return i.createSelector([re],(function(t){return t[e]}))},exports.selectRoleChangeRequest=We,exports.selectRolesMap=re,exports.selectRoom=P,exports.selectRoomStarted=te,exports.selectRoomState=Z,exports.selectScreenShareAudioByPeerID=De,exports.selectScreenShareByPeerID=Ee,exports.selectScreenshareAudioVolumeByPeerID=Ae,exports.selectSimulcastLayerByTrack=Ce,exports.selectSpeakers=C,exports.selectTrackAudioByID=Te,exports.selectTrackByID=Se,exports.selectTracksMap=A,exports.selectUnreadHMSMessagesCount=z,exports.selectVideoTrackByPeerID=me; | ||
"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"),a=e(require("events"));function s(e,t,r,n,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void r(e)}s.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 a(e){s(i,n,o,a,c,"next",e)}function c(e){s(i,n,o,a,c,"throw",e)}a(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",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=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 R(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 a=r.delegate;if(a){var s=y(a,r);if(s){if(s===l)continue;return s}}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={};s(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){s(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){var n;this._invoke=function(o,i){function a(){return new t((function(n,a){!function n(o,i,a,s){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,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(d).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}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 x(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 T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,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=h,s(m,"constructor",h),s(h,"constructor",f),f.displayName=s(h,a,"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,s(e,a,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(k.prototype),s(k.prototype,i,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(c(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(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,R.prototype={constructor:R,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(T),!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 a.type="throw",a.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],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){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 a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},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),T(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;T(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){"object"==typeof globalThis?globalThis.regeneratorRuntime=t: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",S.DEVICE_CHANGE_UPDATE="DEVICE_CHANGE_UPDATE";var g=function(e,t){return e&&t},k=function(e,t){return e&&!t},y=function(e,t){return!e&&t},x=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},T=function(e,t){for(var r,n=new Set,o=d(e);!(r=o()).done;)n.add(r.value);for(var i,a=d(t);!(i=a()).done;)n.add(i.value);return Array.from(n)};function R(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()||0;t.volume=i}e.enrichVideoTrack(t,r)},e.enrichVideoTrack=function(e,t){t instanceof o.HMSRemoteVideoTrack&&(e.layer=t.getSimulcastLayer(),e.degraded=t.degraded,x(t.getSimulcastDefinitions(),e.layerDefinitions)||(e.layerDefinitions=t.getSimulcastDefinitions())),(t instanceof o.HMSLocalVideoTrack||t instanceof o.HMSLocalAudioTrack)&&(x(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.convertDeviceChangeUpdate=function(e){var t={devices:e.devices,selection:e.selection,type:e.type};return e.error&&(t.error=this.convertException(e.error)),t},e}();function E(e,t){return!!D(e,t)[0]}function D(e,t){var r=void 0,n=void 0;if(!t)return[r,n];for(var o,i=d(t.auxiliaryTracks);!(o=i()).done;){var a=e[o.value];M(a)&&(n=w(a)?a:n,r=I(a)?a:r)}return[r,n]}function w(e){return e&&"audio"===e.type}function I(e){return e&&"video"===e.type}function M(e){return e&&"screen"===e.source}function P(e){return Boolean(null==e?void 0:e.degraded)}function L(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].enabled}var O=function(e){return e.room},N=function(e){return e.peers},A=function(e){return e.messages.byID},C=function(e){return e.messages.allIDs},H=function(e){return e.tracks},_=function(e){return e.speakers},U=i.createSelector([O],(function(e){return e&&e.isConnected})),K=i.createSelector([O,N],(function(e,t){return e.peers.map((function(e){return t[e]}))})),V=i.createSelector(H,(function(e){return Object.values(e)})),B=i.createSelector(K,(function(e){return e.filter((function(e){return e.isLocal}))[0]})),q=i.createSelector(B,(function(e){return null==e?void 0:e.id})),j=i.createSelector(B,(function(e){return null==e?void 0:e.audioTrack})),F=i.createSelector(B,(function(e){return null==e?void 0:e.videoTrack})),G=i.createSelector([j,F,i.createSelector(B,(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})),J=i.createSelector(K,(function(e){return e.filter((function(e){return!e.isLocal}))})),W=i.createSelector(N,_,(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})),Q=function(e){var t=B(e);return L(e,null==t?void 0:t.videoTrack)},X=function(e){var t=B(e);return function(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].displayEnabled}(e,null==t?void 0:t.videoTrack)},Y=i.createSelector(B,H,(function(e,t){return E(t,e)})),z=i.createSelector(N,H,(function(e,t){for(var r in e){var n=e[r];if(E(t,n))return n}})),$=i.createSelector(z,(function(e){return!!e})),Z=i.createSelector(N,H,(function(e,t){for(var r in e){var n=e[r],o=D(t,n);if(!o[0]&&o[1])return n}})),ee=i.createSelector(N,H,(function(e,t){var r=[];for(var n in e){var o=e[n];E(t,o)&&r.push(o)}return r})),te=i.createSelector(V,(function(e){return e.filter(P)})),re=i.createSelector(C,(function(e){return e.length})),ne=i.createSelector(A,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),oe=i.createSelector(C,A,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r})),ie=i.createSelector([O],(function(e){return e&&e.roomState})),ae=i.createSelector(ie,(function(e){return e===exports.HMSRoomState.Preview})),se=i.createSelector(O,(function(e){return e.roomState!==exports.HMSRoomState.Disconnected})),ce=function(e){return e.roles},ue=i.createSelector([ce],(function(e){return Object.keys(e)})),le=i.createSelector([B,ce],(function(e,t){return null!=e&&e.roleName?t[e.roleName]:null})),de=i.createSelector([le],(function(e){var t;return!(null==e||null==(t=e.subscribeParams)||!t.subscribeToRoles)&&e.subscribeParams.subscribeToRoles.length>0})),fe=i.createSelector(le,(function(e){return null==e?void 0:e.permissions})),he="HMS-Store:",pe=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,[he].concat(r));break;case o.HMSLogLevel.DEBUG:var a;(a=console).debug.apply(a,[he].concat(r));break;case o.HMSLogLevel.INFO:var s;(s=console).info.apply(s,[he].concat(r));break;case o.HMSLogLevel.WARN:var c;(c=console).warn.apply(c,[he].concat(r));break;case o.HMSLogLevel.ERROR:var u;(u=console).error.apply(u,[he].concat(r))}}},e}();function ve(e){return function(t){return function(r){return e(r,t)}}}pe.level=o.HMSLogLevel.VERBOSE;var Se=function(e,t){return t},me=function(e,t){return t},ge=i.createSelector([N,Se],(function(e,t){return t?e[t]:null})),ke=i.createSelector([H,function(e,t){return t}],(function(e,t){return t?e[t]:null})),ye=ve(ge),xe=ve(i.createSelector(ge,(function(e){return null==e?void 0:e.name}))),Te=ve(ke),Re=ve((function(e,t){var r=ge(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),be=ve((function(e,t){var r=ge(e,t);if(r&&r.audioTrack&&""!==r.audioTrack)return e.tracks[r.audioTrack]})),Ee=Re,De=ve((function(e,t){var r=ge(e,t);return(null==r?void 0:r.auxiliaryTracks.map((function(t){return e.tracks[t]})))||[]})),we=function(e,t){return t?e.speakers[t]:null},Ie=ve(i.createSelector(we,(function(e){return(null==e?void 0:e.audioLevel)||0}))),Me=ve(i.createSelector((function(e,t){var r=be(t)(e);return we(e,null==r?void 0:r.id)}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),Pe=ve((function(e,t){var r=ge(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return w(e.tracks[t])}));return n?e.tracks[n]:void 0}})),Le=ve((function(e,t){var r=ge(e,t);if(r)return D(e.tracks,r)[0]})),Oe=ve((function(e,t){var r=ge(e,t);if(r)return D(e.tracks,r)[1]})),Ne=ve((function(e,t){var r=ge(e,t);return L(e,null==r?void 0:r.audioTrack)})),Ae=ve((function(e,t){var r=ge(e,t);return L(e,null==r?void 0:r.videoTrack)})),Ce=ve((function(e,t){if(t&&e.tracks[t])return 0===e.tracks[t].volume})),He=ve((function(e,t){var r=ge(e,t);return Ce(null==r?void 0:r.audioTrack)(e)})),_e=ve((function(e,t){var r=Oe(t)(e);return Ce(null==r?void 0:r.id)(e)})),Ue=ve((function(e,t){var r=ke(e,t);if(r)return"audio"!==r.type?void pe.w("Please pass audio track here"):r.volume})),Ke=ve((function(e,t){var r=ge(e,t);return Ue(null==r?void 0:r.audioTrack)(e)})),Ve=ve((function(e,t){var r=Oe(t)(e);return Ue(null==r?void 0:r.id)(e)})),Be=ve((function(e,t){var r=ke(e,t);if(r)return"video"!==r.type?void pe.w("Please pass video track here"):r.layer})),qe=i.createSelector([oe,q,Se],(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)}))})),je=i.createSelector([oe,me],(function(e,t){if(t)return e.filter((function(e){var r,n;return!(null==(r=e.recipientRoles)||!r.length)&&(null==(n=e.recipientRoles)?void 0:n.includes(t))}))})),Fe=i.createSelector(oe,(function(e){return e.filter((function(e){var t;return!(e.recipientPeer||null!=(t=e.recipientRoles)&&t.length)}))})),Ge=i.createSelector([je,me],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),Je=i.createSelector([qe,Se],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),We=i.createSelector(Fe,(function(e){return e.filter((function(e){return!e.read})).length})),Qe=ve(qe),Xe=ve(je),Ye=ve(Ge),ze=ve(Je),$e=i.createSelector([N,H],(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)}}))})),Ze=i.createSelector([function(e){return e.roleChangeRequests[0]||null},N,ce],(function(e,t,r){return e?{requestedBy:t[e.requestedBy],role:r[e.roleName],token:e.token}:null})),et=i.createSelector([le],(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}})),tt=i.createSelector([F,H],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]})),rt=i.createSelector([j,H],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]}));function nt(e){return e instanceof o.HMSRemoteAudioTrack||e instanceof o.HMSRemoteVideoTrack}var ot,it,at=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")):pe.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),pe.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,pe.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(se)){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("leave"),pe.i("left room")})).catch((function(e){pe.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,r){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(r);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,r){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(j))){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(F))){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(j))){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(F))){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(ce),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 pe.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(a){return p.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!a){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)}}(),Q)})));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,r){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"add",r));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addPluginToAudioTrack=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.addRemoveAudioPlugin(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.removePluginFromAudioTrack=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.addRemoveAudioPlugin(t,"remove"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.changeRole=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:if(void 0===n&&(n=!1),o=this.hmsSDKPeers[t]){e.next=5;break}return this.logPossibleInconsistency("Unknown peer ID given "+t+" for changerole"),e.abrupt("return");case 5:return e.next=7,this.sdk.changeRole(o,r,n);case 7:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.acceptChangeRole=function(){var e=c(p.mark((function e(t){var r,n;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=t.requestedBy?this.hmsSDKPeers[t.requestedBy.id]:void 0)||pe.w("peer for which role change is requested no longer available - "+t.requestedBy),n={requestedBy:r,role:t.role,token:t.token},e.next=5,this.sdk.acceptChangeRole(n);case 5:this.removeRoleChangeRequest(t);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.rejectChangeRole=function(e){this.removeRoleChangeRequest(e)},t.endRoom=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(null!=(n=this.store.getState(fe))&&n.endRoom){e.next=4;break}return pe.w("You are not allowed to perform this action - endRoom"),e.abrupt("return");case 4:return e.next=6,this.sdk.endRoom(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removePeer=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.hmsSDKPeers[t])||n.isLocal){e.next=6;break}return e.next=4,this.sdk.removePeer(n,r);case 4:e.next=8;break;case 6:return this.logPossibleInconsistency("No remote peer found for peerID - "+t),e.abrupt("return");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setRemoteTrackEnabled=function(){var e=c(p.mark((function e(t,r){var n,o=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=10;break}if(!(n=this.hmsSDKTracks[t])||!nt(n)){e.next=7;break}return e.next=5,this.sdk.changeTrackState(n,r);case 5:e.next=8;break;case 7:this.logPossibleInconsistency("No remote track with ID "+t+" found for change track state");case 8:e.next=11;break;case 10:Array.isArray(t)&&t.forEach((function(e){return o.setRemoteTrackEnabled(e,r)}));case 11:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setLogLevel=function(e){pe.level=e,this.sdk.setLogLevel(e)},t.resetState=function(e){void 0===e&&(e="resetState"),this.setState((function(e){Object.assign(e,m())}),e),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(ye(e.requestedBy.peerId));t?(this.hmsNotifications.sendLeaveRoom(u({},e,{requestedBy:t})),pe.i("resetting state after peer removed",e),this.resetState(e.roomEnded?"roomEnded":"removedFromRoom")):this.logPossibleInconsistency("Not found peer who requested leave room, "+e.requestedBy)},t.onDeviceChange=function(e){var t=e.devices;if(t&&(this.setState((function(e){x(e.devices.audioInput,t.audioInput)||(e.devices.audioInput=t.audioInput),x(e.devices.videoInput,t.videoInput)||(e.devices.videoInput=t.videoInput),x(e.devices.audioOutput,t.audioOutput)||(e.devices.audioOutput=t.audioOutput)}),"deviceChange"),this.syncRoomState("deviceChangeSync"),e.selection)){var r=b.convertDeviceChangeUpdate(e);this.hmsNotifications.sendDeviceChange(r)}},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(t){var r=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(Y)){e.next=7;break}return e.next=4,this.sdk.startScreenShare((function(){return r.syncRoomState("screenshareStopped")}),t);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(t){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(Y)){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={},a={},s={},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,a[p.trackId]=p}}l.isLocal&&Object.assign(s,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(T(Object.keys(e),Object.keys(t)));!(o=i()).done;){var a=o.value,s=e[a],c=t[a];g(s,c)?(x(s.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=s.auxiliaryTracks),R(s,c,r,n),Object.assign(s,c)):k(s,c)?delete e[a]:y(s,c)&&(e[a]=c)}}(e.peers,n,i,a),function(e,t){for(var r,n=d(T(Object.keys(e),Object.keys(t)));!(r=n()).done;){var o=r.value,i=e[o],a=t[o];g(i,a)?Object.assign(i,a):k(i,a)?delete e[o]:y(i,a)&&(e[o]=a)}}(t,i),Object.assign(e.settings,s),r.hmsSDKTracks=a,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(ye(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(ye(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(re)+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],a=i[0],s=i[1];s.audioLevel=r[a]||0,0===s.audioLevel&&delete t.speakers[a]}}),"audioLevel")},t.onChangeTrackStateRequest=function(e){var t=this.store.getState(ye(e.requestedBy.peerId)),r=this.getStoreLocalTrackIDfromSDKTrack(e.track),n=this.store.getState(Te(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);pe.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),pe.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,null==o?void 0:o.audioTrack))null==o||delete o.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.videoTrack))null==o||delete o.videoTrack;else{var a=null==o?void 0:o.auxiliaryTracks.indexOf(e.trackId);a>-1&&r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.auxiliaryTracks[a])&&(null==o||o.auxiliaryTracks.splice(a,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")):pe.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(B).videoTrack!==e)return!1;var t=this.store.getState(X),r=this.store.getState(Q);return t&&!r},t.logPossibleInconsistency=function(e){pe.w("possible inconsistency detected - ",e)},t.addRemoveVideoPlugin=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:if(t){e.next=3;break}return pe.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(o=this.store.getState(F))){e.next=19;break}if(!(i=this.hmsSDKTracks[o])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,i.addPlugin(t,n);case 10:e.next=15;break;case 12:if("remove"!==r){e.next=15;break}return e.next=15,i.removePlugin(t);case 15:this.syncRoomState(r+"VideoPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+o+" not present, unable to remove plugin");case 19:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.addRemoveAudioPlugin=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 pe.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(n=this.store.getState(j))){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+"AudioPlugin"),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.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(G).find((function(r){return t.hmsSDKTracks[r].trackId===e.trackId}))},e}(),st=((ot={})[o.HMSPeerUpdate.PEER_JOINED]=exports.HMSNotificationTypes.PEER_JOINED,ot[o.HMSPeerUpdate.PEER_LEFT]=exports.HMSNotificationTypes.PEER_LEFT,ot[o.HMSPeerUpdate.ROLE_UPDATED]=exports.HMSNotificationTypes.ROLE_UPDATED,ot[o.HMSPeerUpdate.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",ot[o.HMSPeerUpdate.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",ot),ct=((it={})[o.HMSTrackUpdate.TRACK_ADDED]=exports.HMSNotificationTypes.TRACK_ADDED,it[o.HMSTrackUpdate.TRACK_REMOVED]=exports.HMSNotificationTypes.TRACK_REMOVED,it[o.HMSTrackUpdate.TRACK_MUTED]=exports.HMSNotificationTypes.TRACK_MUTED,it[o.HMSTrackUpdate.TRACK_UNMUTED]=exports.HMSNotificationTypes.TRACK_UNMUTED,it),ut=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 a}var t=e.prototype;return t.sendDeviceChange=function(e){var t,r=this.createNotification(exports.HMSNotificationTypes.DEVICE_CHANGE_UPDATE,e,e.error?exports.HMSNotificationSeverity.ERROR:exports.HMSNotificationSeverity.INFO,"Selected "+e.type+" device - "+(null==(t=e.selection)?void 0:t.label));this.emitEvent(r)},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(ye(null==t?void 0:t.id))||t,n=st[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(Te(t)),n=ct[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}(),lt=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new ut(this.store),this.actions=r||new at(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 a,s,c=null==(a=n.payload.nextLiftedState)?void 0:a.actionsById;((null==(s=n.payload.nextLiftedState)?void 0:s.computedStates)||[]).forEach((function(n,o){var i=n.state,a=c[o]||e.prefix+"setState";0===o?e.init(i):(r(i),e.send(a,t.getState()))}))}}},e}();Object.defineProperty(exports,"HMSLogLevel",{enumerable:!0,get:function(){return o.HMSLogLevel}}),Object.defineProperty(exports,"HMSSimulcastLayer",{enumerable:!0,get:function(){return o.HMSSimulcastLayer}}),exports.HMSReactiveStore=lt,exports.createDefaultStoreState=m,exports.selectAudioTrackByPeerID=be,exports.selectAudioTrackVolume=Ue,exports.selectAudioVolumeByPeerID=Ke,exports.selectAuxiliaryAudioByPeerID=Pe,exports.selectAuxiliaryTracksByPeerID=De,exports.selectAvailableRoleNames=ue,exports.selectBroadcastMessages=Fe,exports.selectBroadcastMessagesUnreadCount=We,exports.selectCameraStreamByPeerID=Ee,exports.selectDegradedTracks=te,exports.selectDevices=function(e){return e.devices},exports.selectDominantSpeaker=W,exports.selectHMSMessages=oe,exports.selectHMSMessagesCount=re,exports.selectIsAllowedToPublish=et,exports.selectIsAllowedToSubscribe=de,exports.selectIsAudioLocallyMuted=Ce,exports.selectIsConnectedToRoom=U,exports.selectIsInPreview=ae,exports.selectIsLocalAudioEnabled=function(e){var t=B(e);return L(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalAudioPluginPresent=function(e){return i.createSelector([rt],(function(t){return t.includes(e)}))},exports.selectIsLocalScreenShared=Y,exports.selectIsLocalVideoDisplayEnabled=X,exports.selectIsLocalVideoEnabled=Q,exports.selectIsLocalVideoPluginPresent=function(e){return i.createSelector([tt],(function(t){return t.includes(e)}))},exports.selectIsLocallyMutedByPeerID=He,exports.selectIsPeerAudioEnabled=Ne,exports.selectIsPeerVideoEnabled=Ae,exports.selectIsScreenShareLocallyMutedByPeerID=_e,exports.selectIsSomeoneScreenSharing=$,exports.selectLocalAudioTrackID=j,exports.selectLocalMediaSettings=function(e){return e.settings},exports.selectLocalPeer=B,exports.selectLocalPeerID=q,exports.selectLocalPeerRole=le,exports.selectLocalTrackIDs=G,exports.selectLocalVideoTrackID=F,exports.selectMessageIDsInOrder=C,exports.selectMessagesByPeerID=Qe,exports.selectMessagesByRole=Xe,exports.selectMessagesMap=A,exports.selectMessagesUnreadCountByPeerID=ze,exports.selectMessagesUnreadCountByRole=Ye,exports.selectPeerAudioByID=Me,exports.selectPeerByID=ye,exports.selectPeerNameByID=xe,exports.selectPeerScreenSharing=z,exports.selectPeerSharingAudio=Z,exports.selectPeers=K,exports.selectPeersMap=N,exports.selectPeersScreenSharing=ee,exports.selectPeersWithAudioStatus=$e,exports.selectPermissions=fe,exports.selectRemotePeers=J,exports.selectRoleByRoleName=function(e){return i.createSelector([ce],(function(t){return t[e]}))},exports.selectRoleChangeRequest=Ze,exports.selectRolesMap=ce,exports.selectRoom=O,exports.selectRoomStarted=se,exports.selectRoomState=ie,exports.selectScreenShareAudioByPeerID=Oe,exports.selectScreenShareByPeerID=Le,exports.selectScreenshareAudioVolumeByPeerID=Ve,exports.selectSimulcastLayerByTrack=Be,exports.selectSpeakers=_,exports.selectTrackAudioByID=Ie,exports.selectTrackByID=Te,exports.selectTracksMap=H,exports.selectUnreadHMSMessagesCount=ne,exports.selectVideoTrackByPeerID=Re; | ||
//# sourceMappingURL=hms-video-store.cjs.production.min.js.map |
{ | ||
"version": "0.2.36", | ||
"version": "0.2.37", | ||
"license": "MIT", | ||
@@ -87,2 +87,2 @@ "main": "dist/index.js", | ||
"homepage": "https://github.com/100mslive/hms-video-store#readme" | ||
} | ||
} |
@@ -56,6 +56,4 @@ import { | ||
if (sdkTrack instanceof SDKHMSRemoteAudioTrack) { | ||
const volume = sdkTrack.getVolume(); | ||
if (volume) { | ||
track.volume = volume; | ||
} | ||
const volume = sdkTrack.getVolume() || 0; | ||
track.volume = volume; | ||
} | ||
@@ -62,0 +60,0 @@ SDKToHMS.enrichVideoTrack(track, sdkTrack); |
@@ -6,2 +6,3 @@ import { HMSMessage, HMSPeer, HMSPeerID, HMSRoom, HMSRoomState, HMSStore } from '../schema'; | ||
import { | ||
getScreenshareTracks, | ||
isDegraded, | ||
@@ -199,22 +200,51 @@ isScreenSharing, | ||
*/ | ||
export const selectIsLocalScreenShared = (store: HMSStore): boolean => { | ||
const localPeer = selectLocalPeer(store); | ||
return isScreenSharing(store, localPeer); | ||
}; | ||
export const selectIsLocalScreenShared = createSelector( | ||
selectLocalPeer, | ||
selectTracksMap, | ||
(localPeer, tracksMap) => { | ||
return isScreenSharing(tracksMap, localPeer); | ||
}, | ||
); | ||
/** | ||
* Select the first peer who is currently sharing their screen. | ||
*/ | ||
export const selectPeerScreenSharing = createSelector( | ||
selectPeersMap, | ||
selectTracksMap, | ||
(peersMap, tracksMap) => { | ||
for (const peerID in peersMap) { | ||
const peer = peersMap[peerID]; | ||
if (isScreenSharing(tracksMap, peer)) { | ||
return peer; | ||
} | ||
} | ||
return undefined; | ||
}, | ||
); | ||
/** | ||
* Select a boolean denoting whether someone is sharing screen in the room. | ||
*/ | ||
export const selectIsSomeoneScreenSharing = (store: HMSStore): boolean => { | ||
const peers = selectPeers(store); | ||
return peers.some(peer => isScreenSharing(store, peer)); | ||
}; | ||
export const selectIsSomeoneScreenSharing = createSelector(selectPeerScreenSharing, peer => { | ||
return !!peer; | ||
}); | ||
/** | ||
* Select the first peer who is currently sharing their screen. | ||
* Select the first peer who is currently sharing their audio only screen | ||
*/ | ||
export const selectPeerScreenSharing = (store: HMSStore): HMSPeer | undefined => { | ||
const peers = selectPeers(store); | ||
return peers.find(peer => isScreenSharing(store, peer)); | ||
}; | ||
export const selectPeerSharingAudio = createSelector( | ||
selectPeersMap, | ||
selectTracksMap, | ||
(peersMap, tracksMap) => { | ||
for (const peerID in peersMap) { | ||
const peer = peersMap[peerID]; | ||
const [videoTrack, audioTrack] = getScreenshareTracks(tracksMap, peer); | ||
if (!videoTrack && !!audioTrack) { | ||
return peer; | ||
} | ||
} | ||
return undefined; | ||
}, | ||
); | ||
@@ -224,6 +254,16 @@ /** | ||
*/ | ||
export const selectPeersScreenSharing = (store: HMSStore): HMSPeer[] => { | ||
const peers = selectPeers(store); | ||
return peers.filter(peer => isScreenSharing(store, peer)); | ||
}; | ||
export const selectPeersScreenSharing = createSelector( | ||
selectPeersMap, | ||
selectTracksMap, | ||
(peersMap, tracksMap) => { | ||
const peers = []; | ||
for (const peerID in peersMap) { | ||
const peer = peersMap[peerID]; | ||
if (isScreenSharing(tracksMap, peer)) { | ||
peers.push(peer); | ||
} | ||
} | ||
return peers; | ||
}, | ||
); | ||
@@ -230,0 +270,0 @@ /** |
import { createSelector } from 'reselect'; | ||
import { selectHMSMessages, selectLocalPeerID, selectPeersMap, selectTracksMap } from './selectors'; | ||
import { HMSPeerID, HMSRoleName, HMSStore, HMSTrack, HMSTrackID } from '../schema'; | ||
import { isAudio, isScreenShare, isScreenSharing, isTrackEnabled, isVideo } from './selectorUtils'; | ||
import { getScreenshareTracks, isAudio, isTrackEnabled } from './selectorUtils'; | ||
import { HMSLogger } from '../../common/ui-logger'; | ||
@@ -144,10 +144,6 @@ | ||
const peer = selectPeerByIDBare(store, peerID); | ||
if (peer && isScreenSharing(store, peer)) { | ||
const trackID = peer?.auxiliaryTracks.find(trackId => { | ||
const track = store.tracks[trackId]; | ||
return isVideo(track) && isScreenShare(track); | ||
}); | ||
return trackID ? store.tracks[trackID] : undefined; | ||
if (!peer) { | ||
return undefined; | ||
} | ||
return undefined; | ||
return getScreenshareTracks(store.tracks, peer)[0]; | ||
}); | ||
@@ -162,10 +158,6 @@ | ||
const peer = selectPeerByIDBare(store, peerID); | ||
if (peer && isScreenSharing(store, peer)) { | ||
const trackID = peer?.auxiliaryTracks.find(trackId => { | ||
const track = store.tracks[trackId]; | ||
return isAudio(track) && isScreenShare(track); | ||
}); | ||
return trackID ? store.tracks[trackID] : undefined; | ||
if (!peer) { | ||
return undefined; | ||
} | ||
return undefined; | ||
return getScreenshareTracks(store.tracks, peer)[1]; | ||
}); | ||
@@ -172,0 +164,0 @@ |
@@ -1,16 +0,25 @@ | ||
import { HMSPeer, HMSStore, HMSTrack } from '../schema'; | ||
import { HMSPeer, HMSStore, HMSTrack, HMSTrackID } from '../schema'; | ||
export function isScreenSharing(store: HMSStore, peer: HMSPeer) { | ||
return ( | ||
peer && | ||
peer.auxiliaryTracks.some(trackID => { | ||
if (trackID && store.tracks[trackID]) { | ||
const track = store.tracks[trackID]; | ||
return isScreenShare(track); | ||
} | ||
return false; | ||
}) | ||
); | ||
export function isScreenSharing(tracks: Record<HMSTrackID, HMSTrack>, peer: HMSPeer) { | ||
const [videoTrack] = getScreenshareTracks(tracks, peer); | ||
return !!videoTrack; | ||
} | ||
export function getScreenshareTracks(tracks: Record<HMSTrackID, HMSTrack>, peer: HMSPeer) { | ||
let videoScreenShare = undefined; | ||
let audioScreenShare = undefined; | ||
if (!peer) { | ||
return [videoScreenShare, audioScreenShare]; | ||
} | ||
for (let trackID of peer.auxiliaryTracks) { | ||
const track = tracks[trackID]; | ||
if (isScreenShare(track)) { | ||
audioScreenShare = isAudio(track) ? track : audioScreenShare; | ||
videoScreenShare = isVideo(track) ? track : videoScreenShare; | ||
} | ||
} | ||
return [videoScreenShare, audioScreenShare]; | ||
} | ||
export function isAudio(track: HMSTrack | undefined) { | ||
@@ -17,0 +26,0 @@ return track && track.type === 'audio'; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1153273
12819