softphone-vendor-headsets 1.0.0 → 1.0.1-develop.7
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/LICENSE +2 -2
- package/dist/cjs/src/library/services/headset.d.ts +1 -0
- package/dist/cjs/src/library/services/headset.js +16 -8
- package/dist/cjs/src/library/services/headset.js.map +1 -1
- package/dist/cjs/src/library/services/headset.test.js +4 -0
- package/dist/cjs/src/library/services/headset.test.js.map +1 -1
- package/dist/cjs/src/library/services/vendor-implementations/jabra/jabra.js +5 -2
- package/dist/cjs/src/library/services/vendor-implementations/jabra/jabra.js.map +1 -1
- package/dist/deploy-info.json +3 -3
- package/dist/es/src/library/services/headset.d.ts +1 -0
- package/dist/es/src/library/services/headset.js +16 -8
- package/dist/es/src/library/services/headset.js.map +1 -1
- package/dist/es/src/library/services/headset.test.js +4 -0
- package/dist/es/src/library/services/headset.test.js.map +1 -1
- package/dist/es/src/library/services/vendor-implementations/jabra/jabra.js +5 -2
- package/dist/es/src/library/services/vendor-implementations/jabra/jabra.js.map +1 -1
- package/dist/softhphone-vendor-headsets.js +1 -1
- package/dist/softhphone-vendor-headsets.js.map +1 -1
- package/package.json +90 -88
|
@@ -66,7 +66,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
66
66
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
67
67
|
PERFORMANCE OF THIS SOFTWARE.
|
|
68
68
|
***************************************************************************** */
|
|
69
|
-
var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}Object.create;function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function a(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e}Object.create;function c(e){return"function"==typeof e}function u(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var l=u((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function f(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var h=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._teardowns=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var f=o(u),h=f.next();!h.done;h=f.next()){h.value.remove(this)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}else u.remove(this);var d=this.initialTeardown;if(c(d))try{d()}catch(e){i=e instanceof l?e.errors:[e]}var p=this._teardowns;if(p){this._teardowns=null;try{for(var g=o(p),y=g.next();!y.done;y=g.next()){var m=y.value;try{v(m)}catch(e){i=null!=i?i:[],e instanceof l?i=a(a([],s(i)),s(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=g.return)&&r.call(g)}finally{if(n)throw n.error}}}if(i)throw new l(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)v(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._teardowns=null!==(n=this._teardowns)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&f(t,e)},e.prototype.remove=function(t){var n=this._teardowns;n&&f(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),d=h.EMPTY;function p(e){return e instanceof h||e&&"closed"in e&&c(e.remove)&&c(e.add)&&c(e.unsubscribe)}function v(e){c(e)?e():e.unsubscribe()}var g={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},y={setTimeout:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=y.delegate;return((null==n?void 0:n.setTimeout)||setTimeout).apply(void 0,a([],s(e)))},clearTimeout:function(e){var t=y.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function m(e){y.setTimeout((function(){var t=g.onUnhandledError;if(!t)throw e;t(e)}))}function b(){}var E=w("C",void 0,void 0);function w(e,t,n){return{kind:e,value:t,error:n}}var _=null;function C(e){if(g.useDeprecatedSynchronousErrorHandling){var t=!_;if(t&&(_={errorThrown:!1,error:null}),e(),t){var n=_,r=n.errorThrown,i=n.error;if(_=null,r)throw i}}else e()}function O(e){g.useDeprecatedSynchronousErrorHandling&&_&&(_.errorThrown=!0,_.error=e)}var T=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,p(t)&&t.add(n)):n.destination=S,n}return i(t,e),t.create=function(e,t,n){return new k(e,t,n)},t.prototype.next=function(e){this.isStopped?A(function(e){return w("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?A(w("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?A(E,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(h),k=function(e){function t(t,n,r){var i,o=e.call(this)||this;if(c(t))i=t;else if(t){var s;i=t.next,n=t.error,r=t.complete,o&&g.useDeprecatedNextContext?(s=Object.create(t)).unsubscribe=function(){return o.unsubscribe()}:s=t,i=null==i?void 0:i.bind(s),n=null==n?void 0:n.bind(s),r=null==r?void 0:r.bind(s)}return o.destination={next:i?I(i,o):b,error:I(null!=n?n:R,o),complete:r?I(r,o):b},o}return i(t,e),t}(T);function I(e,t){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{e.apply(void 0,a([],s(t)))}catch(e){g.useDeprecatedSynchronousErrorHandling?O(e):m(e)}}}function R(e){throw e}function A(e,t){var n=g.onStoppedNotification;n&&y.setTimeout((function(){return n(e,t)}))}var S={closed:!0,next:b,error:R,complete:b},P="function"==typeof Symbol&&Symbol.observable||"@@observable";function N(e){return e}function D(e){return 0===e.length?N:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var L=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r,i=this,o=(r=e)&&r instanceof T||function(e){return e&&c(e.next)&&c(e.error)&&c(e.complete)}(r)&&p(r)?e:new k(e,t,n);return C((function(){var e=i,t=e.operator,n=e.source;o.add(t?t.call(o,n):n?i._subscribe(o):i._trySubscribe(o))})),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=x(t))((function(t,r){var i;i=n.subscribe((function(t){try{e(t)}catch(e){r(e),null==i||i.unsubscribe()}}),r,t)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[P]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return D(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=x(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function x(e){var t;return null!==(t=null!=e?e:g.Promise)&&void 0!==t?t:Promise}var H,U=u((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),M=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return i(t,e),t.prototype.lift=function(e){var t=new j(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new U},t.prototype.next=function(e){var t=this;C((function(){var n,r;if(t._throwIfClosed(),!t.isStopped){var i=t.observers.slice();try{for(var s=o(i),a=s.next();!a.done;a=s.next()){a.value.next(e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;C((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;C((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this.hasError,n=this.isStopped,r=this.observers;return t||n?d:(r.push(e),new h((function(){return f(r,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this.hasError,n=this.thrownError,r=this.isStopped;t?e.error(n):r&&e.complete()},t.prototype.asObservable=function(){var e=new L;return e.source=this,e},t.create=function(e,t){return new j(e,t)},t}(L),j=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return i(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:d},t}(M),F=n(10),B=n.n(F),G=n(2);!function(e){e[e.Unknown=0]="Unknown",e[e.AcceptCall=1]="AcceptCall",e[e.TerminateCall=2]="TerminateCall",e[e.HoldCall=3]="HoldCall",e[e.ResumeCall=4]="ResumeCall",e[e.Flash=5]="Flash",e[e.CallInProgress=6]="CallInProgress",e[e.CallRinging=7]="CallRinging",e[e.CallEnded=8]="CallEnded",e[e.TransferToHeadset=9]="TransferToHeadset",e[e.TransferToSpeaker=10]="TransferToSpeaker",e[e.Mute=11]="Mute",e[e.Unmute=12]="Unmute",e[e.MobileCallRinging=13]="MobileCallRinging",e[e.MobileCallInProgress=14]="MobileCallInProgress",e[e.MobileCallEnded=15]="MobileCallEnded",e[e.DOn=16]="DOn",e[e.DOff=17]="DOff",e[e.CallIdle=18]="CallIdle",e[e.Play=19]="Play",e[e.Pause=20]="Pause",e[e.Stop=21]="Stop",e[e.DTMLKey=22]="DTMLKey",e[e.RejectCall=23]="RejectCall",e[e.MakeCall=24]="MakeCall",e[e.Hook=25]="Hook",e[e.HookIdle=26]="HookIdle",e[e.HookDocked=27]="HookDocked",e[e.HookUndocked=28]="HookUndocked",e[e.BaseEvent=29]="BaseEvent",e[e.CallAnsweredAndEnded=30]="CallAnsweredAndEnded",e[e.CallUnansweredAndEnded=31]="CallUnansweredAndEnded",e[e.DeviceChange=32]="DeviceChange",e[e.DeviceArrived=33]="DeviceArrived",e[e.DeviceRemoved=34]="DeviceRemoved"}(H||(H={}));var Y=n(3),V=n.n(Y);function W(e){return(W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function K(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function q(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function s(e){K(o,r,i,s,a,"next",e)}function a(e){K(o,r,i,s,a,"throw",e)}s(void 0)}))}}function z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function $(e,t){return($=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function J(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Z(e);if(t){var i=Z(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return X(this,n)}}function X(e,t){if(t&&("object"===W(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Q(e)}function Q(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var te,ne,re=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&$(e,t)}(v,e);var t,n,r,i,o,s,a,c,u,l,f,h,d,p=J(v);function v(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,v),ee(Q(t=p.call(this,e)),"activePollingInterval",2e3),ee(Q(t),"connectedDeviceInterval",6e3),ee(Q(t),"disconnectedDeviceInterval",2e3),ee(Q(t),"deviceIdRetryInterval",2e3),ee(Q(t),"vendorName","Plantronics"),ee(Q(t),"pluginName","genesys-cloud-headset-library"),ee(Q(t),"apiHost","https://127.0.0.1:32018/Spokes"),ee(Q(t),"isActive",!1),ee(Q(t),"disableEventPolling",!1),ee(Q(t),"config",void 0),ee(Q(t),"deviceStatusTimer",null),ee(Q(t),"isRetry",!1),ee(Q(t),"_deviceInfo",void 0),ee(Q(t),"callEventsTimerId",void 0),ee(Q(t),"deviceStatusTimerId",void 0),ee(Q(t),"incomingConversationId",void 0),t.config=e,t._deviceInfo=null,t.callEventsTimerId=null,t.deviceStatusTimerId=null,t.incomingConversationId="",t}return t=v,n=[{key:"clearTimeouts",value:function(){clearTimeout(this.callEventsTimerId),clearTimeout(this.deviceStatusTimerId)}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["plantronics","plt","poly","(047f:"].some((function(e){return t.includes(e)}))}},{key:"deviceName",get:function(){var e;return null===(e=this._deviceInfo)||void 0===e?void 0:e.ProductName}},{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"pollForCallEvents",value:function(){var e=this;this.callEventsTimerId&&(clearTimeout(this.callEventsTimerId),this.callEventsTimerId=null),this.isConnected&&!this.disableEventPolling&&(this.logger.debug("**** POLLING FOR CALL EVENTS ****"),this.getCallEvents()),this.callEventsTimerId=setTimeout((function(){e.pollForCallEvents()}),this.activePollingInterval)}},{key:"pollForDeviceStatus",value:function(){var e=this;this.deviceStatusTimerId&&(clearTimeout(this.deviceStatusTimerId),this.deviceStatusTimerId=null),!this.isConnected||this.isConnecting||this.disableEventPolling||(this.logger.debug("**** POLLING FOR DEVICE STATUS ****"),this.getDeviceStatus()),this.deviceStatusTimerId=setTimeout((function(){e.pollForDeviceStatus()}),this.isDeviceAttached?this.connectedDeviceInterval:this.disconnectedDeviceInterval)}},{key:"_makeRequestTask",value:(d=q(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequest(t,n);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"_fetch",value:function(e){return B()(e)}},{key:"_makeRequest",value:(h=q(regeneratorRuntime.mark((function e(t,n){var r,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=v.instance,e.abrupt("return",this._fetch("".concat(this.apiHost).concat(t)).then((function(e){return e.json()})).then((function(e){if(!1===e.ok||"Error"===e.Type_Name){if(404===e.status){if(n){i.isConnected&&i.changeConnectionStatus({isConnected:!1,isConnecting:i.isConnecting}),i.disconnect();var o=new Error("Headset: Failed connection to middleware. Headset features unavailable.");return o.handled=!0,i.logger.info(o),Promise.reject(o)}return i._makeRequestTask(t,!0)}return V.a.isFirefox&&(i.errorCode="browser",i.disableRetry=!0),Promise.reject(e)}return r?(!i.isConnected&&i.changeConnectionStatus({isConnected:!0,isConnecting:i.isConnecting}),e):Promise.reject(new Error("Application destroyed."))})).catch((function(e){return Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"_checkIsActiveTask",value:(f=q(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getActiveCalls();case 2:t=e.sent,this.isActive=!!t.length;case 4:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"_getActiveCalls",value:(l=q(regeneratorRuntime.mark((function e(){var t,n,r,i,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/CallServices/CallManagerState?");case 3:i=e.sent,r=i,e.next=11;break;case 7:return e.prev=7,e.t0=e.catch(0),this.logger.info("Error making request for active calls",e.t0),e.abrupt("return",[]);case 11:if(Array.isArray(null===(t=r)||void 0===t||null===(n=t.Result)||void 0===n?void 0:n.Calls)){e.next=13;break}return e.abrupt("return",[]);case 13:return e.abrupt("return",r.Result.Calls.filter((function(e){return e.Source===o.pluginName})));case 14:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return l.apply(this,arguments)})},{key:"getCallEvents",value:(u=q(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/CallServices/CallEvents?name=".concat(this.pluginName));case 3:t=e.sent,e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(0),this.logger.info("Error making request for call events",e.t0),e.abrupt("return");case 10:t.Result&&t.Result.forEach((function(e){var t=H[e.Action];if(!t)return n.logger.info("Unknown call event from headset",{event:e});var r={name:t,code:e.Action,event:e};n.logger.debug("headset info",r),n.callCorrespondingFunction(r)}));case 11:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(){return u.apply(this,arguments)})},{key:"getDeviceStatus",value:(c=q(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequestTask("/DeviceServices/Info").then((function(e){t._deviceInfo=e.Result})).catch((function(e){e.Err&&e.Err.Description.includes("no supported devices")||t.logger.info("Error making request for device status",e)}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"callCorrespondingFunction",value:function(e){switch(e.name){case"AcceptCall":this.deviceAnsweredCall(e);break;case"RejectCall":this.deviceRejectedCall(this.incomingConversationId);break;case"TerminateCall":this.deviceEndedCall(e);break;case"CallEnded":this._checkIsActiveTask();break;case"Mute":this.deviceMuteChanged(!0,e);break;case"Unmute":this.deviceMuteChanged(!1,e);break;case"HoldCall":this.deviceHoldStatusChanged(!0,e);break;case"ResumeCall":this.deviceHoldStatusChanged(!1,e);break;default:this.logger.info("A headset event has occurred",e),this.deviceEventLogs(e)}}},{key:"connect",value:function(){var e=this;return!this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),this.pollForDeviceStatus(),this.pollForCallEvents(),this._makeRequestTask("/SessionManager/Register?name=".concat(this.pluginName)).catch((function(t){return t.Err&&"Plugin exists"===t.Err.Description?e.logger.debug("Plugin already exists",t):Promise.reject(t)})).then((function(){return e._makeRequestTask("/SessionManager/IsActive?name=".concat(e.pluginName,"&active=true"))})).catch((function(t){return t.Err&&!t.isError?e.logger.debug("Is Active",t):Promise.reject(t)})).then((function(t){return!0!==(null==t?void 0:t.Result)?Promise.reject(t):e._makeRequestTask("/UserPreference/SetDefaultSoftPhone?name=".concat(e.pluginName))})).then((function(){e.getDeviceStatus()})).then((function(){return e._getActiveCalls()})).then((function(t){return t.length?(e.isActive=!0,e.logger.info("Currently active calls in the session")):e.getCallEvents()})).catch((function(t){return null!=t&&t.handled?e.logger.error("Unable to properly connect headset"):Promise.reject(t)})).finally((function(){e.isConnecting&&e.changeConnectionStatus({isConnected:e.isConnected,isConnecting:!1})}))}},{key:"disconnect",value:function(){var e=this;return(this.isConnected?this._makeRequestTask("/SessionManager/UnRegister?name=".concat(this.pluginName)):Promise.resolve()).then((function(){e.clearTimeouts(),e._deviceInfo=null,e.isConnected&&e.changeConnectionStatus({isConnected:!1,isConnecting:e.isConnecting}),e.isActive=!1}))}},{key:"incomingCall",value:function(e){this.logger.info("Inside incomingCall of selected implementation (Plantronics/Poly)");var t=e.conversationId,n=e.contactName;if(!t)throw new Error("Must provide conversationId");this.incomingConversationId=t;var r="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),i='"Id":"'.concat(t,'"');if(r+="&callID={".concat(encodeURI(i),"}"),n){var o='"Name":"'.concat(n,'"');r+="&contact={".concat(encodeURI(o),"}")}return this.logger.info("params of endpoint",r),this.isActive=!0,this._makeRequestTask("/CallServices/IncomingCall".concat(encodeURI(r)))}},{key:"outgoingCall",value:function(e){var t=e.conversationId,n=e.contactName;if(!t)throw new Error("Must provide conversationId");var r="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),i='"Id":"'.concat(t,'"');if(r+="&callID={".concat(encodeURI(i),"}"),n){var o='"Name":"'.concat(n,'"');r+="&contact={".concat(encodeURI(o),"}")}return this.isActive=!0,this._makeRequestTask("/CallServices/OutgoingCall".concat(encodeURI(r)))}},{key:"answerCall",value:function(e){var t='"Id":"'.concat(e,'"'),n="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(t),"}");return this.isActive=!0,this.incomingConversationId="",this._makeRequestTask("/CallServices/AnswerCall".concat(encodeURI(n)))}},{key:"rejectCall",value:function(e){return this.incomingConversationId="",this.endCall(e)}},{key:"endCall",value:(a=q(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="?name=".concat(this.pluginName),r='"Id":"'.concat(t,'"'),n+="&callID={".concat(encodeURI(r),"}"),e.next=5,this._makeRequestTask("/CallServices/TerminateCall".concat(encodeURI(n)));case 5:return i=e.sent,e.next=8,this.getCallEvents();case 8:return this._checkIsActiveTask(),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"endAllCalls",value:(s=q(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getActiveCalls();case 2:e.sent.forEach((function(e){return t.endCall(e.CallId)}));case 4:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"setMute",value:(o=q(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequestTask("/CallServices/MuteCall?name=".concat(this.pluginName,"&muted=").concat(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setHold",value:(i=q(regeneratorRuntime.mark((function e(t,n){var r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r='"Id":"'.concat(t,'"'),i="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(r),"}"),e.next=4,this._makeRequestTask("/CallServices/".concat(n?"HoldCall":"ResumeCall").concat(encodeURI(i)));case 4:return o=e.sent,e.abrupt("return",o);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})}],r=[{key:"getInstance",value:function(e){return v.instance||(v.instance=new v(e)),v.instance}}],n&&z(t.prototype,n),r&&z(t,r),Object.defineProperty(t,"prototype",{writable:!1}),v}(G.a);function ie(){return!!window._HostedContextFunctions}function oe(e){return new Promise((function(t,n){try{var r=JSON.stringify(e);window.cefQuery({request:r,persistent:!1,onSuccess:function(e){try{var n=JSON.parse(e);t(n)}catch(e){t({})}},onFailure:function(e){n(e)}})}catch(e){console.error("Error requesting desktop promise",e),n(e)}}))}function se(e){return(se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ae(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ce(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ue(e,t){return(ue=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function le(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=de(e);if(t){var i=de(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return fe(this,n)}}function fe(e,t){if(t&&("object"===se(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return he(e)}function he(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function de(e){return(de=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function pe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}ee(re,"instance",void 0),function(e){e.SocketConnected="SocketConnected",e.EstablishConnection="EstablishConnection",e.SPLogin="SPLoggedIn",e.SPLogout="SPLoggedOut",e.TerminateConnection="TerminateConnection",e.IncomingCall="IncomingCall",e.IncomingCallRejected="InCallRejected",e.IncomingCallAccepted="InCallAccepted",e.OutgoingCall="OutgoingCall",e.CallEnded="CallEnded",e.SystemInformation="SystemInformation",e.HeadsetConnected="HeadsetConnected",e.HeadsetDisconnected="HeadsetDisconnected",e.Hold="CallHold",e.Resume="HeldCallResumed",e.MuteFromApp="MuteHeadset",e.UnmuteFromApp="UnmuteHeadset",e.MuteFromHeadset="MuteSoftphone",e.UnmuteFromHeadset="UnmuteSoftphone"}(te||(te={})),function(e){e.Request="Request",e.Notification="Notification",e.Ack="Acknowledgement"}(ne||(ne={}));var ve=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&ue(e,t)}(o,e);var t,n,r,i=le(o);function o(){var e;ae(this,o);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return pe(he(e=i.call.apply(i,[this].concat(n))),"connectTimeout",5e3),pe(he(e),"vendorName","Sennheiser"),pe(he(e),"isActive",!1),pe(he(e),"devices",null),pe(he(e),"activeDeviceId",null),pe(he(e),"websocketConnected",!1),pe(he(e),"callMappings",{}),pe(he(e),"websocket",null),pe(he(e),"deviceInfo",null),pe(he(e),"webSocketOnOpen",(function(){e.websocketConnected=!0,e.logger.info("websocket open the sennheiser software")})),e}return t=o,r=[{key:"getInstance",value:function(e){return o.instance||(o.instance=new o(e)),o.instance}}],(n=[{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["senn","epos"].some((function(e){return t.includes(e)}))}},{key:"deviceName",get:function(){return this.deviceInfo&&this.deviceInfo.ProductName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"_handleError",value:function(e){this.logger.error("Non-zero return code from sennheiser",e)}},{key:"_handleAck",value:function(e){this.logger.debug("Received Ack for ".concat(e.Event))}},{key:"_sendMessage",value:function(e){this.logger.debug("sending sennheiser message",e),this.websocket.send(JSON.stringify(e))}},{key:"_registerSoftphone",value:function(){var e={Event:te.EstablishConnection,EventType:ne.Request,SPName:"Genesys Cloud Softphone",SPIconImage:"SPImage.ico",RedialSupport:"No",OffHookSupport:"No",MuteSupport:"Yes",DNDOption:"No"};this._sendMessage(e)}},{key:"connect",value:function(){!this.isConnecting&&this.changeConnectionStatus({isConnected:!1,isConnecting:!0});var e=new WebSocket("wss://127.0.0.1:41088");return e.onopen=this.webSocketOnOpen.bind(this),e.onclose=this.webSocketOnClose.bind(this),e.onmessage=this._handleMessage.bind(this),this.websocket=e,Promise.resolve()}},{key:"webSocketOnClose",value:function(e){this.websocketConnected=!1,e.wasClean||this.logger.error(e),this.isConnected||(this.logger.error(new Error("Failed to connect to sennheiser software. Make sure it is installed")),V.a.isFireFox&&(this.errorCode="browser",this.disableRetry=!0)),(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1})}},{key:"disconnect",value:function(){return this.isConnected?(this._sendMessage({Event:te.TerminateConnection,EventType:ne.Request}),Promise.resolve()):Promise.resolve()}},{key:"_createCallMapping",value:function(e){var t,n=Math.round(Math.random()*Math.pow(10,7));return this.callMappings=(pe(t={},e,n),pe(t,n,e),t),this.logger.info("Created callId mapping for sennheiser headset",{conversationId:e,sennheiserCallId:n}),n}},{key:"setMute",value:function(e){return this._sendMessage({Event:e?te.MuteFromApp:te.UnmuteFromApp,EventType:ne.Request}),Promise.resolve()}},{key:"setHold",value:function(e,t){return this._sendMessage({Event:t?te.Hold:te.Resume,EventType:ne.Request,CallID:this.callMappings[e]}),Promise.resolve()}},{key:"incomingCall",value:function(e){var t=e.conversationId,n=this._createCallMapping(t);return this._sendMessage({Event:te.IncomingCall,EventType:ne.Request,CallID:n}),Promise.resolve()}},{key:"answerCall",value:function(e){return this._sendMessage({Event:te.IncomingCallAccepted,EventType:ne.Request,CallID:this.callMappings[e]}),Promise.resolve()}},{key:"rejectCall",value:function(e){return this._sendMessage({Event:te.IncomingCallRejected,EventType:ne.Request,CallID:this.callMappings[e]}),Promise.resolve()}},{key:"outgoingCall",value:function(e){var t=e.conversationId,n=this._createCallMapping(t);return this._sendMessage({Event:te.OutgoingCall,EventType:ne.Request,CallID:n}),Promise.resolve()}},{key:"endCall",value:function(e){var t=this.callMappings[e];return t?(this._sendMessage({Event:te.CallEnded,EventType:ne.Request,CallID:t}),Promise.resolve()):(this.logger.info("Failed to find sennheiser callId, assuming call was already ended"),Promise.resolve())}},{key:"endAllCalls",value:function(){return this.logger.warn("There is no functionality defined for SennheiserService.endAllCalls()"),Promise.resolve()}},{key:"_handleMessage",value:function(e){var t;try{t=JSON.parse(e.data)}catch(t){return this.logger.error(t),void this.logger.error("Failed to parse sennheiser payload",{message:e})}if(this.logger.debug("incoming sennheiser message",t),t.ReturnCode)this._handleError(t);else{var n,r=t.CallID;switch(r&&(n=this.callMappings[r]),t.Event){case te.SocketConnected:this._registerSoftphone();break;case te.EstablishConnection:this._sendMessage({Event:te.SPLogin,EventType:ne.Request});break;case te.SPLogin:this.isConnected&&!this.isConnecting||this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),this._sendMessage({Event:te.SystemInformation,EventType:ne.Request});break;case te.HeadsetConnected:t.HeadsetName&&(this.deviceInfo={deviceName:t.HeadsetName,headsetType:t.HeadsetType});break;case te.HeadsetDisconnected:t.HeadsetName===this.deviceName&&(this.deviceInfo=null);break;case te.IncomingCallAccepted:t.EventType===ne.Notification&&this.deviceAnsweredCall({name:t.Event});break;case te.Hold:if(t.EventType===ne.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged(!0,{name:t.Event});break;case te.Resume:if(t.EventType===ne.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged(!1,{name:t.Event});break;case te.MuteFromHeadset:this.deviceMuteChanged(!0,{name:t.Event});break;case te.UnmuteFromHeadset:this.deviceMuteChanged(!1,{name:t.Event});break;case te.CallEnded:delete this.callMappings[r],delete this.callMappings[n],t.EventType===ne.Notification&&this.deviceEndedCall({name:t.Event});break;case te.IncomingCallRejected:this.deviceRejectedCall(n);break;case te.TerminateConnection:1===this.websocket.readyState&&this.websocket.close(),this.websocket=null;break;default:t.EventType===ne.Ack&&this._handleAck(t)}}}}])&&ce(t.prototype,n),r&&ce(t,r),Object.defineProperty(t,"prototype",{writable:!1}),o}(G.a);pe(ve,"instance",void 0);var ge=n(0),ye=u((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function me(e,t){var n="object"==typeof t;return new Promise((function(r,i){var o=new k({next:function(e){r(e),o.unsubscribe()},error:i,complete:function(){n?r(t.defaultValue):i(new ye)}});e.subscribe(o)}))}function be(e){return function(t){if(function(e){return c(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}var Ee=function(e){function t(t,n,r,i,o){var s=e.call(this,t)||this;return s.onFinalize=o,s._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,s._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,s}return i(t,e),t.prototype.unsubscribe=function(){var t,n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))},t}(T);function we(e,t){return be((function(n,r){var i=0;n.subscribe(new Ee(r,(function(n){return e.call(t,n,i++)&&r.next(n)})))}))}var _e=new L((function(e){return e.complete()}));function Ce(e){return e<=0?function(){return _e}:be((function(t,n){var r=0;t.subscribe(new Ee(n,(function(t){++r<=e&&(n.next(t),e<=r&&n.complete())})))}))}function Oe(e){return be((function(t,n){var r=!1;t.subscribe(new Ee(n,(function(e){r=!0,n.next(e)}),(function(){r||n.next(e),n.complete()})))}))}function Te(e){return void 0===e&&(e=ke),be((function(t,n){var r=!1;t.subscribe(new Ee(n,(function(e){r=!0,n.next(e)}),(function(){return r?n.complete():n.error(e())})))}))}function ke(){return new ye}function Ie(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?we((function(t,n){return e(t,n,r)})):N,Ce(1),n?Oe(t):Te((function(){return new ye})))}}function Re(e){return(Re="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ae(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function Se(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function s(e){Ae(o,r,i,s,a,"next",e)}function a(e){Ae(o,r,i,s,a,"throw",e)}s(void 0)}))}}function Pe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ne(e,t){return(Ne=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function De(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=He(e);if(t){var i=He(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Le(this,n)}}function Le(e,t){if(t&&("object"===Re(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return xe(e)}function xe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function He(e){return(He=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ue(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Me,je=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&Ne(e,t)}(y,e);var t,n,r,i,o,s,a,c,u,l,f,h,d,p,v,g=De(y);function y(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,y),Ue(xe(t=g.call(this,e)),"headsetEventSubscription",void 0),Ue(xe(t),"isActive",!1),Ue(xe(t),"devices",void 0),Ue(xe(t),"activeDeviceId",null),Ue(xe(t),"isMuted",!1),Ue(xe(t),"isHeld",!1),Ue(xe(t),"version",null),Ue(xe(t),"_connectDeferred",void 0),Ue(xe(t),"device",null),Ue(xe(t),"jabraSdk",void 0),Ue(xe(t),"easyCallControlFactory",void 0),Ue(xe(t),"callControlFactory",void 0),Ue(xe(t),"multiCallControl",void 0),Ue(xe(t),"callControl",void 0),Ue(xe(t),"ongoingCalls",0),Ue(xe(t),"callLock",!1),Ue(xe(t),"incomingConversationId",""),t.vendorName="Jabra",t.devices=new Map,t.jabraSdk=t.initializeJabraSdk(),t}return t=y,n=[{key:"isSupported",value:function(){return window.navigator.hid&&!ie()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["jabra"].some((function(e){return t.includes(e)}))}},{key:"deviceInfo",get:function(){return null===this.activeDeviceId||0===this.devices.size?null:this.devices.get(this.activeDeviceId)}},{key:"deviceName",get:function(){return this.deviceInfo.deviceName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"resetState",value:function(){this.setHold(null,!1),this.setMute(!1)}},{key:"_processEvents",value:(v=Se(regeneratorRuntime.mark((function e(t){var n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.headsetEventSubscription=t.deviceSignals.subscribe(function(){var e=Se(regeneratorRuntime.mark((function e(r){var i,o,s,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.callLock){e.next=3;break}return n.logger.debug("Currently not in possession of the Call Lock; Cannot react to Device Actions"),e.abrupt("return");case 3:e.t0=ge.u[r.type],e.next="HOOK_SWITCH"===e.t0?6:"FLASH"===e.t0||"ALT_HOLD"===e.t0?8:"PHONE_MUTE"===e.t0?12:"REJECT_CALL"===e.t0?16:19;break;case 6:if(r.value)t.offHook(!0),t.ring(!1),n.deviceAnsweredCall({name:"CallOffHook",code:r.type});else{t.mute(!1),t.hold(!1),t.offHook(!1),n.deviceEndedCall({name:"CallOnHook",code:r.type});try{t.releaseCallLock()}catch(e){i=e.message,o=e.type,n.checkForCallLockError(i,o)?n.logger.info(i):n.logger.error(o,i)}finally{n.callLock=!1}}return e.abrupt("break",19);case 8:return n.isHeld=!n.isHeld,t.hold(n.isHeld),n.deviceHoldStatusChanged(n.isHeld,{name:n.isHeld?"OnHold":"ResumeCall",code:r.type}),e.abrupt("break",19);case 12:return n.isMuted=!n.isMuted,t.mute(n.isMuted),n.deviceMuteChanged(n.isMuted,{name:n.isMuted?"CallMuted":"CallUnmuted",code:r.type}),e.abrupt("break",19);case 16:t.ring(!1),n.deviceRejectedCall(n.incomingConversationId);try{t.releaseCallLock()}catch(e){s=e.message,a=e.type,n.checkForCallLockError(s,a)?n.logger.info(s):n.logger.error(a,s)}finally{n.callLock=!1}case 19:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 1:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"setMute",value:(p=Se(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return");case 2:this.isMuted=t,this.callControl.mute(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"setHold",value:(d=Se(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return");case 2:this.isHeld=n,this.callControl.hold(n);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"incomingCall",value:(h=Se(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=16;break}return this.incomingConversationId=t.conversationId,e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:if(this.callLock=e.sent,!this.callLock){e.next=9;break}return this.callControl.ring(!0),e.abrupt("return",Promise.resolve());case 9:e.next=16;break;case 11:e.prev=11,e.t0=e.catch(2),n=e.t0.message,r=e.t0.type,this.checkForCallLockError(n,r)?(this.logger.info(n),this.callControl.ring(!0)):this.logger.error(r,n);case 16:case"end":return e.stop()}}),e,this,[[2,11]])}))),function(e){return h.apply(this,arguments)})},{key:"answerCall",value:(f=Se(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return");case 2:this.incomingConversationId="",this.callControl.offHook(!0);case 4:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"rejectCall",value:(l=Se(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.callLock){e.next=3;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 3:this.callControl.ring(!1),this.callControl.releaseCallLock(),e.next=12;break;case 7:e.prev=7,e.t0=e.catch(0),t=e.t0.message,n=e.t0.type,this.checkForCallLockError(t,n)?this.logger.info(t):this.logger.error(n,t);case 12:return e.prev=12,this.incomingConversationId="",this.callLock=!1,this.resetState(),e.finish(12);case 17:case"end":return e.stop()}}),e,this,[[0,7,12,17]])}))),function(){return l.apply(this,arguments)})},{key:"outgoingCall",value:(u=Se(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.callControl.takeCallLock();case 3:if(this.callLock=e.sent,!this.callLock){e.next=7;break}return this.callControl.offHook(!0),e.abrupt("return",Promise.resolve());case 7:e.next=14;break;case 9:e.prev=9,e.t0=e.catch(0),t=e.t0.message,n=e.t0.type,this.checkForCallLockError(t,n)?(this.logger.info(t),this.callControl.offHook(!0)):this.logger.error(n,t);case 14:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(){return u.apply(this,arguments)})},{key:"endCall",value:(c=Se(regeneratorRuntime.mark((function e(t,n){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:if(e.prev=2,this.callLock){e.next=5;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 5:this.callControl.offHook(!1),this.callControl.releaseCallLock(),e.next=14;break;case 9:e.prev=9,e.t0=e.catch(2),r=e.t0.message,i=e.t0.type,this.checkForCallLockError(r,i)?this.logger.info(r):this.logger.error(i,r);case 14:return e.prev=14,this.callLock=!1,this.resetState(),e.finish(14);case 18:case"end":return e.stop()}}),e,this,[[2,9,14,18]])}))),function(e,t){return c.apply(this,arguments)})},{key:"endAllCalls",value:(a=Se(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.callLock){e.next=3;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 3:this.callControl.offHook(!1),this.callControl.releaseCallLock(),e.next=12;break;case 7:e.prev=7,e.t0=e.catch(0),t=e.t0.message,n=e.t0.type,this.checkForCallLockError(t,n)?this.logger.info(t):this.logger.error(n,t);case 12:return e.prev=12,this.callLock=!1,this.resetState(),e.finish(12);case 16:case"end":return e.stop()}}),e,this,[[0,7,12,16]])}))),function(){return a.apply(this,arguments)})},{key:"isDeviceInList",value:function(e,t){var n;return t.includes(null==e||null===(n=e.name)||void 0===n?void 0:n.toLowerCase())}},{key:"connect",value:(s=Se(regeneratorRuntime.mark((function e(t){var n,r,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.toLowerCase(),this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),e.next=4,this.jabraSdk;case 4:n=e.sent,this.callControlFactory=this.createCallControlFactory(n),r=setTimeout(Se(regeneratorRuntime.mark((function e(){var o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,me(n.deviceList);case 2:if(o=e.sent,s=o.find((function(e){return i.isDeviceInList(e,t)}))){e.next=16;break}return e.prev=5,e.next=8,new Promise((function(e,r){var o,s,a=setTimeout(r,3e4);i.requestWebHidPermissions(ge.D),n.deviceList.pipe((o=function(e){return e.find((function(e){return i.isDeviceInList(e,t)}))},be((function(e,t){var n=0;e.subscribe(new Ee(t,(function(e){t.next(o.call(s,e,n++))})))}))),we(Boolean),Ie()).subscribe((function(t){clearTimeout(a),e(t)}))}));case 8:s=e.sent,e.next=16;break;case 11:return e.prev=11,e.t0=e.catch(5),i.isConnecting&&i.changeConnectionStatus({isConnected:i.isConnected,isConnecting:!1}),i.logger.error("The selected device was not granted WebHID permissions"),e.abrupt("return");case 16:return e.next=18,i.callControlFactory.createCallControl(s);case 18:i.callControl=e.sent,i._processEvents(i.callControl),i.isConnecting&&!i.isConnected&&i.changeConnectionStatus({isConnected:!0,isConnecting:!1}),clearTimeout(r);case 22:case"end":return e.stop()}}),e,null,[[5,11]])}))),2e3);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"initializeJabraSdk",value:(o=Se(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Object(ge.C)({appId:"softphone-vendor-headsets",appName:"Softphone Headset Library",transport:ge.z.CHROME_EXTENSION_WITH_WEB_HID_FALLBACK});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),function(){return o.apply(this,arguments)})},{key:"createCallControlFactory",value:function(e){return new ge.a(e)}},{key:"checkForCallLockError",value:function(e,t){return t===ge.b.SDK_USAGE_ERROR&&e.includes("call lock")}},{key:"disconnect",value:(i=Se(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.headsetEventSubscription&&this.headsetEventSubscription.unsubscribe(),(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1});case 2:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})}],r=[{key:"getInstance",value:function(e){return y.instance||(y.instance=new y(e)),y.instance}}],n&&Pe(t.prototype,n),r&&Pe(t,r),Object.defineProperty(t,"prototype",{writable:!1}),y}(G.a);Ue(je,"instance",void 0),Ue(je,"connectTimeout",5e3),function(e){e.Ring="ringer",e.Offhook="offhook",e.Mute="mute",e.Hold="hold"}(Me||(Me={}));var Fe;function Be(e){return(Be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ge(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function Ye(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ve(e,t){return(Ve=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function We(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ze(e);if(t){var i=ze(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Ke(this,n)}}function Ke(e,t){if(t&&("object"===Be(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return qe(e)}function qe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ze(e){return(ze=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e){e.OffHook="OffHook",e.Mute="Mute",e.Hold="Flash",e.RejectCall="RejectCall"}(Fe||(Fe={}));var Je=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&Ve(e,t)}(a,e);var t,n,r,i,o,s=We(a);function a(e){var t,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),$e(qe(n=s.call(this,e)),"isActive",!1),$e(qe(n),"devices",null),$e(qe(n),"activeDeviceId",null),$e(qe(n),"headsetState",null),$e(qe(n),"ignoreNextOffhookEvent",!1),$e(qe(n),"_connectionInProgress",void 0),$e(qe(n),"cefSupportsJabra",!0),$e(qe(n),"incomingConversationId",""),n.vendorName="Jabra",n.headsetState={ringing:!1,offHook:!1},n.devices=new Map;var r={assetURL:window.location.origin+window.location.pathname,callback:n.handleCefEvent.bind(qe(n)),supportsTerminationRequest:!0,supportsUnifiedPreferences:!0},i=null===(t=window._HostedContextFunctions)||void 0===t?void 0:t.register(r);return n.cefSupportsJabra=null==i?void 0:i.supportsJabra,n}return t=a,n=[{key:"deviceInfo",get:function(){return null===this.activeDeviceId||null===this.devices||this.devices&&!this.devices.size?null:this.devices.get(this.activeDeviceId)}},{key:"deviceName",get:function(){return this.deviceInfo&&this.deviceInfo.deviceName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"isHeadsetEvent",value:function(e){return"JabraEvent"===e.msg}},{key:"isDeviceEvent",value:function(e){return"JabraDeviceAttached"===e.msg}},{key:"handleCefEvent",value:function(e){this.isConnected&&(this.isDeviceEvent(e)?this.handleJabraDeviceAttached(e):this.isHeadsetEvent(e)&&this.handleJabraEvent(e))}},{key:"handleJabraDeviceAttached",value:function(e){this.logger.debug("handling jabra attach/detach event",e),this.updateDevices()}},{key:"handleJabraEvent",value:function(e){this.logger.debug("Jabra event received",e),this._processEvent(e.event,e.value)}},{key:"_handleOffhookEvent",value:function(e){e?this.headsetState.ringing&&(this.deviceAnsweredCall(),this._sendCmd(Me.Offhook,e),this._setRinging(!1)):(this._sendCmd(Me.Offhook,e),this._getHeadsetIntoVanillaState(),this.deviceEndedCall())}},{key:"_handleMuteEvent",value:function(e){this._sendCmd(Me.Mute,e),this.deviceMuteChanged(e)}},{key:"_handleHoldEvent",value:function(e){this._sendCmd(Me.Hold,!!e),this.deviceHoldStatusChanged(!!e)}},{key:"_getHeadsetIntoVanillaState",value:function(){this.setHold(null,!1),this.setMute(!1)}},{key:"_sendCmd",value:function(e,t){var n=this.activeDeviceId;this.logger.debug("Sending command to headset",{deviceId:n,cmd:e,value:t}),window._HostedContextFunctions.sendEventToDesktop("jabraEvent",{deviceID:n,event:e,value:t})}},{key:"_setRinging",value:function(e){this._sendCmd(Me.Ring,e),this.headsetState.ringing=e}},{key:"isSupported",value:function(){return ie()&&this.cefSupportsJabra}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["jabra"].some((function(e){return t.includes(e)}))}},{key:"setMute",value:function(e){return this._sendCmd(Me.Mute,e),Promise.resolve()}},{key:"setHold",value:function(e,t){return this._sendCmd(Me.Hold,t),Promise.resolve()}},{key:"incomingCall",value:function(e){return e&&(this.incomingConversationId=e.conversationId),this._setRinging(!0),Promise.resolve()}},{key:"answerCall",value:function(){return this.ignoreNextOffhookEvent=!0,this.incomingConversationId="",this._sendCmd(Me.Offhook,!0),Promise.resolve()}},{key:"rejectCall",value:function(){return this._setRinging(!1),this.incomingConversationId="",Promise.resolve()}},{key:"outgoingCall",value:function(){return this._sendCmd(Me.Offhook,!0),Promise.resolve()}},{key:"endCall",value:function(e,t){return this._setRinging(!1),t||this._sendCmd(Me.Offhook,!1),Promise.resolve()}},{key:"endAllCalls",value:function(){return this._setRinging(!1),this._sendCmd(Me.Offhook,!1),Promise.resolve()}},{key:"updateDevices",value:(i=regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,oe({cmd:"requestJabraDevices"});case 3:if(t=e.sent,this._connectionInProgress&&this._connectionInProgress.resolve(),this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),t&&t.length){e.next=11;break}return this.devices.clear(),this.activeDeviceId=null,this.logger.error(new Error("No attached jabra devices")),e.abrupt("return");case 11:this.logger.info("connected jabra devices",t),this.devices.clear(),t.forEach((function(e){return n.devices.set(e.deviceID,e)})),this.activeDeviceId=t[0].deviceID,this._setRinging(!1),this.setMute(!1),e.next=23;break;case 19:e.prev=19,e.t0=e.catch(0),this.logger.error("Failed to connect to jabra",e.t0),this.disconnect();case 23:case"end":return e.stop()}}),e,this,[[0,19]])})),o=function(){var e=this,t=arguments;return new Promise((function(n,r){var o=i.apply(e,t);function s(e){Ge(o,n,r,s,a,"next",e)}function a(e){Ge(o,n,r,s,a,"throw",e)}s(void 0)}))},function(){return o.apply(this,arguments)})},{key:"_processEvent",value:function(e,t){var n,r,i,o=this;switch(e){case Fe.OffHook:(n=function(){return o._handleOffhookEvent(t)},r=500,i=null,function(){clearTimeout(i),i=setTimeout((function(){n()}),r)})();break;case Fe.RejectCall:this.deviceRejectedCall(this.incomingConversationId);break;case Fe.Mute:this._handleMuteEvent(t);break;case Fe.Hold:this._handleHoldEvent(t)}}},{key:"connect",value:function(){var e,t,n,r,i,o=this;return this.changeConnectionStatus({isConnected:!1,isConnecting:!0}),(e=this.updateDevices(),t=5e3,i=new Promise((function(e,i){r=setTimeout((function(){clearTimeout(r),i(n||"Timed out in "+t+"ms")}),t)})).then((function(e){return clearTimeout(r),e})),Promise.race([e,i])).catch((function(e){o.logger.error("Failed to connect to Jabra",e)}))}},{key:"disconnect",value:function(){return this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),Promise.resolve()}}],r=[{key:"getInstance",value:function(e){return a.instance&&!e.createNew||(a.instance=new a(e)),a.instance}}],n&&Ye(t.prototype,n),r&&Ye(t,r),Object.defineProperty(t,"prototype",{writable:!1}),a}(G.a);$e(Je,"instance",void 0);var Xe=n(1);function Qe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ze(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qe(Object(n),!0).forEach((function(t){nt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function et(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function tt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function nt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var rt=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),nt(this,"plantronics",void 0),nt(this,"jabraNative",void 0),nt(this,"jabra",void 0),nt(this,"sennheiser",void 0),nt(this,"selectedImplementation",void 0),nt(this,"headsetEvents$",void 0),nt(this,"_headsetEvents$",void 0),nt(this,"logger",void 0),this._headsetEvents$=new M,this.headsetEvents$=this._headsetEvents$.asObservable(),this.logger=t.logger||console,this.plantronics=re.getInstance({logger:this.logger}),this.jabraNative=Je.getInstance({logger:this.logger}),this.jabra=je.getInstance({logger:this.logger}),this.sennheiser=ve.getInstance({logger:this.logger}),[this.plantronics,this.jabra,this.jabraNative,this.sennheiser].forEach((function(e){return n.subscribeToHeadsetEvents(e)}))}var t,n,r,i,o;return t=e,n=[{key:"implementations",get:function(){return[this.sennheiser,this.plantronics,this.jabra,this.jabraNative].filter((function(e){return e.isSupported()}))}},{key:"activeMicChange",value:function(e){var t=this.implementations.find((function(t){return t.deviceLabelMatchesVendor(e)}));t?this.changeImplementation(t,e):(this.selectedImplementation&&this.selectedImplementation.disconnect(),this.selectedImplementation=null,this.handleDeviceConnectionStatusChanged())}},{key:"changeImplementation",value:(i=regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t!==this.selectedImplementation){e.next=2;break}return e.abrupt("return");case 2:if(!this.selectedImplementation){e.next=5;break}return e.next=5,this.selectedImplementation.disconnect();case 5:if(this.selectedImplementation=t,!t){e.next=9;break}return e.next=9,t.connect(n);case 9:this._headsetEvents$.next({event:Xe.a.implementationChanged,payload:t});case 10:case"end":return e.stop()}}),e,this)})),o=function(){var e=this,t=arguments;return new Promise((function(n,r){var o=i.apply(e,t);function s(e){et(o,n,r,s,a,"next",e)}function a(e){et(o,n,r,s,a,"throw",e)}s(void 0)}))},function(e,t){return o.apply(this,arguments)})},{key:"incomingCall",value:function(e,t){return this.performActionIfConnected("incomingCall",(function(n){return n.incomingCall(e,t)}))}},{key:"outgoingCall",value:function(e){return this.performActionIfConnected("outgoingCall",(function(t){return t.outgoingCall(e)}))}},{key:"answerCall",value:function(e){return this.performActionIfConnected("answerCall",(function(t){return t.answerCall(e)}))}},{key:"rejectCall",value:function(e){return this.performActionIfConnected("rejectCall",(function(t){return t.rejectCall(e)}))}},{key:"setMute",value:function(e){return this.performActionIfConnected("setMute",(function(t){return t.setMute(e)}))}},{key:"setHold",value:function(e,t){return this.performActionIfConnected("setHold",(function(n){return n.setHold(e,t)}))}},{key:"endCall",value:function(e,t){return this.performActionIfConnected("endCall",(function(n){return n.endCall(e,t)}))}},{key:"endAllCalls",value:function(){return this.performActionIfConnected("endAllCalls",(function(e){return e.endAllCalls()}))}},{key:"retryConnection",value:function(e){return this.selectedImplementation?this.selectedImplementation.connect(e):Promise.reject(new Error("No active headset implementation"))}},{key:"connectionStatus",value:function(){return this.selectedImplementation?this.selectedImplementation.isConnected||this.selectedImplementation.isConnecting?this.selectedImplementation.isConnected?"running":"checking":"notRunning":"noVendor"}},{key:"performActionIfConnected",value:function(e,t){var n=this.selectedImplementation;return n&&n.isConnected?t(n):(this.logger.info("Headset: No vendor headset connected [".concat(e,"]")),Promise.resolve())}},{key:"subscribeToHeadsetEvents",value:function(e){e.on(Xe.a.deviceAnsweredCall,this.handleDeviceAnsweredCall.bind(this)),e.on(Xe.a.deviceRejectedCall,this.handleDeviceRejectedCall.bind(this)),e.on(Xe.a.deviceEndedCall,this.handleDeviceEndedCall.bind(this)),e.on(Xe.a.deviceMuteChanged,this.handleDeviceMuteStatusChanged.bind(this)),e.on(Xe.a.deviceHoldStatusChanged,this.handleDeviceHoldStatusChanged.bind(this)),e.on(Xe.a.deviceEventLogs,this.handleDeviceLogs.bind(this)),e.on(Xe.a.deviceConnectionStatusChanged,this.handleDeviceConnectionStatusChanged.bind(this)),e.on(Xe.a.webHidPermissionRequested,this.handleWebHidPermissionRequested.bind(this))}},{key:"handleDeviceAnsweredCall",value:function(e){e.vendor===this.selectedImplementation&&(this.logger.info("Headset: device answered the call"),this._headsetEvents$.next({event:Xe.a.deviceAnsweredCall,payload:Ze({},e.body)}))}},{key:"handleDeviceRejectedCall",value:function(e){e.vendor===this.selectedImplementation&&(this.logger.info("Headset: device rejected the call"),this._headsetEvents$.next({event:Xe.a.deviceRejectedCall,payload:{conversationId:e.body.conversationId}}))}},{key:"handleDeviceEndedCall",value:function(e){this.logger.info("Headset: device ended the call"),this._headsetEvents$.next({event:Xe.a.deviceEndedCall,payload:Ze({},e.body)})}},{key:"handleDeviceMuteStatusChanged",value:function(e){this.logger.info("Headset: device mute status changed: ",e.body.isMuted),this._headsetEvents$.next({event:Xe.a.deviceMuteStatusChanged,payload:Ze({},e.body)})}},{key:"handleDeviceHoldStatusChanged",value:function(e){this.logger.info("Headset: device hold status changed",e.body.holdRequested),this._headsetEvents$.next({event:Xe.a.deviceHoldStatusChanged,payload:Ze({},e.body)})}},{key:"handleDeviceConnectionStatusChanged",value:function(){this._headsetEvents$.next({event:Xe.a.deviceConnectionStatusChanged,payload:this.connectionStatus()})}},{key:"handleWebHidPermissionRequested",value:function(e){this.logger.debug("Requesting Webhid Permissions"),this._headsetEvents$.next({event:Xe.a.webHidPermissionRequested,payload:Ze({},e.body)})}},{key:"handleDeviceLogs",value:function(e){this._headsetEvents$.next({event:Xe.a.loggableEvent,payload:Ze({},e.body)})}}],r=[{key:"getInstance",value:function(t){return e.instance&&!t.createNew||(e.instance=new e(t)),e.instance}}],n&&tt(t.prototype,n),r&&tt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();nt(rt,"instance",void 0)},function(e,t,n){"use strict";n.r(t);var r=n(11),i=n(2);n.d(t,"VendorImplementation",(function(){return i.a}));var o=n(6);for(var s in o)["default","VendorImplementation"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(s);var a=n(1);n.d(t,"HeadsetEvents",(function(){return a.a}));var c=n(7);for(var s in c)["default","VendorImplementation","HeadsetEvents"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(s);n(8);var u=n(9);for(var s in u)["default","VendorImplementation","HeadsetEvents"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return u[e]}))}(s);t.default=r.a},,function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,u=[],l=!1,f=-1;function h(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&d())}function d(){if(!l){var e=a(h);l=!0;for(var t=u.length;t;){for(c=u,u=[];++f<t;)c&&c[f].run();f=-1,t=u.length}c=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function v(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new p(e,t)),1!==u.length||l||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=v,i.addListener=v,i.once=v,i.off=v,i.removeListener=v,i.removeAllListeners=v,i.emit=v,i.prependListener=v,i.prependOnceListener=v,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";(function(e){
|
|
69
|
+
var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}Object.create;function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function a(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e}Object.create;function c(e){return"function"==typeof e}function u(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var l=u((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function f(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var h=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._teardowns=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var f=o(u),h=f.next();!h.done;h=f.next()){h.value.remove(this)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}else u.remove(this);var d=this.initialTeardown;if(c(d))try{d()}catch(e){i=e instanceof l?e.errors:[e]}var p=this._teardowns;if(p){this._teardowns=null;try{for(var g=o(p),y=g.next();!y.done;y=g.next()){var m=y.value;try{v(m)}catch(e){i=null!=i?i:[],e instanceof l?i=a(a([],s(i)),s(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=g.return)&&r.call(g)}finally{if(n)throw n.error}}}if(i)throw new l(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)v(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._teardowns=null!==(n=this._teardowns)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&f(t,e)},e.prototype.remove=function(t){var n=this._teardowns;n&&f(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),d=h.EMPTY;function p(e){return e instanceof h||e&&"closed"in e&&c(e.remove)&&c(e.add)&&c(e.unsubscribe)}function v(e){c(e)?e():e.unsubscribe()}var g={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},y={setTimeout:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=y.delegate;return((null==n?void 0:n.setTimeout)||setTimeout).apply(void 0,a([],s(e)))},clearTimeout:function(e){var t=y.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function m(e){y.setTimeout((function(){var t=g.onUnhandledError;if(!t)throw e;t(e)}))}function b(){}var E=w("C",void 0,void 0);function w(e,t,n){return{kind:e,value:t,error:n}}var _=null;function C(e){if(g.useDeprecatedSynchronousErrorHandling){var t=!_;if(t&&(_={errorThrown:!1,error:null}),e(),t){var n=_,r=n.errorThrown,i=n.error;if(_=null,r)throw i}}else e()}function O(e){g.useDeprecatedSynchronousErrorHandling&&_&&(_.errorThrown=!0,_.error=e)}var T=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,p(t)&&t.add(n)):n.destination=S,n}return i(t,e),t.create=function(e,t,n){return new k(e,t,n)},t.prototype.next=function(e){this.isStopped?A(function(e){return w("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?A(w("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?A(E,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(h),k=function(e){function t(t,n,r){var i,o=e.call(this)||this;if(c(t))i=t;else if(t){var s;i=t.next,n=t.error,r=t.complete,o&&g.useDeprecatedNextContext?(s=Object.create(t)).unsubscribe=function(){return o.unsubscribe()}:s=t,i=null==i?void 0:i.bind(s),n=null==n?void 0:n.bind(s),r=null==r?void 0:r.bind(s)}return o.destination={next:i?I(i,o):b,error:I(null!=n?n:R,o),complete:r?I(r,o):b},o}return i(t,e),t}(T);function I(e,t){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{e.apply(void 0,a([],s(t)))}catch(e){g.useDeprecatedSynchronousErrorHandling?O(e):m(e)}}}function R(e){throw e}function A(e,t){var n=g.onStoppedNotification;n&&y.setTimeout((function(){return n(e,t)}))}var S={closed:!0,next:b,error:R,complete:b},P="function"==typeof Symbol&&Symbol.observable||"@@observable";function N(e){return e}function D(e){return 0===e.length?N:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var L=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r,i=this,o=(r=e)&&r instanceof T||function(e){return e&&c(e.next)&&c(e.error)&&c(e.complete)}(r)&&p(r)?e:new k(e,t,n);return C((function(){var e=i,t=e.operator,n=e.source;o.add(t?t.call(o,n):n?i._subscribe(o):i._trySubscribe(o))})),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=x(t))((function(t,r){var i;i=n.subscribe((function(t){try{e(t)}catch(e){r(e),null==i||i.unsubscribe()}}),r,t)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[P]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return D(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=x(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function x(e){var t;return null!==(t=null!=e?e:g.Promise)&&void 0!==t?t:Promise}var H,U=u((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),M=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return i(t,e),t.prototype.lift=function(e){var t=new j(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new U},t.prototype.next=function(e){var t=this;C((function(){var n,r;if(t._throwIfClosed(),!t.isStopped){var i=t.observers.slice();try{for(var s=o(i),a=s.next();!a.done;a=s.next()){a.value.next(e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;C((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;C((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this.hasError,n=this.isStopped,r=this.observers;return t||n?d:(r.push(e),new h((function(){return f(r,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this.hasError,n=this.thrownError,r=this.isStopped;t?e.error(n):r&&e.complete()},t.prototype.asObservable=function(){var e=new L;return e.source=this,e},t.create=function(e,t){return new j(e,t)},t}(L),j=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return i(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:d},t}(M),F=n(10),B=n.n(F),G=n(2);!function(e){e[e.Unknown=0]="Unknown",e[e.AcceptCall=1]="AcceptCall",e[e.TerminateCall=2]="TerminateCall",e[e.HoldCall=3]="HoldCall",e[e.ResumeCall=4]="ResumeCall",e[e.Flash=5]="Flash",e[e.CallInProgress=6]="CallInProgress",e[e.CallRinging=7]="CallRinging",e[e.CallEnded=8]="CallEnded",e[e.TransferToHeadset=9]="TransferToHeadset",e[e.TransferToSpeaker=10]="TransferToSpeaker",e[e.Mute=11]="Mute",e[e.Unmute=12]="Unmute",e[e.MobileCallRinging=13]="MobileCallRinging",e[e.MobileCallInProgress=14]="MobileCallInProgress",e[e.MobileCallEnded=15]="MobileCallEnded",e[e.DOn=16]="DOn",e[e.DOff=17]="DOff",e[e.CallIdle=18]="CallIdle",e[e.Play=19]="Play",e[e.Pause=20]="Pause",e[e.Stop=21]="Stop",e[e.DTMLKey=22]="DTMLKey",e[e.RejectCall=23]="RejectCall",e[e.MakeCall=24]="MakeCall",e[e.Hook=25]="Hook",e[e.HookIdle=26]="HookIdle",e[e.HookDocked=27]="HookDocked",e[e.HookUndocked=28]="HookUndocked",e[e.BaseEvent=29]="BaseEvent",e[e.CallAnsweredAndEnded=30]="CallAnsweredAndEnded",e[e.CallUnansweredAndEnded=31]="CallUnansweredAndEnded",e[e.DeviceChange=32]="DeviceChange",e[e.DeviceArrived=33]="DeviceArrived",e[e.DeviceRemoved=34]="DeviceRemoved"}(H||(H={}));var Y=n(3),V=n.n(Y);function W(e){return(W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function K(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function q(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function s(e){K(o,r,i,s,a,"next",e)}function a(e){K(o,r,i,s,a,"throw",e)}s(void 0)}))}}function z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function $(e,t){return($=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function J(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Z(e);if(t){var i=Z(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return X(this,n)}}function X(e,t){if(t&&("object"===W(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Q(e)}function Q(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var te,ne,re=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&$(e,t)}(v,e);var t,n,r,i,o,s,a,c,u,l,f,h,d,p=J(v);function v(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,v),ee(Q(t=p.call(this,e)),"activePollingInterval",2e3),ee(Q(t),"connectedDeviceInterval",6e3),ee(Q(t),"disconnectedDeviceInterval",2e3),ee(Q(t),"deviceIdRetryInterval",2e3),ee(Q(t),"vendorName","Plantronics"),ee(Q(t),"pluginName","genesys-cloud-headset-library"),ee(Q(t),"apiHost","https://127.0.0.1:32018/Spokes"),ee(Q(t),"isActive",!1),ee(Q(t),"disableEventPolling",!1),ee(Q(t),"config",void 0),ee(Q(t),"deviceStatusTimer",null),ee(Q(t),"isRetry",!1),ee(Q(t),"_deviceInfo",void 0),ee(Q(t),"callEventsTimerId",void 0),ee(Q(t),"deviceStatusTimerId",void 0),ee(Q(t),"incomingConversationId",void 0),t.config=e,t._deviceInfo=null,t.callEventsTimerId=null,t.deviceStatusTimerId=null,t.incomingConversationId="",t}return t=v,n=[{key:"clearTimeouts",value:function(){clearTimeout(this.callEventsTimerId),clearTimeout(this.deviceStatusTimerId)}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["plantronics","plt","poly","(047f:"].some((function(e){return t.includes(e)}))}},{key:"deviceName",get:function(){var e;return null===(e=this._deviceInfo)||void 0===e?void 0:e.ProductName}},{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"pollForCallEvents",value:function(){var e=this;this.callEventsTimerId&&(clearTimeout(this.callEventsTimerId),this.callEventsTimerId=null),this.isConnected&&!this.disableEventPolling&&(this.logger.debug("**** POLLING FOR CALL EVENTS ****"),this.getCallEvents()),this.callEventsTimerId=setTimeout((function(){e.pollForCallEvents()}),this.activePollingInterval)}},{key:"pollForDeviceStatus",value:function(){var e=this;this.deviceStatusTimerId&&(clearTimeout(this.deviceStatusTimerId),this.deviceStatusTimerId=null),!this.isConnected||this.isConnecting||this.disableEventPolling||(this.logger.debug("**** POLLING FOR DEVICE STATUS ****"),this.getDeviceStatus()),this.deviceStatusTimerId=setTimeout((function(){e.pollForDeviceStatus()}),this.isDeviceAttached?this.connectedDeviceInterval:this.disconnectedDeviceInterval)}},{key:"_makeRequestTask",value:(d=q(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequest(t,n);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"_fetch",value:function(e){return B()(e)}},{key:"_makeRequest",value:(h=q(regeneratorRuntime.mark((function e(t,n){var r,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=v.instance,e.abrupt("return",this._fetch("".concat(this.apiHost).concat(t)).then((function(e){return e.json()})).then((function(e){if(!1===e.ok||"Error"===e.Type_Name){if(404===e.status){if(n){i.isConnected&&i.changeConnectionStatus({isConnected:!1,isConnecting:i.isConnecting}),i.disconnect();var o=new Error("Headset: Failed connection to middleware. Headset features unavailable.");return o.handled=!0,i.logger.info(o),Promise.reject(o)}return i._makeRequestTask(t,!0)}return V.a.isFirefox&&(i.errorCode="browser",i.disableRetry=!0),Promise.reject(e)}return r?(!i.isConnected&&i.changeConnectionStatus({isConnected:!0,isConnecting:i.isConnecting}),e):Promise.reject(new Error("Application destroyed."))})).catch((function(e){return Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"_checkIsActiveTask",value:(f=q(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getActiveCalls();case 2:t=e.sent,this.isActive=!!t.length;case 4:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"_getActiveCalls",value:(l=q(regeneratorRuntime.mark((function e(){var t,n,r,i,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/CallServices/CallManagerState?");case 3:i=e.sent,r=i,e.next=11;break;case 7:return e.prev=7,e.t0=e.catch(0),this.logger.info("Error making request for active calls",e.t0),e.abrupt("return",[]);case 11:if(Array.isArray(null===(t=r)||void 0===t||null===(n=t.Result)||void 0===n?void 0:n.Calls)){e.next=13;break}return e.abrupt("return",[]);case 13:return e.abrupt("return",r.Result.Calls.filter((function(e){return e.Source===o.pluginName})));case 14:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return l.apply(this,arguments)})},{key:"getCallEvents",value:(u=q(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/CallServices/CallEvents?name=".concat(this.pluginName));case 3:t=e.sent,e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(0),this.logger.info("Error making request for call events",e.t0),e.abrupt("return");case 10:t.Result&&t.Result.forEach((function(e){var t=H[e.Action];if(!t)return n.logger.info("Unknown call event from headset",{event:e});var r={name:t,code:e.Action,event:e};n.logger.debug("headset info",r),n.callCorrespondingFunction(r)}));case 11:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(){return u.apply(this,arguments)})},{key:"getDeviceStatus",value:(c=q(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequestTask("/DeviceServices/Info").then((function(e){t._deviceInfo=e.Result})).catch((function(e){e.Err&&e.Err.Description.includes("no supported devices")||t.logger.info("Error making request for device status",e)}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"callCorrespondingFunction",value:function(e){switch(e.name){case"AcceptCall":this.deviceAnsweredCall(e);break;case"RejectCall":this.deviceRejectedCall(this.incomingConversationId);break;case"TerminateCall":this.deviceEndedCall(e);break;case"CallEnded":this._checkIsActiveTask();break;case"Mute":this.deviceMuteChanged(!0,e);break;case"Unmute":this.deviceMuteChanged(!1,e);break;case"HoldCall":this.deviceHoldStatusChanged(!0,e);break;case"ResumeCall":this.deviceHoldStatusChanged(!1,e);break;default:this.logger.info("A headset event has occurred",e),this.deviceEventLogs(e)}}},{key:"connect",value:function(){var e=this;return!this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),this.pollForDeviceStatus(),this.pollForCallEvents(),this._makeRequestTask("/SessionManager/Register?name=".concat(this.pluginName)).catch((function(t){return t.Err&&"Plugin exists"===t.Err.Description?e.logger.debug("Plugin already exists",t):Promise.reject(t)})).then((function(){return e._makeRequestTask("/SessionManager/IsActive?name=".concat(e.pluginName,"&active=true"))})).catch((function(t){return t.Err&&!t.isError?e.logger.debug("Is Active",t):Promise.reject(t)})).then((function(t){return!0!==(null==t?void 0:t.Result)?Promise.reject(t):e._makeRequestTask("/UserPreference/SetDefaultSoftPhone?name=".concat(e.pluginName))})).then((function(){e.getDeviceStatus()})).then((function(){return e._getActiveCalls()})).then((function(t){return t.length?(e.isActive=!0,e.logger.info("Currently active calls in the session")):e.getCallEvents()})).catch((function(t){return null!=t&&t.handled?e.logger.error("Unable to properly connect headset"):Promise.reject(t)})).finally((function(){e.isConnecting&&e.changeConnectionStatus({isConnected:e.isConnected,isConnecting:!1})}))}},{key:"disconnect",value:function(){var e=this;return(this.isConnected?this._makeRequestTask("/SessionManager/UnRegister?name=".concat(this.pluginName)):Promise.resolve()).then((function(){e.clearTimeouts(),e._deviceInfo=null,e.isConnected&&e.changeConnectionStatus({isConnected:!1,isConnecting:e.isConnecting}),e.isActive=!1}))}},{key:"incomingCall",value:function(e){this.logger.info("Inside incomingCall of selected implementation (Plantronics/Poly)");var t=e.conversationId,n=e.contactName;if(!t)throw new Error("Must provide conversationId");this.incomingConversationId=t;var r="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),i='"Id":"'.concat(t,'"');if(r+="&callID={".concat(encodeURI(i),"}"),n){var o='"Name":"'.concat(n,'"');r+="&contact={".concat(encodeURI(o),"}")}return this.logger.info("params of endpoint",r),this.isActive=!0,this._makeRequestTask("/CallServices/IncomingCall".concat(encodeURI(r)))}},{key:"outgoingCall",value:function(e){var t=e.conversationId,n=e.contactName;if(!t)throw new Error("Must provide conversationId");var r="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),i='"Id":"'.concat(t,'"');if(r+="&callID={".concat(encodeURI(i),"}"),n){var o='"Name":"'.concat(n,'"');r+="&contact={".concat(encodeURI(o),"}")}return this.isActive=!0,this._makeRequestTask("/CallServices/OutgoingCall".concat(encodeURI(r)))}},{key:"answerCall",value:function(e){var t='"Id":"'.concat(e,'"'),n="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(t),"}");return this.isActive=!0,this.incomingConversationId="",this._makeRequestTask("/CallServices/AnswerCall".concat(encodeURI(n)))}},{key:"rejectCall",value:function(e){return this.incomingConversationId="",this.endCall(e)}},{key:"endCall",value:(a=q(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="?name=".concat(this.pluginName),r='"Id":"'.concat(t,'"'),n+="&callID={".concat(encodeURI(r),"}"),e.next=5,this._makeRequestTask("/CallServices/TerminateCall".concat(encodeURI(n)));case 5:return i=e.sent,e.next=8,this.getCallEvents();case 8:return this._checkIsActiveTask(),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"endAllCalls",value:(s=q(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getActiveCalls();case 2:e.sent.forEach((function(e){return t.endCall(e.CallId)}));case 4:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"setMute",value:(o=q(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequestTask("/CallServices/MuteCall?name=".concat(this.pluginName,"&muted=").concat(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setHold",value:(i=q(regeneratorRuntime.mark((function e(t,n){var r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r='"Id":"'.concat(t,'"'),i="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(r),"}"),e.next=4,this._makeRequestTask("/CallServices/".concat(n?"HoldCall":"ResumeCall").concat(encodeURI(i)));case 4:return o=e.sent,e.abrupt("return",o);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})}],r=[{key:"getInstance",value:function(e){return v.instance||(v.instance=new v(e)),v.instance}}],n&&z(t.prototype,n),r&&z(t,r),Object.defineProperty(t,"prototype",{writable:!1}),v}(G.a);function ie(){return!!window._HostedContextFunctions}function oe(e){return new Promise((function(t,n){try{var r=JSON.stringify(e);window.cefQuery({request:r,persistent:!1,onSuccess:function(e){try{var n=JSON.parse(e);t(n)}catch(e){t({})}},onFailure:function(e){n(e)}})}catch(e){console.error("Error requesting desktop promise",e),n(e)}}))}function se(e){return(se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ae(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ce(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ue(e,t){return(ue=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function le(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=de(e);if(t){var i=de(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return fe(this,n)}}function fe(e,t){if(t&&("object"===se(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return he(e)}function he(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function de(e){return(de=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function pe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}ee(re,"instance",void 0),function(e){e.SocketConnected="SocketConnected",e.EstablishConnection="EstablishConnection",e.SPLogin="SPLoggedIn",e.SPLogout="SPLoggedOut",e.TerminateConnection="TerminateConnection",e.IncomingCall="IncomingCall",e.IncomingCallRejected="InCallRejected",e.IncomingCallAccepted="InCallAccepted",e.OutgoingCall="OutgoingCall",e.CallEnded="CallEnded",e.SystemInformation="SystemInformation",e.HeadsetConnected="HeadsetConnected",e.HeadsetDisconnected="HeadsetDisconnected",e.Hold="CallHold",e.Resume="HeldCallResumed",e.MuteFromApp="MuteHeadset",e.UnmuteFromApp="UnmuteHeadset",e.MuteFromHeadset="MuteSoftphone",e.UnmuteFromHeadset="UnmuteSoftphone"}(te||(te={})),function(e){e.Request="Request",e.Notification="Notification",e.Ack="Acknowledgement"}(ne||(ne={}));var ve=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&ue(e,t)}(o,e);var t,n,r,i=le(o);function o(){var e;ae(this,o);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return pe(he(e=i.call.apply(i,[this].concat(n))),"connectTimeout",5e3),pe(he(e),"vendorName","Sennheiser"),pe(he(e),"isActive",!1),pe(he(e),"devices",null),pe(he(e),"activeDeviceId",null),pe(he(e),"websocketConnected",!1),pe(he(e),"callMappings",{}),pe(he(e),"websocket",null),pe(he(e),"deviceInfo",null),pe(he(e),"webSocketOnOpen",(function(){e.websocketConnected=!0,e.logger.info("websocket open the sennheiser software")})),e}return t=o,r=[{key:"getInstance",value:function(e){return o.instance||(o.instance=new o(e)),o.instance}}],(n=[{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["senn","epos"].some((function(e){return t.includes(e)}))}},{key:"deviceName",get:function(){return this.deviceInfo&&this.deviceInfo.ProductName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"_handleError",value:function(e){this.logger.error("Non-zero return code from sennheiser",e)}},{key:"_handleAck",value:function(e){this.logger.debug("Received Ack for ".concat(e.Event))}},{key:"_sendMessage",value:function(e){this.logger.debug("sending sennheiser message",e),this.websocket.send(JSON.stringify(e))}},{key:"_registerSoftphone",value:function(){var e={Event:te.EstablishConnection,EventType:ne.Request,SPName:"Genesys Cloud Softphone",SPIconImage:"SPImage.ico",RedialSupport:"No",OffHookSupport:"No",MuteSupport:"Yes",DNDOption:"No"};this._sendMessage(e)}},{key:"connect",value:function(){!this.isConnecting&&this.changeConnectionStatus({isConnected:!1,isConnecting:!0});var e=new WebSocket("wss://127.0.0.1:41088");return e.onopen=this.webSocketOnOpen.bind(this),e.onclose=this.webSocketOnClose.bind(this),e.onmessage=this._handleMessage.bind(this),this.websocket=e,Promise.resolve()}},{key:"webSocketOnClose",value:function(e){this.websocketConnected=!1,e.wasClean||this.logger.error(e),this.isConnected||(this.logger.error(new Error("Failed to connect to sennheiser software. Make sure it is installed")),V.a.isFireFox&&(this.errorCode="browser",this.disableRetry=!0)),(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1})}},{key:"disconnect",value:function(){return this.isConnected?(this._sendMessage({Event:te.TerminateConnection,EventType:ne.Request}),Promise.resolve()):Promise.resolve()}},{key:"_createCallMapping",value:function(e){var t,n=Math.round(Math.random()*Math.pow(10,7));return this.callMappings=(pe(t={},e,n),pe(t,n,e),t),this.logger.info("Created callId mapping for sennheiser headset",{conversationId:e,sennheiserCallId:n}),n}},{key:"setMute",value:function(e){return this._sendMessage({Event:e?te.MuteFromApp:te.UnmuteFromApp,EventType:ne.Request}),Promise.resolve()}},{key:"setHold",value:function(e,t){return this._sendMessage({Event:t?te.Hold:te.Resume,EventType:ne.Request,CallID:this.callMappings[e]}),Promise.resolve()}},{key:"incomingCall",value:function(e){var t=e.conversationId,n=this._createCallMapping(t);return this._sendMessage({Event:te.IncomingCall,EventType:ne.Request,CallID:n}),Promise.resolve()}},{key:"answerCall",value:function(e){return this._sendMessage({Event:te.IncomingCallAccepted,EventType:ne.Request,CallID:this.callMappings[e]}),Promise.resolve()}},{key:"rejectCall",value:function(e){return this._sendMessage({Event:te.IncomingCallRejected,EventType:ne.Request,CallID:this.callMappings[e]}),Promise.resolve()}},{key:"outgoingCall",value:function(e){var t=e.conversationId,n=this._createCallMapping(t);return this._sendMessage({Event:te.OutgoingCall,EventType:ne.Request,CallID:n}),Promise.resolve()}},{key:"endCall",value:function(e){var t=this.callMappings[e];return t?(this._sendMessage({Event:te.CallEnded,EventType:ne.Request,CallID:t}),Promise.resolve()):(this.logger.info("Failed to find sennheiser callId, assuming call was already ended"),Promise.resolve())}},{key:"endAllCalls",value:function(){return this.logger.warn("There is no functionality defined for SennheiserService.endAllCalls()"),Promise.resolve()}},{key:"_handleMessage",value:function(e){var t;try{t=JSON.parse(e.data)}catch(t){return this.logger.error(t),void this.logger.error("Failed to parse sennheiser payload",{message:e})}if(this.logger.debug("incoming sennheiser message",t),t.ReturnCode)this._handleError(t);else{var n,r=t.CallID;switch(r&&(n=this.callMappings[r]),t.Event){case te.SocketConnected:this._registerSoftphone();break;case te.EstablishConnection:this._sendMessage({Event:te.SPLogin,EventType:ne.Request});break;case te.SPLogin:this.isConnected&&!this.isConnecting||this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),this._sendMessage({Event:te.SystemInformation,EventType:ne.Request});break;case te.HeadsetConnected:t.HeadsetName&&(this.deviceInfo={deviceName:t.HeadsetName,headsetType:t.HeadsetType});break;case te.HeadsetDisconnected:t.HeadsetName===this.deviceName&&(this.deviceInfo=null);break;case te.IncomingCallAccepted:t.EventType===ne.Notification&&this.deviceAnsweredCall({name:t.Event});break;case te.Hold:if(t.EventType===ne.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged(!0,{name:t.Event});break;case te.Resume:if(t.EventType===ne.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged(!1,{name:t.Event});break;case te.MuteFromHeadset:this.deviceMuteChanged(!0,{name:t.Event});break;case te.UnmuteFromHeadset:this.deviceMuteChanged(!1,{name:t.Event});break;case te.CallEnded:delete this.callMappings[r],delete this.callMappings[n],t.EventType===ne.Notification&&this.deviceEndedCall({name:t.Event});break;case te.IncomingCallRejected:this.deviceRejectedCall(n);break;case te.TerminateConnection:1===this.websocket.readyState&&this.websocket.close(),this.websocket=null;break;default:t.EventType===ne.Ack&&this._handleAck(t)}}}}])&&ce(t.prototype,n),r&&ce(t,r),Object.defineProperty(t,"prototype",{writable:!1}),o}(G.a);pe(ve,"instance",void 0);var ge=n(0),ye=u((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function me(e,t){var n="object"==typeof t;return new Promise((function(r,i){var o=new k({next:function(e){r(e),o.unsubscribe()},error:i,complete:function(){n?r(t.defaultValue):i(new ye)}});e.subscribe(o)}))}function be(e){return function(t){if(function(e){return c(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}var Ee=function(e){function t(t,n,r,i,o){var s=e.call(this,t)||this;return s.onFinalize=o,s._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,s._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,s}return i(t,e),t.prototype.unsubscribe=function(){var t,n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))},t}(T);function we(e,t){return be((function(n,r){var i=0;n.subscribe(new Ee(r,(function(n){return e.call(t,n,i++)&&r.next(n)})))}))}var _e=new L((function(e){return e.complete()}));function Ce(e){return e<=0?function(){return _e}:be((function(t,n){var r=0;t.subscribe(new Ee(n,(function(t){++r<=e&&(n.next(t),e<=r&&n.complete())})))}))}function Oe(e){return be((function(t,n){var r=!1;t.subscribe(new Ee(n,(function(e){r=!0,n.next(e)}),(function(){r||n.next(e),n.complete()})))}))}function Te(e){return void 0===e&&(e=ke),be((function(t,n){var r=!1;t.subscribe(new Ee(n,(function(e){r=!0,n.next(e)}),(function(){return r?n.complete():n.error(e())})))}))}function ke(){return new ye}function Ie(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?we((function(t,n){return e(t,n,r)})):N,Ce(1),n?Oe(t):Te((function(){return new ye})))}}function Re(e){return(Re="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ae(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function Se(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function s(e){Ae(o,r,i,s,a,"next",e)}function a(e){Ae(o,r,i,s,a,"throw",e)}s(void 0)}))}}function Pe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ne(e,t){return(Ne=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function De(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=He(e);if(t){var i=He(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Le(this,n)}}function Le(e,t){if(t&&("object"===Re(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return xe(e)}function xe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function He(e){return(He=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ue(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Me,je=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&Ne(e,t)}(y,e);var t,n,r,i,o,s,a,c,u,l,f,h,d,p,v,g=De(y);function y(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,y),Ue(xe(t=g.call(this,e)),"headsetEventSubscription",void 0),Ue(xe(t),"isActive",!1),Ue(xe(t),"devices",void 0),Ue(xe(t),"activeDeviceId",null),Ue(xe(t),"isMuted",!1),Ue(xe(t),"isHeld",!1),Ue(xe(t),"version",null),Ue(xe(t),"_connectDeferred",void 0),Ue(xe(t),"device",null),Ue(xe(t),"jabraSdk",void 0),Ue(xe(t),"easyCallControlFactory",void 0),Ue(xe(t),"callControlFactory",void 0),Ue(xe(t),"multiCallControl",void 0),Ue(xe(t),"callControl",void 0),Ue(xe(t),"ongoingCalls",0),Ue(xe(t),"callLock",!1),Ue(xe(t),"incomingConversationId",""),t.vendorName="Jabra",t.devices=new Map,t}return t=y,n=[{key:"isSupported",value:function(){return window.navigator.hid&&!ie()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return!!["jabra"].some((function(e){return t.includes(e)}))&&(this.jabraSdk=this.initializeJabraSdk(),!0)}},{key:"deviceInfo",get:function(){return null===this.activeDeviceId||0===this.devices.size?null:this.devices.get(this.activeDeviceId)}},{key:"deviceName",get:function(){return this.deviceInfo.deviceName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"resetState",value:function(){this.setHold(null,!1),this.setMute(!1)}},{key:"_processEvents",value:(v=Se(regeneratorRuntime.mark((function e(t){var n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.headsetEventSubscription=t.deviceSignals.subscribe(function(){var e=Se(regeneratorRuntime.mark((function e(r){var i,o,s,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.callLock){e.next=3;break}return n.logger.debug("Currently not in possession of the Call Lock; Cannot react to Device Actions"),e.abrupt("return");case 3:e.t0=ge.u[r.type],e.next="HOOK_SWITCH"===e.t0?6:"FLASH"===e.t0||"ALT_HOLD"===e.t0?8:"PHONE_MUTE"===e.t0?12:"REJECT_CALL"===e.t0?16:19;break;case 6:if(r.value)t.offHook(!0),t.ring(!1),n.deviceAnsweredCall({name:"CallOffHook",code:r.type});else{t.mute(!1),t.hold(!1),t.offHook(!1),n.deviceEndedCall({name:"CallOnHook",code:r.type});try{t.releaseCallLock()}catch(e){i=e.message,o=e.type,n.checkForCallLockError(i,o)?n.logger.info(i):n.logger.error(o,i)}finally{n.callLock=!1}}return e.abrupt("break",19);case 8:return n.isHeld=!n.isHeld,t.hold(n.isHeld),n.deviceHoldStatusChanged(n.isHeld,{name:n.isHeld?"OnHold":"ResumeCall",code:r.type}),e.abrupt("break",19);case 12:return n.isMuted=!n.isMuted,t.mute(n.isMuted),n.deviceMuteChanged(n.isMuted,{name:n.isMuted?"CallMuted":"CallUnmuted",code:r.type}),e.abrupt("break",19);case 16:t.ring(!1),n.deviceRejectedCall(n.incomingConversationId);try{t.releaseCallLock()}catch(e){s=e.message,a=e.type,n.checkForCallLockError(s,a)?n.logger.info(s):n.logger.error(a,s)}finally{n.callLock=!1}case 19:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 1:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"setMute",value:(p=Se(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return");case 2:this.isMuted=t,this.callControl.mute(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"setHold",value:(d=Se(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return");case 2:this.isHeld=n,this.callControl.hold(n);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"incomingCall",value:(h=Se(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=16;break}return this.incomingConversationId=t.conversationId,e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:if(this.callLock=e.sent,!this.callLock){e.next=9;break}return this.callControl.ring(!0),e.abrupt("return",Promise.resolve());case 9:e.next=16;break;case 11:e.prev=11,e.t0=e.catch(2),n=e.t0.message,r=e.t0.type,this.checkForCallLockError(n,r)?(this.logger.info(n),this.callControl.ring(!0)):this.logger.error(r,n);case 16:case"end":return e.stop()}}),e,this,[[2,11]])}))),function(e){return h.apply(this,arguments)})},{key:"answerCall",value:(f=Se(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return");case 2:this.incomingConversationId="",this.callControl.offHook(!0);case 4:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"rejectCall",value:(l=Se(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.callLock){e.next=3;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 3:this.callControl.ring(!1),this.callControl.releaseCallLock(),e.next=12;break;case 7:e.prev=7,e.t0=e.catch(0),t=e.t0.message,n=e.t0.type,this.checkForCallLockError(t,n)?this.logger.info(t):this.logger.error(n,t);case 12:return e.prev=12,this.incomingConversationId="",this.callLock=!1,this.resetState(),e.finish(12);case 17:case"end":return e.stop()}}),e,this,[[0,7,12,17]])}))),function(){return l.apply(this,arguments)})},{key:"outgoingCall",value:(u=Se(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.callControl.takeCallLock();case 3:if(this.callLock=e.sent,!this.callLock){e.next=7;break}return this.callControl.offHook(!0),e.abrupt("return",Promise.resolve());case 7:e.next=14;break;case 9:e.prev=9,e.t0=e.catch(0),t=e.t0.message,n=e.t0.type,this.checkForCallLockError(t,n)?(this.logger.info(t),this.callControl.offHook(!0)):this.logger.error(n,t);case 14:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(){return u.apply(this,arguments)})},{key:"endCall",value:(c=Se(regeneratorRuntime.mark((function e(t,n){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:if(e.prev=2,this.callLock){e.next=5;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 5:this.callControl.offHook(!1),this.callControl.releaseCallLock(),e.next=14;break;case 9:e.prev=9,e.t0=e.catch(2),r=e.t0.message,i=e.t0.type,this.checkForCallLockError(r,i)?this.logger.info(r):this.logger.error(i,r);case 14:return e.prev=14,this.callLock=!1,this.resetState(),e.finish(14);case 18:case"end":return e.stop()}}),e,this,[[2,9,14,18]])}))),function(e,t){return c.apply(this,arguments)})},{key:"endAllCalls",value:(a=Se(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.callLock){e.next=3;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 3:this.callControl.offHook(!1),this.callControl.releaseCallLock(),e.next=12;break;case 7:e.prev=7,e.t0=e.catch(0),t=e.t0.message,n=e.t0.type,this.checkForCallLockError(t,n)?this.logger.info(t):this.logger.error(n,t);case 12:return e.prev=12,this.callLock=!1,this.resetState(),e.finish(12);case 16:case"end":return e.stop()}}),e,this,[[0,7,12,16]])}))),function(){return a.apply(this,arguments)})},{key:"isDeviceInList",value:function(e,t){var n;return t.includes(null==e||null===(n=e.name)||void 0===n?void 0:n.toLowerCase())}},{key:"connect",value:(s=Se(regeneratorRuntime.mark((function e(t){var n,r,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.toLowerCase(),this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),e.next=4,this.jabraSdk;case 4:n=e.sent,this.callControlFactory=this.createCallControlFactory(n),r=setTimeout(Se(regeneratorRuntime.mark((function e(){var o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,me(n.deviceList);case 2:if(o=e.sent,s=o.find((function(e){return i.isDeviceInList(e,t)}))){e.next=16;break}return e.prev=5,e.next=8,new Promise((function(e,r){var o,s,a=setTimeout(r,3e4);i.requestWebHidPermissions(ge.D),n.deviceList.pipe((o=function(e){return e.find((function(e){return i.isDeviceInList(e,t)}))},be((function(e,t){var n=0;e.subscribe(new Ee(t,(function(e){t.next(o.call(s,e,n++))})))}))),we(Boolean),Ie()).subscribe((function(t){clearTimeout(a),e(t)}))}));case 8:s=e.sent,e.next=16;break;case 11:return e.prev=11,e.t0=e.catch(5),i.isConnecting&&i.changeConnectionStatus({isConnected:i.isConnected,isConnecting:!1}),i.logger.error("The selected device was not granted WebHID permissions"),e.abrupt("return");case 16:return e.next=18,i.callControlFactory.createCallControl(s);case 18:i.callControl=e.sent,i._processEvents(i.callControl),i.isConnecting&&!i.isConnected&&i.changeConnectionStatus({isConnected:!0,isConnecting:!1}),clearTimeout(r);case 22:case"end":return e.stop()}}),e,null,[[5,11]])}))),2e3);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"initializeJabraSdk",value:(o=Se(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Object(ge.C)({appId:"softphone-vendor-headsets",appName:"Softphone Headset Library",transport:ge.z.CHROME_EXTENSION_WITH_WEB_HID_FALLBACK});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),function(){return o.apply(this,arguments)})},{key:"createCallControlFactory",value:function(e){return new ge.a(e)}},{key:"checkForCallLockError",value:function(e,t){return t===ge.b.SDK_USAGE_ERROR&&e.includes("call lock")}},{key:"disconnect",value:(i=Se(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.headsetEventSubscription&&this.headsetEventSubscription.unsubscribe(),(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1});case 2:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})}],r=[{key:"getInstance",value:function(e){return y.instance||(y.instance=new y(e)),y.instance}}],n&&Pe(t.prototype,n),r&&Pe(t,r),Object.defineProperty(t,"prototype",{writable:!1}),y}(G.a);Ue(je,"instance",void 0),Ue(je,"connectTimeout",5e3),function(e){e.Ring="ringer",e.Offhook="offhook",e.Mute="mute",e.Hold="hold"}(Me||(Me={}));var Fe;function Be(e){return(Be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ge(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function Ye(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ve(e,t){return(Ve=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function We(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ze(e);if(t){var i=ze(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Ke(this,n)}}function Ke(e,t){if(t&&("object"===Be(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return qe(e)}function qe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ze(e){return(ze=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e){e.OffHook="OffHook",e.Mute="Mute",e.Hold="Flash",e.RejectCall="RejectCall"}(Fe||(Fe={}));var Je=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&Ve(e,t)}(a,e);var t,n,r,i,o,s=We(a);function a(e){var t,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),$e(qe(n=s.call(this,e)),"isActive",!1),$e(qe(n),"devices",null),$e(qe(n),"activeDeviceId",null),$e(qe(n),"headsetState",null),$e(qe(n),"ignoreNextOffhookEvent",!1),$e(qe(n),"_connectionInProgress",void 0),$e(qe(n),"cefSupportsJabra",!0),$e(qe(n),"incomingConversationId",""),n.vendorName="Jabra",n.headsetState={ringing:!1,offHook:!1},n.devices=new Map;var r={assetURL:window.location.origin+window.location.pathname,callback:n.handleCefEvent.bind(qe(n)),supportsTerminationRequest:!0,supportsUnifiedPreferences:!0},i=null===(t=window._HostedContextFunctions)||void 0===t?void 0:t.register(r);return n.cefSupportsJabra=null==i?void 0:i.supportsJabra,n}return t=a,n=[{key:"deviceInfo",get:function(){return null===this.activeDeviceId||null===this.devices||this.devices&&!this.devices.size?null:this.devices.get(this.activeDeviceId)}},{key:"deviceName",get:function(){return this.deviceInfo&&this.deviceInfo.deviceName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"isHeadsetEvent",value:function(e){return"JabraEvent"===e.msg}},{key:"isDeviceEvent",value:function(e){return"JabraDeviceAttached"===e.msg}},{key:"handleCefEvent",value:function(e){this.isConnected&&(this.isDeviceEvent(e)?this.handleJabraDeviceAttached(e):this.isHeadsetEvent(e)&&this.handleJabraEvent(e))}},{key:"handleJabraDeviceAttached",value:function(e){this.logger.debug("handling jabra attach/detach event",e),this.updateDevices()}},{key:"handleJabraEvent",value:function(e){this.logger.debug("Jabra event received",e),this._processEvent(e.event,e.value)}},{key:"_handleOffhookEvent",value:function(e){e?this.headsetState.ringing&&(this.deviceAnsweredCall(),this._sendCmd(Me.Offhook,e),this._setRinging(!1)):(this._sendCmd(Me.Offhook,e),this._getHeadsetIntoVanillaState(),this.deviceEndedCall())}},{key:"_handleMuteEvent",value:function(e){this._sendCmd(Me.Mute,e),this.deviceMuteChanged(e)}},{key:"_handleHoldEvent",value:function(e){this._sendCmd(Me.Hold,!!e),this.deviceHoldStatusChanged(!!e)}},{key:"_getHeadsetIntoVanillaState",value:function(){this.setHold(null,!1),this.setMute(!1)}},{key:"_sendCmd",value:function(e,t){var n=this.activeDeviceId;this.logger.debug("Sending command to headset",{deviceId:n,cmd:e,value:t}),window._HostedContextFunctions.sendEventToDesktop("jabraEvent",{deviceID:n,event:e,value:t})}},{key:"_setRinging",value:function(e){this._sendCmd(Me.Ring,e),this.headsetState.ringing=e}},{key:"isSupported",value:function(){return ie()&&this.cefSupportsJabra}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["jabra"].some((function(e){return t.includes(e)}))}},{key:"setMute",value:function(e){return this._sendCmd(Me.Mute,e),Promise.resolve()}},{key:"setHold",value:function(e,t){return this._sendCmd(Me.Hold,t),Promise.resolve()}},{key:"incomingCall",value:function(e){return e&&(this.incomingConversationId=e.conversationId),this._setRinging(!0),Promise.resolve()}},{key:"answerCall",value:function(){return this.ignoreNextOffhookEvent=!0,this.incomingConversationId="",this._sendCmd(Me.Offhook,!0),Promise.resolve()}},{key:"rejectCall",value:function(){return this._setRinging(!1),this.incomingConversationId="",Promise.resolve()}},{key:"outgoingCall",value:function(){return this._sendCmd(Me.Offhook,!0),Promise.resolve()}},{key:"endCall",value:function(e,t){return this._setRinging(!1),t||this._sendCmd(Me.Offhook,!1),Promise.resolve()}},{key:"endAllCalls",value:function(){return this._setRinging(!1),this._sendCmd(Me.Offhook,!1),Promise.resolve()}},{key:"updateDevices",value:(i=regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,oe({cmd:"requestJabraDevices"});case 3:if(t=e.sent,this._connectionInProgress&&this._connectionInProgress.resolve(),this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),t&&t.length){e.next=11;break}return this.devices.clear(),this.activeDeviceId=null,this.logger.error(new Error("No attached jabra devices")),e.abrupt("return");case 11:this.logger.info("connected jabra devices",t),this.devices.clear(),t.forEach((function(e){return n.devices.set(e.deviceID,e)})),this.activeDeviceId=t[0].deviceID,this._setRinging(!1),this.setMute(!1),e.next=23;break;case 19:e.prev=19,e.t0=e.catch(0),this.logger.error("Failed to connect to jabra",e.t0),this.disconnect();case 23:case"end":return e.stop()}}),e,this,[[0,19]])})),o=function(){var e=this,t=arguments;return new Promise((function(n,r){var o=i.apply(e,t);function s(e){Ge(o,n,r,s,a,"next",e)}function a(e){Ge(o,n,r,s,a,"throw",e)}s(void 0)}))},function(){return o.apply(this,arguments)})},{key:"_processEvent",value:function(e,t){var n,r,i,o=this;switch(e){case Fe.OffHook:(n=function(){return o._handleOffhookEvent(t)},r=500,i=null,function(){clearTimeout(i),i=setTimeout((function(){n()}),r)})();break;case Fe.RejectCall:this.deviceRejectedCall(this.incomingConversationId);break;case Fe.Mute:this._handleMuteEvent(t);break;case Fe.Hold:this._handleHoldEvent(t)}}},{key:"connect",value:function(){var e,t,n,r,i,o=this;return this.changeConnectionStatus({isConnected:!1,isConnecting:!0}),(e=this.updateDevices(),t=5e3,i=new Promise((function(e,i){r=setTimeout((function(){clearTimeout(r),i(n||"Timed out in "+t+"ms")}),t)})).then((function(e){return clearTimeout(r),e})),Promise.race([e,i])).catch((function(e){o.logger.error("Failed to connect to Jabra",e)}))}},{key:"disconnect",value:function(){return this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),Promise.resolve()}}],r=[{key:"getInstance",value:function(e){return a.instance&&!e.createNew||(a.instance=new a(e)),a.instance}}],n&&Ye(t.prototype,n),r&&Ye(t,r),Object.defineProperty(t,"prototype",{writable:!1}),a}(G.a);$e(Je,"instance",void 0);var Xe=n(1);function Qe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ze(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qe(Object(n),!0).forEach((function(t){nt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function et(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function tt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function nt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var rt=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),nt(this,"plantronics",void 0),nt(this,"jabraNative",void 0),nt(this,"jabra",void 0),nt(this,"sennheiser",void 0),nt(this,"selectedImplementation",void 0),nt(this,"headsetEvents$",void 0),nt(this,"_headsetEvents$",void 0),nt(this,"logger",void 0),this._headsetEvents$=new M,this.headsetEvents$=this._headsetEvents$.asObservable(),this.logger=t.logger||console,this.plantronics=re.getInstance({logger:this.logger}),this.jabraNative=Je.getInstance({logger:this.logger}),this.jabra=je.getInstance({logger:this.logger}),this.sennheiser=ve.getInstance({logger:this.logger}),[this.plantronics,this.jabra,this.jabraNative,this.sennheiser].forEach((function(e){return n.subscribeToHeadsetEvents(e)}))}var t,n,r,i,o;return t=e,n=[{key:"implementations",get:function(){return[this.sennheiser,this.plantronics,this.jabra,this.jabraNative].filter((function(e){return e.isSupported()}))}},{key:"activeMicChange",value:function(e){if(e){var t=this.implementations.find((function(t){return t.deviceLabelMatchesVendor(e)}));t?this.changeImplementation(t,e):this.clearSelectedImplementation()}else this.clearSelectedImplementation()}},{key:"changeImplementation",value:(i=regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t!==this.selectedImplementation){e.next=2;break}return e.abrupt("return");case 2:if(!this.selectedImplementation){e.next=5;break}return e.next=5,this.selectedImplementation.disconnect();case 5:if(this.selectedImplementation=t,!t){e.next=9;break}return e.next=9,t.connect(n);case 9:this._headsetEvents$.next({event:Xe.a.implementationChanged,payload:t});case 10:case"end":return e.stop()}}),e,this)})),o=function(){var e=this,t=arguments;return new Promise((function(n,r){var o=i.apply(e,t);function s(e){et(o,n,r,s,a,"next",e)}function a(e){et(o,n,r,s,a,"throw",e)}s(void 0)}))},function(e,t){return o.apply(this,arguments)})},{key:"incomingCall",value:function(e,t){return this.performActionIfConnected("incomingCall",(function(n){return n.incomingCall(e,t)}))}},{key:"outgoingCall",value:function(e){return this.performActionIfConnected("outgoingCall",(function(t){return t.outgoingCall(e)}))}},{key:"answerCall",value:function(e){return this.performActionIfConnected("answerCall",(function(t){return t.answerCall(e)}))}},{key:"rejectCall",value:function(e){return this.performActionIfConnected("rejectCall",(function(t){return t.rejectCall(e)}))}},{key:"setMute",value:function(e){return this.performActionIfConnected("setMute",(function(t){return t.setMute(e)}))}},{key:"setHold",value:function(e,t){return this.performActionIfConnected("setHold",(function(n){return n.setHold(e,t)}))}},{key:"endCall",value:function(e,t){return this.performActionIfConnected("endCall",(function(n){return n.endCall(e,t)}))}},{key:"endAllCalls",value:function(){return this.performActionIfConnected("endAllCalls",(function(e){return e.endAllCalls()}))}},{key:"retryConnection",value:function(e){return this.selectedImplementation?this.selectedImplementation.connect(e):Promise.reject(new Error("No active headset implementation"))}},{key:"connectionStatus",value:function(){return this.selectedImplementation?this.selectedImplementation.isConnected||this.selectedImplementation.isConnecting?this.selectedImplementation.isConnected?"running":"checking":"notRunning":"noVendor"}},{key:"performActionIfConnected",value:function(e,t){var n=this.selectedImplementation;return n&&n.isConnected?t(n):(this.logger.info("Headset: No vendor headset connected [".concat(e,"]")),Promise.resolve())}},{key:"subscribeToHeadsetEvents",value:function(e){e.on(Xe.a.deviceAnsweredCall,this.handleDeviceAnsweredCall.bind(this)),e.on(Xe.a.deviceRejectedCall,this.handleDeviceRejectedCall.bind(this)),e.on(Xe.a.deviceEndedCall,this.handleDeviceEndedCall.bind(this)),e.on(Xe.a.deviceMuteChanged,this.handleDeviceMuteStatusChanged.bind(this)),e.on(Xe.a.deviceHoldStatusChanged,this.handleDeviceHoldStatusChanged.bind(this)),e.on(Xe.a.deviceEventLogs,this.handleDeviceLogs.bind(this)),e.on(Xe.a.deviceConnectionStatusChanged,this.handleDeviceConnectionStatusChanged.bind(this)),e.on(Xe.a.webHidPermissionRequested,this.handleWebHidPermissionRequested.bind(this))}},{key:"clearSelectedImplementation",value:function(){this.selectedImplementation&&this.selectedImplementation.disconnect(),this.selectedImplementation=null,this.handleDeviceConnectionStatusChanged()}},{key:"handleDeviceAnsweredCall",value:function(e){e.vendor===this.selectedImplementation&&(this.logger.info("Headset: device answered the call"),this._headsetEvents$.next({event:Xe.a.deviceAnsweredCall,payload:Ze({},e.body)}))}},{key:"handleDeviceRejectedCall",value:function(e){e.vendor===this.selectedImplementation&&(this.logger.info("Headset: device rejected the call"),this._headsetEvents$.next({event:Xe.a.deviceRejectedCall,payload:{conversationId:e.body.conversationId}}))}},{key:"handleDeviceEndedCall",value:function(e){this.logger.info("Headset: device ended the call"),this._headsetEvents$.next({event:Xe.a.deviceEndedCall,payload:Ze({},e.body)})}},{key:"handleDeviceMuteStatusChanged",value:function(e){this.logger.info("Headset: device mute status changed: ",e.body.isMuted),this._headsetEvents$.next({event:Xe.a.deviceMuteStatusChanged,payload:Ze({},e.body)})}},{key:"handleDeviceHoldStatusChanged",value:function(e){this.logger.info("Headset: device hold status changed",e.body.holdRequested),this._headsetEvents$.next({event:Xe.a.deviceHoldStatusChanged,payload:Ze({},e.body)})}},{key:"handleDeviceConnectionStatusChanged",value:function(){this._headsetEvents$.next({event:Xe.a.deviceConnectionStatusChanged,payload:this.connectionStatus()})}},{key:"handleWebHidPermissionRequested",value:function(e){this.logger.debug("Requesting Webhid Permissions"),this._headsetEvents$.next({event:Xe.a.webHidPermissionRequested,payload:Ze({},e.body)})}},{key:"handleDeviceLogs",value:function(e){this._headsetEvents$.next({event:Xe.a.loggableEvent,payload:Ze({},e.body)})}}],r=[{key:"getInstance",value:function(t){return e.instance&&!t.createNew||(e.instance=new e(t)),e.instance}}],n&&tt(t.prototype,n),r&&tt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();nt(rt,"instance",void 0)},function(e,t,n){"use strict";n.r(t);var r=n(11),i=n(2);n.d(t,"VendorImplementation",(function(){return i.a}));var o=n(6);for(var s in o)["default","VendorImplementation"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(s);var a=n(1);n.d(t,"HeadsetEvents",(function(){return a.a}));var c=n(7);for(var s in c)["default","VendorImplementation","HeadsetEvents"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(s);n(8);var u=n(9);for(var s in u)["default","VendorImplementation","HeadsetEvents"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return u[e]}))}(s);t.default=r.a},,function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,u=[],l=!1,f=-1;function h(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&d())}function d(){if(!l){var e=a(h);l=!0;for(var t=u.length;t;){for(c=u,u=[];++f<t;)c&&c[f].run();f=-1,t=u.length}c=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function v(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new p(e,t)),1!==u.length||l||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=v,i.addListener=v,i.once=v,i.off=v,i.removeListener=v,i.removeAllListeners=v,i.emit=v,i.prependListener=v,i.prependOnceListener=v,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";(function(e){
|
|
70
70
|
/*!
|
|
71
71
|
* The buffer module from node.js, for the browser.
|
|
72
72
|
*
|