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

@100mslive/hms-video-store

Package Overview
Dependencies
Maintainers
16
Versions
730
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.2.12 to 0.2.13

8

dist/core/selectors/selectorsByID.d.ts

@@ -97,4 +97,8 @@ import { HMSStore, HMSTrack } from '../schema';

export declare const selectSimulcastLayerByTrack: (id?: string | undefined) => StoreSelector<import("@100mslive/hms-video").HMSSimulcastLayer | undefined>;
export declare const selectHMSMessagesByPeerID: (id?: string | undefined) => StoreSelector<import("../schema").HMSMessage[] | undefined>;
export declare const selectHMSMessagesByRole: (id?: string | undefined) => StoreSelector<import("../schema").HMSMessage[] | undefined>;
export declare const selectBroadcastMessages: import("reselect").OutputSelector<HMSStore, import("../schema").HMSMessage[], (res: import("../schema").HMSMessage[]) => import("../schema").HMSMessage[]>;
export declare const selectBroadcastMessagesUnreadCount: import("reselect").OutputSelector<HMSStore, number, (res: import("../schema").HMSMessage[]) => number>;
export declare const selectMessagesByPeerID: (id?: string | undefined) => StoreSelector<import("../schema").HMSMessage[] | undefined>;
export declare const selectMessagesByRole: (id?: string | undefined) => StoreSelector<import("../schema").HMSMessage[] | undefined>;
export declare const selectMessagesUnreadCountByRole: (id?: string | undefined) => StoreSelector<number>;
export declare const selectMessagesUnreadCountByPeerID: (id?: string | undefined) => StoreSelector<number>;
export {};

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

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

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

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

const selectMessagesByPeerID = createSelector(
const selectMessagesByPeerIDInternal = createSelector(
[selectHMSMessages, selectLocalPeerID, selectPeerID],

@@ -291,3 +291,3 @@ (messages, localPeerID, peerID) => {

const selectMessagesByRole = createSelector(
const selectMessagesByRoleInternal = createSelector(
[selectHMSMessages, selectRoleName],

@@ -310,4 +310,43 @@ (messages, roleName) => {

export const selectHMSMessagesByPeerID = byIDCurry(selectMessagesByPeerID);
export const selectBroadcastMessages = createSelector(selectHMSMessages, messages => {
return messages.filter(message => {
if (!message.recipientPeers?.length && !message.recipientRoles?.length) {
return true;
}
return false;
});
});
export const selectHMSMessagesByRole = byIDCurry(selectMessagesByRole);
const selectUnreadMessageCountByRole = createSelector(
[selectMessagesByRoleInternal, selectRoleName],
messages => {
if (!messages) {
return 0;
}
return messages.filter(m => !m.read).length;
},
);
const selectUnreadMessageCountByPeerID = createSelector(
[selectMessagesByPeerIDInternal, selectPeerID],
messages => {
if (!messages) {
return 0;
}
return messages.filter(m => !m.read).length;
},
);
export const selectBroadcastMessagesUnreadCount = createSelector(
selectBroadcastMessages,
messages => {
return messages.filter(m => !m.read).length;
},
);
export const selectMessagesByPeerID = byIDCurry(selectMessagesByPeerIDInternal);
export const selectMessagesByRole = byIDCurry(selectMessagesByRoleInternal);
export const selectMessagesUnreadCountByRole = byIDCurry(selectUnreadMessageCountByRole);
export const selectMessagesUnreadCountByPeerID = byIDCurry(selectUnreadMessageCountByPeerID);

@@ -59,4 +59,8 @@ import {

selectRoomStarted,
selectHMSMessagesByPeerID,
selectHMSMessagesByRole,
selectMessagesByPeerID,
selectMessagesByRole,
selectBroadcastMessages,
selectMessagesUnreadCountByRole,
selectBroadcastMessagesUnreadCount,
selectMessagesUnreadCountByPeerID,
} from '../../core';

@@ -219,13 +223,35 @@

test('selectHMSMessagesByPeerID', () => {
test('selectMessagesByPeerID', () => {
const peer = selectRemotePeers(fakeStore);
const messages = selectHMSMessagesByPeerID(peer[0].id)(fakeStore);
const messages = selectMessagesByPeerID(peer[0].id)(fakeStore);
expect(messages).toEqual([fakeStore.messages.byID['202']]);
});
test('selectHMSMessagesByRole', () => {
test('selectMessagesByRole', () => {
const peer = selectRemotePeers(fakeStore);
const messages = selectHMSMessagesByRole(peer[0].roleName)(fakeStore);
const messages = selectMessagesByRole(peer[0].roleName)(fakeStore);
expect(messages).toEqual([fakeStore.messages.byID['202'], fakeStore.messages.byID['203']]);
});
test('selectBroadcastMessages', () => {
const messages = selectBroadcastMessages(fakeStore);
expect(messages).toEqual([fakeStore.messages.byID['201']]);
});
test('selectMessagesUnreadCountByRole', () => {
const peer = selectRemotePeers(fakeStore);
const messages = selectMessagesUnreadCountByRole(peer[0].roleName)(fakeStore);
expect(messages).toBe(1);
});
test('selectMessagesUnreadCountByPeerID', () => {
const peer = selectRemotePeers(fakeStore);
const messages = selectMessagesUnreadCountByPeerID(peer[0].id)(fakeStore);
expect(messages).toBe(1);
});
test('selectBroadcastMessagesUnreadCount', () => {
const messages = selectBroadcastMessagesUnreadCount(fakeStore);
expect(messages).toBe(0);
});
});

@@ -232,0 +258,0 @@

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc