@signalwire/js 3.7.0 → 3.8.0-dev.202202021245.c33a456.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/src/BaseComponent.d.ts +28 -30
- package/dist/core/src/BaseComponent.d.ts.map +1 -1
- package/dist/core/src/BaseSession.d.ts +4 -2
- package/dist/core/src/BaseSession.d.ts.map +1 -1
- package/dist/core/src/chat/BaseChat.d.ts +1 -1
- package/dist/core/src/chat/BaseChat.d.ts.map +1 -1
- package/dist/core/src/chat/ChatMessage.d.ts +2 -2
- package/dist/core/src/chat/ChatMessage.d.ts.map +1 -1
- package/dist/core/src/chat/methods.d.ts +2 -2
- package/dist/core/src/chat/methods.d.ts.map +1 -1
- package/dist/core/src/chat/workers.d.ts +2 -1
- package/dist/core/src/chat/workers.d.ts.map +1 -1
- package/dist/core/src/index.d.ts +3 -3
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/internal/BaseBackendSession.d.ts.map +1 -1
- package/dist/core/src/internal/InternalRPC.d.ts +7 -7
- package/dist/core/src/internal/InternalRPC.d.ts.map +1 -1
- package/dist/core/src/redux/actions.d.ts +15 -14
- package/dist/core/src/redux/actions.d.ts.map +1 -1
- package/dist/core/src/redux/features/component/componentSlice.d.ts +3952 -10
- package/dist/core/src/redux/features/component/componentSlice.d.ts.map +1 -1
- package/dist/core/src/redux/features/executeQueue/executeQueueSlice.d.ts +44 -7
- package/dist/core/src/redux/features/executeQueue/executeQueueSlice.d.ts.map +1 -1
- package/dist/core/src/redux/features/pubSub/pubSubSaga.d.ts.map +1 -1
- package/dist/core/src/redux/features/session/sessionSlice.d.ts +74 -8
- package/dist/core/src/redux/features/session/sessionSlice.d.ts.map +1 -1
- package/dist/core/src/redux/index.d.ts +9 -25
- package/dist/core/src/redux/index.d.ts.map +1 -1
- package/dist/core/src/redux/interfaces.d.ts +4 -3
- package/dist/core/src/redux/interfaces.d.ts.map +1 -1
- package/dist/core/src/redux/rootReducer.d.ts +417 -3
- package/dist/core/src/redux/rootReducer.d.ts.map +1 -1
- package/dist/core/src/redux/rootSaga.d.ts +11 -2
- package/dist/core/src/redux/rootSaga.d.ts.map +1 -1
- package/dist/core/src/redux/toolkit/configureStore.d.ts +77 -0
- package/dist/core/src/redux/toolkit/configureStore.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/createAction.d.ts +180 -0
- package/dist/core/src/redux/toolkit/createAction.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/createReducer.d.ts +42 -0
- package/dist/core/src/redux/toolkit/createReducer.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/createSlice.d.ts +142 -0
- package/dist/core/src/redux/toolkit/createSlice.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/devtoolsExtension.d.ts +185 -0
- package/dist/core/src/redux/toolkit/devtoolsExtension.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/getDefaultMiddleware.d.ts +12 -0
- package/dist/core/src/redux/toolkit/getDefaultMiddleware.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/index.d.ts +13 -0
- package/dist/core/src/redux/toolkit/index.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/isPlainObject.d.ts +12 -0
- package/dist/core/src/redux/toolkit/isPlainObject.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/mapBuilders.d.ts +38 -0
- package/dist/core/src/redux/toolkit/mapBuilders.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/tsHelpers.d.ts +51 -0
- package/dist/core/src/redux/toolkit/tsHelpers.d.ts.map +1 -0
- package/dist/core/src/redux/toolkit/utils.d.ts +11 -0
- package/dist/core/src/redux/toolkit/utils.d.ts.map +1 -0
- package/dist/core/src/redux/utils/createDestroyableSlice.d.ts +3 -2
- package/dist/core/src/redux/utils/createDestroyableSlice.d.ts.map +1 -1
- package/dist/core/src/testUtils.d.ts +8 -25
- package/dist/core/src/testUtils.d.ts.map +1 -1
- package/dist/core/src/types/chat.d.ts +18 -15
- package/dist/core/src/types/chat.d.ts.map +1 -1
- package/dist/core/src/types/utils.d.ts +7 -0
- package/dist/core/src/types/utils.d.ts.map +1 -1
- package/dist/core/src/utils/constants.d.ts +1 -0
- package/dist/core/src/utils/constants.d.ts.map +1 -1
- package/dist/core/src/utils/index.d.ts +6 -1
- package/dist/core/src/utils/index.d.ts.map +1 -1
- package/dist/core/src/utils/interfaces.d.ts +13 -4
- package/dist/core/src/utils/interfaces.d.ts.map +1 -1
- package/dist/index.esm.js +127 -4
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +175 -59
- package/dist/index.js.map +3 -3
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/js/src/BaseRoomSession.d.ts +7 -0
- package/dist/js/src/BaseRoomSession.d.ts.map +1 -1
- package/dist/js/src/JWTSession.d.ts.map +1 -1
- package/dist/js/src/RoomSession.d.ts.map +1 -1
- package/dist/js/src/features/actions.d.ts +1 -1
- package/dist/js/src/features/actions.d.ts.map +1 -1
- package/dist/js/src/testUtils.d.ts +16 -50
- package/dist/js/src/testUtils.d.ts.map +1 -1
- package/dist/js/src/video/workers.d.ts +4 -0
- package/dist/js/src/video/workers.d.ts.map +1 -0
- package/dist/js/tsconfig.build.tsbuildinfo +1 -1
- package/dist/webrtc/src/BaseConnection.d.ts +7 -0
- package/dist/webrtc/src/BaseConnection.d.ts.map +1 -1
- package/dist/webrtc/src/RTCPeer.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/BaseRoomSession.test.ts +2 -2
- package/src/BaseRoomSession.ts +15 -0
- package/src/RoomSession.ts +16 -4
- package/src/chat/Client.test.ts +61 -15
- package/src/video/workers.ts +184 -0
package/dist/index.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SignalWire JS SDK v3.
|
|
2
|
+
* SignalWire JS SDK v3.8.0-dev.202202021245.c33a456.0 (https://signalwire.com)
|
|
3
3
|
* Copyright 2018-2022 SignalWire
|
|
4
4
|
* Licensed under MIT(https://github.com/signalwire/signalwire-js/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SignalWire={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(e){var r,n;r=t,n=function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function o(e,t){var r=e[t];if("function"==typeof r.bind)return r.bind(e);try{return Function.prototype.bind.call(r,e)}catch(t){return function(){return Function.prototype.apply.apply(r,[e,arguments])}}}function i(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(n){return"debug"===n&&(n="log"),typeof console!==t&&("trace"===n&&r?i:void 0!==console[n]?o(console,n):void 0!==console.log?o(console,"log"):e)}function a(t,r){for(var o=0;o<n.length;o++){var i=n[o];this[i]=o<t?e:this.methodFactory(i,t,r)}this.log=this.debug}function c(e,r,n){return function(){typeof console!==t&&(a.call(this,r,n),this[e].apply(this,arguments))}}function u(e,t,r){return s(e)||c.apply(this,arguments)}function d(e,r,o){var i,s=this;r=null==r?"WARN":r;var c="loglevel";function d(){var e;if(typeof window!==t&&c){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var r=window.document.cookie,n=r.indexOf(encodeURIComponent(c)+"=");-1!==n&&(e=/^([^;]+)/.exec(r.slice(n))[1])}catch(e){}return void 0===s.levels[e]&&(e=void 0),e}}"string"==typeof e?c+=":"+e:"symbol"==typeof e&&(c=void 0),s.name=e,s.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},s.methodFactory=o||u,s.getLevel=function(){return i},s.setLevel=function(r,o){if("string"==typeof r&&void 0!==s.levels[r.toUpperCase()]&&(r=s.levels[r.toUpperCase()]),!("number"==typeof r&&r>=0&&r<=s.levels.SILENT))throw"log.setLevel() called with invalid level: "+r;if(i=r,!1!==o&&function(e){var r=(n[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=r)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+r+";"}catch(e){}}}(r),a.call(s,r,e),typeof console===t&&r<s.levels.SILENT)return"No console available for logging"},s.setDefaultLevel=function(e){r=e,d()||s.setLevel(e,!1)},s.resetLevel=function(){s.setLevel(r,!1),function(){if(typeof window!==t&&c){try{return void window.localStorage.removeItem(c)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},s.enableAll=function(e){s.setLevel(s.levels.TRACE,e)},s.disableAll=function(e){s.setLevel(s.levels.SILENT,e)};var l=d();null==l&&(l=r),s.setLevel(l,!1)}var l=new d,h={};l.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=h[e];return t||(t=h[e]=new d(e,l.getLevel(),l.methodFactory)),t};var p=typeof window!==t?window.log:void 0;return l.noConflict=function(){return typeof window!==t&&window.log===l&&(window.log=p),l},l.getLoggers=function(){return h},l.default=l,l},e.exports?e.exports=n():r.log=n()}(r);var n,o=r.exports,i=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(i)}var a=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function c(e){return"string"==typeof e&&a.test(e)}for(var u=[],d=0;d<256;++d)u.push((d+256).toString(16).substr(1));function l(e,t,r){var n=(e=e||{}).random||(e.rng||s)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var o=0;o<16;++o)t[r+o]=n[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[e[t+0]]+u[e[t+1]]+u[e[t+2]]+u[e[t+3]]+"-"+u[e[t+4]]+u[e[t+5]]+"-"+u[e[t+6]]+u[e[t+7]]+"-"+u[e[t+8]]+u[e[t+9]]+"-"+u[e[t+10]]+u[e[t+11]]+u[e[t+12]]+u[e[t+13]]+u[e[t+14]]+u[e[t+15]]).toLowerCase();if(!c(r))throw TypeError("Stringified UUID is invalid");return r}(n)}function h(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map((function(e){return"'"+e+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function p(e){return!!e&&!!e[Z]}function f(e){return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===ee}(e)||Array.isArray(e)||!!e[Y]||!!e.constructor[Y]||_(e)||w(e))}function m(e,t,r){void 0===r&&(r=!1),0===g(e)?(r?Object.keys:te)(e).forEach((function(n){r&&"symbol"==typeof n||t(n,e[n],e)})):e.forEach((function(r,n){return t(n,r,e)}))}function g(e){var t=e[Z];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:_(e)?2:w(e)?3:0}function v(e,t){return 2===g(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function y(e,t,r){var n=g(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function b(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function _(e){return Q&&e instanceof Map}function w(e){return J&&e instanceof Set}function S(e){return e.o||e.t}function k(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=re(e);delete t[Z];for(var r=te(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function E(e,t){return void 0===t&&(t=!1),T(e)||p(e)||!f(e)||(g(e)>1&&(e.set=e.add=e.clear=e.delete=C),Object.freeze(e),t&&m(e,(function(e,t){return E(t,!0)}),!0)),e}function C(){h(2)}function T(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function O(e){var t=ne[e];return t||h(18,e),t}function I(){return H}function P(e,t){t&&(O("Patches"),e.u=[],e.s=[],e.v=t)}function A(e){R(e),e.p.forEach(x),e.p=null}function R(e){e===H&&(H=e.l)}function M(e){return H={p:[],l:H,h:e,m:!0,_:0}}function x(e){var t=e[Z];0===t.i||1===t.i?t.j():t.O=!0}function j(e,t){t._=t.p.length;var r=t.p[0],n=void 0!==e&&e!==r;return t.h.g||O("ES5").S(t,e,n),n?(r[Z].P&&(A(t),h(4)),f(e)&&(e=L(t,e),t.l||N(t,e)),t.u&&O("Patches").M(r[Z],e,t.u,t.s)):e=L(t,r,[]),A(t),t.u&&t.v(t.u,t.s),e!==X?e:void 0}function L(e,t,r){if(T(t))return t;var n=t[Z];if(!n)return m(t,(function(o,i){return D(e,n,t,o,i,r)}),!0),t;if(n.A!==e)return t;if(!n.P)return N(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var o=4===n.i||5===n.i?n.o=k(n.k):n.o;m(3===n.i?new Set(o):o,(function(t,i){return D(e,n,o,t,i,r)})),N(e,o,!1),r&&e.u&&O("Patches").R(n,r,e.u,e.s)}return n.o}function D(e,t,r,n,o,i){if(p(o)){var s=L(e,o,i&&t&&3!==t.i&&!v(t.D,n)?i.concat(n):void 0);if(y(r,n,s),!p(s))return;e.m=!1}if(f(o)&&!T(o)){if(!e.h.F&&e._<1)return;L(e,o),t&&t.A.l||N(e,o)}}function N(e,t,r){void 0===r&&(r=!1),e.h.F&&e.m&&E(t,r)}function V(e,t){var r=e[Z];return(r?S(r):e)[t]}function W(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function $(e){e.P||(e.P=!0,e.l&&$(e.l))}function U(e){e.o||(e.o=k(e.t))}function F(e,t,r){var n=_(t)?O("MapSet").N(t,r):w(t)?O("MapSet").T(t,r):e.g?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:I(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=oe;r&&(o=[n],i=ie);var s=Proxy.revocable(o,i),a=s.revoke,c=s.proxy;return n.k=c,n.j=a,c}(t,r):O("ES5").J(t,r);return(r?r.A:I()).p.push(n),n}function q(e){return p(e)||h(22,e),function e(t){if(!f(t))return t;var r,n=t[Z],o=g(t);if(n){if(!n.P&&(n.i<4||!O("ES5").K(n)))return n.t;n.I=!0,r=z(t,o),n.I=!1}else r=z(t,o);return m(r,(function(t,o){n&&function(e,t){return 2===g(e)?e.get(t):e[t]}(n.t,t)===o||y(r,t,e(o))})),3===o?new Set(r):r}(e)}function z(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return k(e)}var B,H,K="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),Q="undefined"!=typeof Map,J="undefined"!=typeof Set,G="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,X=K?Symbol.for("immer-nothing"):((B={})["immer-nothing"]=!0,B),Y=K?Symbol.for("immer-draftable"):"__$immer_draftable",Z=K?Symbol.for("immer-state"):"__$immer_state",ee=""+Object.prototype.constructor,te="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,re=Object.getOwnPropertyDescriptors||function(e){var t={};return te(e).forEach((function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)})),t},ne={},oe={get:function(e,t){if(t===Z)return e;var r=S(e);if(!v(r,t))return function(e,t,r){var n,o=W(t,r);return o?"value"in o?o.value:null===(n=o.get)||void 0===n?void 0:n.call(e.k):void 0}(e,r,t);var n=r[t];return e.I||!f(n)?n:n===V(e.t,t)?(U(e),e.o[t]=F(e.A.h,n,e)):n},has:function(e,t){return t in S(e)},ownKeys:function(e){return Reflect.ownKeys(S(e))},set:function(e,t,r){var n=W(S(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var o=V(S(e),t),i=null==o?void 0:o[Z];if(i&&i.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(b(r,o)&&(void 0!==r||v(e.t,t)))return!0;U(e),$(e)}return e.o[t]===r&&"number"!=typeof r&&(void 0!==r||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==V(e.t,t)||t in e.t?(e.D[t]=!1,U(e),$(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=S(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){h(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){h(12)}},ie={};m(oe,(function(e,t){ie[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ie.deleteProperty=function(e,t){return oe.deleteProperty.call(this,e[0],t)},ie.set=function(e,t,r){return oe.set.call(this,e[0],t,r,e[0])};var se=new(function(){function e(e){var t=this;this.g=G,this.F=!0,this.produce=function(e,r,n){if("function"==typeof e&&"function"!=typeof r){var o=r;r=e;var i=t;return function(e){var t=this;void 0===e&&(e=o);for(var n=arguments.length,s=Array(n>1?n-1:0),a=1;a<n;a++)s[a-1]=arguments[a];return i.produce(e,(function(e){var n;return(n=r).call.apply(n,[t,e].concat(s))}))}}var s;if("function"!=typeof r&&h(6),void 0!==n&&"function"!=typeof n&&h(7),f(e)){var a=M(t),c=F(t,e,void 0),u=!0;try{s=r(c),u=!1}finally{u?A(a):R(a)}return"undefined"!=typeof Promise&&s instanceof Promise?s.then((function(e){return P(a,n),j(e,a)}),(function(e){throw A(a),e})):(P(a,n),j(s,a))}if(!e||"object"!=typeof e){if((s=r(e))===X)return;return void 0===s&&(s=e),t.F&&E(s,!0),s}h(21,e)},this.produceWithPatches=function(e,r){return"function"==typeof e?function(r){for(var n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return t.produceWithPatches(r,(function(t){return e.apply(void 0,[t].concat(o))}))}:[t.produce(e,r,(function(e,t){n=e,o=t})),n,o];var n,o},"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze)}var t=e.prototype;return t.createDraft=function(e){f(e)||h(8),p(e)&&(e=q(e));var t=M(this),r=F(this,e,void 0);return r[Z].C=!0,R(t),r},t.finishDraft=function(e,t){var r=(e&&e[Z]).A;return P(r,t),j(void 0,r)},t.setAutoFreeze=function(e){this.F=e},t.setUseProxies=function(e){e&&!G&&h(20),this.g=e},t.applyPatches=function(e,t){var r;for(r=t.length-1;r>=0;r--){var n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));var o=O("Patches").$;return p(e)?o(e,t):this.produce(e,(function(e){return o(e,t)}))},e}()),ae=se.produce;se.produceWithPatches.bind(se),se.setAutoFreeze.bind(se),se.setUseProxies.bind(se),se.applyPatches.bind(se),se.createDraft.bind(se),se.finishDraft.bind(se);var ce=ae;function ue(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function de(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function le(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?de(Object(r),!0).forEach((function(t){ue(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):de(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function he(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var pe="function"==typeof Symbol&&Symbol.observable||"@@observable",fe=function(){return Math.random().toString(36).substring(7).split("").join(".")},me={INIT:"@@redux/INIT"+fe(),REPLACE:"@@redux/REPLACE"+fe(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+fe()}};function ge(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ve(e,t,r){var n;if("function"==typeof t&&"function"==typeof r||"function"==typeof r&&"function"==typeof arguments[3])throw new Error(he(0));if("function"==typeof t&&void 0===r&&(r=t,t=void 0),void 0!==r){if("function"!=typeof r)throw new Error(he(1));return r(ve)(e,t)}if("function"!=typeof e)throw new Error(he(2));var o=e,i=t,s=[],a=s,c=!1;function u(){a===s&&(a=s.slice())}function d(){if(c)throw new Error(he(3));return i}function l(e){if("function"!=typeof e)throw new Error(he(4));if(c)throw new Error(he(5));var t=!0;return u(),a.push(e),function(){if(t){if(c)throw new Error(he(6));t=!1,u();var r=a.indexOf(e);a.splice(r,1),s=null}}}function h(e){if(!ge(e))throw new Error(he(7));if(void 0===e.type)throw new Error(he(8));if(c)throw new Error(he(9));try{c=!0,i=o(i,e)}finally{c=!1}for(var t=s=a,r=0;r<t.length;r++)(0,t[r])();return e}function p(e){if("function"!=typeof e)throw new Error(he(10));o=e,h({type:me.REPLACE})}function f(){var e,t=l;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(he(11));function r(){e.next&&e.next(d())}return r(),{unsubscribe:t(r)}}})[pe]=function(){return this},e}return h({type:me.INIT}),(n={dispatch:h,subscribe:l,getState:d,replaceReducer:p})[pe]=f,n}function ye(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++){var o=t[n];"function"==typeof e[o]&&(r[o]=e[o])}var i,s=Object.keys(r);try{!function(e){Object.keys(e).forEach((function(t){var r=e[t];if(void 0===r(void 0,{type:me.INIT}))throw new Error(he(12));if(void 0===r(void 0,{type:me.PROBE_UNKNOWN_ACTION()}))throw new Error(he(13))}))}(r)}catch(e){i=e}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var n=!1,o={},a=0;a<s.length;a++){var c=s[a],u=e[c],d=(0,r[c])(u,t);if(void 0===d)throw new Error(he(14));o[c]=d,n=n||d!==u}return(n=n||s.length!==Object.keys(e).length)?o:e}}function be(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function _e(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw new Error(he(15))},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return n=be.apply(void 0,i)(r.dispatch),le(le({},r),{},{dispatch:n})}}}function we(e){return function(t){var r=t.dispatch,n=t.getState;return function(t){return function(o){return"function"==typeof o?o(r,n,e):t(o)}}}}var Se=we();Se.withExtraArgument=we;var ke,Ee=Se,Ce=(ke=function(e,t){return(ke=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}ke(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),Te=function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e},Oe=Object.defineProperty,Ie=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,Re=function(e,t,r){return t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},Me=function(e,t){for(var r in t||(t={}))Pe.call(t,r)&&Re(e,r,t[r]);if(Ie)for(var n=0,o=Ie(t);n<o.length;n++)Ae.call(t,r=o[n])&&Re(e,r,t[r]);return e},xe="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?be:be.apply(null,arguments)},je=function(e){function t(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=e.apply(this,r)||this;return Object.setPrototypeOf(o,t.prototype),o}return Ce(t,e),Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.prototype.concat.apply(this,t)},t.prototype.prepend=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return 1===e.length&&Array.isArray(e[0])?new(t.bind.apply(t,Te([void 0],e[0].concat(this)))):new(t.bind.apply(t,Te([void 0],e.concat(this))))},t}(Array);function Le(e){var t,r=function(e){return function(e){void 0===e&&(e={});var t=e.thunk,r=void 0===t||t,n=new je;return r&&(function(e){return"boolean"==typeof e}(r)?n.push(Ee):n.push(Ee.withExtraArgument(r.extraArgument))),n}(e)},n=e||{},o=n.reducer,i=void 0===o?void 0:o,s=n.middleware,a=void 0===s?r():s,c=n.devTools,u=void 0===c||c,d=n.preloadedState,l=void 0===d?void 0:d,h=n.enhancers,p=void 0===h?void 0:h;if("function"==typeof i)t=i;else{if(!function(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;for(var r=t;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return t===r}(i))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=ye(i)}var f=a;"function"==typeof f&&(f=f(r));var m=_e.apply(void 0,f),g=be;u&&(g=xe(Me({trace:!1},"object"==typeof u&&u)));var v=[m];return Array.isArray(p)?v=Te([m],p):"function"==typeof p&&(v=p(v)),ve(t,l,g.apply(void 0,v))}function De(e,t){function r(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(t){var o=t.apply(void 0,r);if(!o)throw new Error("prepareAction did not return an object");return Me(Me({type:e,payload:o.payload},"meta"in o&&{meta:o.meta}),"error"in o&&{error:o.error})}return{type:e,payload:r[0]}}return r.toString=function(){return""+e},r.type=e,r.match=function(t){return t.type===e},r}function Ne(e){var t,r={},n=[],o={addCase:function(e,t){var n="string"==typeof e?e:e.type;if(n in r)throw new Error("addCase cannot be called with two reducers for the same action type");return r[n]=t,o},addMatcher:function(e,t){return n.push({matcher:e,reducer:t}),o},addDefaultCase:function(e){return t=e,o}};return e(o),[r,n,t]}!function(){function e(e,t){var r=o[e];return r?r.enumerable=t:o[e]=r={configurable:!0,enumerable:t,get:function(){return oe.get(this[Z],e)},set:function(t){oe.set(this[Z],e,t)}},r}function t(e){for(var t=e.length-1;t>=0;t--){var o=e[t][Z];if(!o.P)switch(o.i){case 5:n(o)&&$(o);break;case 4:r(o)&&$(o)}}}function r(e){for(var t=e.t,r=e.k,n=te(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==Z){var s=t[i];if(void 0===s&&!v(t,i))return!0;var a=r[i],c=a&&a[Z];if(c?c.t!==s:!b(a,s))return!0}}var u=!!t[Z];return n.length!==te(t).length+(u?0:1)}function n(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var o={};!function(e,t){ne.ES5||(ne.ES5=t)}(0,{J:function(t,r){var n=Array.isArray(t),o=function(t,r){if(t){for(var n=Array(r.length),o=0;o<r.length;o++)Object.defineProperty(n,""+o,e(o,!0));return n}var i=re(r);delete i[Z];for(var s=te(i),a=0;a<s.length;a++){var c=s[a];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(r),i)}(n,t),i={i:n?5:4,A:r?r.A:I(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,Z,{value:i,writable:!0}),o},S:function(e,r,o){o?p(r)&&r[Z].A===e&&t(e.p):(e.u&&function e(t){if(t&&"object"==typeof t){var r=t[Z];if(r){var o=r.t,i=r.k,s=r.D,a=r.i;if(4===a)m(i,(function(t){t!==Z&&(void 0!==o[t]||v(o,t)?s[t]||e(i[t]):(s[t]=!0,$(r)))})),m(o,(function(e){void 0!==i[e]||v(i,e)||(s[e]=!1,$(r))}));else if(5===a){if(n(r)&&($(r),s.length=!0),i.length<o.length)for(var c=i.length;c<o.length;c++)s[c]=!1;else for(var u=o.length;u<i.length;u++)s[u]=!0;for(var d=Math.min(i.length,o.length),l=0;l<d;l++)void 0===s[l]&&e(i[l])}}}}(e.p[0]),t(e.p))},K:function(e){return 4===e.i?r(e):n(e)}})}();var Ve=function(e){return"@@redux-saga/"+e},We=Ve("CANCEL_PROMISE"),$e=Ve("CHANNEL_END"),Ue=Ve("IO"),Fe=Ve("MATCH"),qe=Ve("MULTICAST"),ze=Ve("SAGA_ACTION"),Be=Ve("SELF_CANCELLATION"),He=Ve("TASK"),Ke=Ve("TASK_CANCEL"),Qe=Ve("TERMINATE"),Je=Ve("LOCATION");function Ge(){return(Ge=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)}var Xe=function(e){return null==e},Ye=function(e){return null!=e},Ze=function(e){return"function"==typeof e},et=function(e){return"string"==typeof e},tt=Array.isArray,rt=function(e){return e&&Ze(e.then)},nt=function(e){return e&&Ze(e.next)&&Ze(e.throw)},ot=function e(t){return t&&(et(t)||st(t)||Ze(t)||tt(t)&&t.every(e))},it=function(e){return e&&Ze(e.take)&&Ze(e.close)},st=function(e){return Boolean(e)&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype};function at(e,t){var r;void 0===t&&(t=!0);var n=new Promise((function(n){r=setTimeout(n,e,t)}));return n[We]=function(){clearTimeout(r)},n}var ct=function(e){return function(){return!0}}(),ut=function(){},dt=function(e){return e},lt=function(e,t){Ge(e,t),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach((function(r){e[r]=t[r]}))};function ht(e,t){var r=e.indexOf(t);r>=0&&e.splice(r,1)}function pt(e){var t=!1;return function(){t||(t=!0,e())}}var ft=function(e){throw e},mt=function(e){return{value:e,done:!0}};function gt(e,t,r){void 0===t&&(t=ft),void 0===r&&(r="iterator");var n={meta:{name:r},next:e,throw:t,return:mt,isSagaIterator:!0};return"undefined"!=typeof Symbol&&(n[Symbol.iterator]=function(){return n}),n}function vt(e,t){var r=t.sagaStack;console.error(e),console.error(r)}var yt=function(e){return Array.apply(null,new Array(e))},bt=function(e){return function(t){return e(Object.defineProperty(t,ze,{value:!0}))}},_t=function(e){return e===Qe},wt=function(e){return e===Ke},St=function(e){return _t(e)||wt(e)};function kt(e,t){var r,n=Object.keys(e),o=n.length,i=0,s=tt(e)?yt(o):{},a={};return n.forEach((function(e){var n=function(n,a){r||(a||St(n)?(t.cancel(),t(n,a)):(s[e]=n,++i===o&&(r=!0,t(s))))};n.cancel=ut,a[e]=n})),t.cancel=function(){r||(r=!0,n.forEach((function(e){return a[e].cancel()})))},a}function Et(e){return{name:e.name||"anonymous",location:Ct(e)}}function Ct(e){return e[Je]}var Tt={isEmpty:ct,put:ut,take:ut},Ot="TAKE",It="CALL",Pt="FORK",At="SELECT",Rt=function(e,t){var r;return(r={})[Ue]=!0,r.combinator=!1,r.type=e,r.payload=t,r},Mt=function(e){return Rt(Pt,Ge({},e.payload,{detached:!0}))};function xt(e,t){return void 0===e&&(e="*"),ot(e)?Rt(Ot,{pattern:e}):it(r=e)&&r[qe]&&Ye(t)&&ot(t)?Rt(Ot,{channel:e,pattern:t}):it(e)?Rt(Ot,{channel:e}):void 0;var r}function jt(e,t){return Xe(t)&&(t=e,e=void 0),Rt("PUT",{channel:e,action:t})}function Lt(e,t){var r,n=null;return Ze(e)?r=e:(tt(e)?(n=e[0],r=e[1]):(n=e.context,r=e.fn),n&&et(r)&&Ze(n[r])&&(r=n[r])),{context:n,fn:r,args:t}}function Dt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return Rt(It,Lt(e,r))}function Nt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return Rt(Pt,Lt(e,r))}function Vt(e){void 0===e&&(e=dt);for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return Rt(At,{selector:e,args:r})}var Wt=Dt.bind(null,at),$t=[],Ut=0;function Ft(e){try{Bt(),e()}finally{Ht()}}function qt(e){$t.push(e),Ut||(Bt(),Kt())}function zt(e){try{return Bt(),e()}finally{Kt()}}function Bt(){Ut++}function Ht(){Ut--}function Kt(){var e;for(Ht();!Ut&&void 0!==(e=$t.shift());)Ft(e)}var Qt=function(e){return function(t){return e.some((function(e){return Zt(e)(t)}))}},Jt=function(e){return function(t){return e(t)}},Gt=function(e){return function(t){return t.type===String(e)}},Xt=function(e){return function(t){return t.type===e}},Yt=function(){return ct};function Zt(e){var t="*"===e?Yt:et(e)?Gt:tt(e)?Qt:function(e){return Ze(e)&&e.hasOwnProperty("toString")}(e)?Gt:Ze(e)?Jt:st(e)?Xt:null;if(null===t)throw new Error("invalid pattern: "+e);return t(e)}var er={type:$e},tr=function(e){return e&&e.type===$e};function rr(e){void 0===e&&(e=function(e,t){void 0===e&&(e=10);var r=new Array(e),n=0,o=0,i=0,s=function(){if(0!=n){var t=r[i];return r[i]=null,n--,i=(i+1)%e,t}},a=function(){for(var e=[];n;)e.push(s());return e};return{isEmpty:function(){return 0==n},put:function(t){var s;n<e||(s=2*e,r=a(),n=r.length,o=r.length,i=0,r.length=s,e=s),function(t){r[o]=t,o=(o+1)%e,n++}(t)},take:s,flush:a}}(void 0));var t=!1,r=[];return{take:function(n){t&&e.isEmpty()?n(er):e.isEmpty()?(r.push(n),n.cancel=function(){ht(r,n)}):n(e.take())},put:function(n){if(!t){if(0===r.length)return e.put(n);r.shift()(n)}},flush:function(r){t&&e.isEmpty()?r(er):r(e.flush())},close:function(){if(!t){t=!0;var e=r;r=[];for(var n=0,o=e.length;n<o;n++)(0,e[n])(er)}}}}function nr(){var e,t,r,n,o,i,s=(t=!1,n=r=[],o=function(){n===r&&(n=r.slice())},i=function(){t=!0;var e=r=n;n=[],e.forEach((function(e){e(er)}))},(e={})[qe]=!0,e.put=function(e){if(!t)if(tr(e))i();else for(var o=r=n,s=0,a=o.length;s<a;s++){var c=o[s];c[Fe](e)&&(c.cancel(),c(e))}},e.take=function(e,r){void 0===r&&(r=Yt),t?e(er):(e[Fe]=r,o(),n.push(e),e.cancel=pt((function(){o(),ht(n,e)})))},e.close=i,e),a=s.put;return s.put=function(e){e[ze]?a(e):qt((function(){a(e)}))},s}function or(e,t){var r=e[We];Ze(r)&&(t.cancel=r),e.then(t,(function(e){t(e,!0)}))}var ir,sr=0,ar=function(){return++sr};function cr(e){e.isRunning()&&e.cancel()}var ur=((ir={}).TAKE=function(e,t,r){var n=t.channel,o=void 0===n?e.channel:n,i=t.pattern,s=t.maybe,a=function(e){e instanceof Error?r(e,!0):!tr(e)||s?r(e):r(Qe)};try{o.take(a,Ye(i)?Zt(i):null)}catch(e){return void r(e,!0)}r.cancel=a.cancel},ir.PUT=function(e,t,r){var n=t.channel,o=t.action,i=t.resolve;qt((function(){var t;try{t=(n?n.put:e.dispatch)(o)}catch(e){return void r(e,!0)}i&&rt(t)?or(t,r):r(t)}))},ir.ALL=function(e,t,r,n){var o=n.digestEffect,i=sr,s=Object.keys(t);if(0!==s.length){var a=kt(t,r);s.forEach((function(e){o(t[e],i,a[e],e)}))}else r(tt(t)?[]:{})},ir.RACE=function(e,t,r,n){var o=n.digestEffect,i=sr,s=Object.keys(t),a=tt(t)?yt(s.length):{},c={},u=!1;s.forEach((function(e){var t=function(t,n){u||(n||St(t)?(r.cancel(),r(t,n)):(r.cancel(),u=!0,a[e]=t,r(a)))};t.cancel=ut,c[e]=t})),r.cancel=function(){u||(u=!0,s.forEach((function(e){return c[e].cancel()})))},s.forEach((function(e){u||o(t[e],i,c[e],e)}))},ir.CALL=function(e,t,r,n){var o=t.context,i=t.fn,s=t.args,a=n.task;try{var c=i.apply(o,s);if(rt(c))return void or(c,r);if(nt(c))return void yr(e,c,a.context,sr,Et(i),!1,r);r(c)}catch(e){r(e,!0)}},ir.CPS=function(e,t,r){var n=t.context,o=t.fn,i=t.args;try{var s=function(e,t){Xe(e)?r(t):r(e,!0)};o.apply(n,i.concat(s)),s.cancel&&(r.cancel=s.cancel)}catch(e){r(e,!0)}},ir.FORK=function(e,t,r,n){var o=t.fn,i=t.detached,s=n.task,a=function(e){var t=e.context,r=e.fn,n=e.args;try{var o=r.apply(t,n);if(nt(o))return o;var i=!1;return gt((function(e){return i?{value:e,done:!0}:(i=!0,{value:o,done:!rt(o)})}))}catch(e){return gt((function(){throw e}))}}({context:t.context,fn:o,args:t.args}),c=function(e,t){return e.isSagaIterator?{name:e.meta.name}:Et(t)}(a,o);zt((function(){var t=yr(e,a,s.context,sr,c,i,void 0);i?r(t):t.isRunning()?(s.queue.addTask(t),r(t)):t.isAborted()?s.queue.abort(t.error()):r(t)}))},ir.JOIN=function(e,t,r,n){var o=n.task,i=function(e,t){if(e.isRunning()){var r={task:o,cb:t};t.cancel=function(){e.isRunning()&&ht(e.joiners,r)},e.joiners.push(r)}else e.isAborted()?t(e.error(),!0):t(e.result())};if(tt(t)){if(0===t.length)return void r([]);var s=kt(t,r);t.forEach((function(e,t){i(e,s[t])}))}else i(t,r)},ir.CANCEL=function(e,t,r,n){t===Be?cr(n.task):tt(t)?t.forEach(cr):cr(t),r()},ir.SELECT=function(e,t,r){var n=t.selector,o=t.args;try{r(n.apply(void 0,[e.getState()].concat(o)))}catch(e){r(e,!0)}},ir.ACTION_CHANNEL=function(e,t,r){var n=t.pattern,o=rr(t.buffer),i=Zt(n),s=function t(r){tr(r)||e.channel.take(t,i),o.put(r)},a=o.close;o.close=function(){s.cancel(),a()},e.channel.take(s,i),r(o)},ir.CANCELLED=function(e,t,r,n){r(n.task.isCancelled())},ir.FLUSH=function(e,t,r){t.flush(r)},ir.GET_CONTEXT=function(e,t,r,n){r(n.task.context[t])},ir.SET_CONTEXT=function(e,t,r,n){lt(n.task.context,t),r()},ir);function dr(e,t){return e+"?"+t}function lr(e){var t=e.name,r=e.location;return r?t+" "+dr(r.fileName,r.lineNumber):t}function hr(e){var t,r=(t=[]).concat.apply(t,e.map((function(e){return e.cancelledTasks})));return r.length?["Tasks cancelled due to error:"].concat(r).join("\n"):""}var pr=null,fr=[],mr=function(e){e.crashedEffect=pr,fr.push(e)},gr=function(){pr=null,fr.length=0},vr=function(){var e,t=fr[0],r=fr.slice(1),n=t.crashedEffect?(e=Ct(t.crashedEffect))?e.code+" "+dr(e.fileName,e.lineNumber):"":null;return["The above error occurred in task "+lr(t.meta)+(n?" \n when executing effect "+n:"")].concat(r.map((function(e){return" created by "+lr(e.meta)})),[hr(fr)]).join("\n")};function yr(e,t,r,n,o,i,s){var a=e.finalizeRunEffect((function(t,r,n){rt(t)?or(t,n):nt(t)?yr(e,t,u.context,r,o,!1,n):t&&t[Ue]?(0,ur[t.type])(e,t.payload,n,d):n(t)}));l.cancel=ut;var c={meta:o,cancel:function(){0===c.status&&(c.status=1,l(Ke))},status:0},u=function(e,t,r,n,o,i,s){var a;void 0===s&&(s=ut);var c,u,d=0,l=null,h=[],p=Object.create(r),f=function(e,t,r){var n,o=[],i=!1;function s(e){h.push.apply(h,f.getTasks().map((function(e){return e.meta.name}))),c(),r(e,!0)}function a(t){o.push(t),t.cont=function(a,c){i||(ht(o,t),t.cont=ut,c?s(a):(t===e&&(n=a),o.length||(i=!0,r(n))))}}function c(){i||(i=!0,o.forEach((function(e){e.cont=ut,e.cancel()})),o=[])}return a(e),{addTask:a,cancelAll:c,abort:s,getTasks:function(){return o}}}(t,0,m);function m(t,r){if(r){if(d=2,mr({meta:o,cancelledTasks:h}),g.isRoot){var n=vr();gr(),e.onError(t,{sagaStack:n})}u=t,l&&l.reject(t)}else t===Ke?d=1:1!==d&&(d=3),c=t,l&&l.resolve(t);g.cont(t,r),g.joiners.forEach((function(e){e.cb(t,r)})),g.joiners=null}var g=((a={})[He]=!0,a.id=n,a.meta=o,a.isRoot=i,a.context=p,a.joiners=[],a.queue=f,a.cancel=function(){0===d&&(d=1,f.cancelAll(),m(Ke,!1))},a.cont=s,a.end=m,a.setContext=function(e){lt(p,e)},a.toPromise=function(){return l||((e={}).promise=new Promise((function(t,r){e.resolve=t,e.reject=r})),l=e,2===d?l.reject(u):0!==d&&l.resolve(c)),l.promise;var e},a.isRunning=function(){return 0===d},a.isCancelled=function(){return 1===d||0===d&&1===t.status},a.isAborted=function(){return 2===d},a.result=function(){return c},a.error=function(){return u},a);return g}(e,c,r,n,o,i,s),d={task:u,digestEffect:h};return s&&(s.cancel=u.cancel),l(),u;function l(e,r){try{var o;r?(o=t.throw(e),gr()):wt(e)?(c.status=1,l.cancel(),o=Ze(t.return)?t.return(Ke):{done:!0,value:Ke}):o=_t(e)?Ze(t.return)?t.return():{done:!0}:t.next(e),o.done?(1!==c.status&&(c.status=3),c.cont(o.value)):h(o.value,n,l)}catch(e){if(1===c.status)throw e;c.status=2,c.cont(e,!0)}}function h(t,r,n,o){void 0===o&&(o="");var i,s=ar();function c(r,o){i||(i=!0,n.cancel=ut,e.sagaMonitor&&(o?e.sagaMonitor.effectRejected(s,r):e.sagaMonitor.effectResolved(s,r)),o&&function(e){pr=e}(t),n(r,o))}e.sagaMonitor&&e.sagaMonitor.effectTriggered({effectId:s,parentEffectId:r,label:o,effect:t}),c.cancel=ut,n.cancel=function(){i||(i=!0,c.cancel(),c.cancel=ut,e.sagaMonitor&&e.sagaMonitor.effectCancelled(s))},a(t,s,c)}}function br(e,t){for(var r=e.channel,n=void 0===r?nr():r,o=e.dispatch,i=e.getState,s=e.context,a=void 0===s?{}:s,c=e.sagaMonitor,u=e.effectMiddlewares,d=e.onError,l=void 0===d?vt:d,h=arguments.length,p=new Array(h>2?h-2:0),f=2;f<h;f++)p[f-2]=arguments[f];var m,g=t.apply(void 0,p),v=ar();if(c&&(c.rootSagaStarted=c.rootSagaStarted||ut,c.effectTriggered=c.effectTriggered||ut,c.effectResolved=c.effectResolved||ut,c.effectRejected=c.effectRejected||ut,c.effectCancelled=c.effectCancelled||ut,c.actionDispatched=c.actionDispatched||ut,c.rootSagaStarted({effectId:v,saga:t,args:p})),u){var y=be.apply(void 0,u);m=function(e){return function(t,r,n){return y((function(t){return e(t,r,n)}))(t)}}}else m=dt;var b={channel:n,dispatch:bt(o),getState:i,sagaMonitor:c,onError:l,finalizeRunEffect:m};return zt((function(){var e=yr(b,g,a,v,Et(t),!0,void 0);return c&&c.effectResolved(v,e),e}))}function _r(e){var t,r=void 0===e?{}:e,n=r.context,o=void 0===n?{}:n,i=r.channel,s=void 0===i?nr():i,a=r.sagaMonitor,c=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}(r,["context","channel","sagaMonitor"]);function u(e){return t=br.bind(null,Ge({},c,{context:o,channel:s,dispatch:e.dispatch,getState:e.getState,sagaMonitor:a})),function(e){return function(t){a&&a.actionDispatched&&a.actionDispatched(t);var r=e(t);return s.put(t),r}}}return u.run=function(){return t.apply(void 0,arguments)},u.setContext=function(e){lt(o,e)},u}var wr={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function i(e,t,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,o=[];if(0===this._eventsCount)return o;for(n in e=this._events)t.call(e,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,o=t.length,i=new Array(o);n<o;n++)i[n]=t[n].fn;return i},a.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},a.prototype.emit=function(e,t,n,o,i,s){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,d=this._events[a],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,o),!0;case 5:return d.fn.call(d.context,t,n,o,i),!0;case 6:return d.fn.call(d.context,t,n,o,i,s),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,p=d.length;for(u=0;u<p;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,o);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},a.prototype.on=function(e,t,r){return i(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return i(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,o){var i=r?r+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||n&&a.context!==n||s(this,i);else{for(var c=0,u=[],d=a.length;c<d;c++)(a[c].fn!==t||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},a.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&s(this,t):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(wr);var Sr=wr.exports,kr=Object.defineProperty,Er=Object.defineProperties,Cr=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,Or=Object.prototype.hasOwnProperty,Ir=Object.prototype.propertyIsEnumerable,Pr=(e,t,r)=>t in e?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ar=(e,t)=>{for(var r in t||(t={}))Or.call(t,r)&&Pr(e,r,t[r]);if(Tr)for(var r of Tr(t))Ir.call(t,r)&&Pr(e,r,t[r]);return e},Rr=(e,t)=>Er(e,Cr(t)),Mr=(e,t)=>{var r={};for(var n in e)Or.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Tr)for(var n of Tr(e))t.indexOf(n)<0&&Ir.call(e,n)&&(r[n]=e[n]);return r},xr=(e,t)=>{for(var r in t)kr(e,r,{get:t[r],enumerable:!0})},jr=(e,t,r)=>(Pr(e,"symbol"!=typeof t?t+"":t,r),r),Lr="__local__",Dr=["room.started","room.ended"].map((e=>`video.${e}`)),Nr=()=>(new Date).toISOString().replace("T"," ").replace("Z",""),Vr=o.getLogger("signalwire"),Wr=Vr.methodFactory;Vr.methodFactory=(e,t,r)=>{const n=Wr(e,t,r);return function(){const e=[Nr(),"-"];for(let t=0;t<arguments.length;t++)e.push(arguments[t]);n.apply(void 0,e)}};var $r,Ur=Vr.getLevel();Vr.setLevel(Ur);var Fr={},qr=()=>null!=$r?$r:Vr,zr=({type:e,payload:t})=>{const r=qr(),{logWsTraffic:n}=Fr||{};if(!n)return;const o=(e=>!("method"in e)||"signalwire.ping"!==e.method)(t)?JSON.stringify(t,null,2):t;return r.info(`${e.toUpperCase()}: \n`,o,"\n")},Br=()=>{const e=qr();return new Proxy(e,{get:(e,t,r)=>"wsTraffic"===t?zr:Reflect.get(e,t,r)})},Hr=(e,t)=>{const{result:r={},error:n}=e;if(n)return{error:n};const{code:o,node_id:i,result:s=null}=r;return o&&"200"!==o?{error:r}:null===s?(t&&(r.node_id=t),{result:r}):s?s.jsonrpc?Hr(s,i):{result:s}:{result:r}},Kr={propsToUpdateValue:["updated","layers","members","recordings","playbacks"]},Qr=(e,t=Kr)=>Object.entries(e).reduce(((e,[r,n])=>{const o=Jr(r);return e[o]="object"==typeof n&&n?Array.isArray(n)?t.propsToUpdateValue.includes(r)?n.map((e=>"string"==typeof e?Jr(e):Qr(e))):n:Qr(n):(e=>e.endsWith("At"))(o)?(e=>{if(void 0===e)return e;const t=new Date(1e3*e);return isNaN(t.getTime())?e:t})(n):n,e}),{}),Jr=e=>e.includes("_")?e.split("_").reduce(((e,t,r)=>{const n=t.trim().charAt(0),o=t.substr(1).toLowerCase();return`${e}${0===r?n.toLowerCase():n.toUpperCase()}${o}`}),""):e,Gr=({event:e,namespace:t})=>("string"==typeof e&&(e=Zr({event:e,namespace:t}),e=Yr(e)),e),Xr=/[A-Z]/g,Yr=e=>e.replace(Xr,(e=>`_${e.toLowerCase()}`)),Zr=({namespace:e,event:t})=>!e||t.startsWith(e)?t:`${e}:${t}`,en=(e,t)=>(Object.keys(t).forEach((t=>{if(e.prototype.hasOwnProperty(t))throw new Error(`[extendComponent] Duplicated method name: ${t}`)})),Object.defineProperties(e.prototype,t),e),tn=({instance:e,transform:t,payload:r,transformedPayload:n})=>new Proxy(e,{get:(e,o,i)=>"toString"===o?(({property:e,payload:t})=>"function"==typeof e?()=>JSON.stringify(t):e)({property:e[o],payload:n}):"_eventsNamespace"===o&&t.getInstanceEventNamespace?t.getInstanceEventNamespace(r):"eventChannel"===o&&t.getInstanceEventChannel?t.getInstanceEventChannel(r):o in n?n[o]:Reflect.get(e,o,i)}),rn=new Map,nn=[{field:"members",preProcessPayload:e=>({member:e}),eventTransformType:"roomSessionMember"},{field:"recordings",preProcessPayload:e=>({recording:e}),eventTransformType:"roomSessionRecording"}],on=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}},sn=/^(ws|wss):\/\//,an=["video.member.updated","video.member.talking"],cn=["video.room.joined","video.track","video.active","video.answering","video.destroy","video.early","video.hangup","video.held","video.new","video.purge","video.recovering","video.requesting","video.ringing","video.trying"],un=e=>e.includes(Lr),dn=e=>{const t=e.split(".")[0];return e.split(".").reduce(((e,r)=>(e.push(r),r===t&&e.push(Lr),e)),[]).join(".")},ln=e=>{var t;return Ar({jsonrpc:"2.0",id:null!=(t=e.id)?t:l()},e)},hn=e=>Ar({jsonrpc:"2.0"},e),pn={major:3,minor:0,revision:0},fn=e=>ln({method:"signalwire.connect",params:Ar({version:pn},e)}),mn={id:"callID",destinationNumber:"destination_number",remoteCallerName:"remote_caller_id_name",remoteCallerNumber:"remote_caller_id_number",callerName:"caller_id_name",callerNumber:"caller_id_number"},gn=e=>{if(e.hasOwnProperty("dialogParams")){const t=Mr(e.dialogParams,["remoteSdp","localStream","remoteStream"]);for(const e in mn)e&&t.hasOwnProperty(e)&&(t[mn[e]]=t[e],delete t[e]);e.dialogParams=t}return e},vn=e=>(t={})=>ln({method:e,params:gn(t)}),yn=vn("verto.invite"),bn=vn("verto.bye"),_n=vn("verto.info"),wn=(e,t)=>hn({id:e,result:{method:t}}),Sn={};xr(Sn,{authErrorAction:()=>In,authSuccessAction:()=>Pn,closeConnectionAction:()=>Cn,createAction:()=>De,destroyAction:()=>En,executeAction:()=>On,getCustomSagaActionType:()=>Vn,initAction:()=>kn,makeCustomSagaAction:()=>Nn,reauthAction:()=>Tn,sessionConnectedAction:()=>xn,sessionDisconnectedAction:()=>jn,sessionReconnectingAction:()=>Ln,socketClosedAction:()=>An,socketErrorAction:()=>Rn,socketMessageAction:()=>Mn});var kn=De("swSdk/init"),En=De("swSdk/destroy"),Cn=De("swSdk/closeConnection"),Tn=De("swSdk/reauth"),On=De("swSdk/executeRequest"),In=De("auth/error"),Pn=De("auth/success"),An=De("socket/closed"),Rn=De("socket/error"),Mn=De("socket/message"),xn=De("session.connected"),jn=De("session.disconnected"),Ln=De("session.reconnecting"),Dn=(e,t)=>`${t.type}/${e}`,Nn=(e,t)=>Rr(Ar({},t),{type:Dn(e,t)}),Vn=(e,t)=>Dn(e,t),Wn=({name:e="",initialState:t,reducers:r,extraReducers:n})=>function(e){var t=e.name;if(!t)throw new Error("`name` is a required option for createSlice");var r,n="function"==typeof e.initialState?e.initialState:ce(e.initialState,(function(){})),o=e.reducers||{},i=Object.keys(o),s={},a={},c={};function u(){var t="function"==typeof e.extraReducers?Ne(e.extraReducers):[e.extraReducers],r=t[0],o=t[1],i=void 0===o?[]:o,s=t[2],c=void 0===s?void 0:s,u=Me(Me({},void 0===r?{}:r),a);return function(e,t,r,n){void 0===r&&(r=[]);var o,i="function"==typeof t?Ne(t):[t,r,n],s=i[0],a=i[1],c=i[2];if(function(e){return"function"==typeof e}(e))o=function(){return ce(e(),(function(){}))};else{var u=ce(e,(function(){}));o=function(){return u}}function d(e,t){void 0===e&&(e=o());var r=Te([s[t.type]],a.filter((function(e){return(0,e.matcher)(t)})).map((function(e){return e.reducer})));return 0===r.filter((function(e){return!!e})).length&&(r=[c]),r.reduce((function(e,r){if(r){var n;if(p(e))return void 0===(n=r(e,t))?e:n;if(f(e))return ce(e,(function(e){return r(e,t)}));if(void 0===(n=r(e,t))){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return n}return e}),e)}return d.getInitialState=o,d}(n,u,i,c)}return i.forEach((function(e){var r,n,i=o[e],u=t+"/"+e;"reducer"in i?(r=i.reducer,n=i.prepare):r=i,s[e]=r,a[u]=r,c[e]=n?De(u,n):De(u)})),{name:t,reducer:function(e,t){return r||(r=u()),r(e,t)},actions:c,caseReducers:s,getInitialState:function(){return r||(r=u()),r.getInitialState()}}}({name:e,initialState:t,reducers:r,extraReducers:e=>{e.addCase(En.type,(()=>t)),"function"==typeof n&&n(e)}}),$n=Wn({name:"session",initialState:{protocol:"",iceServers:[],authStatus:"unknown",authError:void 0,authCount:0},reducers:{connected:(e,{payload:t})=>{var r,n;e.authStatus="authorized",e.authCount+=1,e.protocol=null!=(r=null==t?void 0:t.protocol)?r:"",e.iceServers=null!=(n=null==t?void 0:t.ice_servers)?n:[]},authStatus:(e,{payload:t})=>{e.authStatus=t}},extraReducers:e=>{e.addCase(In.type,((e,{payload:t})=>{e.authStatus="unauthorized",e.authError=t.error}))}}),{actions:Un,reducer:Fn}=$n,qn=Wn({name:"components",initialState:{byId:{}},reducers:{upsert:(e,{payload:t})=>{t.id in e.byId?Object.keys(t).forEach((r=>{e.byId[t.id][r]=t[r]})):e.byId[t.id]=t},executeSuccess:(e,{payload:t})=>{var r,n;const{componentId:o,requestId:i,response:s}=t;null!=(r=e.byId)[o]||(r[o]={id:o}),null!=(n=e.byId[o]).responses||(n.responses={}),e.byId[o].responses[i]=s},executeFailure:(e,{payload:t})=>{var r,n;const{componentId:o,requestId:i,error:s,action:a}=t;null!=(r=e.byId)[o]||(r[o]={id:o}),null!=(n=e.byId[o]).errors||(n.errors={}),e.byId[o].errors[i]={action:a,jsonrpc:s}},cleanup:(e,{payload:t})=>{t.ids.forEach((t=>{delete e.byId[t]}))}}}),{actions:zn,reducer:Bn}=qn,Hn={queue:[]},Kn=Wn({name:"executeQueue",initialState:Hn,reducers:{add:(e,{payload:t})=>{e.queue.push(t)},clean:()=>Hn}}),{actions:Qn,reducer:Jn}=Kn,Gn=ye({components:Bn,session:Fn,executeQueue:Jn});xr({},{createCatchableSaga:()=>Zn,createRestartableSaga:()=>Xn});var Xn=e=>function*(){!function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];Mt(Nt.apply(void 0,[e].concat(r)))}((function*(){for(;;)try{Br().debug("Run a restartable saga"),yield Dt(e),Br().debug("One of the restartable saga has ended. Restarting..")}catch(e){Br().error("Restartable Saga Error",e)}}))},Yn=e=>Br().error("Catchable Saga Error",e),Zn=(e,t=Yn)=>function*(...r){try{yield Dt(e,...r)}catch(e){t(e)}},eo={};xr(eo,{getAuthError:()=>oo,getAuthStatus:()=>no,getIceServers:()=>to,getSession:()=>ro});var to=({session:e})=>{var t;return null!=(t=null==e?void 0:e.iceServers)?t:[]},ro=e=>e.session,no=({session:e})=>e.authStatus,oo=({session:e})=>e.authError,io=({components:e},t)=>{var r;return null==(r=e.byId)?void 0:r[t]},so=e=>{const t=(({components:e})=>e.byId)(e);let r=[];return Object.keys(t).forEach((e=>{(t[e].responses||t[e].errors)&&r.push(e)})),r};function*ao(e){function*t(t){if("authorized"!==(yield Vt(no)))return;const{componentId:r,requestId:n,method:o,params:i}=t.payload;try{const s=(({method:e,params:t})=>ln({method:e,params:t}))({id:n,method:o,params:i}),a=yield Dt(e.execute,s);r&&n&&(yield jt(zn.executeSuccess({componentId:r,requestId:n,response:a})))}catch(e){Br().warn("worker error",r,e),r&&n&&(yield jt(zn.executeFailure({componentId:r,requestId:n,action:t,error:e})))}finally{if((yield Rt("CANCELLED",{}))&&r&&n){const e={jsonrpc:"2.0",id:n,error:{code:-32600,message:"Cancelled task"}};Br().debug("executeActionWorker cancelled",{requestId:n,componentId:r,error:e}),yield jt(zn.executeFailure({componentId:r,requestId:n,action:t,error:e}))}}}for(;;){const e=yield xt(On.type);yield Nt(t,e)}}function*co({session:e,sessionChannel:t,pubSubChannel:r}){function*n({jsonrpc:t,nodeId:r}){var n,o;const{id:i,method:s,params:a={}}=t;switch(s){case"verto.media":{const e={id:a.callID,state:"early",remoteSDP:a.sdp,nodeId:r};yield jt(zn.upsert(e)),yield jt(On({method:"video.message",params:{message:wn(i,s),node_id:r}}));break}case"verto.answer":{const e={id:a.callID,state:"active",nodeId:r};(null==a?void 0:a.sdp)&&(e.remoteSDP=a.sdp),yield jt(zn.upsert(e)),yield jt(On({method:"video.message",params:{message:wn(i,s),node_id:r}}));break}case"verto.bye":{const e={id:a.callID,state:"hangup",nodeId:r,byeCause:null!=(n=null==a?void 0:a.cause)?n:"",byeCauseCode:null!=(o=null==a?void 0:a.causeCode)?o:0,redirectDestination:null==a?void 0:a.redirectDestination};yield jt(zn.upsert(e)),yield jt(On({method:"video.message",params:{message:wn(i,s),node_id:r}}));break}case"verto.ping":yield jt(On({method:"video.message",params:{message:wn(i,s),node_id:r}}));break;case"verto.punt":return e.disconnect();case"verto.mediaParams":{const{callID:e,mediaParams:t={}}=a;if(!e){Br().debug("Invalid mediaParams event",a);break}const r={id:e};(null==t?void 0:t.video)&&(r.videoConstraints=t.video),(null==t?void 0:t.audio)&&(r.audioConstraints=t.audio),yield jt(zn.upsert(r));break}case"verto.info":return Br().debug("Verto Info",a);case"verto.clientReady":return Br().debug("Verto ClientReady",a);case"verto.announce":return Br().debug("Verto Announce",a);default:return Br().debug(`Unknown Verto method: ${s}`,a)}}function*o(e){switch(e.event_type){case"video.room.subscribed":yield jt(zn.upsert({id:e.params.call_id,roomId:e.params.room_session.room_id,roomSessionId:e.params.room_session.id,memberId:e.params.member_id,previewUrl:e.params.room_session.preview_url})),yield jt(r,{type:"video.room.joined",payload:e.params});break;case"video.member.updated":{const{member:{updated:t=[]}}=e.params;for(const n of t){const t=`video.member.updated.${n}`;yield jt(r,{type:t,payload:e.params})}break}case"video.member.joined":{const{member:t}=e.params;(null==t?void 0:t.parent_id)&&(yield Vt(io,t.parent_id))&&(yield jt(zn.upsert({id:t.id,roomId:e.params.room_id,roomSessionId:e.params.room_session_id,memberId:t.id})));break}case"video.member.talking":{const{member:t}=e.params;if("talking"in t){const n=t.talking?"started":"ended";yield jt(r,{type:`video.member.talking.${n}`,payload:e.params});const o=t.talking?"start":"stop";yield jt(r,{type:`video.member.talking.${o}`,payload:e.params})}break}}yield jt(r,{type:e.event_type,payload:e.params})}function*i(e){yield jt(r,{type:e.event_type,payload:e.params})}function*s(e){var t;"webrtc.message"!==(null==(t=e)?void 0:t.event_type)?(e=>{var t;return!!(null==(t=null==e?void 0:e.event_type)?void 0:t.startsWith("video."))})(e)?yield Nt(o,e):(e=>{var t;return!!(null==(t=null==e?void 0:e.event_type)?void 0:t.startsWith("cantina-manager."))})(e)?yield Nt(i,e):yield jt({type:e.event_type,payload:e}):yield Nt(n,{jsonrpc:e.params,nodeId:e.node_id})}const a=Zn((function*(e){if(e.type!==Mn.type)return void(yield jt(e));const{method:t,params:r}=e.payload;switch(t){case"signalwire.event":yield Nt(s,r);break;default:return Br().debug(`Unknown message: ${t}`,e)}}),(e=>{Br().error("Channel Error",e)}));for(;;)try{for(;;){const e=yield xt(t);yield Nt(a,e)}}catch(e){Br().error("sessionChannelWorker error:",e)}finally{Br().debug("sessionChannelWorker finally")}}function uo(e){return function(t,r){void 0===r&&(r=Tt);var n,o,i=!1,s=rr(r),a=function(){i||(i=!0,Ze(n)&&n(),s.close())};return n=pt((o=function(e){tr(e)?a():s.put(e)},e.dispatch=e=>{o(e)},n=()=>{Br().debug("sessionChannel unsubscribe"),e.disconnect()})),i&&n(),{take:s.take,flush:s.flush,close:a}}()}function*lo({pubSubChannel:e,emitter:t}){for(;;){const n=yield xt(e),{type:o,payload:i}=n;try{const e=void 0===(r=n).payload?"":(e=>e.type.startsWith("video.member."))(r)||(e=>e.type.startsWith("video.layout."))(r)||(e=>e.type.startsWith("video.recording."))(r)||(e=>e.type.startsWith("video.playback."))(r)?r.payload.room_session_id:(e=>e.type.startsWith("video.room."))(r)?r.payload.room_session.id:((e=>{e.type.startsWith("chat.")})(r),"");Dr.includes(o)&&t.emit(o,i),t.emit(Gr({namespace:e,event:o}),i)}catch(e){Br().error(e)}}var r}var ho=({executeQueue:e})=>e;function*po(){function*e(e){"authorized"!==(yield Vt(no))&&(yield jt(Qn.add(e.payload)))}for(;;){const t=yield xt(On.type);yield Nt(e,t)}}function*fo(){const{queue:e}=yield Vt(ho);for(const t of e)yield jt(On(t));yield jt(Qn.clean())}var mo=class extends Error{constructor(e,t){super(t),this.code=e,this.message=t,jr(this,"name","AuthError"),Object.setPrototypeOf(this,mo.prototype)}};function*go(){const e=yield Vt(so);e.length&&(yield jt(zn.cleanup({ids:e})))}function*vo(){for(;;)yield Wt(36e5),yield Nt(go)}function*yo({SessionConstructor:e,userOptions:t,channels:r}){var n;const o=new e(t),i=yield Dt(uo,o),s=r.pubSubChannel;let a=[];if(null==(n=t.workers)?void 0:n.length)try{const e=t.workers.map((e=>Dt(Xn(e))));a=yield function(e){var t=Rt("ALL",e);return t.combinator=!0,t}(e)}catch(e){Br().error("Error running custom workers",e)}yield Nt(co,{session:o,sessionChannel:i,pubSubChannel:s}),yield Nt(wo,{session:o,sessionChannel:i,pubSubChannel:s,userOptions:t});const c=yield Nt(vo);o.connect(),yield xt(En.type),null==c||c.cancel(),s.close(),i.close(),a.forEach((e=>e.cancel()))}function*bo({session:e,sessionChannel:t,pubSubChannel:r}){"reconnecting"===e.status?(yield jt(r,Ln()),yield Wt(2e3*Math.random()),yield Dt(e.connect)):(t.close(),yield jt(r,jn()))}function*_o({session:e,token:t}){try{e.reauthenticate&&(e.token=t,yield Dt(e.reauthenticate))}catch(e){Br().error("Reauthenticate Error",e)}}function*wo(e){for(;;){const t=yield xt([Pn.type,In.type,Rn.type,An.type,Tn.type]);switch(t.type){case Pn.type:yield Nt(So,e);break;case In.type:{const{error:e}=t.payload;throw e?new mo(e.code,e.error):new Error("Unauthorized")}case Rn.type:break;case An.type:yield Nt(bo,e);break;case Tn.type:yield Nt(_o,{session:e.session,token:t.payload.token})}}}function*So(e){const{session:t,pubSubChannel:r,userOptions:n}=e,o=yield Nt(lo,{pubSubChannel:r,emitter:n.emitter}),i=yield Nt(ao,t);yield jt(Un.connected(t.rpcConnectResult)),yield jt(r,xn());const s=yield Nt(fo);yield xt(Cn.type),o.cancel(),i.cancel(),s.cancel()}var ko=e=>{const{componentListeners:t={},sessionListeners:r={},store:n,Component:o,customSagas:i=[]}=e,s=Object.keys(t),a=Object.keys(r);return e=>{const c=new o(Rr(Ar({},e),{store:n})),u=new Map;let d=!0;const l=n.subscribe((()=>{const e=n.getState(),o=io(e,c.__uuid)||{};for(const e of s){if(!1===d)return;const r=`${c.__uuid}.${e}`,n=u.get(r),i=o[e];if(void 0!==i&&n!==i){u.set(r,i);const n=t[e];"string"==typeof n?c[n](o):n(o)}}const i=ro(e);for(const e of a){if(!1===d)return;const t=`session.${e}`,n=u.get(t),o=i[e];if(void 0!==o&&n!==o){u.set(t,o);const n=r[e];"string"==typeof n?c[n](i):"function"==typeof n&&n(i)}}})),h=null==i?void 0:i.map((e=>n.runSaga(e,{instance:c,runSaga:n.runSaga})));return c.destroyer=()=>{d=!1,l(),u.clear(),(null==h?void 0:h.length)&&h.forEach((e=>e.cancel()))},c}},Eo=e=>e,Co=class{constructor(e){this.options=e,jr(this,"uuid",l()),jr(this,"_eventsPrefix",""),jr(this,"_eventsRegisterQueue",new Set),jr(this,"_eventsEmitQueue",new Set),jr(this,"_eventsNamespace"),jr(this,"_eventsTransformsCache",new Map),jr(this,"_requests",new Map),jr(this,"_customSagaTriggers",new Map),jr(this,"_destroyer"),jr(this,"_emitterTransforms",new Map),jr(this,"_emitterListenersCache",new Map),jr(this,"_trackedEvents",[]),jr(this,"_runningWorkers",[])}get __uuid(){return this.uuid}get logger(){return Br()}_getNamespacedEvent(e){let t=this._eventsNamespace;return"string"==typeof e&&un(e)&&(t=this.__uuid),Gr({event:e,namespace:t})}_getPrefixedEvent(e){return this._eventsPrefix&&"string"==typeof e&&!e.includes(`${this._eventsPrefix}.`)?`${this._eventsPrefix}.${e}`:e}_getInternalEvent(e){return this._getNamespacedEvent(this._getPrefixedEvent(e))}set destroyer(e){this._destroyer=e}get store(){return this.options.store}get emitter(){return this.options.emitter}addEventToRegisterQueue(e){const[t,r]=e.params;return this.logger.trace("Adding event to the register queue",{event:t,fn:r}),this._eventsRegisterQueue.add({type:e.type,params:e.params}),this.emitter}_addEventToEmitQueue(e,t){this.logger.trace("Adding to the emit queue",e),this._eventsEmitQueue.add({event:e,args:t})}shouldAddToQueue(){return void 0===this._eventsNamespace}runAndCacheEventHandlerTransform({internalEvent:e,transform:t,payload:r}){if(!this._eventsTransformsCache.has(e)){const n=t.instanceFactory(r);return this._eventsTransformsCache.set(e,n),n}return this._eventsTransformsCache.get(e)}cleanupEventHandlerTransformCache({internalEvent:e,force:t}){const r=this._eventsTransformsCache.get(e),n=this.listenerCount(e);return r&&(t||n<=1)?(r.destroy(),this._eventsTransformsCache.delete(e)):(this.logger.trace("[cleanupEventHandlerTransformCache] Key wasn't cached",e),!1)}getEmitterListenersMapByInternalEventName(e){var t;return null!=(t=this._emitterListenersCache.get(e))?t:new Map}getAndRemoveStableEventHandler(e,t){const r=this.getEmitterListenersMapByInternalEventName(e);if(t&&r.has(t)){const n=r.get(t);return r.delete(t),this._emitterListenersCache.set(e,r),n}return t}_createStableEventHandler(e,t){return r=>{const n=this._emitterTransforms.get(e);if(!n)return t(r);const o=this.runAndCacheEventHandlerTransform({internalEvent:e,transform:n,payload:r}),i=this._parseNestedFields(n.payloadTransform(r)),s=tn({instance:o,payload:r,transformedPayload:i,transform:n});return t(s)}}_parseNestedFields(e){return nn.forEach((({field:t,preProcessPayload:r,eventTransformType:n})=>{var o;const i=this._emitterTransforms.get(n);i&&(null==(o=null==e?void 0:e[t])?void 0:o.length)&&(e[t]=e[t].map((e=>(({transform:e,payload:t})=>{const r=(({transform:e,payload:t})=>{if(!rn.has(e.type)){const r=e.instanceFactory(t);return rn.set(e.type,r),r}return rn.get(e.type)})({transform:e,payload:t}),n=e.payloadTransform(t);return tn({transform:e,payload:t,instance:r,transformedPayload:n})})({transform:i,payload:r(e)}))))})),e}getOrCreateStableEventHandler(e,t){const r=this.getEmitterListenersMapByInternalEventName(e);let n=r.get(t);return n||(n=this._createStableEventHandler(e,t),r.set(t,n),this._emitterListenersCache.set(e,r)),n}_trackEvent(e){this._trackedEvents=Array.from(new Set(this._trackedEvents.concat(e)))}_untrackEvent(e){this._trackedEvents=this._trackedEvents.filter((t=>t!==e))}_addListener(e,t,r){const n=this._getInternalEvent(e);this._trackEvent(n);const o=r?"once":"on";if(this.shouldAddToQueue())return this.addEventToRegisterQueue({type:o,params:[e,t]}),this.emitter;const i=this.getOrCreateStableEventHandler(n,t);return this.logger.trace("Registering event",n),this.emitter[o](n,i)}on(e,t){return this._addListener(e,t)}once(e,t){return this._addListener(e,t,!0)}off(e,t){if(this.shouldAddToQueue())return this.addEventToRegisterQueue({type:"off",params:[e,t]}),this.emitter;const r=this._getInternalEvent(e),n=this.getAndRemoveStableEventHandler(r,t);return this.cleanupEventHandlerTransformCache({internalEvent:r,force:!n}),this.logger.trace("Removing event listener",r),this._untrackEvent(r),this.emitter.off(r,n)}removeAllListeners(e){return this.shouldAddToQueue()?(this.addEventToRegisterQueue({type:"removeAllListeners",params:[e]}),this.emitter):e?this.off(e):(this.eventNames().forEach((e=>{this.off(e)})),this.emitter)}eventNames(){return this._trackedEvents}getSubscriptions(){return(e=>{const t=this.eventNames().map((e=>{if("string"==typeof e){const t=(e=>{const t=e.split(":");return t[t.length-1]})(e);return cn.includes(t)?null:an.find((e=>t.startsWith(e)))||t}return e}));return Array.from(new Set(t)).filter(Boolean)})()}emit(e,...t){if(this.shouldAddToQueue())return this._addEventToEmitQueue(e,t),!1;const r=this._getInternalEvent(e);return this.logger.trace("Emit on event:",r),this.emitter.emit(r,...t)}listenerCount(e){return this.emitter.listenerCount(e)}destroy(){var e;null==(e=this._destroyer)||e.call(this),this.removeAllListeners(),this.detachWorkers()}execute({method:e,params:t},{transformResolve:r=Eo,transformReject:n=Eo}={transformResolve:Eo,transformReject:Eo}){return new Promise(((o,i)=>{const s=l();this._requests.set(s,{resolve:o,reject:i,transformResolve:r,transformReject:n}),this.store.dispatch(On({requestId:s,componentId:this.__uuid,method:e,params:t}))}))}triggerCustomSaga(e){return new Promise(((t,r)=>{const n=l();this._customSagaTriggers.set(n,{resolve:t,reject:r}),this.store.dispatch(Ar({dispatchId:n},Nn(this.__uuid,e)))}))}settleCustomSagaTrigger({dispatchId:e,payload:t,kind:r}){const n=this._customSagaTriggers.get(e);n&&(n[r](t),this._customSagaTriggers.delete(e))}select(e){return e(this.store.getState())}onError(e){this._requests.forEach(((t,r)=>{void 0!==(null==e?void 0:e.errors[r])&&(t.reject(t.transformReject(e.errors[r])),this._requests.delete(r))}))}onSuccess(e){this._requests.forEach(((t,r)=>{void 0!==(null==e?void 0:e.responses[r])&&(t.resolve(t.transformResolve(e.responses[r])),this._requests.delete(r))}))}getStateProperty(e){return this[e]}flushEventsRegisterQueue(){this._eventsRegisterQueue.forEach((e=>{this[e.type](...e.params),this._eventsRegisterQueue.delete(e)}))}flushEventsEmitQueue(){this._eventsEmitQueue.forEach((e=>{const{event:t,args:r}=e;this.emit(t,...r),this._eventsEmitQueue.delete(e)}))}flushEventsQueue(){this.flushEventsRegisterQueue(),this.flushEventsEmitQueue()}_attachListeners(e){"string"==typeof e&&(this._eventsNamespace=e),this.flushEventsQueue()}getEmitterTransforms(){return new Map}get _sessionAuthStatus(){return no(this.store.getState())}_waitUntilSessionAuthorized(){switch(no(this.store.getState())){case"authorized":return Promise.resolve(this);case"unknown":case"authorizing":return new Promise(((e,t)=>{const r=this.store.subscribe((()=>{const n=no(this.store.getState()),o=oo(this.store.getState());if("authorized"===n)e(this),r();else if("unauthorized"===n){const e=o?new mo(o.code,o.error):new Error("Unauthorized");t(e),r()}}))}));case"unauthorized":return Promise.reject(new Error("Unauthorized"))}}_setEmitterTransform({event:e,handler:t,local:r}){const n=this._getInternalEvent(e);(r?un(e):!un(e)&&this.eventNames().includes(n))&&this._emitterTransforms.set(n,t)}applyEmitterTransforms({local:e=!1}={local:!1}){this.getEmitterTransforms().forEach(((t,r)=>{Array.isArray(r)?r.forEach((r=>{this._setEmitterTransform({event:r,handler:t,local:e})})):this._setEmitterTransform({event:r,handler:t,local:e}),this._emitterTransforms.set(t.type,t)}))}getWorkers(){return new Map}attachWorkers(){this.getWorkers().forEach((({worker:e})=>{const t=this.store.runSaga(e);this._runningWorkers.push(t)}))}detachWorkers(){this._runningWorkers.forEach((e=>{e.cancel()})),this._runningWorkers=[]}},To=class extends Co{constructor(e){super(e),this.options=e,this._attachListeners("")}connect(){const e=no(this.store.getState());return"unknown"!==e&&"unauthorized"!==e||this.store.dispatch(kn()),this._waitUntilSessionAuthorized()}disconnect(){this.store.dispatch(En())}},Oo=class extends Co{constructor(e){super(e),this.options=e,jr(this,"subscribeMethod","signalwire.subscribe"),jr(this,"subscribeParams",{}),this.applyEmitterTransforms({local:!0})}subscribe(){return new Promise((async(e,t)=>{const r=this.getSubscriptions();if(r.length>0){const e={method:this.subscribeMethod,params:Rr(Ar({},this.subscribeParams),{event_channel:this.getStateProperty("eventChannel"),events:r})};try{this.applyEmitterTransforms(),this.attachWorkers(),await this.execute(e)}catch(e){return t(e)}}else this.logger.warn("`subscribe()` was called without any listeners attached.");return e(void 0)}))}},Io={audio_muted:!0,video_muted:!0,deaf:!0,on_hold:!0,visible:!0,input_volume:1,output_volume:1,input_sensitivity:1};Object.keys(Io).map((e=>`video.member.updated.${e}`));var Po=Qr(Io);Object.keys(Po).map((e=>`member.updated.${e}`));var Ao={};xr(Ao,{RoomSessionPlaybackAPI:()=>ni,RoomSessionRecordingAPI:()=>ti,audioMuteMember:()=>zo,audioUnmuteMember:()=>Bo,createRoomSessionPlaybackObject:()=>oi,createRoomSessionRecordingObject:()=>ri,deafMember:()=>Qo,getLayouts:()=>jo,getMembers:()=>Lo,getPlaybacks:()=>Fo,getRecordings:()=>$o,hideVideoMuted:()=>No,play:()=>qo,removeMember:()=>ei,setDeaf:()=>Go,setHideVideoMuted:()=>Wo,setInputSensitivityMember:()=>Zo,setInputVolumeMember:()=>Xo,setLayout:()=>Do,setOutputVolumeMember:()=>Yo,showVideoMuted:()=>Vo,startRecording:()=>Uo,undeafMember:()=>Jo,videoMuteMember:()=>Ho,videoUnmuteMember:()=>Ko});var Ro=()=>{},Mo=(e,t={})=>({value:function(r={}){return this.execute({method:e,params:Ar({room_session_id:this.roomSessionId},r)},t)}}),xo=(e,t={})=>({value:function(r={}){var n=r,{memberId:o}=n,i=Mr(n,["memberId"]);return this.execute({method:e,params:Ar({room_session_id:this.roomSessionId,member_id:o||this.memberId},i)},t)}}),jo=Mo("video.list_available_layouts",{transformResolve:e=>({layouts:e.layouts})}),Lo=Mo("video.members.get",{transformResolve:e=>({members:e.members})}),Do=Mo("video.set_layout",{transformResolve:Ro}),No=Mo("video.hide_video_muted",{transformResolve:Ro}),Vo=Mo("video.show_video_muted",{transformResolve:Ro}),Wo={value:function(e){return this.execute({method:e?"video.hide_video_muted":"video.show_video_muted",params:{room_session_id:this.roomSessionId}},{transformResolve:Ro})}},$o=Mo("video.recording.list",{transformResolve:e=>({recordings:e.recordings.map((e=>Qr(e)))})}),Uo={value:function(){return new Promise((async e=>{const t=t=>{e(t)};this.on(dn("video.recording.start"),t);try{const e=await this.execute({method:"video.recording.start",params:{room_session_id:this.roomSessionId}});this.emit(dn("video.recording.start"),Rr(Ar({},e),{room_session_id:this.roomSessionId}))}catch(e){throw this.off(dn("video.recording.start"),t),e}}))}},Fo=Mo("video.playback.list",{transformResolve:e=>({playbacks:e.playbacks.map((e=>Qr(e)))})}),qo={value:function(e){return new Promise((async t=>{const r=e=>{t(e)};this.on(dn("video.playback.start"),r);try{const t=await this.execute({method:"video.playback.start",params:Ar({room_session_id:this.roomSessionId},e)});this.emit(dn("video.playback.start"),Rr(Ar({},t),{room_session_id:this.roomSessionId}))}catch(e){throw this.off(dn("video.playback.start"),r),e}}))}},zo=xo("video.member.audio_mute",{transformResolve:Ro}),Bo=xo("video.member.audio_unmute",{transformResolve:Ro}),Ho=xo("video.member.video_mute",{transformResolve:Ro}),Ko=xo("video.member.video_unmute",{transformResolve:Ro}),Qo=xo("video.member.deaf",{transformResolve:Ro}),Jo=xo("video.member.undeaf",{transformResolve:Ro}),Go={value:function(e){return this.execute({method:e?"video.member.deaf":"video.member.undeaf",params:{room_session_id:this.roomSessionId,member_id:this.memberId}},{transformResolve:Ro})}},Xo=xo("video.member.set_input_volume",{transformResolve:Ro}),Yo=xo("video.member.set_output_volume",{transformResolve:Ro}),Zo=xo("video.member.set_input_sensitivity",{transformResolve:Ro}),ei={value:function(e={}){var t=e,{memberId:r}=t,n=Mr(t,["memberId"]);if(!r)throw new TypeError('Invalid or missing "memberId" argument');return this.execute({method:"video.member.remove",params:Ar({room_session_id:this.roomSessionId,member_id:r},n)},{transformResolve:Ro})}},ti=class extends Co{async pause(){await this.execute({method:"video.recording.pause",params:{room_session_id:this.getStateProperty("roomSessionId"),recording_id:this.getStateProperty("id")}})}async resume(){await this.execute({method:"video.recording.resume",params:{room_session_id:this.getStateProperty("roomSessionId"),recording_id:this.getStateProperty("id")}})}async stop(){await this.execute({method:"video.recording.stop",params:{room_session_id:this.getStateProperty("roomSessionId"),recording_id:this.getStateProperty("id")}})}},ri=e=>ko({store:e.store,Component:ti,componentListeners:{errors:"onError",responses:"onSuccess"}})(e),ni=class extends Co{async pause(){await this.execute({method:"video.playback.pause",params:{room_session_id:this.getStateProperty("roomSessionId"),playback_id:this.getStateProperty("id")}})}async resume(){await this.execute({method:"video.playback.resume",params:{room_session_id:this.getStateProperty("roomSessionId"),playback_id:this.getStateProperty("id")}})}async stop(){await this.execute({method:"video.playback.stop",params:{room_session_id:this.getStateProperty("roomSessionId"),playback_id:this.getStateProperty("id")}})}async setVolume(e){await this.execute({method:"video.playback.set_volume",params:{room_session_id:this.getStateProperty("roomSessionId"),playback_id:this.getStateProperty("id"),volume:e}})}},oi=e=>ko({store:e.store,Component:ni,componentListeners:{errors:"onError",responses:"onSuccess"}})(e),ii={};xr(ii,{BaseChatAPI:()=>bi,BaseChatConsumer:()=>yi,ChatMessage:()=>fi,createBaseChatObject:()=>_i,getMembers:()=>li,getMessages:()=>di,getState:()=>pi,publish:()=>ui,setState:()=>hi});var si=e=>{const t=!e||Array.isArray(e)?e:[e];return Array.isArray(t)?t.map((e=>({name:e}))):[]},ai=e=>Array.isArray(e)||"string"==typeof e,ci=(e,t={})=>({value:function(r={}){const n=ai(null==r?void 0:r.channels)?si(r.channels):void 0;return this.execute({method:e,params:Rr(Ar({},r),{channels:n})},t)}}),ui=ci("chat.publish"),di=ci("chat.messages.get",{transformResolve:e=>({messages:e.messages.map((e=>Qr(e))),cursor:e.cursor})}),li=ci("chat.members.get",{transformResolve:e=>({members:e.members.map((e=>Qr(e)))})}),hi=ci("chat.presence.set_state",{transformResolve:()=>{}}),pi=((e,t={})=>({value:function(r={}){var n=r,{memberId:o}=n,i=Mr(n,["memberId"]);const s=ai(null==i?void 0:i.channels)?si(i.channels):void 0;return this.execute({method:e,params:Rr(Ar({member_id:o},i),{channels:s})},t)}}))("chat.presence.get_state",{transformResolve:e=>({channels:e.channels})}),fi=class{constructor(e){this.payload=e}get id(){return this.payload.id}get senderId(){return this.payload.senderId}get channel(){return this.payload.channel}get content(){return this.payload.content}get meta(){return this.payload.meta}get publishedAt(){return this.payload.publishedAt}},mi=class{constructor(e){this.payload=e}get id(){return this.payload.id}get channel(){return this.payload.channel}get state(){var e,t;return null!=(t=null==(e=this.payload)?void 0:e.state)?t:{}}},gi=function*({channels:{pubSubChannel:e}}){for(;;){const t=yield xt((e=>e.type.startsWith("chat.")));switch(Br().debug("chatWorker:",t),t.type){case"chat.channel.message":yield jt(e,{type:"chat.message",payload:t.payload});break;case"chat.member.joined":case"chat.member.updated":case"chat.member.left":yield jt(e,t);break;default:Br().warn("[chatWorker] Unrecognized Action",t)}}},vi=e=>e.map((e=>({name:e}))),yi=class extends Oo{constructor(e){super(e),jr(this,"_eventsPrefix","chat"),jr(this,"subscribeMethod","chat.subscribe"),this._attachListeners("")}_getChannelsParam(e,t){const r=!e||Array.isArray(e)?e:[e];if(!Array.isArray(r)||0===r.length)throw new Error(`Please specify one or more channels when calling .${t}()`);return{channels:vi(r)}}_setSubscribeParams(e){this.subscribeParams=Ar(Ar({},this.subscribeParams),e)}_getSubscribeParams({channels:e}){return Ar({},this._getChannelsParam(e,"subscribe"))}_getUnsubscribeParams({channels:e}){const t=this._getChannelsParam(e,"unsubscribe");return Ar({},t)}getWorkers(){return new Map([["chat",{worker:gi}]])}getEmitterTransforms(){return new Map([[["message"],{type:"chatMessage",instanceFactory:e=>{const{channel:t,message:r}=e.params;return new fi(Qr(Rr(Ar({},r),{channel:t})))},payloadTransform:e=>{const{channel:t,message:r}=e.params;return Qr(Rr(Ar({},r),{channel:t}))}}],[["member.joined","member.left"],{type:"chatMessage",instanceFactory:e=>{const{channel:t,member:r}=e.params,n=Rr(Ar({},Qr(r)),{channel:t});return new mi(n)},payloadTransform:e=>{const{channel:t,member:r}=e.params;return Rr(Ar({},Qr(r)),{channel:t})}}],[["member.updated"],{type:"chatMessage",instanceFactory:e=>{const{channel:t,member:r,state:n={}}=e.params,o=Rr(Ar({},Qr(r)),{channel:t,state:n});return new mi(o)},payloadTransform:e=>{const{channel:t,member:r,state:n={}}=e.params;return Rr(Ar({},Qr(r)),{channel:t,state:n})}}]])}async subscribe(e){const t=this._getSubscribeParams({channels:e});return this._setSubscribeParams(t),super.subscribe()}async unsubscribe(e){if("unknown"===this._sessionAuthStatus||"unauthorized"===this._sessionAuthStatus)throw new Error("You must be authenticated to unsubscribe from a channel");const t=this._getUnsubscribeParams({channels:e});return new Promise((async(e,r)=>{const n=this.getSubscriptions();if(n.length>0){const e={method:"chat.unsubscribe",params:Rr(Ar({},t),{events:n})};try{await this.execute(e)}catch(e){return r(e)}}else this.logger.warn("`unsubscribe()` was called without any listeners attached.");return e(void 0)}))}},bi=en(yi,{publish:ui,getMembers:li,getMessages:di,setState:hi,getState:pi}),_i=e=>ko({store:e.store,Component:bi,componentListeners:{errors:"onError",responses:"onSuccess"}})(e),wi=Ar({},eo);const Si=()=>"undefined"!=typeof navigator&&!!navigator.mediaDevices,ki=()=>{if(!Si())throw new Error("The media devices API isn't supported in this environment");return navigator.mediaDevices},Ei=(e={audio:!0,video:!0})=>{try{return ki().getUserMedia(e)}catch(t){switch(t.name){case"Error":Br().error("navigator.mediaDevices.getUserMedia doesn't seem to be supported.");break;case"NotFoundError":Br().error("No media tracks of the type specified were found that satisfy the given constraints.");break;case"NotReadableError":Br().error("Hardware error occurred at the operating system, browser, or Web page level which prevented access to the device. This could have been caused by having the Camera or Mic being user by another application.");break;case"OverconstrainedError":Br().error(`The constraint: ${t.constraint} cannot be met by the selected device.`),Br().info("List of available constraints:",Ii());break;case"NotAllowedError":Br().error("The user has mostly likely denied access to the device. This could also happen if the browsing context is insecure (using HTTP rather than HTTPS)");break;case"TypeError":0===Object.keys(e).length?Br().error('Constraints can\'t be empty nor have "video" and "audio" set to false.'):Br().error("Please check that you are calling this method from a secure context (using HTTPS rather than HTTP).");break;case"SecurityError":Br().error("User media support is disabled on the Document on which getUserMedia() was called. The mechanism by which user media support is enabled and disabled is left up to the individual user agent.")}throw t}},Ci=e=>ki().getDisplayMedia(e),Ti=()=>ki().enumerateDevices(),Oi=async e=>{let t=await Ti().catch((e=>[]));return e&&(t=t.filter((({kind:t})=>t===e))),t},Ii=()=>ki().getSupportedConstraints(),Pi=e=>e&&e instanceof MediaStream,Ai=()=>"sinkId"in HTMLMediaElement.prototype,Ri=async(e,t)=>{if(null!==e)if("string"==typeof t)if(Ai())try{return await e.setSinkId(t)}catch(e){throw"SecurityError"===e.name?Br().error(`You need to use HTTPS for selecting audio output device: ${e}`):Br().error(`Error: ${e}`),e}else Br().warn("Browser does not support output device selection.");else Br().warn(`Invalid speaker deviceId: '${t}'`);else Br().warn("No HTMLMediaElement to attach the speakerId")},Mi=e=>{var t;Pi(e)&&(null===(t=null==e?void 0:e.getTracks())||void 0===t||t.forEach(xi))},xi=e=>{e&&"live"===e.readyState&&(e.stop(),e.dispatchEvent(new Event("ended")))},ji={camera:"videoinput",microphone:"audioinput",speaker:"audiooutput"},Li=e=>{if(e)return ji[e]},Di=async e=>{if("permissions"in navigator&&"function"==typeof navigator.permissions.query&&e)try{return"granted"===(await navigator.permissions.query({name:e})).state}catch(e){}return(async e=>{const t=await Oi(e);return t.length?t.every((({deviceId:e,label:t})=>Boolean(e&&t))):(Br().warn(`No ${e} devices to check for permissions!`),null)})(Li(e))},Ni=()=>Di("camera"),Vi=()=>Di("microphone"),Wi=()=>Di("speaker"),$i=async(e,t=!1)=>{if(!1===await Di(e)){const t=(e=>({audio:!e||"all"===e||"microphone"===e||"speaker"===e,video:!e||"all"===e||"camera"===e}))(e),r=await Ei(t);Mi(r)}return Fi(e,t)},Ui=(e,t={})=>{const r=[];return e.filter((({deviceId:e,kind:n,groupId:o})=>{var i;if(!e||t.targets&&!(null===(i=t.targets)||void 0===i?void 0:i.includes(n)))return!1;if(!o)return!0;const s=`${n}-${o}`,a=!(null==t?void 0:t.excludeDefault)||"default"!==e;return!(r.includes(s)||!a||(r.push(s),0))}))},Fi=async(e,t=!1)=>{const r=await Oi(Li(e));return!0===t?r:Ui(r)},qi=async(e,t,r)=>{const n=await Fi(r,!0);for(let r=0;r<n.length;r++){const{deviceId:o,label:i}=n[r];if(e===o||t===i)return o}return null},zi=e=>{const t=new Map;return e.forEach((e=>{e.deviceId&&t.set(e.deviceId,e)})),t},Bi={camera:Ni,microphone:Vi,speaker:Wi},Hi=["camera","microphone","speaker"],Ki=`Allowed targets are: '${Hi.join("', '")}'`,Qi={speaker:Ai},Ji=async(e={})=>{const t=await(async e=>{var t;const r=(null!==(t=e.targets)&&void 0!==t?t:Hi).filter((e=>!!Hi.includes(e)||(Br().warn(`We'll ignore the "${e}" target as it is not allowed. ${Ki}.`),!1)));if(!r.length)throw new Error(`At least one "target" is required for createDeviceWatcher(). ${Ki}.`);const n=await(async e=>{const t=e.targets;return(await Promise.all(t.map((e=>Bi[e]())))).reduce(((e,r,n)=>{var o;const i=t[n];return e[!(i in Qi)||(null===(o=Qi[i])||void 0===o?void 0:o.call(Qi))?"supported":"unsupported"].push([i,!!r]),e}),{supported:[],unsupported:[]})})({targets:r});if(n.unsupported.length>0&&r.length===n.unsupported.length)throw new Error(`The platform doesn't support "${r.join(", ")}" as target/s, which means it's not possible to watch for changes on those devices.`);if(n.supported.every((([e,t])=>!t)))throw new Error("You must ask the user for permissions before being able to listen for device changes. Try calling getUserMedia() before calling `createDeviceWatcher()`.");let o=[];const i=n.supported.reduce(((e,[t,r])=>(r?e.push(t):o.push(t),e)),[]);if(i.length!==r.length){const e=n.unsupported.length>0?`The platform doesn't support "${n.unsupported.map((([e])=>e)).join(", ")}" as target/s, which means it's not possible to watch for changes on those devices. `:"",t=o.length>0?`The user hasn't granted permissions for the following targets: ${o.join(", ")}. `:"";Br().warn(`${e}${t}We'll be watching for the following targets instead: "${i.join(", ")}"`)}return Br().debug(`Watching these targets: "${i.join(", ")}"`),i})({targets:e.targets}),r=new Sr,n=await Ti(),o=null==t?void 0:t.reduce(((e,t)=>{const r=Li(t);return r&&e.push(r),e}),[]);let i=Ui(n,{excludeDefault:!0,targets:o});return ki().addEventListener("devicechange",(async()=>{const e=await Ti(),t=i,n=Ui(e,{excludeDefault:!0,targets:o});i=n;const s=((e,t)=>{const r=zi(e),n=zi(e),o=[];Br().debug("[_getDeviceListDiff] <- oldDevices",e),Br().debug("[_getDeviceListDiff] -> newDevices",t);const i=t.filter((e=>{const t=e.deviceId,i=r.get(t);return i&&(n.delete(t),e.label!==i.label&&o.push(e)),void 0===i}));return{updated:o.map((e=>({type:"updated",payload:e}))),removed:Array.from(n,(([e,t])=>t)).map((e=>({type:"removed",payload:e}))),added:i.map((e=>({type:"added",payload:e})))}})(t,n),a=s.added.length>0,c=s.removed.length>0,u=s.updated.length>0;(a||c||u)&&r.emit("changed",{changes:s,devices:n}),a&&r.emit("added",{changes:s.added,devices:n}),c&&r.emit("removed",{changes:s.removed,devices:n}),u&&r.emit("updated",{changes:s.updated,devices:n})})),r},Gi=async e=>{Br().info("RTCService.getUserMedia",e);const{audio:t,video:r}=e;if(t||r)try{return await Ei(e)}catch(e){throw Br().error("getUserMedia error: ",e),e}},Xi=async e=>{let{audio:t=!0,micId:r}=e;const{micLabel:n=""}=e;if(r){const e=await qi(r,n,"microphone").catch((e=>null));e&&("boolean"==typeof t&&(t={}),t.deviceId={exact:e})}let{video:o=!1,camId:i}=e;const{camLabel:s=""}=e;if(i){const e=await qi(i,s,"camera").catch((e=>null));e&&("boolean"==typeof o&&(o={}),o.deviceId={exact:e})}return{audio:t,video:o}},Yi=e=>/^m=audio/.test(e),Zi=e=>/^m=video/.test(e),es=e=>{const t=e.split("\r\n"),r=t.findIndex((e=>/^a=rtpmap/.test(e)&&/opus\/48000/.test(e)));if(r<0)return e;const n=(e=>{const t=new RegExp("a=rtpmap:(\\d+) \\w+\\/\\d+"),r=e.match(t);return r&&2==r.length?r[1]:null})(t[r]),o=new RegExp(`a=fmtp:${n}`),i=t.findIndex((e=>o.test(e)));return i>=0?/stereo=1;/.test(t[i])||(t[i]+="; stereo=1; sprop-stereo=1"):t[r]+=`\r\na=fmtp:${n} stereo=1; sprop-stereo=1`,t.join("\r\n")};class ts{constructor(e,t){this.call=e,this.type=t,this._negotiating=!1,this.options=e.options,this.logger.debug("New Peer with type:",this.type,"Options:",this.options),this._onIce=this._onIce.bind(this)}get logger(){return Br()}get isOffer(){return"offer"===this.type}get isAnswer(){return"answer"===this.type}get isSimulcast(){return!0===this.options.simulcast}get isSfu(){return!0===this.options.sfu}get localVideoTrack(){const e=this._getSenderByKind("video");return(null==e?void 0:e.track)||null}get localAudioTrack(){const e=this._getSenderByKind("audio");return(null==e?void 0:e.track)||null}get hasAudioSender(){return!!this._getSenderByKind("audio")}get hasVideoSender(){return!!this._getSenderByKind("video")}get hasAudioReceiver(){return!!this._getReceiverByKind("audio")}get hasVideoReceiver(){return!!this._getReceiverByKind("video")}get config(){const{iceServers:e=[],rtcPeerConfig:t={}}=this.options,r=Object.assign({bundlePolicy:"max-compat",iceServers:e,sdpSemantics:"unified-plan"},t);return this.logger.debug("RTC config",r),r}get localSdp(){var e,t;return null===(t=null===(e=this.instance)||void 0===e?void 0:e.localDescription)||void 0===t?void 0:t.sdp}stopTrackSender(e){var t,r;try{const n=this._getSenderByKind(e);if(!n)return this.logger.info(`There is not a '${e}' sender to stop.`);n.track&&(xi(n.track),null===(r=null===(t=this.options)||void 0===t?void 0:t.localStream)||void 0===r||r.removeTrack(n.track))}catch(t){this.logger.error("RTCPeer stopTrackSender error",e,t)}}async restoreTrackSender(e){var t,r;try{const n=this._getSenderByKind(e);if(!n)return this.logger.info(`There is not a '${e}' sender to restore.`);if(n.track&&"ended"!==n.track.readyState)return this.logger.info(`There is already an active ${e} track.`);const o=await Xi(this.options),i=await Gi({[e]:o[e]});if(i&&Pi(i)){const o=i.getTracks().find((t=>t.kind===e));o&&(await n.replaceTrack(o),null===(r=null===(t=this.options)||void 0===t?void 0:t.localStream)||void 0===r||r.addTrack(o))}}catch(t){this.logger.error("RTCPeer restoreTrackSender error",e,t)}}getDeviceId(e){try{const t=this._getSenderByKind(e);if(!t||!t.track)return null;const{deviceId:r=null}=t.track.getSettings();return r}catch(t){return this.logger.error("RTCPeer getDeviceId error",e,t),null}}getTrackSettings(e){try{const t=this._getSenderByKind(e);return t&&t.track?t.track.getSettings():null}catch(t){return this.logger.error("RTCPeer getTrackSettings error",e,t),null}}getDeviceLabel(e){try{const t=this._getSenderByKind(e);return t&&t.track?t.track.label:null}catch(t){return this.logger.error("RTCPeer getDeviceLabel error",e,t),null}}restartIceWithRelayOnly(){try{const e=this.instance.getConfiguration();if("relay"===e.iceTransportPolicy)return this.logger.warn("RTCPeer already with iceTransportPolicy relay only");const t=Object.assign(Object.assign({},e),{iceTransportPolicy:"relay"});this.instance.setConfiguration(t),this.instance.restartIce()}catch(e){this.logger.error("RTCPeer restartIce error",e)}}async applyMediaConstraints(e,t){try{const r=this._getSenderByKind(e);if(!r||!r.track)return this.logger.info("No sender to apply constraints",e,t);if("live"===r.track.readyState){const n=Object.assign(Object.assign({},r.track.getConstraints()),t),o=this.getDeviceId(e);o&&!this.options.screenShare&&(n.deviceId={exact:o}),this.logger.info(`Apply ${e} constraints`,this.call.id,n),await r.track.applyConstraints(n)}}catch(r){this.logger.error("Error applying constraints",e,t)}}_getSenderByKind(e){return this.instance.getSenders?this.instance.getSenders().find((({track:t})=>t&&t.kind===e)):(this.logger.warn("RTCPeerConnection.getSenders() not available."),null)}_getReceiverByKind(e){return this.instance.getReceivers?this.instance.getReceivers().find((({track:t})=>t&&t.kind===e)):(this.logger.warn("RTCPeerConnection.getReceivers() not available."),null)}async startNegotiation(e=!1){var t,r;if(this._negotiating)return this.logger.warn("Skip twice onnegotiationneeded!");this._negotiating=!0;try{if((this.options.additionalDevice||this.options.screenShare)&&(null===(r=(t=this.instance).getTransceivers)||void 0===r||r.call(t).forEach((e=>{e.direction="sendonly"}))),this.instance.removeEventListener("icecandidate",this._onIce),this.instance.addEventListener("icecandidate",this._onIce),this.isOffer){this.logger.debug("Trying to generate offer");const e=await this.instance.createOffer({voiceActivityDetection:!1});await this._setLocalDescription(e)}if(this.isAnswer){this.logger.debug("Trying to generate answer"),await this._setRemoteDescription({sdp:this.options.remoteSdp,type:"offer"});const e=await this.instance.createAnswer({voiceActivityDetection:!1});await this._setLocalDescription(e)}e&&this._sdpReady()}catch(e){this.logger.error(`Error creating ${this.type}:`,e)}}async onRemoteSdp(e){try{const t=this.isOffer?"answer":"offer";await this._setRemoteDescription({sdp:e,type:t}),this.isOffer&&this._resolveStartMethod()}catch(e){this.logger.error(`Error handling remote SDP on call ${this.call.id}:`,e),this.call.hangup(),this._rejectStartMethod(e)}}_setupRTCPeerConnection(){this.instance||(this.instance=new window.RTCPeerConnection(this.config),this._attachListeners())}async start(){return new Promise((async(e,t)=>{this._resolveStartMethod=e,this._rejectStartMethod=t;try{this.options.localStream=await this._retrieveLocalStream()}catch(e){return this.logger.error("Error retrieving a local stream",e),this._rejectStartMethod(e),this.call.setState("hangup")}this._setupRTCPeerConnection();const{localStream:r=null}=this.options;if(r&&Pi(r)){const e=r.getAudioTracks();this.logger.debug("Local audio tracks: ",e);const t=r.getVideoTracks();if(this.logger.debug("Local video tracks: ",t),this.isOffer&&"function"==typeof this.instance.addTransceiver){e.forEach((e=>{this.instance.addTransceiver(e,{direction:"sendrecv",streams:[r]})}));const n={direction:"sendrecv",streams:[r]};if(this.isSimulcast&&(n.sendEncodings=["0","1","2"].map((e=>({active:!0,rid:e,scaleResolutionDownBy:6*Number(e)||1})))),this.logger.debug("Applying video transceiverParams",n),t.forEach((e=>{this.instance.addTransceiver(e,n)})),this.isSfu){const{msStreamsNumber:e=5}=this.options;this.logger.debug("Add ",e,"recvonly MS Streams"),n.direction="recvonly";for(let t=0;t<Number(e);t++)this.instance.addTransceiver("video",n)}}else"function"==typeof this.instance.addTrack?(e.forEach((e=>{this.instance.addTrack(e,r)})),t.forEach((e=>{this.instance.addTrack(e,r)}))):this.instance.addStream(r)}this.isOffer?(this.options.negotiateAudio&&this._checkMediaToNegotiate("audio"),this.options.negotiateVideo&&this._checkMediaToNegotiate("video")):this.startNegotiation()}))}_checkMediaToNegotiate(e){if(!this._getSenderByKind(e)&&this.instance.addTransceiver){const t=this.instance.addTransceiver(e);this.logger.debug("Add transceiver",e,t)}}async _sdpReady(){if(clearTimeout(this._iceTimeout),this._iceTimeout=null,!this.instance.localDescription)return;const{sdp:e,type:t}=this.instance.localDescription;if(-1===e.indexOf("candidate"))return this.logger.debug("No candidate - retry \n"),void this.startNegotiation(!0);this.logger.debug("LOCAL SDP \n",`Type: ${t}`,"\n\n",e),this.instance.removeEventListener("icecandidate",this._onIce);try{await this.call.onLocalSDPReady(this.instance.localDescription)}catch(e){this._rejectStartMethod(e)}}_onIce(e){this._iceTimeout||(this._iceTimeout=setTimeout((()=>this._sdpReady()),this.options.iceGatheringTimeout)),e.candidate?(this.logger.debug("IceCandidate:",e.candidate),this.call.emit("icecandidate",e)):this._sdpReady()}_setLocalDescription(e){const{useStereo:t,googleMaxBitrate:r,googleMinBitrate:n,googleStartBitrate:o}=this.options;return e.sdp&&t&&(e.sdp=es(e.sdp)),e.sdp&&r&&n&&o&&(e.sdp=((e,t,r,n)=>{const o=e.split("\r\n");return o.forEach(((e,i)=>{/^a=fmtp:\d*/.test(e)?o[i]+=`;x-google-max-bitrate=${t};x-google-min-bitrate=${r};x-google-start-bitrate=${n}`:/^a=mid:(1|video)/.test(e)&&(o[i]+=`\r\nb=AS:${t}`)})),o.join("\r\n")})(e.sdp,r,n,o)),this.logger.debug("LOCAL SDP \n",`Type: ${e.type}`,"\n\n",e.sdp),this.instance.setLocalDescription(e)}_setRemoteDescription(e){e.sdp&&this.options.useStereo&&(e.sdp=es(e.sdp)),e.sdp&&this.instance.localDescription&&(e.sdp=((e,t)=>{const r="\r\n",n=this.instance.localDescription.sdp.split(r);if(n.findIndex(Yi)<n.findIndex(Zi))return e;const o=e.split(r),i=o.findIndex(Yi),s=o.findIndex(Zi),a=o.slice(i,s),c=o.slice(s,o.length-1);return[...o.slice(0,i),...c,...a,""].join(r)})(e.sdp));const t=e;return this.logger.debug("REMOTE SDP \n",`Type: ${e.type}`,"\n\n",e.sdp),this.instance.setRemoteDescription(t)}async _retrieveLocalStream(){if(Pi(this.options.localStream))return this.options.localStream;const e=await Xi(this.options);return Gi(e)}_attachListeners(){this.instance.addEventListener("signalingstatechange",(()=>{switch(this.logger.debug("signalingState:",this.instance.signalingState),this.instance.signalingState){case"stable":this._negotiating=!1;break;case"closed":delete this.instance;break;default:this._negotiating=!0}})),this.instance.addEventListener("negotiationneeded",(()=>{this.logger.debug("Negotiation needed event"),this.startNegotiation()})),this.instance.addEventListener("iceconnectionstatechange",(()=>{this.logger.debug("iceConnectionState:",this.instance.iceConnectionState)})),this.instance.addEventListener("icegatheringstatechange",(()=>{this.logger.debug("iceGatheringState:",this.instance.iceGatheringState)})),this.instance.addEventListener("track",(e=>{this.call.emit("track",e),this.options.remoteStream=e.streams[0]})),this.instance.addEventListener("addstream",(e=>{e.stream&&(this.options.remoteStream=e.stream)}))}}const rs={destinationNumber:"room",remoteCallerName:"Outbound Call",remoteCallerNumber:"",callerName:"",callerNumber:"",audio:!0,video:{aspectRatio:16/9},useStereo:!1,attach:!1,screenShare:!1,additionalDevice:!1,userVariables:{},requestTimeout:1e4,autoApplyMediaParams:!0,iceGatheringTimeout:2e3};class ns extends Co{constructor(e){var t;super(e),this.nodeId="",this.gotEarly=!1,this.doReinvite=!1,this._eventsPrefix="video",this.state="new",this.prevState="new";const r=null!==(t=null==e?void 0:e.iceServers)&&void 0!==t?t:this.select(wi.getIceServers);this.options=Object.assign(Object.assign(Object.assign({},rs),e),{iceServers:r}),this.setState("new"),this.logger.debug("New Call with Options:",this.options),this.applyEmitterTransforms({local:!0}),this.attachWorkers()}get id(){return this.__uuid}get active(){return"active"===this.state}get trying(){return"trying"===this.state}get memberId(){return this._memberId}get previewUrl(){return this._previewUrl}get roomId(){return this._roomId}get roomSessionId(){return this._roomSessionId}get localStream(){return this.options.localStream}get remoteStream(){return this.options.remoteStream}get messagePayload(){const{destinationNumber:e,attach:t,callerName:r,callerNumber:n,remoteCallerName:o,remoteCallerNumber:i,userVariables:s,screenShare:a,additionalDevice:c}=this.options;return{sessid:this.options.sessionid,dialogParams:{id:this.__uuid,destinationNumber:e,attach:t,callerName:r,callerNumber:n,remoteCallerName:o,remoteCallerNumber:i,userVariables:s,screenShare:a,additionalDevice:c}}}get cameraId(){return this.peer?this.peer.getDeviceId("video"):null}get cameraLabel(){return this.peer?this.peer.getDeviceLabel("video"):null}get microphoneId(){return this.peer?this.peer.getDeviceId("audio"):null}get microphoneLabel(){return this.peer?this.peer.getDeviceLabel("audio"):null}get withAudio(){return!!this.remoteStream&&this.remoteStream.getAudioTracks().length>0}get withVideo(){return!!this.remoteStream&&this.remoteStream.getVideoTracks().length>0}get localVideoTrack(){return this.peer.localVideoTrack}get localAudioTrack(){return this.peer.localAudioTrack}vertoExecute(e){const t={message:e,node_id:this.nodeId};return"verto.invite"===e.method&&(t.subscribe=this.options.screenShare?["video.room.screenshare"]:this.options.additionalDevice?["video.room.additionaldevice"]:this.getSubscriptions()),this.execute({method:"video.message",params:t})}onStateChange(e){switch(this.logger.debug("onStateChange",e),e.state){case"hangup":this._hangup(e);break;default:this.setState(e.state)}}onRemoteSDP(e){this.logger.debug("onRemoteSDP",e),e.remoteSDP&&this.peer.onRemoteSdp(e.remoteSDP)}onRoomSubscribed(e){this.logger.debug("onRoomSubscribed",e),this.nodeId=e.nodeId,this._roomId=e.roomId,this._roomSessionId=e.roomSessionId,this._memberId=e.memberId,this._previewUrl=e.previewUrl,this._attachListeners(this.options.additionalDevice||this.options.screenShare?e.memberId:e.roomSessionId),this.applyEmitterTransforms()}onVideoConstraints(e){this.logger.debug("onVideoConstraints",e),(null==e?void 0:e.videoConstraints)&&this.peer.applyMediaConstraints("video",e.videoConstraints)}onAudioConstraints(e){this.logger.debug("onAudioConstraints",e),(null==e?void 0:e.audioConstraints)&&this.peer.applyMediaConstraints("audio",e.audioConstraints)}updateCamera(e){return this.updateConstraints({video:Object.assign({aspectRatio:16/9},e)})}updateMicrophone(e){return this.updateConstraints({audio:e})}manageSendersWithConstraints(e){return!1===e.audio&&(this.logger.info("Switching off the microphone"),this.stopOutboundAudio()),!1===e.video&&(this.logger.info("Switching off the camera"),this.stopOutboundVideo()),e.audio||e.video}updateConstraints(e){return new Promise((async(t,r)=>{try{if(this.logger.debug("updateConstraints trying constraints",this.__uuid,e),!Object.keys(e).length)return this.logger.warn("Invalid constraints:",e);if(!this.manageSendersWithConstraints(e))return void this.logger.debug("Either `video` and `audio` (or both) constraints were set to `false` so their corresponding senders (if any) were stopped");const r=await Ei(e);this.logger.debug("updateConstraints got stream",r),this.options.localStream||(this.options.localStream=new MediaStream);const{instance:n}=this.peer,o=r.getTracks();for(let e=0;e<o.length;e++){const t=o[e];this.logger.debug("updateConstraints apply track: ",t);const r=n.getTransceivers().find((({mid:e,sender:r,receiver:n})=>r.track&&r.track.kind===t.kind?(this.logger.debug("Found transceiver by sender"),!0):n.track&&n.track.kind===t.kind?(this.logger.debug("Found transceiver by receiver"),!0):null===e&&(this.logger.debug("Found disassociated transceiver"),!0)));r&&r.sender?(this.logger.debug("updateConstraints FOUND - replaceTrack on it and on localStream"),await r.sender.replaceTrack(t),this.logger.debug("updateConstraints replaceTrack SUCCESS"),this.options.localStream.getTracks().forEach((e=>{var r;e.kind===t.kind&&e.id!==t.id&&(this.logger.debug("updateConstraints stop old track and apply new one - "),xi(e),null===(r=this.options.localStream)||void 0===r||r.removeTrack(e))})),this.options.localStream.addTrack(t)):(this.logger.debug("updateConstraints NOT FOUND - addTrack and start dancing!"),this.peer.type="offer",this.doReinvite=!0,this.options.localStream.addTrack(t),n.addTrack(t,this.options.localStream)),this.logger.debug("updateConstraints Simply update mic/cam"),"audio"===t.kind?this.options.micId=t.getSettings().deviceId:"video"===t.kind&&(this.options.camId=t.getSettings().deviceId)}this.logger.debug("updateConstraints done!"),t()}catch(e){this.logger.error("updateConstraints",e),r(e)}}))}invite(){return new Promise((async(e,t)=>{this.direction="outbound",this.peer=new ts(this,"offer");try{await this.peer.start(),e(this)}catch(e){this.logger.error("Invite error",e),t(e)}}))}answer(){return new Promise((async(e,t)=>{this.direction="inbound",this.peer=new ts(this,"answer");try{await this.peer.start(),e(this)}catch(e){this.logger.error("Answer error",e),t(e)}}))}onLocalSDPReady(e){const{type:t,sdp:r}=e;switch(t){case"offer":return this.executeInvite(r);case"answer":this.logger.warn("Unhandled verto.answer");break;default:return this.logger.error(`Unknown SDP type: '${t}' on call ${this.id}`)}}async executeInvite(e){this.setState("requesting");try{const t=yn(Object.assign(Object.assign({},this.messagePayload),{sdp:e})),r=await this.vertoExecute(t);this.logger.debug("Invite response",r)}catch(e){throw this.setState("hangup"),e.jsonrpc}}async hangup(){try{const e=bn(this.messagePayload);await this.vertoExecute(e)}catch(e){this.logger.error("Hangup error:",e)}finally{this._hangup()}}dtmf(e){const t=_n(Object.assign(Object.assign({},this.messagePayload),{dtmf:e}));this.vertoExecute(t)}doReinviteWithRelayOnly(){this.peer&&this.active&&this.peer.restartIceWithRelayOnly()}stopOutboundAudio(){this.peer&&this.active&&this.peer.stopTrackSender("audio")}restoreOutboundAudio(){this.peer&&this.active&&this.peer.restoreTrackSender("audio")}stopOutboundVideo(){this.peer&&this.active&&this.peer.stopTrackSender("video")}restoreOutboundVideo(){this.peer&&this.active&&this.peer.restoreTrackSender("video")}setState(e){switch(this.prevState=this.state,this.state=e,this.logger.debug(`Call ${this.id} state change from ${this.prevState} to ${this.state}`),this.emit(this.state,this),e){case"purge":this._finalize();break;case"hangup":this.setState("destroy");break;case"destroy":this._finalize()}}_hangup(e={}){const{byeCause:t="NORMAL_CLEARING",byeCauseCode:r="16",redirectDestination:n}=e;return this.cause=t,this.causeCode=r,n&&this.peer.localSdp?(this.logger.debug("Redirect Destination to:",n),this.nodeId=n,this.executeInvite(this.peer.localSdp)):this.setState("hangup")}_finalize(){this.peer&&this.peer.instance&&(this.peer.instance.close(),delete this.peer);const{remoteStream:e,localStream:t}=this.options;Mi(e),Mi(t),this.destroy()}}const os=e=>`sw-sdk-${e}`,is=()=>{const e=document.createElement("video");return e.muted=!0,e.autoplay=!0,e.playsInline=!0,e},ss=({x:e,y:t,width:r,height:n})=>({top:`${t}%`,left:`${e}%`,width:`${r}%`,height:`${n}%`}),as=e=>t=>{const r=document.getElementById(os(t));r&&(r.style.display=e)},cs=Sn.createAction("swJs/audioSetSpeakerAction");function*us({element:e,room:t}){const r=Sn.getCustomSagaActionType(t.__uuid,cs);for(;;){const n=yield xt([r]);try{switch(n.type){case r:const o=yield Dt(Ri,e,n.payload);t.settleCustomSagaTrigger({dispatchId:n.dispatchId,payload:o,kind:"resolve"})}}catch(e){t.settleCustomSagaTrigger({dispatchId:n.dispatchId,payload:e,kind:"reject"}),Br().error(e)}}}function*ds({track:e,element:t,speakerId:r,room:n}){(({track:e,element:t})=>{t.autoplay=!0,t.playsinline=!0,t.srcObject=new MediaStream([e]),e.addEventListener("ended",(()=>{t.srcObject=null,t.remove()}))})({track:e,element:t}),r&&Ri(t,r).catch((()=>{})),yield Nt(us,{element:t,room:n})}function*ls({rootElement:e,applyLocalVideoOverlay:t=!0,track:r,element:n}){(r=>{if((({track:e,element:t})=>{t.srcObject=new MediaStream([e]),e.addEventListener("ended",(()=>{t.srcObject=null,t.remove()}))})({element:n,track:r}),n.style.width="100%",!t)return void e.appendChild(n);const o=document.createElement("div");o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.right="0",o.style.bottom="0",o.appendChild(n);const i=document.createElement("div");i.style.paddingBottom="56.25%",i.appendChild(o);const s=document.createElement("div");s.classList.add("mcuLayers"),i.appendChild(s);const a=document.createElement("div");a.style.position="relative",a.style.width="100%",a.style.margin="0 auto",a.appendChild(i),e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",e.appendChild(a)})(r)}const hs={state:"onStateChange",remoteSDP:"onRemoteSDP",roomId:"onRoomSubscribed",videoConstraints:"onVideoConstraints",audioConstraints:"onAudioConstraints",errors:"onError",responses:"onSuccess"},ps={echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,googAutoGainControl:!1},fs=en(class extends ns{join(){return super.invite()}leave(){return super.hangup()}},{audioMute:Ao.audioMuteMember,audioUnmute:Ao.audioUnmuteMember,videoMute:Ao.videoMuteMember,videoUnmute:Ao.videoUnmuteMember,setMicrophoneVolume:Ao.setInputVolumeMember,setInputVolume:Ao.setInputVolumeMember,setInputSensitivity:Ao.setInputSensitivityMember}),ms=en(class extends ns{join(){return super.invite()}leave(){return super.hangup()}},{audioMute:Ao.audioMuteMember,audioUnmute:Ao.audioUnmuteMember,videoMute:Ao.videoMuteMember,videoUnmute:Ao.videoUnmuteMember,setInputVolume:Ao.setInputVolumeMember,setMicrophoneVolume:Ao.setInputVolumeMember,setInputSensitivity:Ao.setInputSensitivityMember}),gs=en(class extends ns{_screenShareList=new Set;_deviceList=new Set;get screenShareList(){return Array.from(this._screenShareList)}get deviceList(){return Array.from(this._deviceList)}getEmitterTransforms(){return new Map([[[dn("video.recording.start"),"video.recording.started","video.recording.updated","video.recording.ended"],{type:"roomSessionRecording",instanceFactory:e=>Ao.createRoomSessionRecordingObject({store:this.store,emitter:this.emitter}),payloadTransform:e=>Qr({...e.recording,room_session_id:this.roomSessionId})}],[[dn("video.playback.start"),"video.playback.started","video.playback.updated","video.playback.ended"],{type:"roomSessionPlayback",instanceFactory:e=>Ao.createRoomSessionPlaybackObject({store:this.store,emitter:this.emitter}),payloadTransform:e=>Qr({...e.playback,room_session_id:this.roomSessionId})}]])}async createScreenShareObject(e={}){return this.startScreenShare(e)}async startScreenShare(e={}){const{autoJoin:t=!0,audio:r=!1,video:n=!0}=e,o=await Ci({audio:!0===r?ps:r,video:n}),i={...this.options,screenShare:!0,recoverCall:!1,localStream:o,remoteStream:void 0,userVariables:{...this.options?.userVariables||{},memberCallId:this.__uuid,memberId:this.memberId}},s=ko({store:this.store,Component:fs,componentListeners:hs})(i);o.getVideoTracks().forEach((e=>{e.addEventListener("ended",(()=>{s&&s.active&&s.leave()}))})),s.on("destroy",(()=>{this._screenShareList.delete(s)}));try{return this._screenShareList.add(s),t&&await s.join(),s}catch(e){throw this.logger.error("ScreenShare Error",e),e}}addCamera(e={}){const{autoJoin:t=!0,...r}=e;return this.addDevice({autoJoin:t,video:r})}addMicrophone(e={}){const{autoJoin:t=!0,...r}=e;return this.addDevice({autoJoin:t,audio:r})}async addDevice(e={}){const{autoJoin:t=!0,audio:r=!1,video:n=!1}=e;if(!r&&!n)throw new TypeError("At least one of `audio` or `video` must be requested.");const o={...this.options,localStream:void 0,remoteStream:void 0,audio:r,video:n,additionalDevice:!0,recoverCall:!1,userVariables:{...this.options?.userVariables||{},memberCallId:this.__uuid,memberId:this.memberId}},i=ko({store:this.store,Component:ms,componentListeners:hs})(o);i.on("destroy",(()=>{this._deviceList.delete(i)}));try{return this._deviceList.add(i),t&&await i.join(),i}catch(e){throw this.logger.error("RoomDevice Error",e),e}}join(){return super.invite()}leave(){return this.hangup()}updateSpeaker({deviceId:e}){return this.triggerCustomSaga(cs(e))}async hangup(){return this._screenShareList.forEach((e=>{e.leave()})),this._deviceList.forEach((e=>{e.leave()})),super.hangup()}_finalize(){this._screenShareList.clear(),this._deviceList.clear(),super._finalize()}getLayoutList(){return this.getLayouts()}getMemberList(){return this.getMembers()}},{audioMute:Ao.audioMuteMember,audioUnmute:Ao.audioUnmuteMember,videoMute:Ao.videoMuteMember,videoUnmute:Ao.videoUnmuteMember,deaf:Ao.deafMember,undeaf:Ao.undeafMember,setInputVolume:Ao.setInputVolumeMember,setOutputVolume:Ao.setOutputVolumeMember,setMicrophoneVolume:Ao.setInputVolumeMember,setSpeakerVolume:Ao.setOutputVolumeMember,setInputSensitivity:Ao.setInputSensitivityMember,removeMember:Ao.removeMember,getMembers:Ao.getMembers,getLayouts:Ao.getLayouts,setLayout:Ao.setLayout,hideVideoMuted:Ao.hideVideoMuted,showVideoMuted:Ao.showVideoMuted,getRecordings:Ao.getRecordings,startRecording:Ao.startRecording,getPlaybacks:Ao.getPlaybacks,play:Ao.play,setHideVideoMuted:Ao.setHideVideoMuted});class vs extends Oo{_eventsPrefix="cantina-manager";getEmitterTransforms(){return new Map([[["cantina-manager.rooms.subscribed"],{type:"roomSession",instanceFactory:({rooms:e})=>({rooms:e.map((e=>Qr(e)))}),payloadTransform:({rooms:e})=>({rooms:e.map((e=>Qr(e)))})}],[["cantina-manager.room.started","cantina-manager.room.added","cantina-manager.room.updated","cantina-manager.room.ended","cantina-manager.room.deleted"],{type:"roomSession",instanceFactory:e=>Qr(e),payloadTransform:e=>Qr(e)}]])}}class ys extends To{_cantina;_chat;get rooms(){return{makeRoomObject:e=>{const{rootElement:t,applyLocalVideoOverlay:r=!0,stopCameraWhileMuted:n=!0,stopMicrophoneWhileMuted:o=!0,...i}=e,s=[];s.push((({speakerId:e})=>function*({instance:t,runSaga:r}){try{const n=new Audio;let o;const i=function(s){switch(s.track.kind){case"audio":o=r(ds,{track:s.track,element:n,speakerId:e,room:t}),t.off("track",i)}};t.on("track",i),t.once("destroy",(()=>{o?.cancel()}))}catch(e){Br().error("audioElementSaga",e)}})({speakerId:i.speakerId})),t&&s.push((({rootElement:e,applyLocalVideoOverlay:t})=>function*({instance:r,runSaga:n}){try{const o=new Map,i=is(),s=(({layerMap:e,element:t,rootElement:r})=>async({layout:n,myMemberId:o,localStream:i})=>{try{const{layers:s=[]}=n,a=s.find((({member_id:e})=>e===o)),c=os(o);let u=e.get(c);if(!a)return void(u&&(Br().debug("Current layer not visible"),u.style.display="none"));if(!u){u=await(async({location:e,element:t})=>{t.readyState===HTMLMediaElement.HAVE_NOTHING&&await(({element:e})=>new Promise((t=>{e.addEventListener("canplay",(function r(){e.removeEventListener("canplay",r),t()})),e.addEventListener("resize",(function r(){e.removeEventListener("resize",r),t()}))})))({element:t});const{top:r,left:n,width:o,height:i}=ss(e),s=document.createElement("div");return s.style.position="absolute",s.style.overflow="hidden",s.style.top=r,s.style.left=n,s.style.width=o,s.style.height=i,s})({element:t,location:a}),u.id=c;const n=is();n.srcObject=i,n.style.width="100%",n.style.height="100%",u.appendChild(n);const o=r.querySelector(".mcuLayers"),s=document.getElementById(c);return void(o&&!s&&(o.appendChild(u),e.set(c,u)))}const{top:d,left:l,width:h,height:p}=ss(a);u.style.display="block",u.style.top=d,u.style.left=l,u.style.width=h,u.style.height=p}catch(e){Br().error("Layout Changed Error",e)}})({rootElement:e,element:i,layerMap:o}),a=as("none"),c=as("block");let u;r.on("layout.changed",(e=>{r.peer.hasVideoSender&&r.localStream&&s({layout:e.layout,localStream:r.localStream,myMemberId:r.memberId})})),r.on("member.updated.video_muted",(e=>{try{const{member:t}=e;t.id===r.memberId&&"video_muted"in t&&(t.video_muted?a(t.id):c(t.id))}catch(e){Br().error("Error handling video_muted",e)}}));const d=function(o){switch(o.track.kind){case"video":u=n(ls,{applyLocalVideoOverlay:t,rootElement:e,track:o.track,element:i}),r.off("track",d)}};r.on("track",d),r.once("destroy",(()=>{(e=>{for(;e.firstChild;)e.removeChild(e.firstChild)})(e),o.clear(),u?.cancel()}))}catch(e){Br().error("videoElementSaga",e)}})({rootElement:t,applyLocalVideoOverlay:r}));const a=(c={...i,store:this.store,emitter:this.emitter,customSagas:s},ko({store:c.store,customSagas:c.customSagas,Component:gs,componentListeners:hs})(c));var c;return o&&a.on("member.updated.audio_muted",(({member:e})=>{try{e.id===a.memberId&&"audio_muted"in e&&(e.audio_muted?a.stopOutboundAudio():a.restoreOutboundAudio())}catch(e){this.logger.error("Error handling audio_muted",e)}})),n&&a.on("member.updated.video_muted",(({member:e})=>{try{e.id===a.memberId&&"video_muted"in e&&(e.video_muted?a.stopOutboundVideo():a.restoreOutboundVideo())}catch(e){this.logger.error("Error handling video_muted",e)}})),a}}}get chat(){return this._chat||(this._chat=ii.createBaseChatObject({store:this.store,emitter:this.options.emitter})),this._chat}get cantina(){return this._cantina||(this._cantina=(e=>{const t=ko({store:e.store,Component:vs,componentListeners:{errors:"onError",responses:"onSuccess"}})(e);return new Proxy(t,{get:(e,t,r)=>"_eventsNamespace"===t?"":"eventChannel"===t?"cantina-manager.rooms":Reflect.get(e,t,r)})})(this.options)),this._cantina}reauthenticate(e){this.store.dispatch(Sn.reauthAction({token:e}))}}class bs extends class extends class{constructor(e){var t,r;this.options=e,jr(this,"uuid",l()),jr(this,"WebSocketConstructor"),jr(this,"agent"),jr(this,"connectVersion",pn),jr(this,"_rpcConnectResult"),jr(this,"_requests",new Map),jr(this,"_socket",null),jr(this,"_host","wss://relay.signalwire.com"),jr(this,"_executeTimeoutMs",1e4),jr(this,"_executeTimeoutError",Symbol.for("sw-execute-timeout")),jr(this,"_checkPingDelay",15e3),jr(this,"_checkPingTimer",null),jr(this,"_status","unknown");const{host:n,logLevel:o="info"}=e;n&&(this._host=(e=>`${sn.test(e)?"":"wss://"}${e}`)(n)),o&&(null==(r=(t=this.logger).setLevel)||r.call(t,o)),this._onSocketOpen=this._onSocketOpen.bind(this),this._onSocketError=this._onSocketError.bind(this),this._onSocketClose=this._onSocketClose.bind(this),this._onSocketMessage=this._onSocketMessage.bind(this),this.execute=this.execute.bind(this),this.connect=this.connect.bind(this)}get host(){return this._host}get rpcConnectResult(){return this._rpcConnectResult}get relayProtocol(){var e,t;return null!=(t=null==(e=this._rpcConnectResult)?void 0:e.protocol)?t:""}get signature(){var e,t;return null==(t=null==(e=this._rpcConnectResult)?void 0:e.authorization)?void 0:t.signature}get logger(){return Br()}get connecting(){var e;return 0===(null==(e=this._socket)?void 0:e.readyState)}get connected(){var e;return 1===(null==(e=this._socket)?void 0:e.readyState)}get closing(){var e;return 2===(null==(e=this._socket)?void 0:e.readyState)}get closed(){return!this._socket||3===this._socket.readyState}get status(){return this._status}set token(e){this.options.token=e}connect(){(null==this?void 0:this.WebSocketConstructor)?this._socket?this.logger.warn("Session already connected."):(this._socket=this._createSocket(),this._socket.addEventListener("open",this._onSocketOpen),this._socket.addEventListener("close",this._onSocketClose),this._socket.addEventListener("error",this._onSocketError),this._socket.addEventListener("message",this._onSocketMessage)):this.logger.error("Missing WebSocketConstructor")}_createSocket(){return new this.WebSocketConstructor(this._host)}async disconnect(){this._socket&&!this.closing?(clearTimeout(this._checkPingTimer),this._requests.clear(),this._closeConnection("disconnected")):this.logger.warn("Session not connected or already in closing state.")}execute(e){if("idle"===this._status||!this.connected)return Promise.reject("Can't call `execute` when Session is not authorized.");let t;return t="params"in e?new Promise(((t,r)=>{this._requests.set(e.id,{rpcRequest:e,resolve:t,reject:r})})):Promise.resolve(),this.logger.wsTraffic({type:"send",payload:e}),this._socket.send(JSON.stringify(e)),((e,t,r)=>{let n=null;return Promise.race([e,new Promise(((e,o)=>n=setTimeout(o,t,r)))]).finally((()=>clearTimeout(n)))})(t,this._executeTimeoutMs,this._executeTimeoutError).catch((t=>{if(t!==this._executeTimeoutError)throw t;this.logger.error("Request Timeout",e),this._closeConnection("reconnecting")}))}async authenticate(){const e={agent:this.agent,version:this.connectVersion,authentication:{project:this.options.project,token:this.options.token}};this._relayProtocolIsValid()&&(e.protocol=this.relayProtocol),this._rpcConnectResult=await this.execute(fn(e))}async _onSocketOpen(e){this.logger.debug("_onSocketOpen",e.type);try{await this.authenticate(),this._status="connected",this.dispatch(Pn())}catch(e){this.logger.error("Auth Error",e),this.dispatch(In({error:e}))}}_onSocketError(e){this.logger.debug("_onSocketError",e),this.dispatch(Rn())}_onSocketClose(e){this.logger.debug("_onSocketClose",e.type,e.code,e.reason),this._status=e.code>=1006&&e.code<=1014?"reconnecting":"disconnected",this.dispatch(An()),this._socket=null}_onSocketMessage(e){const t=on(e.data);this.logger.wsTraffic({type:"recv",payload:t});const r=this._requests.get(t.id);if(r){const{rpcRequest:e,resolve:n,reject:o}=r;this._requests.delete(t.id);const{result:i,error:s}=(({response:e,request:t})=>{const{result:r={},error:n}=e;if(n)return{error:n};switch(t.method){case"signalwire.connect":return{result:r};default:return Hr(e)}})({response:t,request:e});return s?o(s):n(i)}switch(t.method){case"signalwire.ping":case"blade.ping":return this._pingHandler(t);case"signalwire.disconnect":this.execute((n=t.id,hn({id:n,result:{}}))).catch((e=>{this.logger.error("SwDisconnect Error",e)})).finally((()=>{this._status="idle"}));break;default:this.dispatch(Mn(t)),this._handleWebSocketMessage(t)}var n}_handleWebSocketMessage(e){}dispatch(e){throw new Error("Method not implemented")}_relayProtocolIsValid(){var e;return this.signature&&(null==(e=null==this?void 0:this.relayProtocol)?void 0:e.split("_")[1])===this.signature}async _pingHandler(e){var t,r,n;clearTimeout(this._checkPingTimer),this._checkPingTimer=setTimeout((()=>{this._closeConnection("reconnecting")}),this._checkPingDelay),await this.execute((r=e.id,n=null==(t=null==e?void 0:e.params)?void 0:t.timestamp,hn({id:r,result:{timestamp:n||Date.now()/1e3}})))}_closeConnection(e){this._status=e,this.dispatch(Un.authStatus("unknown")),this.dispatch(Cn()),this._socket&&(this._socket.close(),this._socket=null)}}{constructor(e){super(e),this.options=e,jr(this,"_expiredDiffSeconds",0),jr(this,"_refreshTokenNotificationDiff",120),jr(this,"_checkTokenExpirationDelay",2e4),jr(this,"_checkTokenExpirationTimer",null),this._checkTokenExpiration=this._checkTokenExpiration.bind(this),this.reauthenticate=this.reauthenticate.bind(this)}get expiresAt(){var e,t,r;return null!=(r=null==(t=null==(e=null==this?void 0:this._rpcConnectResult)?void 0:e.authorization)?void 0:t.expires_at)?r:0}get expiresIn(){const e=Math.floor(Date.now()/1e3);return this.expiresAt-e}get expired(){return this.expiresIn<=this._expiredDiffSeconds}async authenticate(){const e={agent:this.agent,version:this.connectVersion,authentication:{jwt_token:this.options.token}};if(this._relayProtocolIsValid())e.protocol=this.relayProtocol;else if(this.signature){const r=await(t=this.signature,(async(e,t)=>{if("undefined"==typeof window&&"undefined"!=typeof process)return null;const r=window.sessionStorage.getItem((e=>`@signalwire:${e}`)(t));return on(r)})(0,t));r&&(e.protocol=r)}var t;this._rpcConnectResult=await this.execute(fn(e)),this._checkTokenExpiration()}async reauthenticate(){if(this.expired)return this.connect();const e={project:this._rpcConnectResult.authorization.project,jwt_token:this.options.token};try{this._rpcConnectResult=await this.execute((t=e,ln({method:"signalwire.reauthenticate",params:{authentication:t}})))}catch(e){throw clearTimeout(this._checkTokenExpirationTimer),e}var t}_checkTokenExpiration(){this.expiresAt&&(this.expiresIn<=this._refreshTokenNotificationDiff&&(this.options._onRefreshToken?this.options._onRefreshToken():this.logger.warn("The token is going to expire!")),clearTimeout(this._checkTokenExpirationTimer),this.expired||(this._checkTokenExpirationTimer=setTimeout(this._checkTokenExpiration,this._checkTokenExpirationDelay)))}}{WebSocketConstructor=WebSocket;agent="@signalwire/js/3.7.0"}const _s=e=>{const t={...e,emitter:new Sr},r=(e=>{var t;const{userOptions:r,SessionConstructor:n,preloadedState:o={},runSagaMiddleware:i=!0}=e,s=_r(),a={pubSubChannel:rr()},c=Le({devTools:null==(t=null==r?void 0:r.devTools)||t,reducer:Gn,preloadedState:o,middleware:e=>e().concat(s)});if(i){const e=(e=>function*({userOptions:t,channels:r}){t.logger&&($r=t.logger),t.debug&&(e=>{null!=e?Object.assign(Fr,e):Fr={}})(t.debug),yield Nt(po),yield xt(kn.type);try{yield Dt(yo,Rr(Ar({},e),{userOptions:t,channels:r}))}catch(e){return void Br().error("RootSaga Error:",e)}})({SessionConstructor:n});s.run(e,{userOptions:r,channels:a})}return Rr(Ar({},c),{runSaga:(e,t)=>s.run(e,Rr(Ar({},t),{channels:a}))})})({userOptions:t,SessionConstructor:bs});return ko({store:r,Component:ys,componentListeners:{errors:"onError",responses:"onSuccess"}})(t)},ws={aspectRatio:{ideal:16/9}},Ss=e=>new Promise((async(t,r)=>{const{audio:n=!0,video:o=!0,iceServers:i,rootElementId:s,applyLocalVideoOverlay:a=!0,autoJoin:c=!1,stopCameraWhileMuted:u=!0,stopMicrophoneWhileMuted:d=!0,speakerId:l,...h}=e,p=_s({...h});if(await p.connect(),!p)return;let f;if(s){const e=document.getElementById(s);e?f=e:(f=document.body,Br().warn(`We couldn't find an element with id: ${s}: using 'document.body' instead.`))}const m=p.rooms.makeRoomObject({audio:n,video:!0===o?ws:o,negotiateAudio:!0,negotiateVideo:!0,iceServers:i,rootElement:f,applyLocalVideoOverlay:a,stopCameraWhileMuted:u,stopMicrophoneWhileMuted:d,speakerId:l});if(m.once("destroy",(()=>{p.disconnect()})),c)try{await m.join(),t(m)}catch(e){r(e)}else t(m)})),ks={aspectRatio:{ideal:16/9}},Es=["audioMute","audioUnmute","deaf","getLayouts","getMembers","getRecordings","hideVideoMuted","leave","removerMember","restoreOutboundAudio","restoreOutboundVideo","setInputSensitivity","setInputVolume","setLayout","setOutputVolume","showVideoMuted","startRecording","stopOutboundAudio","stopOutboundVideo","undeaf","videoMute","videoUnmute","setMicrophoneVolume","setSpeakerVolume"];var Cs=Object.freeze({__proto__:null,RoomSession:function(e){const{audio:t=!0,video:r=!0,iceServers:n,rootElement:o,applyLocalVideoOverlay:i=!0,stopCameraWhileMuted:s=!0,stopMicrophoneWhileMuted:a=!0,speakerId:c,...u}=e,d=_s(u),l=d.rooms.makeRoomObject({audio:t,video:!0===r?ks:r,negotiateAudio:!0,negotiateVideo:!0,iceServers:n,rootElement:o,applyLocalVideoOverlay:i,stopCameraWhileMuted:s,stopMicrophoneWhileMuted:a,speakerId:c});l.once("destroy",(()=>{d.disconnect()}));const h=()=>new Promise((async(e,t)=>{try{await d.connect(),l.once("room.subscribed",(()=>{e(l)})),await l.join()}catch(e){Br().error("RoomSession Join",e),t(e)}}));return new Proxy(l,{get(e,t,r){if("join"===t)return h;if(!e.active&&Es.includes(t))throw new Error(`Tried to access the property/method "${t}" before the room was connected. Please call roomSession.join() first.`);return Reflect.get(e,t,r)}})},createRoomObject:Ss,joinRoom:e=>Ss({...e,autoJoin:!0}),createClient:_s}),Ts=Object.freeze({__proto__:null,getDevices:Fi,getCameraDevices:()=>Fi("camera"),getMicrophoneDevices:()=>Fi("microphone"),getSpeakerDevices:()=>Fi("speaker"),getDevicesWithPermissions:$i,getCameraDevicesWithPermissions:()=>$i("camera"),getMicrophoneDevicesWithPermissions:()=>$i("microphone"),getSpeakerDevicesWithPermissions:()=>$i("speaker"),checkPermissions:Di,checkCameraPermissions:Ni,checkMicrophonePermissions:Vi,checkSpeakerPermissions:Wi,requestPermissions:async e=>{try{const t=await Ei(e);Mi(t)}catch(e){throw e}},createDeviceWatcher:Ji,createCameraDeviceWatcher:()=>Ji({targets:["camera"]}),createMicrophoneDeviceWatcher:()=>Ji({targets:["microphone"]}),createSpeakerDeviceWatcher:()=>Ji({targets:["speaker"]}),supportsMediaDevices:Si,supportsGetUserMedia:()=>{var e;return"function"==typeof(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia)},supportsGetDisplayMedia:()=>{var e;return"function"==typeof(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getDisplayMedia)},getUserMedia:Ei,getDisplayMedia:Ci,enumerateDevices:Ti,getSupportedConstraints:Ii,supportsMediaOutput:Ai,setMediaElementSinkId:Ri,stopStream:Mi,stopTrack:xi}),Os=Object.freeze({__proto__:null,Client:function(e){Br().warn("`Chat` is still under development and may change in the future without prior notice.");const t=_s(e),r=async e=>(await t.connect(),t.chat.subscribe(e)),n=async e=>(await t.connect(),t.chat.publish(e));return new Proxy(t.chat,{get:(e,t,o)=>"subscribe"===t?r:"publish"===t?n:Reflect.get(e,t,o)})}});e.Video=Cs,e.WebRTC=Ts,e.__sw__Chat=Os,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SignalWire={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(e){var r,n;r=t,n=function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function o(e,t){var r=e[t];if("function"==typeof r.bind)return r.bind(e);try{return Function.prototype.bind.call(r,e)}catch(t){return function(){return Function.prototype.apply.apply(r,[e,arguments])}}}function i(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(n){return"debug"===n&&(n="log"),typeof console!==t&&("trace"===n&&r?i:void 0!==console[n]?o(console,n):void 0!==console.log?o(console,"log"):e)}function a(t,r){for(var o=0;o<n.length;o++){var i=n[o];this[i]=o<t?e:this.methodFactory(i,t,r)}this.log=this.debug}function c(e,r,n){return function(){typeof console!==t&&(a.call(this,r,n),this[e].apply(this,arguments))}}function u(e,t,r){return s(e)||c.apply(this,arguments)}function d(e,r,o){var i,s=this;r=null==r?"WARN":r;var c="loglevel";function d(){var e;if(typeof window!==t&&c){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var r=window.document.cookie,n=r.indexOf(encodeURIComponent(c)+"=");-1!==n&&(e=/^([^;]+)/.exec(r.slice(n))[1])}catch(e){}return void 0===s.levels[e]&&(e=void 0),e}}"string"==typeof e?c+=":"+e:"symbol"==typeof e&&(c=void 0),s.name=e,s.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},s.methodFactory=o||u,s.getLevel=function(){return i},s.setLevel=function(r,o){if("string"==typeof r&&void 0!==s.levels[r.toUpperCase()]&&(r=s.levels[r.toUpperCase()]),!("number"==typeof r&&r>=0&&r<=s.levels.SILENT))throw"log.setLevel() called with invalid level: "+r;if(i=r,!1!==o&&function(e){var r=(n[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=r)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+r+";"}catch(e){}}}(r),a.call(s,r,e),typeof console===t&&r<s.levels.SILENT)return"No console available for logging"},s.setDefaultLevel=function(e){r=e,d()||s.setLevel(e,!1)},s.resetLevel=function(){s.setLevel(r,!1),function(){if(typeof window!==t&&c){try{return void window.localStorage.removeItem(c)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},s.enableAll=function(e){s.setLevel(s.levels.TRACE,e)},s.disableAll=function(e){s.setLevel(s.levels.SILENT,e)};var l=d();null==l&&(l=r),s.setLevel(l,!1)}var l=new d,h={};l.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=h[e];return t||(t=h[e]=new d(e,l.getLevel(),l.methodFactory)),t};var p=typeof window!==t?window.log:void 0;return l.noConflict=function(){return typeof window!==t&&window.log===l&&(window.log=p),l},l.getLoggers=function(){return h},l.default=l,l},e.exports?e.exports=n():r.log=n()}(r);var n,o=r.exports,i=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(i)}var a=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function c(e){return"string"==typeof e&&a.test(e)}for(var u=[],d=0;d<256;++d)u.push((d+256).toString(16).substr(1));function l(e,t,r){var n=(e=e||{}).random||(e.rng||s)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var o=0;o<16;++o)t[r+o]=n[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[e[t+0]]+u[e[t+1]]+u[e[t+2]]+u[e[t+3]]+"-"+u[e[t+4]]+u[e[t+5]]+"-"+u[e[t+6]]+u[e[t+7]]+"-"+u[e[t+8]]+u[e[t+9]]+"-"+u[e[t+10]]+u[e[t+11]]+u[e[t+12]]+u[e[t+13]]+u[e[t+14]]+u[e[t+15]]).toLowerCase();if(!c(r))throw TypeError("Stringified UUID is invalid");return r}(n)}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){h(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var g="function"==typeof Symbol&&Symbol.observable||"@@observable",v=function(){return Math.random().toString(36).substring(7).split("").join(".")},y={INIT:"@@redux/INIT"+v(),REPLACE:"@@redux/REPLACE"+v(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+v()}};function b(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function _(e,t,r){var n;if("function"==typeof t&&"function"==typeof r||"function"==typeof r&&"function"==typeof arguments[3])throw new Error(f(0));if("function"==typeof t&&void 0===r&&(r=t,t=void 0),void 0!==r){if("function"!=typeof r)throw new Error(f(1));return r(_)(e,t)}if("function"!=typeof e)throw new Error(f(2));var o=e,i=t,s=[],a=s,c=!1;function u(){a===s&&(a=s.slice())}function d(){if(c)throw new Error(f(3));return i}function l(e){if("function"!=typeof e)throw new Error(f(4));if(c)throw new Error(f(5));var t=!0;return u(),a.push(e),function(){if(t){if(c)throw new Error(f(6));t=!1,u();var r=a.indexOf(e);a.splice(r,1),s=null}}}function h(e){if(!b(e))throw new Error(f(7));if(void 0===e.type)throw new Error(f(8));if(c)throw new Error(f(9));try{c=!0,i=o(i,e)}finally{c=!1}for(var t=s=a,r=0;r<t.length;r++)(0,t[r])();return e}function p(e){if("function"!=typeof e)throw new Error(f(10));o=e,h({type:y.REPLACE})}function m(){var e,t=l;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(f(11));function r(){e.next&&e.next(d())}return r(),{unsubscribe:t(r)}}})[g]=function(){return this},e}return h({type:y.INIT}),(n={dispatch:h,subscribe:l,getState:d,replaceReducer:p})[g]=m,n}function S(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++){var o=t[n];"function"==typeof e[o]&&(r[o]=e[o])}var i,s=Object.keys(r);try{!function(e){Object.keys(e).forEach((function(t){var r=e[t];if(void 0===r(void 0,{type:y.INIT}))throw new Error(f(12));if(void 0===r(void 0,{type:y.PROBE_UNKNOWN_ACTION()}))throw new Error(f(13))}))}(r)}catch(e){i=e}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var n=!1,o={},a=0;a<s.length;a++){var c=s[a],u=e[c],d=(0,r[c])(u,t);if(void 0===d)throw new Error(f(14));o[c]=d,n=n||d!==u}return(n=n||s.length!==Object.keys(e).length)?o:e}}function w(e,t){return function(){return t(e.apply(this,arguments))}}function k(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function E(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw new Error(f(15))},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return n=k.apply(void 0,i)(r.dispatch),m(m({},r),{},{dispatch:n})}}}var C=Object.freeze({__proto__:null,__DO_NOT_USE__ActionTypes:y,applyMiddleware:E,bindActionCreators:function(e,t){if("function"==typeof e)return w(e,t);if("object"!=typeof e||null===e)throw new Error(f(16));var r={};for(var n in e){var o=e[n];"function"==typeof o&&(r[n]=w(o,t))}return r},combineReducers:S,compose:k,createStore:_}),T=function(e){return"@@redux-saga/"+e},I=T("CANCEL_PROMISE"),O=T("CHANNEL_END"),M=T("IO"),R=T("MATCH"),P=T("MULTICAST"),A=T("SAGA_ACTION"),x=T("SELF_CANCELLATION"),L=T("TASK"),j=T("TASK_CANCEL"),D=T("TERMINATE"),N=T("LOCATION");function V(){return(V=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)}var W=function(e){return null==e},$=function(e){return null!=e},U=function(e){return"function"==typeof e},q=function(e){return"string"==typeof e},B=Array.isArray,z=function(e){return e&&U(e.then)},F=function(e){return e&&U(e.next)&&U(e.throw)},H=function e(t){return t&&(q(t)||K(t)||U(t)||B(t)&&t.every(e))},Q=function(e){return e&&U(e.take)&&U(e.close)},K=function(e){return Boolean(e)&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype};function J(e,t){var r;void 0===t&&(t=!0);var n=new Promise((function(n){r=setTimeout(n,e,t)}));return n[I]=function(){clearTimeout(r)},n}var G=function(e){return function(){return!0}}(),X=function(){},Y=function(e){return e},Z=function(e,t){V(e,t),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach((function(r){e[r]=t[r]}))};function ee(e,t){var r=e.indexOf(t);r>=0&&e.splice(r,1)}function te(e){var t=!1;return function(){t||(t=!0,e())}}var re=function(e){throw e},ne=function(e){return{value:e,done:!0}};function oe(e,t,r){void 0===t&&(t=re),void 0===r&&(r="iterator");var n={meta:{name:r},next:e,throw:t,return:ne,isSagaIterator:!0};return"undefined"!=typeof Symbol&&(n[Symbol.iterator]=function(){return n}),n}function ie(e,t){var r=t.sagaStack;console.error(e),console.error(r)}var se=function(e){return Array.apply(null,new Array(e))},ae=function(e){return function(t){return e(Object.defineProperty(t,A,{value:!0}))}},ce=function(e){return e===D},ue=function(e){return e===j},de=function(e){return ce(e)||ue(e)};function le(e,t){var r,n=Object.keys(e),o=n.length,i=0,s=B(e)?se(o):{},a={};return n.forEach((function(e){var n=function(n,a){r||(a||de(n)?(t.cancel(),t(n,a)):(s[e]=n,++i===o&&(r=!0,t(s))))};n.cancel=X,a[e]=n})),t.cancel=function(){r||(r=!0,n.forEach((function(e){return a[e].cancel()})))},a}function he(e){return{name:e.name||"anonymous",location:pe(e)}}function pe(e){return e[N]}var me={isEmpty:G,put:X,take:X},fe="TAKE",ge="CALL",ve="FORK",ye="SELECT",be=function(e,t){var r;return(r={})[M]=!0,r.combinator=!1,r.type=e,r.payload=t,r},_e=function(e){return be(ve,V({},e.payload,{detached:!0}))};function Se(e,t){return void 0===e&&(e="*"),H(e)?be(fe,{pattern:e}):Q(r=e)&&r[P]&&$(t)&&H(t)?be(fe,{channel:e,pattern:t}):Q(e)?be(fe,{channel:e}):void 0;var r}function we(e,t){return W(t)&&(t=e,e=void 0),be("PUT",{channel:e,action:t})}function ke(e,t){var r,n=null;return U(e)?r=e:(B(e)?(n=e[0],r=e[1]):(n=e.context,r=e.fn),n&&q(r)&&U(n[r])&&(r=n[r])),{context:n,fn:r,args:t}}function Ee(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return be(ge,ke(e,r))}function Ce(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return be(ve,ke(e,r))}function Te(e){void 0===e&&(e=Y);for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return be(ye,{selector:e,args:r})}var Ie=Ee.bind(null,J),Oe=[],Me=0;function Re(e){try{xe(),e()}finally{Le()}}function Pe(e){Oe.push(e),Me||(xe(),je())}function Ae(e){try{return xe(),e()}finally{je()}}function xe(){Me++}function Le(){Me--}function je(){var e;for(Le();!Me&&void 0!==(e=Oe.shift());)Re(e)}var De=function(e){return function(t){return e.some((function(e){return Ue(e)(t)}))}},Ne=function(e){return function(t){return e(t)}},Ve=function(e){return function(t){return t.type===String(e)}},We=function(e){return function(t){return t.type===e}},$e=function(){return G};function Ue(e){var t,r="*"===e?$e:q(e)?Ve:B(e)?De:U(t=e)&&t.hasOwnProperty("toString")?Ve:U(e)?Ne:K(e)?We:null;if(null===r)throw new Error("invalid pattern: "+e);return r(e)}var qe={type:O},Be=function(e){return e&&e.type===O};function ze(e){void 0===e&&(e=function(e,t){void 0===e&&(e=10);var r=new Array(e),n=0,o=0,i=0,s=function(){if(0!=n){var t=r[i];return r[i]=null,n--,i=(i+1)%e,t}},a=function(){for(var e=[];n;)e.push(s());return e};return{isEmpty:function(){return 0==n},put:function(t){var s;n<e||(s=2*e,r=a(),n=r.length,o=r.length,i=0,r.length=s,e=s),function(t){r[o]=t,o=(o+1)%e,n++}(t)},take:s,flush:a}}(void 0));var t=!1,r=[];return{take:function(n){t&&e.isEmpty()?n(qe):e.isEmpty()?(r.push(n),n.cancel=function(){ee(r,n)}):n(e.take())},put:function(n){if(!t){if(0===r.length)return e.put(n);r.shift()(n)}},flush:function(r){t&&e.isEmpty()?r(qe):r(e.flush())},close:function(){if(!t){t=!0;var e=r;r=[];for(var n=0,o=e.length;n<o;n++)(0,e[n])(qe)}}}}function Fe(){var e,t=!1,r=[],n=r,o=function(){n===r&&(n=r.slice())},i=function(){t=!0;var e=r=n;n=[],e.forEach((function(e){e(qe)}))};return(e={})[P]=!0,e.put=function(e){if(!t)if(Be(e))i();else for(var o=r=n,s=0,a=o.length;s<a;s++){var c=o[s];c[R](e)&&(c.cancel(),c(e))}},e.take=function(e,r){void 0===r&&(r=$e),t?e(qe):(e[R]=r,o(),n.push(e),e.cancel=te((function(){o(),ee(n,e)})))},e.close=i,e}function He(){var e=Fe(),t=e.put;return e.put=function(e){e[A]?t(e):Pe((function(){t(e)}))},e}function Qe(e,t){var r=e[I];U(r)&&(t.cancel=r),e.then(t,(function(e){t(e,!0)}))}var Ke,Je=0,Ge=function(){return++Je};function Xe(e){e.isRunning()&&e.cancel()}var Ye=((Ke={}).TAKE=function(e,t,r){var n=t.channel,o=void 0===n?e.channel:n,i=t.pattern,s=t.maybe,a=function(e){e instanceof Error?r(e,!0):!Be(e)||s?r(e):r(D)};try{o.take(a,$(i)?Ue(i):null)}catch(e){return void r(e,!0)}r.cancel=a.cancel},Ke.PUT=function(e,t,r){var n=t.channel,o=t.action,i=t.resolve;Pe((function(){var t;try{t=(n?n.put:e.dispatch)(o)}catch(e){return void r(e,!0)}i&&z(t)?Qe(t,r):r(t)}))},Ke.ALL=function(e,t,r,n){var o=n.digestEffect,i=Je,s=Object.keys(t);if(0!==s.length){var a=le(t,r);s.forEach((function(e){o(t[e],i,a[e],e)}))}else r(B(t)?[]:{})},Ke.RACE=function(e,t,r,n){var o=n.digestEffect,i=Je,s=Object.keys(t),a=B(t)?se(s.length):{},c={},u=!1;s.forEach((function(e){var t=function(t,n){u||(n||de(t)?(r.cancel(),r(t,n)):(r.cancel(),u=!0,a[e]=t,r(a)))};t.cancel=X,c[e]=t})),r.cancel=function(){u||(u=!0,s.forEach((function(e){return c[e].cancel()})))},s.forEach((function(e){u||o(t[e],i,c[e],e)}))},Ke.CALL=function(e,t,r,n){var o=t.context,i=t.fn,s=t.args,a=n.task;try{var c=i.apply(o,s);if(z(c))return void Qe(c,r);if(F(c))return void at(e,c,a.context,Je,he(i),!1,r);r(c)}catch(e){r(e,!0)}},Ke.CPS=function(e,t,r){var n=t.context,o=t.fn,i=t.args;try{var s=function(e,t){W(e)?r(t):r(e,!0)};o.apply(n,i.concat(s)),s.cancel&&(r.cancel=s.cancel)}catch(e){r(e,!0)}},Ke.FORK=function(e,t,r,n){var o=t.fn,i=t.detached,s=n.task,a=function(e){var t=e.context,r=e.fn,n=e.args;try{var o=r.apply(t,n);if(F(o))return o;var i=!1;return oe((function(e){return i?{value:e,done:!0}:(i=!0,{value:o,done:!z(o)})}))}catch(e){return oe((function(){throw e}))}}({context:t.context,fn:o,args:t.args}),c=function(e,t){return e.isSagaIterator?{name:e.meta.name}:he(t)}(a,o);Ae((function(){var t=at(e,a,s.context,Je,c,i,void 0);i?r(t):t.isRunning()?(s.queue.addTask(t),r(t)):t.isAborted()?s.queue.abort(t.error()):r(t)}))},Ke.JOIN=function(e,t,r,n){var o=n.task,i=function(e,t){if(e.isRunning()){var r={task:o,cb:t};t.cancel=function(){e.isRunning()&&ee(e.joiners,r)},e.joiners.push(r)}else e.isAborted()?t(e.error(),!0):t(e.result())};if(B(t)){if(0===t.length)return void r([]);var s=le(t,r);t.forEach((function(e,t){i(e,s[t])}))}else i(t,r)},Ke.CANCEL=function(e,t,r,n){t===x?Xe(n.task):B(t)?t.forEach(Xe):Xe(t),r()},Ke.SELECT=function(e,t,r){var n=t.selector,o=t.args;try{r(n.apply(void 0,[e.getState()].concat(o)))}catch(e){r(e,!0)}},Ke.ACTION_CHANNEL=function(e,t,r){var n=t.pattern,o=ze(t.buffer),i=Ue(n),s=function t(r){Be(r)||e.channel.take(t,i),o.put(r)},a=o.close;o.close=function(){s.cancel(),a()},e.channel.take(s,i),r(o)},Ke.CANCELLED=function(e,t,r,n){r(n.task.isCancelled())},Ke.FLUSH=function(e,t,r){t.flush(r)},Ke.GET_CONTEXT=function(e,t,r,n){r(n.task.context[t])},Ke.SET_CONTEXT=function(e,t,r,n){Z(n.task.context,t),r()},Ke);function Ze(e,t){return e+"?"+t}function et(e){var t=e.name,r=e.location;return r?t+" "+Ze(r.fileName,r.lineNumber):t}function tt(e){var t,r=(t=[]).concat.apply(t,e.map((function(e){return e.cancelledTasks})));return r.length?["Tasks cancelled due to error:"].concat(r).join("\n"):""}var rt=null,nt=[],ot=function(e){e.crashedEffect=rt,nt.push(e)},it=function(){rt=null,nt.length=0},st=function(){var e,t=nt[0],r=nt.slice(1),n=t.crashedEffect?(e=pe(t.crashedEffect))?e.code+" "+Ze(e.fileName,e.lineNumber):"":null;return["The above error occurred in task "+et(t.meta)+(n?" \n when executing effect "+n:"")].concat(r.map((function(e){return" created by "+et(e.meta)})),[tt(nt)]).join("\n")};function at(e,t,r,n,o,i,s){var a=e.finalizeRunEffect((function(t,r,n){z(t)?Qe(t,n):F(t)?at(e,t,u.context,r,o,!1,n):t&&t[M]?(0,Ye[t.type])(e,t.payload,n,d):n(t)}));l.cancel=X;var c={meta:o,cancel:function(){0===c.status&&(c.status=1,l(j))},status:0},u=function(e,t,r,n,o,i,s){var a;void 0===s&&(s=X);var c,u,d=0,l=null,h=[],p=Object.create(r),m=function(e,t,r){var n,o=[],i=!1;function s(e){h.push.apply(h,m.getTasks().map((function(e){return e.meta.name}))),c(),r(e,!0)}function a(t){o.push(t),t.cont=function(a,c){i||(ee(o,t),t.cont=X,c?s(a):(t===e&&(n=a),o.length||(i=!0,r(n))))}}function c(){i||(i=!0,o.forEach((function(e){e.cont=X,e.cancel()})),o=[])}return a(e),{addTask:a,cancelAll:c,abort:s,getTasks:function(){return o}}}(t,0,f);function f(t,r){if(r){if(d=2,ot({meta:o,cancelledTasks:h}),g.isRoot){var n=st();it(),e.onError(t,{sagaStack:n})}u=t,l&&l.reject(t)}else t===j?d=1:1!==d&&(d=3),c=t,l&&l.resolve(t);g.cont(t,r),g.joiners.forEach((function(e){e.cb(t,r)})),g.joiners=null}var g=((a={})[L]=!0,a.id=n,a.meta=o,a.isRoot=i,a.context=p,a.joiners=[],a.queue=m,a.cancel=function(){0===d&&(d=1,m.cancelAll(),f(j,!1))},a.cont=s,a.end=f,a.setContext=function(e){Z(p,e)},a.toPromise=function(){return l||((e={}).promise=new Promise((function(t,r){e.resolve=t,e.reject=r})),l=e,2===d?l.reject(u):0!==d&&l.resolve(c)),l.promise;var e},a.isRunning=function(){return 0===d},a.isCancelled=function(){return 1===d||0===d&&1===t.status},a.isAborted=function(){return 2===d},a.result=function(){return c},a.error=function(){return u},a);return g}(e,c,r,n,o,i,s),d={task:u,digestEffect:h};return s&&(s.cancel=u.cancel),l(),u;function l(e,r){try{var o;r?(o=t.throw(e),it()):ue(e)?(c.status=1,l.cancel(),o=U(t.return)?t.return(j):{done:!0,value:j}):o=ce(e)?U(t.return)?t.return():{done:!0}:t.next(e),o.done?(1!==c.status&&(c.status=3),c.cont(o.value)):h(o.value,n,l)}catch(e){if(1===c.status)throw e;c.status=2,c.cont(e,!0)}}function h(t,r,n,o){void 0===o&&(o="");var i,s=Ge();function c(r,o){i||(i=!0,n.cancel=X,e.sagaMonitor&&(o?e.sagaMonitor.effectRejected(s,r):e.sagaMonitor.effectResolved(s,r)),o&&function(e){rt=e}(t),n(r,o))}e.sagaMonitor&&e.sagaMonitor.effectTriggered({effectId:s,parentEffectId:r,label:o,effect:t}),c.cancel=X,n.cancel=function(){i||(i=!0,c.cancel(),c.cancel=X,e.sagaMonitor&&e.sagaMonitor.effectCancelled(s))},a(t,s,c)}}function ct(e,t){for(var r=e.channel,n=void 0===r?He():r,o=e.dispatch,i=e.getState,s=e.context,a=void 0===s?{}:s,c=e.sagaMonitor,u=e.effectMiddlewares,d=e.onError,l=void 0===d?ie:d,h=arguments.length,p=new Array(h>2?h-2:0),m=2;m<h;m++)p[m-2]=arguments[m];var f,g=t.apply(void 0,p),v=Ge();if(c&&(c.rootSagaStarted=c.rootSagaStarted||X,c.effectTriggered=c.effectTriggered||X,c.effectResolved=c.effectResolved||X,c.effectRejected=c.effectRejected||X,c.effectCancelled=c.effectCancelled||X,c.actionDispatched=c.actionDispatched||X,c.rootSagaStarted({effectId:v,saga:t,args:p})),u){var y=k.apply(void 0,u);f=function(e){return function(t,r,n){return y((function(t){return e(t,r,n)}))(t)}}}else f=Y;var b={channel:n,dispatch:ae(o),getState:i,sagaMonitor:c,onError:l,finalizeRunEffect:f};return Ae((function(){var e=at(b,g,a,v,he(t),!0,void 0);return c&&c.effectResolved(v,e),e}))}function ut(e){var t,r=void 0===e?{}:e,n=r.context,o=void 0===n?{}:n,i=r.channel,s=void 0===i?He():i,a=r.sagaMonitor,c=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}(r,["context","channel","sagaMonitor"]);function u(e){return t=ct.bind(null,V({},c,{context:o,channel:s,dispatch:e.dispatch,getState:e.getState,sagaMonitor:a})),function(e){return function(t){a&&a.actionDispatched&&a.actionDispatched(t);var r=e(t);return s.put(t),r}}}return u.run=function(){return t.apply(void 0,arguments)},u.setContext=function(e){Z(o,e)},u}var dt={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function i(e,t,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,o=[];if(0===this._eventsCount)return o;for(n in e=this._events)t.call(e,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,o=t.length,i=new Array(o);n<o;n++)i[n]=t[n].fn;return i},a.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},a.prototype.emit=function(e,t,n,o,i,s){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,d=this._events[a],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,o),!0;case 5:return d.fn.call(d.context,t,n,o,i),!0;case 6:return d.fn.call(d.context,t,n,o,i,s),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,p=d.length;for(u=0;u<p;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,o);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},a.prototype.on=function(e,t,r){return i(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return i(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,o){var i=r?r+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||n&&a.context!==n||s(this,i);else{for(var c=0,u=[],d=a.length;c<d;c++)(a[c].fn!==t||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},a.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&s(this,t):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(dt);var lt=dt.exports,ht=Object.defineProperty,pt=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,ft=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertyNames,vt=Object.getOwnPropertySymbols,yt=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable,_t=(e,t,r)=>t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,St=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&_t(e,r,t[r]);if(vt)for(var r of vt(t))bt.call(t,r)&&_t(e,r,t[r]);return e},wt=(e,t)=>pt(e,ft(t)),kt=(e,t)=>{var r={};for(var n in e)yt.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&vt)for(var n of vt(e))t.indexOf(n)<0&&bt.call(e,n)&&(r[n]=e[n]);return r},Et=(e,t)=>{for(var r in t)ht(e,r,{get:t[r],enumerable:!0})},Ct=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of gt(t))yt.call(e,o)||!r&&"default"===o||ht(e,o,{get:()=>t[o],enumerable:!(n=mt(t,o))||n.enumerable});return e},Tt=(e,t,r)=>(_t(e,"symbol"!=typeof t?t+"":t,r),r),It="__local__",Ot="__synthetic__",Mt=["room.started","room.ended"].map((e=>`video.${e}`)),Rt=()=>(new Date).toISOString().replace("T"," ").replace("Z",""),Pt=o.getLogger("signalwire"),At=Pt.methodFactory;Pt.methodFactory=(e,t,r)=>{const n=At(e,t,r);return function(){const e=[Rt(),"-"];for(let t=0;t<arguments.length;t++)e.push(arguments[t]);n.apply(void 0,e)}};var xt,Lt=Pt.getLevel();Pt.setLevel(Lt);var jt={},Dt=()=>null!=xt?xt:Pt,Nt=({type:e,payload:t})=>{const r=Dt(),{logWsTraffic:n}=jt||{};if(!n)return;const o=(e=>!("method"in e)||"signalwire.ping"!==e.method)(t)?JSON.stringify(t,null,2):t;return r.info(`${e.toUpperCase()}: \n`,o,"\n")},Vt=()=>{const e=Dt();return new Proxy(e,{get:(e,t,r)=>"wsTraffic"===t?Nt:Reflect.get(e,t,r)})},Wt=(e,t)=>{const{result:r={},error:n}=e;if(n)return{error:n};const{code:o,node_id:i,result:s=null}=r;return o&&"200"!==o?{error:r}:null===s?(t&&(r.node_id=t),{result:r}):s?s.jsonrpc?Wt(s,i):{result:s}:{result:r}},$t={propsToUpdateValue:["updated","layers","members","recordings","playbacks"]},Ut=(e,t=$t)=>Object.entries(e).reduce(((e,[r,n])=>{const o=qt(r);return e[o]="object"==typeof n&&n?Array.isArray(n)?t.propsToUpdateValue.includes(r)?n.map((e=>"string"==typeof e?qt(e):Ut(e))):n:Ut(n):(e=>e.endsWith("At"))(o)?(e=>{if(void 0===e)return e;const t=new Date(1e3*e);return isNaN(t.getTime())?e:t})(n):n,e}),{}),qt=e=>e.includes("_")?e.split("_").reduce(((e,t,r)=>{const n=t.trim().charAt(0),o=t.substr(1).toLowerCase();return`${e}${0===r?n.toLowerCase():n.toUpperCase()}${o}`}),""):e,Bt=({event:e,namespace:t})=>("string"==typeof e&&(e=Ht({event:e,namespace:t}),e=Ft(e)),e),zt=/[A-Z]/g,Ft=e=>e.replace(zt,(e=>`_${e.toLowerCase()}`)),Ht=({namespace:e,event:t})=>!e||t.startsWith(e)?t:`${e}:${t}`,Qt=(e,t)=>(Object.keys(t).forEach((t=>{if(e.prototype.hasOwnProperty(t))throw new Error(`[extendComponent] Duplicated method name: ${t}`)})),Object.defineProperties(e.prototype,t),e),Kt=({instance:e,transform:t,payload:r,transformedPayload:n})=>new Proxy(e,{get:(e,o,i)=>"toString"===o?(({property:e,payload:t})=>"function"==typeof e?()=>JSON.stringify(t):e)({property:e[o],payload:n}):"_eventsNamespace"===o&&t.getInstanceEventNamespace?t.getInstanceEventNamespace(r):"eventChannel"===o&&t.getInstanceEventChannel?t.getInstanceEventChannel(r):o in n?n[o]:Reflect.get(e,o,i)}),Jt=new Map,Gt=[{field:"members",preProcessPayload:e=>({member:e}),eventTransformType:"roomSessionMember"},{field:"recordings",preProcessPayload:e=>({recording:e}),eventTransformType:"roomSessionRecording"}],Xt=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}},Yt=/^(ws|wss):\/\//,Zt=["video.member.updated","video.member.talking"],er=["video.room.joined","video.track","video.active","video.answering","video.destroy","video.early","video.hangup","video.held","video.new","video.purge","video.recovering","video.requesting","video.ringing","video.trying"],tr=e=>{const t=e.map((e=>{if("string"==typeof e){const t=(e=>{const t=e.split(":");return t[t.length-1]})(e);return er.includes(t)||(e=>e.includes(Ot))(t)?null:Zt.find((e=>t.startsWith(e)))||t}return e}));return Array.from(new Set(t)).filter(Boolean)},rr=e=>e.includes(It),nr=e=>{const t=e.split(".")[0];return e.split(".").reduce(((e,r)=>(e.push(r),r===t&&e.push(It),e)),[]).join(".")},or=e=>{var t;return St({jsonrpc:"2.0",id:null!=(t=e.id)?t:l()},e)},ir=e=>St({jsonrpc:"2.0"},e),sr={major:3,minor:0,revision:0},ar=e=>or({method:"signalwire.connect",params:St({version:sr},e)}),cr={id:"callID",destinationNumber:"destination_number",remoteCallerName:"remote_caller_id_name",remoteCallerNumber:"remote_caller_id_number",callerName:"caller_id_name",callerNumber:"caller_id_number"},ur=e=>{if(e.hasOwnProperty("dialogParams")){const t=kt(e.dialogParams,["remoteSdp","localStream","remoteStream"]);for(const e in cr)e&&t.hasOwnProperty(e)&&(t[cr[e]]=t[e],delete t[e]);e.dialogParams=t}return e},dr=e=>(t={})=>or({method:e,params:ur(t)}),lr=dr("verto.invite"),hr=dr("verto.bye"),pr=dr("verto.info"),mr=(e,t)=>ir({id:e,result:{method:t}}),fr={};Et(fr,{authErrorAction:()=>Cr,authSuccessAction:()=>Tr,closeConnectionAction:()=>wr,createAction:()=>vr,destroyAction:()=>Sr,executeAction:()=>Er,getCustomSagaActionType:()=>Dr,initAction:()=>_r,makeCustomSagaAction:()=>jr,reauthAction:()=>kr,sessionAuthErrorAction:()=>xr,sessionConnectedAction:()=>Rr,sessionDisconnectedAction:()=>Pr,sessionReconnectingAction:()=>Ar,socketClosedAction:()=>Ir,socketErrorAction:()=>Or,socketMessageAction:()=>Mr});var gr={};function vr(e,t){function r(...r){if(t){let n=t(...r);if(!n)throw new Error("prepareAction did not return an object");return St(St({type:e,payload:n.payload},"meta"in n&&{meta:n.meta}),"error"in n&&{error:n.error})}return{type:e,payload:r[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=t=>t.type===e,r}Et(gr,{configureStore:()=>br,createAction:()=>vr}),Ct(gr,C);var yr="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?k:k.apply(null,arguments)};function br(e){const t=function(){return[]},{reducer:r,middleware:n=t(),devTools:o=!0,preloadedState:i,enhancers:s}=e||{};let a;if("function"==typeof r)a=r;else{if(!function(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let r=t;for(;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return t===r}(r))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');a=S(r)}let c=n;"function"==typeof c&&(c=c(t));const u=E(...c);let d=k;o&&(d=yr(St({trace:!1},"object"==typeof o&&o)));let l=[u];return Array.isArray(s)?l=[u,...s]:"function"==typeof s&&(l=s(l)),_(a,i,d(...l))}var _r=vr("swSdk/init"),Sr=vr("swSdk/destroy"),wr=vr("swSdk/closeConnection"),kr=vr("swSdk/reauth"),Er=vr("swSdk/executeRequest"),Cr=vr("auth/error"),Tr=vr("auth/success"),Ir=vr("socket/closed"),Or=vr("socket/error"),Mr=vr("socket/message"),Rr=vr("session.connected"),Pr=vr("session.disconnected"),Ar=vr("session.reconnecting"),xr=vr("session.auth_error"),Lr=(e,t)=>`${t.type}/${e}`,jr=(e,t)=>wt(St({},t),{type:Lr(e,t)}),Dr=(e,t)=>Lr(e,t);function Nr(e){const t={},r=[];let n;const o={addCase(e,r){const n="string"==typeof e?e:e.type;if(n in t)throw new Error("addCase cannot be called with two reducers for the same action type");return t[n]=r,o},addMatcher:(e,t)=>(r.push({matcher:e,reducer:t}),o),addDefaultCase:e=>(n=e,o)};return e(o),[t,r,n]}var Vr=({name:e="",initialState:t,reducers:r,extraReducers:n})=>function(e){const{name:t}=e;if(!t)throw new Error("`name` is a required option for createSlice");const r=e.initialState,n=e.reducers||{},o=Object.keys(n),i={},s={},a={};function c(){const[t={},n=[],o]="function"==typeof e.extraReducers?Nr(e.extraReducers):[e.extraReducers],i=St(St({},t),s);return function(e,t,r=[],n){let o,[i,s,a]="function"==typeof t?Nr(t):[t,r,n];function c(e=o(),t){let r=[i[t.type],...s.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===r.filter((e=>!!e)).length&&(r=[a]),r.reduce(((e,r)=>r?r(e,t):e),e)}return o="function"==typeof e?()=>e():()=>e,c.getInitialState=o,c}(r,i,n,o)}let u;return o.forEach((e=>{const r=n[e],o=`${t}/${e}`;let c,u;"reducer"in r?(c=r.reducer,u=r.prepare):c=r,i[e]=c,s[o]=c,a[e]=u?vr(o,u):vr(o)})),{name:t,reducer:(e,t)=>(u||(u=c()),u(e,t)),actions:a,caseReducers:i,getInitialState:()=>(u||(u=c()),u.getInitialState())}}({name:e,initialState:t,reducers:r,extraReducers:e=>{e.addCase(Sr.type,(()=>t)),"function"==typeof n&&n(e)}}),Wr=Vr({name:"session",initialState:{protocol:"",iceServers:[],authStatus:"unknown",authError:void 0,authCount:0},reducers:{connected:(e,{payload:t})=>{var r,n;return wt(St({},e),{authStatus:"authorized",authCount:e.authCount+1,protocol:null!=(r=null==t?void 0:t.protocol)?r:"",iceServers:null!=(n=null==t?void 0:t.ice_servers)?n:[]})},authStatus:(e,{payload:t})=>wt(St({},e),{authStatus:t})},extraReducers:e=>{e.addCase(Cr.type,((e,{payload:t})=>wt(St({},e),{authStatus:"unauthorized",authError:t.error})))}}),{actions:$r,reducer:Ur}=Wr,qr={};Et(qr,{authErrorAction:()=>Cr,authSuccessAction:()=>Tr,closeConnectionAction:()=>wr,configureStore:()=>Tn,connect:()=>Cn,createAction:()=>vr,createCatchableSaga:()=>en,createRestartableSaga:()=>Yr,destroyAction:()=>Sr,executeAction:()=>Er,getCustomSagaActionType:()=>Dr,initAction:()=>_r,makeCustomSagaAction:()=>jr,reauthAction:()=>kr,sessionAuthErrorAction:()=>xr,sessionConnectedAction:()=>Rr,sessionDisconnectedAction:()=>Pr,sessionReconnectingAction:()=>Ar,socketClosedAction:()=>Ir,socketErrorAction:()=>Or,socketMessageAction:()=>Mr});var Br=({state:e,payload:t,componentId:r,key:n,requestId:o})=>wt(St({},e),r in e.byId?{byId:wt(St({},e.byId),{[r]:wt(St({},e.byId[r]),{[n]:wt(St({},e.byId[r][n]),{[o]:t})})})}:{byId:wt(St({},e.byId),{[r]:{id:r,[n]:{[o]:t}}})}),zr=Vr({name:"components",initialState:{byId:{}},reducers:{upsert:(e,{payload:t})=>wt(St({},e),t.id in e.byId?{byId:wt(St({},e.byId),{[t.id]:St(St({},e.byId[t.id]),t)})}:{byId:wt(St({},e.byId),{[t.id]:t})}),executeSuccess:(e,{payload:t})=>{const{componentId:r,requestId:n,response:o}=t;return Br({componentId:r,requestId:n,state:e,key:"responses",payload:o})},executeFailure:(e,{payload:t})=>{const{componentId:r,requestId:n,error:o,action:i}=t;return Br({componentId:r,requestId:n,state:e,key:"errors",payload:{action:i,jsonrpc:o}})},cleanup:(e,{payload:t})=>wt(St({},e),{byId:Object.entries(e.byId).reduce(((e,[r,n])=>(t.ids.includes(r)||(e[r]=n),e)),{})})}}),{actions:Fr,reducer:Hr}=zr,Qr={queue:[]},Kr=Vr({name:"executeQueue",initialState:Qr,reducers:{add:(e,{payload:t})=>wt(St({},e),{queue:e.queue.concat(t)}),clean:()=>Qr}}),{actions:Jr,reducer:Gr}=Kr,Xr=(0,gr.combineReducers)({components:Hr,session:Ur,executeQueue:Gr});Et({},{createCatchableSaga:()=>en,createRestartableSaga:()=>Yr});var Yr=e=>function*(){!function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];_e(Ce.apply(void 0,[e].concat(r)))}((function*(){for(;;)try{Vt().debug("Run a restartable saga"),yield Ee(e),Vt().debug("One of the restartable saga has ended. Restarting..")}catch(e){Vt().error("Restartable Saga Error",e)}}))},Zr=e=>Vt().error("Catchable Saga Error",e),en=(e,t=Zr)=>function*(...r){try{yield Ee(e,...r)}catch(e){t(e)}},tn={};Et(tn,{getAuthError:()=>sn,getAuthStatus:()=>on,getIceServers:()=>rn,getSession:()=>nn});var rn=({session:e})=>{var t;return null!=(t=null==e?void 0:e.iceServers)?t:[]},nn=e=>e.session,on=({session:e})=>e.authStatus,sn=({session:e})=>e.authError,an=({components:e},t)=>{var r;return null==(r=e.byId)?void 0:r[t]},cn=e=>{const t=(({components:e})=>e.byId)(e);let r=[];return Object.keys(t).forEach((e=>{(t[e].responses||t[e].errors)&&r.push(e)})),r};function*un(e){function*t(t){if("authorized"!==(yield Te(on)))return;const{componentId:r,requestId:n,method:o,params:i}=t.payload;try{const s=(({method:e,params:t})=>or({method:e,params:t}))({id:n,method:o,params:i}),a=yield Ee(e.execute,s);r&&n&&(yield we(Fr.executeSuccess({componentId:r,requestId:n,response:a})))}catch(e){Vt().warn("worker error",r,e),r&&n&&(yield we(Fr.executeFailure({componentId:r,requestId:n,action:t,error:e})))}finally{if((yield be("CANCELLED",{}))&&r&&n){const e={jsonrpc:"2.0",id:n,error:{code:-32600,message:"Cancelled task"}};Vt().debug("executeActionWorker cancelled",{requestId:n,componentId:r,error:e}),yield we(Fr.executeFailure({componentId:r,requestId:n,action:t,error:e}))}}}for(;;){const e=yield Se(Er.type);yield Ce(t,e)}}function*dn({session:e,sessionChannel:t,pubSubChannel:r}){function*n({jsonrpc:t,nodeId:r}){var n,o;const{id:i,method:s,params:a={}}=t;switch(s){case"verto.media":{const e={id:a.callID,state:"early",remoteSDP:a.sdp,nodeId:r};yield we(Fr.upsert(e)),yield we(Er({method:"video.message",params:{message:mr(i,s),node_id:r}}));break}case"verto.answer":{const e={id:a.callID,state:"active",nodeId:r};(null==a?void 0:a.sdp)&&(e.remoteSDP=a.sdp),yield we(Fr.upsert(e)),yield we(Er({method:"video.message",params:{message:mr(i,s),node_id:r}}));break}case"verto.bye":{const e={id:a.callID,state:"hangup",nodeId:r,byeCause:null!=(n=null==a?void 0:a.cause)?n:"",byeCauseCode:null!=(o=null==a?void 0:a.causeCode)?o:0,redirectDestination:null==a?void 0:a.redirectDestination};yield we(Fr.upsert(e)),yield we(Er({method:"video.message",params:{message:mr(i,s),node_id:r}}));break}case"verto.ping":yield we(Er({method:"video.message",params:{message:mr(i,s),node_id:r}}));break;case"verto.punt":return e.disconnect();case"verto.mediaParams":{const{callID:e,mediaParams:t={}}=a;if(!e){Vt().debug("Invalid mediaParams event",a);break}const r={id:e};(null==t?void 0:t.video)&&(r.videoConstraints=t.video),(null==t?void 0:t.audio)&&(r.audioConstraints=t.audio),yield we(Fr.upsert(r));break}case"verto.info":return Vt().debug("Verto Info",a);case"verto.clientReady":return Vt().debug("Verto ClientReady",a);case"verto.announce":return Vt().debug("Verto Announce",a);default:return Vt().debug(`Unknown Verto method: ${s}`,a)}}function*o(e){switch(e.event_type){case"video.room.subscribed":yield we(Fr.upsert({id:e.params.call_id,roomId:e.params.room_session.room_id,roomSessionId:e.params.room_session.id,memberId:e.params.member_id,previewUrl:e.params.room_session.preview_url})),yield we(r,{type:"video.room.joined",payload:e.params});break;case"video.member.updated":{const{member:{updated:t=[]}}=e.params;for(const n of t){const t=`video.member.updated.${n}`;yield we(r,{type:t,payload:e.params})}break}case"video.member.joined":{const{member:t}=e.params;(null==t?void 0:t.parent_id)&&(yield Te(an,t.parent_id))&&(yield we(Fr.upsert({id:t.id,roomId:e.params.room_id,roomSessionId:e.params.room_session_id,memberId:t.id})));break}case"video.member.talking":{const{member:t}=e.params;if("talking"in t){const n=t.talking?"started":"ended";yield we(r,{type:`video.member.talking.${n}`,payload:e.params});const o=t.talking?"start":"stop";yield we(r,{type:`video.member.talking.${o}`,payload:e.params})}break}}yield we(r,{type:e.event_type,payload:e.params})}function*i(e){yield we(r,{type:e.event_type,payload:e.params})}function*s(e){var t;"webrtc.message"!==(null==(t=e)?void 0:t.event_type)?(e=>{var t;return!!(null==(t=null==e?void 0:e.event_type)?void 0:t.startsWith("video."))})(e)?yield Ce(o,e):(e=>{var t;return!!(null==(t=null==e?void 0:e.event_type)?void 0:t.startsWith("cantina-manager."))})(e)?yield Ce(i,e):yield we({type:e.event_type,payload:e}):yield Ce(n,{jsonrpc:e.params,nodeId:e.node_id})}const a=en((function*(e){if(e.type!==Mr.type)return void(yield we(e));const{method:t,params:r}=e.payload;switch(t){case"signalwire.event":yield Ce(s,r);break;default:return Vt().debug(`Unknown message: ${t}`,e)}}),(e=>{Vt().error("Channel Error",e)}));for(;;)try{for(;;){const e=yield Se(t);yield Ce(a,e)}}catch(e){Vt().error("sessionChannelWorker error:",e)}finally{Vt().debug("sessionChannelWorker finally")}}function ln(e){return function(t,r){void 0===r&&(r=me);var n,o,i=!1,s=ze(r),a=function(){i||(i=!0,U(n)&&n(),s.close())};return n=te((o=function(e){Be(e)?a():s.put(e)},e.dispatch=e=>{o(e)},n=()=>{Vt().debug("sessionChannel unsubscribe"),e.disconnect()})),i&&n(),{take:s.take,flush:s.flush,close:a}}()}function*hn({pubSubChannel:e,emitter:t}){for(;;){const n=yield Se(e,"*"),{type:o,payload:i}=n;try{const e=void 0===(r=n).payload?"":(e=>e.type.startsWith("video.member.")||e.type.startsWith("video.__synthetic__.member"))(r)||(e=>e.type.startsWith("video.layout."))(r)||(e=>e.type.startsWith("video.recording."))(r)||(e=>e.type.startsWith("video.playback."))(r)?r.payload.room_session_id:(e=>e.type.startsWith("video.room."))(r)?r.payload.room_session.id:((e=>{e.type.startsWith("chat.")})(r),"");Mt.includes(o)&&t.emit(o,i),t.emit(Bt({namespace:e,event:o}),i)}catch(e){Vt().error(e)}}var r}var pn=({executeQueue:e})=>e;function*mn(){function*e(e){"authorized"!==(yield Te(on))&&(yield we(Jr.add(e.payload)))}for(;;){const t=yield Se(Er.type);yield Ce(e,t)}}function*fn(){const{queue:e}=yield Te(pn);for(const t of e)yield we(Er(t));yield we(Jr.clean())}var gn=class extends Error{constructor(e,t){super(t),this.code=e,this.message=t,Tt(this,"name","AuthError"),Object.setPrototypeOf(this,gn.prototype)}};function*vn(){const e=yield Te(cn);e.length&&(yield we(Fr.cleanup({ids:e})))}function*yn(){for(;;)yield Ie(36e5),yield Ce(vn)}function*bn({SessionConstructor:e,userOptions:t,channels:r}){var n;const o=new e(t),i=yield Ee(ln,o),s=r.pubSubChannel;let a=[];if(null==(n=t.workers)?void 0:n.length)try{const e=t.workers.map((e=>Ee(Yr(e))));a=yield function(e){var t=be("ALL",e);return t.combinator=!0,t}(e)}catch(e){Vt().error("Error running custom workers",e)}yield Ce(dn,{session:o,sessionChannel:i,pubSubChannel:s}),yield Ce(wn,{session:o,sessionChannel:i,pubSubChannel:s,userOptions:t});const c=yield Ce(yn);o.connect(),yield Se(Sr.type),null==c||c.cancel(),s.close(),i.close(),a.forEach((e=>e.cancel()))}function*_n({session:e,sessionChannel:t,pubSubChannel:r}){"reconnecting"===e.status?(yield we(r,Ar()),yield Ie(2e3*Math.random()),yield Ee(e.connect)):(t.close(),yield we(r,Pr()))}function*Sn({session:e,token:t}){try{e.reauthenticate&&(e.token=t,yield Ee(e.reauthenticate))}catch(e){Vt().error("Reauthenticate Error",e)}}function*wn(e){for(;;){const t=yield Se([Tr.type,Cr.type,Or.type,Ir.type,kr.type]);switch(t.type){case Tr.type:yield Ce(kn,e);break;case Cr.type:yield Ce(En,{action:t,userOptions:e.userOptions,pubSubChannel:e.pubSubChannel});break;case Or.type:break;case Ir.type:yield Ce(_n,e);break;case kr.type:yield Ce(Sn,{session:e.session,token:t.payload.token})}}}function*kn(e){const{session:t,pubSubChannel:r,userOptions:n}=e,o=yield Ce(hn,{pubSubChannel:r,emitter:n.emitter}),i=yield Ce(un,t);yield we($r.connected(t.rpcConnectResult)),yield we(r,Rr());const s=yield Ce(fn);yield Se(wr.type),o.cancel(),i.cancel(),s.cancel()}function*En(e){const{pubSubChannel:t,userOptions:r,action:n}=e,{error:o}=n.payload,i=o?new gn(o.code,o.error):new Error("Unauthorized"),s=yield Ce(hn,{pubSubChannel:t,emitter:r.emitter});throw yield we(t,xr()),s.cancel(),i}var Cn=e=>{const{componentListeners:t={},sessionListeners:r={},store:n,Component:o,customSagas:i=[]}=e,s=Object.keys(t),a=Object.keys(r);return e=>{const c=new o(wt(St({},e),{store:n})),u=new Map;let d=!0;const l=n.subscribe((()=>{const e=n.getState(),o=an(e,c.__uuid)||{};for(const e of s){if(!1===d)return;const r=`${c.__uuid}.${e}`,n=u.get(r),i=o[e];if(void 0!==i&&n!==i){u.set(r,i);const n=t[e];"string"==typeof n?c[n](o):n(o)}}const i=nn(e);for(const e of a){if(!1===d)return;const t=`session.${e}`,n=u.get(t),o=i[e];if(void 0!==o&&n!==o){u.set(t,o);const n=r[e];"string"==typeof n?c[n](i):"function"==typeof n&&n(i)}}})),h=null==i?void 0:i.map((e=>n.runSaga(e,{instance:c,runSaga:n.runSaga})));return c.destroyer=()=>{d=!1,l(),u.clear(),(null==h?void 0:h.length)&&h.forEach((e=>e.cancel()))},c}};Ct(qr,gr);var Tn=e=>{var t;const{userOptions:r,SessionConstructor:n,preloadedState:o={},runSagaMiddleware:i=!0}=e,s=ut(),a={pubSubChannel:Fe()},c=br({devTools:null==(t=null==r?void 0:r.devTools)||t,reducer:Xr,preloadedState:o,middleware:e=>e().concat(s)});if(i){const e=(e=>function*({userOptions:t,channels:r}){t.logger&&(xt=t.logger),t.debug&&(e=>{null!=e?Object.assign(jt,e):jt={}})(t.debug),yield Ce(mn),yield Se(_r.type);try{yield Ee(bn,wt(St({},e),{userOptions:t,channels:r}))}catch(e){return void Vt().error("RootSaga Error:",e)}})({SessionConstructor:n});s.run(e,{userOptions:r,channels:a})}return wt(St({},c),{runSaga:(e,t)=>s.run(e,wt(St({},t),{channels:a}))})},In=e=>e,On=class{constructor(e){this.options=e,Tt(this,"uuid",l()),Tt(this,"_eventsPrefix",""),Tt(this,"_eventsRegisterQueue",new Set),Tt(this,"_eventsEmitQueue",new Set),Tt(this,"_eventsNamespace"),Tt(this,"_eventsTransformsCache",new Map),Tt(this,"_requests",new Map),Tt(this,"_customSagaTriggers",new Map),Tt(this,"_destroyer"),Tt(this,"_emitterTransforms",new Map),Tt(this,"_emitterListenersCache",new Map),Tt(this,"_trackedEvents",[]),Tt(this,"_runningWorkers",[]),Tt(this,"_workers",new Map)}get __uuid(){return this.uuid}_getNamespacedEvent(e){let t=this._eventsNamespace;return"string"==typeof e&&rr(e)&&(t=this.__uuid),Bt({event:e,namespace:t})}_getPrefixedEvent(e){return this._eventsPrefix&&"string"==typeof e&&!e.includes(`${this._eventsPrefix}.`)?`${this._eventsPrefix}.${e}`:e}_getInternalEvent(e){return this._getNamespacedEvent(this._getPrefixedEvent(e))}get logger(){return Vt()}set destroyer(e){this._destroyer=e}get store(){return this.options.store}get emitter(){return this.options.emitter}addEventToRegisterQueue(e){const[t,r]=e.params;return this.logger.trace("Adding event to the register queue",{event:t,fn:r}),this._eventsRegisterQueue.add({type:e.type,params:e.params}),this.emitter}_addEventToEmitQueue(e,t){this.logger.trace("Adding to the emit queue",e),this._eventsEmitQueue.add({event:e,args:t})}shouldAddToQueue(){return void 0===this._eventsNamespace}runAndCacheEventHandlerTransform({internalEvent:e,transform:t,payload:r}){if(!this._eventsTransformsCache.has(e)){const n=t.instanceFactory(r);return this._eventsTransformsCache.set(e,n),n}return this._eventsTransformsCache.get(e)}cleanupEventHandlerTransformCache({internalEvent:e,force:t}){const r=this._eventsTransformsCache.get(e),n=this.listenerCount(e);return r&&(t||n<=1)?(r.destroy(),this._eventsTransformsCache.delete(e)):(this.logger.trace("[cleanupEventHandlerTransformCache] Key wasn't cached",e),!1)}getEmitterListenersMapByInternalEventName(e){var t;return null!=(t=this._emitterListenersCache.get(e))?t:new Map}getAndRemoveStableEventHandler(e,t){const r=this.getEmitterListenersMapByInternalEventName(e);if(t&&r.has(t)){const n=r.get(t);return r.delete(t),this._emitterListenersCache.set(e,r),n}return t}_createStableEventHandler(e,t){return r=>{const n=this._emitterTransforms.get(e);if(!n)return t(r);const o=this.runAndCacheEventHandlerTransform({internalEvent:e,transform:n,payload:r}),i=this._parseNestedFields(n.payloadTransform(r)),s=Kt({instance:o,payload:r,transformedPayload:i,transform:n});return t(s)}}_parseNestedFields(e){return Gt.forEach((({field:t,preProcessPayload:r,eventTransformType:n})=>{var o;const i=this._emitterTransforms.get(n);i&&(null==(o=null==e?void 0:e[t])?void 0:o.length)&&(e[t]=e[t].map((e=>(({transform:e,payload:t})=>{const r=(({transform:e,payload:t})=>{if(!Jt.has(e.type)){const r=e.instanceFactory(t);return Jt.set(e.type,r),r}return Jt.get(e.type)})({transform:e,payload:t}),n=e.payloadTransform(t);return Kt({transform:e,payload:t,instance:r,transformedPayload:n})})({transform:i,payload:r(e)}))))})),e}getOrCreateStableEventHandler(e,t){const r=this.getEmitterListenersMapByInternalEventName(e);let n=r.get(t);return n||(n=this._createStableEventHandler(e,t),r.set(t,n),this._emitterListenersCache.set(e,r)),n}_trackEvent(e){this._trackedEvents=Array.from(new Set(this._trackedEvents.concat(e)))}_untrackEvent(e){this._trackedEvents=this._trackedEvents.filter((t=>t!==e))}_addListener(e,t,r){const n=this._getInternalEvent(e);this._trackEvent(n);const o=r?"once":"on";if(this.shouldAddToQueue())return this.addEventToRegisterQueue({type:o,params:[e,t]}),this.emitter;const i=this.getOrCreateStableEventHandler(n,t);return this.logger.trace("Registering event",n),this.emitter[o](n,i)}on(e,t){return this._addListener(e,t)}once(e,t){return this._addListener(e,t,!0)}off(e,t){if(this.shouldAddToQueue())return this.addEventToRegisterQueue({type:"off",params:[e,t]}),this.emitter;const r=this._getInternalEvent(e),n=this.getAndRemoveStableEventHandler(r,t);return this.cleanupEventHandlerTransformCache({internalEvent:r,force:!n}),this.logger.trace("Removing event listener",r),this._untrackEvent(r),this.emitter.off(r,n)}removeAllListeners(e){return this.shouldAddToQueue()?(this.addEventToRegisterQueue({type:"removeAllListeners",params:[e]}),this.emitter):e?this.off(e):(this.eventNames().forEach((e=>{this.off(e)})),this.emitter)}eventNames(){return this._trackedEvents}getSubscriptions(){return tr(this.eventNames())}emit(e,...t){if(this.shouldAddToQueue())return this._addEventToEmitQueue(e,t),!1;const r=this._getInternalEvent(e);return this.logger.trace("Emit on event:",r),this.emitter.emit(r,...t)}listenerCount(e){return this.emitter.listenerCount(e)}destroy(){var e;null==(e=this._destroyer)||e.call(this),this.removeAllListeners(),this.detachWorkers()}execute({method:e,params:t},{transformParams:r=In,transformResolve:n=In,transformReject:o=In}={transformParams:In,transformResolve:In,transformReject:In}){return new Promise(((i,s)=>{const a=l();this._requests.set(a,{resolve:i,reject:s,transformResolve:n,transformReject:o}),this.store.dispatch(Er({requestId:a,componentId:this.__uuid,method:e,params:r(t)}))}))}triggerCustomSaga(e){return new Promise(((t,r)=>{const n=l();this._customSagaTriggers.set(n,{resolve:t,reject:r}),this.store.dispatch(St({dispatchId:n},jr(this.__uuid,e)))}))}settleCustomSagaTrigger({dispatchId:e,payload:t,kind:r}){const n=this._customSagaTriggers.get(e);n&&(n[r](t),this._customSagaTriggers.delete(e))}select(e){return e(this.store.getState())}onError(e){this._requests.forEach(((t,r)=>{void 0!==(null==e?void 0:e.errors[r])&&(t.reject(t.transformReject(e.errors[r])),this._requests.delete(r))}))}onSuccess(e){this._requests.forEach(((t,r)=>{void 0!==(null==e?void 0:e.responses[r])&&(t.resolve(t.transformResolve(e.responses[r])),this._requests.delete(r))}))}getStateProperty(e){return this[e]}flushEventsRegisterQueue(){this._eventsRegisterQueue.forEach((e=>{this[e.type](...e.params),this._eventsRegisterQueue.delete(e)}))}flushEventsEmitQueue(){this._eventsEmitQueue.forEach((e=>{const{event:t,args:r}=e;this.emit(t,...r),this._eventsEmitQueue.delete(e)}))}flushEventsQueue(){this.flushEventsRegisterQueue(),this.flushEventsEmitQueue()}_attachListeners(e){"string"==typeof e&&(this._eventsNamespace=e),this.flushEventsQueue()}getEmitterTransforms(){return new Map}get _sessionAuthStatus(){return on(this.store.getState())}_waitUntilSessionAuthorized(){switch(on(this.store.getState())){case"authorized":return Promise.resolve(this);case"unknown":case"authorizing":return new Promise(((e,t)=>{const r=this.store.subscribe((()=>{const n=on(this.store.getState()),o=sn(this.store.getState());if("authorized"===n)e(this),r();else if("unauthorized"===n){const e=o?new gn(o.code,o.error):new Error("Unauthorized");t(e),r()}}))}));case"unauthorized":return Promise.reject(new Error("Unauthorized"))}}_setEmitterTransform({event:e,handler:t,local:r}){const n=this._getInternalEvent(e);(r?rr(e):!rr(e)&&this.eventNames().includes(n))&&this._emitterTransforms.set(n,t)}applyEmitterTransforms({local:e=!1}={local:!1}){this.getEmitterTransforms().forEach(((t,r)=>{Array.isArray(r)?r.forEach((r=>{this._setEmitterTransform({event:r,handler:t,local:e})})):this._setEmitterTransform({event:r,handler:t,local:e}),this._emitterTransforms.set(t.type,t)}))}setWorker(e,t){this._workers.set(e,t)}getWorkers(){return this._workers}attachWorkers(){this.getWorkers().forEach((({worker:e},t)=>{const r=this.store.runSaga(e,{instance:this,runSaga:this.store.runSaga});this._runningWorkers.push(r),this._workers.delete(t)}))}detachWorkers(){this._runningWorkers.forEach((e=>{e.cancel()})),this._runningWorkers=[]}},Mn=class extends On{constructor(e){super(e),this.options=e,this._attachListeners("")}connect(){const e=on(this.store.getState());return"unknown"!==e&&"unauthorized"!==e||this.store.dispatch(_r()),this._waitUntilSessionAuthorized()}disconnect(){this.store.dispatch(Sr())}},Rn=class extends On{constructor(e){super(e),this.options=e,Tt(this,"subscribeMethod","signalwire.subscribe"),Tt(this,"subscribeParams",{}),this.applyEmitterTransforms({local:!0})}subscribe(){return new Promise((async(e,t)=>{const r=this.getSubscriptions();if(r.length>0){const e={method:this.subscribeMethod,params:wt(St({},this.subscribeParams),{event_channel:this.getStateProperty("eventChannel"),events:r})};try{this.applyEmitterTransforms(),this.attachWorkers(),await this.execute(e)}catch(e){return t(e)}}else this.logger.warn("`subscribe()` was called without any listeners attached.");return e(void 0)}))}},Pn={audio_muted:!0,video_muted:!0,deaf:!0,on_hold:!0,visible:!0,input_volume:1,output_volume:1,input_sensitivity:1};Object.keys(Pn).map((e=>`video.member.updated.${e}`));var An=Ut(Pn);Object.keys(An).map((e=>`member.updated.${e}`));var xn={};Et(xn,{RoomSessionPlaybackAPI:()=>so,RoomSessionRecordingAPI:()=>oo,audioMuteMember:()=>Qn,audioUnmuteMember:()=>Kn,createRoomSessionPlaybackObject:()=>ao,createRoomSessionRecordingObject:()=>io,deafMember:()=>Xn,getLayouts:()=>Nn,getMembers:()=>Vn,getPlaybacks:()=>Fn,getRecordings:()=>Bn,hideVideoMuted:()=>$n,play:()=>Hn,removeMember:()=>no,setDeaf:()=>Zn,setHideVideoMuted:()=>qn,setInputSensitivityMember:()=>ro,setInputVolumeMember:()=>eo,setLayout:()=>Wn,setOutputVolumeMember:()=>to,showVideoMuted:()=>Un,startRecording:()=>zn,undeafMember:()=>Yn,videoMuteMember:()=>Jn,videoUnmuteMember:()=>Gn});var Ln=()=>{},jn=(e,t={})=>({value:function(r={}){return this.execute({method:e,params:St({room_session_id:this.roomSessionId},r)},t)}}),Dn=(e,t={})=>({value:function(r={}){var n=r,{memberId:o}=n,i=kt(n,["memberId"]);return this.execute({method:e,params:St({room_session_id:this.roomSessionId,member_id:o||this.memberId},i)},t)}}),Nn=jn("video.list_available_layouts",{transformResolve:e=>({layouts:e.layouts})}),Vn=jn("video.members.get",{transformResolve:e=>({members:e.members})}),Wn=jn("video.set_layout",{transformResolve:Ln}),$n=jn("video.hide_video_muted",{transformResolve:Ln}),Un=jn("video.show_video_muted",{transformResolve:Ln}),qn={value:function(e){return this.execute({method:e?"video.hide_video_muted":"video.show_video_muted",params:{room_session_id:this.roomSessionId}},{transformResolve:Ln})}},Bn=jn("video.recording.list",{transformResolve:e=>({recordings:e.recordings.map((e=>Ut(e)))})}),zn={value:function(){return new Promise((async e=>{const t=t=>{e(t)};this.on(nr("video.recording.start"),t);try{const e=await this.execute({method:"video.recording.start",params:{room_session_id:this.roomSessionId}});this.emit(nr("video.recording.start"),wt(St({},e),{room_session_id:this.roomSessionId}))}catch(e){throw this.off(nr("video.recording.start"),t),e}}))}},Fn=jn("video.playback.list",{transformResolve:e=>({playbacks:e.playbacks.map((e=>Ut(e)))})}),Hn={value:function(e){return new Promise((async t=>{const r=e=>{t(e)};this.on(nr("video.playback.start"),r);try{const t=await this.execute({method:"video.playback.start",params:St({room_session_id:this.roomSessionId},e)});this.emit(nr("video.playback.start"),wt(St({},t),{room_session_id:this.roomSessionId}))}catch(e){throw this.off(nr("video.playback.start"),r),e}}))}},Qn=Dn("video.member.audio_mute",{transformResolve:Ln}),Kn=Dn("video.member.audio_unmute",{transformResolve:Ln}),Jn=Dn("video.member.video_mute",{transformResolve:Ln}),Gn=Dn("video.member.video_unmute",{transformResolve:Ln}),Xn=Dn("video.member.deaf",{transformResolve:Ln}),Yn=Dn("video.member.undeaf",{transformResolve:Ln}),Zn={value:function(e){return this.execute({method:e?"video.member.deaf":"video.member.undeaf",params:{room_session_id:this.roomSessionId,member_id:this.memberId}},{transformResolve:Ln})}},eo=Dn("video.member.set_input_volume",{transformResolve:Ln}),to=Dn("video.member.set_output_volume",{transformResolve:Ln}),ro=Dn("video.member.set_input_sensitivity",{transformResolve:Ln}),no={value:function(e={}){var t=e,{memberId:r}=t,n=kt(t,["memberId"]);if(!r)throw new TypeError('Invalid or missing "memberId" argument');return this.execute({method:"video.member.remove",params:St({room_session_id:this.roomSessionId,member_id:r},n)},{transformResolve:Ln})}},oo=class extends On{async pause(){await this.execute({method:"video.recording.pause",params:{room_session_id:this.getStateProperty("roomSessionId"),recording_id:this.getStateProperty("id")}})}async resume(){await this.execute({method:"video.recording.resume",params:{room_session_id:this.getStateProperty("roomSessionId"),recording_id:this.getStateProperty("id")}})}async stop(){await this.execute({method:"video.recording.stop",params:{room_session_id:this.getStateProperty("roomSessionId"),recording_id:this.getStateProperty("id")}})}},io=e=>Cn({store:e.store,Component:oo,componentListeners:{errors:"onError",responses:"onSuccess"}})(e),so=class extends On{async pause(){await this.execute({method:"video.playback.pause",params:{room_session_id:this.getStateProperty("roomSessionId"),playback_id:this.getStateProperty("id")}})}async resume(){await this.execute({method:"video.playback.resume",params:{room_session_id:this.getStateProperty("roomSessionId"),playback_id:this.getStateProperty("id")}})}async stop(){await this.execute({method:"video.playback.stop",params:{room_session_id:this.getStateProperty("roomSessionId"),playback_id:this.getStateProperty("id")}})}async setVolume(e){await this.execute({method:"video.playback.set_volume",params:{room_session_id:this.getStateProperty("roomSessionId"),playback_id:this.getStateProperty("id"),volume:e}})}},ao=e=>Cn({store:e.store,Component:so,componentListeners:{errors:"onError",responses:"onSuccess"}})(e),co={};Et(co,{BaseChatAPI:()=>ko,BaseChatConsumer:()=>wo,ChatMessage:()=>bo,createBaseChatObject:()=>Eo,getMemberState:()=>yo,getMembers:()=>go,getMessages:()=>fo,publish:()=>mo,setMemberState:()=>vo});var uo=e=>{const t=!e||Array.isArray(e)?e:[e];return Array.isArray(t)?t.map((e=>({name:e}))):[]},lo=e=>Array.isArray(e)||"string"==typeof e,ho=(e,t={})=>({value:function(r={}){const n=lo(null==r?void 0:r.channels)?uo(r.channels):void 0;return this.execute({method:e,params:wt(St({},r),{channels:n})},t)}}),po=(e,t={})=>({value:function(r={}){var n=r,{memberId:o}=n,i=kt(n,["memberId"]);const s=lo(null==i?void 0:i.channels)?uo(i.channels):void 0;return this.execute({method:e,params:wt(St({member_id:o},i),{channels:s})},t)}}),mo=ho("chat.publish"),fo=ho("chat.messages.get",{transformResolve:e=>({messages:e.messages.map((e=>Ut(e))),cursor:e.cursor})}),go=ho("chat.members.get",{transformResolve:e=>({members:e.members.map((e=>Ut(e)))})}),vo=po("chat.member.set_state",{transformResolve:()=>{}}),yo=po("chat.member.get_state",{transformResolve:e=>({channels:e.channels})}),bo=class{constructor(e){this.payload=e}get id(){return this.payload.id}get member(){return this.payload.member}get channel(){return this.payload.channel}get content(){return this.payload.content}get meta(){return this.payload.meta}get publishedAt(){return this.payload.publishedAt}},_o=function*({channels:{pubSubChannel:e}}){for(;;){const t=yield Se((e=>e.type.startsWith("chat.")));switch(Vt().debug("chatWorker:",t),t.type){case"chat.channel.message":yield we(e,{type:"chat.message",payload:t.payload});break;case"chat.member.joined":case"chat.member.updated":case"chat.member.left":yield we(e,t);break;default:Vt().warn("[chatWorker] Unrecognized Action",t)}}},So=e=>e.map((e=>({name:e}))),wo=class extends Rn{constructor(e){super(e),Tt(this,"_eventsPrefix","chat"),Tt(this,"subscribeMethod","chat.subscribe"),this._attachListeners("")}_getChannelsParam(e,t){const r=!e||Array.isArray(e)?e:[e];if(!Array.isArray(r)||0===r.length)throw new Error(`Please specify one or more channels when calling .${t}()`);return{channels:So(r)}}_setSubscribeParams(e){this.subscribeParams=St(St({},this.subscribeParams),e)}_getSubscribeParams({channels:e}){return St({},this._getChannelsParam(e,"subscribe"))}_getUnsubscribeParams({channels:e}){const t=this._getChannelsParam(e,"unsubscribe");return St({},t)}getWorkers(){return new Map([["chat",{worker:_o}]])}getEmitterTransforms(){return new Map([[["message"],{type:"chatMessage",instanceFactory:e=>{const{channel:t,message:r}=e.params;return new bo(Ut(wt(St({},r),{channel:t})))},payloadTransform:e=>{const{channel:t,message:r}=e.params;return Ut(wt(St({},r),{channel:t}))}}],[["member.joined","member.left","member.updated"],{type:"chatMessage",instanceFactory:e=>{const{member:t}=e.params;return new class{constructor(e){this.payload=e}get id(){return this.payload.id}get channel(){return this.payload.channel}get state(){var e;return null!=(e=this.payload.state)?e:{}}}(Ut(t))},payloadTransform:e=>{const{member:t}=e.params;return Ut(t)}}]])}async subscribe(e){const t=this._getSubscribeParams({channels:e});return this._setSubscribeParams(t),super.subscribe()}async unsubscribe(e){if("unknown"===this._sessionAuthStatus||"unauthorized"===this._sessionAuthStatus)throw new Error("You must be authenticated to unsubscribe from a channel");const t=this._getUnsubscribeParams({channels:e});return new Promise((async(e,r)=>{const n=this.getSubscriptions();if(n.length>0){const e={method:"chat.unsubscribe",params:wt(St({},t),{events:n})};try{await this.execute(e)}catch(e){return r(e)}}else this.logger.warn("`unsubscribe()` was called without any listeners attached.");return e(void 0)}))}},ko=Qt(wo,{publish:mo,getMembers:go,getMessages:fo,setMemberState:vo,getMemberState:yo}),Eo=e=>Cn({store:e.store,Component:ko,componentListeners:{errors:"onError",responses:"onSuccess"}})(e),Co=St({},tn);const To=()=>"undefined"!=typeof navigator&&!!navigator.mediaDevices,Io=()=>{if(!To())throw new Error("The media devices API isn't supported in this environment");return navigator.mediaDevices},Oo=(e={audio:!0,video:!0})=>{try{return Io().getUserMedia(e)}catch(t){switch(t.name){case"Error":Vt().error("navigator.mediaDevices.getUserMedia doesn't seem to be supported.");break;case"NotFoundError":Vt().error("No media tracks of the type specified were found that satisfy the given constraints.");break;case"NotReadableError":Vt().error("Hardware error occurred at the operating system, browser, or Web page level which prevented access to the device. This could have been caused by having the Camera or Mic being user by another application.");break;case"OverconstrainedError":Vt().error(`The constraint: ${t.constraint} cannot be met by the selected device.`),Vt().info("List of available constraints:",Ao());break;case"NotAllowedError":Vt().error("The user has mostly likely denied access to the device. This could also happen if the browsing context is insecure (using HTTP rather than HTTPS)");break;case"TypeError":0===Object.keys(e).length?Vt().error('Constraints can\'t be empty nor have "video" and "audio" set to false.'):Vt().error("Please check that you are calling this method from a secure context (using HTTPS rather than HTTP).");break;case"SecurityError":Vt().error("User media support is disabled on the Document on which getUserMedia() was called. The mechanism by which user media support is enabled and disabled is left up to the individual user agent.")}throw t}},Mo=e=>Io().getDisplayMedia(e),Ro=()=>Io().enumerateDevices(),Po=async e=>{let t=await Ro().catch((e=>[]));return e&&(t=t.filter((({kind:t})=>t===e))),t},Ao=()=>Io().getSupportedConstraints(),xo=e=>e&&e instanceof MediaStream,Lo=()=>"sinkId"in HTMLMediaElement.prototype,jo=async(e,t)=>{if(null!==e)if("string"==typeof t)if(Lo())try{return await e.setSinkId(t)}catch(e){throw"SecurityError"===e.name?Vt().error(`You need to use HTTPS for selecting audio output device: ${e}`):Vt().error(`Error: ${e}`),e}else Vt().warn("Browser does not support output device selection.");else Vt().warn(`Invalid speaker deviceId: '${t}'`);else Vt().warn("No HTMLMediaElement to attach the speakerId")},Do=e=>{var t;xo(e)&&(null===(t=null==e?void 0:e.getTracks())||void 0===t||t.forEach(No))},No=e=>{e&&"live"===e.readyState&&(e.stop(),e.dispatchEvent(new Event("ended")))},Vo={camera:"videoinput",microphone:"audioinput",speaker:"audiooutput"},Wo=e=>{if(e)return Vo[e]},$o=async e=>{if("permissions"in navigator&&"function"==typeof navigator.permissions.query&&e)try{return"granted"===(await navigator.permissions.query({name:e})).state}catch(e){}return(async e=>{const t=await Po(e);return t.length?t.every((({deviceId:e,label:t})=>Boolean(e&&t))):(Vt().warn(`No ${e} devices to check for permissions!`),null)})(Wo(e))},Uo=()=>$o("camera"),qo=()=>$o("microphone"),Bo=()=>$o("speaker"),zo=async(e,t=!1)=>{if(!1===await $o(e)){const t=(e=>({audio:!e||"all"===e||"microphone"===e||"speaker"===e,video:!e||"all"===e||"camera"===e}))(e),r=await Oo(t);Do(r)}return Ho(e,t)},Fo=(e,t={})=>{const r=[];return e.filter((({deviceId:e,kind:n,groupId:o})=>{var i;if(!e||t.targets&&!(null===(i=t.targets)||void 0===i?void 0:i.includes(n)))return!1;if(!o)return!0;const s=`${n}-${o}`,a=!(null==t?void 0:t.excludeDefault)||"default"!==e;return!(r.includes(s)||!a||(r.push(s),0))}))},Ho=async(e,t=!1)=>{const r=await Po(Wo(e));return!0===t?r:Fo(r)},Qo=async(e,t,r)=>{const n=await Ho(r,!0);for(let r=0;r<n.length;r++){const{deviceId:o,label:i}=n[r];if(e===o||t===i)return o}return null},Ko=e=>{const t=new Map;return e.forEach((e=>{e.deviceId&&t.set(e.deviceId,e)})),t},Jo={camera:Uo,microphone:qo,speaker:Bo},Go=["camera","microphone","speaker"],Xo=`Allowed targets are: '${Go.join("', '")}'`,Yo={speaker:Lo},Zo=async(e={})=>{const t=await(async e=>{var t;const r=(null!==(t=e.targets)&&void 0!==t?t:Go).filter((e=>!!Go.includes(e)||(Vt().warn(`We'll ignore the "${e}" target as it is not allowed. ${Xo}.`),!1)));if(!r.length)throw new Error(`At least one "target" is required for createDeviceWatcher(). ${Xo}.`);const n=await(async e=>{const t=e.targets;return(await Promise.all(t.map((e=>Jo[e]())))).reduce(((e,r,n)=>{var o;const i=t[n];return e[!(i in Yo)||(null===(o=Yo[i])||void 0===o?void 0:o.call(Yo))?"supported":"unsupported"].push([i,!!r]),e}),{supported:[],unsupported:[]})})({targets:r});if(n.unsupported.length>0&&r.length===n.unsupported.length)throw new Error(`The platform doesn't support "${r.join(", ")}" as target/s, which means it's not possible to watch for changes on those devices.`);if(n.supported.every((([e,t])=>!t)))throw new Error("You must ask the user for permissions before being able to listen for device changes. Try calling getUserMedia() before calling `createDeviceWatcher()`.");let o=[];const i=n.supported.reduce(((e,[t,r])=>(r?e.push(t):o.push(t),e)),[]);if(i.length!==r.length){const e=n.unsupported.length>0?`The platform doesn't support "${n.unsupported.map((([e])=>e)).join(", ")}" as target/s, which means it's not possible to watch for changes on those devices. `:"",t=o.length>0?`The user hasn't granted permissions for the following targets: ${o.join(", ")}. `:"";Vt().warn(`${e}${t}We'll be watching for the following targets instead: "${i.join(", ")}"`)}return Vt().debug(`Watching these targets: "${i.join(", ")}"`),i})({targets:e.targets}),r=new lt,n=await Ro(),o=null==t?void 0:t.reduce(((e,t)=>{const r=Wo(t);return r&&e.push(r),e}),[]);let i=Fo(n,{excludeDefault:!0,targets:o});return Io().addEventListener("devicechange",(async()=>{const e=await Ro(),t=i,n=Fo(e,{excludeDefault:!0,targets:o});i=n;const s=((e,t)=>{const r=Ko(e),n=Ko(e),o=[];Vt().debug("[_getDeviceListDiff] <- oldDevices",e),Vt().debug("[_getDeviceListDiff] -> newDevices",t);const i=t.filter((e=>{const t=e.deviceId,i=r.get(t);return i&&(n.delete(t),e.label!==i.label&&o.push(e)),void 0===i}));return{updated:o.map((e=>({type:"updated",payload:e}))),removed:Array.from(n,(([e,t])=>t)).map((e=>({type:"removed",payload:e}))),added:i.map((e=>({type:"added",payload:e})))}})(t,n),a=s.added.length>0,c=s.removed.length>0,u=s.updated.length>0;(a||c||u)&&r.emit("changed",{changes:s,devices:n}),a&&r.emit("added",{changes:s.added,devices:n}),c&&r.emit("removed",{changes:s.removed,devices:n}),u&&r.emit("updated",{changes:s.updated,devices:n})})),r},ei=async e=>{Vt().info("RTCService.getUserMedia",e);const{audio:t,video:r}=e;if(t||r)try{return await Oo(e)}catch(e){throw Vt().error("getUserMedia error: ",e),e}},ti=async e=>{let{audio:t=!0,micId:r}=e;const{micLabel:n=""}=e;if(r){const e=await Qo(r,n,"microphone").catch((e=>null));e&&("boolean"==typeof t&&(t={}),t.deviceId={exact:e})}let{video:o=!1,camId:i}=e;const{camLabel:s=""}=e;if(i){const e=await Qo(i,s,"camera").catch((e=>null));e&&("boolean"==typeof o&&(o={}),o.deviceId={exact:e})}return{audio:t,video:o}},ri=e=>/^m=audio/.test(e),ni=e=>/^m=video/.test(e),oi=e=>{const t=e.split("\r\n"),r=t.findIndex((e=>/^a=rtpmap/.test(e)&&/opus\/48000/.test(e)));if(r<0)return e;const n=(e=>{const t=new RegExp("a=rtpmap:(\\d+) \\w+\\/\\d+"),r=e.match(t);return r&&2==r.length?r[1]:null})(t[r]),o=new RegExp(`a=fmtp:${n}`),i=t.findIndex((e=>o.test(e)));return i>=0?/stereo=1;/.test(t[i])||(t[i]+="; stereo=1; sprop-stereo=1"):t[r]+=`\r\na=fmtp:${n} stereo=1; sprop-stereo=1`,t.join("\r\n")};class ii{constructor(e,t){this.call=e,this.type=t,this._negotiating=!1,this.options=e.options,this.logger.debug("New Peer with type:",this.type,"Options:",this.options),this._onIce=this._onIce.bind(this)}get logger(){return Vt()}get isOffer(){return"offer"===this.type}get isAnswer(){return"answer"===this.type}get isSimulcast(){return!0===this.options.simulcast}get isSfu(){return!0===this.options.sfu}get localVideoTrack(){const e=this._getSenderByKind("video");return(null==e?void 0:e.track)||null}get localAudioTrack(){const e=this._getSenderByKind("audio");return(null==e?void 0:e.track)||null}get hasAudioSender(){return!!this._getSenderByKind("audio")}get hasVideoSender(){return!!this._getSenderByKind("video")}get hasAudioReceiver(){return!!this._getReceiverByKind("audio")}get hasVideoReceiver(){return!!this._getReceiverByKind("video")}get config(){const{rtcPeerConfig:e={}}=this.options,t=Object.assign({bundlePolicy:"max-compat",iceServers:this.call.iceServers,sdpSemantics:"unified-plan"},e);return this.logger.debug("RTC config",t),t}get localSdp(){var e,t;return null===(t=null===(e=this.instance)||void 0===e?void 0:e.localDescription)||void 0===t?void 0:t.sdp}stopTrackSender(e){var t,r;try{const n=this._getSenderByKind(e);if(!n)return this.logger.info(`There is not a '${e}' sender to stop.`);n.track&&(No(n.track),null===(r=null===(t=this.options)||void 0===t?void 0:t.localStream)||void 0===r||r.removeTrack(n.track))}catch(t){this.logger.error("RTCPeer stopTrackSender error",e,t)}}async restoreTrackSender(e){var t,r;try{const n=this._getSenderByKind(e);if(!n)return this.logger.info(`There is not a '${e}' sender to restore.`);if(n.track&&"ended"!==n.track.readyState)return this.logger.info(`There is already an active ${e} track.`);const o=await ti(this.options),i=await ei({[e]:o[e]});if(i&&xo(i)){const o=i.getTracks().find((t=>t.kind===e));o&&(await n.replaceTrack(o),null===(r=null===(t=this.options)||void 0===t?void 0:t.localStream)||void 0===r||r.addTrack(o))}}catch(t){this.logger.error("RTCPeer restoreTrackSender error",e,t)}}getDeviceId(e){try{const t=this._getSenderByKind(e);if(!t||!t.track)return null;const{deviceId:r=null}=t.track.getSettings();return r}catch(t){return this.logger.error("RTCPeer getDeviceId error",e,t),null}}getTrackSettings(e){try{const t=this._getSenderByKind(e);return t&&t.track?t.track.getSettings():null}catch(t){return this.logger.error("RTCPeer getTrackSettings error",e,t),null}}getDeviceLabel(e){try{const t=this._getSenderByKind(e);return t&&t.track?t.track.label:null}catch(t){return this.logger.error("RTCPeer getDeviceLabel error",e,t),null}}restartIceWithRelayOnly(){try{const e=this.instance.getConfiguration();if("relay"===e.iceTransportPolicy)return this.logger.warn("RTCPeer already with iceTransportPolicy relay only");const t=Object.assign(Object.assign({},e),{iceTransportPolicy:"relay"});this.instance.setConfiguration(t),this.instance.restartIce()}catch(e){this.logger.error("RTCPeer restartIce error",e)}}async applyMediaConstraints(e,t){try{const r=this._getSenderByKind(e);if(!r||!r.track)return this.logger.info("No sender to apply constraints",e,t);if("live"===r.track.readyState){const n=Object.assign(Object.assign({},r.track.getConstraints()),t),o=this.getDeviceId(e);o&&!this.options.screenShare&&(n.deviceId={exact:o}),this.logger.info(`Apply ${e} constraints`,this.call.id,n),await r.track.applyConstraints(n)}}catch(r){this.logger.error("Error applying constraints",e,t)}}_getSenderByKind(e){return this.instance.getSenders?this.instance.getSenders().find((({track:t})=>t&&t.kind===e)):(this.logger.warn("RTCPeerConnection.getSenders() not available."),null)}_getReceiverByKind(e){return this.instance.getReceivers?this.instance.getReceivers().find((({track:t})=>t&&t.kind===e)):(this.logger.warn("RTCPeerConnection.getReceivers() not available."),null)}async startNegotiation(e=!1){var t,r;if(this._negotiating)return this.logger.warn("Skip twice onnegotiationneeded!");this._negotiating=!0;try{if((this.options.additionalDevice||this.options.screenShare)&&(null===(r=(t=this.instance).getTransceivers)||void 0===r||r.call(t).forEach((e=>{e.direction="sendonly"}))),this.instance.removeEventListener("icecandidate",this._onIce),this.instance.addEventListener("icecandidate",this._onIce),this.isOffer){this.logger.debug("Trying to generate offer");const e=await this.instance.createOffer({voiceActivityDetection:!1});await this._setLocalDescription(e)}if(this.isAnswer){this.logger.debug("Trying to generate answer"),await this._setRemoteDescription({sdp:this.options.remoteSdp,type:"offer"});const e=await this.instance.createAnswer({voiceActivityDetection:!1});await this._setLocalDescription(e)}e&&this._sdpReady()}catch(e){this.logger.error(`Error creating ${this.type}:`,e)}}async onRemoteSdp(e){try{const t=this.isOffer?"answer":"offer";await this._setRemoteDescription({sdp:e,type:t}),this.isOffer&&this._resolveStartMethod()}catch(e){this.logger.error(`Error handling remote SDP on call ${this.call.id}:`,e),this.call.hangup(),this._rejectStartMethod(e)}}_setupRTCPeerConnection(){this.instance||(this.instance=new window.RTCPeerConnection(this.config),this._attachListeners())}async start(){return new Promise((async(e,t)=>{this._resolveStartMethod=e,this._rejectStartMethod=t;try{this.options.localStream=await this._retrieveLocalStream()}catch(e){return this.logger.error("Error retrieving a local stream",e),this._rejectStartMethod(e),this.call.setState("hangup")}this._setupRTCPeerConnection();const{localStream:r=null}=this.options;if(r&&xo(r)){const e=r.getAudioTracks();this.logger.debug("Local audio tracks: ",e);const t=r.getVideoTracks();if(this.logger.debug("Local video tracks: ",t),this.isOffer&&"function"==typeof this.instance.addTransceiver){e.forEach((e=>{this.instance.addTransceiver(e,{direction:"sendrecv",streams:[r]})}));const n={direction:"sendrecv",streams:[r]};if(this.isSimulcast&&(n.sendEncodings=["0","1","2"].map((e=>({active:!0,rid:e,scaleResolutionDownBy:6*Number(e)||1})))),this.logger.debug("Applying video transceiverParams",n),t.forEach((e=>{this.instance.addTransceiver(e,n)})),this.isSfu){const{msStreamsNumber:e=5}=this.options;this.logger.debug("Add ",e,"recvonly MS Streams"),n.direction="recvonly";for(let t=0;t<Number(e);t++)this.instance.addTransceiver("video",n)}}else"function"==typeof this.instance.addTrack?(e.forEach((e=>{this.instance.addTrack(e,r)})),t.forEach((e=>{this.instance.addTrack(e,r)}))):this.instance.addStream(r)}this.isOffer?(this.options.negotiateAudio&&this._checkMediaToNegotiate("audio"),this.options.negotiateVideo&&this._checkMediaToNegotiate("video")):this.startNegotiation()}))}_checkMediaToNegotiate(e){if(!this._getSenderByKind(e)&&this.instance.addTransceiver){const t=this.instance.addTransceiver(e,{direction:"recvonly"});this.logger.debug("Add transceiver",e,t)}}async _sdpReady(){if(clearTimeout(this._iceTimeout),this._iceTimeout=null,!this.instance.localDescription)return;const{sdp:e,type:t}=this.instance.localDescription;if(-1===e.indexOf("candidate"))return this.logger.debug("No candidate - retry \n"),void this.startNegotiation(!0);this.logger.debug("LOCAL SDP \n",`Type: ${t}`,"\n\n",e),this.instance.removeEventListener("icecandidate",this._onIce);try{await this.call.onLocalSDPReady(this.instance.localDescription)}catch(e){this._rejectStartMethod(e)}}_onIce(e){this._iceTimeout||(this._iceTimeout=setTimeout((()=>this._sdpReady()),this.options.iceGatheringTimeout)),e.candidate?(this.logger.debug("IceCandidate:",e.candidate),this.call.emit("icecandidate",e)):this._sdpReady()}_setLocalDescription(e){const{useStereo:t,googleMaxBitrate:r,googleMinBitrate:n,googleStartBitrate:o}=this.options;return e.sdp&&t&&(e.sdp=oi(e.sdp)),e.sdp&&r&&n&&o&&(e.sdp=((e,t,r,n)=>{const o=e.split("\r\n");return o.forEach(((e,i)=>{/^a=fmtp:\d*/.test(e)?o[i]+=`;x-google-max-bitrate=${t};x-google-min-bitrate=${r};x-google-start-bitrate=${n}`:/^a=mid:(1|video)/.test(e)&&(o[i]+=`\r\nb=AS:${t}`)})),o.join("\r\n")})(e.sdp,r,n,o)),this.logger.debug("LOCAL SDP \n",`Type: ${e.type}`,"\n\n",e.sdp),this.instance.setLocalDescription(e)}_setRemoteDescription(e){e.sdp&&this.options.useStereo&&(e.sdp=oi(e.sdp)),e.sdp&&this.instance.localDescription&&(e.sdp=((e,t)=>{const r="\r\n",n=this.instance.localDescription.sdp.split(r);if(n.findIndex(ri)<n.findIndex(ni))return e;const o=e.split(r),i=o.findIndex(ri),s=o.findIndex(ni),a=o.slice(i,s),c=o.slice(s,o.length-1);return[...o.slice(0,i),...c,...a,""].join(r)})(e.sdp));const t=e;return this.logger.debug("REMOTE SDP \n",`Type: ${e.type}`,"\n\n",e.sdp),this.instance.setRemoteDescription(t)}async _retrieveLocalStream(){if(xo(this.options.localStream))return this.options.localStream;const e=await ti(this.options);return ei(e)}_attachListeners(){this.instance.addEventListener("signalingstatechange",(()=>{switch(this.logger.debug("signalingState:",this.instance.signalingState),this.instance.signalingState){case"stable":this._negotiating=!1;break;case"closed":delete this.instance;break;default:this._negotiating=!0}})),this.instance.addEventListener("negotiationneeded",(()=>{this.logger.debug("Negotiation needed event"),this.startNegotiation()})),this.instance.addEventListener("iceconnectionstatechange",(()=>{this.logger.debug("iceConnectionState:",this.instance.iceConnectionState)})),this.instance.addEventListener("icegatheringstatechange",(()=>{this.logger.debug("iceGatheringState:",this.instance.iceGatheringState)})),this.instance.addEventListener("track",(e=>{this.call.emit("track",e),this.options.remoteStream=e.streams[0]})),this.instance.addEventListener("addstream",(e=>{e.stream&&(this.options.remoteStream=e.stream)}))}}const si={destinationNumber:"room",remoteCallerName:"Outbound Call",remoteCallerNumber:"",callerName:"",callerNumber:"",audio:!0,video:{aspectRatio:16/9},useStereo:!1,attach:!1,screenShare:!1,additionalDevice:!1,userVariables:{},requestTimeout:1e4,autoApplyMediaParams:!0,iceGatheringTimeout:2e3};class ai extends On{constructor(e){super(e),this.nodeId="",this.gotEarly=!1,this.doReinvite=!1,this._eventsPrefix="video",this.state="new",this.prevState="new",this.options=Object.assign(Object.assign({},si),e),this.setState("new"),this.logger.debug("New Call with Options:",this.options),this.applyEmitterTransforms({local:!0}),this.attachWorkers()}get id(){return this.__uuid}get active(){return"active"===this.state}get trying(){return"trying"===this.state}get memberId(){return this._memberId}get previewUrl(){return this._previewUrl}get roomId(){return this._roomId}get roomSessionId(){return this._roomSessionId}get localStream(){return this.options.localStream}get remoteStream(){return this.options.remoteStream}get iceServers(){var e,t;return null!==(t=null===(e=this.options)||void 0===e?void 0:e.iceServers)&&void 0!==t?t:this.select(Co.getIceServers)}get messagePayload(){const{destinationNumber:e,attach:t,callerName:r,callerNumber:n,remoteCallerName:o,remoteCallerNumber:i,userVariables:s,screenShare:a,additionalDevice:c}=this.options;return{sessid:this.options.sessionid,dialogParams:{id:this.__uuid,destinationNumber:e,attach:t,callerName:r,callerNumber:n,remoteCallerName:o,remoteCallerNumber:i,userVariables:s,screenShare:a,additionalDevice:c}}}get cameraId(){return this.peer?this.peer.getDeviceId("video"):null}get cameraLabel(){return this.peer?this.peer.getDeviceLabel("video"):null}get microphoneId(){return this.peer?this.peer.getDeviceId("audio"):null}get microphoneLabel(){return this.peer?this.peer.getDeviceLabel("audio"):null}get withAudio(){return!!this.remoteStream&&this.remoteStream.getAudioTracks().length>0}get withVideo(){return!!this.remoteStream&&this.remoteStream.getVideoTracks().length>0}get localVideoTrack(){return this.peer.localVideoTrack}get localAudioTrack(){return this.peer.localAudioTrack}vertoExecute(e){const t={message:e,node_id:this.nodeId};return"verto.invite"===e.method&&(t.subscribe=this.options.screenShare?["video.room.screenshare"]:this.options.additionalDevice?["video.room.additionaldevice"]:this.getSubscriptions()),this.execute({method:"video.message",params:t})}onStateChange(e){switch(this.logger.debug("onStateChange",e),e.state){case"hangup":this._hangup(e);break;default:this.setState(e.state)}}onRemoteSDP(e){this.logger.debug("onRemoteSDP",e),e.remoteSDP&&this.peer.onRemoteSdp(e.remoteSDP)}onRoomSubscribed(e){this.logger.debug("onRoomSubscribed",e),this.nodeId=e.nodeId,this._roomId=e.roomId,this._roomSessionId=e.roomSessionId,this._memberId=e.memberId,this._previewUrl=e.previewUrl,this._attachListeners(this.options.additionalDevice||this.options.screenShare?e.memberId:e.roomSessionId),this.applyEmitterTransforms()}onVideoConstraints(e){this.logger.debug("onVideoConstraints",e),(null==e?void 0:e.videoConstraints)&&this.peer.applyMediaConstraints("video",e.videoConstraints)}onAudioConstraints(e){this.logger.debug("onAudioConstraints",e),(null==e?void 0:e.audioConstraints)&&this.peer.applyMediaConstraints("audio",e.audioConstraints)}updateCamera(e){return this.updateConstraints({video:Object.assign({aspectRatio:16/9},e)})}updateMicrophone(e){return this.updateConstraints({audio:e})}manageSendersWithConstraints(e){return!1===e.audio&&(this.logger.info("Switching off the microphone"),this.stopOutboundAudio()),!1===e.video&&(this.logger.info("Switching off the camera"),this.stopOutboundVideo()),e.audio||e.video}updateConstraints(e){return new Promise((async(t,r)=>{try{if(this.logger.debug("updateConstraints trying constraints",this.__uuid,e),!Object.keys(e).length)return this.logger.warn("Invalid constraints:",e);if(!this.manageSendersWithConstraints(e))return void this.logger.debug("Either `video` and `audio` (or both) constraints were set to `false` so their corresponding senders (if any) were stopped");const r=await Oo(e);this.logger.debug("updateConstraints got stream",r),this.options.localStream||(this.options.localStream=new MediaStream);const{instance:n}=this.peer,o=r.getTracks();for(let e=0;e<o.length;e++){const t=o[e];this.logger.debug("updateConstraints apply track: ",t);const r=n.getTransceivers().find((({mid:e,sender:r,receiver:n})=>r.track&&r.track.kind===t.kind?(this.logger.debug("Found transceiver by sender"),!0):n.track&&n.track.kind===t.kind?(this.logger.debug("Found transceiver by receiver"),!0):null===e&&(this.logger.debug("Found disassociated transceiver"),!0)));r&&r.sender?(this.logger.debug("updateConstraints FOUND - replaceTrack on it and on localStream"),await r.sender.replaceTrack(t),this.logger.debug("updateConstraints replaceTrack SUCCESS"),this.options.localStream.getTracks().forEach((e=>{var r;e.kind===t.kind&&e.id!==t.id&&(this.logger.debug("updateConstraints stop old track and apply new one - "),No(e),null===(r=this.options.localStream)||void 0===r||r.removeTrack(e))})),this.options.localStream.addTrack(t)):(this.logger.debug("updateConstraints NOT FOUND - addTrack and start dancing!"),this.peer.type="offer",this.doReinvite=!0,this.options.localStream.addTrack(t),n.addTrack(t,this.options.localStream)),this.logger.debug("updateConstraints Simply update mic/cam"),"audio"===t.kind?this.options.micId=t.getSettings().deviceId:"video"===t.kind&&(this.options.camId=t.getSettings().deviceId)}this.logger.debug("updateConstraints done!"),t()}catch(e){this.logger.error("updateConstraints",e),r(e)}}))}invite(){return new Promise((async(e,t)=>{this.direction="outbound",this.peer=new ii(this,"offer");try{await this.peer.start(),e(this)}catch(e){this.logger.error("Invite error",e),t(e)}}))}answer(){return new Promise((async(e,t)=>{this.direction="inbound",this.peer=new ii(this,"answer");try{await this.peer.start(),e(this)}catch(e){this.logger.error("Answer error",e),t(e)}}))}onLocalSDPReady(e){const{type:t,sdp:r}=e,n=this._mungeSDP(r);switch(this.logger.debug("MUNGED SDP \n",`Type: ${t}`,"\n\n",n),t){case"offer":return this.executeInvite(n);case"answer":this.logger.warn("Unhandled verto.answer");break;default:return this.logger.error(`Unknown SDP type: '${t}' on call ${this.id}`)}}async executeInvite(e){this.setState("requesting");try{const t=lr(Object.assign(Object.assign({},this.messagePayload),{sdp:e})),r=await this.vertoExecute(t);this.logger.debug("Invite response",r)}catch(e){throw this.setState("hangup"),e.jsonrpc}}async hangup(){try{const e=hr(this.messagePayload);await this.vertoExecute(e)}catch(e){this.logger.error("Hangup error:",e)}finally{this._hangup()}}dtmf(e){const t=pr(Object.assign(Object.assign({},this.messagePayload),{dtmf:e}));this.vertoExecute(t)}doReinviteWithRelayOnly(){this.peer&&this.active&&this.peer.restartIceWithRelayOnly()}stopOutboundAudio(){this.peer&&this.active&&this.peer.stopTrackSender("audio")}restoreOutboundAudio(){this.peer&&this.active&&this.peer.restoreTrackSender("audio")}stopOutboundVideo(){this.peer&&this.active&&this.peer.stopTrackSender("video")}restoreOutboundVideo(){this.peer&&this.active&&this.peer.restoreTrackSender("video")}setState(e){switch(this.prevState=this.state,this.state=e,this.logger.debug(`Call ${this.id} state change from ${this.prevState} to ${this.state}`),this.emit(this.state,this),e){case"purge":this._finalize();break;case"hangup":this.setState("destroy");break;case"destroy":this._finalize()}}_hangup(e={}){const{byeCause:t="NORMAL_CLEARING",byeCauseCode:r="16",redirectDestination:n}=e;return this.cause=t,this.causeCode=r,n&&this.peer.localSdp?(this.logger.debug("Redirect Destination to:",n),this.nodeId=n,this.executeInvite(this.peer.localSdp)):this.setState("hangup")}_mungeSDP(e){return e}_finalize(){this.peer&&this.peer.instance&&(this.peer.instance.close(),delete this.peer);const{remoteStream:e,localStream:t}=this.options;Do(e),Do(t),this.destroy()}}const ci=e=>`sw-sdk-${e}`,ui=()=>{const e=document.createElement("video");return e.muted=!0,e.autoplay=!0,e.playsInline=!0,e},di=({x:e,y:t,width:r,height:n})=>({top:`${t}%`,left:`${e}%`,width:`${r}%`,height:`${n}%`}),li=e=>t=>{const r=document.getElementById(ci(t));r&&(r.style.display=e)},hi=fr.createAction("swJs/audioSetSpeakerAction");function*pi({element:e,room:t}){const r=fr.getCustomSagaActionType(t.__uuid,hi);for(;;){const n=yield Se([r]);try{switch(n.type){case r:const o=yield Ee(jo,e,n.payload);t.settleCustomSagaTrigger({dispatchId:n.dispatchId,payload:o,kind:"resolve"})}}catch(e){t.settleCustomSagaTrigger({dispatchId:n.dispatchId,payload:e,kind:"reject"}),Vt().error(e)}}}function*mi({track:e,element:t,speakerId:r,room:n}){(({track:e,element:t})=>{t.autoplay=!0,t.playsinline=!0,t.srcObject=new MediaStream([e]),e.addEventListener("ended",(()=>{t.srcObject=null,t.remove()}))})({track:e,element:t}),r&&jo(t,r).catch((()=>{})),yield Ce(pi,{element:t,room:n})}function*fi({rootElement:e,applyLocalVideoOverlay:t=!0,track:r,element:n}){(r=>{if((({track:e,element:t})=>{t.srcObject=new MediaStream([e]),e.addEventListener("ended",(()=>{t.srcObject=null,t.remove()}))})({element:n,track:r}),n.style.width="100%",!t)return void e.appendChild(n);const o=document.createElement("div");o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.right="0",o.style.bottom="0",o.appendChild(n);const i=document.createElement("div");i.style.paddingBottom="56.25%",i.appendChild(o);const s=document.createElement("div");s.classList.add("mcuLayers"),i.appendChild(s);const a=document.createElement("div");a.style.position="relative",a.style.width="100%",a.style.margin="0 auto",a.appendChild(i),e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",e.appendChild(a)})(r)}const gi={state:"onStateChange",remoteSDP:"onRemoteSDP",roomId:"onRoomSubscribed",videoConstraints:"onVideoConstraints",audioConstraints:"onAudioConstraints",errors:"onError",responses:"onSuccess"},vi={echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,googAutoGainControl:!1},yi=Qt(class extends ai{join(){return super.invite()}leave(){return super.hangup()}},{audioMute:xn.audioMuteMember,audioUnmute:xn.audioUnmuteMember,videoMute:xn.videoMuteMember,videoUnmute:xn.videoUnmuteMember,setMicrophoneVolume:xn.setInputVolumeMember,setInputVolume:xn.setInputVolumeMember,setInputSensitivity:xn.setInputSensitivityMember}),bi=Qt(class extends ai{join(){return super.invite()}leave(){return super.hangup()}},{audioMute:xn.audioMuteMember,audioUnmute:xn.audioUnmuteMember,videoMute:xn.videoMuteMember,videoUnmute:xn.videoUnmuteMember,setInputVolume:xn.setInputVolumeMember,setMicrophoneVolume:xn.setInputVolumeMember,setInputSensitivity:xn.setInputSensitivityMember}),_i=()=>{},Si="video.memberList.updated",wi=Bt({event:Si}),ki=(e=>{const t=e.split(".")[0];return e.split(".").reduce(((e,r)=>(e.push(r),r===t&&e.push(Ot),e)),[]).join(".")})(wi),Ei=["video.room.joined","video.member.joined","video.member.left","video.member.updated"];function*Ci({pubSubChannel:e}){const t=new Map;function*r(r){const{payload:n}=r,o=(({action:e,memberList:t})=>{const r=(e=>"video.room.joined"===e.type?e.payload.room_session.members:[e.payload.member])(e);switch(e.type){case"video.member.left":r.forEach((e=>{t.delete(e.id)}));break;default:r.forEach((e=>{t.set(e.id,e)}))}return Array.from(t.values())})({action:r,memberList:t}),i={room_session_id:n.room_session_id||n.room_session.id,members:o};yield we(e,{type:ki,payload:i})}for(;;){const t=yield Se(e,(({type:e})=>Ei.includes(e)));yield Ce(r,t)}}const Ti=function*({channels:{pubSubChannel:e},instance:t}){const r=t.getSubscriptions();if(!(e=>e.some((e=>e.includes(wi))))(r))return;const{cleanup:n}=((e,t)=>{(e=>tr(Ei).filter((t=>!e.includes(t))))(t).forEach((t=>{e.once(t,_i)}));const r=t=>{e.emit(Si,t)};return e.on(ki,r),{cleanup:()=>{e.off(ki,r)}}})(t,r);yield Ce(Ci,{pubSubChannel:e}),t.once("destroy",(()=>{n()}))},Ii=Qt(class extends ai{_screenShareList=new Set;_deviceList=new Set;get screenShareList(){return Array.from(this._screenShareList)}get deviceList(){return Array.from(this._deviceList)}getEmitterTransforms(){return new Map([[[nr("video.recording.start"),"video.recording.started","video.recording.updated","video.recording.ended"],{type:"roomSessionRecording",instanceFactory:e=>xn.createRoomSessionRecordingObject({store:this.store,emitter:this.emitter}),payloadTransform:e=>Ut({...e.recording,room_session_id:this.roomSessionId})}],[[nr("video.playback.start"),"video.playback.started","video.playback.updated","video.playback.ended"],{type:"roomSessionPlayback",instanceFactory:e=>xn.createRoomSessionPlaybackObject({store:this.store,emitter:this.emitter}),payloadTransform:e=>Ut({...e.playback,room_session_id:this.roomSessionId})}]])}attachPreConnectWorkers(){this.setWorker("memberListUpdated",{worker:Ti}),this.attachWorkers()}async createScreenShareObject(e={}){return this.startScreenShare(e)}async startScreenShare(e={}){const{autoJoin:t=!0,audio:r=!1,video:n=!0}=e,o=await Mo({audio:!0===r?vi:r,video:n}),i={...this.options,screenShare:!0,recoverCall:!1,localStream:o,remoteStream:void 0,userVariables:{...this.options?.userVariables||{},memberCallId:this.__uuid,memberId:this.memberId}},s=Cn({store:this.store,Component:yi,componentListeners:gi})(i);o.getVideoTracks().forEach((e=>{e.addEventListener("ended",(()=>{s&&s.active&&s.leave()}))})),s.on("destroy",(()=>{this._screenShareList.delete(s)}));try{return this._screenShareList.add(s),t&&await s.join(),s}catch(e){throw this.logger.error("ScreenShare Error",e),e}}addCamera(e={}){const{autoJoin:t=!0,...r}=e;return this.addDevice({autoJoin:t,video:r})}addMicrophone(e={}){const{autoJoin:t=!0,...r}=e;return this.addDevice({autoJoin:t,audio:r})}async addDevice(e={}){const{autoJoin:t=!0,audio:r=!1,video:n=!1}=e;if(!r&&!n)throw new TypeError("At least one of `audio` or `video` must be requested.");const o={...this.options,localStream:void 0,remoteStream:void 0,audio:r,video:n,additionalDevice:!0,recoverCall:!1,userVariables:{...this.options?.userVariables||{},memberCallId:this.__uuid,memberId:this.memberId}},i=Cn({store:this.store,Component:bi,componentListeners:gi})(o);i.on("destroy",(()=>{this._deviceList.delete(i)}));try{return this._deviceList.add(i),t&&await i.join(),i}catch(e){throw this.logger.error("RoomDevice Error",e),e}}join(){return super.invite()}leave(){return this.hangup()}updateSpeaker({deviceId:e}){return this.triggerCustomSaga(hi(e))}async hangup(){return this._screenShareList.forEach((e=>{e.leave()})),this._deviceList.forEach((e=>{e.leave()})),super.hangup()}_finalize(){this._screenShareList.clear(),this._deviceList.clear(),super._finalize()}getLayoutList(){return this.getLayouts()}getMemberList(){return this.getMembers()}},{audioMute:xn.audioMuteMember,audioUnmute:xn.audioUnmuteMember,videoMute:xn.videoMuteMember,videoUnmute:xn.videoUnmuteMember,deaf:xn.deafMember,undeaf:xn.undeafMember,setInputVolume:xn.setInputVolumeMember,setOutputVolume:xn.setOutputVolumeMember,setMicrophoneVolume:xn.setInputVolumeMember,setSpeakerVolume:xn.setOutputVolumeMember,setInputSensitivity:xn.setInputSensitivityMember,removeMember:xn.removeMember,getMembers:xn.getMembers,getLayouts:xn.getLayouts,setLayout:xn.setLayout,hideVideoMuted:xn.hideVideoMuted,showVideoMuted:xn.showVideoMuted,getRecordings:xn.getRecordings,startRecording:xn.startRecording,getPlaybacks:xn.getPlaybacks,play:xn.play,setHideVideoMuted:xn.setHideVideoMuted});class Oi extends Rn{_eventsPrefix="cantina-manager";getEmitterTransforms(){return new Map([[["cantina-manager.rooms.subscribed"],{type:"roomSession",instanceFactory:({rooms:e})=>({rooms:e.map((e=>Ut(e)))}),payloadTransform:({rooms:e})=>({rooms:e.map((e=>Ut(e)))})}],[["cantina-manager.room.started","cantina-manager.room.added","cantina-manager.room.updated","cantina-manager.room.ended","cantina-manager.room.deleted"],{type:"roomSession",instanceFactory:e=>Ut(e),payloadTransform:e=>Ut(e)}]])}}class Mi extends Mn{_cantina;_chat;get rooms(){return{makeRoomObject:e=>{const{rootElement:t,applyLocalVideoOverlay:r=!0,stopCameraWhileMuted:n=!0,stopMicrophoneWhileMuted:o=!0,...i}=e,s=[];s.push((({speakerId:e})=>function*({instance:t,runSaga:r}){try{const n=new Audio;let o;const i=function(s){switch(s.track.kind){case"audio":o=r(mi,{track:s.track,element:n,speakerId:e,room:t}),t.off("track",i)}};t.on("track",i),t.once("destroy",(()=>{o?.cancel()}))}catch(e){Vt().error("audioElementSaga",e)}})({speakerId:i.speakerId})),t&&s.push((({rootElement:e,applyLocalVideoOverlay:t})=>function*({instance:r,runSaga:n}){try{const o=new Map,i=ui(),s=(({layerMap:e,element:t,rootElement:r})=>async({layout:n,myMemberId:o,localStream:i})=>{try{const{layers:s=[]}=n,a=s.find((({member_id:e})=>e===o)),c=ci(o);let u=e.get(c);if(!a)return void(u&&(Vt().debug("Current layer not visible"),u.style.display="none"));if(!u){u=await(async({location:e,element:t})=>{t.readyState===HTMLMediaElement.HAVE_NOTHING&&await(({element:e})=>new Promise((t=>{e.addEventListener("canplay",(function r(){e.removeEventListener("canplay",r),t()})),e.addEventListener("resize",(function r(){e.removeEventListener("resize",r),t()}))})))({element:t});const{top:r,left:n,width:o,height:i}=di(e),s=document.createElement("div");return s.style.position="absolute",s.style.overflow="hidden",s.style.top=r,s.style.left=n,s.style.width=o,s.style.height=i,s})({element:t,location:a}),u.id=c;const n=ui();n.srcObject=i,n.style.width="100%",n.style.height="100%",u.appendChild(n);const o=r.querySelector(".mcuLayers"),s=document.getElementById(c);return void(o&&!s&&(o.appendChild(u),e.set(c,u)))}const{top:d,left:l,width:h,height:p}=di(a);u.style.display="block",u.style.top=d,u.style.left=l,u.style.width=h,u.style.height=p}catch(e){Vt().error("Layout Changed Error",e)}})({rootElement:e,element:i,layerMap:o}),a=li("none"),c=li("block");let u;r.on("layout.changed",(e=>{r.peer.hasVideoSender&&r.localStream&&s({layout:e.layout,localStream:r.localStream,myMemberId:r.memberId})})),r.on("member.updated.video_muted",(e=>{try{const{member:t}=e;t.id===r.memberId&&"video_muted"in t&&(t.video_muted?a(t.id):c(t.id))}catch(e){Vt().error("Error handling video_muted",e)}}));const d=function(o){switch(o.track.kind){case"video":u=n(fi,{applyLocalVideoOverlay:t,rootElement:e,track:o.track,element:i}),r.off("track",d)}};r.on("track",d),r.once("destroy",(()=>{(e=>{for(;e.firstChild;)e.removeChild(e.firstChild)})(e),o.clear(),u?.cancel()}))}catch(e){Vt().error("videoElementSaga",e)}})({rootElement:t,applyLocalVideoOverlay:r}));const a=(c={...i,store:this.store,emitter:this.emitter,customSagas:s},Cn({store:c.store,customSagas:c.customSagas,Component:Ii,componentListeners:gi})(c));var c;return o&&a.on("member.updated.audio_muted",(({member:e})=>{try{e.id===a.memberId&&"audio_muted"in e&&(e.audio_muted?a.stopOutboundAudio():a.restoreOutboundAudio())}catch(e){this.logger.error("Error handling audio_muted",e)}})),n&&a.on("member.updated.video_muted",(({member:e})=>{try{e.id===a.memberId&&"video_muted"in e&&(e.video_muted?a.stopOutboundVideo():a.restoreOutboundVideo())}catch(e){this.logger.error("Error handling video_muted",e)}})),a}}}get chat(){return this._chat||(this._chat=co.createBaseChatObject({store:this.store,emitter:this.options.emitter})),this._chat}get cantina(){return this._cantina||(this._cantina=(e=>{const t=Cn({store:e.store,Component:Oi,componentListeners:{errors:"onError",responses:"onSuccess"}})(e);return new Proxy(t,{get:(e,t,r)=>"_eventsNamespace"===t?"":"eventChannel"===t?"cantina-manager.rooms":Reflect.get(e,t,r)})})(this.options)),this._cantina}reauthenticate(e){this.store.dispatch(fr.reauthAction({token:e}))}}class Ri extends class extends class{constructor(e){var t,r;this.options=e,Tt(this,"uuid",l()),Tt(this,"WebSocketConstructor"),Tt(this,"agent"),Tt(this,"connectVersion",sr),Tt(this,"_rpcConnectResult"),Tt(this,"_requests",new Map),Tt(this,"_socket",null),Tt(this,"_host","wss://relay.signalwire.com"),Tt(this,"_executeTimeoutMs",1e4),Tt(this,"_executeTimeoutError",Symbol.for("sw-execute-timeout")),Tt(this,"_checkPingDelay",15e3),Tt(this,"_checkPingTimer",null),Tt(this,"_status","unknown");const{host:n,logLevel:o="info"}=e;n&&(this._host=(e=>`${Yt.test(e)?"":"wss://"}${e}`)(n)),o&&(null==(r=(t=this.logger).setLevel)||r.call(t,o)),this._onSocketOpen=this._onSocketOpen.bind(this),this._onSocketError=this._onSocketError.bind(this),this._onSocketClose=this._onSocketClose.bind(this),this._onSocketMessage=this._onSocketMessage.bind(this),this.execute=this.execute.bind(this),this.connect=this.connect.bind(this)}get host(){return this._host}get rpcConnectResult(){return this._rpcConnectResult}get relayProtocol(){var e,t;return null!=(t=null==(e=this._rpcConnectResult)?void 0:e.protocol)?t:""}get signature(){var e,t;return null==(t=null==(e=this._rpcConnectResult)?void 0:e.authorization)?void 0:t.signature}get logger(){return Vt()}get connecting(){var e;return 0===(null==(e=this._socket)?void 0:e.readyState)}get connected(){var e;return 1===(null==(e=this._socket)?void 0:e.readyState)}get closing(){var e;return 2===(null==(e=this._socket)?void 0:e.readyState)}get closed(){return!this._socket||3===this._socket.readyState}get status(){return this._status}set token(e){this.options.token=e}connect(){(null==this?void 0:this.WebSocketConstructor)?this._socket?this.logger.warn("Session already connected."):(this._socket=this._createSocket(),this._socket.addEventListener("open",this._onSocketOpen),this._socket.addEventListener("close",this._onSocketClose),this._socket.addEventListener("error",this._onSocketError),this._socket.addEventListener("message",this._onSocketMessage)):this.logger.error("Missing WebSocketConstructor")}_createSocket(){return new this.WebSocketConstructor(this._host)}async disconnect(){this._socket&&!this.closing?(clearTimeout(this._checkPingTimer),this._requests.clear(),this._closeConnection("disconnected")):this.logger.warn("Session not connected or already in closing state.")}execute(e){if("idle"===this._status||!this.connected)return Promise.reject("Can't call `execute` when Session is not authorized.");let t;return t="params"in e?new Promise(((t,r)=>{this._requests.set(e.id,{rpcRequest:e,resolve:t,reject:r})})):Promise.resolve(),this.logger.wsTraffic({type:"send",payload:e}),this._socket.send(this.encode(e)),((e,t,r)=>{let n=null;return Promise.race([e,new Promise(((e,o)=>n=setTimeout(o,t,r)))]).finally((()=>clearTimeout(n)))})(t,this._executeTimeoutMs,this._executeTimeoutError).catch((t=>{if(t!==this._executeTimeoutError)throw t;this.logger.error("Request Timeout",e),this._closeConnection("reconnecting")}))}async authenticate(){const e={agent:this.agent,version:this.connectVersion,authentication:{project:this.options.project,token:this.options.token}};this._relayProtocolIsValid()&&(e.protocol=this.relayProtocol),this._rpcConnectResult=await this.execute(ar(e))}async _onSocketOpen(e){this.logger.debug("_onSocketOpen",e.type);try{await this.authenticate(),this._status="connected",this.dispatch(Tr())}catch(e){this.logger.error("Auth Error",e),this.dispatch(Cr({error:e}))}}_onSocketError(e){this.logger.debug("_onSocketError",e),this.dispatch(Or())}_onSocketClose(e){this.logger.debug("_onSocketClose",e.type,e.code,e.reason),this._status=e.code>=1006&&e.code<=1014?"reconnecting":"disconnected",this.dispatch(Ir()),this._socket=null}_onSocketMessage(e){const t=this.decode(e.data);if(this.logger.wsTraffic({type:"recv",payload:t}),!Boolean(t.method)){const e=this._requests.get(t.id);if(e){const{rpcRequest:r,resolve:n,reject:o}=e;this._requests.delete(t.id);const{result:i,error:s}=(({response:e,request:t})=>{const{result:r={},error:n}=e;if(n)return{error:n};switch(t.method){case"signalwire.connect":return{result:r};default:return Wt(e)}})({response:t,request:r});return s?o(s):n(i)}return this.logger.warn("Unknown request for",t)}var r;switch(t.method){case"signalwire.ping":case"blade.ping":return this._pingHandler(t);case"signalwire.disconnect":this.execute((r=t.id,ir({id:r,result:{}}))).catch((e=>{this.logger.error("SwDisconnect Error",e)})).finally((()=>{this._status="idle"}));break;default:this.dispatch(Mr(t)),this._handleWebSocketMessage(t)}}_handleWebSocketMessage(e){}dispatch(e){throw new Error("Method not implemented")}_relayProtocolIsValid(){var e;return this.signature&&(null==(e=null==this?void 0:this.relayProtocol)?void 0:e.split("_")[1])===this.signature}encode(e){return JSON.stringify(e)}decode(e){return Xt(e)}async _pingHandler(e){var t,r,n;clearTimeout(this._checkPingTimer),this._checkPingTimer=setTimeout((()=>{this._closeConnection("reconnecting")}),this._checkPingDelay),await this.execute((r=e.id,n=null==(t=null==e?void 0:e.params)?void 0:t.timestamp,ir({id:r,result:{timestamp:n||Date.now()/1e3}})))}_closeConnection(e){this._status=e,this.dispatch($r.authStatus("unknown")),this.dispatch(wr()),this._socket&&(this._socket.close(),this._socket=null)}}{constructor(e){super(e),this.options=e,Tt(this,"_expiredDiffSeconds",0),Tt(this,"_refreshTokenNotificationDiff",120),Tt(this,"_checkTokenExpirationDelay",2e4),Tt(this,"_checkTokenExpirationTimer",null),this._checkTokenExpiration=this._checkTokenExpiration.bind(this),this.reauthenticate=this.reauthenticate.bind(this)}get expiresAt(){var e,t,r;return null!=(r=null==(t=null==(e=null==this?void 0:this._rpcConnectResult)?void 0:e.authorization)?void 0:t.expires_at)?r:0}get expiresIn(){const e=Math.floor(Date.now()/1e3);return this.expiresAt-e}get expired(){return this.expiresIn<=this._expiredDiffSeconds}async authenticate(){const e={agent:this.agent,version:this.connectVersion,authentication:{jwt_token:this.options.token}};if(this._relayProtocolIsValid())e.protocol=this.relayProtocol;else if(this.signature){const r=await(t=this.signature,(async(e,t)=>{if("undefined"==typeof window&&"undefined"!=typeof process)return null;const r=window.sessionStorage.getItem((e=>`@signalwire:${e}`)(t));return Xt(r)})(0,t));r&&(e.protocol=r)}var t;this._rpcConnectResult=await this.execute(ar(e)),this._checkTokenExpiration()}async reauthenticate(){if(this.expired)return this.connect();const e={project:this._rpcConnectResult.authorization.project,jwt_token:this.options.token};try{this._rpcConnectResult=await this.execute((t=e,or({method:"signalwire.reauthenticate",params:{authentication:t}})))}catch(e){throw clearTimeout(this._checkTokenExpirationTimer),e}var t}_checkTokenExpiration(){this.expiresAt&&(this.expiresIn<=this._refreshTokenNotificationDiff&&(this.options._onRefreshToken?this.options._onRefreshToken():this.logger.warn("The token is going to expire!")),clearTimeout(this._checkTokenExpirationTimer),this.expired||(this._checkTokenExpirationTimer=setTimeout(this._checkTokenExpiration,this._checkTokenExpirationDelay)))}}{WebSocketConstructor=WebSocket;agent="@signalwire/js/3.8.0-dev.202202021245.c33a456.0"}const Pi=e=>{const t={...e,emitter:new lt},r=Tn({userOptions:t,SessionConstructor:Ri});return Cn({store:r,Component:Mi,componentListeners:{errors:"onError",responses:"onSuccess"}})(t)},Ai={aspectRatio:{ideal:16/9}},xi=e=>new Promise((async(t,r)=>{const{audio:n=!0,video:o=!0,iceServers:i,rootElementId:s,applyLocalVideoOverlay:a=!0,autoJoin:c=!1,stopCameraWhileMuted:u=!0,stopMicrophoneWhileMuted:d=!0,speakerId:l,...h}=e,p=Pi({...h});if(await p.connect(),!p)return;let m;if(s){const e=document.getElementById(s);e?m=e:(m=document.body,Vt().warn(`We couldn't find an element with id: ${s}: using 'document.body' instead.`))}const f=p.rooms.makeRoomObject({audio:n,video:!0===o?Ai:o,negotiateAudio:!0,negotiateVideo:!0,iceServers:i,rootElement:m,applyLocalVideoOverlay:a,stopCameraWhileMuted:u,stopMicrophoneWhileMuted:d,speakerId:l});if(f.once("destroy",(()=>{p.disconnect()})),c)try{await f.join(),t(f)}catch(e){r(e)}else t(f)})),Li={aspectRatio:{ideal:16/9}},ji=["audioMute","audioUnmute","deaf","getLayouts","getMembers","getRecordings","hideVideoMuted","leave","removerMember","restoreOutboundAudio","restoreOutboundVideo","setInputSensitivity","setInputVolume","setLayout","setOutputVolume","showVideoMuted","startRecording","stopOutboundAudio","stopOutboundVideo","undeaf","videoMute","videoUnmute","setMicrophoneVolume","setSpeakerVolume"];var Di=Object.freeze({__proto__:null,RoomSession:function(e){const{audio:t=!0,video:r=!0,iceServers:n,rootElement:o,applyLocalVideoOverlay:i=!0,stopCameraWhileMuted:s=!0,stopMicrophoneWhileMuted:a=!0,speakerId:c,...u}=e,d=Pi(u),l=d.rooms.makeRoomObject({audio:t,video:!0===r?Li:r,negotiateAudio:!0,negotiateVideo:!0,iceServers:n,rootElement:o,applyLocalVideoOverlay:i,stopCameraWhileMuted:s,stopMicrophoneWhileMuted:a,speakerId:c});l.once("destroy",(()=>{d.disconnect()}));const h={join:()=>new Promise((async(e,t)=>{try{l.attachPreConnectWorkers(),await d.connect(),l.once("room.subscribed",(()=>{e(l)})),await l.join()}catch(e){Vt().error("RoomSession Join",e),t(e)}}))};return new Proxy(l,{get(e,t,r){if(t in h)return h[t];if(!e.active&&ji.includes(t))throw new Error(`Tried to access the property/method "${t}" before the room was connected. Please call roomSession.join() first.`);return Reflect.get(e,t,r)}})},createRoomObject:xi,joinRoom:e=>xi({...e,autoJoin:!0}),createClient:Pi}),Ni=Object.freeze({__proto__:null,getDevices:Ho,getCameraDevices:()=>Ho("camera"),getMicrophoneDevices:()=>Ho("microphone"),getSpeakerDevices:()=>Ho("speaker"),getDevicesWithPermissions:zo,getCameraDevicesWithPermissions:()=>zo("camera"),getMicrophoneDevicesWithPermissions:()=>zo("microphone"),getSpeakerDevicesWithPermissions:()=>zo("speaker"),checkPermissions:$o,checkCameraPermissions:Uo,checkMicrophonePermissions:qo,checkSpeakerPermissions:Bo,requestPermissions:async e=>{try{const t=await Oo(e);Do(t)}catch(e){throw e}},createDeviceWatcher:Zo,createCameraDeviceWatcher:()=>Zo({targets:["camera"]}),createMicrophoneDeviceWatcher:()=>Zo({targets:["microphone"]}),createSpeakerDeviceWatcher:()=>Zo({targets:["speaker"]}),supportsMediaDevices:To,supportsGetUserMedia:()=>{var e;return"function"==typeof(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia)},supportsGetDisplayMedia:()=>{var e;return"function"==typeof(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getDisplayMedia)},getUserMedia:Oo,getDisplayMedia:Mo,enumerateDevices:Ro,getSupportedConstraints:Ao,supportsMediaOutput:Lo,setMediaElementSinkId:jo,stopStream:Do,stopTrack:No}),Vi=Object.freeze({__proto__:null,Client:function(e){Vt().warn("`Chat` is still under development and may change in the future without prior notice.");const t=Pi(e),r=async e=>(await t.connect(),t.chat.subscribe(e)),n=async e=>(await t.connect(),t.chat.publish(e));return new Proxy(t.chat,{get:(e,t,o)=>"subscribe"===t?r:"publish"===t?n:Reflect.get(e,t,o)})}});e.Video=Di,e.WebRTC=Ni,e.__sw__Chat=Vi,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
7
7
|
//# sourceMappingURL=index.umd.js.map
|