softphone-vendor-headsets 2.5.6-develop.1 → 2.5.6-develop.3
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.
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
23
23
|
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
-
e.exports=function(){var e=function(e,t,n,r,i,o){for(var a=function(e,t){var n=e.toString(16);return n.length<2&&(n="0"+n),t&&(n=n.toUpperCase()),n},s=t;s<=n;s++)i[o++]=a(e[s],r);return i},t=function(e,t,n,r,i){for(var o=t;o<=n;o+=2)r[i++]=parseInt(e.substr(o,2),16)},n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#".split(""),r=[0,68,0,84,83,82,72,0,75,76,70,65,0,63,62,69,0,1,2,3,4,5,6,7,8,9,64,0,73,66,74,71,81,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,77,0,78,67,0,0,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,79,0,80,0,0],o=function(e,t){if(t%4!=0)throw new Error("z85_encode: invalid input length (multiple of 4 expected)");for(var r="",i=0,o=0;i<t;)if(o=256*o+e[i++],i%4==0){for(var a=52200625;a>=1;){var s=Math.floor(o/a)%85;r+=n[s],a/=85}o=0}return r},a=function(e,t){var n=e.length;if(n%5!=0)throw new Error("z85_decode: invalid input length (multiple of 5 expected)");void 0===t&&(t=new Array(4*n/5));for(var i=0,o=0,a=0;i<n;){var s=e.charCodeAt(i++)-32;if(s<0||s>=r.length)break;if(a=85*a+r[s],i%5==0){for(var c=16777216;c>=1;)t[o++]=Math.trunc(a/c%256),c/=256;a=0}}return t},s=function(e,t){var n={ibits:8,obits:8,obigendian:!0};for(var r in t)void 0!==n[r]&&(n[r]=t[r]);for(var i,o,a,s=[],c=0,u=0,l=0,f=e.length;0===u&&(o=e.charCodeAt(c++)),i=o>>n.ibits-(u+8)&255,u=(u+8)%n.ibits,n.obigendian?0===l?a=i<<n.obits-8:a|=i<<n.obits-8-l:0===l?a=i:a|=i<<l,!(0==(l=(l+8)%n.obits)&&(s.push(a),c>=f)););return s},c=function(e,t){var n={ibits:32,ibigendian:!0};for(var r in t)void 0!==n[r]&&(n[r]=t[r]);var i="",o=4294967295;n.ibits<32&&(o=(1<<n.ibits)-1);for(var a=e.length,s=0;s<a;s++)for(var c=e[s]&o,u=0;u<n.ibits;u+=8)n.ibigendian?i+=String.fromCharCode(c>>n.ibits-8-u&255):i+=String.fromCharCode(c>>u&255);return i},u=256,l=function(e,t,n,r,i,o,a,s){return[s,a,o,i,r,n,t,e]},f=function(){return l(0,0,0,0,0,0,0,0)},h=function(e){return e.slice(0)},d=function(e){for(var t=f(),n=0;n<8;n++)t[n]=Math.floor(e%u),e/=u;return t},p=function(e){for(var t=0,n=7;n>=0;n--)t*=u,t+=e[n];return Math.floor(t)},v=function(e,t){for(var n=0,r=0;r<8;r++)n+=e[r]+t[r],e[r]=Math.floor(n%u),n=Math.floor(n/u);return n},y=function(e,t){for(var n=0,r=0;r<8;r++)n+=e[r]*t,e[r]=Math.floor(n%u),n=Math.floor(n/u);return n},g=function(e,t){for(var n=0;n<8;n++)e[n]&=t[n];return e},m=function(e,t){var n=f();if(t%8!=0)throw new Error("ui64_rorn: only bit rotations supported with a multiple of digit bits");for(var r=Math.floor(t/8),i=0;i<r;i++){for(var o=6;o>=0;o--)n[o+1]=n[o];for(n[0]=e[0],o=0;o<7;o++)e[o]=e[o+1];e[o]=0}return p(n)},b=function(e,t){if(t>64)throw new Error("ui64_ror: invalid number of bits to shift");var n,r=new Array(16);for(n=0;n<8;n++)r[n+8]=e[n],r[n]=0;var i=Math.floor(t/8),o=t%8;for(n=i;n<15;n++)r[n-i]=255&(r[n]>>>o|r[n+1]<<8-o);for(r[15-i]=r[15]>>>o&255,n=15-i+1;n<16;n++)r[n]=0;for(n=0;n<8;n++)e[n]=r[n+8];return r.slice(0,8)},w=function(e,t){for(var n=0;n<8;n++)e[n]^=t[n]},E=function(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n},C=function(e,t){return e<<t&4294967295|e>>>32-t&4294967295},_=function(e){return c(function(e,t){function n(e,t,n,r){return e<20?t&n|~t&r:e<40?t^n^r:e<60?t&n|t&r|n&r:t^n^r}function r(e){return e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514}e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var i=Array(80),o=1732584193,a=-271733879,s=-1732584194,c=271733878,u=-1009589776,l=0;l<e.length;l+=16){for(var f=o,h=a,d=s,p=c,v=u,y=0;y<80;y++){i[y]=y<16?e[l+y]:C(i[y-3]^i[y-8]^i[y-14]^i[y-16],1);var g=E(E(C(o,5),n(y,a,s,c)),E(E(u,i[y]),r(y)));u=c,c=s,s=C(a,30),a=o,o=g}o=E(o,f),a=E(a,h),s=E(s,d),c=E(c,p),u=E(u,v)}return[o,a,s,c,u]}(s(e,{ibits:8,obits:32,obigendian:!0}),8*e.length),{ibits:32,ibigendian:!0})},I=function(e){return c(function(e,t){function n(e,t,n,r,i,o){return E(C(E(E(t,e),E(r,o)),i),n)}function r(e,t,r,i,o,a,s){return n(t&r|~t&i,e,t,o,a,s)}function i(e,t,r,i,o,a,s){return n(t&i|r&~i,e,t,o,a,s)}function o(e,t,r,i,o,a,s){return n(t^r^i,e,t,o,a,s)}function a(e,t,r,i,o,a,s){return n(r^(t|~i),e,t,o,a,s)}e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var s=1732584193,c=-271733879,u=-1732584194,l=271733878,f=0;f<e.length;f+=16){var h=s,d=c,p=u,v=l;s=r(s,c,u,l,e[f+0],7,-680876936),l=r(l,s,c,u,e[f+1],12,-389564586),u=r(u,l,s,c,e[f+2],17,606105819),c=r(c,u,l,s,e[f+3],22,-1044525330),s=r(s,c,u,l,e[f+4],7,-176418897),l=r(l,s,c,u,e[f+5],12,1200080426),u=r(u,l,s,c,e[f+6],17,-1473231341),c=r(c,u,l,s,e[f+7],22,-45705983),s=r(s,c,u,l,e[f+8],7,1770035416),l=r(l,s,c,u,e[f+9],12,-1958414417),u=r(u,l,s,c,e[f+10],17,-42063),c=r(c,u,l,s,e[f+11],22,-1990404162),s=r(s,c,u,l,e[f+12],7,1804603682),l=r(l,s,c,u,e[f+13],12,-40341101),u=r(u,l,s,c,e[f+14],17,-1502002290),s=i(s,c=r(c,u,l,s,e[f+15],22,1236535329),u,l,e[f+1],5,-165796510),l=i(l,s,c,u,e[f+6],9,-1069501632),u=i(u,l,s,c,e[f+11],14,643717713),c=i(c,u,l,s,e[f+0],20,-373897302),s=i(s,c,u,l,e[f+5],5,-701558691),l=i(l,s,c,u,e[f+10],9,38016083),u=i(u,l,s,c,e[f+15],14,-660478335),c=i(c,u,l,s,e[f+4],20,-405537848),s=i(s,c,u,l,e[f+9],5,568446438),l=i(l,s,c,u,e[f+14],9,-1019803690),u=i(u,l,s,c,e[f+3],14,-187363961),c=i(c,u,l,s,e[f+8],20,1163531501),s=i(s,c,u,l,e[f+13],5,-1444681467),l=i(l,s,c,u,e[f+2],9,-51403784),u=i(u,l,s,c,e[f+7],14,1735328473),s=o(s,c=i(c,u,l,s,e[f+12],20,-1926607734),u,l,e[f+5],4,-378558),l=o(l,s,c,u,e[f+8],11,-2022574463),u=o(u,l,s,c,e[f+11],16,1839030562),c=o(c,u,l,s,e[f+14],23,-35309556),s=o(s,c,u,l,e[f+1],4,-1530992060),l=o(l,s,c,u,e[f+4],11,1272893353),u=o(u,l,s,c,e[f+7],16,-155497632),c=o(c,u,l,s,e[f+10],23,-1094730640),s=o(s,c,u,l,e[f+13],4,681279174),l=o(l,s,c,u,e[f+0],11,-358537222),u=o(u,l,s,c,e[f+3],16,-722521979),c=o(c,u,l,s,e[f+6],23,76029189),s=o(s,c,u,l,e[f+9],4,-640364487),l=o(l,s,c,u,e[f+12],11,-421815835),u=o(u,l,s,c,e[f+15],16,530742520),s=a(s,c=o(c,u,l,s,e[f+2],23,-995338651),u,l,e[f+0],6,-198630844),l=a(l,s,c,u,e[f+7],10,1126891415),u=a(u,l,s,c,e[f+14],15,-1416354905),c=a(c,u,l,s,e[f+5],21,-57434055),s=a(s,c,u,l,e[f+12],6,1700485571),l=a(l,s,c,u,e[f+3],10,-1894986606),u=a(u,l,s,c,e[f+10],15,-1051523),c=a(c,u,l,s,e[f+1],21,-2054922799),s=a(s,c,u,l,e[f+8],6,1873313359),l=a(l,s,c,u,e[f+15],10,-30611744),u=a(u,l,s,c,e[f+6],15,-1560198380),c=a(c,u,l,s,e[f+13],21,1309151649),s=a(s,c,u,l,e[f+4],6,-145523070),l=a(l,s,c,u,e[f+11],10,-1120210379),u=a(u,l,s,c,e[f+2],15,718787259),c=a(c,u,l,s,e[f+9],21,-343485551),s=E(s,h),c=E(c,d),u=E(u,p),l=E(l,v)}return[s,c,u,l]}(s(e,{ibits:8,obits:32,obigendian:!1}),8*e.length),{ibits:32,ibigendian:!1})},k=function(e){this.mul=l(88,81,244,45,76,149,127,45),this.inc=l(20,5,123,126,247,103,129,79),this.mask=l(0,0,0,0,255,255,255,255),this.state=h(this.inc),this.next(),g(this.state,this.mask),e=d(void 0!==e?e>>>0:4294967295*Math.random()>>>0),function(e,t){for(var n=0;n<8;n++)e[n]|=t[n]}(this.state,e),this.next()};k.prototype.next=function(){var e=h(this.state);(function(e,t){var n,r,i,o=new Array(16);for(n=0;n<16;n++)o[n]=0;for(n=0;n<8;n++){for(i=0,r=0;r<8;r++)i+=e[n]*t[r]+o[n+r],o[n+r]=i%u,i/=u;for(;r<16-n;r++)i+=o[n+r],o[n+r]=i%u,i/=u}for(n=0;n<8;n++)e[n]=o[n];o.slice(8,8)})(this.state,this.mul),v(this.state,this.inc);var t=h(e);b(t,18),w(t,e),b(t,27);var n=h(e);b(n,59),g(t,this.mask);var r=p(n),i=h(t);return function(e,t){if(t>64)throw new Error("ui64_rol: invalid number of bits to shift");var n,r=new Array(16);for(n=0;n<8;n++)r[n+8]=0,r[n]=e[n];var i=Math.floor(t/8),o=t%8;for(n=7-i;n>0;n--)r[n+i]=255&(r[n]<<o|r[n-1]>>>8-o);for(r[0+i]=r[0]<<o&255,n=0+i-1;n>=0;n--)r[n]=0;for(n=0;n<8;n++)e[n]=r[n];r.slice(8,8)}(i,32-r),b(t,r),w(t,i),p(t)};var O=new k,S=function(e,t){for(var n=[],r=0;r<e;r++)n[r]=O.next()%t;return n},T=0,x=0,A=function(){if(1===arguments.length&&"string"==typeof arguments[0])this.parse.apply(this,arguments);else if(arguments.length>=1&&"number"==typeof arguments[0])this.make.apply(this,arguments);else{if(arguments.length>=1)throw new Error("UUID: constructor: invalid arguments");for(var e=0;e<16;e++)this[e]=0}};return(A.prototype="undefined"!=typeof Uint8Array?new Uint8Array(16):i?i.alloc(16):new Array(16)).constructor=A,A.prototype.make=function(e){var t,n=this;if(1===e){var r=(new Date).getTime();r!==T?x=0:x++,T=r;var i,o=d(r);y(o,1e4),v(o,l(1,178,29,210,19,129,64,0)),x>0&&v(o,d(x)),i=m(o,8),n[3]=255&i,i=m(o,8),n[2]=255&i,i=m(o,8),n[1]=255&i,i=m(o,8),n[0]=255&i,i=m(o,8),n[5]=255&i,i=m(o,8),n[4]=255&i,i=m(o,8),n[7]=255&i,i=m(o,8),n[6]=15&i;var a=S(2,255);n[8]=a[0],n[9]=a[1];var s=S(6,255);for(s[0]|=1,s[0]|=2,t=0;t<6;t++)n[10+t]=s[t]}else if(4===e){var c=S(16,255);for(t=0;t<16;t++)this[t]=c[t]}else{if(3!==e&&5!==e)throw new Error("UUID: make: invalid version");var u="",f="object"==typeof arguments[1]&&arguments[1]instanceof A?arguments[1]:(new A).parse(arguments[1]);for(t=0;t<16;t++)u+=String.fromCharCode(f[t]);u+=arguments[2];var h=3===e?I(u):_(u);for(t=0;t<16;t++)n[t]=h.charCodeAt(t)}return n[6]&=15,n[6]|=e<<4,n[8]&=63,n[8]|=128,n},A.prototype.format=function(t){var n,r;return"z85"===t?n=o(this,16):"b16"===t?(r=Array(32),e(this,0,15,!0,r,0),n=r.join("")):void 0!==t&&"std"!==t||(r=new Array(36),e(this,0,3,!1,r,0),r[8]="-",e(this,4,5,!1,r,9),r[13]="-",e(this,6,7,!1,r,14),r[18]="-",e(this,8,9,!1,r,19),r[23]="-",e(this,10,15,!1,r,24),n=r.join("")),n},A.prototype.toString=function(e){return this.format(e)},A.prototype.toJSON=function(){return this.format("std")},A.prototype.parse=function(e,n){if("string"!=typeof e)throw new Error("UUID: parse: invalid argument (type string expected)");if("z85"===n)a(e,this);else if("b16"===n)t(e,0,35,this,0);else if(void 0===n||"std"===n){var r={nil:"00000000-0000-0000-0000-000000000000","ns:DNS":"6ba7b810-9dad-11d1-80b4-00c04fd430c8","ns:URL":"6ba7b811-9dad-11d1-80b4-00c04fd430c8","ns:OID":"6ba7b812-9dad-11d1-80b4-00c04fd430c8","ns:X500":"6ba7b814-9dad-11d1-80b4-00c04fd430c8"};if(void 0!==r[e])e=r[e];else if(!e.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))throw new Error('UUID: parse: invalid string representation (expected "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")');t(e,0,7,this,0),t(e,9,12,this,4),t(e,14,17,this,6),t(e,19,22,this,8),t(e,24,35,this,10)}return this},A.prototype.export=function(){for(var e=Array(16),t=0;t<16;t++)e[t]=this[t];return e},A.prototype.import=function(e){if(!("object"==typeof e&&e instanceof Array))throw new Error("UUID: import: invalid argument (type Array expected)");if(16!==e.length)throw new Error("UUID: import: invalid argument (Array of length 16 expected)");for(var t=0;t<16;t++){if("number"!=typeof e[t])throw new Error("UUID: import: invalid array element #"+t+" (type Number expected)");if(!isFinite(e[t])||Math.floor(e[t])!==e[t])throw new Error("UUID: import: invalid array element #"+t+" (Number with integer value expected)");if(!(e[t]>=0&&e[t]<=255))throw new Error("UUID: import: invalid array element #"+t+" (Number with integer value in range 0...255 expected)");this[t]=e[t]}return this},A.prototype.compare=function(e){if("object"!=typeof e)throw new Error("UUID: compare: invalid argument (type UUID expected)");if(!(e instanceof A))throw new Error("UUID: compare: invalid argument (type UUID expected)");for(var t=0;t<16;t++){if(this[t]<e[t])return-1;if(this[t]>e[t])return 1}return 0},A.prototype.equal=function(e){return 0===this.compare(e)},A.prototype.fold=function(e){if(void 0===e)throw new Error("UUID: fold: invalid argument (number of fold operations expected)");if(e<1||e>4)throw new Error("UUID: fold: invalid argument (1-4 fold operations expected)");for(var t=16/Math.pow(2,e),n=new Array(t),r=0;r<t;r++){for(var i=0,o=0;r+o<16;o+=t)i^=this[r+o];n[r]=i}return n},A.PCG=k,A}(),e.exports.default=e.exports}));class rn{constructor(e){this.transport=e,this.gnpLockAcquired=e.consoleAppEvent.pipe(rt(e=>"response-gnp-lock"===e.event),Me(e=>e.token),mt(1)),this.gnpLockAcquired.subscribe()}acquireGnpLock(e){const t=new nn(4).toString(),n={action:"request-gnp-lock",id:e,token:t},r=this.gnpLockAcquired.pipe(dt(e=>e===t));return this.transport.writeAction(n),r}releaseGnpLock(e,t){const n={action:"release-gnp-lock",id:e,token:t};this.transport.writeAction(n)}}!function(e){e[e.INPUT=0]="INPUT",e[e.OUTPUT=1]="OUTPUT",e[e.FEATURE=2]="FEATURE"}(en||(en={})),function(e){e.ABSOLUTE="absolute",e.RELATIVE="relative"}(tn||(tn={}));class on{constructor(e){this.id=e}equals(e){return this.id===e.id}startsWith(e){return this.id.startsWith(e.id)}toString(){return this.id}}function an(e,t,n){const r=e.toString(16).padStart(4,"0"),i=t.toString(16).padStart(4,"0");return new on(`${r}:${i}:${n}`)}class sn{constructor(e,t,n,r){this.id=e,this.usagePage=t,this.usage=n,this.value=r}isArray(){return Array.isArray(this.value)}static deserialize(e,t){return new sn(new on(e),t.usagePage,t.usage,t.value)}}class cn{constructor(e,t,n){this.descriptor=t,this.transport=n,this.transportId=e.transportId,this.input=n.consoleAppEvent.pipe(rt(e=>e.id===this.transportId),cn.inputReportsFilter)}output(e,t,n){const r={action:"hid-output",id:this.transportId,usagePage:e,usage:t,value:n};this.transport.writeAction(r)}getFeatureReport(e,t){const n=new nn(4).toString(),r={action:"request-hid-feature",id:this.transportId,token:n,usagePage:e,usage:t};return this.transport.writeAction(r),this.transport.consoleAppEvent.pipe(dt(e=>"response-hid-feature"===e.event&&e.token===n),Me(e=>e.value))}setFeatureReport(e,t,n){const r={action:"set-hid-feature",id:this.transportId,usagePage:e,usage:t,value:n};this.transport.writeAction(r)}findDescriptor(e,t,n){return this.descriptor.find(r=>r.usagePage===e&&r.usage===t&&r.reportType===n)}}cn.inputReportsFilter=e=>e.pipe(rt(e=>"hid-input"===e.event),Me(e=>sn.deserialize(e.id,e)));class un{static typeFromAttr(e){return e>>6}static packetLengthFromAttr(e){return e&this.lengthMask}static deserialize(e){const t=e[0],n=e[1],r=e[2],i=this.typeFromAttr(e[3]),o=e[4],a=e[5],s=this.packetLengthFromAttr(e[3]),c=e.slice(6,s);return new Vt(t,n,i,o,a,c,r)}}un.lengthMask=63;class ln{constructor(){this.data=[]}hasHeader(){return this.data.length>=ln.gnpPacketHeaderLength}expectedPacketLength(){if(!this.hasHeader())throw new It("Unable to get expected packet length without a full header",$e.UNEXPECTED_ERROR);return un.packetLengthFromAttr(this.data[3])}appendData(e){this.hasHeader()&&this.expectedPacketLength()>ln.gnpPacketMaxLength&&(this.data=[]),this.data=this.data.concat(e)}hasFullPacket(){if(!this.hasHeader())return!1;const e=this.expectedPacketLength();return this.data.length>=e}getPacketAndReset(){if(!this.hasFullPacket())throw new It("Trying to get packet but buffer is not complete",$e.UNEXPECTED_ERROR);const e=un.deserialize(Uint8Array.from(this.data));return this.data=[],e}}ln.gnpPacketHeaderLength=6,ln.gnpPacketMaxLength=63;const fn=()=>{};function hn(e){return _t(t=>e(),t=>e(),()=>fn)}const dn=()=>{return e=e=>e.command===Ft.NACK,t=e=>{const t=e.subCommand in Gt?Gt[e.subCommand]:e.subCommand;return new It("Got NACK response. Reason: "+t,$e.DEVICE_ERROR)},n=>n.pipe(Me(n=>e(n)?Le(t(n)):Ae(n)),Et());var e,t},pn=e=>dt(t=>t.type===Mt.REPLY&&t.sequenceNumber===e.sequenceNumber&&t.destination===e.source&&t.source===e.destination);class vn{constructor(e,t,n,r,i=0){this.hidChannel=e,this.gnpLock=t,this.transportId=n,this.primaryAddress=r,this.lockQueue=[],this.packets=e.input.pipe(vn.inputFilter),this.events=this.packets.pipe(vn.eventsFilter),this.nextSequenceNumber=i}static get inputFilter(){return e=>{const t=e.pipe(rt(e=>e.usagePage===jt.GN_PROTOCOL&&e.usage===Ht.DATA&&e.isArray())),n=new ln;return t.pipe(Fe(e=>{const t=e.value;return n.appendData(t),n.hasFullPacket()?Ae(n.getPacketAndReset()):Ze}),yt())}}static supportsGnpOverHid(e){return void 0!==e.findDescriptor(jt.GN_PROTOCOL,Ht.DATA,en.OUTPUT)}getNextSequenceNumber(){const e=this.nextSequenceNumber;return this.nextSequenceNumber=(this.nextSequenceNumber+1)%255,e}doWithGnpLockHeld(e){this.lockQueue.push(e),this.lockQueue.length>1||this.processLockQueue()}processLockQueue(){this.gnpLock.acquireGnpLock(this.transportId).subscribe(e=>{(0,this.lockQueue[0])(e=>{var t;const n=null===(t=this.hidChannel.findDescriptor(jt.GN_PROTOCOL,Ht.DATA,en.OUTPUT))||void 0===t?void 0:t.reportSize;if(!n)throw new It("Cannot send GNP packets to this device.",$e.DEVICE_ERROR);const r=class{static attrFromTypeAndPayloadLength(e,t){return(e<<6)+(t+6)}static serialize(e){const t=new Uint8Array(6);t[0]=e.destination,t[1]=e.source,t[2]=e.sequenceNumber,t[3]=this.attrFromTypeAndPayloadLength(e.type,e.payload.length),t[4]=e.command,t[5]=e.subCommand;const n=new Uint8Array(t.length+e.payload.length);return n.set(t),n.set(e.payload,t.length),n}}.serialize(e);let i=0;do{const e=Math.min(r.length-i,n),t=r.subarray(i,i+e);i+=t.length,this.hidChannel.output(jt.GN_PROTOCOL,Ht.DATA,Array.from(t))}while(i<r.length)},this.packets,()=>{this.gnpLock.releaseGnpLock(this.transportId,e),this.lockQueue.splice(0,1),this.lockQueue.length>0&&this.processLockQueue()})})}sendEvent(e,t,n=this.primaryAddress){const r=new Vt(n,Ut.PC_ADDR,Mt.EVENT,e.command,e.subCommand,e.serialize(t),0);this.doWithGnpLockHeld((e,t,n)=>{e(r),n()})}read(e,t=this.primaryAddress,n=2500){const r=new Yt(e,e=>new Uint8Array);return this.readWithParams(r,null,t,n)}readWithParams(e,t,n=this.primaryAddress,r=2500){const i=new Vt(n,Ut.PC_ADDR,Mt.READ,e.command,e.subCommand,e.serialize(t),this.getNextSequenceNumber()),o=new X;return this.doWithGnpLockHeld((t,n,a)=>{n.pipe(pn(i),dn(),dt(e=>e.command===i.command&&e.subCommand===i.subCommand),He(r),hn(a),Me(t=>e.deserialize(t))).subscribe(o),t(i)}),o}write(e,t,n=this.primaryAddress,r=2500){const i=new Vt(n,Ut.PC_ADDR,Mt.WRITE,e.command,e.subCommand,e.serialize(t),this.getNextSequenceNumber()),o=new X;return this.doWithGnpLockHeld((e,t,n)=>{t.pipe(pn(i),dn(),dt(e=>e.command===Ft.ACK),He(r),hn(n),Me(()=>!0)).subscribe(o),e(i)}),o}}vn.eventsFilter=e=>e.pipe(rt(e=>e.type===Mt.EVENT));class yn{constructor(e,t){this.parentGnpChannel=e,this.primaryAddress=t,this.events=e.events.pipe(rt(e=>e.source===this.primaryAddress))}sendEvent(e,t,n){this.parentGnpChannel.sendEvent(e,t,this.primaryAddress)}read(e,t,n){return this.parentGnpChannel.read(e,this.primaryAddress,n)}readWithParams(e,t,n,r){return this.parentGnpChannel.readWithParams(e,t,this.primaryAddress,r)}write(e,t,n,r){return this.parentGnpChannel.write(e,t,this.primaryAddress,r)}}function gn(e,t,n,r){if(!vn.supportsGnpOverHid(e))return Le(()=>new It("Device does not support GNP commands.",$e.DEVICE_ERROR));const i=Ae(Ut.HS_BT_USB_ADDR,Ut.BASE_ADDR,Ut.CRADLE_ADDR,Ut.HS1_ADDR,Ut.HS_CRADLE_ADDR).pipe(Me((r,i)=>Ve(()=>{const o=new vn(e,new rn(t),n,r,i);return o.read(Xt,r,500).pipe(Me(e=>o),st(()=>ce))})),Ge(),lt(1),ft(()=>new It("GNP probe failed.",$e.DEVICE_ERROR)));return it(r.pipe(Fe(e=>Le(()=>new It("Device was suddenly disconnected.",$e.DEVICE_ERROR)))),i).pipe(yt())}function mn(e,t){return new yn(e,t)}class bn{constructor(){this.primaryAddress=Ut.BASE_ADDR,this.events=Ze}subscribeToEvent(e,t){return Le(()=>new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED))}sendEvent(e,t,n){throw new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED)}read(e,t,n){return Le(()=>new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED))}readWithParams(e,t,n,r){return Le(()=>new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED))}write(e,t,n,r){return Le(()=>new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED))}}class wn{constructor(e){this.transportId=e,this.isChild=!1}equals(e){return this.isChild===e.isChild&&this.transportId===e.transportId}toString(){return this.transportId}}class En{constructor(e,t){this.parentId=e,this.gnpAddress=t,this.isChild=!0,this.transportId=e.transportId}equals(e){if(this.isChild===e.isChild){const t=e;return this.parentId.equals(t.parentId)&&this.gnpAddress===t.gnpAddress}return!1}toString(){return`0x${e=this.gnpAddress,e.toString(16).padStart(2,"0").toUpperCase()}@${this.transportId}`;var e}}var Cn,_n,In;!function(e){e.NO_TRACKING="no-tracking",e.TRACK_ERRORS="track-errors",e.TRACK_USAGE="track-usage",e.TRACK_ALL="track-all"}(Cn||(Cn={})),function(e){e[e.BLUETOOTH=0]="BLUETOOTH",e[e.INDIRECT=1]="INDIRECT",e[e.USB=2]="USB"}(_n||(_n={})),function(e){e[e.BASE=0]="BASE",e[e.HEADSET=1]="HEADSET",e[e.DESKSTAND=2]="DESKSTAND",e[e.OTHER=3]="OTHER",e[e.DONGLE=4]="DONGLE",e[e.PC=5]="PC",e[e.EHS=6]="EHS",e[e.USB=7]="USB",e[e.SPEAKER_PHONE=8]="SPEAKER_PHONE",e[e.INDICATOR=9]="INDICATOR",e[e.MOBILE=10]="MOBILE",e[e.NONE=11]="NONE",e[e.LOCAL=12]="LOCAL",e[e.DISPLAY=13]="DISPLAY",e[e.HS_CRADLE=14]="HS_CRADLE",e[e.HS_CRADLE2=15]="HS_CRADLE2",e[e.MOBILE_IAP=16]="MOBILE_IAP",e[e.CRADLE=17]="CRADLE",e[e.VIDEO=18]="VIDEO",e[e.NOT_GN=252]="NOT_GN",e[e.ANY_GN=253]="ANY_GN",e[e.NOT_INIT=254]="NOT_INIT",e[e.ANY=255]="ANY"}(In||(In={}));class kn{constructor(e,t,n,r,i,o,a,s,c,u,l){this.id=e,this.type=t,this.hidChannel=n,this.events=r,this.primaryAddress=i,this.sendEvent=o,this.read=a,this.readWithParams=s,this.write=c,this.onDisconnect=u,this.parentConnectionId=l,this.onDisconnect.subscribe({error:A})}static createConnection(e,t,n,r,i,o){const a=r.sendEvent.bind(r),s=r.read.bind(r),c=r.readWithParams.bind(r),u=r.write.bind(r);return new kn(e,t,n,r.events,r.primaryAddress,a,s,c,u,i,o)}}const On=(e=3,t=500)=>n=>n.pipe(Fe((n,r)=>{const i=r+1;return i>e?Le(()=>n):We(i*i*t)}));function Sn(e,t,n,r=1e3,i=3,o=100){return Ve(()=>e.read(t,n,r)).pipe(vt(On(i,o)))}function Tn(e,t,n){const{deviceType:r,address:i}=n;return{transportId:t.transportId,vid:t.vid,pid:Sn(e,$t,i),name:Sn(e,zt,i),serialNumber:Sn(e,Qt,i),capabilities:t.capabilities,deviceType:r,connectionGnpAddress:i}}class xn{constructor(e,t,n=Tn,r=kn.createConnection,i=mn){this.parentConnection=t,this.connectionCreator=r,this.createChildGnpChannel=i;const o=t.events.pipe(rt(e=>e.command===Ft.DEVICE&&e.subCommand===Bt.ATTACH_EVENT),Me(e=>({deviceType:e.payload[0],address:e.payload[1]}))).pipe(Me(n.bind(null,t,e)));this.connectionEvents=o.pipe(Me(e=>{const n=it(t.events.pipe(dt(t=>t.command===Ft.DEVICE&&t.subCommand===Bt.DETACH_EVENT&&t.payload[1]===e.connectionGnpAddress),Me(A)),t.onDisconnect);return{attach:e,detach:n}}),Fe(e=>at(Ae(e.attach),this.createConnection(e.attach,e.detach))),Me(([e,t])=>({event:e,connection:t})),Ct(t.onDisconnect)),t.sendEvent(Wt,[])}createConnection(e,t){const n=e.connectionGnpAddress,r=this.createChildGnpChannel(this.parentConnection,n),i=new En(this.parentConnection.id,n);return Ae(this.connectionCreator(i,_n.INDIRECT,this.parentConnection.hidChannel,r,t,this.parentConnection.id))}}const An={command:Ft.IDENT,subCommand:Bt.TYPE,deserialize:e=>{const{payload:t}=e,n=t[0];if(n<1||n>=t.length)throw new It("Cannot get device type.",$e.DEVICE_ERROR);return t[1]}};function Ln(e,t,n,r=Ke.ERROR,i=ze.JS_LIB){kt(`${e} ${function(e){if(e instanceof It){const t=e;return`JabraError: ${t.message} (type: ${t.type})`}if(e instanceof Error){const t=e;return`Error: ${t.message} (name: ${t.name})`}return"Unknown error: "+e}(t)}`,n,r,i)}function Pn(e){return new xn(e.event,e.connection).connectionEvents}class Nn{constructor(e,t,n=((e,t,n)=>new cn(e,t,n)),r=gn,i=Pn,o=kn.createConnection){this.transport=e,this.logger=t,this.createHidChannel=n,this.createRootGnpChannel=r,this.connectionCreator=o;const a=this.transport.consoleAppEvent.pipe(rt(e=>"attach"===e.event),Me(Nn.createAttachEvent),st((e,t)=>(Ln("",e,this.logger),t))).pipe(Me(e=>{const t=this.transport.consoleAppEvent.pipe(rt(e=>"detach"===e.event),dt(t=>Nn.getTransportId(t)===e.transportId),Me(A),mt());return t.subscribe(),{attach:e,detach:t}}),Fe(e=>this.createConnection(e.attach,e.detach)),yt()),s=a.pipe(rt(e=>e.event.deviceType===In.DONGLE),rt(e=>vn.supportsGnpOverHid(e.connection.hidChannel)),Fe(e=>i(e)));this.connectionEvents=qe(a,s).pipe(yt())}static convertToReportType(e){switch(e){case"input":return en.INPUT;case"output":return en.OUTPUT;case"feature":return en.FEATURE;default:throw new It(e+" is not a valid ReportType",$e.UNEXPECTED_ERROR)}}static convertToValueType(e){switch(e){case"absolute":return tn.ABSOLUTE;case"relative":return tn.RELATIVE;default:throw new It(e+" Not a valid ValueType",$e.UNEXPECTED_ERROR)}}static createDescriptor(e){return e.map(e=>({reportType:Nn.convertToReportType(e.reportType),usagePage:e.usagePage,usage:e.usage,valueType:Nn.convertToValueType(e.valueType),reportSize:e.reportSize}))}static getMandatoryField(e,t){const n=e[t];if(void 0===n)throw new It(`JSON event lacks required field "${t}: ${JSON.stringify(e)}`,$e.UNEXPECTED_ERROR);return n}static getTransportId(e){return Nn.getMandatoryField(e,"id")}static createAttachEvent(e){return{transportId:Nn.getTransportId(e),vid:Nn.getMandatoryField(e,"vid"),pid:Ae(Nn.getMandatoryField(e,"pid")),name:Ae(Nn.getMandatoryField(e,"name")),serialNumber:Ae(Nn.getMandatoryField(e,"serialNumber")),capabilities:Nn.createDescriptor(Nn.getMandatoryField(e,"descriptor"))}}createConnection(e,t,n=3,r=100){const{capabilities:i,transportId:o}=e,a=new wn(o),s=this.createHidChannel(a,i,this.transport),c=this.createRootGnpChannel(s,this.transport,o,t).pipe(st((e,t)=>(e.type&&e.type===$e.DEVICE_ERROR&&this.transport.context===Xe.WEB_HID&&kt("Child devices are not yet supported when using WebHID.",this.logger,Ke.WARNING,ze.JS_LIB),Ae(new bn))),yt()),u=c.pipe(Fe(e=>e.read(An)),vt(On(n,r)),st(e=>Ae(In.ANY)));return at(c,u).pipe(Ct(t),Me(([n,r])=>({event:Object.assign(Object.assign({},e),{deviceType:r,connectionGnpAddress:n.primaryAddress}),connection:this.connectionCreator(a,_n.USB,s,n,t)})))}}var Rn,Dn,jn,Hn,Un;class Mn{constructor(e,t,n,r,i,o){this.vendorId=e,this.productId=t,this.serialNumber=n,this.name=r,this.type=i,Dn.set(this,void 0),y(this,Dn,new St(o,v(Mn,Rn,"m",Hn)),"f"),this.connectionAdded=v(this,Dn,"f").itemAdded,this.connectionRemoved=v(this,Dn,"f").itemRemoved,this.connectionList=v(this,Dn,"f").itemList,this.onDisconnect=v(this,Dn,"f").itemList.pipe(bt(1),dt(e=>0===e.length),Me(A),yt())}get id(){return an(this.vendorId,this.productId,this.serialNumber)}get currentConnections(){return v(this,Dn,"f").getValue()}get browserLabel(){return`${this.vendorId.toString(16).padStart(4,"0")}:${this.productId.toString(16).padStart(4,"0")}`}}Rn=Mn,Dn=new WeakMap,Hn=function(e,t){return v(Mn,Rn,"f",jn).indexOf(e.type)-v(Mn,Rn,"f",jn).indexOf(t.type)},jn={value:[_n.USB,_n.INDIRECT,_n.BLUETOOTH]};class Fn{constructor(e){this.deviceObservables=new St(e)}static exceptionToUndefined(e){try{return e()}catch(e){if(e instanceof It)return;throw e}}connectionExists(e){return void 0!==Fn.exceptionToUndefined(()=>this.findConnectionById(e))}findConnectionById(e){for(const t of this.deviceObservables.getValue())for(const n of t.currentConnections)if(n.id.equals(e))return n;throw new It("Could not find connection with id "+e.toString(),$e.UNEXPECTED_ERROR)}findDeviceByDeviceId(e){return this.deviceObservables.getValue().find(t=>t.id.startsWith(e)||e.startsWith(t.id))}}class Bn{constructor(e,t){this.logger=t;const[n,r]=(i=e.pipe(rt(e=>!this.deviceCollection.connectionExists(e.connection.id)),ct(e=>this.force(e))),[rt(o=({event:e,pid:t,serialNumber:n})=>!this.deviceCollection.findDeviceByDeviceId(an(e.event.vid,t,n)),a)(_e(i)),rt(nt(o,a))(_e(i))]);var i,o,a;const s=n.pipe(Me(e=>Bn.createDevice(e,r)));this.deviceCollection=new Fn(s),this.deviceObservables=this.deviceCollection.deviceObservables}force(e){const{name:t,pid:n,serialNumber:r}=e.event,i=e.connection.onDisconnect.pipe((o=Le(()=>new Error(`Connection with ID ${e.connection.id} disconnected`)),g(a)?ct((function(){return o}),a):ct((function(){return o}))));var o,a;return at(t,n,r).pipe(Me(([t,n,r])=>({event:e,name:t,pid:n,serialNumber:r})),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length?K((function(t,n){ot(f([t],l(e)))(n)})):Y}(i),st(e=>(kt("Failed to retrieve child connection information. Error: "+e,this.logger,Ke.WARNING,ze.JS_LIB),ce)))}static createDevice(e,t){const{event:n,pid:r,name:i,serialNumber:o}=e,{vid:a,deviceType:s}=n.event,c=t.pipe(rt(t=>Bn.isSameDevice(e,t)),Me(e=>e.event.connection)),u=Ye(Ae(n.connection),c);return new Mn(a,r,o,i,s,u)}static isSameDevice(e,t){const n=an(e.event.event.vid,e.pid,e.serialNumber),r=an(t.event.event.vid,t.pid,t.serialNumber);return n.startsWith(r)||r.startsWith(n)}static create(e,t){const n=new Nn(e,t);return new Bn(n.connectionEvents)}}function Gn(e){var t,n,r;return s(this,void 0,void 0,(function*(){const i=null==e?void 0:e.logger;kt("Jabra SDK JS starting up...",i,Ke.INFO);const o=new Rt(e);o.validateOrganizationKey(),o.validateAppId(),o.validateAppName();const a=null!==(n=null===(t=null==e?void 0:e.internal)||void 0===t?void 0:t.testDeviceTransport)&&void 0!==n?n:yield Lt(i,null==e?void 0:e.transport,null===(r=null==e?void 0:e.internal)||void 0===r?void 0:r.recorder);new Pt(a,i);const s=Bn.create(a,i),c=new xt(s,a,e);return yield a.connect(),c}))}class Yn{constructor(e,t,n,r){this.deviceId=e,this.usagePage=t,this.usage=n,this.value=r}}class Vn{constructor(e,t){this.token=e,this.value=t}}!function(e){e.UsageReport=class{constructor(e,t){this.usage=e,this.value=t}}}(Un||(Un={}));var Wn,qn,Kn,zn,$n,Jn,Xn,Qn,Zn,er,tr=Zt((function(e){!function(t){var n=function(e,t,n){if(!(e instanceof ArrayBuffer||void 0!==i&&e instanceof i))throw new Error("Must specify a valid ArrayBuffer or Buffer.");t=t||0,n=n||e.byteLength||e.length,this._view=new Uint8Array(e.buffer||e,t,n),this.bigEndian=!1};n._scratch=new DataView(new ArrayBuffer(8)),Object.defineProperty(n.prototype,"buffer",{get:function(){return void 0!==i?i.from(this._view.buffer):this._view.buffer},enumerable:!0,configurable:!1}),Object.defineProperty(n.prototype,"byteLength",{get:function(){return this._view.length},enumerable:!0,configurable:!1}),n.prototype._setBit=function(e,t){t?this._view[e>>3]|=1<<(7&e):this._view[e>>3]&=~(1<<(7&e))},n.prototype.getBits=function(e,t,n){var r=8*this._view.length-e;if(t>r)throw new Error("Cannot get "+t+" bit(s) from offset "+e+", "+r+" available");for(var i=0,o=0;o<t;){var a=t-o,s=7&e,c=this._view[e>>3],u=Math.min(a,8-s);this.bigEndian?(i<<=u,i|=c>>8-u-s&~(255<<u)):i|=(c>>s&~(255<<u))<<o,e+=u,o+=u}return n?(32!==t&&i&1<<t-1&&(i|=-1^(1<<t)-1),i):i>>>0},n.prototype.setBits=function(e,t,n){var r=8*this._view.length-e;if(n>r)throw new Error("Cannot set "+n+" bit(s) from offset "+e+", "+r+" available");for(var i=0;i<n;){var o,a,s,c=n-i,u=7&e,l=e>>3,f=Math.min(c,8-u);if(this.bigEndian){a=t>>n-i-f&(o=~(-1<<f));var h=8-u-f;s=~(o<<h),this._view[l]=this._view[l]&s|a<<h}else a=t&(o=~(255<<f)),t>>=f,s=~(o<<u),this._view[l]=this._view[l]&s|a<<u;e+=f,i+=f}},n.prototype.getBoolean=function(e){return 0!==this.getBits(e,1,!1)},n.prototype.getInt8=function(e){return this.getBits(e,8,!0)},n.prototype.getUint8=function(e){return this.getBits(e,8,!1)},n.prototype.getInt16=function(e){return this.getBits(e,16,!0)},n.prototype.getUint16=function(e){return this.getBits(e,16,!1)},n.prototype.getInt32=function(e){return this.getBits(e,32,!0)},n.prototype.getUint32=function(e){return this.getBits(e,32,!1)},n.prototype.getFloat32=function(e){return n._scratch.setUint32(0,this.getUint32(e)),n._scratch.getFloat32(0)},n.prototype.getFloat64=function(e){return n._scratch.setUint32(0,this.getUint32(e)),n._scratch.setUint32(4,this.getUint32(e+32)),n._scratch.getFloat64(0)},n.prototype.setBoolean=function(e,t){this.setBits(e,t?1:0,1)},n.prototype.setInt8=n.prototype.setUint8=function(e,t){this.setBits(e,t,8)},n.prototype.setInt16=n.prototype.setUint16=function(e,t){this.setBits(e,t,16)},n.prototype.setInt32=n.prototype.setUint32=function(e,t){this.setBits(e,t,32)},n.prototype.setFloat32=function(e,t){n._scratch.setFloat32(0,t),this.setBits(e,n._scratch.getUint32(0),32)},n.prototype.setFloat64=function(e,t){n._scratch.setFloat64(0,t),this.setBits(e,n._scratch.getUint32(0),32),this.setBits(e+32,n._scratch.getUint32(4),32)},n.prototype.getArrayBuffer=function(e,t){for(var n=new Uint8Array(t),r=0;r<t;r++)n[r]=this.getUint8(e+8*r);return n};var r=function(e,t){return function(){if(this._index+t>this._length)throw new Error("Trying to read past the end of the stream");var n=this._view[e](this._index);return this._index+=t,n}},o=function(e,t){return function(n){this._view[e](this._index,n),this._index+=t}};function a(e,t,n){if(0===t)return"";var r=0,i=[],o=!0,a=!!t;for(t||(t=Math.floor((e._length-e._index)/8));r<t;){var s=e.readUint8();if(0===s&&(o=!1,!a))break;o&&i.push(s),r++}var c=String.fromCharCode.apply(null,i);if(!n)return c;try{return decodeURIComponent(escape(c))}catch(e){return c}}var s=function(e,t,r){var o=e instanceof ArrayBuffer||void 0!==i&&e instanceof i;if(!(e instanceof n||o))throw new Error("Must specify a valid BitView, ArrayBuffer or Buffer");this._view=o?new n(e,t,r):e,this._index=0,this._startIndex=0,this._length=8*this._view.byteLength};Object.defineProperty(s.prototype,"index",{get:function(){return this._index-this._startIndex},set:function(e){this._index=e+this._startIndex},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"length",{get:function(){return this._length-this._startIndex},set:function(e){this._length=e+this._startIndex},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"bitsLeft",{get:function(){return this._length-this._index},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"byteIndex",{get:function(){return Math.ceil(this._index/8)},set:function(e){this._index=8*e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"buffer",{get:function(){return this._view.buffer},enumerable:!0,configurable:!1}),Object.defineProperty(s.prototype,"view",{get:function(){return this._view},enumerable:!0,configurable:!1}),Object.defineProperty(s.prototype,"bigEndian",{get:function(){return this._view.bigEndian},set:function(e){this._view.bigEndian=e},enumerable:!0,configurable:!1}),s.prototype.readBits=function(e,t){var n=this._view.getBits(this._index,e,t);return this._index+=e,n},s.prototype.writeBits=function(e,t){this._view.setBits(this._index,e,t),this._index+=t},s.prototype.readBoolean=r("getBoolean",1),s.prototype.readInt8=r("getInt8",8),s.prototype.readUint8=r("getUint8",8),s.prototype.readInt16=r("getInt16",16),s.prototype.readUint16=r("getUint16",16),s.prototype.readInt32=r("getInt32",32),s.prototype.readUint32=r("getUint32",32),s.prototype.readFloat32=r("getFloat32",32),s.prototype.readFloat64=r("getFloat64",64),s.prototype.writeBoolean=o("setBoolean",1),s.prototype.writeInt8=o("setInt8",8),s.prototype.writeUint8=o("setUint8",8),s.prototype.writeInt16=o("setInt16",16),s.prototype.writeUint16=o("setUint16",16),s.prototype.writeInt32=o("setInt32",32),s.prototype.writeUint32=o("setUint32",32),s.prototype.writeFloat32=o("setFloat32",32),s.prototype.writeFloat64=o("setFloat64",64),s.prototype.readASCIIString=function(e){return function(e,t){return a(e,t,!1)}(this,e)},s.prototype.readUTF8String=function(e){return function(e,t){return a(e,t,!0)}(this,e)},s.prototype.writeASCIIString=function(e,t){!function(e,t,n){for(var r=n||t.length+1,i=0;i<r;i++)e.writeUint8(i<t.length?t.charCodeAt(i):0)}(this,e,t)},s.prototype.writeUTF8String=function(e,t){!function(e,t,n){for(var r=function(e){var t,n,r=[];for(t=0;t<e.length;t++)(n=e.charCodeAt(t))<=127?r.push(n):n<=2047?(r.push(n>>6|192),r.push(63&n|128)):n<=65535?(r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)):(r.push(n>>18|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128));return r}(t),i=n||r.length+1,o=0;o<i;o++)e.writeUint8(o<r.length?r[o]:0)}(this,e,t)},s.prototype.readBitStream=function(e){var t=new s(this._view);return t._startIndex=this._index,t._index=this._index,t.length=e,this._index+=e,t},s.prototype.writeBitStream=function(e,t){var n;for(t||(t=e.bitsLeft);t>0;)n=Math.min(t,32),this.writeBits(e.readBits(n),n),t-=n},s.prototype.readArrayBuffer=function(e){var t=this._view.getArrayBuffer(this._index,e);return this._index+=8*e,t},s.prototype.writeArrayBuffer=function(e,t){this.writeBitStream(new s(e),8*t)},e.exports&&(e.exports={BitView:n,BitStream:s})}()}));function nr(){return s(this,void 0,void 0,(function*(){const{hid:e}=window.navigator;if(!e)throw new It("WebHID not supported",$e.INIT_ERROR);const t=yield e.requestDevice({filters:[{vendorId:Wn.VENDOR_ID}]});return new BroadcastChannel(Wn.PAIRING_CHANNEL).postMessage(null),t}))}!function(e){e[e.VENDOR_ID=2830]="VENDOR_ID",e.PAIRING_CHANNEL="jabra-webhid-pairing-channel"}(Wn||(Wn={})),function(e){e[e.HOOK_SWITCH=32]="HOOK_SWITCH",e[e.GN_PSEUDO_HOOK_SWITCH=65531]="GN_PSEUDO_HOOK_SWITCH",e[e.FLASH=33]="FLASH",e[e.ALT_HOLD=35]="ALT_HOLD",e[e.REDIAL=36]="REDIAL",e[e.ONLINE=42]="ONLINE",e[e.SPEAKER_PHONE=43]="SPEAKER_PHONE",e[e.PHONE_MUTE=47]="PHONE_MUTE",e[e.SEND=49]="SEND",e[e.SPEED_DIAL=80]="SPEED_DIAL",e[e.VOICE_MAIL=112]="VOICE_MAIL",e[e.ANSWER_ON_OFF=116]="ANSWER_ON_OFF",e[e.LINE_BUSY=151]="LINE_BUSY",e[e.RINGER=158]="RINGER",e[e.PHONE_KEY_0=176]="PHONE_KEY_0",e[e.PHONE_KEY_1=177]="PHONE_KEY_1",e[e.PHONE_KEY_2=178]="PHONE_KEY_2",e[e.PHONE_KEY_3=179]="PHONE_KEY_3",e[e.PHONE_KEY_4=180]="PHONE_KEY_4",e[e.PHONE_KEY_5=181]="PHONE_KEY_5",e[e.PHONE_KEY_6=182]="PHONE_KEY_6",e[e.PHONE_KEY_7=183]="PHONE_KEY_7",e[e.PHONE_KEY_8=184]="PHONE_KEY_8",e[e.PHONE_KEY_9=185]="PHONE_KEY_9",e[e.PHONE_KEY_STAR=186]="PHONE_KEY_STAR",e[e.PHONE_KEY_POUND=187]="PHONE_KEY_POUND",e[e.ALT_VOLUME_UP=233]="ALT_VOLUME_UP",e[e.ALT_VOLUME_DOWN=234]="ALT_VOLUME_DOWN",e[e.REJECT_CALL=65533]="REJECT_CALL"}(qn||(qn={}));class rr{constructor(e,t,n){this.type=e,this.value=t,this.valueType=n}toString(){return void 0===qn[this.type]?`Unknown signal: type: ${this.type}, value: ${this.value}, valueType: ${this.valueType}`:`Signal: type: ${qn[this.type]}, value: ${this.value}, valueType: ${this.valueType}`}}!function(e){e[e.BUTTON=9]="BUTTON",e[e.CONSUMER=12]="CONSUMER",e[e.LED=8]="LED",e[e.TELEPHONY=11]="TELEPHONY",e[e.GN_CONSUMER=65312]="GN_CONSUMER",e[e.GN_EXT_BUTTONS=65360]="GN_EXT_BUTTONS",e[e.GN_LED=65344]="GN_LED",e[e.GN_MISC=65376]="GN_MISC",e[e.GN_TELEPHONY=65328]="GN_TELEPHONY"}(Kn||(Kn={})),function(e){e[e.MUTE=9]="MUTE",e[e.OFF_HOOK=23]="OFF_HOOK",e[e.RING=24]="RING",e[e.MESSAGE_WAIT=25]="MESSAGE_WAIT",e[e.HOLD=32]="HOLD",e[e.MIC_MUTE=33]="MIC_MUTE",e[e.ONLINE=42]="ONLINE",e[e.HID_OFFLINE=43]="HID_OFFLINE"}(zn||(zn={})),function(e){e[e.HOOK_SWITCH=32]="HOOK_SWITCH",e[e.FLASH=33]="FLASH",e[e.HOLD=35]="HOLD",e[e.REDIAL=36]="REDIAL",e[e.ONLINE=42]="ONLINE",e[e.SPEAKER_PHONE=43]="SPEAKER_PHONE",e[e.MUTE=47]="MUTE",e[e.HID_SEND=49]="HID_SEND",e[e.SPEED_DIAL=80]="SPEED_DIAL",e[e.VOICE_MAIL=112]="VOICE_MAIL",e[e.ANSWER_ON_OFF=116]="ANSWER_ON_OFF",e[e.LINE_BUSY=151]="LINE_BUSY",e[e.RINGER=158]="RINGER",e[e.PHONE_KEY_0=176]="PHONE_KEY_0",e[e.PHONE_KEY_1=177]="PHONE_KEY_1",e[e.PHONE_KEY_2=178]="PHONE_KEY_2",e[e.PHONE_KEY_3=179]="PHONE_KEY_3",e[e.PHONE_KEY_4=180]="PHONE_KEY_4",e[e.PHONE_KEY_5=181]="PHONE_KEY_5",e[e.PHONE_KEY_6=182]="PHONE_KEY_6",e[e.PHONE_KEY_7=183]="PHONE_KEY_7",e[e.PHONE_KEY_8=184]="PHONE_KEY_8",e[e.PHONE_KEY_9=185]="PHONE_KEY_9",e[e.PHONE_KEY_STAR=186]="PHONE_KEY_STAR",e[e.PHONE_KEY_POUND=187]="PHONE_KEY_POUND",e[e.HID_ALT_VOLUME_UP=233]="HID_ALT_VOLUME_UP",e[e.HID_ALT_VOLUME_DOWN=234]="HID_ALT_VOLUME_DOWN",e[e.GN_PSEUDO_HOOK_SWITCH=65531]="GN_PSEUDO_HOOK_SWITCH",e[e.GN_OUT_OF_RANGE=65532]="GN_OUT_OF_RANGE",e[e.GN_REJECT_CALL=65533]="GN_REJECT_CALL",e[e.GN_TELEPHONY_CONT_SET=65535]="GN_TELEPHONY_CONT_SET"}($n||($n={}));class ir{constructor(e,t,n,r,i){this.hidChannel=e,this.onDisconnect=t,this.isSoftphoneInFocus=n,this.lockHeld=r,this.logger=i,this.cachedSignals=new Map}setup(){const e=this.filter().pipe(yt());return e.subscribe(),e}filter(){const e=this.hidChannel.input.pipe(rt(e=>e.usagePage===Kn.GN_TELEPHONY&&!e.isArray()),Fe(e=>{const t=this.hidChannel.findDescriptor(e.usagePage,e.usage,en.INPUT);return(null==t?void 0:t.valueType)?Ae(Object.assign(Object.assign({},e),{valueType:t.valueType})):(Ln("",new It(`Unable to find value-type in descriptor for UsagePage: ${e.usagePage} and Usage: ${e.usage}`,$e.FEATURE_NOT_SUPPORTED),this.logger),ce)}),rt(e=>e.valueType===tn.RELATIVE?Boolean(e.value):this.cachedSignals.get(e.usage)!==e.value),_t(e=>{this.cachedSignals.set(e.usage,e.value)}),Ct(this.onDisconnect),yt()),t=[qn.HOOK_SWITCH,qn.REDIAL],n=e.pipe(function(e){return t=>t.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fe(e);return K((function(t,r){for(var i=e.length,o=new Array(i),a=e.map((function(){return!1})),s=!1,c=function(t){_e(e[t]).subscribe(z(r,(function(e){o[t]=e,s||a[t]||(a[t]=!0,(s=a.every(Y))&&(a=null))}),A))},u=0;u<i;u++)c(u);t.subscribe(z(r,(function(e){if(s){var t=f([e],l(o));r.next(n?n.apply(void 0,f([],l(t))):t)}})))}))}(e),rt(([e,t])=>t),Me(([e,t])=>e))}(this.isSoftphoneInFocus),rt(e=>t.includes(e.usage)&&!this.lockHeld.getValue()));return qe(e.pipe(rt(e=>this.lockHeld.getValue())),n).pipe(Me(e=>new rr(e.usage,0!==e.value,e.valueType)),st(e=>(kt(e.message,this.logger),ce)))}}class or{constructor(e,t,n,r,i,o){this.device=e,this.onDisconnect=n,Jn.set(this,void 0),Xn.set(this,new Z(!1)),Qn.set(this,void 0),Zn.set(this,!1),this.deviceSignals=new X,y(this,Jn,r,"f"),v(this,Jn,"f").lockHeld.subscribe(v(this,Xn,"f")),y(this,Qn,t,"f"),this.onDisconnect.pipe(dt(),Me(()=>!0)).subscribe(e=>{y(this,Zn,e,"f")});const a=new ir(v(this,Qn,"f"),this.onDisconnect,i,v(this,Xn,"f"),o);this.deviceSignals=a.setup()}checkCallLockHeld(e){if(!v(this,Xn,"f").getValue())throw new It(e,$e.SDK_USAGE_ERROR)}checkCallLockNotHeld(e){if(v(this,Xn,"f").getValue())throw new It(e,$e.SDK_USAGE_ERROR)}checkHasDisconnected(){if(v(this,Zn,"f"))throw new It("CallControl cannot be performed as the connection has disconnected.",$e.SDK_USAGE_ERROR)}takeCallLock(){return this.checkHasDisconnected(),this.checkCallLockNotHeld("Trying to take the call lock, but it is already held!"),Ne(v(this,Jn,"f").tryTakeCallLock())}releaseCallLock(){this.checkHasDisconnected(),this.checkCallLockHeld("Trying to release the call lock, but it is not held!"),v(this,Jn,"f").releaseCallLock()}offHook(e){this.checkHasDisconnected(),this.checkCallLockHeld("Calls can only be started and stopped when the call lock is held.");const t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.OFF_HOOK,en.OUTPUT);if(!t)throw new It(`Device ${this.device.name} does not support any offHook functionality.`,$e.FEATURE_NOT_SUPPORTED);const n=e?1:0;v(this,Qn,"f").output(t.usagePage,t.usage,n)}ring(e){this.checkHasDisconnected(),this.checkCallLockHeld("The ringer state can only be modified when the call lock is held.");const t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.RING,en.OUTPUT),n=v(this,Qn,"f").findDescriptor(Kn.GN_TELEPHONY,$n.RINGER,en.OUTPUT);if(!t&&!n)throw new It(`Device ${this.device.name} does not support any ring functionality.`,$e.FEATURE_NOT_SUPPORTED);if(n){const t=e?1:0;v(this,Qn,"f").output(n.usagePage,n.usage,t)}if(t){const n=e?1:0;v(this,Qn,"f").output(t.usagePage,t.usage,n)}}mute(e){this.checkHasDisconnected(),this.checkCallLockHeld("The mute state can only be modified when the call lock is held.");let t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.MIC_MUTE,en.OUTPUT);if(t||(t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.MUTE,en.OUTPUT)),!t)throw new It(`Device ${this.device.name} does not support any mute functionality.`,$e.FEATURE_NOT_SUPPORTED);const n=e?1:0;v(this,Qn,"f").output(t.usagePage,t.usage,n)}hold(e){this.checkHasDisconnected(),this.checkCallLockHeld("The hold state can only be modified when the call lock is held.");const t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.HOLD,en.OUTPUT);if(!t)throw new It(`Device ${this.device.name} does not support hold functionality.`,$e.FEATURE_NOT_SUPPORTED);const n=e?1:0;v(this,Qn,"f").output(t.usagePage,t.usage,n)}}Jn=new WeakMap,Xn=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,function(e){e[e.STD_TELEPHONY=0]="STD_TELEPHONY",e[e.GN_TELEPHONY=1]="GN_TELEPHONY"}(er||(er={}));const ar={[Dt.SKYPE]:er.GN_TELEPHONY,[Dt.CISCO]:er.GN_TELEPHONY,[Dt.AVAYA]:er.GN_TELEPHONY,[Dt.SIEMENS]:er.GN_TELEPHONY,[Dt.IBM]:er.GN_TELEPHONY,[Dt.AASTRA]:er.GN_TELEPHONY,[Dt.JABRA]:er.GN_TELEPHONY,[Dt.NEC]:er.GN_TELEPHONY,[Dt.SHORETEL]:er.GN_TELEPHONY,[Dt.MS_OC]:er.STD_TELEPHONY,[Dt.ALCATEL]:er.STD_TELEPHONY,[Dt.OTHER]:er.STD_TELEPHONY,[Dt.NORTEL]:null,[Dt.GENERIC]:null};class sr{constructor(e,t,n){this.connectionCallLock=e,this.device=t,this.logger=n,this.lockHeld=new Z(!1),this.currentLocks=new Z(new Set),this.lockReleaseEvent=new X}tryTakeCallLock(){const{currentConnections:e}=this.device,t=new Set,n=Ve(()=>xe(e).pipe(ct(e=>this.takeSingleCallLock(e).pipe(st(e=>(Ln("DeviceCallLock:",e,this.logger),Ae(""))))),_t(e=>t.add(e)))).pipe(function(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?rt((function(t,n){return e(t,n,r)})):Y,pt(1),n?ut(t):ft((function(){return new Pe})))}}(),Me(n=>(t.delete(""),this.currentLocks.next(t),t.size!==e.length?(this.releaseCallLock(),!1):(this.lockHeld.next(!0),!0))),mt());return n.subscribe(e=>{e&&(this.acquireLockOnNextConnectionEmit(),this.releaseLockOnRemovedConnectionEmit())}),n}acquireLockOnNextConnectionEmit(){this.device.connectionAdded.pipe(Ct(this.lockReleaseEvent)).subscribe(e=>{this.takeSingleCallLock(e).pipe(Ct(this.lockReleaseEvent),Me(e=>(this.currentLocks.getValue().add(e),this.currentLocks.next(this.currentLocks.getValue()),A)),vt(On())).subscribe({error:e=>{kt("Failed to acquire the call lock on a new connection.\n Another softphone running an old SDK has most likely acquired this lock.\n Full error: "+e,this.logger,Ke.WARNING,ze.JS_LIB)}})})}releaseLockOnRemovedConnectionEmit(){this.device.connectionRemoved.pipe(Ct(this.lockReleaseEvent)).subscribe(e=>this.releaseSingleCallLock(e.id.transportId))}takeSingleCallLock(e){return Ve(()=>this.connectionCallLock.tryTakeCallLock(e.id.transportId)).pipe(Me(t=>t.acquired?Ae(t.transportId):Le(()=>new It("Failed to acquire call lock on connection "+e.id.transportId,$e.SDK_USAGE_ERROR))),Et())}releaseCallLock(){this.lockReleaseEvent.next(),[...this.currentLocks.getValue()].forEach(e=>{this.releaseSingleCallLock(e)}),this.currentLocks.getValue().clear(),this.currentLocks.next(this.currentLocks.getValue())}releaseSingleCallLock(e){this.connectionCallLock.releaseCallLock(e),this.currentLocks.getValue().delete(e),this.currentLocks.next(this.currentLocks.getValue()),0!==this.currentLocks.getValue().size&&0!==this.device.currentConnections.length||(this.lockReleaseEvent.next(),this.lockHeld.next(!1))}}class cr{constructor(e){this.transport=e}tryTakeCallLock(e){const t={action:"request-call-lock",id:e};return this.transport.writeAction(t),this.transport.consoleAppEvent.pipe(rt(t=>"response-call-lock"===t.event&&t.id===e),Me(e=>({transportId:e.id,acquired:e.acquired})),dt())}releaseCallLock(e){const t={action:"release-call-lock",id:e};this.transport.writeAction(t)}}const ur=[{usagePage:Kn.GN_LED,usage:zn.OFF_HOOK,reportType:en.OUTPUT},{usagePage:Kn.GN_LED,usage:zn.RING,reportType:en.OUTPUT},{usagePage:Kn.GN_TELEPHONY,usage:$n.RINGER,reportType:en.OUTPUT},{usagePage:Kn.GN_LED,usage:zn.MIC_MUTE,reportType:en.OUTPUT},{usagePage:Kn.GN_LED,usage:zn.MUTE,reportType:en.OUTPUT},{usagePage:Kn.GN_LED,usage:zn.HOLD,reportType:en.OUTPUT}],lr=[_n.USB,_n.INDIRECT,_n.BLUETOOTH];function fr(e){const{currentConnections:t,type:n}=e;var r;return(r=t,[...r].sort((e,t)=>lr.indexOf(e.type)-lr.indexOf(t.type))).find(e=>function(e,t){const{hidChannel:n}=e;return!!function(e){return ur.some(({usagePage:t,usage:n,reportType:r})=>e.findDescriptor(t,n,r))}(n)&&(!vn.supportsGnpOverHid(n)||t!==In.DONGLE&&t!==In.OTHER)}(e,n))}function hr(e,t,n,r,i){const o=fr(e),{hidChannel:a,onDisconnect:s}=o,c=new sr(new cr(r),e,i);return t||r.context===Xe.WEB_HID?Ae(new or(e,a,s,c,n.softphoneInFocus,i)):function(e,t){return e.findDescriptor(Kn.GN_TELEPHONY,$n.GN_TELEPHONY_CONT_SET,en.FEATURE)?Ve(()=>(e.setFeatureReport(Kn.GN_TELEPHONY,$n.GN_TELEPHONY_CONT_SET,1),Ae(!0))):t?function(e,t){const n=e.read(Jt).pipe(Me(e=>ar[e]===t)),r=e.read(new Kt).pipe(Me(e=>e.find(e=>ar[e]===t))).pipe(Me(t=>t?e.write(Jt,t):Ae(!1)),Et());return n.pipe((i=Ae(!0),o=r,e=>e.pipe(Me(e=>e?i:o),Et())));var i,o}(t,er.GN_TELEPHONY):Ae(!1)}(a,o).pipe(Me(t=>new or(e,a,s,c,n.softphoneInFocus,i)))}class dr{constructor(e,t){this.devComm=e,this.softphoneInFocus=new W,this.softphoneInFocus=t.pipe(dt(),Fe(e=>this.devComm.consoleAppEvent.pipe(rt(e=>"softphone-in-focus"===e.event),Me(e=>e.infocus),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=he(e);return K((function(t,r){(n?Ye(e,t,n):Ye(e,t)).subscribe(r)}))}(!e),mt(1)))),this.softphoneInFocus.subscribe(()=>{})}setSharedSoftphoneInfo(e){if(!(null==e?void 0:e.partnerKey)||!(null==e?void 0:e.appId))return void kt("Unable to register with Jabra Direct: partnerKey or appId missing in config",null==e?void 0:e.logger,Ke.WARNING);const t=e.partnerKey+e.appId,n=new nn(5,"ns:OID",t);let{appName:r}=e;if((!e.appName||e.appName.length<3)&&(kt("App name missing in config. Fall back to use appId as app name.",null==e?void 0:e.logger,Ke.WARNING),r=e.appId),r.length>100)return void kt("Unable to register with Jabra Direct: appName must be below 100 characters.",null==e?void 0:e.logger,Ke.WARNING);const i={action:"set-softphone-info",name:r,id:n.toString()};this.devComm.writeAction(i)}}var pr,vr,yr,gr,mr,br,wr,Er;class Cr{constructor(e){var t;pr.set(this,void 0),vr.set(this,void 0),yr.set(this,void 0),gr.set(this,void 0),y(this,gr,e._readyEvents.pipe(dt(e=>"ready"===e.event),Me(e=>e.jabraDirectInstalled)),"f"),y(this,vr,new dr(e._transport,v(this,gr,"f")),"f"),v(this,vr,"f").setSharedSoftphoneInfo(e._config),y(this,pr,e._transport,"f"),y(this,yr,null===(t=e._config)||void 0===t?void 0:t.logger,"f")}createCallControl(e){return this.supportsCallControl(e)?Re(v(this,gr,"f").pipe(Fe(t=>hr(e,t,v(this,vr,"f"),v(this,pr,"f"),v(this,yr,"f"))))):Promise.reject(new It(`Device ${e.name} does not support call control.`,$e.FEATURE_NOT_SUPPORTED))}supportsCallControl(e){return void 0!==fr(e)}}pr=new WeakMap,vr=new WeakMap,yr=new WeakMap,gr=new WeakMap,function(e){e.HOLD_CURRENT="hold-current",e.END_CURRENT="end-current"}(mr||(mr={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted",e.NO_ONGOING_CALLS="no-ongoing-calls"}(br||(br={})),function(e){e.ON_HOLD="on-hold",e.NOT_ON_HOLD="not-on-hold",e.NO_ONGOING_CALLS="no-ongoing-calls"}(wr||(wr={})),function(e){e.NO_INCOMING="no-incoming",e.AWAITING_RESPONSE="awaiting-response",e.RESOLVING_RESPONSE="resolving-response",e.ACCEPTED="accepted",e.REJECTED="rejected"}(Er||(Er={}));new WeakMap;new WeakMap;br.NO_ONGOING_CALLS,wr.NO_ONGOING_CALLS,Er.NO_INCOMING;new WeakMap,new WeakMap;new WeakMap,new WeakMap}).call(this,n(14),n(5),n(15).Buffer)},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){return e.implementationChanged="implementationChanged",e.deviceHoldStatusChanged="deviceHoldStatusChanged",e.deviceMuteStatusChanged="deviceMuteStatusChanged",e.deviceAnsweredCall="deviceAnsweredCall",e.deviceEndedCall="deviceEndedCall",e.deviceRejectedCall="deviceRejectedCall",e.loggableEvent="loggableEvent",e.webHidPermissionRequested="webHidPermissionRequested",e.deviceConnectionStatusChanged="deviceConnectionStatusChanged",e.deviceEventLogs="deviceEventLogs",e}({})},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(4);function i(e){return(i="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 o(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 a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){f(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(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,h(r.key),r)}}function c(e,t,n){return t=u(t),function(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function f(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e){var t=function(e,t){if("object"!=i(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==i(t)?t:t+""}var d=function(e){function t(e){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),f(n=c(this,t),"vendorName","Not Specified"),f(n,"isConnecting",!1),f(n,"isConnected",!1),f(n,"isMuted",!1),f(n,"errorCode",null),f(n,"disableRetry",!1),f(n,"logger",void 0),f(n,"config",void 0);var i=new r.EventEmitter;return Object.keys(i.__proto__).forEach((function(e){n[e]=i[e]})),n.config=e,n.vendorName=e.vendorName,n.logger=e.logger,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(t,e),n=t,(i=[{key:"isDeviceAttached",get:function(){throw new Error("".concat(this.vendorName," - isDeviceAttatched getter not implemented"))}},{key:"isSupported",value:function(){return!0}},{key:"deviceLabelMatchesVendor",value:function(e){throw new Error("".concat(this.vendorName," - deviceLabelMatchesVendor() not implemented"))}},{key:"connect",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - connect() not implemented")))}},{key:"disconnect",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - disconnect() not implemented")))}},{key:"incomingCall",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - incomingCall() not implemented")))}},{key:"outgoingCall",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - outgoingCall() not implemented")))}},{key:"answerCall",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - answerCall() not implemented")))}},{key:"rejectCall",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - rejectCall() not implemented")))}},{key:"endCall",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - endCall() not implemented")))}},{key:"endAllCalls",value:function(){return Promise.reject(new Error("".concat(this.vendorName," - endAllCalls() not implemented")))}},{key:"setMute",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - setMute() not implemented")))}},{key:"setHold",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - setHold() not implemented")))}},{key:"resetHeadsetStateForCall",value:function(e){return this.rejectCall(e)}},{key:"emitEvent",value:function(e,t){this.emit(e,{vendor:this,body:a({},t)})}},{key:"requestWebHidPermissions",value:function(e){this.logger.debug("Emitting premission request event"),this.emitEvent("webHidPermissionRequested",{callback:e})}},{key:"deviceAnsweredCall",value:function(e){this.emitEvent("deviceAnsweredCall",e)}},{key:"deviceRejectedCall",value:function(e){this.emitEvent("deviceRejectedCall",e)}},{key:"deviceEndedCall",value:function(e){this.emitEvent("deviceEndedCall",e)}},{key:"deviceMuteChanged",value:function(e){this.emitEvent("deviceMuteStatusChanged",a({},e))}},{key:"deviceHoldStatusChanged",value:function(e){this.emitEvent("deviceHoldStatusChanged",a({},e))}},{key:"deviceEventLogs",value:function(e){this.emitEvent("deviceEventLogs",e)}},{key:"changeConnectionStatus",value:function(e){this.isConnected=e.isConnected,this.isConnecting=e.isConnecting,this.emitEvent("deviceConnectionStatusChanged",a({currentVendor:this},e))}},{key:"deductProductId",value:function(e){var t=null==e?void 0:e.match(/\((\w+):(\w+)\)$/);return t?parseInt(t[2],16):null}}])&&s(n.prototype,i),o&&s(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,i,o}(r.EventEmitter)},function(e,t,n){e.exports=function(){"use strict";var e="undefined"==typeof window,t=!1,n=!1,r=!1,i=!1,o=!1,a=!1,s=!1,c=!1,u=!1,l=!1;return e||(t="undefined"!=typeof InstallTrigger,n=!!window.chrome,r=!!window.chrome,i=n&&!window.chrome.webstore&&!window.chrome.runtime,o=0<Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")||window.safari&&window.safari.pushNotification,a=!!window.opr&&!!window.opr.addons||!!window.opera,s=!!window.StyleMedia,c=n&&!!navigator.userAgent.match(/edg/i),u=(r||a)&&!!window.CSS,l=!(n||o||t||a||!document.documentMode)),{get isChrome(){return r},get isChromeOrChromium(){return n},get isChromium(){return i},get isFirefox(){return t},get isSafari(){return o},get isOpera(){return a},get isEdge(){return s},get isEdgeChromium(){return c},get isIE(){return l},get isBlink(){return u}}}()},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise((function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&g(e,"error",t,n)}(e,i,{once:!0})}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function f(e,t,n,r){var i,o,a,s;if(u(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),void 0===a)a=o[t]=n,++e._eventsCount;else if("function"==typeof a?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=l(e))>0&&a.length>i&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,s=c,console&&console.warn&&console.warn(s)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=h.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):y(i,i.length)}function v(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function y(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function g(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(o){r.once&&e.removeEventListener(t,i),n(o)}))}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var u=c.length,l=y(c,u);for(n=0;n<u;++n)o(l[n],this,t)}return!0},s.prototype.addListener=function(e,t){return f(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return f(this,e,t,!0)},s.prototype.once=function(e,t){return u(t),this.on(e,d(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,d(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,o,a;if(u(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},s.prototype.listenerCount=v,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){},function(e,t){},function(e,t,n){},function(e,t){},function(e,t,n){var r,i,o;i=[t,e],void 0===(o="function"==typeof(r=function(e,t){"use strict";var n=5e3,r="callback";function i(){return"jsonp_"+Date.now()+"_"+Math.ceil(1e5*Math.random())}function o(e){try{delete window[e]}catch(t){window[e]=void 0}}function a(e){var t=document.getElementById(e);t&&document.getElementsByTagName("head")[0].removeChild(t)}t.exports=function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],s=e,c=t.timeout||n,u=t.jsonpCallback||r,l=void 0;return new Promise((function(n,r){var f=t.jsonpCallbackFunction||i(),h=u+"_"+f;window[f]=function(e){n({ok:!0,json:function(){return Promise.resolve(e)}}),l&&clearTimeout(l),a(h),o(f)},s+=-1===s.indexOf("?")?"?":"&";var d=document.createElement("script");d.setAttribute("src",""+s+u+"="+f),t.charset&&d.setAttribute("charset",t.charset),t.nonce&&d.setAttribute("nonce",t.nonce),t.referrerPolicy&&d.setAttribute("referrerPolicy",t.referrerPolicy),t.crossorigin&&d.setAttribute("crossorigin","true"),d.id=h,document.getElementsByTagName("head")[0].appendChild(d),l=setTimeout((function(){r(new Error("JSONP request to "+e+" timed out")),o(f),a(h),window[f]=function(){o(f)}}),c),d.onerror=function(){r(new Error("JSONP request to "+e+" failed")),o(f),a(h),l&&clearTimeout(l)}}))}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){"use strict";n.d(t,"a",(function(){return ir}));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)}function o(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function a(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}Object.create;function s(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 c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.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 a}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function l(e){return this instanceof l?(this.v=e,this):new l(e)}function f(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),o=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(e){i[e]&&(r[e]=function(t){return new Promise((function(n,r){o.push([e,t,n,r])>1||s(e,t)}))})}function s(e,t){try{(n=i[e](t)).value instanceof l?Promise.resolve(n.value.v).then(c,u):f(o[0][2],n)}catch(e){f(o[0][3],e)}var n}function c(e){s("next",e)}function u(e){s("throw",e)}function f(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function h(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=s(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}}Object.create;"function"==typeof SuppressedError&&SuppressedError;function d(e){return"function"==typeof e}function p(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 v=p((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 y(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var g=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=s(o),l=a.next();!l.done;l=a.next()){l.value.remove(this)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else o.remove(this);var f=this.initialTeardown;if(d(f))try{f()}catch(e){i=e instanceof v?e.errors:[e]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var p=s(h),y=p.next();!y.done;y=p.next()){var g=y.value;try{w(g)}catch(e){i=null!=i?i:[],e instanceof v?i=u(u([],c(i)),c(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}}if(i)throw new v(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)w(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&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)&&y(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&y(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),m=g.EMPTY;function b(e){return e instanceof g||e&&"closed"in e&&d(e.remove)&&d(e.add)&&d(e.unsubscribe)}function w(e){d(e)?e():e.unsubscribe()}var E={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},C={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=C.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,u([e,t],c(n))):setTimeout.apply(void 0,u([e,t],c(n)))},clearTimeout:function(e){var t=C.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function _(e){C.setTimeout((function(){var t=E.onUnhandledError;if(!t)throw e;t(e)}))}function I(){}var k=O("C",void 0,void 0);function O(e,t,n){return{kind:e,value:t,error:n}}var S=null;function T(e){if(E.useDeprecatedSynchronousErrorHandling){var t=!S;if(t&&(S={errorThrown:!1,error:null}),e(),t){var n=S,r=n.errorThrown,i=n.error;if(S=null,r)throw i}}else e()}var x=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,b(t)&&t.add(n)):n.destination=j,n}return i(t,e),t.create=function(e,t,n){return new N(e,t,n)},t.prototype.next=function(e){this.isStopped?D(function(e){return O("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?D(O("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?D(k,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}(g),A=Function.prototype.bind;function L(e,t){return A.call(e,t)}var P=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){R(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){R(e)}else R(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){R(e)}},e}(),N=function(e){function t(t,n,r){var i,o,a=e.call(this)||this;d(t)||!t?i={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:a&&E.useDeprecatedNextContext?((o=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},i={next:t.next&&L(t.next,o),error:t.error&&L(t.error,o),complete:t.complete&&L(t.complete,o)}):i=t;return a.destination=new P(i),a}return i(t,e),t}(x);function R(e){var t;E.useDeprecatedSynchronousErrorHandling?(t=e,E.useDeprecatedSynchronousErrorHandling&&S&&(S.errorThrown=!0,S.error=t)):_(e)}function D(e,t){var n=E.onStoppedNotification;n&&C.setTimeout((function(){return n(e,t)}))}var j={closed:!0,next:I,error:function(e){throw e},complete:I},H="function"==typeof Symbol&&Symbol.observable||"@@observable";function U(e){return e}function M(e){return 0===e.length?U:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var F=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 x||function(e){return e&&d(e.next)&&d(e.error)&&d(e.complete)}(r)&&b(r)?e:new N(e,t,n);return T((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=B(t))((function(t,r){var i=new N({next:function(t){try{e(t)}catch(e){r(e),i.unsubscribe()}},error:r,complete:t});n.subscribe(i)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[H]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return M(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=B(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 B(e){var t;return null!==(t=null!=e?e:E.Promise)&&void 0!==t?t:Promise}var G=p((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Y=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return i(t,e),t.prototype.lift=function(e){var t=new V(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new G},t.prototype.next=function(e){var t=this;T((function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=s(t.currentObservers),o=i.next();!o.done;o=i.next()){o.value.next(e)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;T((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;T((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=this.currentObservers=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,n=this.hasError,r=this.isStopped,i=this.observers;return n||r?m:(this.currentObservers=null,i.push(e),new g((function(){t.currentObservers=null,y(i,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 F;return e.source=this,e},t.create=function(e,t){return new V(e,t)},t}(F),V=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:m},t}(Y),W=n(2),q=n(3),K=n.n(q);function z(){return!!window._HostedContextFunctions}function $(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 J(e){return(J="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 X(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Q(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Z(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Z=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==J(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(J(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function ee(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function te(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){ee(o,r,i,a,s,"next",e)}function s(e){ee(o,r,i,a,s,"throw",e)}a(void 0)}))}}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(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,ce(r.key),r)}}function ie(e,t,n){return t=oe(t),function(e,t){if(t&&("object"===J(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],oe(e).constructor):t.apply(e,n))}function oe(e){return(oe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ae(e,t){return(ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function se(e,t,n){return(t=ce(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(e){var t=function(e,t){if("object"!=J(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=J(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==J(t)?t:t+""}var ue=1,le=4,fe=function(e){function t(){var e;ne(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return se(e=ie(this,t,[].concat(r)),"vendorName","CyberAcoustics"),se(e,"activeConversationId",void 0),se(e,"_deviceInfo",null),se(e,"activeDevice",void 0),se(e,"numDeviceEventListeners",0),se(e,"currentProductID",null),se(e,"headsetOutputReportId",3),se(e,"headsetInputReportId",3),se(e,"vendorInputReportId",4),se(e,"currentState",0),se(e,"isHolding",!1),se(e,"currentlDeviceLabel",void 0),se(e,"currentCallInfo",void 0),se(e,"currentCallState","callIdle"),se(e,"deviceStatus",0),se(e,"gCmdBuf",new Uint8Array([0,0])),se(e,"inputReportReportId",3),se(e,"outputReportReportId",3),se(e,"JLCommandSet",!1),se(e,"callControlSuport",!0),se(e,"flagSupport",15),se(e,"handeledInputReportIds",[e.headsetInputReportId,e.vendorInputReportId]),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ae(e,t)}(t,e),n=t,r=[{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isSupported",value:function(){return window.navigator.hid&&!z()}},{key:"deviceLabelMatchesVendor",value:function(e){this.logger.debug("CA: matchVendor");var t=e.toLowerCase();return["ac-104enc","ac-204enc","ac-304","foundever","ca essential","ca-2890"].some((function(e){return t.includes(e)}))}},{key:"connect",value:(m=te(Z().mark((function e(t){var n,r,i=this;return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=!1,this.logger.debug("CA: Connect Attempt"),this.currentlDeviceLabel=t,this.logger.debug("CA Device String = ".concat(t)),this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),e.next=7,window.navigator.hid.getDevices();case 7:if(r=e.sent,this.selectDevice(r,t),!this.activeDevice){e.next=14;break}if(this.activeDevice.opened){e.next=13;break}return e.next=13,this.activeDevice.open();case 13:this.activeDevice.opened?(n=!0,this.handleDeviceConnect(),this.logger.debug("CA: Connect SUCCESS- previously connected device")):this.logger.debug("CA: Connect FAIL- Failed connect to previously connected device");case 14:if(n){e.next=26;break}return e.prev=15,e.next=18,new Promise((function(e,n){var r=setTimeout(n,3e4);i.requestWebHidPermissions(te(Z().mark((function o(){var a,s,c;return Z().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i.logger.debug("Requesting web HID permissions"),a=i.deductProductId(t),o.next=4,window.navigator.hid.requestDevice({filters:[{vendorId:13201,productId:a||void 0}]});case 4:return s=o.sent,clearTimeout(r),o.next=8,i.connectFromHidPermissions(s,t);case 8:(c=o.sent)?e(c):n(),console.debug("CA: requestWebHidPermissions device found = ".concat(c," "));case 11:case"end":return o.stop()}}),o)}))))}));case 18:n=e.sent,e.next=26;break;case 21:return e.prev=21,e.t0=e.catch(15),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),this.logger.error("CA: WebHID permissions denied"),e.abrupt("return");case 26:case"end":return e.stop()}}),e,this,[[15,21]])}))),function(e){return m.apply(this,arguments)})},{key:"connectFromHidPermissions",value:(g=te(Z().mark((function e(t,n){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.activeDevice=null,this.selectDevice(t,n),!this.activeDevice){e.next=14;break}if(this.activeDevice.opened){e.next=6;break}return e.next=6,this.activeDevice.open();case 6:if(!this.activeDevice.opened){e.next=12;break}return this.handleDeviceConnect(),this.logger.debug("CA: Connect SUCCESS- from HIDWebPermission request "),e.abrupt("return",!0);case 12:return this.logger.debug("CA: Connect FAIL requesting WebHID permissions"),e.abrupt("return",!1);case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})},{key:"handleInputReport",value:function(e){var t=e.reportId;if(this.handeledInputReportIds.includes(t)){var n=e.data.getUint8(0),r=(e.data.getUint8(1)<<8)+n;this.logger.debug("CA received button press ".concat(this.formatHex(r)," reportID ").concat(t," from Device")),this.handleDeviceButtonPress(r,t)}}},{key:"handleDeviceConnect",value:(y=te(Z().mark((function e(){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._deviceInfo={ProductName:this.activeDevice.productName},this.handleInputReport=this.handleInputReport.bind(this),this.activeDevice.addEventListener("inputreport",this.handleInputReport),this.numDeviceEventListeners++,console.debug("Installed Device Input listener, num listeners = ".concat(this.numDeviceEventListeners," ")),this.numDeviceEventListeners>1&&(this.logger.debug("%c CA: ********************************************************","color: red"),this.logger.debug("%c CA: *****WARNING ***** MULTIPLE EVENT LISTENERS ON DEVICE!!!","color: red"),this.logger.debug("%c CA: ********************************************************","color: red")),this.currentProductID=this.activeDevice.productId,this.logger.debug("Product ID: 0x".concat(this.currentProductID.toString(16))),this.currentCallState="callIdle",this.headsetOutputReportId=this.outputReportReportId,this.headsetInputReportId=this.outputReportReportId,this.vendorInputReportId=4,this.handeledInputReportIds=[this.headsetInputReportId,this.vendorInputReportId],e.t0=this.currentProductID,e.next=4===e.t0?16:24===e.t0?21:23;break;case 16:return this.flagSupport=576,this.JLCommandSet=!0,ue=512,le=64,e.abrupt("break",25);case 21:return this.flagSupport=5,e.abrupt("break",25);case 23:return this.flagSupport=15,e.abrupt("break",25);case 25:this.logger.debug("flagSupport = ".concat(this.formatHex(this.flagSupport)," ")),this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 27:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"selectDevice",value:function(e,t){var n=this;this.logger.debug("CA: SelectDevice");var r=t.toLowerCase(),i=!1;return e.forEach((function(e){var t;if(r.includes(null==e||null===(t=e.productName)||void 0===t?void 0:t.toLowerCase())){var o,a=X(e.collections);try{for(a.s();!(o=a.n()).done;){var s=o.value;if((5===s.usage||1===s.usage)&&11===s.usagePage){n.activeDevice=e,i=!0,0!==s.inputReports.length&&(n.inputReportReportId=s.inputReports[0].reportId,n.logger.debug("CA inputReportReportId = ".concat(n.inputReportReportId))),0!==s.outputReports.length&&(n.outputReportReportId=s.outputReports[0].reportId,n.logger.debug("CA outputReportReportId = ".concat(n.outputReportReportId)));break}}}catch(e){a.e(e)}finally{a.f()}}})),i}},{key:"disconnect",value:(v=te(Z().mark((function e(){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.activeDevice){e.next=15;break}return this.logger.debug("CA: Disconnecting"),this.ChangeCallState("callEnd"),this.ChangeCallState("callIdle"),this.isMuted&&(this.setMute(!1),this.deviceMuteChanged({isMuted:!1,name:"CallUnmuted"})),this.activeDevice.removeEventListener("inputreport",this.handleInputReport),this.numDeviceEventListeners--,console.debug("Removed Device Input listener, num listeners = ".concat(this.numDeviceEventListeners," ")),e.next=10,this.activeDevice.close();case 10:this.logger.debug("CA: Device closed"),this.activeDevice=null,this._deviceInfo=null,this.currentCallState="callIdle",(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1});case 15:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"incomingCall",value:(p=te(Z().mark((function e(t){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: incomingCall"),this.currentCallInfo=t,this.activeConversationId=t.conversationId,this.ParseStateEvents(2);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"outgoingCall",value:(d=te(Z().mark((function e(t){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: outgoingCall"),this.currentCallInfo=t,this.activeConversationId=t.conversationId,this.ParseStateEvents(8);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"answerCall",value:(h=te(Z().mark((function e(t,n){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: Answer Call from UI"),this.activeConversationId=t,n&&(this.logger.debug("CA: AutoAnswer"),this.ParseStateEvents(2)),this.ParseStateEvents(7);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"rejectCall",value:(f=te(Z().mark((function e(){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: rejectCall from UI"),this.ParseStateEvents(3);case 2:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"endCall",value:(l=te(Z().mark((function e(t,n){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: endCall from UI"),this.ParseStateEvents(3);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"endAllCalls",value:(u=te(Z().mark((function e(){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: endAllCalls from UI"),this.ParseStateEvents(3);case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"setMute",value:(c=te(Z().mark((function e(t){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: setMute. Value: ".concat(t)),this.isMuted=t,this.UpdateDeviceStatus(le,t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setHold",value:(s=te(Z().mark((function e(t,n){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: setHold. Value: ".concat(n)),this.activeConversationId=t,this.isHolding=n;case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleDeviceButtonPress",value:function(e,t){if(this.activeDevice)if(t===this.headsetInputReportId){if(24===this.currentProductID){switch(e){case 1:case 5:this.isMuted=!this.isMuted,this.deviceMuteChanged({isMuted:this.isMuted,name:this.isMuted?"CallMuted":"CallUnmuted"}),this.UpdateDeviceStatus(le,this.isMuted),this.logger.debug("CA: AC304 Mute update micMuteFlag = ".concat(this.formatHex(le)," this.isMuted = ").concat(this.isMuted))}return}switch(e){case 515:case 19:this.isMuted=!this.isMuted,this.deviceMuteChanged({isMuted:this.isMuted,name:this.isMuted?"CallMuted":"CallUnmuted"}),this.setMute(this.isMuted);break;case 0:this.ParseStateEvents(5);break;case 1:this.ParseStateEvents(0);break;case 2:this.ParseStateEvents(6)}}else if(t===this.vendorInputReportId)switch(e){case 2:this.ParseStateEvents(1)}else console.debug("CA: Unhandeled input report #".concat(t.toString(16)));else this.logger.error("do not have active device")}},{key:"ParseStateEvents",value:function(e){switch(this.currentCallState){case"callIdle":switch(e){case 2:this.ChangeCallState("callIncoming");break;case 8:this.ChangeCallState("callOutgoing")}break;case"callIncoming":switch(e){case 0:case 7:this.ChangeCallState("callAnswering");break;case 5:case 3:this.ChangeCallState("callRejecting"),this.ChangeCallState("callEnd"),this.ChangeCallState("callIdle")}break;case"callAnswering":switch(e){case 1:this.ChangeCallState("callActive");break;case 3:case 5:this.ChangeCallState("callEnd"),this.ChangeCallState("callIdle")}break;case"callActive":case"callOutgoing":switch(e){case 3:case 6:this.ChangeCallState("callEnd"),this.ChangeCallState("callIdle")}}}},{key:"ChangeCallState",value:function(e){switch(this.logger.debug("%cCA SETTING STATE: ".concat(e),"color: red"),this.currentCallState=e,this.currentCallState){case"callIdle":this.deviceStatus=0;break;case"callIncoming":this.UpdateDeviceStatus(8,!0);break;case"callOutgoing":case"callAnswering":this.UpdateDeviceStatus(ue,!0),this.isMuted&&(this.setMute(!1),this.deviceMuteChanged({isMuted:!1,name:"CallUnmuted"}));break;case"callActive":this.UpdateDeviceStatus(8,!1),this.deviceAnsweredCall({name:"CallOffHook",conversationId:this.activeConversationId});break;case"callEnd":this.UpdateDeviceStatus(ue,!1),this.deviceEndedCall({name:"CallOnHook",conversationId:this.activeConversationId});break;case"callRejecting":this.UpdateDeviceStatus(8,!1),this.deviceRejectedCall({name:"CallRejected",conversationId:this.activeConversationId})}}},{key:"UpdateDeviceStatus",value:function(e,t){e&this.flagSupport?(this.deviceStatus=t?this.deviceStatus|e:this.deviceStatus&~e,this.SendCommandToDevice(this.deviceStatus)):console.debug("CA: UpdateDeviceStatus called with unsupported flag ".concat(e.toString(16),"... returning"))}},{key:"SendCommandToDevice",value:(a=te(Z().mark((function e(t){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.JLCommandSet?(this.gCmdBuf[0]=t>>8,this.gCmdBuf[1]=255&t):this.gCmdBuf[0]=t,e.next=3,this.activeDevice.sendReport(this.headsetOutputReportId,this.gCmdBuf);case 3:this.logger.debug("CA: Sent Command to Device. Value: ".concat(this.formatHex(this.gCmdBuf[0]),", ").concat(this.formatHex(this.gCmdBuf[1])," ")),this.gCmdBuf[0]=0,this.gCmdBuf[1]=0;case 6:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"formatHex",value:function(e){return"0x".concat(e.toString(16).padStart(2,"0"))}},{key:"HidMockDeviceInit",value:(o=te(Z().mark((function e(){var t;return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.getDevices();case 2:return t=e.sent,this.activeDevice=t[0],e.abrupt("return",this.activeDevice);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_currentCallState",get:function(){return this.currentCallState},set:function(e){this.currentCallState=e}},{key:"_deviceStatus",get:function(){return this.deviceStatus},set:function(e){this.deviceStatus=e}},{key:"_activeConversationId",get:function(){return this.activeConversationId}},{key:"_currentCallInfo",get:function(){return this.currentCallInfo}},{key:"holdState",get:function(){return this.isHolding}},{key:"_headsetInputReportId",get:function(){return this.headsetInputReportId}},{key:"_vendorInputReportId",get:function(){return this.vendorInputReportId}},{key:"_headsetOutputReportId",get:function(){return this.headsetOutputReportId}},{key:"muteState",get:function(){return this.isMuted},set:function(e){this.isMuted=e}},{key:"_JLCommandSet",set:function(e){this.JLCommandSet=e}},{key:"_handeledInputReportIds",set:function(e){this.handeledInputReportIds[0]=e}},{key:"_flagSupport",set:function(e){this.flagSupport=e}},{key:"_currentProductID",set:function(e){this.currentProductID=e}}],i=[{key:"getInstance",value:function(e){return t.instance||(t.instance=new t(e)),t.instance}}],r&&re(n.prototype,r),i&&re(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d,p,v,y,g,m}(W.a);se(fe,"instance",void 0);var he=n(10),de=n.n(he),pe=function(e){return 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",e}({});function ve(e){return(ve="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 ye(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 ge(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ye(Object(n),!0).forEach((function(t){ke(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ye(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function me(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */me=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==ve(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(ve(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function be(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function we(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){be(o,r,i,a,s,"next",e)}function s(e){be(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Ee(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,Oe(r.key),r)}}function Ce(e,t,n){return t=_e(t),function(e,t){if(t&&("object"===ve(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],_e(e).constructor):t.apply(e,n))}function _e(e){return(_e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ie(e,t){return(Ie=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function ke(e,t,n){return(t=Oe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Oe(e){var t=function(e,t){if("object"!=ve(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=ve(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ve(t)?t:t+""}var Se=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),ke(n=Ce(this,t,[e]),"activePollingInterval",2e3),ke(n,"connectedDeviceInterval",6e3),ke(n,"disconnectedDeviceInterval",2e3),ke(n,"deviceIdRetryInterval",2e3),ke(n,"vendorName","Plantronics"),ke(n,"pluginName",void 0),ke(n,"apiHost","https://127.0.0.1:32018/Spokes"),ke(n,"isActive",!1),ke(n,"disableEventPolling",!1),ke(n,"config",void 0),ke(n,"deviceStatusTimer",null),ke(n,"isRetry",!1),ke(n,"_deviceInfo",void 0),ke(n,"callEventsTimerId",void 0),ke(n,"deviceStatusTimerId",void 0),ke(n,"incomingConversationId",void 0),ke(n,"callMappings",{}),n.config=e,n.pluginName=e.appName||"genesys-cloud-headset-library",n._deviceInfo=null,n.callEventsTimerId=null,n.deviceStatusTimerId=null,n.incomingConversationId=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ie(e,t)}(t,e),n=t,r=[{key:"_createCallMapping",value:function(e){var t=Math.round(Math.random()*Math.pow(10,8));return this.callMappings[e]=t,this.callMappings[t]=e,this.logger.info("Created callId mapping for plantronics headset",{conversationId:e,plantronicsCallId:t}),t}},{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:(b=we(me().mark((function e(t,n){return me().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 b.apply(this,arguments)})},{key:"_fetch",value:function(e){return de()(e)}},{key:"_makeRequest",value:(m=we(me().mark((function e(n,r){var i,o=this;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.instance,e.abrupt("return",this._fetch("".concat(this.apiHost).concat(n)).then((function(e){return e.json()})).then((function(e){if(o.isConnected||o.isConnecting){if(!1===e.ok||"Error"===e.Type_Name){if(404===e.status){if(r){o.isConnected&&o.changeConnectionStatus({isConnected:!1,isConnecting:o.isConnecting}),o.disconnect();var t=new Error("Headset: Failed connection to middleware. Headset features unavailable.");return t.handled=!0,o.logger.info(t),Promise.reject(t)}return o._makeRequestTask(n,!0)}return K.a.isFirefox&&(o.errorCode="browser",o.disableRetry=!0),Promise.reject(e)}return i?(!o.isConnected&&o.changeConnectionStatus({isConnected:!0,isConnecting:o.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 m.apply(this,arguments)})},{key:"_checkIsActiveTask",value:(g=we(me().mark((function e(){var t;return me().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 g.apply(this,arguments)})},{key:"_getActiveCalls",value:(y=we(me().mark((function e(){var t,n,r,i=this;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/CallServices/CallManagerState?");case 3:r=e.sent,n=r,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=n)||void 0===t||null===(t=t.Result)||void 0===t?void 0:t.Calls)){e.next=13;break}return e.abrupt("return",[]);case 13:return e.abrupt("return",n.Result.Calls.filter((function(e){return e.Source===i.pluginName})));case 14:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return y.apply(this,arguments)})},{key:"getCallEvents",value:(v=we(me().mark((function e(){var t,n=this;return me().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=pe[e.Action];if(!t)return n.logger.info("Unknown call event from headset",{event:e});var r={name:t,event:e};n.logger.debug("headset info",r),n.callCorrespondingFunction(r)}));case 11:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(){return v.apply(this,arguments)})},{key:"getDeviceStatus",value:(p=we(me().mark((function e(){var t=this;return me().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 p.apply(this,arguments)})},{key:"callCorrespondingFunction",value:function(e){var t=e.event.CallId.Id,n=this.callMappings[t];switch(e.name){case"AcceptCall":this.deviceAnsweredCall(ge(ge({},e),{},{conversationId:n}));break;case"RejectCall":this.endCall(n),this.deviceRejectedCall({name:e.name,conversationId:this.incomingConversationId});break;case"TerminateCall":this.setMute(!1),this.setHold(n,!1),this.deviceEndedCall(ge(ge({},e),{},{conversationId:n}));break;case"CallEnded":delete this.callMappings[t],delete this.callMappings[n],this._checkIsActiveTask();break;case"Mute":this.deviceMuteChanged(ge(ge({isMuted:!0},e),{},{conversationId:n}));break;case"Unmute":this.deviceMuteChanged(ge(ge({isMuted:!1},e),{},{conversationId:n}));break;case"HoldCall":this.deviceHoldStatusChanged(ge(ge({holdRequested:!0},e),{},{conversationId:n}));break;case"ResumeCall":this.deviceHoldStatusChanged(ge(ge({holdRequested:!1},e),{},{conversationId:n}));break;default:this.logger.info("A headset event has occurred",ge(ge({},e),{},{conversationId:n})),this.deviceEventLogs(ge(ge({},e),{},{conversationId:n}))}}},{key:"unregisterPlugin",value:(d=we(me().mark((function e(){var t;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/SessionManager/UnRegister?name=".concat(this.pluginName));case 3:return e.abrupt("return",e.sent);case 6:if(e.prev=6,e.t0=e.catch(0),"Invalid plugin name"!==(null===e.t0||void 0===e.t0||null===(t=e.t0.Err)||void 0===t?void 0:t.Description)){e.next=10;break}return e.abrupt("return");case 10:this.logger.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(){return d.apply(this,arguments)})},{key:"connect",value:(h=we(me().mark((function e(){var t=this;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),this.pollForDeviceStatus(),this.pollForCallEvents(),e.next=5,this.unregisterPlugin();case 5:return e.abrupt("return",this._makeRequestTask("/SessionManager/Register?name=".concat(this.pluginName)).catch((function(e){return e.Err&&"Plugin exists"===e.Err.Description?t.logger.debug("Plugin already exists",e):Promise.reject(e)})).then((function(){return t._makeRequestTask("/SessionManager/IsActive?name=".concat(t.pluginName,"&active=true"))})).catch((function(e){return e.Err&&!e.isError?t.logger.debug("Is Active",e):Promise.reject(e)})).then((function(e){return!0!==(null==e?void 0:e.Result)?Promise.reject(e):t._makeRequestTask("/UserPreference/SetDefaultSoftPhone?name=".concat(t.pluginName))})).then((function(){t.getDeviceStatus()})).then((function(){return t._getActiveCalls()})).then((function(e){if(!e.length)return t.getCallEvents();t.isActive=!0,t.logger.warn("Plantronics headset should be in vanilla state but is reporting active call state.")})).catch((function(e){return null!=e&&e.handled?t.logger.error("Unable to properly connect headset"):Promise.reject(e)})).finally((function(){t.isConnecting&&t.changeConnectionStatus({isConnected:t.isConnected,isConnecting:!1})})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"disconnect",value:(f=we(me().mark((function e(t){return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=2;break}return e.abrupt("return");case 2:if("alternativeClient"===t){e.next=5;break}return e.next=5,this.unregisterPlugin();case 5:this.clearTimeouts(),this._deviceInfo=null,this.isConnected&&this.changeConnectionStatus({isConnected:!1,isConnecting:this.isConnecting}),this.isActive=!1;case 9:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{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");var r=this._createCallMapping(t);this.incomingConversationId=t;var i="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),o='"Id":"'.concat(r,'"');if(i+="&callID={".concat(encodeURI(o),"}"),n){var a='"Name":"'.concat(n,'"');i+="&contact={".concat(encodeURI(a),"}")}return this.logger.info("params of endpoint",i),this.isActive=!0,this._makeRequestTask("/CallServices/IncomingCall".concat(i))}},{key:"outgoingCall",value:(l=we(me().mark((function e(t){var n,r,i,o,a,s;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.conversationId,r=t.contactName,n){e.next=3;break}throw new Error("Must provide conversationId");case 3:return i=this._createCallMapping(n),o="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),a='"Id":"'.concat(i,'"'),o+="&callID={".concat(encodeURI(a),"}"),r&&(s='"Name":"'.concat(r,'"'),o+="&contact={".concat(encodeURI(s),"}")),this.isActive=!0,e.next=11,this._makeRequestTask("/CallServices/OutgoingCall".concat(o));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"answerCall",value:(u=we(me().mark((function e(t,n){var r,i,o;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=3;break}return e.next=3,this.incomingCall({conversationId:t});case 3:return r=this.callMappings[t],i='"Id":"'.concat(r,'"'),o="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(i),"}"),this.isActive=!0,this.incomingConversationId=null,e.abrupt("return",this._makeRequestTask("/CallServices/AnswerCall".concat(o)));case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"rejectCall",value:function(e){return this.incomingConversationId=null,this.endCall(e)}},{key:"endCall",value:(c=we(me().mark((function e(t){var n,r,i,o;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="?name=".concat(this.pluginName),r=this.callMappings[t],i='"Id":"'.concat(r,'"'),n+="&callID={".concat(encodeURI(i),"}"),e.next=6,this._makeRequestTask("/CallServices/TerminateCall".concat(n));case 6:return o=e.sent,this.setMute(!1),this.setHold(t,!1),e.next=11,this.getCallEvents();case 11:return this._checkIsActiveTask(),e.abrupt("return",o);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"endAllCalls",value:(s=we(me().mark((function e(){var t=this;return me().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(t.callMappings[e.CallId])}));case 4:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"setMute",value:(a=we(me().mark((function e(t){var n;return me().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 a.apply(this,arguments)})},{key:"setHold",value:(o=we(me().mark((function e(t,n){var r,i,o,a;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.callMappings[t],i='"Id":"'.concat(r,'"'),o="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(i),"}"),e.next=5,this._makeRequestTask("/CallServices/".concat(n?"HoldCall":"ResumeCall").concat(o));case 5:return a=e.sent,e.abrupt("return",a);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})}],i=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],r&&Ee(n.prototype,r),i&&Ee(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d,p,v,y,g,m,b}(W.a);ke(Se,"instance",void 0);var Te=function(e){return 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",e}({}),xe=function(e){return e.Request="Request",e.Notification="Notification",e.Ack="Acknowledgement",e}({});function Ae(e){return(Ae="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 Le(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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,He(r.key),r)}}function Ne(e,t,n){return t=Re(t),function(e,t){if(t&&("object"===Ae(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],Re(e).constructor):t.apply(e,n))}function Re(e){return(Re=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function De(e,t){return(De=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function je(e,t,n){return(t=He(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function He(e){var t=function(e,t){if("object"!=Ae(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Ae(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Ae(t)?t:t+""}var Ue=function(e){function t(){var e;Le(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return je(e=Ne(this,t,[].concat(r)),"connectTimeout",5e3),je(e,"vendorName","Sennheiser"),je(e,"isActive",!1),je(e,"devices",null),je(e,"activeDeviceId",null),je(e,"websocketConnected",!1),je(e,"websocket",null),je(e,"deviceInfo",null),je(e,"ignoreAcknowledgement",!1),je(e,"webSocketOnOpen",(function(){e.websocketConnected=!0,e.logger.info("websocket open the sennheiser software")})),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&De(e,t)}(t,e),n=t,i=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],(r=[{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:"resetHeadsetStateForCall",value:function(e){return this.ignoreAcknowledgement=!0,this.endCall(e)}},{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:xe.Request,SPName:"Genesys Cloud Softphone",SPIconImage:"SPImage.ico",RedialSupport:"No",OffHookSupport:"No",MuteSupport:"Yes",DNDOption:"No"};this._sendMessage(e)}},{key:"connect",value:function(){this.ignoreAcknowledgement=!1,!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")),K.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:xe.Request}),Promise.resolve()):Promise.resolve()}},{key:"setMute",value:function(e){return this._sendMessage({Event:e?Te.MuteFromApp:Te.UnmuteFromApp,EventType:xe.Request}),Promise.resolve()}},{key:"setHold",value:function(e,t){return this._sendMessage({Event:t?Te.Hold:Te.Resume,EventType:xe.Request,CallID:e}),Promise.resolve()}},{key:"incomingCall",value:function(e){return this.ignoreAcknowledgement=!1,this._sendMessage({Event:Te.IncomingCall,EventType:xe.Request,CallID:e.conversationId}),Promise.resolve()}},{key:"answerCall",value:function(e,t){return t&&this.incomingCall({conversationId:e}),this._sendMessage({Event:Te.IncomingCallAccepted,EventType:xe.Request,CallID:e}),Promise.resolve()}},{key:"rejectCall",value:function(e){return this._sendMessage({Event:Te.IncomingCallRejected,EventType:xe.Request,CallID:e}),Promise.resolve()}},{key:"outgoingCall",value:function(e){this.ignoreAcknowledgement=!1;var t=e.conversationId;return this._sendMessage({Event:Te.OutgoingCall,EventType:xe.Request,CallID:t}),Promise.resolve()}},{key:"endCall",value:function(e,t){return t||(this._sendMessage({Event:Te.Resume,EventType:xe.Request}),this._sendMessage({Event:Te.UnmuteFromApp,EventType:xe.Request})),this._sendMessage({Event:Te.CallEnded,EventType:xe.Request,CallID:e}),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=t.CallID;if(!this.ignoreAcknowledgement)switch(t.Event){case Te.SocketConnected:this._registerSoftphone();break;case Te.EstablishConnection:this._sendMessage({Event:Te.SPLogin,EventType:xe.Request});break;case Te.SPLogin:this.isConnected&&!this.isConnecting||this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),this._sendMessage({Event:Te.SystemInformation,EventType:xe.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===xe.Notification&&this.deviceAnsweredCall({name:t.Event,conversationId:n});break;case Te.Hold:if(t.EventType===xe.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged({holdRequested:!0,name:t.Event,conversationId:n});break;case Te.Resume:if(t.EventType===xe.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged({holdRequested:!1,name:t.Event,conversationId:n});break;case Te.MuteFromHeadset:this.deviceMuteChanged({isMuted:!0,name:t.Event});break;case Te.UnmuteFromHeadset:this.deviceMuteChanged({isMuted:!1,name:t.Event});break;case Te.CallEnded:t.EventType===xe.Notification&&(this._sendMessage({Event:Te.UnmuteFromApp,EventType:xe.Request}),this.deviceEndedCall({name:t.Event,conversationId:n}));break;case Te.IncomingCallRejected:t.EventType===xe.Notification&&this.deviceRejectedCall({name:t.Event,conversationId:n});break;case Te.TerminateConnection:1===this.websocket.readyState&&this.websocket.close(),this.websocket=null;break;default:t.EventType===xe.Ack&&this._handleAck(t)}}}}])&&Pe(n.prototype,r),i&&Pe(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i}(W.a);je(Ue,"instance",void 0);var Me=n(0),Fe=p((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Be(e,t){var n="object"==typeof t;return new Promise((function(r,i){var o=new N({next:function(e){r(e),o.unsubscribe()},error:i,complete:function(){n?r(t.defaultValue):i(new Fe)}});e.subscribe(o)}))}var Ge=function(e){function t(t,n){return e.call(this)||this}return i(t,e),t.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},t}(g),Ye={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=Ye.delegate;return(null==i?void 0:i.setInterval)?i.setInterval.apply(i,u([e,t],c(n))):setInterval.apply(void 0,u([e,t],c(n)))},clearInterval:function(e){var t=Ye.delegate;return((null==t?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},Ve=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return i(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var r=this.id,i=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(i,r,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(i,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),Ye.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!=n&&this.delay===n&&!1===this.pending)return t;null!=t&&Ye.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n,r=!1;try{this.work(e)}catch(e){r=!0,n=e||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,r=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,y(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Ge),We={now:function(){return(We.delegate||Date).now()},delegate:void 0},qe=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=We.now,e}(),Ke=new(function(e){function t(t,n){void 0===n&&(n=qe.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return i(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var n;this._active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}(qe))(Ve);function ze(e){return function(t){if(function(e){return d(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 $e="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Je(e){if(e instanceof F)return e;if(null!=e){if(function(e){return d(e[H])}(e))return c=e,new F((function(e){var t=c[H]();if(d(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if((o=e)&&"number"==typeof o.length&&"function"!=typeof o)return i=e,new F((function(e){for(var t=0;t<i.length&&!e.closed;t++)e.next(i[t]);e.complete()}));if(d(null==(r=e)?void 0:r.then))return n=e,new F((function(e){n.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,_)}));if(function(e){return Symbol.asyncIterator&&d(null==e?void 0:e[Symbol.asyncIterator])}(e))return Xe(e);if(function(e){return d(null==e?void 0:e[$e])}(e))return t=e,new F((function(e){var n,r;try{for(var i=s(t),o=i.next();!o.done;o=i.next()){var a=o.value;if(e.next(a),e.closed)return}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}e.complete()}));if(function(e){return d(null==e?void 0:e.getReader)}(e))return Xe(function(e){return f(this,arguments,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,l(t.read())];case 3:return n=i.sent(),r=n.value,n.done?[4,l(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,l(r)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e))}var t,n,r,i,o,c;throw function(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(e)}function Xe(e){return new F((function(t){(function(e,t){var n,r,i,s;return o(this,void 0,void 0,(function(){var o,c;return a(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),n=h(e),a.label=1;case 1:return[4,n.next()];case 2:if((r=a.sent()).done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=a.sent(),i={error:c},[3,11];case 6:return a.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function Qe(e,t,n,r,i){return new Ze(e,t,n,r,i)}var Ze=function(e){function t(t,n,r,i,o,a){var s=e.call(this,t)||this;return s.onFinalize=o,s.shouldUnsubscribe=a,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;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(x);var et=p((function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}}));function tt(e,t){var n,r=(n=e)instanceof Date&&!isNaN(n)?{first:e}:"number"==typeof e?{each:e}:e,i=r.first,o=r.each,a=r.with,s=void 0===a?nt:a,c=r.scheduler,u=void 0===c?null!=t?t:Ke:c,l=r.meta,f=void 0===l?null:l;if(null==i&&null==o)throw new TypeError("No timeout provided.");return ze((function(e,t){var n,r,a=null,c=0,l=function(e){r=function(e,t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=!1);var o=t.schedule((function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()}),r);if(e.add(o),!i)return o}(t,u,(function(){try{n.unsubscribe(),Je(s({meta:f,lastValue:a,seen:c})).subscribe(t)}catch(e){t.error(e)}}),e)};n=e.subscribe(Qe(t,(function(e){null==r||r.unsubscribe(),c++,t.next(a=e),o>0&&l(o)}),void 0,void 0,(function(){(null==r?void 0:r.closed)||null==r||r.unsubscribe(),a=null}))),!c&&l(null!=i?"number"==typeof i?i:+i-u.now():o)}))}function nt(e){throw new et(e)}function rt(e){return ze((function(t,n){var r=!1;t.subscribe(Qe(n,(function(e){r=!0,n.next(e)}),(function(){r||n.next(e),n.complete()})))}))}function it(e,t){return ze((function(n,r){var i=0;n.subscribe(Qe(r,(function(n){return e.call(t,n,i++)&&r.next(n)})))}))}var ot=new F((function(e){return e.complete()}));function at(e){return e<=0?function(){return ot}:ze((function(t,n){var r=0;t.subscribe(Qe(n,(function(t){++r<=e&&(n.next(t),e<=r&&n.complete())})))}))}function st(e){return void 0===e&&(e=ct),ze((function(t,n){var r=!1;t.subscribe(Qe(n,(function(e){r=!0,n.next(e)}),(function(){return r?n.complete():n.error(e())})))}))}function ct(){return new Fe}function ut(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?it((function(t,n){return e(t,n,r)})):U,at(1),n?rt(t):st((function(){return new Fe})))}}function lt(e,t){return ze((function(n,r){var i=0;n.subscribe(Qe(r,(function(n){r.next(e.call(t,n,i++))})))}))}function ft(e){return(ft="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 ht(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ht=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==ft(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(ft(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function dt(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function pt(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){dt(o,r,i,a,s,"next",e)}function s(e){dt(o,r,i,a,s,"throw",e)}a(void 0)}))}}function vt(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,wt(r.key),r)}}function yt(e,t,n){return t=gt(t),function(e,t){if(t&&("object"===ft(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],gt(e).constructor):t.apply(e,n))}function gt(e){return(gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function mt(e,t){return(mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function bt(e,t,n){return(t=wt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wt(e){var t=function(e,t){if("object"!=ft(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=ft(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ft(t)?t:t+""}var Et=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),bt(n=yt(this,t,[e]),"headsetEventSubscription",void 0),bt(n,"isActive",!1),bt(n,"_deviceInfo",void 0),bt(n,"isMuted",!1),bt(n,"isHeld",!1),bt(n,"version",null),bt(n,"_connectDeferred",void 0),bt(n,"jabraSdk",void 0),bt(n,"callControlFactory",void 0),bt(n,"callControl",void 0),bt(n,"ongoingCalls",0),bt(n,"callLock",!1),bt(n,"pendingConversationId",void 0),bt(n,"pendingConversationIsOutbound",void 0),bt(n,"activeConversationId",void 0),n.vendorName="Jabra",n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&mt(e,t)}(t,e),n=t,r=[{key:"isSupported",value:function(){return window.navigator.hid&&!z()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return!!["jabra"].some((function(e){return t.includes(e)}))}},{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"deviceName",get:function(){var e;return null===(e=this.deviceInfo)||void 0===e?void 0:e.deviceName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"resetState",value:function(){this.setHold(null,!1),this.setMute(!1)}},{key:"_processEvents",value:function(e){var t=this;this.headsetEventSubscription=e.deviceSignals.subscribe(function(){var n=pt(ht().mark((function n(r){var i,o,a,s;return ht().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(t.callLock){n.next=3;break}return t.logger.debug("Currently not in possession of the Call Lock; Cannot react to Device Actions"),n.abrupt("return");case 3:n.t0=r.type,n.next=n.t0===Me.u.HOOK_SWITCH?6:n.t0===Me.u.FLASH||n.t0===Me.u.ALT_HOLD?11:n.t0===Me.u.PHONE_MUTE?15:n.t0===Me.u.REJECT_CALL?19:23;break;case 6:if(!t.activeConversationId||!t.pendingConversationId){n.next=9;break}return t.logger.info("ignoring hookswitch event because there is an active and incoming call"),n.abrupt("break",23);case 9:if(r.value)e.offHook(!0),e.ring(!1),t.activeConversationId=t.pendingConversationId,t.pendingConversationId=null,t.pendingConversationIsOutbound||t.deviceAnsweredCall({name:"CallOffHook",code:r.type,conversationId:t.activeConversationId});else{e.mute(!1),e.hold(!1),e.offHook(!1),t.deviceEndedCall({name:"CallOnHook",code:r.type,conversationId:t.activeConversationId});try{e.releaseCallLock()}catch(e){i=e.message,o=e.type,t.checkForCallLockError(i,o)?t.logger.info(i):t.logger.error(o,i)}finally{t.activeConversationId=null,t.callLock=!1}}return n.abrupt("break",23);case 11:return t.isHeld=!t.isHeld,e.hold(t.isHeld),t.deviceHoldStatusChanged({holdRequested:t.isHeld,name:t.isHeld?"OnHold":"ResumeCall",code:r.type,conversationId:t.activeConversationId}),n.abrupt("break",23);case 15:return t.isMuted=!t.isMuted,e.mute(t.isMuted),t.deviceMuteChanged({isMuted:t.isMuted,name:t.isMuted?"CallMuted":"CallUnmuted",code:r.type,conversationId:t.activeConversationId}),n.abrupt("break",23);case 19:e.ring(!1),t.deviceRejectedCall({name:Me.u[r.type],conversationId:t.pendingConversationId}),t.pendingConversationId=null;try{t.activeConversationId||(e.releaseCallLock(),t.callLock=!1)}catch(e){a=e.message,s=e.type,t.checkForCallLockError(a,s)?t.logger.info(a):t.logger.error(s,a)}case 23:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}())}},{key:"setMute",value:(b=pt(ht().mark((function e(t){return ht().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 b.apply(this,arguments)})},{key:"setHold",value:(m=pt(ht().mark((function e(t,n){return ht().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 m.apply(this,arguments)})},{key:"incomingCall",value:(g=pt(ht().mark((function e(t){var n,r;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!1,e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:this.callLock=e.sent,e.next=13;break;case 8:e.prev=8,e.t0=e.catch(2),n=e.t0.message,r=e.t0.type,this.checkForCallLockError(n,r)?(this.logger.info(n),this.callLock=!0):this.logger.error(r,n);case 13:this.callLock&&this.callControl.ring(!0);case 14:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(e){return g.apply(this,arguments)})},{key:"answerCall",value:(y=pt(ht().mark((function e(t,n){var r,i;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=13;break}return this.pendingConversationId=t,e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:this.callLock=e.sent,e.next=13;break;case 8:e.prev=8,e.t0=e.catch(2),r=e.t0.message,i=e.t0.type,this.checkForCallLockError(r,i)?(this.logger.info(r),this.callLock=!0):this.logger.error(i,r);case 13:if(this.callLock){e.next=15;break}return e.abrupt("return");case 15:this.callControl.ring(!1),this.callControl.offHook(!0);case 17:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(e,t){return y.apply(this,arguments)})},{key:"rejectCall",value:(v=pt(ht().mark((function e(){var t,n;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 2:if(this.callControl.ring(!1),this.pendingConversationId=null,!this.activeConversationId)try{this.resetState(),this.callControl.releaseCallLock()}catch(e){t=e.message,n=e.type,this.checkForCallLockError(t,n)?this.logger.info(t):this.logger.error(n,t)}finally{this.pendingConversationId=null,this.callLock=!1}case 5:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"outgoingCall",value:(p=pt(ht().mark((function e(t){var n,r;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.callControl.takeCallLock();case 3:this.callLock=e.sent,e.next=11;break;case 6:e.prev=6,e.t0=e.catch(0),n=e.t0.message,r=e.t0.type,this.checkForCallLockError(n,r)?(this.logger.info(n),this.callLock=!0):this.logger.error(r,n);case 11:this.callLock&&(this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!0,this.callControl.offHook(!0));case 12:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(e){return p.apply(this,arguments)})},{key:"endCall",value:(d=pt(ht().mark((function e(t,n){var r,i;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:if(t===this.activeConversationId&&(this.activeConversationId=null),e.prev=3,this.callLock){e.next=6;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 6:this.callControl.offHook(!1),this.resetState(),this.callControl.releaseCallLock(),e.next=16;break;case 11:e.prev=11,e.t0=e.catch(3),r=e.t0.message,i=e.t0.type,this.checkForCallLockError(r,i)?this.logger.info(r):this.logger.error(i,r);case 16:return e.prev=16,this.callLock=!1,e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,11,16,19]])}))),function(e,t){return d.apply(this,arguments)})},{key:"endAllCalls",value:(h=pt(ht().mark((function e(){var t,n;return ht().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.activeConversationId=null,this.callControl.offHook(!1),this.resetState(),this.callControl.releaseCallLock(),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.logger.error(n,t);case 14:return e.prev=14,this.callLock=!1,e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[0,9,14,17]])}))),function(){return h.apply(this,arguments)})},{key:"isDeviceInList",value:function(e,t){var n;return t.toLowerCase().includes(null==e||null===(n=e.name)||void 0===n?void 0:n.toLowerCase())}},{key:"connect",value:(f=pt(ht().mark((function e(t){var n,r;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isConnecting){e.next=2;break}return e.abrupt("return");case 2:if(this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),this.jabraSdk){e.next=8;break}return e.next=6,this.initializeJabraSdk();case 6:this.jabraSdk=e.sent,this.callControlFactory=this.createCallControlFactory(this.jabraSdk);case 8:return n=t.toLocaleLowerCase(),this._deviceInfo=null,e.next=12,this.deviceHasPermissions(n);case 12:if(!e.sent){e.next=22;break}return e.next=15,this.getPreviouslyConnectedDevice(n);case 15:if(r=e.sent){e.next=20;break}return console.warn('Unable to find appropriate device. Setting state to "Not Running" to allow a retry"',n),this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),e.abrupt("return");case 20:e.next=32;break;case 22:return e.prev=22,e.next=25,this.getDeviceFromWebhid(n);case 25:r=e.sent,e.next=32;break;case 28:return e.prev=28,e.t0=e.catch(22),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),e.abrupt("return");case 32:return e.next=34,this.callControlFactory.createCallControl(r);case 34:return this.callControl=e.sent,e.next=37,this.resetHeadsetState();case 37:this._processEvents(this.callControl),this._deviceInfo={ProductName:r.name,deviceName:r.name,attached:!0,deviceId:r.id.toString()},this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 40:case"end":return e.stop()}}),e,this,[[22,28]])}))),function(e){return f.apply(this,arguments)})},{key:"deviceHasPermissions",value:(l=pt(ht().mark((function e(t){var n,r;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.getDevices();case 2:return n=e.sent,r=!1,n.forEach((function(e){var n;t.includes(null==e||null===(n=e.productName)||void 0===n?void 0:n.toLowerCase())&&(r=!0)})),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return l.apply(this,arguments)})},{key:"getPreviouslyConnectedDevice",value:(u=pt(ht().mark((function e(t){var n,r=this;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.jabraSdk.deviceList.pipe(rt(null),ut((function(e){return!!e.length})),lt((function(e){return e.find((function(e){return r.isDeviceInList(e,t)}))})),it((function(e){return!!e})),tt(15e3)),e.abrupt("return",Be(n).catch((function(e){return e instanceof et||e instanceof Fe?null:Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getDeviceFromWebhid",value:(c=pt(ht().mark((function e(t){var n=this;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.requestWebHidPermissions(Me.D),e.abrupt("return",Be(this.jabraSdk.deviceList.pipe(lt((function(e){return e.find((function(e){return n.isDeviceInList(e,t)}))})),it((function(e){return!!e})),ut(),tt(3e4))).catch((function(e){return e instanceof et&&(e=new Error("The selected device was not granted WebHID permissions")),n.logger.error(e),Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"initializeJabraSdk",value:(s=pt(ht().mark((function e(){return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Object(Me.C)({appId:"softphone-vendor-headsets",appName:"Softphone Headset Library",transport:Me.z.CHROME_EXTENSION_WITH_WEB_HID_FALLBACK}));case 1:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"createCallControlFactory",value:function(e){return new Me.a(e)}},{key:"checkForCallLockError",value:function(e,t){return t===Me.b.SDK_USAGE_ERROR&&e.includes("call lock")}},{key:"resetHeadsetState",value:(a=pt(ht().mark((function e(){return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callControl){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:this.callControl.hold(!1),this.callControl.mute(!1),this.callControl.offHook(!1),this.callControl.releaseCallLock(),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(2),this.logger.warn("Failed to takeCallLock in order to resetHeadsetState. Ignoring reset.");case 14:case"end":return e.stop()}}),e,this,[[2,11]])}))),function(){return a.apply(this,arguments)})},{key:"disconnect",value:(o=pt(ht().mark((function e(){var t,n;return ht().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.releaseCallLock(),e.next=11;break;case 6:e.prev=6,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 11:return e.prev=11,this.resetHeadsetState(),this.callLock=!1,this.activeConversationId&&(this.activeConversationId=null),this.headsetEventSubscription&&this.headsetEventSubscription.unsubscribe(),(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),e.finish(11);case 18:case"end":return e.stop()}}),e,this,[[0,6,11,18]])}))),function(){return o.apply(this,arguments)})}],i=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],r&&vt(n.prototype,r),i&&vt(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d,p,v,y,g,m,b}(W.a);bt(Et,"instance",void 0),bt(Et,"connectTimeout",5e3);var Ct=function(e){return e.Ring="ringer",e.Offhook="offhook",e.Mute="mute",e.Hold="hold",e}({}),_t=function(e){return e.OffHook="OffHook",e.Mute="Mute",e.Hold="Flash",e.RejectCall="RejectCall",e}({});function It(e){return(It="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 kt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */kt=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==It(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(It(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function Ot(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function St(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Ot(o,r,i,a,s,"next",e)}function s(e){Ot(o,r,i,a,s,"throw",e)}a(void 0)}))}}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,Nt(r.key),r)}}function xt(e,t,n){return t=At(t),function(e,t){if(t&&("object"===It(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],At(e).constructor):t.apply(e,n))}function At(e){return(At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Lt(e,t){return(Lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function Pt(e,t,n){return(t=Nt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Nt(e){var t=function(e,t){if("object"!=It(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=It(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==It(t)?t:t+""}var Rt=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),Pt(n=xt(this,t,[e]),"isActive",!1),Pt(n,"devices",null),Pt(n,"activeDeviceId",null),Pt(n,"headsetState",null),Pt(n,"ignoreNextOffhookEvent",!1),Pt(n,"cefSupportsJabra",!0),Pt(n,"pendingConversationId",void 0),Pt(n,"activeConversationId",void 0),Pt(n,"pendingConversationIsOutbound",void 0),n.vendorName="Jabra",n.headsetState={ringing:!1,offHook:!1},n.devices=new Map,z()&&(n.isHostedContextInitialized()?n.setupNativeHandlers():n.waitForHostedContext()),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Lt(e,t)}(t,e),n=t,r=[{key:"isHostedContextInitialized",value:function(){var e;return null===(e=window.Orgspan)||void 0===e?void 0:e.serviceFor("application").get("hostedContext").isHosted()}},{key:"waitForHostedContext",value:function(){var e=this;setTimeout((function(){e.isHostedContextInitialized()?e.setupNativeHandlers():e.waitForHostedContext()}),500)}},{key:"setupNativeHandlers",value:function(){var e,t=null===(e=window.Orgspan)||void 0===e?void 0:e.serviceFor("application").get("hostedContext");this.cefSupportsJabra=t.supportsJabra(),t.on("JabraEvent",this.handleJabraEvent.bind(this)),t.on("JabraDeviceAttached",this.handleJabraDeviceAttached.bind(this))}},{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.eventName,e.value)}},{key:"_handleOffhookEvent",value:function(e){if(e)return this.activeConversationId=this.pendingConversationId,this.pendingConversationId=null,void(this.headsetState.ringing&&(this.pendingConversationIsOutbound||this.deviceAnsweredCall({name:"CallOffHook",conversationId:this.activeConversationId}),this._sendCmd(Ct.Offhook,e),this._setRinging(!1)));this.activeConversationId&&(this._sendCmd(Ct.Offhook,e),this.deviceEndedCall({name:"CallOnHook",conversationId:this.activeConversationId})),this._getHeadsetIntoVanillaState(),this.activeConversationId=null}},{key:"_handleMuteEvent",value:function(e){this._sendCmd(Ct.Mute,e),this.isMuted=e,this.deviceMuteChanged({isMuted:e,name:e?"CallMuted":"CallUnmuted",conversationId:this.activeConversationId})}},{key:"_handleHoldEvent",value:function(e){this._sendCmd(Ct.Hold,!!e),this.deviceHoldStatusChanged({holdRequested:!!e,name:e?"OnHold":"ResumeCall",conversationId:this.activeConversationId})}},{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(Ct.Ring,e),this.headsetState.ringing=e}},{key:"isSupported",value:function(){return z()&&this.cefSupportsJabra}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["jabra"].some((function(e){return t.includes(e)}))}},{key:"setMute",value:(d=St(kt().mark((function e(t){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._sendCmd(Ct.Mute,t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"setHold",value:(h=St(kt().mark((function e(t,n){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._sendCmd(Ct.Hold,n);case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"incomingCall",value:(f=St(kt().mark((function e(t){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!1,this._setRinging(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"answerCall",value:(l=St(kt().mark((function e(t,n){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n&&(this.pendingConversationId=t),this.ignoreNextOffhookEvent=!0,this._sendCmd(Ct.Offhook,!0);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"rejectCall",value:(u=St(kt().mark((function e(){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._setRinging(!1),this.pendingConversationId=null;case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"outgoingCall",value:(c=St(kt().mark((function e(t){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!0,this._sendCmd(Ct.Offhook,!0);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"endCall",value:(s=St(kt().mark((function e(t,n){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._setRinging(!1),n||this._sendCmd(Ct.Offhook,!1),this.activeConversationId=null;case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"endAllCalls",value:(a=St(kt().mark((function e(){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._setRinging(!1),this._sendCmd(Ct.Offhook,!1),this.activeConversationId=null;case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateDevices",value:(o=St(kt().mark((function e(){var t,n=this;return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,$({cmd:"requestJabraDevices"});case 3:if(t=e.sent,this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),t&&t.length){e.next=10;break}return this.devices.clear(),this.activeDeviceId=null,this.logger.error(new Error("No attached jabra devices")),e.abrupt("return");case 10: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=22;break;case 18:e.prev=18,e.t0=e.catch(0),this.logger.error("Failed to connect to jabra",e.t0),this.disconnect();case 22:case"end":return e.stop()}}),e,this,[[0,18]])}))),function(){return o.apply(this,arguments)})},{key:"_processEvent",value:function(e,t){var n,r,i,o=this;switch(e){case _t.OffHook:(n=function(){return o._handleOffhookEvent(t)},r=500,i=null,function(){clearTimeout(i),i=setTimeout((function(){n()}),r)})();break;case _t.RejectCall:this.deviceRejectedCall({name:_t.RejectCall,conversationId:this.pendingConversationId});break;case _t.Mute:this._handleMuteEvent(t);break;case _t.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()}}],i=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],r&&Tt(n.prototype,r),i&&Tt(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d}(W.a);function Dt(e){return(Dt="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 jt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */jt=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Dt(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Dt(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function Ht(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ut(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ut(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Ut(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Mt(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Ft(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Mt(o,r,i,a,s,"next",e)}function s(e){Mt(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Bt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Gt(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,Kt(r.key),r)}}function Yt(e,t,n){return t=Vt(t),function(e,t){if(t&&("object"===Dt(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],Vt(e).constructor):t.apply(e,n))}function Vt(e){return(Vt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Wt(e,t){return(Wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function qt(e,t,n){return(t=Kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kt(e){var t=function(e,t){if("object"!=Dt(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Dt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Dt(t)?t:t+""}Pt(Rt,"instance",void 0);var zt=function(e){function t(){var e;Bt(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return qt(e=Yt(this,t,[].concat(r)),"pendingConversationId",void 0),qt(e,"activeConversationId",void 0),qt(e,"_deviceInfo",null),qt(e,"activeDevice",void 0),qt(e,"callState",0),qt(e,"recCallState",0),qt(e,"isHold",!1),qt(e,"inputReportReportId",null),qt(e,"vendorName","Yealink"),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Wt(e,t)}(t,e),n=t,r=[{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isSupported",value:function(){return window.navigator.hid&&!z()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["yealink","(6993:"].some((function(e){return t.includes(e)}))}},{key:"connect",value:(v=Ft(jt().mark((function e(t){var n,r=this;return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),n=t.toLowerCase(),e.next=4,window.navigator.hid.getDevices();case 4:if(e.sent.forEach((function(e){var t;if(!r.activeDevice&&n.includes(null==e||null===(t=e.productName)||void 0===t?void 0:t.toLowerCase())){var i,o=Ht(e.collections);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(5===a.usage&&11===a.usagePage){r.activeDevice=e,0!==a.inputReports.length&&(r.inputReportReportId=4);break}}}catch(e){o.e(e)}finally{o.f()}}})),this.activeDevice){e.next=18;break}return e.prev=7,e.next=10,new Promise((function(e,i){var o=setTimeout(i,3e4);r.requestWebHidPermissions(Ft(jt().mark((function a(){var s,c,u,l;return jt().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return s=r.deductProductId(t),c=[{usage:5,usagePage:11,vendorId:27027,productId:s||void 0}],a.next=4,window.navigator.hid.requestDevice({filters:c});case 4:return clearTimeout(o),a.next=7,window.navigator.hid.getDevices();case 7:u=a.sent,l=!1,u.forEach((function(t){var i;if(n.includes(null==t||null===(i=t.productName)||void 0===i?void 0:i.toLowerCase())){var o,a=Ht(t.collections);try{for(a.s();!(o=a.n()).done;){var s=o.value;if(5===s.usage&&11===s.usagePage){l=!0,0!==s.inputReports.length&&(r.inputReportReportId=4),e(t);break}}}catch(e){a.e(e)}finally{a.f()}}})),l||i();case 11:case"end":return a.stop()}}),a)}))))}));case 10:this.activeDevice=e.sent,e.next=18;break;case 13:return e.prev=13,e.t0=e.catch(7),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),this.logger.error("The selected device was not granted WebHID permissions"),e.abrupt("return");case 18:if(this.activeDevice.opened){e.next=21;break}return e.next=21,this.activeDevice.open();case 21:this.logger.debug("get device reportId ".concat(this.inputReportReportId)),this.activeDevice.addEventListener("inputreport",(function(e){if(e.reportId===r.inputReportReportId){var t=e.data.getUint8(0);r.processBtnPress(t)}})),this._deviceInfo={ProductName:this.activeDevice.productName},this.isConnecting&&!this.isConnected&&this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 25:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e){return v.apply(this,arguments)})},{key:"disconnect",value:(p=Ft(jt().mark((function e(){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),this.activeDevice&&(this.activeDevice.close(),this.activeDevice=null,this._deviceInfo=null,this.inputReportReportId=0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"processBtnPress",value:function(e){if(this.activeDevice){this.logger.debug("User pressed button ".concat(e,". local ").concat(this.recCallState));var t=e^this.recCallState;0!==t&&(0===e||0!=(-3&this.callState)?(this.recCallState=e,1&t?1&e?(this.answerCall(),this.activeConversationId?this.deviceAnsweredCall({name:"OffHook",conversationId:this.activeConversationId}):this.logger.debug("activeConversationId is empty")):this.isHold||(this.sendOpToDevice(this.isMuted?2:0),this.activeConversationId?this.deviceEndedCall({name:"OnHook",conversationId:this.activeConversationId}):this.logger.debug("activeConversationId is empty"),this.activeConversationId=null):4&t?4&e&&(this.setMute(!this.isMuted),this.deviceMuteChanged({isMuted:this.isMuted,name:this.isMuted?"CallMuted":"CallUnmuted",conversationId:this.activeConversationId})):8&t?8&e&&(this.setHold(null,!this.isHold),this.deviceHoldStatusChanged({holdRequested:this.isHold,name:this.isHold?"OnHold":"ResumeCall",conversationId:this.activeConversationId})):64&t&&64&e&&(this.deviceRejectedCall({name:"Reject",conversationId:this.pendingConversationId}),this.rejectCall())):this.logger.debug("Not talking, ignore key"))}else this.logger.error("do not have active device")}},{key:"incomingCall",value:(d=Ft(jt().mark((function e(t){var n;return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t&&(this.pendingConversationId=t.conversationId,n=this.isMuted?2:0,this.sendOpToDevice(4|n));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"outgoingCall",value:(h=Ft(jt().mark((function e(t){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.sendOpToDevice(1);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"answerCall",value:(f=Ft(jt().mark((function e(){var t;return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId&&(this.activeConversationId=this.pendingConversationId,this.pendingConversationId=null),t=this.isMuted?2:0,this.sendOpToDevice(1|t);case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"rejectCall",value:(l=Ft(jt().mark((function e(){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=null,this.sendOpToDevice(this.isMuted?2:0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"endCall",value:(u=Ft(jt().mark((function e(t,n){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:t===this.activeConversationId&&(this.activeConversationId=null),this.sendOpToDevice(this.isMuted?2:0);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"endAllCalls",value:(c=Ft(jt().mark((function e(){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.activeConversationId=null,this.sendOpToDevice(this.isMuted?2:0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"setMute",value:(s=Ft(jt().mark((function e(t){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t?this.sendOpToDevice(2|this.callState):this.sendOpToDevice(-3&this.callState);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"setHold",value:(a=Ft(jt().mark((function e(t,n){var r,i;return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n?(r=-2&this.callState,this.sendOpToDevice(8|r)):(i=-9&this.callState,this.sendOpToDevice(1|i));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"sendOpToDevice",value:(o=Ft(jt().mark((function e(t){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.activeDevice&&0!==this.inputReportReportId){e.next=3;break}return this.logger.error("do not have active device"),e.abrupt("return");case 3:return this.isHold=!!(8&t),this.isMuted=!!(2&t),this.logger.debug("send to dev ".concat(t)),this.callState=t,e.next=9,this.activeDevice.sendReport(this.inputReportReportId,new Uint8Array([t]));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})}],i=[{key:"getInstance",value:function(e){return t.instance||(t.instance=new t(e)),t.instance}}],r&&Gt(n.prototype,r),i&&Gt(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d,p,v}(W.a);function $t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||en(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Jt=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==cn(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(cn(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function Xt(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Qt(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Xt(o,r,i,a,s,"next",e)}function s(e){Xt(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Zt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=en(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function en(e,t){if(e){if("string"==typeof e)return tn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tn(e,t):void 0}}function tn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function nn(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 rn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nn(Object(n),!0).forEach((function(t){on(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function on(e,t,n){return(t=sn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function an(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,sn(r.key),r)}}function sn(e){var t=function(e,t){if("object"!=cn(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=cn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==cn(t)?t:t+""}function cn(e){return(cn="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)}qt(zt,"instance",void 0);var un,ln=Object.defineProperty,fn=function(e,t,n){return function(e,t,n){return t in e?ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n}(e,"symbol"!=cn(t)?t+"":t,n)},hn=((un=hn||{})[un.LED=8]="LED",un[un.TELEPHONY=11]="TELEPHONY",un),dn=function(e){return e[e.PROGRAMMABLE_BUTTON=7]="PROGRAMMABLE_BUTTON",e[e.HOOK_SWITCH=32]="HOOK_SWITCH",e[e.FLASH=33]="FLASH",e[e.PHONE_MUTE=47]="PHONE_MUTE",e}(dn||{}),pn=function(e){return e[e.MUTE=9]="MUTE",e[e.OFF_HOOK=23]="OFF_HOOK",e[e.RING=24]="RING",e[e.HOLD=32]="HOLD",e}(pn||{}),vn=function(e){return e[e.ToggleButton=0]="ToggleButton",e[e.ToggleSwitch=1]="ToggleSwitch",e}(vn||{});function yn(e){return 65535&e}function gn(e){return e>>>16}function mn(e){return e.isAbsolute?1:0}var bn={usage:5,usagePage:11},wn=[32,47,7],En=function(e){return wn.includes(e)},Cn=[23,24,9],_n=function(e){return Cn.includes(e)},In=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),this.device=t,fn(this,"inputEventInfos"),fn(this,"inputEventObserverCallbacks"),fn(this,"outputEventInfos"),this.inputEventInfos=wn.reduce((function(e,t){return rn(rn({},e),{},on({},t,void 0))}),{}),this.inputEventObserverCallbacks=wn.reduce((function(e,t){return rn(rn({},e),{},on({},t,[]))}),{}),this.outputEventInfos=Cn.reduce((function(e,t){return rn(rn({},e),{},on({},t,void 0))}),{}),this.parseDeviceDescriptors(),this.device.addEventListener("inputreport",(function(e){return n.onInputReport(e)}))}return t=e,n=[{key:"onInputReport",value:function(e){var t,n,r,i,o,a,s,c,u=this.device.productId;if(u>=64&&u<=130&&5===e.reportId)switch(e.data.getUint8(0)){case 32:null===(t=(n=this.inputEventObserverCallbacks[32])[0])||void 0===t||t.call(n,!0,1);break;case 8:this.inputEventObserverCallbacks[7][0](!0,1);break;case 0:null===(r=(i=this.inputEventObserverCallbacks[32])[0])||void 0===r||r.call(i,!1,1);break;case 1:null===(o=(a=this.inputEventObserverCallbacks[47])[0])||void 0===o||o.call(a,!1,1);break;case 5:null===(s=(c=this.inputEventObserverCallbacks[47])[0])||void 0===s||s.call(c,!0,1)}else for(var l=0,f=wn;l<f.length;l++){var h=f[l],d=this.inputEventInfos[h];if(void 0!==d&&e.reportId===d.reportId){var p,v=Math.trunc(d.offset/8),y=d.offset%8,g=0!=(e.data.getUint8(v)&1<<y),m=Zt(this.inputEventObserverCallbacks[h]);try{for(m.s();!(p=m.n()).done;)(0,p.value)(g,d.controlType)}catch(e){m.e(e)}finally{m.f()}}}}},{key:"close",value:(a=Qt(Jt().mark((function e(){return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.device.opened,!e.t0){e.next=4;break}return e.next=4,this.device.close();case 4:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"parseDeviceDescriptors",value:function(){if(void 0===this.device.collections)throw new Error("Undefined device collection");var e=this.device.collections.find((function(e){return 11===e.usagePage}));if(void 0===e)throw new Error("No telephony collection");e.inputReports&&this.parseInputReport(e.inputReports),e.outputReports&&this.parseOutputReport(e.outputReports)}},{key:"parseInputReport",value:function(e){var t,n=Zt(e);try{for(n.s();!(t=n.n()).done;){var r=t.value,i=0;if(void 0!==r.items&&void 0!==r.reportId){var o,a=Zt(r.items);try{for(a.s();!(o=a.n()).done;){var s=o.value;if(void 0!==s.usages&&void 0!==s.reportSize&&void 0!==s.reportCount&&void 0!==s.isAbsolute){var c,u=Zt(s.usages.entries());try{for(u.s();!(c=u.n()).done;){var l=$t(c.value,2),f=l[0],h=l[1];if(11===gn(h)||589831===h){var d=yn(h);En(d)&&(this.inputEventInfos[d]={reportId:r.reportId,offset:i+f*s.reportSize,controlType:mn(s)})}}}catch(e){u.e(e)}finally{u.f()}i+=s.reportCount*s.reportSize}}}catch(e){a.e(e)}finally{a.f()}}}}catch(e){n.e(e)}finally{n.f()}}},{key:"parseOutputReport",value:function(e){var t,n=this,r=Zt(e);try{var i=function(){var e=t.value;if(void 0===e.items||void 0===e.reportId)return 1;var r,i=0,o=[],a=Zt(e.items);try{for(a.s();!(r=a.n()).done;){var s=r.value;if(void 0===s.usages||void 0===s.reportSize||void 0===s.reportCount){o=[];break}var c,u=Zt(s.usages.entries());try{for(u.s();!(c=u.n()).done;){var l=$t(c.value,2),f=l[0],h=l[1];if(8===gn(h)){var d=yn(h);_n(d)&&o.push([d,i+f*s.reportSize])}}}catch(e){u.e(e)}finally{u.f()}i+=s.reportCount*s.reportSize}}catch(e){a.e(e)}finally{a.f()}for(var p=i,v=function(){var t=$t(g[y],2),r=t[0],i=t[1];n.outputEventInfos[r]={reportId:e.reportId,state:!1,offset:i,generator:function(){var t=new Uint8Array(p/8);return{reportId:e.reportId,data:t}},setter:function(e,t){if(i>=0){var n=Math.trunc(i/8),r=i%8;t[n]|=(e?1:0)<<r}return t}}},y=0,g=o;y<g.length;y++)v()};for(r.s();!(t=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}}},{key:"getControlType",value:function(e){var t;if(this.supportInput(e))return null===(t=this.inputEventInfos[e])||void 0===t?void 0:t.controlType}},{key:"supportInput",value:function(e){return void 0!==this.inputEventInfos[e]}},{key:"supportOutput",value:function(e){return void 0!==this.outputEventInfos[e]}},{key:"subscribe",value:function(e,t){this.inputEventObserverCallbacks[e].push(t)}},{key:"unsubscribe",value:function(e){this.inputEventObserverCallbacks[e]=[]}},{key:"setState",value:function(e,t){if(this.device.opened){var n=this.outputEventInfos[e];void 0!==n&&(n.state=t)}}},{key:"getState",value:function(e){var t;if(this.device.opened)return null===(t=this.outputEventInfos[e])||void 0===t?void 0:t.state}},{key:"send",value:(o=Qt(Jt().mark((function e(t){var n,r,i,o,a,s,c,u,l,f,h,d,p,v,y,g=this;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.device.opened){e.next=2;break}return e.abrupt("return");case 2:if(!((n=this.device.productId)>=64&&n<=130)){e.next=22;break}if(r=t.get(24),i=t.get(23),o=t.get(9),e.t0=void 0!==r,!e.t0){e.next=10;break}return this.setState(24,r),e.next=10,this.device.sendReport(6,new Uint8Array([r?1:0,0]));case 10:if(e.t1=void 0!==i,!e.t1){e.next=15;break}return this.setState(23,i),e.next=15,this.device.sendReport(6,new Uint8Array([i?2:0,0]));case 15:if(e.t2=void 0!==o,!e.t2){e.next=20;break}return this.setState(9,o),e.next=20,this.device.sendReport(6,new Uint8Array([o?4:5,0]));case 20:e.next=48;break;case 22:a=[],s=Zt(t),e.prev=24,u=Jt().mark((function e(){var t,n,r,i;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=$t(c.value,2),n=t[0],r=t[1],void 0!==(i=g.outputEventInfos[n])&&(void 0===a.find((function(e){return e.reportId===(null==i?void 0:i.reportId)}))&&a.push(null==i?void 0:i.generator()),i.state=r);case 3:case"end":return e.stop()}}),e)})),s.s();case 27:if((c=s.n()).done){e.next=31;break}return e.delegateYield(u(),"t3",29);case 29:e.next=27;break;case 31:e.next=36;break;case 33:e.prev=33,e.t4=e.catch(24),s.e(e.t4);case 36:return e.prev=36,s.f(),e.finish(36);case 39:l=0,f=a;case 40:if(!(l<f.length)){e.next=48;break}for(h=f[l],d=0,p=Cn;d<p.length;d++)v=p[d],void 0===(y=this.outputEventInfos[v])||y.reportId!==h.reportId||!y.state||(h.data=y.setter(y.state,h.data));return e.next=45,this.device.sendReport(h.reportId,h.data);case 45:l++,e.next=40;break;case 48:case"end":return e.stop()}}),e,this,[[24,33,36,39]])}))),function(e){return o.apply(this,arguments)})}],r=[{key:"create",value:(i=Qt(Jt().mark((function t(n){return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=n.opened,t.t0){t.next=4;break}return t.next=4,n.open();case 4:return t.abrupt("return",new e(n));case 5:case"end":return t.stop()}}),t)}))),function(e){return i.apply(this,arguments)})}],n&&an(t.prototype,n),r&&an(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r,i,o,a}(),kn=function(e){if(!e.supportInput(32))throw new Error("Device is missing hook switch support");if(!e.supportInput(47))throw new Error("Device is missing mute switch support")},On=function(e){if(!e.supportOutput(24))throw new Error("Device is missing ring support");if(!e.supportOutput(23))throw new Error("Device is missing off/on hook support");if(!e.supportOutput(9))throw new Error("Device is missing mute support")},Sn=function(e){return e[e.ACCEPT_CALL=0]="ACCEPT_CALL",e[e.END_CALL=1]="END_CALL",e[e.REJECT_CALL=2]="REJECT_CALL",e[e.MUTE_CALL=3]="MUTE_CALL",e[e.UNMUTE_CALL=4]="UNMUTE_CALL",e}(Sn||{});function Tn(e){return xn.apply(this,arguments)}function xn(){return(xn=Qt(Jt().mark((function e(t){var n;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,In.create(t);case 2:return n=e.sent,e.abrupt("return",(On(n),kn(n),{productName:n.device.productName,ring:function(){return n.send(new Map([[24,!0]]))},onHook:function(){return n.send(new Map([[23,!1],[24,!1],[9,!1]]))},offHook:function(){return n.send(new Map([[23,!0],[24,!1],[9,!1]]))},muteOn:function(){return n.send(new Map([[23,!0],[24,!1],[9,!0]]))},muteOff:function(){return n.send(new Map([[23,!0],[24,!1],[9,!1]]))},subscribe:function(e){n.subscribe(32,(function(t,r){if(0===r&&t){if(n.getState(24))return void e(0);if(n.getState(23))return void e(1)}if(1===r){if(t&&n.getState(24))return void e(0);if(!t&&n.getState(23))return void e(1)}})),n.subscribe(47,(function(t,r){if(0===r&&t)e(n.getState(9)?4:3);else if(1===r){if(t&&!n.getState(9))return void e(3);if(!t&&n.getState(9))return void e(4)}})),n.subscribe(7,(function(t,n){t&&e(2)}))},unsubscribe:function(){n.unsubscribe(32),n.unsubscribe(47),n.unsubscribe(7)}}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function An(e){return Ln.apply(this,arguments)}function Ln(){return(Ln=Qt(Jt().mark((function e(t){var n,r,i,o;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.getDevices();case 2:n=e.sent,r=Zt(n),e.prev=4,r.s();case 6:if((i=r.n()).done){e.next=14;break}if(o=i.value,!t.toLowerCase().includes(o.productName.toLowerCase())){e.next=12;break}return e.next=11,Tn(o);case 11:return e.abrupt("return",e.sent);case 12:e.next=6;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(4),r.e(e.t0);case 19:return e.prev=19,r.f(),e.finish(19);case 22:case"end":return e.stop()}}),e,null,[[4,16,19,22]])})))).apply(this,arguments)}function Pn(e){return Nn.apply(this,arguments)}function Nn(){return(Nn=Qt(Jt().mark((function e(t){var n;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.requestDevice({filters:[rn({vendorId:13323,productId:t.productId},bn)]});case 2:if(n=e.sent.find((function(e){return e.collections.find((function(e){return e.usage===bn.usage&&e.usagePage===bn.usagePage}))}))){e.next=5;break}throw new Error("No requested device found");case 5:return e.next=7,Tn(n);case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Rn(e){return(Rn="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 Dn(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Dn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Rn(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Rn(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function jn(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Hn(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){jn(o,r,i,a,s,"next",e)}function s(e){jn(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Un(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Mn(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,Vn(r.key),r)}}function Fn(e,t,n){return t=Bn(t),function(e,t){if(t&&("object"===Rn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],Bn(e).constructor):t.apply(e,n))}function Bn(e){return(Bn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Gn(e,t){return(Gn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function Yn(e,t,n){return(t=Vn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vn(e){var t=function(e,t){if("object"!=Rn(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Rn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Rn(t)?t:t+""}var Wn=function(e){function t(){var e;Un(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return Yn(e=Fn(this,t,[].concat(r)),"activeConversationId",void 0),Yn(e,"pendingConversationId",void 0),Yn(e,"_deviceInfo",null),Yn(e,"activeDevice",null),Yn(e,"vendorName","VBet"),Yn(e,"processBtnPress",(function(t){switch(t){case Sn.ACCEPT_CALL:e.pendingConversationId?(e.answerCall(e.pendingConversationId),e.deviceAnsweredCall({name:"OffHook",conversationId:e.activeConversationId})):e.logger.error("No call to be answered");break;case Sn.END_CALL:if(e.activeConversationId){var n=e.activeConversationId;e.endCall(n),e.deviceEndedCall({name:"OnHook",conversationId:n})}else e.logger.error("No call to be terminated");break;case Sn.MUTE_CALL:case Sn.UNMUTE_CALL:e.activeConversationId?(e.setMute(t===Sn.MUTE_CALL),e.deviceMuteChanged({isMuted:e.isMuted,name:e.isMuted?"CallMuted":"CallUnmuted",conversationId:e.activeConversationId})):e.logger.error("No call to be muted");break;case Sn.REJECT_CALL:e.pendingConversationId?(e.rejectCall(e.pendingConversationId),e.deviceRejectedCall({name:"Reject",conversationId:e.pendingConversationId})):e.logger.error("No call to be rejected")}})),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Gn(e,t)}(t,e),n=t,r=[{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isSupported",value:function(){return window.navigator.hid&&!z()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["vt","340b"].some((function(e){return t.includes(e)}))}},{key:"connect",value:(d=Hn(Dn().mark((function e(t){var n,r,i=this;return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),e.prev=1,e.next=4,An(t);case 4:if(!(n=e.sent)){e.next=9;break}this.activeDevice=n,e.next=13;break;case 9:return e.next=11,new Promise((function(e,n){var r=i.deductProductId(t),o=setTimeout((function(){return n("The selected device was not granted WebHID permissions")}),3e4);i.requestWebHidPermissions((function(){Pn({productId:r||void 0}).then((function(t){e(t),clearTimeout(o)})).catch((function(e){n(e)}))}))}));case 11:r=e.sent,this.activeDevice=r;case 13:e.next=20;break;case 15:return e.prev=15,e.t0=e.catch(1),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),this.logger.error(e.t0),e.abrupt("return");case 20:this._deviceInfo={ProductName:this.activeDevice.productName},this.activeDevice.subscribe(this.processBtnPress),this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 23:case"end":return e.stop()}}),e,this,[[1,15]])}))),function(e){return d.apply(this,arguments)})},{key:"disconnect",value:(h=Hn(Dn().mark((function e(){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),this.activeDevice&&this.activeDevice.unsubscribe(),this.activeDevice=null,this._deviceInfo=null,this.isMuted=!1;case 5:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"incomingCall",value:(f=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.activeDevice.ring();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"outgoingCall",value:(l=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.activeConversationId=t.conversationId,this.activeDevice.offHook();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"answerCall",value:(u=Hn(Dn().mark((function e(t,n){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId===t||n?(this.activeConversationId=t,this.pendingConversationId="",this.activeDevice.offHook()):this.logger.error("no call to be answered");case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"rejectCall",value:(c=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t===this.pendingConversationId?(this.pendingConversationId="",this.activeDevice.onHook()):this.logger.error("no call to be rejected");case 1:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"endCall",value:(s=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t===this.activeConversationId?(this.activeConversationId="",this.pendingConversationId="",this.activeDevice.onHook()):this.logger.error("no call to be ended");case 1:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"endAllCalls",value:(a=Hn(Dn().mark((function e(){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.activeConversationId="",this.pendingConversationId="",this.activeDevice.onHook();case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"setMute",value:(o=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.isMuted=t,this.isMuted?this.activeDevice.muteOn():this.activeDevice.muteOff();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})}],i=[{key:"getInstance",value:function(e){return t.instance||(t.instance=new t(e)),t.instance}}],r&&Mn(n.prototype,r),i&&Mn(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d}(W.a);Yn(Wn,"instance",void 0);var qn=n(1);function Kn(e){return(Kn="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 zn(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 $n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?zn(Object(n),!0).forEach((function(t){nr(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Jn(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Jn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Kn(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Kn(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function Xn(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Qn(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Xn(o,r,i,a,s,"next",e)}function s(e){Xn(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Zn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return er(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return er(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function er(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function tr(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,rr(r.key),r)}}function nr(e,t,n){return(t=rr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rr(e){var t=function(e,t){if("object"!=Kn(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Kn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Kn(t)?t:t+""}var ir=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),nr(this,"plantronics",void 0),nr(this,"jabraNative",void 0),nr(this,"jabra",void 0),nr(this,"sennheiser",void 0),nr(this,"yealink",void 0),nr(this,"vbet",void 0),nr(this,"cyberAcoustics",void 0),nr(this,"selectedImplementation",void 0),nr(this,"headsetEvents$",void 0),nr(this,"headsetConversationStates",{}),nr(this,"_headsetEvents$",void 0),nr(this,"logger",void 0),this._headsetEvents$=new Y,this.headsetEvents$=this._headsetEvents$.asObservable(),this.logger=t.logger||console,this.plantronics=Se.getInstance({logger:this.logger,appName:t.appName}),this.jabraNative=Rt.getInstance({logger:this.logger}),this.jabra=Et.getInstance({logger:this.logger}),this.sennheiser=Ue.getInstance({logger:this.logger}),this.yealink=zt.getInstance({logger:this.logger}),this.vbet=Wn.getInstance({logger:this.logger}),this.cyberAcoustics=fe.getInstance({logger:this.logger}),[this.plantronics,this.jabra,this.jabraNative,this.sennheiser,this.yealink,this.vbet,this.cyberAcoustics].forEach((function(e){return n.subscribeToHeadsetEvents(e)}))}return t=e,n=[{key:"implementations",get:function(){return[this.sennheiser,this.plantronics,this.jabra,this.jabraNative,this.yealink,this.vbet,this.cyberAcoustics].filter((function(e){return e.isSupported()}))}},{key:"isDifferentState",value:function(e){var t=this.headsetConversationStates[e.conversationId];return!t||Object.entries(e.state).some((function(e){var n=Zn(e,2),r=n[0],i=n[1];return t[r]!==i}))}},{key:"updateHeadsetState",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{expectExistingConversation:!0};if(this.isDifferentState(e)){var n=this.headsetConversationStates[e.conversationId];return n?(Object.assign(n,e.state),!0):(t.expectExistingConversation&&this.logger.warn("updateHeadsetState has no existing state for provided conversationId.",{conversationId:e.conversationId}),!1)}return!1}},{key:"deviceIsSupported",value:function(e){return!!e.micLabel&&!!this.implementations.find((function(t){return t.deviceLabelMatchesVendor(e.micLabel)}))}},{key:"activeMicChange",value:function(e,t){if(e){var n=this.implementations.find((function(t){return t.deviceLabelMatchesVendor(e)}));n?this.changeImplementation(n,e):this.selectedImplementation&&this.clearSelectedImplementation(t)}else this.clearSelectedImplementation(t)}},{key:"changeImplementation",value:(h=Qn(Jn().mark((function e(t,n){return Jn().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=6;break}return this.headsetConversationStates={},e.next=6,this.selectedImplementation.disconnect();case 6:if(this.selectedImplementation=t,this._headsetEvents$.next({event:qn.a.implementationChanged,payload:t}),!t){e.next=11;break}return e.next=11,t.connect(n);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"incomingCall",value:(f=Qn(Jn().mark((function e(t,n){var r;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:return this.headsetConversationStates[t.conversationId]={conversationId:t.conversationId,held:!1,muted:!1,offHook:!1,ringing:!0},e.abrupt("return",r.incomingCall(t,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"outgoingCall",value:(l=Qn(Jn().mark((function e(t){var n;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:return this.headsetConversationStates[t.conversationId]={conversationId:t.conversationId,held:!1,muted:!1,offHook:!0,ringing:!1},e.abrupt("return",n.outgoingCall(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"answerCall",value:(u=Qn(Jn().mark((function e(t,n){var r,i;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(n){e.next=9;break}if(i={ringing:!1,offHook:!0},!this.updateHeadsetState({conversationId:t,state:i})){e.next=7;break}return e.abrupt("return",r.answerCall(t));case 7:e.next=11;break;case 9:return this.headsetConversationStates[t]={conversationId:t,held:!1,muted:!1,offHook:!0,ringing:!1},e.abrupt("return",r.answerCall(t,n));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"rejectCall",value:(c=Qn(Jn().mark((function e(t){var n,r,i,o=arguments;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(o.length>1&&void 0!==o[1])||o[1],r=this.getConnectedImpl()){e.next=4;break}return e.abrupt("return");case 4:if(i={ringing:!1},!this.updateHeadsetState({conversationId:t,state:i},{expectExistingConversation:n})){e.next=9;break}return this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t),e.abrupt("return",r.rejectCall(t));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setMute",value:(s=Qn(Jn().mark((function e(t){var n;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(!Object.values(this.headsetConversationStates).some((function(e){return e.muted!==t}))){e.next=6;break}return Object.values(this.headsetConversationStates).forEach((function(e){return e.muted=t})),e.abrupt("return",n.setMute(t));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"setHold",value:(a=Qn(Jn().mark((function e(t,n){var r,i;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(i={held:n},!this.updateHeadsetState({conversationId:t,state:i})){e.next=6;break}return e.abrupt("return",r.setHold(t,n));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"endCall",value:(o=Qn(Jn().mark((function e(t,n){var r,i;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(i={offHook:!1},!this.updateHeadsetState({conversationId:t,state:i})){e.next=8;break}return this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t),e.abrupt("return",r.endCall(t,n));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"endAllCalls",value:(i=Qn(Jn().mark((function e(){var t,n=this;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:return Object.values(this.headsetConversationStates).forEach((function(e){e.removeTimer||(e.removeTimer=n.setRemoveTimer(e.conversationId))})),e.abrupt("return",t.endAllCalls());case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{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:"resetHeadsetStateForCall",value:function(e){var t=this.getConnectedImpl();if(t)return t.resetHeadsetStateForCall(e);this.logger.info("No active implementation, headset state does not require a reset")}},{key:"getConnectedImpl",value:function(){var e=this.selectedImplementation;return e&&e.isConnected?e:null}},{key:"subscribeToHeadsetEvents",value:function(e){e.on(qn.a.deviceAnsweredCall,this.handleDeviceAnsweredCall.bind(this)),e.on(qn.a.deviceRejectedCall,this.handleDeviceRejectedCall.bind(this)),e.on(qn.a.deviceEndedCall,this.handleDeviceEndedCall.bind(this)),e.on(qn.a.deviceMuteStatusChanged,this.handleDeviceMuteStatusChanged.bind(this)),e.on(qn.a.deviceHoldStatusChanged,this.handleDeviceHoldStatusChanged.bind(this)),e.on(qn.a.deviceEventLogs,this.handleDeviceLogs.bind(this)),e.on(qn.a.deviceConnectionStatusChanged,this.handleDeviceConnectionStatusChanged.bind(this)),e.on(qn.a.webHidPermissionRequested,this.handleWebHidPermissionRequested.bind(this))}},{key:"clearSelectedImplementation",value:function(e){this.selectedImplementation&&(this.selectedImplementation.disconnect(e),this._headsetEvents$.next({event:qn.a.implementationChanged,payload:null}),this.selectedImplementation=null,this.handleDeviceConnectionStatusChanged())}},{key:"setRemoveTimer",value:function(e){var t=this;return setTimeout((function(){t.headsetConversationStates[e].removeTimer&&delete t.headsetConversationStates[e]}),2e3)}},{key:"handleDeviceAnsweredCall",value:function(e){e.vendor===this.selectedImplementation&&(this.updateHeadsetState({conversationId:e.body.conversationId,state:{ringing:!1,offHook:!0}}),this.logger.info("Headset: device answered the call"),this._headsetEvents$.next({event:qn.a.deviceAnsweredCall,payload:$n({},e.body)}))}},{key:"handleDeviceRejectedCall",value:function(e){if(e.vendor===this.selectedImplementation){var t=e.body.conversationId;this.updateHeadsetState({conversationId:t,state:{ringing:!1}})&&(this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t)),this.logger.info("Headset: device rejected the call"),this._headsetEvents$.next({event:qn.a.deviceRejectedCall,payload:$n({},e.body)})}}},{key:"handleDeviceEndedCall",value:function(e){this.logger.info("Headset: device ended the call");var t=e.body.conversationId;this.updateHeadsetState({conversationId:t,state:{offHook:!1}})&&(this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t)),this._headsetEvents$.next({event:qn.a.deviceEndedCall,payload:$n({},e.body)})}},{key:"handleDeviceMuteStatusChanged",value:function(e){this.logger.info("Headset: device mute status changed: ",e.body.isMuted),Object.values(this.headsetConversationStates).some((function(t){return t.muted!==e.body.isMuted}))&&Object.values(this.headsetConversationStates).forEach((function(t){return t.muted=e.body.isMuted})),this._headsetEvents$.next({event:qn.a.deviceMuteStatusChanged,payload:$n({},e.body)})}},{key:"handleDeviceHoldStatusChanged",value:function(e){this.logger.info("Headset: device hold status changed",e.body.holdRequested);var t={held:e.body.holdRequested},n=e.body.conversationId;this.updateHeadsetState({conversationId:n,state:t}),this._headsetEvents$.next({event:qn.a.deviceHoldStatusChanged,payload:$n({},e.body)})}},{key:"handleDeviceConnectionStatusChanged",value:function(){this._headsetEvents$.next({event:qn.a.deviceConnectionStatusChanged,payload:this.connectionStatus()})}},{key:"handleWebHidPermissionRequested",value:function(e){this.logger.debug("Requesting Webhid Permissions"),this._headsetEvents$.next({event:qn.a.webHidPermissionRequested,payload:$n({},e.body)})}},{key:"handleDeviceLogs",value:function(e){this._headsetEvents$.next({event:qn.a.loggableEvent,payload:$n({},e.body)})}}],r=[{key:"getInstance",value:function(t){return e.instance&&!t.createNew||(e.instance=new e(t)),e.instance}}],n&&tr(t.prototype,n),r&&tr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r,i,o,a,s,c,u,l,f,h}();nr(ir,"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 a in o)["default","VendorImplementation"].indexOf(a)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(a);var s=n(1);n.d(t,"HeadsetEvents",(function(){return s.a}));var c=n(7);for(var a in c)["default","VendorImplementation","HeadsetEvents"].indexOf(a)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(a);n(8);var u=n(9);for(var a in u)["default","VendorImplementation","HeadsetEvents"].indexOf(a)<0&&function(e){n.d(t,e,(function(){return u[e]}))}(a);t.default=r.a},,function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(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:a}catch(e){r=a}}();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=s(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===a||!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||s(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){
|
|
25
|
+
e.exports=function(){var e=function(e,t,n,r,i,o){for(var a=function(e,t){var n=e.toString(16);return n.length<2&&(n="0"+n),t&&(n=n.toUpperCase()),n},s=t;s<=n;s++)i[o++]=a(e[s],r);return i},t=function(e,t,n,r,i){for(var o=t;o<=n;o+=2)r[i++]=parseInt(e.substr(o,2),16)},n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#".split(""),r=[0,68,0,84,83,82,72,0,75,76,70,65,0,63,62,69,0,1,2,3,4,5,6,7,8,9,64,0,73,66,74,71,81,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,77,0,78,67,0,0,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,79,0,80,0,0],o=function(e,t){if(t%4!=0)throw new Error("z85_encode: invalid input length (multiple of 4 expected)");for(var r="",i=0,o=0;i<t;)if(o=256*o+e[i++],i%4==0){for(var a=52200625;a>=1;){var s=Math.floor(o/a)%85;r+=n[s],a/=85}o=0}return r},a=function(e,t){var n=e.length;if(n%5!=0)throw new Error("z85_decode: invalid input length (multiple of 5 expected)");void 0===t&&(t=new Array(4*n/5));for(var i=0,o=0,a=0;i<n;){var s=e.charCodeAt(i++)-32;if(s<0||s>=r.length)break;if(a=85*a+r[s],i%5==0){for(var c=16777216;c>=1;)t[o++]=Math.trunc(a/c%256),c/=256;a=0}}return t},s=function(e,t){var n={ibits:8,obits:8,obigendian:!0};for(var r in t)void 0!==n[r]&&(n[r]=t[r]);for(var i,o,a,s=[],c=0,u=0,l=0,f=e.length;0===u&&(o=e.charCodeAt(c++)),i=o>>n.ibits-(u+8)&255,u=(u+8)%n.ibits,n.obigendian?0===l?a=i<<n.obits-8:a|=i<<n.obits-8-l:0===l?a=i:a|=i<<l,!(0==(l=(l+8)%n.obits)&&(s.push(a),c>=f)););return s},c=function(e,t){var n={ibits:32,ibigendian:!0};for(var r in t)void 0!==n[r]&&(n[r]=t[r]);var i="",o=4294967295;n.ibits<32&&(o=(1<<n.ibits)-1);for(var a=e.length,s=0;s<a;s++)for(var c=e[s]&o,u=0;u<n.ibits;u+=8)n.ibigendian?i+=String.fromCharCode(c>>n.ibits-8-u&255):i+=String.fromCharCode(c>>u&255);return i},u=256,l=function(e,t,n,r,i,o,a,s){return[s,a,o,i,r,n,t,e]},f=function(){return l(0,0,0,0,0,0,0,0)},h=function(e){return e.slice(0)},d=function(e){for(var t=f(),n=0;n<8;n++)t[n]=Math.floor(e%u),e/=u;return t},p=function(e){for(var t=0,n=7;n>=0;n--)t*=u,t+=e[n];return Math.floor(t)},v=function(e,t){for(var n=0,r=0;r<8;r++)n+=e[r]+t[r],e[r]=Math.floor(n%u),n=Math.floor(n/u);return n},y=function(e,t){for(var n=0,r=0;r<8;r++)n+=e[r]*t,e[r]=Math.floor(n%u),n=Math.floor(n/u);return n},g=function(e,t){for(var n=0;n<8;n++)e[n]&=t[n];return e},m=function(e,t){var n=f();if(t%8!=0)throw new Error("ui64_rorn: only bit rotations supported with a multiple of digit bits");for(var r=Math.floor(t/8),i=0;i<r;i++){for(var o=6;o>=0;o--)n[o+1]=n[o];for(n[0]=e[0],o=0;o<7;o++)e[o]=e[o+1];e[o]=0}return p(n)},b=function(e,t){if(t>64)throw new Error("ui64_ror: invalid number of bits to shift");var n,r=new Array(16);for(n=0;n<8;n++)r[n+8]=e[n],r[n]=0;var i=Math.floor(t/8),o=t%8;for(n=i;n<15;n++)r[n-i]=255&(r[n]>>>o|r[n+1]<<8-o);for(r[15-i]=r[15]>>>o&255,n=15-i+1;n<16;n++)r[n]=0;for(n=0;n<8;n++)e[n]=r[n+8];return r.slice(0,8)},w=function(e,t){for(var n=0;n<8;n++)e[n]^=t[n]},E=function(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n},C=function(e,t){return e<<t&4294967295|e>>>32-t&4294967295},_=function(e){return c(function(e,t){function n(e,t,n,r){return e<20?t&n|~t&r:e<40?t^n^r:e<60?t&n|t&r|n&r:t^n^r}function r(e){return e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514}e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var i=Array(80),o=1732584193,a=-271733879,s=-1732584194,c=271733878,u=-1009589776,l=0;l<e.length;l+=16){for(var f=o,h=a,d=s,p=c,v=u,y=0;y<80;y++){i[y]=y<16?e[l+y]:C(i[y-3]^i[y-8]^i[y-14]^i[y-16],1);var g=E(E(C(o,5),n(y,a,s,c)),E(E(u,i[y]),r(y)));u=c,c=s,s=C(a,30),a=o,o=g}o=E(o,f),a=E(a,h),s=E(s,d),c=E(c,p),u=E(u,v)}return[o,a,s,c,u]}(s(e,{ibits:8,obits:32,obigendian:!0}),8*e.length),{ibits:32,ibigendian:!0})},I=function(e){return c(function(e,t){function n(e,t,n,r,i,o){return E(C(E(E(t,e),E(r,o)),i),n)}function r(e,t,r,i,o,a,s){return n(t&r|~t&i,e,t,o,a,s)}function i(e,t,r,i,o,a,s){return n(t&i|r&~i,e,t,o,a,s)}function o(e,t,r,i,o,a,s){return n(t^r^i,e,t,o,a,s)}function a(e,t,r,i,o,a,s){return n(r^(t|~i),e,t,o,a,s)}e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var s=1732584193,c=-271733879,u=-1732584194,l=271733878,f=0;f<e.length;f+=16){var h=s,d=c,p=u,v=l;s=r(s,c,u,l,e[f+0],7,-680876936),l=r(l,s,c,u,e[f+1],12,-389564586),u=r(u,l,s,c,e[f+2],17,606105819),c=r(c,u,l,s,e[f+3],22,-1044525330),s=r(s,c,u,l,e[f+4],7,-176418897),l=r(l,s,c,u,e[f+5],12,1200080426),u=r(u,l,s,c,e[f+6],17,-1473231341),c=r(c,u,l,s,e[f+7],22,-45705983),s=r(s,c,u,l,e[f+8],7,1770035416),l=r(l,s,c,u,e[f+9],12,-1958414417),u=r(u,l,s,c,e[f+10],17,-42063),c=r(c,u,l,s,e[f+11],22,-1990404162),s=r(s,c,u,l,e[f+12],7,1804603682),l=r(l,s,c,u,e[f+13],12,-40341101),u=r(u,l,s,c,e[f+14],17,-1502002290),s=i(s,c=r(c,u,l,s,e[f+15],22,1236535329),u,l,e[f+1],5,-165796510),l=i(l,s,c,u,e[f+6],9,-1069501632),u=i(u,l,s,c,e[f+11],14,643717713),c=i(c,u,l,s,e[f+0],20,-373897302),s=i(s,c,u,l,e[f+5],5,-701558691),l=i(l,s,c,u,e[f+10],9,38016083),u=i(u,l,s,c,e[f+15],14,-660478335),c=i(c,u,l,s,e[f+4],20,-405537848),s=i(s,c,u,l,e[f+9],5,568446438),l=i(l,s,c,u,e[f+14],9,-1019803690),u=i(u,l,s,c,e[f+3],14,-187363961),c=i(c,u,l,s,e[f+8],20,1163531501),s=i(s,c,u,l,e[f+13],5,-1444681467),l=i(l,s,c,u,e[f+2],9,-51403784),u=i(u,l,s,c,e[f+7],14,1735328473),s=o(s,c=i(c,u,l,s,e[f+12],20,-1926607734),u,l,e[f+5],4,-378558),l=o(l,s,c,u,e[f+8],11,-2022574463),u=o(u,l,s,c,e[f+11],16,1839030562),c=o(c,u,l,s,e[f+14],23,-35309556),s=o(s,c,u,l,e[f+1],4,-1530992060),l=o(l,s,c,u,e[f+4],11,1272893353),u=o(u,l,s,c,e[f+7],16,-155497632),c=o(c,u,l,s,e[f+10],23,-1094730640),s=o(s,c,u,l,e[f+13],4,681279174),l=o(l,s,c,u,e[f+0],11,-358537222),u=o(u,l,s,c,e[f+3],16,-722521979),c=o(c,u,l,s,e[f+6],23,76029189),s=o(s,c,u,l,e[f+9],4,-640364487),l=o(l,s,c,u,e[f+12],11,-421815835),u=o(u,l,s,c,e[f+15],16,530742520),s=a(s,c=o(c,u,l,s,e[f+2],23,-995338651),u,l,e[f+0],6,-198630844),l=a(l,s,c,u,e[f+7],10,1126891415),u=a(u,l,s,c,e[f+14],15,-1416354905),c=a(c,u,l,s,e[f+5],21,-57434055),s=a(s,c,u,l,e[f+12],6,1700485571),l=a(l,s,c,u,e[f+3],10,-1894986606),u=a(u,l,s,c,e[f+10],15,-1051523),c=a(c,u,l,s,e[f+1],21,-2054922799),s=a(s,c,u,l,e[f+8],6,1873313359),l=a(l,s,c,u,e[f+15],10,-30611744),u=a(u,l,s,c,e[f+6],15,-1560198380),c=a(c,u,l,s,e[f+13],21,1309151649),s=a(s,c,u,l,e[f+4],6,-145523070),l=a(l,s,c,u,e[f+11],10,-1120210379),u=a(u,l,s,c,e[f+2],15,718787259),c=a(c,u,l,s,e[f+9],21,-343485551),s=E(s,h),c=E(c,d),u=E(u,p),l=E(l,v)}return[s,c,u,l]}(s(e,{ibits:8,obits:32,obigendian:!1}),8*e.length),{ibits:32,ibigendian:!1})},k=function(e){this.mul=l(88,81,244,45,76,149,127,45),this.inc=l(20,5,123,126,247,103,129,79),this.mask=l(0,0,0,0,255,255,255,255),this.state=h(this.inc),this.next(),g(this.state,this.mask),e=d(void 0!==e?e>>>0:4294967295*Math.random()>>>0),function(e,t){for(var n=0;n<8;n++)e[n]|=t[n]}(this.state,e),this.next()};k.prototype.next=function(){var e=h(this.state);(function(e,t){var n,r,i,o=new Array(16);for(n=0;n<16;n++)o[n]=0;for(n=0;n<8;n++){for(i=0,r=0;r<8;r++)i+=e[n]*t[r]+o[n+r],o[n+r]=i%u,i/=u;for(;r<16-n;r++)i+=o[n+r],o[n+r]=i%u,i/=u}for(n=0;n<8;n++)e[n]=o[n];o.slice(8,8)})(this.state,this.mul),v(this.state,this.inc);var t=h(e);b(t,18),w(t,e),b(t,27);var n=h(e);b(n,59),g(t,this.mask);var r=p(n),i=h(t);return function(e,t){if(t>64)throw new Error("ui64_rol: invalid number of bits to shift");var n,r=new Array(16);for(n=0;n<8;n++)r[n+8]=0,r[n]=e[n];var i=Math.floor(t/8),o=t%8;for(n=7-i;n>0;n--)r[n+i]=255&(r[n]<<o|r[n-1]>>>8-o);for(r[0+i]=r[0]<<o&255,n=0+i-1;n>=0;n--)r[n]=0;for(n=0;n<8;n++)e[n]=r[n];r.slice(8,8)}(i,32-r),b(t,r),w(t,i),p(t)};var O=new k,S=function(e,t){for(var n=[],r=0;r<e;r++)n[r]=O.next()%t;return n},T=0,x=0,A=function(){if(1===arguments.length&&"string"==typeof arguments[0])this.parse.apply(this,arguments);else if(arguments.length>=1&&"number"==typeof arguments[0])this.make.apply(this,arguments);else{if(arguments.length>=1)throw new Error("UUID: constructor: invalid arguments");for(var e=0;e<16;e++)this[e]=0}};return(A.prototype="undefined"!=typeof Uint8Array?new Uint8Array(16):i?i.alloc(16):new Array(16)).constructor=A,A.prototype.make=function(e){var t,n=this;if(1===e){var r=(new Date).getTime();r!==T?x=0:x++,T=r;var i,o=d(r);y(o,1e4),v(o,l(1,178,29,210,19,129,64,0)),x>0&&v(o,d(x)),i=m(o,8),n[3]=255&i,i=m(o,8),n[2]=255&i,i=m(o,8),n[1]=255&i,i=m(o,8),n[0]=255&i,i=m(o,8),n[5]=255&i,i=m(o,8),n[4]=255&i,i=m(o,8),n[7]=255&i,i=m(o,8),n[6]=15&i;var a=S(2,255);n[8]=a[0],n[9]=a[1];var s=S(6,255);for(s[0]|=1,s[0]|=2,t=0;t<6;t++)n[10+t]=s[t]}else if(4===e){var c=S(16,255);for(t=0;t<16;t++)this[t]=c[t]}else{if(3!==e&&5!==e)throw new Error("UUID: make: invalid version");var u="",f="object"==typeof arguments[1]&&arguments[1]instanceof A?arguments[1]:(new A).parse(arguments[1]);for(t=0;t<16;t++)u+=String.fromCharCode(f[t]);u+=arguments[2];var h=3===e?I(u):_(u);for(t=0;t<16;t++)n[t]=h.charCodeAt(t)}return n[6]&=15,n[6]|=e<<4,n[8]&=63,n[8]|=128,n},A.prototype.format=function(t){var n,r;return"z85"===t?n=o(this,16):"b16"===t?(r=Array(32),e(this,0,15,!0,r,0),n=r.join("")):void 0!==t&&"std"!==t||(r=new Array(36),e(this,0,3,!1,r,0),r[8]="-",e(this,4,5,!1,r,9),r[13]="-",e(this,6,7,!1,r,14),r[18]="-",e(this,8,9,!1,r,19),r[23]="-",e(this,10,15,!1,r,24),n=r.join("")),n},A.prototype.toString=function(e){return this.format(e)},A.prototype.toJSON=function(){return this.format("std")},A.prototype.parse=function(e,n){if("string"!=typeof e)throw new Error("UUID: parse: invalid argument (type string expected)");if("z85"===n)a(e,this);else if("b16"===n)t(e,0,35,this,0);else if(void 0===n||"std"===n){var r={nil:"00000000-0000-0000-0000-000000000000","ns:DNS":"6ba7b810-9dad-11d1-80b4-00c04fd430c8","ns:URL":"6ba7b811-9dad-11d1-80b4-00c04fd430c8","ns:OID":"6ba7b812-9dad-11d1-80b4-00c04fd430c8","ns:X500":"6ba7b814-9dad-11d1-80b4-00c04fd430c8"};if(void 0!==r[e])e=r[e];else if(!e.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))throw new Error('UUID: parse: invalid string representation (expected "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")');t(e,0,7,this,0),t(e,9,12,this,4),t(e,14,17,this,6),t(e,19,22,this,8),t(e,24,35,this,10)}return this},A.prototype.export=function(){for(var e=Array(16),t=0;t<16;t++)e[t]=this[t];return e},A.prototype.import=function(e){if(!("object"==typeof e&&e instanceof Array))throw new Error("UUID: import: invalid argument (type Array expected)");if(16!==e.length)throw new Error("UUID: import: invalid argument (Array of length 16 expected)");for(var t=0;t<16;t++){if("number"!=typeof e[t])throw new Error("UUID: import: invalid array element #"+t+" (type Number expected)");if(!isFinite(e[t])||Math.floor(e[t])!==e[t])throw new Error("UUID: import: invalid array element #"+t+" (Number with integer value expected)");if(!(e[t]>=0&&e[t]<=255))throw new Error("UUID: import: invalid array element #"+t+" (Number with integer value in range 0...255 expected)");this[t]=e[t]}return this},A.prototype.compare=function(e){if("object"!=typeof e)throw new Error("UUID: compare: invalid argument (type UUID expected)");if(!(e instanceof A))throw new Error("UUID: compare: invalid argument (type UUID expected)");for(var t=0;t<16;t++){if(this[t]<e[t])return-1;if(this[t]>e[t])return 1}return 0},A.prototype.equal=function(e){return 0===this.compare(e)},A.prototype.fold=function(e){if(void 0===e)throw new Error("UUID: fold: invalid argument (number of fold operations expected)");if(e<1||e>4)throw new Error("UUID: fold: invalid argument (1-4 fold operations expected)");for(var t=16/Math.pow(2,e),n=new Array(t),r=0;r<t;r++){for(var i=0,o=0;r+o<16;o+=t)i^=this[r+o];n[r]=i}return n},A.PCG=k,A}(),e.exports.default=e.exports}));class rn{constructor(e){this.transport=e,this.gnpLockAcquired=e.consoleAppEvent.pipe(rt(e=>"response-gnp-lock"===e.event),Me(e=>e.token),mt(1)),this.gnpLockAcquired.subscribe()}acquireGnpLock(e){const t=new nn(4).toString(),n={action:"request-gnp-lock",id:e,token:t},r=this.gnpLockAcquired.pipe(dt(e=>e===t));return this.transport.writeAction(n),r}releaseGnpLock(e,t){const n={action:"release-gnp-lock",id:e,token:t};this.transport.writeAction(n)}}!function(e){e[e.INPUT=0]="INPUT",e[e.OUTPUT=1]="OUTPUT",e[e.FEATURE=2]="FEATURE"}(en||(en={})),function(e){e.ABSOLUTE="absolute",e.RELATIVE="relative"}(tn||(tn={}));class on{constructor(e){this.id=e}equals(e){return this.id===e.id}startsWith(e){return this.id.startsWith(e.id)}toString(){return this.id}}function an(e,t,n){const r=e.toString(16).padStart(4,"0"),i=t.toString(16).padStart(4,"0");return new on(`${r}:${i}:${n}`)}class sn{constructor(e,t,n,r){this.id=e,this.usagePage=t,this.usage=n,this.value=r}isArray(){return Array.isArray(this.value)}static deserialize(e,t){return new sn(new on(e),t.usagePage,t.usage,t.value)}}class cn{constructor(e,t,n){this.descriptor=t,this.transport=n,this.transportId=e.transportId,this.input=n.consoleAppEvent.pipe(rt(e=>e.id===this.transportId),cn.inputReportsFilter)}output(e,t,n){const r={action:"hid-output",id:this.transportId,usagePage:e,usage:t,value:n};this.transport.writeAction(r)}getFeatureReport(e,t){const n=new nn(4).toString(),r={action:"request-hid-feature",id:this.transportId,token:n,usagePage:e,usage:t};return this.transport.writeAction(r),this.transport.consoleAppEvent.pipe(dt(e=>"response-hid-feature"===e.event&&e.token===n),Me(e=>e.value))}setFeatureReport(e,t,n){const r={action:"set-hid-feature",id:this.transportId,usagePage:e,usage:t,value:n};this.transport.writeAction(r)}findDescriptor(e,t,n){return this.descriptor.find(r=>r.usagePage===e&&r.usage===t&&r.reportType===n)}}cn.inputReportsFilter=e=>e.pipe(rt(e=>"hid-input"===e.event),Me(e=>sn.deserialize(e.id,e)));class un{static typeFromAttr(e){return e>>6}static packetLengthFromAttr(e){return e&this.lengthMask}static deserialize(e){const t=e[0],n=e[1],r=e[2],i=this.typeFromAttr(e[3]),o=e[4],a=e[5],s=this.packetLengthFromAttr(e[3]),c=e.slice(6,s);return new Vt(t,n,i,o,a,c,r)}}un.lengthMask=63;class ln{constructor(){this.data=[]}hasHeader(){return this.data.length>=ln.gnpPacketHeaderLength}expectedPacketLength(){if(!this.hasHeader())throw new It("Unable to get expected packet length without a full header",$e.UNEXPECTED_ERROR);return un.packetLengthFromAttr(this.data[3])}appendData(e){this.hasHeader()&&this.expectedPacketLength()>ln.gnpPacketMaxLength&&(this.data=[]),this.data=this.data.concat(e)}hasFullPacket(){if(!this.hasHeader())return!1;const e=this.expectedPacketLength();return this.data.length>=e}getPacketAndReset(){if(!this.hasFullPacket())throw new It("Trying to get packet but buffer is not complete",$e.UNEXPECTED_ERROR);const e=un.deserialize(Uint8Array.from(this.data));return this.data=[],e}}ln.gnpPacketHeaderLength=6,ln.gnpPacketMaxLength=63;const fn=()=>{};function hn(e){return _t(t=>e(),t=>e(),()=>fn)}const dn=()=>{return e=e=>e.command===Ft.NACK,t=e=>{const t=e.subCommand in Gt?Gt[e.subCommand]:e.subCommand;return new It("Got NACK response. Reason: "+t,$e.DEVICE_ERROR)},n=>n.pipe(Me(n=>e(n)?Le(t(n)):Ae(n)),Et());var e,t},pn=e=>dt(t=>t.type===Mt.REPLY&&t.sequenceNumber===e.sequenceNumber&&t.destination===e.source&&t.source===e.destination);class vn{constructor(e,t,n,r,i=0){this.hidChannel=e,this.gnpLock=t,this.transportId=n,this.primaryAddress=r,this.lockQueue=[],this.packets=e.input.pipe(vn.inputFilter),this.events=this.packets.pipe(vn.eventsFilter),this.nextSequenceNumber=i}static get inputFilter(){return e=>{const t=e.pipe(rt(e=>e.usagePage===jt.GN_PROTOCOL&&e.usage===Ht.DATA&&e.isArray())),n=new ln;return t.pipe(Fe(e=>{const t=e.value;return n.appendData(t),n.hasFullPacket()?Ae(n.getPacketAndReset()):Ze}),yt())}}static supportsGnpOverHid(e){return void 0!==e.findDescriptor(jt.GN_PROTOCOL,Ht.DATA,en.OUTPUT)}getNextSequenceNumber(){const e=this.nextSequenceNumber;return this.nextSequenceNumber=(this.nextSequenceNumber+1)%255,e}doWithGnpLockHeld(e){this.lockQueue.push(e),this.lockQueue.length>1||this.processLockQueue()}processLockQueue(){this.gnpLock.acquireGnpLock(this.transportId).subscribe(e=>{(0,this.lockQueue[0])(e=>{var t;const n=null===(t=this.hidChannel.findDescriptor(jt.GN_PROTOCOL,Ht.DATA,en.OUTPUT))||void 0===t?void 0:t.reportSize;if(!n)throw new It("Cannot send GNP packets to this device.",$e.DEVICE_ERROR);const r=class{static attrFromTypeAndPayloadLength(e,t){return(e<<6)+(t+6)}static serialize(e){const t=new Uint8Array(6);t[0]=e.destination,t[1]=e.source,t[2]=e.sequenceNumber,t[3]=this.attrFromTypeAndPayloadLength(e.type,e.payload.length),t[4]=e.command,t[5]=e.subCommand;const n=new Uint8Array(t.length+e.payload.length);return n.set(t),n.set(e.payload,t.length),n}}.serialize(e);let i=0;do{const e=Math.min(r.length-i,n),t=r.subarray(i,i+e);i+=t.length,this.hidChannel.output(jt.GN_PROTOCOL,Ht.DATA,Array.from(t))}while(i<r.length)},this.packets,()=>{this.gnpLock.releaseGnpLock(this.transportId,e),this.lockQueue.splice(0,1),this.lockQueue.length>0&&this.processLockQueue()})})}sendEvent(e,t,n=this.primaryAddress){const r=new Vt(n,Ut.PC_ADDR,Mt.EVENT,e.command,e.subCommand,e.serialize(t),0);this.doWithGnpLockHeld((e,t,n)=>{e(r),n()})}read(e,t=this.primaryAddress,n=2500){const r=new Yt(e,e=>new Uint8Array);return this.readWithParams(r,null,t,n)}readWithParams(e,t,n=this.primaryAddress,r=2500){const i=new Vt(n,Ut.PC_ADDR,Mt.READ,e.command,e.subCommand,e.serialize(t),this.getNextSequenceNumber()),o=new X;return this.doWithGnpLockHeld((t,n,a)=>{n.pipe(pn(i),dn(),dt(e=>e.command===i.command&&e.subCommand===i.subCommand),He(r),hn(a),Me(t=>e.deserialize(t))).subscribe(o),t(i)}),o}write(e,t,n=this.primaryAddress,r=2500){const i=new Vt(n,Ut.PC_ADDR,Mt.WRITE,e.command,e.subCommand,e.serialize(t),this.getNextSequenceNumber()),o=new X;return this.doWithGnpLockHeld((e,t,n)=>{t.pipe(pn(i),dn(),dt(e=>e.command===Ft.ACK),He(r),hn(n),Me(()=>!0)).subscribe(o),e(i)}),o}}vn.eventsFilter=e=>e.pipe(rt(e=>e.type===Mt.EVENT));class yn{constructor(e,t){this.parentGnpChannel=e,this.primaryAddress=t,this.events=e.events.pipe(rt(e=>e.source===this.primaryAddress))}sendEvent(e,t,n){this.parentGnpChannel.sendEvent(e,t,this.primaryAddress)}read(e,t,n){return this.parentGnpChannel.read(e,this.primaryAddress,n)}readWithParams(e,t,n,r){return this.parentGnpChannel.readWithParams(e,t,this.primaryAddress,r)}write(e,t,n,r){return this.parentGnpChannel.write(e,t,this.primaryAddress,r)}}function gn(e,t,n,r){if(!vn.supportsGnpOverHid(e))return Le(()=>new It("Device does not support GNP commands.",$e.DEVICE_ERROR));const i=Ae(Ut.HS_BT_USB_ADDR,Ut.BASE_ADDR,Ut.CRADLE_ADDR,Ut.HS1_ADDR,Ut.HS_CRADLE_ADDR).pipe(Me((r,i)=>Ve(()=>{const o=new vn(e,new rn(t),n,r,i);return o.read(Xt,r,500).pipe(Me(e=>o),st(()=>ce))})),Ge(),lt(1),ft(()=>new It("GNP probe failed.",$e.DEVICE_ERROR)));return it(r.pipe(Fe(e=>Le(()=>new It("Device was suddenly disconnected.",$e.DEVICE_ERROR)))),i).pipe(yt())}function mn(e,t){return new yn(e,t)}class bn{constructor(){this.primaryAddress=Ut.BASE_ADDR,this.events=Ze}subscribeToEvent(e,t){return Le(()=>new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED))}sendEvent(e,t,n){throw new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED)}read(e,t,n){return Le(()=>new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED))}readWithParams(e,t,n,r){return Le(()=>new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED))}write(e,t,n,r){return Le(()=>new It("This device does not support GNP commands.",$e.FEATURE_NOT_SUPPORTED))}}class wn{constructor(e){this.transportId=e,this.isChild=!1}equals(e){return this.isChild===e.isChild&&this.transportId===e.transportId}toString(){return this.transportId}}class En{constructor(e,t){this.parentId=e,this.gnpAddress=t,this.isChild=!0,this.transportId=e.transportId}equals(e){if(this.isChild===e.isChild){const t=e;return this.parentId.equals(t.parentId)&&this.gnpAddress===t.gnpAddress}return!1}toString(){return`0x${e=this.gnpAddress,e.toString(16).padStart(2,"0").toUpperCase()}@${this.transportId}`;var e}}var Cn,_n,In;!function(e){e.NO_TRACKING="no-tracking",e.TRACK_ERRORS="track-errors",e.TRACK_USAGE="track-usage",e.TRACK_ALL="track-all"}(Cn||(Cn={})),function(e){e[e.BLUETOOTH=0]="BLUETOOTH",e[e.INDIRECT=1]="INDIRECT",e[e.USB=2]="USB"}(_n||(_n={})),function(e){e[e.BASE=0]="BASE",e[e.HEADSET=1]="HEADSET",e[e.DESKSTAND=2]="DESKSTAND",e[e.OTHER=3]="OTHER",e[e.DONGLE=4]="DONGLE",e[e.PC=5]="PC",e[e.EHS=6]="EHS",e[e.USB=7]="USB",e[e.SPEAKER_PHONE=8]="SPEAKER_PHONE",e[e.INDICATOR=9]="INDICATOR",e[e.MOBILE=10]="MOBILE",e[e.NONE=11]="NONE",e[e.LOCAL=12]="LOCAL",e[e.DISPLAY=13]="DISPLAY",e[e.HS_CRADLE=14]="HS_CRADLE",e[e.HS_CRADLE2=15]="HS_CRADLE2",e[e.MOBILE_IAP=16]="MOBILE_IAP",e[e.CRADLE=17]="CRADLE",e[e.VIDEO=18]="VIDEO",e[e.NOT_GN=252]="NOT_GN",e[e.ANY_GN=253]="ANY_GN",e[e.NOT_INIT=254]="NOT_INIT",e[e.ANY=255]="ANY"}(In||(In={}));class kn{constructor(e,t,n,r,i,o,a,s,c,u,l){this.id=e,this.type=t,this.hidChannel=n,this.events=r,this.primaryAddress=i,this.sendEvent=o,this.read=a,this.readWithParams=s,this.write=c,this.onDisconnect=u,this.parentConnectionId=l,this.onDisconnect.subscribe({error:A})}static createConnection(e,t,n,r,i,o){const a=r.sendEvent.bind(r),s=r.read.bind(r),c=r.readWithParams.bind(r),u=r.write.bind(r);return new kn(e,t,n,r.events,r.primaryAddress,a,s,c,u,i,o)}}const On=(e=3,t=500)=>n=>n.pipe(Fe((n,r)=>{const i=r+1;return i>e?Le(()=>n):We(i*i*t)}));function Sn(e,t,n,r=1e3,i=3,o=100){return Ve(()=>e.read(t,n,r)).pipe(vt(On(i,o)))}function Tn(e,t,n){const{deviceType:r,address:i}=n;return{transportId:t.transportId,vid:t.vid,pid:Sn(e,$t,i),name:Sn(e,zt,i),serialNumber:Sn(e,Qt,i),capabilities:t.capabilities,deviceType:r,connectionGnpAddress:i}}class xn{constructor(e,t,n=Tn,r=kn.createConnection,i=mn){this.parentConnection=t,this.connectionCreator=r,this.createChildGnpChannel=i;const o=t.events.pipe(rt(e=>e.command===Ft.DEVICE&&e.subCommand===Bt.ATTACH_EVENT),Me(e=>({deviceType:e.payload[0],address:e.payload[1]}))).pipe(Me(n.bind(null,t,e)));this.connectionEvents=o.pipe(Me(e=>{const n=it(t.events.pipe(dt(t=>t.command===Ft.DEVICE&&t.subCommand===Bt.DETACH_EVENT&&t.payload[1]===e.connectionGnpAddress),Me(A)),t.onDisconnect);return{attach:e,detach:n}}),Fe(e=>at(Ae(e.attach),this.createConnection(e.attach,e.detach))),Me(([e,t])=>({event:e,connection:t})),Ct(t.onDisconnect)),t.sendEvent(Wt,[])}createConnection(e,t){const n=e.connectionGnpAddress,r=this.createChildGnpChannel(this.parentConnection,n),i=new En(this.parentConnection.id,n);return Ae(this.connectionCreator(i,_n.INDIRECT,this.parentConnection.hidChannel,r,t,this.parentConnection.id))}}const An={command:Ft.IDENT,subCommand:Bt.TYPE,deserialize:e=>{const{payload:t}=e,n=t[0];if(n<1||n>=t.length)throw new It("Cannot get device type.",$e.DEVICE_ERROR);return t[1]}};function Ln(e,t,n,r=Ke.ERROR,i=ze.JS_LIB){kt(`${e} ${function(e){if(e instanceof It){const t=e;return`JabraError: ${t.message} (type: ${t.type})`}if(e instanceof Error){const t=e;return`Error: ${t.message} (name: ${t.name})`}return"Unknown error: "+e}(t)}`,n,r,i)}function Pn(e){return new xn(e.event,e.connection).connectionEvents}class Nn{constructor(e,t,n=((e,t,n)=>new cn(e,t,n)),r=gn,i=Pn,o=kn.createConnection){this.transport=e,this.logger=t,this.createHidChannel=n,this.createRootGnpChannel=r,this.connectionCreator=o;const a=this.transport.consoleAppEvent.pipe(rt(e=>"attach"===e.event),Me(Nn.createAttachEvent),st((e,t)=>(Ln("",e,this.logger),t))).pipe(Me(e=>{const t=this.transport.consoleAppEvent.pipe(rt(e=>"detach"===e.event),dt(t=>Nn.getTransportId(t)===e.transportId),Me(A),mt());return t.subscribe(),{attach:e,detach:t}}),Fe(e=>this.createConnection(e.attach,e.detach)),yt()),s=a.pipe(rt(e=>e.event.deviceType===In.DONGLE),rt(e=>vn.supportsGnpOverHid(e.connection.hidChannel)),Fe(e=>i(e)));this.connectionEvents=qe(a,s).pipe(yt())}static convertToReportType(e){switch(e){case"input":return en.INPUT;case"output":return en.OUTPUT;case"feature":return en.FEATURE;default:throw new It(e+" is not a valid ReportType",$e.UNEXPECTED_ERROR)}}static convertToValueType(e){switch(e){case"absolute":return tn.ABSOLUTE;case"relative":return tn.RELATIVE;default:throw new It(e+" Not a valid ValueType",$e.UNEXPECTED_ERROR)}}static createDescriptor(e){return e.map(e=>({reportType:Nn.convertToReportType(e.reportType),usagePage:e.usagePage,usage:e.usage,valueType:Nn.convertToValueType(e.valueType),reportSize:e.reportSize}))}static getMandatoryField(e,t){const n=e[t];if(void 0===n)throw new It(`JSON event lacks required field "${t}: ${JSON.stringify(e)}`,$e.UNEXPECTED_ERROR);return n}static getTransportId(e){return Nn.getMandatoryField(e,"id")}static createAttachEvent(e){return{transportId:Nn.getTransportId(e),vid:Nn.getMandatoryField(e,"vid"),pid:Ae(Nn.getMandatoryField(e,"pid")),name:Ae(Nn.getMandatoryField(e,"name")),serialNumber:Ae(Nn.getMandatoryField(e,"serialNumber")),capabilities:Nn.createDescriptor(Nn.getMandatoryField(e,"descriptor"))}}createConnection(e,t,n=3,r=100){const{capabilities:i,transportId:o}=e,a=new wn(o),s=this.createHidChannel(a,i,this.transport),c=this.createRootGnpChannel(s,this.transport,o,t).pipe(st((e,t)=>(e.type&&e.type===$e.DEVICE_ERROR&&this.transport.context===Xe.WEB_HID&&kt("Child devices are not yet supported when using WebHID.",this.logger,Ke.WARNING,ze.JS_LIB),Ae(new bn))),yt()),u=c.pipe(Fe(e=>e.read(An)),vt(On(n,r)),st(e=>Ae(In.ANY)));return at(c,u).pipe(Ct(t),Me(([n,r])=>({event:Object.assign(Object.assign({},e),{deviceType:r,connectionGnpAddress:n.primaryAddress}),connection:this.connectionCreator(a,_n.USB,s,n,t)})))}}var Rn,Dn,jn,Hn,Un;class Mn{constructor(e,t,n,r,i,o){this.vendorId=e,this.productId=t,this.serialNumber=n,this.name=r,this.type=i,Dn.set(this,void 0),y(this,Dn,new St(o,v(Mn,Rn,"m",Hn)),"f"),this.connectionAdded=v(this,Dn,"f").itemAdded,this.connectionRemoved=v(this,Dn,"f").itemRemoved,this.connectionList=v(this,Dn,"f").itemList,this.onDisconnect=v(this,Dn,"f").itemList.pipe(bt(1),dt(e=>0===e.length),Me(A),yt())}get id(){return an(this.vendorId,this.productId,this.serialNumber)}get currentConnections(){return v(this,Dn,"f").getValue()}get browserLabel(){return`${this.vendorId.toString(16).padStart(4,"0")}:${this.productId.toString(16).padStart(4,"0")}`}}Rn=Mn,Dn=new WeakMap,Hn=function(e,t){return v(Mn,Rn,"f",jn).indexOf(e.type)-v(Mn,Rn,"f",jn).indexOf(t.type)},jn={value:[_n.USB,_n.INDIRECT,_n.BLUETOOTH]};class Fn{constructor(e){this.deviceObservables=new St(e)}static exceptionToUndefined(e){try{return e()}catch(e){if(e instanceof It)return;throw e}}connectionExists(e){return void 0!==Fn.exceptionToUndefined(()=>this.findConnectionById(e))}findConnectionById(e){for(const t of this.deviceObservables.getValue())for(const n of t.currentConnections)if(n.id.equals(e))return n;throw new It("Could not find connection with id "+e.toString(),$e.UNEXPECTED_ERROR)}findDeviceByDeviceId(e){return this.deviceObservables.getValue().find(t=>t.id.startsWith(e)||e.startsWith(t.id))}}class Bn{constructor(e,t){this.logger=t;const[n,r]=(i=e.pipe(rt(e=>!this.deviceCollection.connectionExists(e.connection.id)),ct(e=>this.force(e))),[rt(o=({event:e,pid:t,serialNumber:n})=>!this.deviceCollection.findDeviceByDeviceId(an(e.event.vid,t,n)),a)(_e(i)),rt(nt(o,a))(_e(i))]);var i,o,a;const s=n.pipe(Me(e=>Bn.createDevice(e,r)));this.deviceCollection=new Fn(s),this.deviceObservables=this.deviceCollection.deviceObservables}force(e){const{name:t,pid:n,serialNumber:r}=e.event,i=e.connection.onDisconnect.pipe((o=Le(()=>new Error(`Connection with ID ${e.connection.id} disconnected`)),g(a)?ct((function(){return o}),a):ct((function(){return o}))));var o,a;return at(t,n,r).pipe(Me(([t,n,r])=>({event:e,name:t,pid:n,serialNumber:r})),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length?K((function(t,n){ot(f([t],l(e)))(n)})):Y}(i),st(e=>(kt("Failed to retrieve child connection information. Error: "+e,this.logger,Ke.WARNING,ze.JS_LIB),ce)))}static createDevice(e,t){const{event:n,pid:r,name:i,serialNumber:o}=e,{vid:a,deviceType:s}=n.event,c=t.pipe(rt(t=>Bn.isSameDevice(e,t)),Me(e=>e.event.connection)),u=Ye(Ae(n.connection),c);return new Mn(a,r,o,i,s,u)}static isSameDevice(e,t){const n=an(e.event.event.vid,e.pid,e.serialNumber),r=an(t.event.event.vid,t.pid,t.serialNumber);return n.startsWith(r)||r.startsWith(n)}static create(e,t){const n=new Nn(e,t);return new Bn(n.connectionEvents)}}function Gn(e){var t,n,r;return s(this,void 0,void 0,(function*(){const i=null==e?void 0:e.logger;kt("Jabra SDK JS starting up...",i,Ke.INFO);const o=new Rt(e);o.validateOrganizationKey(),o.validateAppId(),o.validateAppName();const a=null!==(n=null===(t=null==e?void 0:e.internal)||void 0===t?void 0:t.testDeviceTransport)&&void 0!==n?n:yield Lt(i,null==e?void 0:e.transport,null===(r=null==e?void 0:e.internal)||void 0===r?void 0:r.recorder);new Pt(a,i);const s=Bn.create(a,i),c=new xt(s,a,e);return yield a.connect(),c}))}class Yn{constructor(e,t,n,r){this.deviceId=e,this.usagePage=t,this.usage=n,this.value=r}}class Vn{constructor(e,t){this.token=e,this.value=t}}!function(e){e.UsageReport=class{constructor(e,t){this.usage=e,this.value=t}}}(Un||(Un={}));var Wn,qn,Kn,zn,$n,Jn,Xn,Qn,Zn,er,tr=Zt((function(e){!function(t){var n=function(e,t,n){if(!(e instanceof ArrayBuffer||void 0!==i&&e instanceof i))throw new Error("Must specify a valid ArrayBuffer or Buffer.");t=t||0,n=n||e.byteLength||e.length,this._view=new Uint8Array(e.buffer||e,t,n),this.bigEndian=!1};n._scratch=new DataView(new ArrayBuffer(8)),Object.defineProperty(n.prototype,"buffer",{get:function(){return void 0!==i?i.from(this._view.buffer):this._view.buffer},enumerable:!0,configurable:!1}),Object.defineProperty(n.prototype,"byteLength",{get:function(){return this._view.length},enumerable:!0,configurable:!1}),n.prototype._setBit=function(e,t){t?this._view[e>>3]|=1<<(7&e):this._view[e>>3]&=~(1<<(7&e))},n.prototype.getBits=function(e,t,n){var r=8*this._view.length-e;if(t>r)throw new Error("Cannot get "+t+" bit(s) from offset "+e+", "+r+" available");for(var i=0,o=0;o<t;){var a=t-o,s=7&e,c=this._view[e>>3],u=Math.min(a,8-s);this.bigEndian?(i<<=u,i|=c>>8-u-s&~(255<<u)):i|=(c>>s&~(255<<u))<<o,e+=u,o+=u}return n?(32!==t&&i&1<<t-1&&(i|=-1^(1<<t)-1),i):i>>>0},n.prototype.setBits=function(e,t,n){var r=8*this._view.length-e;if(n>r)throw new Error("Cannot set "+n+" bit(s) from offset "+e+", "+r+" available");for(var i=0;i<n;){var o,a,s,c=n-i,u=7&e,l=e>>3,f=Math.min(c,8-u);if(this.bigEndian){a=t>>n-i-f&(o=~(-1<<f));var h=8-u-f;s=~(o<<h),this._view[l]=this._view[l]&s|a<<h}else a=t&(o=~(255<<f)),t>>=f,s=~(o<<u),this._view[l]=this._view[l]&s|a<<u;e+=f,i+=f}},n.prototype.getBoolean=function(e){return 0!==this.getBits(e,1,!1)},n.prototype.getInt8=function(e){return this.getBits(e,8,!0)},n.prototype.getUint8=function(e){return this.getBits(e,8,!1)},n.prototype.getInt16=function(e){return this.getBits(e,16,!0)},n.prototype.getUint16=function(e){return this.getBits(e,16,!1)},n.prototype.getInt32=function(e){return this.getBits(e,32,!0)},n.prototype.getUint32=function(e){return this.getBits(e,32,!1)},n.prototype.getFloat32=function(e){return n._scratch.setUint32(0,this.getUint32(e)),n._scratch.getFloat32(0)},n.prototype.getFloat64=function(e){return n._scratch.setUint32(0,this.getUint32(e)),n._scratch.setUint32(4,this.getUint32(e+32)),n._scratch.getFloat64(0)},n.prototype.setBoolean=function(e,t){this.setBits(e,t?1:0,1)},n.prototype.setInt8=n.prototype.setUint8=function(e,t){this.setBits(e,t,8)},n.prototype.setInt16=n.prototype.setUint16=function(e,t){this.setBits(e,t,16)},n.prototype.setInt32=n.prototype.setUint32=function(e,t){this.setBits(e,t,32)},n.prototype.setFloat32=function(e,t){n._scratch.setFloat32(0,t),this.setBits(e,n._scratch.getUint32(0),32)},n.prototype.setFloat64=function(e,t){n._scratch.setFloat64(0,t),this.setBits(e,n._scratch.getUint32(0),32),this.setBits(e+32,n._scratch.getUint32(4),32)},n.prototype.getArrayBuffer=function(e,t){for(var n=new Uint8Array(t),r=0;r<t;r++)n[r]=this.getUint8(e+8*r);return n};var r=function(e,t){return function(){if(this._index+t>this._length)throw new Error("Trying to read past the end of the stream");var n=this._view[e](this._index);return this._index+=t,n}},o=function(e,t){return function(n){this._view[e](this._index,n),this._index+=t}};function a(e,t,n){if(0===t)return"";var r=0,i=[],o=!0,a=!!t;for(t||(t=Math.floor((e._length-e._index)/8));r<t;){var s=e.readUint8();if(0===s&&(o=!1,!a))break;o&&i.push(s),r++}var c=String.fromCharCode.apply(null,i);if(!n)return c;try{return decodeURIComponent(escape(c))}catch(e){return c}}var s=function(e,t,r){var o=e instanceof ArrayBuffer||void 0!==i&&e instanceof i;if(!(e instanceof n||o))throw new Error("Must specify a valid BitView, ArrayBuffer or Buffer");this._view=o?new n(e,t,r):e,this._index=0,this._startIndex=0,this._length=8*this._view.byteLength};Object.defineProperty(s.prototype,"index",{get:function(){return this._index-this._startIndex},set:function(e){this._index=e+this._startIndex},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"length",{get:function(){return this._length-this._startIndex},set:function(e){this._length=e+this._startIndex},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"bitsLeft",{get:function(){return this._length-this._index},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"byteIndex",{get:function(){return Math.ceil(this._index/8)},set:function(e){this._index=8*e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"buffer",{get:function(){return this._view.buffer},enumerable:!0,configurable:!1}),Object.defineProperty(s.prototype,"view",{get:function(){return this._view},enumerable:!0,configurable:!1}),Object.defineProperty(s.prototype,"bigEndian",{get:function(){return this._view.bigEndian},set:function(e){this._view.bigEndian=e},enumerable:!0,configurable:!1}),s.prototype.readBits=function(e,t){var n=this._view.getBits(this._index,e,t);return this._index+=e,n},s.prototype.writeBits=function(e,t){this._view.setBits(this._index,e,t),this._index+=t},s.prototype.readBoolean=r("getBoolean",1),s.prototype.readInt8=r("getInt8",8),s.prototype.readUint8=r("getUint8",8),s.prototype.readInt16=r("getInt16",16),s.prototype.readUint16=r("getUint16",16),s.prototype.readInt32=r("getInt32",32),s.prototype.readUint32=r("getUint32",32),s.prototype.readFloat32=r("getFloat32",32),s.prototype.readFloat64=r("getFloat64",64),s.prototype.writeBoolean=o("setBoolean",1),s.prototype.writeInt8=o("setInt8",8),s.prototype.writeUint8=o("setUint8",8),s.prototype.writeInt16=o("setInt16",16),s.prototype.writeUint16=o("setUint16",16),s.prototype.writeInt32=o("setInt32",32),s.prototype.writeUint32=o("setUint32",32),s.prototype.writeFloat32=o("setFloat32",32),s.prototype.writeFloat64=o("setFloat64",64),s.prototype.readASCIIString=function(e){return function(e,t){return a(e,t,!1)}(this,e)},s.prototype.readUTF8String=function(e){return function(e,t){return a(e,t,!0)}(this,e)},s.prototype.writeASCIIString=function(e,t){!function(e,t,n){for(var r=n||t.length+1,i=0;i<r;i++)e.writeUint8(i<t.length?t.charCodeAt(i):0)}(this,e,t)},s.prototype.writeUTF8String=function(e,t){!function(e,t,n){for(var r=function(e){var t,n,r=[];for(t=0;t<e.length;t++)(n=e.charCodeAt(t))<=127?r.push(n):n<=2047?(r.push(n>>6|192),r.push(63&n|128)):n<=65535?(r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)):(r.push(n>>18|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128));return r}(t),i=n||r.length+1,o=0;o<i;o++)e.writeUint8(o<r.length?r[o]:0)}(this,e,t)},s.prototype.readBitStream=function(e){var t=new s(this._view);return t._startIndex=this._index,t._index=this._index,t.length=e,this._index+=e,t},s.prototype.writeBitStream=function(e,t){var n;for(t||(t=e.bitsLeft);t>0;)n=Math.min(t,32),this.writeBits(e.readBits(n),n),t-=n},s.prototype.readArrayBuffer=function(e){var t=this._view.getArrayBuffer(this._index,e);return this._index+=8*e,t},s.prototype.writeArrayBuffer=function(e,t){this.writeBitStream(new s(e),8*t)},e.exports&&(e.exports={BitView:n,BitStream:s})}()}));function nr(){return s(this,void 0,void 0,(function*(){const{hid:e}=window.navigator;if(!e)throw new It("WebHID not supported",$e.INIT_ERROR);const t=yield e.requestDevice({filters:[{vendorId:Wn.VENDOR_ID}]});return new BroadcastChannel(Wn.PAIRING_CHANNEL).postMessage(null),t}))}!function(e){e[e.VENDOR_ID=2830]="VENDOR_ID",e.PAIRING_CHANNEL="jabra-webhid-pairing-channel"}(Wn||(Wn={})),function(e){e[e.HOOK_SWITCH=32]="HOOK_SWITCH",e[e.GN_PSEUDO_HOOK_SWITCH=65531]="GN_PSEUDO_HOOK_SWITCH",e[e.FLASH=33]="FLASH",e[e.ALT_HOLD=35]="ALT_HOLD",e[e.REDIAL=36]="REDIAL",e[e.ONLINE=42]="ONLINE",e[e.SPEAKER_PHONE=43]="SPEAKER_PHONE",e[e.PHONE_MUTE=47]="PHONE_MUTE",e[e.SEND=49]="SEND",e[e.SPEED_DIAL=80]="SPEED_DIAL",e[e.VOICE_MAIL=112]="VOICE_MAIL",e[e.ANSWER_ON_OFF=116]="ANSWER_ON_OFF",e[e.LINE_BUSY=151]="LINE_BUSY",e[e.RINGER=158]="RINGER",e[e.PHONE_KEY_0=176]="PHONE_KEY_0",e[e.PHONE_KEY_1=177]="PHONE_KEY_1",e[e.PHONE_KEY_2=178]="PHONE_KEY_2",e[e.PHONE_KEY_3=179]="PHONE_KEY_3",e[e.PHONE_KEY_4=180]="PHONE_KEY_4",e[e.PHONE_KEY_5=181]="PHONE_KEY_5",e[e.PHONE_KEY_6=182]="PHONE_KEY_6",e[e.PHONE_KEY_7=183]="PHONE_KEY_7",e[e.PHONE_KEY_8=184]="PHONE_KEY_8",e[e.PHONE_KEY_9=185]="PHONE_KEY_9",e[e.PHONE_KEY_STAR=186]="PHONE_KEY_STAR",e[e.PHONE_KEY_POUND=187]="PHONE_KEY_POUND",e[e.ALT_VOLUME_UP=233]="ALT_VOLUME_UP",e[e.ALT_VOLUME_DOWN=234]="ALT_VOLUME_DOWN",e[e.REJECT_CALL=65533]="REJECT_CALL"}(qn||(qn={}));class rr{constructor(e,t,n){this.type=e,this.value=t,this.valueType=n}toString(){return void 0===qn[this.type]?`Unknown signal: type: ${this.type}, value: ${this.value}, valueType: ${this.valueType}`:`Signal: type: ${qn[this.type]}, value: ${this.value}, valueType: ${this.valueType}`}}!function(e){e[e.BUTTON=9]="BUTTON",e[e.CONSUMER=12]="CONSUMER",e[e.LED=8]="LED",e[e.TELEPHONY=11]="TELEPHONY",e[e.GN_CONSUMER=65312]="GN_CONSUMER",e[e.GN_EXT_BUTTONS=65360]="GN_EXT_BUTTONS",e[e.GN_LED=65344]="GN_LED",e[e.GN_MISC=65376]="GN_MISC",e[e.GN_TELEPHONY=65328]="GN_TELEPHONY"}(Kn||(Kn={})),function(e){e[e.MUTE=9]="MUTE",e[e.OFF_HOOK=23]="OFF_HOOK",e[e.RING=24]="RING",e[e.MESSAGE_WAIT=25]="MESSAGE_WAIT",e[e.HOLD=32]="HOLD",e[e.MIC_MUTE=33]="MIC_MUTE",e[e.ONLINE=42]="ONLINE",e[e.HID_OFFLINE=43]="HID_OFFLINE"}(zn||(zn={})),function(e){e[e.HOOK_SWITCH=32]="HOOK_SWITCH",e[e.FLASH=33]="FLASH",e[e.HOLD=35]="HOLD",e[e.REDIAL=36]="REDIAL",e[e.ONLINE=42]="ONLINE",e[e.SPEAKER_PHONE=43]="SPEAKER_PHONE",e[e.MUTE=47]="MUTE",e[e.HID_SEND=49]="HID_SEND",e[e.SPEED_DIAL=80]="SPEED_DIAL",e[e.VOICE_MAIL=112]="VOICE_MAIL",e[e.ANSWER_ON_OFF=116]="ANSWER_ON_OFF",e[e.LINE_BUSY=151]="LINE_BUSY",e[e.RINGER=158]="RINGER",e[e.PHONE_KEY_0=176]="PHONE_KEY_0",e[e.PHONE_KEY_1=177]="PHONE_KEY_1",e[e.PHONE_KEY_2=178]="PHONE_KEY_2",e[e.PHONE_KEY_3=179]="PHONE_KEY_3",e[e.PHONE_KEY_4=180]="PHONE_KEY_4",e[e.PHONE_KEY_5=181]="PHONE_KEY_5",e[e.PHONE_KEY_6=182]="PHONE_KEY_6",e[e.PHONE_KEY_7=183]="PHONE_KEY_7",e[e.PHONE_KEY_8=184]="PHONE_KEY_8",e[e.PHONE_KEY_9=185]="PHONE_KEY_9",e[e.PHONE_KEY_STAR=186]="PHONE_KEY_STAR",e[e.PHONE_KEY_POUND=187]="PHONE_KEY_POUND",e[e.HID_ALT_VOLUME_UP=233]="HID_ALT_VOLUME_UP",e[e.HID_ALT_VOLUME_DOWN=234]="HID_ALT_VOLUME_DOWN",e[e.GN_PSEUDO_HOOK_SWITCH=65531]="GN_PSEUDO_HOOK_SWITCH",e[e.GN_OUT_OF_RANGE=65532]="GN_OUT_OF_RANGE",e[e.GN_REJECT_CALL=65533]="GN_REJECT_CALL",e[e.GN_TELEPHONY_CONT_SET=65535]="GN_TELEPHONY_CONT_SET"}($n||($n={}));class ir{constructor(e,t,n,r,i){this.hidChannel=e,this.onDisconnect=t,this.isSoftphoneInFocus=n,this.lockHeld=r,this.logger=i,this.cachedSignals=new Map}setup(){const e=this.filter().pipe(yt());return e.subscribe(),e}filter(){const e=this.hidChannel.input.pipe(rt(e=>e.usagePage===Kn.GN_TELEPHONY&&!e.isArray()),Fe(e=>{const t=this.hidChannel.findDescriptor(e.usagePage,e.usage,en.INPUT);return(null==t?void 0:t.valueType)?Ae(Object.assign(Object.assign({},e),{valueType:t.valueType})):(Ln("",new It(`Unable to find value-type in descriptor for UsagePage: ${e.usagePage} and Usage: ${e.usage}`,$e.FEATURE_NOT_SUPPORTED),this.logger),ce)}),rt(e=>e.valueType===tn.RELATIVE?Boolean(e.value):this.cachedSignals.get(e.usage)!==e.value),_t(e=>{this.cachedSignals.set(e.usage,e.value)}),Ct(this.onDisconnect),yt()),t=[qn.HOOK_SWITCH,qn.REDIAL],n=e.pipe(function(e){return t=>t.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fe(e);return K((function(t,r){for(var i=e.length,o=new Array(i),a=e.map((function(){return!1})),s=!1,c=function(t){_e(e[t]).subscribe(z(r,(function(e){o[t]=e,s||a[t]||(a[t]=!0,(s=a.every(Y))&&(a=null))}),A))},u=0;u<i;u++)c(u);t.subscribe(z(r,(function(e){if(s){var t=f([e],l(o));r.next(n?n.apply(void 0,f([],l(t))):t)}})))}))}(e),rt(([e,t])=>t),Me(([e,t])=>e))}(this.isSoftphoneInFocus),rt(e=>t.includes(e.usage)&&!this.lockHeld.getValue()));return qe(e.pipe(rt(e=>this.lockHeld.getValue())),n).pipe(Me(e=>new rr(e.usage,0!==e.value,e.valueType)),st(e=>(kt(e.message,this.logger),ce)))}}class or{constructor(e,t,n,r,i,o){this.device=e,this.onDisconnect=n,Jn.set(this,void 0),Xn.set(this,new Z(!1)),Qn.set(this,void 0),Zn.set(this,!1),this.deviceSignals=new X,y(this,Jn,r,"f"),v(this,Jn,"f").lockHeld.subscribe(v(this,Xn,"f")),y(this,Qn,t,"f"),this.onDisconnect.pipe(dt(),Me(()=>!0)).subscribe(e=>{y(this,Zn,e,"f")});const a=new ir(v(this,Qn,"f"),this.onDisconnect,i,v(this,Xn,"f"),o);this.deviceSignals=a.setup()}checkCallLockHeld(e){if(!v(this,Xn,"f").getValue())throw new It(e,$e.SDK_USAGE_ERROR)}checkCallLockNotHeld(e){if(v(this,Xn,"f").getValue())throw new It(e,$e.SDK_USAGE_ERROR)}checkHasDisconnected(){if(v(this,Zn,"f"))throw new It("CallControl cannot be performed as the connection has disconnected.",$e.SDK_USAGE_ERROR)}takeCallLock(){return this.checkHasDisconnected(),this.checkCallLockNotHeld("Trying to take the call lock, but it is already held!"),Ne(v(this,Jn,"f").tryTakeCallLock())}releaseCallLock(){this.checkHasDisconnected(),this.checkCallLockHeld("Trying to release the call lock, but it is not held!"),v(this,Jn,"f").releaseCallLock()}offHook(e){this.checkHasDisconnected(),this.checkCallLockHeld("Calls can only be started and stopped when the call lock is held.");const t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.OFF_HOOK,en.OUTPUT);if(!t)throw new It(`Device ${this.device.name} does not support any offHook functionality.`,$e.FEATURE_NOT_SUPPORTED);const n=e?1:0;v(this,Qn,"f").output(t.usagePage,t.usage,n)}ring(e){this.checkHasDisconnected(),this.checkCallLockHeld("The ringer state can only be modified when the call lock is held.");const t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.RING,en.OUTPUT),n=v(this,Qn,"f").findDescriptor(Kn.GN_TELEPHONY,$n.RINGER,en.OUTPUT);if(!t&&!n)throw new It(`Device ${this.device.name} does not support any ring functionality.`,$e.FEATURE_NOT_SUPPORTED);if(n){const t=e?1:0;v(this,Qn,"f").output(n.usagePage,n.usage,t)}if(t){const n=e?1:0;v(this,Qn,"f").output(t.usagePage,t.usage,n)}}mute(e){this.checkHasDisconnected(),this.checkCallLockHeld("The mute state can only be modified when the call lock is held.");let t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.MIC_MUTE,en.OUTPUT);if(t||(t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.MUTE,en.OUTPUT)),!t)throw new It(`Device ${this.device.name} does not support any mute functionality.`,$e.FEATURE_NOT_SUPPORTED);const n=e?1:0;v(this,Qn,"f").output(t.usagePage,t.usage,n)}hold(e){this.checkHasDisconnected(),this.checkCallLockHeld("The hold state can only be modified when the call lock is held.");const t=v(this,Qn,"f").findDescriptor(Kn.GN_LED,zn.HOLD,en.OUTPUT);if(!t)throw new It(`Device ${this.device.name} does not support hold functionality.`,$e.FEATURE_NOT_SUPPORTED);const n=e?1:0;v(this,Qn,"f").output(t.usagePage,t.usage,n)}}Jn=new WeakMap,Xn=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,function(e){e[e.STD_TELEPHONY=0]="STD_TELEPHONY",e[e.GN_TELEPHONY=1]="GN_TELEPHONY"}(er||(er={}));const ar={[Dt.SKYPE]:er.GN_TELEPHONY,[Dt.CISCO]:er.GN_TELEPHONY,[Dt.AVAYA]:er.GN_TELEPHONY,[Dt.SIEMENS]:er.GN_TELEPHONY,[Dt.IBM]:er.GN_TELEPHONY,[Dt.AASTRA]:er.GN_TELEPHONY,[Dt.JABRA]:er.GN_TELEPHONY,[Dt.NEC]:er.GN_TELEPHONY,[Dt.SHORETEL]:er.GN_TELEPHONY,[Dt.MS_OC]:er.STD_TELEPHONY,[Dt.ALCATEL]:er.STD_TELEPHONY,[Dt.OTHER]:er.STD_TELEPHONY,[Dt.NORTEL]:null,[Dt.GENERIC]:null};class sr{constructor(e,t,n){this.connectionCallLock=e,this.device=t,this.logger=n,this.lockHeld=new Z(!1),this.currentLocks=new Z(new Set),this.lockReleaseEvent=new X}tryTakeCallLock(){const{currentConnections:e}=this.device,t=new Set,n=Ve(()=>xe(e).pipe(ct(e=>this.takeSingleCallLock(e).pipe(st(e=>(Ln("DeviceCallLock:",e,this.logger),Ae(""))))),_t(e=>t.add(e)))).pipe(function(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?rt((function(t,n){return e(t,n,r)})):Y,pt(1),n?ut(t):ft((function(){return new Pe})))}}(),Me(n=>(t.delete(""),this.currentLocks.next(t),t.size!==e.length?(this.releaseCallLock(),!1):(this.lockHeld.next(!0),!0))),mt());return n.subscribe(e=>{e&&(this.acquireLockOnNextConnectionEmit(),this.releaseLockOnRemovedConnectionEmit())}),n}acquireLockOnNextConnectionEmit(){this.device.connectionAdded.pipe(Ct(this.lockReleaseEvent)).subscribe(e=>{this.takeSingleCallLock(e).pipe(Ct(this.lockReleaseEvent),Me(e=>(this.currentLocks.getValue().add(e),this.currentLocks.next(this.currentLocks.getValue()),A)),vt(On())).subscribe({error:e=>{kt("Failed to acquire the call lock on a new connection.\n Another softphone running an old SDK has most likely acquired this lock.\n Full error: "+e,this.logger,Ke.WARNING,ze.JS_LIB)}})})}releaseLockOnRemovedConnectionEmit(){this.device.connectionRemoved.pipe(Ct(this.lockReleaseEvent)).subscribe(e=>this.releaseSingleCallLock(e.id.transportId))}takeSingleCallLock(e){return Ve(()=>this.connectionCallLock.tryTakeCallLock(e.id.transportId)).pipe(Me(t=>t.acquired?Ae(t.transportId):Le(()=>new It("Failed to acquire call lock on connection "+e.id.transportId,$e.SDK_USAGE_ERROR))),Et())}releaseCallLock(){this.lockReleaseEvent.next(),[...this.currentLocks.getValue()].forEach(e=>{this.releaseSingleCallLock(e)}),this.currentLocks.getValue().clear(),this.currentLocks.next(this.currentLocks.getValue())}releaseSingleCallLock(e){this.connectionCallLock.releaseCallLock(e),this.currentLocks.getValue().delete(e),this.currentLocks.next(this.currentLocks.getValue()),0!==this.currentLocks.getValue().size&&0!==this.device.currentConnections.length||(this.lockReleaseEvent.next(),this.lockHeld.next(!1))}}class cr{constructor(e){this.transport=e}tryTakeCallLock(e){const t={action:"request-call-lock",id:e};return this.transport.writeAction(t),this.transport.consoleAppEvent.pipe(rt(t=>"response-call-lock"===t.event&&t.id===e),Me(e=>({transportId:e.id,acquired:e.acquired})),dt())}releaseCallLock(e){const t={action:"release-call-lock",id:e};this.transport.writeAction(t)}}const ur=[{usagePage:Kn.GN_LED,usage:zn.OFF_HOOK,reportType:en.OUTPUT},{usagePage:Kn.GN_LED,usage:zn.RING,reportType:en.OUTPUT},{usagePage:Kn.GN_TELEPHONY,usage:$n.RINGER,reportType:en.OUTPUT},{usagePage:Kn.GN_LED,usage:zn.MIC_MUTE,reportType:en.OUTPUT},{usagePage:Kn.GN_LED,usage:zn.MUTE,reportType:en.OUTPUT},{usagePage:Kn.GN_LED,usage:zn.HOLD,reportType:en.OUTPUT}],lr=[_n.USB,_n.INDIRECT,_n.BLUETOOTH];function fr(e){const{currentConnections:t,type:n}=e;var r;return(r=t,[...r].sort((e,t)=>lr.indexOf(e.type)-lr.indexOf(t.type))).find(e=>function(e,t){const{hidChannel:n}=e;return!!function(e){return ur.some(({usagePage:t,usage:n,reportType:r})=>e.findDescriptor(t,n,r))}(n)&&(!vn.supportsGnpOverHid(n)||t!==In.DONGLE&&t!==In.OTHER)}(e,n))}function hr(e,t,n,r,i){const o=fr(e),{hidChannel:a,onDisconnect:s}=o,c=new sr(new cr(r),e,i);return t||r.context===Xe.WEB_HID?Ae(new or(e,a,s,c,n.softphoneInFocus,i)):function(e,t){return e.findDescriptor(Kn.GN_TELEPHONY,$n.GN_TELEPHONY_CONT_SET,en.FEATURE)?Ve(()=>(e.setFeatureReport(Kn.GN_TELEPHONY,$n.GN_TELEPHONY_CONT_SET,1),Ae(!0))):t?function(e,t){const n=e.read(Jt).pipe(Me(e=>ar[e]===t)),r=e.read(new Kt).pipe(Me(e=>e.find(e=>ar[e]===t))).pipe(Me(t=>t?e.write(Jt,t):Ae(!1)),Et());return n.pipe((i=Ae(!0),o=r,e=>e.pipe(Me(e=>e?i:o),Et())));var i,o}(t,er.GN_TELEPHONY):Ae(!1)}(a,o).pipe(Me(t=>new or(e,a,s,c,n.softphoneInFocus,i)))}class dr{constructor(e,t){this.devComm=e,this.softphoneInFocus=new W,this.softphoneInFocus=t.pipe(dt(),Fe(e=>this.devComm.consoleAppEvent.pipe(rt(e=>"softphone-in-focus"===e.event),Me(e=>e.infocus),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=he(e);return K((function(t,r){(n?Ye(e,t,n):Ye(e,t)).subscribe(r)}))}(!e),mt(1)))),this.softphoneInFocus.subscribe(()=>{})}setSharedSoftphoneInfo(e){if(!(null==e?void 0:e.partnerKey)||!(null==e?void 0:e.appId))return void kt("Unable to register with Jabra Direct: partnerKey or appId missing in config",null==e?void 0:e.logger,Ke.WARNING);const t=e.partnerKey+e.appId,n=new nn(5,"ns:OID",t);let{appName:r}=e;if((!e.appName||e.appName.length<3)&&(kt("App name missing in config. Fall back to use appId as app name.",null==e?void 0:e.logger,Ke.WARNING),r=e.appId),r.length>100)return void kt("Unable to register with Jabra Direct: appName must be below 100 characters.",null==e?void 0:e.logger,Ke.WARNING);const i={action:"set-softphone-info",name:r,id:n.toString()};this.devComm.writeAction(i)}}var pr,vr,yr,gr,mr,br,wr,Er;class Cr{constructor(e){var t;pr.set(this,void 0),vr.set(this,void 0),yr.set(this,void 0),gr.set(this,void 0),y(this,gr,e._readyEvents.pipe(dt(e=>"ready"===e.event),Me(e=>e.jabraDirectInstalled)),"f"),y(this,vr,new dr(e._transport,v(this,gr,"f")),"f"),v(this,vr,"f").setSharedSoftphoneInfo(e._config),y(this,pr,e._transport,"f"),y(this,yr,null===(t=e._config)||void 0===t?void 0:t.logger,"f")}createCallControl(e){return this.supportsCallControl(e)?Re(v(this,gr,"f").pipe(Fe(t=>hr(e,t,v(this,vr,"f"),v(this,pr,"f"),v(this,yr,"f"))))):Promise.reject(new It(`Device ${e.name} does not support call control.`,$e.FEATURE_NOT_SUPPORTED))}supportsCallControl(e){return void 0!==fr(e)}}pr=new WeakMap,vr=new WeakMap,yr=new WeakMap,gr=new WeakMap,function(e){e.HOLD_CURRENT="hold-current",e.END_CURRENT="end-current"}(mr||(mr={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted",e.NO_ONGOING_CALLS="no-ongoing-calls"}(br||(br={})),function(e){e.ON_HOLD="on-hold",e.NOT_ON_HOLD="not-on-hold",e.NO_ONGOING_CALLS="no-ongoing-calls"}(wr||(wr={})),function(e){e.NO_INCOMING="no-incoming",e.AWAITING_RESPONSE="awaiting-response",e.RESOLVING_RESPONSE="resolving-response",e.ACCEPTED="accepted",e.REJECTED="rejected"}(Er||(Er={}));new WeakMap;new WeakMap;br.NO_ONGOING_CALLS,wr.NO_ONGOING_CALLS,Er.NO_INCOMING;new WeakMap,new WeakMap;new WeakMap,new WeakMap}).call(this,n(14),n(5),n(15).Buffer)},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){return e.implementationChanged="implementationChanged",e.deviceHoldStatusChanged="deviceHoldStatusChanged",e.deviceMuteStatusChanged="deviceMuteStatusChanged",e.deviceAnsweredCall="deviceAnsweredCall",e.deviceEndedCall="deviceEndedCall",e.deviceRejectedCall="deviceRejectedCall",e.loggableEvent="loggableEvent",e.webHidPermissionRequested="webHidPermissionRequested",e.deviceConnectionStatusChanged="deviceConnectionStatusChanged",e.deviceEventLogs="deviceEventLogs",e}({})},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(4);function i(e){return(i="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 o(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 a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){f(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(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,h(r.key),r)}}function c(e,t,n){return t=u(t),function(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function f(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e){var t=function(e,t){if("object"!=i(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==i(t)?t:t+""}var d=function(e){function t(e){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),f(n=c(this,t),"vendorName","Not Specified"),f(n,"isConnecting",!1),f(n,"isConnected",!1),f(n,"isMuted",!1),f(n,"errorCode",null),f(n,"disableRetry",!1),f(n,"logger",void 0),f(n,"config",void 0);var i=new r.EventEmitter;return Object.keys(i.__proto__).forEach((function(e){n[e]=i[e]})),n.config=e,n.vendorName=e.vendorName,n.logger=e.logger,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(t,e),n=t,(i=[{key:"isDeviceAttached",get:function(){throw new Error("".concat(this.vendorName," - isDeviceAttatched getter not implemented"))}},{key:"isSupported",value:function(){return!0}},{key:"deviceLabelMatchesVendor",value:function(e){throw new Error("".concat(this.vendorName," - deviceLabelMatchesVendor() not implemented"))}},{key:"connect",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - connect() not implemented")))}},{key:"disconnect",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - disconnect() not implemented")))}},{key:"incomingCall",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - incomingCall() not implemented")))}},{key:"outgoingCall",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - outgoingCall() not implemented")))}},{key:"answerCall",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - answerCall() not implemented")))}},{key:"rejectCall",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - rejectCall() not implemented")))}},{key:"endCall",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - endCall() not implemented")))}},{key:"endAllCalls",value:function(){return Promise.reject(new Error("".concat(this.vendorName," - endAllCalls() not implemented")))}},{key:"setMute",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - setMute() not implemented")))}},{key:"setHold",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - setHold() not implemented")))}},{key:"resetHeadsetStateForCall",value:function(e){return this.rejectCall(e)}},{key:"emitEvent",value:function(e,t){this.emit(e,{vendor:this,body:a({},t)})}},{key:"requestWebHidPermissions",value:function(e){this.logger.debug("Emitting premission request event"),this.emitEvent("webHidPermissionRequested",{callback:e})}},{key:"deviceAnsweredCall",value:function(e){this.emitEvent("deviceAnsweredCall",e)}},{key:"deviceRejectedCall",value:function(e){this.emitEvent("deviceRejectedCall",e)}},{key:"deviceEndedCall",value:function(e){this.emitEvent("deviceEndedCall",e)}},{key:"deviceMuteChanged",value:function(e){this.emitEvent("deviceMuteStatusChanged",a({},e))}},{key:"deviceHoldStatusChanged",value:function(e){this.emitEvent("deviceHoldStatusChanged",a({},e))}},{key:"deviceEventLogs",value:function(e){this.emitEvent("deviceEventLogs",e)}},{key:"changeConnectionStatus",value:function(e){this.isConnected=e.isConnected,this.isConnecting=e.isConnecting,this.emitEvent("deviceConnectionStatusChanged",a({currentVendor:this},e))}},{key:"deductProductId",value:function(e){var t=null==e?void 0:e.match(/\((\w+):(\w+)\)$/);return t?parseInt(t[2],16):null}}])&&s(n.prototype,i),o&&s(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,i,o}(r.EventEmitter)},function(e,t,n){e.exports=function(){"use strict";var e="undefined"==typeof window,t=!1,n=!1,r=!1,i=!1,o=!1,a=!1,s=!1,c=!1,u=!1,l=!1;return e||(t="undefined"!=typeof InstallTrigger,n=!!window.chrome,r=!!window.chrome,i=n&&!window.chrome.webstore&&!window.chrome.runtime,o=0<Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")||window.safari&&window.safari.pushNotification,a=!!window.opr&&!!window.opr.addons||!!window.opera,s=!!window.StyleMedia,c=n&&!!navigator.userAgent.match(/edg/i),u=(r||a)&&!!window.CSS,l=!(n||o||t||a||!document.documentMode)),{get isChrome(){return r},get isChromeOrChromium(){return n},get isChromium(){return i},get isFirefox(){return t},get isSafari(){return o},get isOpera(){return a},get isEdge(){return s},get isEdgeChromium(){return c},get isIE(){return l},get isBlink(){return u}}}()},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise((function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&g(e,"error",t,n)}(e,i,{once:!0})}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function f(e,t,n,r){var i,o,a,s;if(u(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),void 0===a)a=o[t]=n,++e._eventsCount;else if("function"==typeof a?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=l(e))>0&&a.length>i&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,s=c,console&&console.warn&&console.warn(s)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=h.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):y(i,i.length)}function v(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function y(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function g(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(o){r.once&&e.removeEventListener(t,i),n(o)}))}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var u=c.length,l=y(c,u);for(n=0;n<u;++n)o(l[n],this,t)}return!0},s.prototype.addListener=function(e,t){return f(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return f(this,e,t,!0)},s.prototype.once=function(e,t){return u(t),this.on(e,d(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,d(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,o,a;if(u(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},s.prototype.listenerCount=v,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){},function(e,t){},function(e,t,n){},function(e,t,n){},function(e,t,n){var r,i,o;i=[t,e],void 0===(o="function"==typeof(r=function(e,t){"use strict";var n=5e3,r="callback";function i(){return"jsonp_"+Date.now()+"_"+Math.ceil(1e5*Math.random())}function o(e){try{delete window[e]}catch(t){window[e]=void 0}}function a(e){var t=document.getElementById(e);t&&document.getElementsByTagName("head")[0].removeChild(t)}t.exports=function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],s=e,c=t.timeout||n,u=t.jsonpCallback||r,l=void 0;return new Promise((function(n,r){var f=t.jsonpCallbackFunction||i(),h=u+"_"+f;window[f]=function(e){n({ok:!0,json:function(){return Promise.resolve(e)}}),l&&clearTimeout(l),a(h),o(f)},s+=-1===s.indexOf("?")?"?":"&";var d=document.createElement("script");d.setAttribute("src",""+s+u+"="+f),t.charset&&d.setAttribute("charset",t.charset),t.nonce&&d.setAttribute("nonce",t.nonce),t.referrerPolicy&&d.setAttribute("referrerPolicy",t.referrerPolicy),t.crossorigin&&d.setAttribute("crossorigin","true"),d.id=h,document.getElementsByTagName("head")[0].appendChild(d),l=setTimeout((function(){r(new Error("JSONP request to "+e+" timed out")),o(f),a(h),window[f]=function(){o(f)}}),c),d.onerror=function(){r(new Error("JSONP request to "+e+" failed")),o(f),a(h),l&&clearTimeout(l)}}))}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){"use strict";n.d(t,"a",(function(){return ir}));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)}function o(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function a(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}Object.create;function s(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 c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.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 a}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function l(e){return this instanceof l?(this.v=e,this):new l(e)}function f(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),o=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(e){i[e]&&(r[e]=function(t){return new Promise((function(n,r){o.push([e,t,n,r])>1||s(e,t)}))})}function s(e,t){try{(n=i[e](t)).value instanceof l?Promise.resolve(n.value.v).then(c,u):f(o[0][2],n)}catch(e){f(o[0][3],e)}var n}function c(e){s("next",e)}function u(e){s("throw",e)}function f(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function h(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=s(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}}Object.create;"function"==typeof SuppressedError&&SuppressedError;function d(e){return"function"==typeof e}function p(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 v=p((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 y(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var g=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=s(o),l=a.next();!l.done;l=a.next()){l.value.remove(this)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else o.remove(this);var f=this.initialTeardown;if(d(f))try{f()}catch(e){i=e instanceof v?e.errors:[e]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var p=s(h),y=p.next();!y.done;y=p.next()){var g=y.value;try{w(g)}catch(e){i=null!=i?i:[],e instanceof v?i=u(u([],c(i)),c(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}}if(i)throw new v(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)w(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&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)&&y(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&y(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),m=g.EMPTY;function b(e){return e instanceof g||e&&"closed"in e&&d(e.remove)&&d(e.add)&&d(e.unsubscribe)}function w(e){d(e)?e():e.unsubscribe()}var E={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},C={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=C.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,u([e,t],c(n))):setTimeout.apply(void 0,u([e,t],c(n)))},clearTimeout:function(e){var t=C.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function _(e){C.setTimeout((function(){var t=E.onUnhandledError;if(!t)throw e;t(e)}))}function I(){}var k=O("C",void 0,void 0);function O(e,t,n){return{kind:e,value:t,error:n}}var S=null;function T(e){if(E.useDeprecatedSynchronousErrorHandling){var t=!S;if(t&&(S={errorThrown:!1,error:null}),e(),t){var n=S,r=n.errorThrown,i=n.error;if(S=null,r)throw i}}else e()}var x=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,b(t)&&t.add(n)):n.destination=j,n}return i(t,e),t.create=function(e,t,n){return new N(e,t,n)},t.prototype.next=function(e){this.isStopped?D(function(e){return O("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?D(O("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?D(k,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}(g),A=Function.prototype.bind;function L(e,t){return A.call(e,t)}var P=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){R(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){R(e)}else R(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){R(e)}},e}(),N=function(e){function t(t,n,r){var i,o,a=e.call(this)||this;d(t)||!t?i={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:a&&E.useDeprecatedNextContext?((o=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},i={next:t.next&&L(t.next,o),error:t.error&&L(t.error,o),complete:t.complete&&L(t.complete,o)}):i=t;return a.destination=new P(i),a}return i(t,e),t}(x);function R(e){var t;E.useDeprecatedSynchronousErrorHandling?(t=e,E.useDeprecatedSynchronousErrorHandling&&S&&(S.errorThrown=!0,S.error=t)):_(e)}function D(e,t){var n=E.onStoppedNotification;n&&C.setTimeout((function(){return n(e,t)}))}var j={closed:!0,next:I,error:function(e){throw e},complete:I},H="function"==typeof Symbol&&Symbol.observable||"@@observable";function U(e){return e}function M(e){return 0===e.length?U:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var F=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 x||function(e){return e&&d(e.next)&&d(e.error)&&d(e.complete)}(r)&&b(r)?e:new N(e,t,n);return T((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=B(t))((function(t,r){var i=new N({next:function(t){try{e(t)}catch(e){r(e),i.unsubscribe()}},error:r,complete:t});n.subscribe(i)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[H]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return M(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=B(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 B(e){var t;return null!==(t=null!=e?e:E.Promise)&&void 0!==t?t:Promise}var G=p((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Y=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return i(t,e),t.prototype.lift=function(e){var t=new V(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new G},t.prototype.next=function(e){var t=this;T((function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=s(t.currentObservers),o=i.next();!o.done;o=i.next()){o.value.next(e)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;T((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;T((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=this.currentObservers=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,n=this.hasError,r=this.isStopped,i=this.observers;return n||r?m:(this.currentObservers=null,i.push(e),new g((function(){t.currentObservers=null,y(i,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 F;return e.source=this,e},t.create=function(e,t){return new V(e,t)},t}(F),V=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:m},t}(Y),W=n(2),q=n(3),K=n.n(q);function z(){return!!window._HostedContextFunctions}function $(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 J(e){return(J="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 X(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Q(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Z(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Z=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==J(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(J(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function ee(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function te(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){ee(o,r,i,a,s,"next",e)}function s(e){ee(o,r,i,a,s,"throw",e)}a(void 0)}))}}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(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,ce(r.key),r)}}function ie(e,t,n){return t=oe(t),function(e,t){if(t&&("object"===J(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],oe(e).constructor):t.apply(e,n))}function oe(e){return(oe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ae(e,t){return(ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function se(e,t,n){return(t=ce(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(e){var t=function(e,t){if("object"!=J(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=J(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==J(t)?t:t+""}var ue=1,le=4,fe=function(e){function t(){var e;ne(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return se(e=ie(this,t,[].concat(r)),"vendorName","CyberAcoustics"),se(e,"activeConversationId",void 0),se(e,"_deviceInfo",null),se(e,"activeDevice",void 0),se(e,"numDeviceEventListeners",0),se(e,"currentProductID",null),se(e,"headsetOutputReportId",3),se(e,"headsetInputReportId",3),se(e,"vendorInputReportId",4),se(e,"currentState",0),se(e,"isHolding",!1),se(e,"currentlDeviceLabel",void 0),se(e,"currentCallInfo",void 0),se(e,"currentCallState","callIdle"),se(e,"deviceStatus",0),se(e,"gCmdBuf",new Uint8Array([0,0])),se(e,"inputReportReportId",3),se(e,"outputReportReportId",3),se(e,"JLCommandSet",!1),se(e,"callControlSuport",!0),se(e,"flagSupport",15),se(e,"handeledInputReportIds",[e.headsetInputReportId,e.vendorInputReportId]),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ae(e,t)}(t,e),n=t,r=[{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isSupported",value:function(){return window.navigator.hid&&!z()}},{key:"deviceLabelMatchesVendor",value:function(e){this.logger.debug("CA: matchVendor");var t=e.toLowerCase();return["ac-104enc","ac-204enc","ac-304","foundever","ca essential","ca-2890"].some((function(e){return t.includes(e)}))}},{key:"connect",value:(m=te(Z().mark((function e(t){var n,r,i=this;return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=!1,this.logger.debug("CA: Connect Attempt"),this.currentlDeviceLabel=t,this.logger.debug("CA Device String = ".concat(t)),this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),e.next=7,window.navigator.hid.getDevices();case 7:if(r=e.sent,this.selectDevice(r,t),!this.activeDevice){e.next=14;break}if(this.activeDevice.opened){e.next=13;break}return e.next=13,this.activeDevice.open();case 13:this.activeDevice.opened?(n=!0,this.handleDeviceConnect(),this.logger.debug("CA: Connect SUCCESS- previously connected device")):this.logger.debug("CA: Connect FAIL- Failed connect to previously connected device");case 14:if(n){e.next=26;break}return e.prev=15,e.next=18,new Promise((function(e,n){var r=setTimeout(n,3e4);i.requestWebHidPermissions(te(Z().mark((function o(){var a,s,c;return Z().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i.logger.debug("Requesting web HID permissions"),a=i.deductProductId(t),o.next=4,window.navigator.hid.requestDevice({filters:[{vendorId:13201,productId:a||void 0}]});case 4:return s=o.sent,clearTimeout(r),o.next=8,i.connectFromHidPermissions(s,t);case 8:(c=o.sent)?e(c):n(),console.debug("CA: requestWebHidPermissions device found = ".concat(c," "));case 11:case"end":return o.stop()}}),o)}))))}));case 18:n=e.sent,e.next=26;break;case 21:return e.prev=21,e.t0=e.catch(15),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),this.logger.error("CA: WebHID permissions denied"),e.abrupt("return");case 26:case"end":return e.stop()}}),e,this,[[15,21]])}))),function(e){return m.apply(this,arguments)})},{key:"connectFromHidPermissions",value:(g=te(Z().mark((function e(t,n){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.activeDevice=null,this.selectDevice(t,n),!this.activeDevice){e.next=14;break}if(this.activeDevice.opened){e.next=6;break}return e.next=6,this.activeDevice.open();case 6:if(!this.activeDevice.opened){e.next=12;break}return this.handleDeviceConnect(),this.logger.debug("CA: Connect SUCCESS- from HIDWebPermission request "),e.abrupt("return",!0);case 12:return this.logger.debug("CA: Connect FAIL requesting WebHID permissions"),e.abrupt("return",!1);case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})},{key:"handleInputReport",value:function(e){var t=e.reportId;if(this.handeledInputReportIds.includes(t)){var n=e.data.getUint8(0),r=(e.data.getUint8(1)<<8)+n;this.logger.debug("CA received button press ".concat(this.formatHex(r)," reportID ").concat(t," from Device")),this.handleDeviceButtonPress(r,t)}}},{key:"handleDeviceConnect",value:(y=te(Z().mark((function e(){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._deviceInfo={ProductName:this.activeDevice.productName},this.handleInputReport=this.handleInputReport.bind(this),this.activeDevice.addEventListener("inputreport",this.handleInputReport),this.numDeviceEventListeners++,console.debug("Installed Device Input listener, num listeners = ".concat(this.numDeviceEventListeners," ")),this.numDeviceEventListeners>1&&(this.logger.debug("%c CA: ********************************************************","color: red"),this.logger.debug("%c CA: *****WARNING ***** MULTIPLE EVENT LISTENERS ON DEVICE!!!","color: red"),this.logger.debug("%c CA: ********************************************************","color: red")),this.currentProductID=this.activeDevice.productId,this.logger.debug("Product ID: 0x".concat(this.currentProductID.toString(16))),this.currentCallState="callIdle",this.headsetOutputReportId=this.outputReportReportId,this.headsetInputReportId=this.outputReportReportId,this.vendorInputReportId=4,this.handeledInputReportIds=[this.headsetInputReportId,this.vendorInputReportId],e.t0=this.currentProductID,e.next=4===e.t0?16:24===e.t0?21:23;break;case 16:return this.flagSupport=576,this.JLCommandSet=!0,ue=512,le=64,e.abrupt("break",25);case 21:return this.flagSupport=5,e.abrupt("break",25);case 23:return this.flagSupport=15,e.abrupt("break",25);case 25:this.logger.debug("flagSupport = ".concat(this.formatHex(this.flagSupport)," ")),this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 27:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"selectDevice",value:function(e,t){var n=this;this.logger.debug("CA: SelectDevice");var r=t.toLowerCase(),i=!1;return e.forEach((function(e){var t;if(r.includes(null==e||null===(t=e.productName)||void 0===t?void 0:t.toLowerCase())){var o,a=X(e.collections);try{for(a.s();!(o=a.n()).done;){var s=o.value;if((5===s.usage||1===s.usage)&&11===s.usagePage){n.activeDevice=e,i=!0,0!==s.inputReports.length&&(n.inputReportReportId=s.inputReports[0].reportId,n.logger.debug("CA inputReportReportId = ".concat(n.inputReportReportId))),0!==s.outputReports.length&&(n.outputReportReportId=s.outputReports[0].reportId,n.logger.debug("CA outputReportReportId = ".concat(n.outputReportReportId)));break}}}catch(e){a.e(e)}finally{a.f()}}})),i}},{key:"disconnect",value:(v=te(Z().mark((function e(){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.activeDevice){e.next=15;break}return this.logger.debug("CA: Disconnecting"),this.ChangeCallState("callEnd"),this.ChangeCallState("callIdle"),this.isMuted&&(this.setMute(!1),this.deviceMuteChanged({isMuted:!1,name:"CallUnmuted"})),this.activeDevice.removeEventListener("inputreport",this.handleInputReport),this.numDeviceEventListeners--,console.debug("Removed Device Input listener, num listeners = ".concat(this.numDeviceEventListeners," ")),e.next=10,this.activeDevice.close();case 10:this.logger.debug("CA: Device closed"),this.activeDevice=null,this._deviceInfo=null,this.currentCallState="callIdle",(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1});case 15:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"incomingCall",value:(p=te(Z().mark((function e(t){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: incomingCall"),this.currentCallInfo=t,this.activeConversationId=t.conversationId,this.ParseStateEvents(2);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"outgoingCall",value:(d=te(Z().mark((function e(t){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: outgoingCall"),this.currentCallInfo=t,this.activeConversationId=t.conversationId,this.ParseStateEvents(8);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"answerCall",value:(h=te(Z().mark((function e(t,n){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: Answer Call from UI"),this.activeConversationId=t,n&&(this.logger.debug("CA: AutoAnswer"),this.ParseStateEvents(2)),this.ParseStateEvents(7);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"rejectCall",value:(f=te(Z().mark((function e(){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: rejectCall from UI"),this.ParseStateEvents(3);case 2:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"endCall",value:(l=te(Z().mark((function e(t,n){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: endCall from UI"),this.ParseStateEvents(3);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"endAllCalls",value:(u=te(Z().mark((function e(){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: endAllCalls from UI"),this.ParseStateEvents(3);case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"setMute",value:(c=te(Z().mark((function e(t){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: setMute. Value: ".concat(t)),this.isMuted=t,this.UpdateDeviceStatus(le,t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setHold",value:(s=te(Z().mark((function e(t,n){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: setHold. Value: ".concat(n)),this.activeConversationId=t,this.isHolding=n;case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleDeviceButtonPress",value:function(e,t){if(this.activeDevice)if(t===this.headsetInputReportId){if(24===this.currentProductID){switch(e){case 1:case 5:this.isMuted=!this.isMuted,this.deviceMuteChanged({isMuted:this.isMuted,name:this.isMuted?"CallMuted":"CallUnmuted"}),this.UpdateDeviceStatus(le,this.isMuted),this.logger.debug("CA: AC304 Mute update micMuteFlag = ".concat(this.formatHex(le)," this.isMuted = ").concat(this.isMuted))}return}switch(e){case 515:case 19:this.isMuted=!this.isMuted,this.deviceMuteChanged({isMuted:this.isMuted,name:this.isMuted?"CallMuted":"CallUnmuted"}),this.setMute(this.isMuted);break;case 0:this.ParseStateEvents(5);break;case 1:this.ParseStateEvents(0);break;case 2:this.ParseStateEvents(6)}}else if(t===this.vendorInputReportId)switch(e){case 2:this.ParseStateEvents(1)}else console.debug("CA: Unhandeled input report #".concat(t.toString(16)));else this.logger.error("do not have active device")}},{key:"ParseStateEvents",value:function(e){switch(this.currentCallState){case"callIdle":switch(e){case 2:this.ChangeCallState("callIncoming");break;case 8:this.ChangeCallState("callOutgoing")}break;case"callIncoming":switch(e){case 0:case 7:this.ChangeCallState("callAnswering");break;case 5:case 3:this.ChangeCallState("callRejecting"),this.ChangeCallState("callEnd"),this.ChangeCallState("callIdle")}break;case"callAnswering":switch(e){case 1:this.ChangeCallState("callActive");break;case 3:case 5:this.ChangeCallState("callEnd"),this.ChangeCallState("callIdle")}break;case"callActive":case"callOutgoing":switch(e){case 3:case 6:this.ChangeCallState("callEnd"),this.ChangeCallState("callIdle")}}}},{key:"ChangeCallState",value:function(e){switch(this.logger.debug("%cCA SETTING STATE: ".concat(e),"color: red"),this.currentCallState=e,this.currentCallState){case"callIdle":this.deviceStatus=0;break;case"callIncoming":this.UpdateDeviceStatus(8,!0);break;case"callOutgoing":case"callAnswering":this.UpdateDeviceStatus(ue,!0),this.isMuted&&(this.setMute(!1),this.deviceMuteChanged({isMuted:!1,name:"CallUnmuted"}));break;case"callActive":this.UpdateDeviceStatus(8,!1),this.deviceAnsweredCall({name:"CallOffHook",conversationId:this.activeConversationId});break;case"callEnd":this.UpdateDeviceStatus(ue,!1),this.deviceEndedCall({name:"CallOnHook",conversationId:this.activeConversationId});break;case"callRejecting":this.UpdateDeviceStatus(8,!1),this.deviceRejectedCall({name:"CallRejected",conversationId:this.activeConversationId})}}},{key:"UpdateDeviceStatus",value:function(e,t){e&this.flagSupport?(this.deviceStatus=t?this.deviceStatus|e:this.deviceStatus&~e,this.SendCommandToDevice(this.deviceStatus)):console.debug("CA: UpdateDeviceStatus called with unsupported flag ".concat(e.toString(16),"... returning"))}},{key:"SendCommandToDevice",value:(a=te(Z().mark((function e(t){return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.JLCommandSet?(this.gCmdBuf[0]=t>>8,this.gCmdBuf[1]=255&t):this.gCmdBuf[0]=t,e.next=3,this.activeDevice.sendReport(this.headsetOutputReportId,this.gCmdBuf);case 3:this.logger.debug("CA: Sent Command to Device. Value: ".concat(this.formatHex(this.gCmdBuf[0]),", ").concat(this.formatHex(this.gCmdBuf[1])," ")),this.gCmdBuf[0]=0,this.gCmdBuf[1]=0;case 6:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"formatHex",value:function(e){return"0x".concat(e.toString(16).padStart(2,"0"))}},{key:"HidMockDeviceInit",value:(o=te(Z().mark((function e(){var t;return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.getDevices();case 2:return t=e.sent,this.activeDevice=t[0],e.abrupt("return",this.activeDevice);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_currentCallState",get:function(){return this.currentCallState},set:function(e){this.currentCallState=e}},{key:"_deviceStatus",get:function(){return this.deviceStatus},set:function(e){this.deviceStatus=e}},{key:"_activeConversationId",get:function(){return this.activeConversationId}},{key:"_currentCallInfo",get:function(){return this.currentCallInfo}},{key:"holdState",get:function(){return this.isHolding}},{key:"_headsetInputReportId",get:function(){return this.headsetInputReportId}},{key:"_vendorInputReportId",get:function(){return this.vendorInputReportId}},{key:"_headsetOutputReportId",get:function(){return this.headsetOutputReportId}},{key:"muteState",get:function(){return this.isMuted},set:function(e){this.isMuted=e}},{key:"_JLCommandSet",set:function(e){this.JLCommandSet=e}},{key:"_handeledInputReportIds",set:function(e){this.handeledInputReportIds[0]=e}},{key:"_flagSupport",set:function(e){this.flagSupport=e}},{key:"_currentProductID",set:function(e){this.currentProductID=e}}],i=[{key:"getInstance",value:function(e){return t.instance||(t.instance=new t(e)),t.instance}}],r&&re(n.prototype,r),i&&re(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d,p,v,y,g,m}(W.a);se(fe,"instance",void 0);var he=n(10),de=n.n(he),pe=function(e){return 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",e}({});function ve(e){return(ve="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 ye(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 ge(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ye(Object(n),!0).forEach((function(t){ke(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ye(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function me(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */me=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==ve(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(ve(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function be(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function we(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){be(o,r,i,a,s,"next",e)}function s(e){be(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Ee(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,Oe(r.key),r)}}function Ce(e,t,n){return t=_e(t),function(e,t){if(t&&("object"===ve(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],_e(e).constructor):t.apply(e,n))}function _e(e){return(_e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ie(e,t){return(Ie=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function ke(e,t,n){return(t=Oe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Oe(e){var t=function(e,t){if("object"!=ve(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=ve(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ve(t)?t:t+""}var Se=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),ke(n=Ce(this,t,[e]),"activePollingInterval",2e3),ke(n,"connectedDeviceInterval",6e3),ke(n,"disconnectedDeviceInterval",2e3),ke(n,"deviceIdRetryInterval",2e3),ke(n,"vendorName","Plantronics"),ke(n,"pluginName",void 0),ke(n,"apiHost","https://127.0.0.1:32018/Spokes"),ke(n,"isActive",!1),ke(n,"disableEventPolling",!1),ke(n,"config",void 0),ke(n,"deviceStatusTimer",null),ke(n,"isRetry",!1),ke(n,"_deviceInfo",void 0),ke(n,"callEventsTimerId",void 0),ke(n,"deviceStatusTimerId",void 0),ke(n,"incomingConversationId",void 0),ke(n,"callMappings",{}),n.config=e,n.pluginName=e.appName||"genesys-cloud-headset-library",n._deviceInfo=null,n.callEventsTimerId=null,n.deviceStatusTimerId=null,n.incomingConversationId=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ie(e,t)}(t,e),n=t,r=[{key:"_createCallMapping",value:function(e){var t=Math.round(Math.random()*Math.pow(10,8));return this.callMappings[e]=t,this.callMappings[t]=e,this.logger.info("Created callId mapping for plantronics headset",{conversationId:e,plantronicsCallId:t}),t}},{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:(b=we(me().mark((function e(t,n){return me().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 b.apply(this,arguments)})},{key:"_fetch",value:function(e){return de()(e)}},{key:"_makeRequest",value:(m=we(me().mark((function e(n,r){var i,o=this;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.instance,e.abrupt("return",this._fetch("".concat(this.apiHost).concat(n)).then((function(e){return e.json()})).then((function(e){if(o.isConnected||o.isConnecting){if(!1===e.ok||"Error"===e.Type_Name){if(404===e.status){if(r){o.isConnected&&o.changeConnectionStatus({isConnected:!1,isConnecting:o.isConnecting}),o.disconnect();var t=new Error("Headset: Failed connection to middleware. Headset features unavailable.");return t.handled=!0,o.logger.info(t),Promise.reject(t)}return o._makeRequestTask(n,!0)}return K.a.isFirefox&&(o.errorCode="browser",o.disableRetry=!0),Promise.reject(e)}return i?(!o.isConnected&&o.changeConnectionStatus({isConnected:!0,isConnecting:o.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 m.apply(this,arguments)})},{key:"_checkIsActiveTask",value:(g=we(me().mark((function e(){var t;return me().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 g.apply(this,arguments)})},{key:"_getActiveCalls",value:(y=we(me().mark((function e(){var t,n,r,i=this;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/CallServices/CallManagerState?");case 3:r=e.sent,n=r,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=n)||void 0===t||null===(t=t.Result)||void 0===t?void 0:t.Calls)){e.next=13;break}return e.abrupt("return",[]);case 13:return e.abrupt("return",n.Result.Calls.filter((function(e){return e.Source===i.pluginName})));case 14:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return y.apply(this,arguments)})},{key:"getCallEvents",value:(v=we(me().mark((function e(){var t,n=this;return me().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=pe[e.Action];if(!t)return n.logger.info("Unknown call event from headset",{event:e});var r={name:t,event:e};n.logger.debug("headset info",r),n.callCorrespondingFunction(r)}));case 11:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(){return v.apply(this,arguments)})},{key:"getDeviceStatus",value:(p=we(me().mark((function e(){var t=this;return me().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 p.apply(this,arguments)})},{key:"callCorrespondingFunction",value:function(e){var t=e.event.CallId.Id,n=this.callMappings[t];switch(e.name){case"AcceptCall":this.deviceAnsweredCall(ge(ge({},e),{},{conversationId:n}));break;case"RejectCall":this.endCall(n),this.deviceRejectedCall({name:e.name,conversationId:this.incomingConversationId});break;case"TerminateCall":this.setMute(!1),this.setHold(n,!1),this.deviceEndedCall(ge(ge({},e),{},{conversationId:n}));break;case"CallEnded":delete this.callMappings[t],delete this.callMappings[n],this._checkIsActiveTask();break;case"Mute":this.deviceMuteChanged(ge(ge({isMuted:!0},e),{},{conversationId:n}));break;case"Unmute":this.deviceMuteChanged(ge(ge({isMuted:!1},e),{},{conversationId:n}));break;case"HoldCall":this.deviceHoldStatusChanged(ge(ge({holdRequested:!0},e),{},{conversationId:n}));break;case"ResumeCall":this.deviceHoldStatusChanged(ge(ge({holdRequested:!1},e),{},{conversationId:n}));break;default:this.logger.info("A headset event has occurred",ge(ge({},e),{},{conversationId:n})),this.deviceEventLogs(ge(ge({},e),{},{conversationId:n}))}}},{key:"unregisterPlugin",value:(d=we(me().mark((function e(){var t;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/SessionManager/UnRegister?name=".concat(this.pluginName));case 3:return e.abrupt("return",e.sent);case 6:if(e.prev=6,e.t0=e.catch(0),"Invalid plugin name"!==(null===e.t0||void 0===e.t0||null===(t=e.t0.Err)||void 0===t?void 0:t.Description)){e.next=10;break}return e.abrupt("return");case 10:this.logger.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(){return d.apply(this,arguments)})},{key:"connect",value:(h=we(me().mark((function e(){var t=this;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),this.pollForDeviceStatus(),this.pollForCallEvents(),e.next=5,this.unregisterPlugin();case 5:return e.abrupt("return",this._makeRequestTask("/SessionManager/Register?name=".concat(this.pluginName)).catch((function(e){return e.Err&&"Plugin exists"===e.Err.Description?t.logger.debug("Plugin already exists",e):Promise.reject(e)})).then((function(){return t._makeRequestTask("/SessionManager/IsActive?name=".concat(t.pluginName,"&active=true"))})).catch((function(e){return e.Err&&!e.isError?t.logger.debug("Is Active",e):Promise.reject(e)})).then((function(e){return!0!==(null==e?void 0:e.Result)?Promise.reject(e):t._makeRequestTask("/UserPreference/SetDefaultSoftPhone?name=".concat(t.pluginName))})).then((function(){t.getDeviceStatus()})).then((function(){return t._getActiveCalls()})).then((function(e){if(!e.length)return t.getCallEvents();t.isActive=!0,t.logger.warn("Plantronics headset should be in vanilla state but is reporting active call state.")})).catch((function(e){return null!=e&&e.handled?t.logger.error("Unable to properly connect headset"):Promise.reject(e)})).finally((function(){t.isConnecting&&t.changeConnectionStatus({isConnected:t.isConnected,isConnecting:!1})})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"disconnect",value:(f=we(me().mark((function e(t){return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=2;break}return e.abrupt("return");case 2:if("alternativeClient"===t){e.next=5;break}return e.next=5,this.unregisterPlugin();case 5:this.clearTimeouts(),this._deviceInfo=null,this.isConnected&&this.changeConnectionStatus({isConnected:!1,isConnecting:this.isConnecting}),this.isActive=!1;case 9:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{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");var r=this._createCallMapping(t);this.incomingConversationId=t;var i="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),o='"Id":"'.concat(r,'"');if(i+="&callID={".concat(encodeURI(o),"}"),n){var a='"Name":"'.concat(n,'"');i+="&contact={".concat(encodeURI(a),"}")}return this.logger.info("params of endpoint",i),this.isActive=!0,this._makeRequestTask("/CallServices/IncomingCall".concat(i))}},{key:"outgoingCall",value:(l=we(me().mark((function e(t){var n,r,i,o,a,s;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.conversationId,r=t.contactName,n){e.next=3;break}throw new Error("Must provide conversationId");case 3:return i=this._createCallMapping(n),o="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),a='"Id":"'.concat(i,'"'),o+="&callID={".concat(encodeURI(a),"}"),r&&(s='"Name":"'.concat(r,'"'),o+="&contact={".concat(encodeURI(s),"}")),this.isActive=!0,e.next=11,this._makeRequestTask("/CallServices/OutgoingCall".concat(o));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"answerCall",value:(u=we(me().mark((function e(t,n){var r,i,o;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=3;break}return e.next=3,this.incomingCall({conversationId:t});case 3:return r=this.callMappings[t],i='"Id":"'.concat(r,'"'),o="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(i),"}"),this.isActive=!0,this.incomingConversationId=null,e.abrupt("return",this._makeRequestTask("/CallServices/AnswerCall".concat(o)));case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"rejectCall",value:function(e){return this.incomingConversationId=null,this.endCall(e)}},{key:"endCall",value:(c=we(me().mark((function e(t){var n,r,i,o;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="?name=".concat(this.pluginName),r=this.callMappings[t],i='"Id":"'.concat(r,'"'),n+="&callID={".concat(encodeURI(i),"}"),e.next=6,this._makeRequestTask("/CallServices/TerminateCall".concat(n));case 6:return o=e.sent,this.setMute(!1),this.setHold(t,!1),e.next=11,this.getCallEvents();case 11:return this._checkIsActiveTask(),e.abrupt("return",o);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"endAllCalls",value:(s=we(me().mark((function e(){var t=this;return me().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(t.callMappings[e.CallId])}));case 4:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"setMute",value:(a=we(me().mark((function e(t){var n;return me().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 a.apply(this,arguments)})},{key:"setHold",value:(o=we(me().mark((function e(t,n){var r,i,o,a;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.callMappings[t],i='"Id":"'.concat(r,'"'),o="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(i),"}"),e.next=5,this._makeRequestTask("/CallServices/".concat(n?"HoldCall":"ResumeCall").concat(o));case 5:return a=e.sent,e.abrupt("return",a);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})}],i=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],r&&Ee(n.prototype,r),i&&Ee(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d,p,v,y,g,m,b}(W.a);ke(Se,"instance",void 0);var Te=function(e){return 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",e}({}),xe=function(e){return e.Request="Request",e.Notification="Notification",e.Ack="Acknowledgement",e}({});function Ae(e){return(Ae="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 Le(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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,He(r.key),r)}}function Ne(e,t,n){return t=Re(t),function(e,t){if(t&&("object"===Ae(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],Re(e).constructor):t.apply(e,n))}function Re(e){return(Re=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function De(e,t){return(De=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function je(e,t,n){return(t=He(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function He(e){var t=function(e,t){if("object"!=Ae(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Ae(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Ae(t)?t:t+""}var Ue=function(e){function t(){var e;Le(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return je(e=Ne(this,t,[].concat(r)),"connectTimeout",5e3),je(e,"vendorName","Sennheiser"),je(e,"isActive",!1),je(e,"devices",null),je(e,"activeDeviceId",null),je(e,"websocketConnected",!1),je(e,"websocket",null),je(e,"deviceInfo",null),je(e,"ignoreAcknowledgement",!1),je(e,"webSocketOnOpen",(function(){e.websocketConnected=!0,e.logger.info("websocket open the sennheiser software")})),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&De(e,t)}(t,e),n=t,i=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],(r=[{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:"resetHeadsetStateForCall",value:function(e){return this.ignoreAcknowledgement=!0,this.endCall(e)}},{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:xe.Request,SPName:"Genesys Cloud Softphone",SPIconImage:"SPImage.ico",RedialSupport:"No",OffHookSupport:"No",MuteSupport:"Yes",DNDOption:"No"};this._sendMessage(e)}},{key:"connect",value:function(){this.ignoreAcknowledgement=!1,!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")),K.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:xe.Request}),Promise.resolve()):Promise.resolve()}},{key:"setMute",value:function(e){return this._sendMessage({Event:e?Te.MuteFromApp:Te.UnmuteFromApp,EventType:xe.Request}),Promise.resolve()}},{key:"setHold",value:function(e,t){return this._sendMessage({Event:t?Te.Hold:Te.Resume,EventType:xe.Request,CallID:e}),Promise.resolve()}},{key:"incomingCall",value:function(e){return this.ignoreAcknowledgement=!1,this._sendMessage({Event:Te.IncomingCall,EventType:xe.Request,CallID:e.conversationId}),Promise.resolve()}},{key:"answerCall",value:function(e,t){return t&&this.incomingCall({conversationId:e}),this._sendMessage({Event:Te.IncomingCallAccepted,EventType:xe.Request,CallID:e}),Promise.resolve()}},{key:"rejectCall",value:function(e){return this._sendMessage({Event:Te.IncomingCallRejected,EventType:xe.Request,CallID:e}),Promise.resolve()}},{key:"outgoingCall",value:function(e){this.ignoreAcknowledgement=!1;var t=e.conversationId;return this._sendMessage({Event:Te.OutgoingCall,EventType:xe.Request,CallID:t}),Promise.resolve()}},{key:"endCall",value:function(e,t){return t||(this._sendMessage({Event:Te.Resume,EventType:xe.Request}),this._sendMessage({Event:Te.UnmuteFromApp,EventType:xe.Request})),this._sendMessage({Event:Te.CallEnded,EventType:xe.Request,CallID:e}),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=t.CallID;if(!this.ignoreAcknowledgement)switch(t.Event){case Te.SocketConnected:this._registerSoftphone();break;case Te.EstablishConnection:this._sendMessage({Event:Te.SPLogin,EventType:xe.Request});break;case Te.SPLogin:this.isConnected&&!this.isConnecting||this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),this._sendMessage({Event:Te.SystemInformation,EventType:xe.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===xe.Notification&&this.deviceAnsweredCall({name:t.Event,conversationId:n});break;case Te.Hold:if(t.EventType===xe.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged({holdRequested:!0,name:t.Event,conversationId:n});break;case Te.Resume:if(t.EventType===xe.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged({holdRequested:!1,name:t.Event,conversationId:n});break;case Te.MuteFromHeadset:this.deviceMuteChanged({isMuted:!0,name:t.Event});break;case Te.UnmuteFromHeadset:this.deviceMuteChanged({isMuted:!1,name:t.Event});break;case Te.CallEnded:t.EventType===xe.Notification&&(this._sendMessage({Event:Te.UnmuteFromApp,EventType:xe.Request}),this.deviceEndedCall({name:t.Event,conversationId:n}));break;case Te.IncomingCallRejected:t.EventType===xe.Notification&&this.deviceRejectedCall({name:t.Event,conversationId:n});break;case Te.TerminateConnection:1===this.websocket.readyState&&this.websocket.close(),this.websocket=null;break;default:t.EventType===xe.Ack&&this._handleAck(t)}}}}])&&Pe(n.prototype,r),i&&Pe(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i}(W.a);je(Ue,"instance",void 0);var Me=n(0),Fe=p((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Be(e,t){var n="object"==typeof t;return new Promise((function(r,i){var o=new N({next:function(e){r(e),o.unsubscribe()},error:i,complete:function(){n?r(t.defaultValue):i(new Fe)}});e.subscribe(o)}))}var Ge=function(e){function t(t,n){return e.call(this)||this}return i(t,e),t.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},t}(g),Ye={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=Ye.delegate;return(null==i?void 0:i.setInterval)?i.setInterval.apply(i,u([e,t],c(n))):setInterval.apply(void 0,u([e,t],c(n)))},clearInterval:function(e){var t=Ye.delegate;return((null==t?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},Ve=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return i(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var r=this.id,i=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(i,r,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(i,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),Ye.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!=n&&this.delay===n&&!1===this.pending)return t;null!=t&&Ye.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n,r=!1;try{this.work(e)}catch(e){r=!0,n=e||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,r=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,y(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Ge),We={now:function(){return(We.delegate||Date).now()},delegate:void 0},qe=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=We.now,e}(),Ke=new(function(e){function t(t,n){void 0===n&&(n=qe.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return i(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var n;this._active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}(qe))(Ve);function ze(e){return function(t){if(function(e){return d(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 $e="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Je(e){if(e instanceof F)return e;if(null!=e){if(function(e){return d(e[H])}(e))return c=e,new F((function(e){var t=c[H]();if(d(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if((o=e)&&"number"==typeof o.length&&"function"!=typeof o)return i=e,new F((function(e){for(var t=0;t<i.length&&!e.closed;t++)e.next(i[t]);e.complete()}));if(d(null==(r=e)?void 0:r.then))return n=e,new F((function(e){n.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,_)}));if(function(e){return Symbol.asyncIterator&&d(null==e?void 0:e[Symbol.asyncIterator])}(e))return Xe(e);if(function(e){return d(null==e?void 0:e[$e])}(e))return t=e,new F((function(e){var n,r;try{for(var i=s(t),o=i.next();!o.done;o=i.next()){var a=o.value;if(e.next(a),e.closed)return}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}e.complete()}));if(function(e){return d(null==e?void 0:e.getReader)}(e))return Xe(function(e){return f(this,arguments,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,l(t.read())];case 3:return n=i.sent(),r=n.value,n.done?[4,l(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,l(r)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e))}var t,n,r,i,o,c;throw function(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(e)}function Xe(e){return new F((function(t){(function(e,t){var n,r,i,s;return o(this,void 0,void 0,(function(){var o,c;return a(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),n=h(e),a.label=1;case 1:return[4,n.next()];case 2:if((r=a.sent()).done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=a.sent(),i={error:c},[3,11];case 6:return a.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function Qe(e,t,n,r,i){return new Ze(e,t,n,r,i)}var Ze=function(e){function t(t,n,r,i,o,a){var s=e.call(this,t)||this;return s.onFinalize=o,s.shouldUnsubscribe=a,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;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(x);var et=p((function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}}));function tt(e,t){var n,r=(n=e)instanceof Date&&!isNaN(n)?{first:e}:"number"==typeof e?{each:e}:e,i=r.first,o=r.each,a=r.with,s=void 0===a?nt:a,c=r.scheduler,u=void 0===c?null!=t?t:Ke:c,l=r.meta,f=void 0===l?null:l;if(null==i&&null==o)throw new TypeError("No timeout provided.");return ze((function(e,t){var n,r,a=null,c=0,l=function(e){r=function(e,t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=!1);var o=t.schedule((function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()}),r);if(e.add(o),!i)return o}(t,u,(function(){try{n.unsubscribe(),Je(s({meta:f,lastValue:a,seen:c})).subscribe(t)}catch(e){t.error(e)}}),e)};n=e.subscribe(Qe(t,(function(e){null==r||r.unsubscribe(),c++,t.next(a=e),o>0&&l(o)}),void 0,void 0,(function(){(null==r?void 0:r.closed)||null==r||r.unsubscribe(),a=null}))),!c&&l(null!=i?"number"==typeof i?i:+i-u.now():o)}))}function nt(e){throw new et(e)}function rt(e){return ze((function(t,n){var r=!1;t.subscribe(Qe(n,(function(e){r=!0,n.next(e)}),(function(){r||n.next(e),n.complete()})))}))}function it(e,t){return ze((function(n,r){var i=0;n.subscribe(Qe(r,(function(n){return e.call(t,n,i++)&&r.next(n)})))}))}var ot=new F((function(e){return e.complete()}));function at(e){return e<=0?function(){return ot}:ze((function(t,n){var r=0;t.subscribe(Qe(n,(function(t){++r<=e&&(n.next(t),e<=r&&n.complete())})))}))}function st(e){return void 0===e&&(e=ct),ze((function(t,n){var r=!1;t.subscribe(Qe(n,(function(e){r=!0,n.next(e)}),(function(){return r?n.complete():n.error(e())})))}))}function ct(){return new Fe}function ut(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?it((function(t,n){return e(t,n,r)})):U,at(1),n?rt(t):st((function(){return new Fe})))}}function lt(e,t){return ze((function(n,r){var i=0;n.subscribe(Qe(r,(function(n){r.next(e.call(t,n,i++))})))}))}function ft(e){return(ft="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 ht(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ht=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==ft(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(ft(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function dt(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function pt(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){dt(o,r,i,a,s,"next",e)}function s(e){dt(o,r,i,a,s,"throw",e)}a(void 0)}))}}function vt(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,wt(r.key),r)}}function yt(e,t,n){return t=gt(t),function(e,t){if(t&&("object"===ft(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],gt(e).constructor):t.apply(e,n))}function gt(e){return(gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function mt(e,t){return(mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function bt(e,t,n){return(t=wt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wt(e){var t=function(e,t){if("object"!=ft(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=ft(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ft(t)?t:t+""}var Et=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),bt(n=yt(this,t,[e]),"headsetEventSubscription",void 0),bt(n,"isActive",!1),bt(n,"_deviceInfo",void 0),bt(n,"isMuted",!1),bt(n,"isHeld",!1),bt(n,"version",null),bt(n,"_connectDeferred",void 0),bt(n,"jabraSdk",void 0),bt(n,"callControlFactory",void 0),bt(n,"callControl",void 0),bt(n,"ongoingCalls",0),bt(n,"callLock",!1),bt(n,"pendingConversationId",void 0),bt(n,"pendingConversationIsOutbound",void 0),bt(n,"activeConversationId",void 0),n.vendorName="Jabra",n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&mt(e,t)}(t,e),n=t,r=[{key:"isSupported",value:function(){return window.navigator.hid&&!z()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return!!["jabra"].some((function(e){return t.includes(e)}))}},{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"deviceName",get:function(){var e;return null===(e=this.deviceInfo)||void 0===e?void 0:e.deviceName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"resetState",value:function(){this.setHold(null,!1),this.setMute(!1)}},{key:"_processEvents",value:function(e){var t=this;this.headsetEventSubscription=e.deviceSignals.subscribe(function(){var n=pt(ht().mark((function n(r){var i,o,a,s;return ht().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(t.callLock){n.next=3;break}return t.logger.debug("Currently not in possession of the Call Lock; Cannot react to Device Actions"),n.abrupt("return");case 3:n.t0=r.type,n.next=n.t0===Me.u.HOOK_SWITCH?6:n.t0===Me.u.FLASH||n.t0===Me.u.ALT_HOLD?11:n.t0===Me.u.PHONE_MUTE?15:n.t0===Me.u.REJECT_CALL?19:23;break;case 6:if(!t.activeConversationId||!t.pendingConversationId){n.next=9;break}return t.logger.info("ignoring hookswitch event because there is an active and incoming call"),n.abrupt("break",23);case 9:if(r.value)e.offHook(!0),e.ring(!1),t.activeConversationId=t.pendingConversationId,t.pendingConversationId=null,t.pendingConversationIsOutbound||t.deviceAnsweredCall({name:"CallOffHook",code:r.type,conversationId:t.activeConversationId});else{e.mute(!1),e.hold(!1),e.offHook(!1),t.deviceEndedCall({name:"CallOnHook",code:r.type,conversationId:t.activeConversationId});try{e.releaseCallLock()}catch(e){i=e.message,o=e.type,t.checkForCallLockError(i,o)?t.logger.info(i):t.logger.error(o,i)}finally{t.activeConversationId=null,t.callLock=!1}}return n.abrupt("break",23);case 11:return t.isHeld=!t.isHeld,e.hold(t.isHeld),t.deviceHoldStatusChanged({holdRequested:t.isHeld,name:t.isHeld?"OnHold":"ResumeCall",code:r.type,conversationId:t.activeConversationId}),n.abrupt("break",23);case 15:return t.isMuted=!t.isMuted,e.mute(t.isMuted),t.deviceMuteChanged({isMuted:t.isMuted,name:t.isMuted?"CallMuted":"CallUnmuted",code:r.type,conversationId:t.activeConversationId}),n.abrupt("break",23);case 19:e.ring(!1),t.deviceRejectedCall({name:Me.u[r.type],conversationId:t.pendingConversationId}),t.pendingConversationId=null;try{t.activeConversationId||(e.releaseCallLock(),t.callLock=!1)}catch(e){a=e.message,s=e.type,t.checkForCallLockError(a,s)?t.logger.info(a):t.logger.error(s,a)}case 23:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}())}},{key:"setMute",value:(b=pt(ht().mark((function e(t){return ht().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 b.apply(this,arguments)})},{key:"setHold",value:(m=pt(ht().mark((function e(t,n){return ht().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 m.apply(this,arguments)})},{key:"incomingCall",value:(g=pt(ht().mark((function e(t){var n,r;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!1,e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:this.callLock=e.sent,e.next=13;break;case 8:e.prev=8,e.t0=e.catch(2),n=e.t0.message,r=e.t0.type,this.checkForCallLockError(n,r)?(this.logger.info(n),this.callLock=!0):this.logger.error(r,n);case 13:this.callLock&&this.callControl.ring(!0);case 14:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(e){return g.apply(this,arguments)})},{key:"answerCall",value:(y=pt(ht().mark((function e(t,n){var r,i;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=13;break}return this.pendingConversationId=t,e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:this.callLock=e.sent,e.next=13;break;case 8:e.prev=8,e.t0=e.catch(2),r=e.t0.message,i=e.t0.type,this.checkForCallLockError(r,i)?(this.logger.info(r),this.callLock=!0):this.logger.error(i,r);case 13:if(this.callLock){e.next=15;break}return e.abrupt("return");case 15:this.callControl.ring(!1),this.callControl.offHook(!0);case 17:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(e,t){return y.apply(this,arguments)})},{key:"rejectCall",value:(v=pt(ht().mark((function e(){var t,n;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 2:if(this.callControl.ring(!1),this.pendingConversationId=null,!this.activeConversationId)try{this.resetState(),this.callControl.releaseCallLock()}catch(e){t=e.message,n=e.type,this.checkForCallLockError(t,n)?this.logger.info(t):this.logger.error(n,t)}finally{this.pendingConversationId=null,this.callLock=!1}case 5:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"outgoingCall",value:(p=pt(ht().mark((function e(t){var n,r;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.callControl.takeCallLock();case 3:this.callLock=e.sent,e.next=11;break;case 6:e.prev=6,e.t0=e.catch(0),n=e.t0.message,r=e.t0.type,this.checkForCallLockError(n,r)?(this.logger.info(n),this.callLock=!0):this.logger.error(r,n);case 11:this.callLock&&(this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!0,this.callControl.offHook(!0));case 12:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(e){return p.apply(this,arguments)})},{key:"endCall",value:(d=pt(ht().mark((function e(t,n){var r,i;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:if(t===this.activeConversationId&&(this.activeConversationId=null),e.prev=3,this.callLock){e.next=6;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 6:this.callControl.offHook(!1),this.resetState(),this.callControl.releaseCallLock(),e.next=16;break;case 11:e.prev=11,e.t0=e.catch(3),r=e.t0.message,i=e.t0.type,this.checkForCallLockError(r,i)?this.logger.info(r):this.logger.error(i,r);case 16:return e.prev=16,this.callLock=!1,e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,11,16,19]])}))),function(e,t){return d.apply(this,arguments)})},{key:"endAllCalls",value:(h=pt(ht().mark((function e(){var t,n;return ht().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.activeConversationId=null,this.callControl.offHook(!1),this.resetState(),this.callControl.releaseCallLock(),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.logger.error(n,t);case 14:return e.prev=14,this.callLock=!1,e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[0,9,14,17]])}))),function(){return h.apply(this,arguments)})},{key:"isDeviceInList",value:function(e,t){var n;return t.toLowerCase().includes(null==e||null===(n=e.name)||void 0===n?void 0:n.toLowerCase())}},{key:"connect",value:(f=pt(ht().mark((function e(t){var n,r;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isConnecting){e.next=2;break}return e.abrupt("return");case 2:if(this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),this.jabraSdk){e.next=8;break}return e.next=6,this.initializeJabraSdk();case 6:this.jabraSdk=e.sent,this.callControlFactory=this.createCallControlFactory(this.jabraSdk);case 8:return n=t.toLocaleLowerCase(),this._deviceInfo=null,e.next=12,this.deviceHasPermissions(n);case 12:if(!e.sent){e.next=22;break}return e.next=15,this.getPreviouslyConnectedDevice(n);case 15:if(r=e.sent){e.next=20;break}return console.warn('Unable to find appropriate device. Setting state to "Not Running" to allow a retry"',n),this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),e.abrupt("return");case 20:e.next=32;break;case 22:return e.prev=22,e.next=25,this.getDeviceFromWebhid(n);case 25:r=e.sent,e.next=32;break;case 28:return e.prev=28,e.t0=e.catch(22),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),e.abrupt("return");case 32:return e.next=34,this.callControlFactory.createCallControl(r);case 34:return this.callControl=e.sent,e.next=37,this.resetHeadsetState();case 37:this._processEvents(this.callControl),this._deviceInfo={ProductName:r.name,deviceName:r.name,attached:!0,deviceId:r.id.toString()},this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 40:case"end":return e.stop()}}),e,this,[[22,28]])}))),function(e){return f.apply(this,arguments)})},{key:"deviceHasPermissions",value:(l=pt(ht().mark((function e(t){var n,r;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.getDevices();case 2:return n=e.sent,r=!1,n.forEach((function(e){var n;t.includes(null==e||null===(n=e.productName)||void 0===n?void 0:n.toLowerCase())&&(r=!0)})),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return l.apply(this,arguments)})},{key:"getPreviouslyConnectedDevice",value:(u=pt(ht().mark((function e(t){var n,r=this;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.jabraSdk.deviceList.pipe(rt(null),ut((function(e){return!!e.length})),lt((function(e){return e.find((function(e){return r.isDeviceInList(e,t)}))})),it((function(e){return!!e})),tt(15e3)),e.abrupt("return",Be(n).catch((function(e){return e instanceof et||e instanceof Fe?null:Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getDeviceFromWebhid",value:(c=pt(ht().mark((function e(t){var n=this;return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.requestWebHidPermissions(Me.D),e.abrupt("return",Be(this.jabraSdk.deviceList.pipe(lt((function(e){return e.find((function(e){return n.isDeviceInList(e,t)}))})),it((function(e){return!!e})),ut(),tt(3e4))).catch((function(e){return e instanceof et&&(e=new Error("The selected device was not granted WebHID permissions")),n.logger.error(e),Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"initializeJabraSdk",value:(s=pt(ht().mark((function e(){return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Object(Me.C)({appId:"softphone-vendor-headsets",appName:"Softphone Headset Library",transport:Me.z.CHROME_EXTENSION_WITH_WEB_HID_FALLBACK}));case 1:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"createCallControlFactory",value:function(e){return new Me.a(e)}},{key:"checkForCallLockError",value:function(e,t){return t===Me.b.SDK_USAGE_ERROR&&e.includes("call lock")}},{key:"resetHeadsetState",value:(a=pt(ht().mark((function e(){return ht().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callControl){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:this.callControl.hold(!1),this.callControl.mute(!1),this.callControl.offHook(!1),this.callControl.releaseCallLock(),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(2),this.logger.warn("Failed to takeCallLock in order to resetHeadsetState. Ignoring reset.");case 14:case"end":return e.stop()}}),e,this,[[2,11]])}))),function(){return a.apply(this,arguments)})},{key:"disconnect",value:(o=pt(ht().mark((function e(){var t,n;return ht().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.releaseCallLock(),e.next=11;break;case 6:e.prev=6,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 11:return e.prev=11,this.resetHeadsetState(),this.callLock=!1,this.activeConversationId&&(this.activeConversationId=null),this.headsetEventSubscription&&this.headsetEventSubscription.unsubscribe(),(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),e.finish(11);case 18:case"end":return e.stop()}}),e,this,[[0,6,11,18]])}))),function(){return o.apply(this,arguments)})}],i=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],r&&vt(n.prototype,r),i&&vt(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d,p,v,y,g,m,b}(W.a);bt(Et,"instance",void 0),bt(Et,"connectTimeout",5e3);var Ct=function(e){return e.Ring="ringer",e.Offhook="offhook",e.Mute="mute",e.Hold="hold",e}({}),_t=function(e){return e.OffHook="OffHook",e.Mute="Mute",e.Hold="Flash",e.RejectCall="RejectCall",e}({});function It(e){return(It="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 kt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */kt=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==It(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(It(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function Ot(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function St(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Ot(o,r,i,a,s,"next",e)}function s(e){Ot(o,r,i,a,s,"throw",e)}a(void 0)}))}}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,Nt(r.key),r)}}function xt(e,t,n){return t=At(t),function(e,t){if(t&&("object"===It(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],At(e).constructor):t.apply(e,n))}function At(e){return(At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Lt(e,t){return(Lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function Pt(e,t,n){return(t=Nt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Nt(e){var t=function(e,t){if("object"!=It(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=It(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==It(t)?t:t+""}var Rt=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),Pt(n=xt(this,t,[e]),"isActive",!1),Pt(n,"devices",null),Pt(n,"activeDeviceId",null),Pt(n,"headsetState",null),Pt(n,"ignoreNextOffhookEvent",!1),Pt(n,"cefSupportsJabra",!0),Pt(n,"pendingConversationId",void 0),Pt(n,"activeConversationId",void 0),Pt(n,"pendingConversationIsOutbound",void 0),n.vendorName="Jabra",n.headsetState={ringing:!1,offHook:!1},n.devices=new Map,z()&&(n.isHostedContextInitialized()?n.setupNativeHandlers():n.waitForHostedContext()),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Lt(e,t)}(t,e),n=t,r=[{key:"isHostedContextInitialized",value:function(){var e;return null===(e=window.Orgspan)||void 0===e?void 0:e.serviceFor("application").get("hostedContext").isHosted()}},{key:"waitForHostedContext",value:function(){var e=this;setTimeout((function(){e.isHostedContextInitialized()?e.setupNativeHandlers():e.waitForHostedContext()}),500)}},{key:"setupNativeHandlers",value:function(){var e,t=null===(e=window.Orgspan)||void 0===e?void 0:e.serviceFor("application").get("hostedContext");this.cefSupportsJabra=t.supportsJabra(),t.on("JabraEvent",this.handleJabraEvent.bind(this)),t.on("JabraDeviceAttached",this.handleJabraDeviceAttached.bind(this))}},{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.eventName,e.value)}},{key:"_handleOffhookEvent",value:function(e){if(e)return this.activeConversationId=this.pendingConversationId,this.pendingConversationId=null,void(this.headsetState.ringing&&(this.pendingConversationIsOutbound||this.deviceAnsweredCall({name:"CallOffHook",conversationId:this.activeConversationId}),this._sendCmd(Ct.Offhook,e),this._setRinging(!1)));this.activeConversationId&&(this._sendCmd(Ct.Offhook,e),this.deviceEndedCall({name:"CallOnHook",conversationId:this.activeConversationId})),this._getHeadsetIntoVanillaState(),this.activeConversationId=null}},{key:"_handleMuteEvent",value:function(e){this._sendCmd(Ct.Mute,e),this.isMuted=e,this.deviceMuteChanged({isMuted:e,name:e?"CallMuted":"CallUnmuted",conversationId:this.activeConversationId})}},{key:"_handleHoldEvent",value:function(e){this._sendCmd(Ct.Hold,!!e),this.deviceHoldStatusChanged({holdRequested:!!e,name:e?"OnHold":"ResumeCall",conversationId:this.activeConversationId})}},{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(Ct.Ring,e),this.headsetState.ringing=e}},{key:"isSupported",value:function(){return z()&&this.cefSupportsJabra}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["jabra"].some((function(e){return t.includes(e)}))}},{key:"setMute",value:(d=St(kt().mark((function e(t){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._sendCmd(Ct.Mute,t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"setHold",value:(h=St(kt().mark((function e(t,n){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._sendCmd(Ct.Hold,n);case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"incomingCall",value:(f=St(kt().mark((function e(t){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!1,this._setRinging(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"answerCall",value:(l=St(kt().mark((function e(t,n){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n&&(this.pendingConversationId=t),this.ignoreNextOffhookEvent=!0,this._sendCmd(Ct.Offhook,!0);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"rejectCall",value:(u=St(kt().mark((function e(){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._setRinging(!1),this.pendingConversationId=null;case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"outgoingCall",value:(c=St(kt().mark((function e(t){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!0,this._sendCmd(Ct.Offhook,!0);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"endCall",value:(s=St(kt().mark((function e(t,n){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._setRinging(!1),n||this._sendCmd(Ct.Offhook,!1),this.activeConversationId=null;case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"endAllCalls",value:(a=St(kt().mark((function e(){return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._setRinging(!1),this._sendCmd(Ct.Offhook,!1),this.activeConversationId=null;case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateDevices",value:(o=St(kt().mark((function e(){var t,n=this;return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,$({cmd:"requestJabraDevices"});case 3:if(t=e.sent,this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),t&&t.length){e.next=10;break}return this.devices.clear(),this.activeDeviceId=null,this.logger.error(new Error("No attached jabra devices")),e.abrupt("return");case 10: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=22;break;case 18:e.prev=18,e.t0=e.catch(0),this.logger.error("Failed to connect to jabra",e.t0),this.disconnect();case 22:case"end":return e.stop()}}),e,this,[[0,18]])}))),function(){return o.apply(this,arguments)})},{key:"_processEvent",value:function(e,t){var n,r,i,o=this;switch(e){case _t.OffHook:(n=function(){return o._handleOffhookEvent(t)},r=500,i=null,function(){clearTimeout(i),i=setTimeout((function(){n()}),r)})();break;case _t.RejectCall:this.deviceRejectedCall({name:_t.RejectCall,conversationId:this.pendingConversationId});break;case _t.Mute:this._handleMuteEvent(t);break;case _t.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()}}],i=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],r&&Tt(n.prototype,r),i&&Tt(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d}(W.a);function Dt(e){return(Dt="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 jt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */jt=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Dt(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Dt(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function Ht(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ut(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ut(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Ut(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Mt(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Ft(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Mt(o,r,i,a,s,"next",e)}function s(e){Mt(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Bt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Gt(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,Kt(r.key),r)}}function Yt(e,t,n){return t=Vt(t),function(e,t){if(t&&("object"===Dt(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],Vt(e).constructor):t.apply(e,n))}function Vt(e){return(Vt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Wt(e,t){return(Wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function qt(e,t,n){return(t=Kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kt(e){var t=function(e,t){if("object"!=Dt(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Dt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Dt(t)?t:t+""}Pt(Rt,"instance",void 0);var zt=function(e){function t(){var e;Bt(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return qt(e=Yt(this,t,[].concat(r)),"pendingConversationId",void 0),qt(e,"activeConversationId",void 0),qt(e,"_deviceInfo",null),qt(e,"activeDevice",void 0),qt(e,"callState",0),qt(e,"recCallState",0),qt(e,"isHold",!1),qt(e,"inputReportReportId",null),qt(e,"vendorName","Yealink"),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Wt(e,t)}(t,e),n=t,r=[{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isSupported",value:function(){return window.navigator.hid&&!z()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["yealink","(6993:"].some((function(e){return t.includes(e)}))}},{key:"connect",value:(v=Ft(jt().mark((function e(t){var n,r=this;return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),n=t.toLowerCase(),e.next=4,window.navigator.hid.getDevices();case 4:if(e.sent.forEach((function(e){var t;if(!r.activeDevice&&n.includes(null==e||null===(t=e.productName)||void 0===t?void 0:t.toLowerCase())){var i,o=Ht(e.collections);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(5===a.usage&&11===a.usagePage){r.activeDevice=e,0!==a.inputReports.length&&(r.inputReportReportId=4);break}}}catch(e){o.e(e)}finally{o.f()}}})),this.activeDevice){e.next=18;break}return e.prev=7,e.next=10,new Promise((function(e,i){var o=setTimeout(i,3e4);r.requestWebHidPermissions(Ft(jt().mark((function a(){var s,c,u,l;return jt().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return s=r.deductProductId(t),c=[{usage:5,usagePage:11,vendorId:27027,productId:s||void 0}],a.next=4,window.navigator.hid.requestDevice({filters:c});case 4:return clearTimeout(o),a.next=7,window.navigator.hid.getDevices();case 7:u=a.sent,l=!1,u.forEach((function(t){var i;if(n.includes(null==t||null===(i=t.productName)||void 0===i?void 0:i.toLowerCase())){var o,a=Ht(t.collections);try{for(a.s();!(o=a.n()).done;){var s=o.value;if(5===s.usage&&11===s.usagePage){l=!0,0!==s.inputReports.length&&(r.inputReportReportId=4),e(t);break}}}catch(e){a.e(e)}finally{a.f()}}})),l||i();case 11:case"end":return a.stop()}}),a)}))))}));case 10:this.activeDevice=e.sent,e.next=18;break;case 13:return e.prev=13,e.t0=e.catch(7),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),this.logger.error("The selected device was not granted WebHID permissions"),e.abrupt("return");case 18:if(this.activeDevice.opened){e.next=21;break}return e.next=21,this.activeDevice.open();case 21:this.logger.debug("get device reportId ".concat(this.inputReportReportId)),this.activeDevice.addEventListener("inputreport",(function(e){if(e.reportId===r.inputReportReportId){var t=e.data.getUint8(0);r.processBtnPress(t)}})),this._deviceInfo={ProductName:this.activeDevice.productName},this.isConnecting&&!this.isConnected&&this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 25:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e){return v.apply(this,arguments)})},{key:"disconnect",value:(p=Ft(jt().mark((function e(){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),this.activeDevice&&(this.activeDevice.close(),this.activeDevice=null,this._deviceInfo=null,this.inputReportReportId=0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"processBtnPress",value:function(e){if(this.activeDevice){this.logger.debug("User pressed button ".concat(e,". local ").concat(this.recCallState));var t=e^this.recCallState;0!==t&&(0===e||0!=(-3&this.callState)?(this.recCallState=e,1&t?1&e?(this.answerCall(),this.activeConversationId?this.deviceAnsweredCall({name:"OffHook",conversationId:this.activeConversationId}):this.logger.debug("activeConversationId is empty")):this.isHold||(this.sendOpToDevice(this.isMuted?2:0),this.activeConversationId?this.deviceEndedCall({name:"OnHook",conversationId:this.activeConversationId}):this.logger.debug("activeConversationId is empty"),this.activeConversationId=null):4&t?4&e&&(this.setMute(!this.isMuted),this.deviceMuteChanged({isMuted:this.isMuted,name:this.isMuted?"CallMuted":"CallUnmuted",conversationId:this.activeConversationId})):8&t?8&e&&(this.setHold(null,!this.isHold),this.deviceHoldStatusChanged({holdRequested:this.isHold,name:this.isHold?"OnHold":"ResumeCall",conversationId:this.activeConversationId})):64&t&&64&e&&(this.deviceRejectedCall({name:"Reject",conversationId:this.pendingConversationId}),this.rejectCall())):this.logger.debug("Not talking, ignore key"))}else this.logger.error("do not have active device")}},{key:"incomingCall",value:(d=Ft(jt().mark((function e(t){var n;return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t&&(this.pendingConversationId=t.conversationId,n=this.isMuted?2:0,this.sendOpToDevice(4|n));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"outgoingCall",value:(h=Ft(jt().mark((function e(t){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.sendOpToDevice(1);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"answerCall",value:(f=Ft(jt().mark((function e(){var t;return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId&&(this.activeConversationId=this.pendingConversationId,this.pendingConversationId=null),t=this.isMuted?2:0,this.sendOpToDevice(1|t);case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"rejectCall",value:(l=Ft(jt().mark((function e(){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=null,this.sendOpToDevice(this.isMuted?2:0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"endCall",value:(u=Ft(jt().mark((function e(t,n){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:t===this.activeConversationId&&(this.activeConversationId=null),this.sendOpToDevice(this.isMuted?2:0);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"endAllCalls",value:(c=Ft(jt().mark((function e(){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.activeConversationId=null,this.sendOpToDevice(this.isMuted?2:0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"setMute",value:(s=Ft(jt().mark((function e(t){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t?this.sendOpToDevice(2|this.callState):this.sendOpToDevice(-3&this.callState);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"setHold",value:(a=Ft(jt().mark((function e(t,n){var r,i;return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n?(r=-2&this.callState,this.sendOpToDevice(8|r)):(i=-9&this.callState,this.sendOpToDevice(1|i));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"sendOpToDevice",value:(o=Ft(jt().mark((function e(t){return jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.activeDevice&&0!==this.inputReportReportId){e.next=3;break}return this.logger.error("do not have active device"),e.abrupt("return");case 3:return this.isHold=!!(8&t),this.isMuted=!!(2&t),this.logger.debug("send to dev ".concat(t)),this.callState=t,e.next=9,this.activeDevice.sendReport(this.inputReportReportId,new Uint8Array([t]));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})}],i=[{key:"getInstance",value:function(e){return t.instance||(t.instance=new t(e)),t.instance}}],r&&Gt(n.prototype,r),i&&Gt(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d,p,v}(W.a);function $t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||en(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Jt=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==cn(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(cn(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function Xt(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Qt(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Xt(o,r,i,a,s,"next",e)}function s(e){Xt(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Zt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=en(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function en(e,t){if(e){if("string"==typeof e)return tn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tn(e,t):void 0}}function tn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function nn(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 rn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nn(Object(n),!0).forEach((function(t){on(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function on(e,t,n){return(t=sn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function an(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,sn(r.key),r)}}function sn(e){var t=function(e,t){if("object"!=cn(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=cn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==cn(t)?t:t+""}function cn(e){return(cn="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)}qt(zt,"instance",void 0);var un,ln=Object.defineProperty,fn=function(e,t,n){return function(e,t,n){return t in e?ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n}(e,"symbol"!=cn(t)?t+"":t,n)},hn=((un=hn||{})[un.LED=8]="LED",un[un.TELEPHONY=11]="TELEPHONY",un),dn=function(e){return e[e.PROGRAMMABLE_BUTTON=7]="PROGRAMMABLE_BUTTON",e[e.HOOK_SWITCH=32]="HOOK_SWITCH",e[e.FLASH=33]="FLASH",e[e.PHONE_MUTE=47]="PHONE_MUTE",e}(dn||{}),pn=function(e){return e[e.MUTE=9]="MUTE",e[e.OFF_HOOK=23]="OFF_HOOK",e[e.RING=24]="RING",e[e.HOLD=32]="HOLD",e}(pn||{}),vn=function(e){return e[e.ToggleButton=0]="ToggleButton",e[e.ToggleSwitch=1]="ToggleSwitch",e}(vn||{});function yn(e){return 65535&e}function gn(e){return e>>>16}function mn(e){return e.isAbsolute?1:0}var bn={usage:5,usagePage:11},wn=[32,47,7],En=function(e){return wn.includes(e)},Cn=[23,24,9],_n=function(e){return Cn.includes(e)},In=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),this.device=t,fn(this,"inputEventInfos"),fn(this,"inputEventObserverCallbacks"),fn(this,"outputEventInfos"),this.inputEventInfos=wn.reduce((function(e,t){return rn(rn({},e),{},on({},t,void 0))}),{}),this.inputEventObserverCallbacks=wn.reduce((function(e,t){return rn(rn({},e),{},on({},t,[]))}),{}),this.outputEventInfos=Cn.reduce((function(e,t){return rn(rn({},e),{},on({},t,void 0))}),{}),this.parseDeviceDescriptors(),this.device.addEventListener("inputreport",(function(e){return n.onInputReport(e)}))}return t=e,n=[{key:"onInputReport",value:function(e){var t,n,r,i,o,a,s,c,u=this.device.productId;if(u>=64&&u<=130&&5===e.reportId)switch(e.data.getUint8(0)){case 32:null===(t=(n=this.inputEventObserverCallbacks[32])[0])||void 0===t||t.call(n,!0,1);break;case 8:this.inputEventObserverCallbacks[7][0](!0,1);break;case 0:null===(r=(i=this.inputEventObserverCallbacks[32])[0])||void 0===r||r.call(i,!1,1);break;case 1:null===(o=(a=this.inputEventObserverCallbacks[47])[0])||void 0===o||o.call(a,!1,1);break;case 5:null===(s=(c=this.inputEventObserverCallbacks[47])[0])||void 0===s||s.call(c,!0,1)}else for(var l=0,f=wn;l<f.length;l++){var h=f[l],d=this.inputEventInfos[h];if(void 0!==d&&e.reportId===d.reportId){var p,v=Math.trunc(d.offset/8),y=d.offset%8,g=0!=(e.data.getUint8(v)&1<<y),m=Zt(this.inputEventObserverCallbacks[h]);try{for(m.s();!(p=m.n()).done;)(0,p.value)(g,d.controlType)}catch(e){m.e(e)}finally{m.f()}}}}},{key:"close",value:(a=Qt(Jt().mark((function e(){return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.device.opened,!e.t0){e.next=4;break}return e.next=4,this.device.close();case 4:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"parseDeviceDescriptors",value:function(){if(void 0===this.device.collections)throw new Error("Undefined device collection");var e=this.device.collections.find((function(e){return 11===e.usagePage}));if(void 0===e)throw new Error("No telephony collection");e.inputReports&&this.parseInputReport(e.inputReports),e.outputReports&&this.parseOutputReport(e.outputReports)}},{key:"parseInputReport",value:function(e){var t,n=Zt(e);try{for(n.s();!(t=n.n()).done;){var r=t.value,i=0;if(void 0!==r.items&&void 0!==r.reportId){var o,a=Zt(r.items);try{for(a.s();!(o=a.n()).done;){var s=o.value;if(void 0!==s.usages&&void 0!==s.reportSize&&void 0!==s.reportCount&&void 0!==s.isAbsolute){var c,u=Zt(s.usages.entries());try{for(u.s();!(c=u.n()).done;){var l=$t(c.value,2),f=l[0],h=l[1];if(11===gn(h)||589831===h){var d=yn(h);En(d)&&(this.inputEventInfos[d]={reportId:r.reportId,offset:i+f*s.reportSize,controlType:mn(s)})}}}catch(e){u.e(e)}finally{u.f()}i+=s.reportCount*s.reportSize}}}catch(e){a.e(e)}finally{a.f()}}}}catch(e){n.e(e)}finally{n.f()}}},{key:"parseOutputReport",value:function(e){var t,n=this,r=Zt(e);try{var i=function(){var e=t.value;if(void 0===e.items||void 0===e.reportId)return 1;var r,i=0,o=[],a=Zt(e.items);try{for(a.s();!(r=a.n()).done;){var s=r.value;if(void 0===s.usages||void 0===s.reportSize||void 0===s.reportCount){o=[];break}var c,u=Zt(s.usages.entries());try{for(u.s();!(c=u.n()).done;){var l=$t(c.value,2),f=l[0],h=l[1];if(8===gn(h)){var d=yn(h);_n(d)&&o.push([d,i+f*s.reportSize])}}}catch(e){u.e(e)}finally{u.f()}i+=s.reportCount*s.reportSize}}catch(e){a.e(e)}finally{a.f()}for(var p=i,v=function(){var t=$t(g[y],2),r=t[0],i=t[1];n.outputEventInfos[r]={reportId:e.reportId,state:!1,offset:i,generator:function(){var t=new Uint8Array(p/8);return{reportId:e.reportId,data:t}},setter:function(e,t){if(i>=0){var n=Math.trunc(i/8),r=i%8;t[n]|=(e?1:0)<<r}return t}}},y=0,g=o;y<g.length;y++)v()};for(r.s();!(t=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}}},{key:"getControlType",value:function(e){var t;if(this.supportInput(e))return null===(t=this.inputEventInfos[e])||void 0===t?void 0:t.controlType}},{key:"supportInput",value:function(e){return void 0!==this.inputEventInfos[e]}},{key:"supportOutput",value:function(e){return void 0!==this.outputEventInfos[e]}},{key:"subscribe",value:function(e,t){this.inputEventObserverCallbacks[e].push(t)}},{key:"unsubscribe",value:function(e){this.inputEventObserverCallbacks[e]=[]}},{key:"setState",value:function(e,t){if(this.device.opened){var n=this.outputEventInfos[e];void 0!==n&&(n.state=t)}}},{key:"getState",value:function(e){var t;if(this.device.opened)return null===(t=this.outputEventInfos[e])||void 0===t?void 0:t.state}},{key:"send",value:(o=Qt(Jt().mark((function e(t){var n,r,i,o,a,s,c,u,l,f,h,d,p,v,y,g=this;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.device.opened){e.next=2;break}return e.abrupt("return");case 2:if(!((n=this.device.productId)>=64&&n<=130)){e.next=22;break}if(r=t.get(24),i=t.get(23),o=t.get(9),e.t0=void 0!==r,!e.t0){e.next=10;break}return this.setState(24,r),e.next=10,this.device.sendReport(6,new Uint8Array([r?1:0,0]));case 10:if(e.t1=void 0!==i,!e.t1){e.next=15;break}return this.setState(23,i),e.next=15,this.device.sendReport(6,new Uint8Array([i?2:0,0]));case 15:if(e.t2=void 0!==o,!e.t2){e.next=20;break}return this.setState(9,o),e.next=20,this.device.sendReport(6,new Uint8Array([o?4:5,0]));case 20:e.next=48;break;case 22:a=[],s=Zt(t),e.prev=24,u=Jt().mark((function e(){var t,n,r,i;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=$t(c.value,2),n=t[0],r=t[1],void 0!==(i=g.outputEventInfos[n])&&(void 0===a.find((function(e){return e.reportId===(null==i?void 0:i.reportId)}))&&a.push(null==i?void 0:i.generator()),i.state=r);case 3:case"end":return e.stop()}}),e)})),s.s();case 27:if((c=s.n()).done){e.next=31;break}return e.delegateYield(u(),"t3",29);case 29:e.next=27;break;case 31:e.next=36;break;case 33:e.prev=33,e.t4=e.catch(24),s.e(e.t4);case 36:return e.prev=36,s.f(),e.finish(36);case 39:l=0,f=a;case 40:if(!(l<f.length)){e.next=48;break}for(h=f[l],d=0,p=Cn;d<p.length;d++)v=p[d],void 0===(y=this.outputEventInfos[v])||y.reportId!==h.reportId||!y.state||(h.data=y.setter(y.state,h.data));return e.next=45,this.device.sendReport(h.reportId,h.data);case 45:l++,e.next=40;break;case 48:case"end":return e.stop()}}),e,this,[[24,33,36,39]])}))),function(e){return o.apply(this,arguments)})}],r=[{key:"create",value:(i=Qt(Jt().mark((function t(n){return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=n.opened,t.t0){t.next=4;break}return t.next=4,n.open();case 4:return t.abrupt("return",new e(n));case 5:case"end":return t.stop()}}),t)}))),function(e){return i.apply(this,arguments)})}],n&&an(t.prototype,n),r&&an(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r,i,o,a}(),kn=function(e){if(!e.supportInput(32))throw new Error("Device is missing hook switch support");if(!e.supportInput(47))throw new Error("Device is missing mute switch support")},On=function(e){if(!e.supportOutput(24))throw new Error("Device is missing ring support");if(!e.supportOutput(23))throw new Error("Device is missing off/on hook support");if(!e.supportOutput(9))throw new Error("Device is missing mute support")},Sn=function(e){return e[e.ACCEPT_CALL=0]="ACCEPT_CALL",e[e.END_CALL=1]="END_CALL",e[e.REJECT_CALL=2]="REJECT_CALL",e[e.MUTE_CALL=3]="MUTE_CALL",e[e.UNMUTE_CALL=4]="UNMUTE_CALL",e}(Sn||{});function Tn(e){return xn.apply(this,arguments)}function xn(){return(xn=Qt(Jt().mark((function e(t){var n;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,In.create(t);case 2:return n=e.sent,e.abrupt("return",(On(n),kn(n),{productName:n.device.productName,ring:function(){return n.send(new Map([[24,!0]]))},onHook:function(){return n.send(new Map([[23,!1],[24,!1],[9,!1]]))},offHook:function(){return n.send(new Map([[23,!0],[24,!1],[9,!1]]))},muteOn:function(){return n.send(new Map([[23,!0],[24,!1],[9,!0]]))},muteOff:function(){return n.send(new Map([[23,!0],[24,!1],[9,!1]]))},subscribe:function(e){n.subscribe(32,(function(t,r){if(0===r&&t){if(n.getState(24))return void e(0);if(n.getState(23))return void e(1)}if(1===r){if(t&&n.getState(24))return void e(0);if(!t&&n.getState(23))return void e(1)}})),n.subscribe(47,(function(t,r){if(0===r&&t)e(n.getState(9)?4:3);else if(1===r){if(t&&!n.getState(9))return void e(3);if(!t&&n.getState(9))return void e(4)}})),n.subscribe(7,(function(t,n){t&&e(2)}))},unsubscribe:function(){n.unsubscribe(32),n.unsubscribe(47),n.unsubscribe(7)}}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function An(e){return Ln.apply(this,arguments)}function Ln(){return(Ln=Qt(Jt().mark((function e(t){var n,r,i,o;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.getDevices();case 2:n=e.sent,r=Zt(n),e.prev=4,r.s();case 6:if((i=r.n()).done){e.next=14;break}if(o=i.value,!t.toLowerCase().includes(o.productName.toLowerCase())){e.next=12;break}return e.next=11,Tn(o);case 11:return e.abrupt("return",e.sent);case 12:e.next=6;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(4),r.e(e.t0);case 19:return e.prev=19,r.f(),e.finish(19);case 22:case"end":return e.stop()}}),e,null,[[4,16,19,22]])})))).apply(this,arguments)}function Pn(e){return Nn.apply(this,arguments)}function Nn(){return(Nn=Qt(Jt().mark((function e(t){var n;return Jt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.requestDevice({filters:[rn({vendorId:13323,productId:t.productId},bn)]});case 2:if(n=e.sent.find((function(e){return e.collections.find((function(e){return e.usage===bn.usage&&e.usagePage===bn.usagePage}))}))){e.next=5;break}throw new Error("No requested device found");case 5:return e.next=7,Tn(n);case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Rn(e){return(Rn="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 Dn(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Dn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Rn(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Rn(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function jn(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Hn(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){jn(o,r,i,a,s,"next",e)}function s(e){jn(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Un(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Mn(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,Vn(r.key),r)}}function Fn(e,t,n){return t=Bn(t),function(e,t){if(t&&("object"===Rn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],Bn(e).constructor):t.apply(e,n))}function Bn(e){return(Bn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Gn(e,t){return(Gn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function Yn(e,t,n){return(t=Vn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vn(e){var t=function(e,t){if("object"!=Rn(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Rn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Rn(t)?t:t+""}var Wn=function(e){function t(){var e;Un(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return Yn(e=Fn(this,t,[].concat(r)),"activeConversationId",void 0),Yn(e,"pendingConversationId",void 0),Yn(e,"_deviceInfo",null),Yn(e,"activeDevice",null),Yn(e,"vendorName","VBet"),Yn(e,"processBtnPress",(function(t){switch(t){case Sn.ACCEPT_CALL:e.pendingConversationId?(e.answerCall(e.pendingConversationId),e.deviceAnsweredCall({name:"OffHook",conversationId:e.activeConversationId})):e.logger.error("No call to be answered");break;case Sn.END_CALL:if(e.activeConversationId){var n=e.activeConversationId;e.endCall(n),e.deviceEndedCall({name:"OnHook",conversationId:n})}else e.logger.error("No call to be terminated");break;case Sn.MUTE_CALL:case Sn.UNMUTE_CALL:e.activeConversationId?(e.setMute(t===Sn.MUTE_CALL),e.deviceMuteChanged({isMuted:e.isMuted,name:e.isMuted?"CallMuted":"CallUnmuted",conversationId:e.activeConversationId})):e.logger.error("No call to be muted");break;case Sn.REJECT_CALL:e.pendingConversationId?(e.rejectCall(e.pendingConversationId),e.deviceRejectedCall({name:"Reject",conversationId:e.pendingConversationId})):e.logger.error("No call to be rejected")}})),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Gn(e,t)}(t,e),n=t,r=[{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isSupported",value:function(){return window.navigator.hid&&!z()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["vt","340b"].some((function(e){return t.includes(e)}))}},{key:"connect",value:(d=Hn(Dn().mark((function e(t){var n,r,i=this;return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),e.prev=1,e.next=4,An(t);case 4:if(!(n=e.sent)){e.next=9;break}this.activeDevice=n,e.next=13;break;case 9:return e.next=11,new Promise((function(e,n){var r=i.deductProductId(t),o=setTimeout((function(){return n("The selected device was not granted WebHID permissions")}),3e4);i.requestWebHidPermissions((function(){Pn({productId:r||void 0}).then((function(t){e(t),clearTimeout(o)})).catch((function(e){n(e)}))}))}));case 11:r=e.sent,this.activeDevice=r;case 13:e.next=20;break;case 15:return e.prev=15,e.t0=e.catch(1),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),this.logger.error(e.t0),e.abrupt("return");case 20:this._deviceInfo={ProductName:this.activeDevice.productName},this.activeDevice.subscribe(this.processBtnPress),this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 23:case"end":return e.stop()}}),e,this,[[1,15]])}))),function(e){return d.apply(this,arguments)})},{key:"disconnect",value:(h=Hn(Dn().mark((function e(){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),this.activeDevice&&this.activeDevice.unsubscribe(),this.activeDevice=null,this._deviceInfo=null,this.isMuted=!1;case 5:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"incomingCall",value:(f=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.activeDevice.ring();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"outgoingCall",value:(l=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.activeConversationId=t.conversationId,this.activeDevice.offHook();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"answerCall",value:(u=Hn(Dn().mark((function e(t,n){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId===t||n?(this.activeConversationId=t,this.pendingConversationId="",this.activeDevice.offHook()):this.logger.error("no call to be answered");case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"rejectCall",value:(c=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t===this.pendingConversationId?(this.pendingConversationId="",this.activeDevice.onHook()):this.logger.error("no call to be rejected");case 1:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"endCall",value:(s=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t===this.activeConversationId?(this.activeConversationId="",this.pendingConversationId="",this.activeDevice.onHook()):this.logger.error("no call to be ended");case 1:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"endAllCalls",value:(a=Hn(Dn().mark((function e(){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.activeConversationId="",this.pendingConversationId="",this.activeDevice.onHook();case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"setMute",value:(o=Hn(Dn().mark((function e(t){return Dn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.isMuted=t,this.isMuted?this.activeDevice.muteOn():this.activeDevice.muteOff();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})}],i=[{key:"getInstance",value:function(e){return t.instance||(t.instance=new t(e)),t.instance}}],r&&Mn(n.prototype,r),i&&Mn(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i,o,a,s,c,u,l,f,h,d}(W.a);Yn(Wn,"instance",void 0);var qn=n(1);function Kn(e){return(Kn="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 zn(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 $n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?zn(Object(n),!0).forEach((function(t){nr(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Jn(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Jn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,a=Object.create(o.prototype),s=new x(r||[]);return i(a,"_invoke",{value:k(e,n,s)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",p="completed",v={};function y(){}function g(){}function m(){}var b={};u(b,a,(function(){return this}));var w=Object.getPrototypeOf,E=w&&w(w(A([])));E&&E!==n&&r.call(E,a)&&(b=E);var C=m.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Kn(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,n,r){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=d;var u=f(t,n,r);if("normal"===u.type){if(i=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=f(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Kn(t)+" is not iterable")}return g.prototype=m,i(C,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:g,configurable:!0}),g.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,s,(function(){return this})),t.AsyncIterator=I,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(C),u(C,c,"Generator"),u(C,a,(function(){return this})),u(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function Xn(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Qn(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Xn(o,r,i,a,s,"next",e)}function s(e){Xn(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Zn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return er(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return er(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function er(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function tr(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,rr(r.key),r)}}function nr(e,t,n){return(t=rr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rr(e){var t=function(e,t){if("object"!=Kn(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Kn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Kn(t)?t:t+""}var ir=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),nr(this,"plantronics",void 0),nr(this,"jabraNative",void 0),nr(this,"jabra",void 0),nr(this,"sennheiser",void 0),nr(this,"yealink",void 0),nr(this,"vbet",void 0),nr(this,"cyberAcoustics",void 0),nr(this,"selectedImplementation",void 0),nr(this,"headsetEvents$",void 0),nr(this,"headsetConversationStates",{}),nr(this,"_headsetEvents$",void 0),nr(this,"logger",void 0),this._headsetEvents$=new Y,this.headsetEvents$=this._headsetEvents$.asObservable(),this.logger=t.logger||console,this.plantronics=Se.getInstance({logger:this.logger,appName:t.appName}),this.jabraNative=Rt.getInstance({logger:this.logger}),this.jabra=Et.getInstance({logger:this.logger}),this.sennheiser=Ue.getInstance({logger:this.logger}),this.yealink=zt.getInstance({logger:this.logger}),this.vbet=Wn.getInstance({logger:this.logger}),this.cyberAcoustics=fe.getInstance({logger:this.logger}),[this.plantronics,this.jabra,this.jabraNative,this.sennheiser,this.yealink,this.vbet,this.cyberAcoustics].forEach((function(e){return n.subscribeToHeadsetEvents(e)}))}return t=e,n=[{key:"implementations",get:function(){return[this.sennheiser,this.plantronics,this.jabra,this.jabraNative,this.yealink,this.vbet,this.cyberAcoustics].filter((function(e){return e.isSupported()}))}},{key:"isDifferentState",value:function(e){var t=this.headsetConversationStates[e.conversationId];return!t||Object.entries(e.state).some((function(e){var n=Zn(e,2),r=n[0],i=n[1];return t[r]!==i}))}},{key:"updateHeadsetState",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{expectExistingConversation:!0};if(this.isDifferentState(e)){var n=this.headsetConversationStates[e.conversationId];return n?(Object.assign(n,e.state),!0):(t.expectExistingConversation&&this.logger.warn("updateHeadsetState has no existing state for provided conversationId.",{conversationId:e.conversationId}),!1)}return!1}},{key:"deviceIsSupported",value:function(e){return!!e.micLabel&&!!this.implementations.find((function(t){return t.deviceLabelMatchesVendor(e.micLabel)}))}},{key:"activeMicChange",value:function(e,t){if(e){var n=this.implementations.find((function(t){return t.deviceLabelMatchesVendor(e)}));n?this.changeImplementation(n,e):this.selectedImplementation&&this.clearSelectedImplementation(t)}else this.clearSelectedImplementation(t)}},{key:"changeImplementation",value:(h=Qn(Jn().mark((function e(t,n){return Jn().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=6;break}return this.headsetConversationStates={},e.next=6,this.selectedImplementation.disconnect();case 6:if(this.selectedImplementation=t,this._headsetEvents$.next({event:qn.a.implementationChanged,payload:t}),!t){e.next=11;break}return e.next=11,t.connect(n);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"incomingCall",value:(f=Qn(Jn().mark((function e(t,n){var r;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:return this.headsetConversationStates[t.conversationId]={conversationId:t.conversationId,held:!1,muted:!1,offHook:!1,ringing:!0},e.abrupt("return",r.incomingCall(t,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"outgoingCall",value:(l=Qn(Jn().mark((function e(t){var n;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:return this.headsetConversationStates[t.conversationId]={conversationId:t.conversationId,held:!1,muted:!1,offHook:!0,ringing:!1},e.abrupt("return",n.outgoingCall(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"answerCall",value:(u=Qn(Jn().mark((function e(t,n){var r,i;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(n){e.next=9;break}if(i={ringing:!1,offHook:!0},!this.updateHeadsetState({conversationId:t,state:i})){e.next=7;break}return e.abrupt("return",r.answerCall(t));case 7:e.next=11;break;case 9:return this.headsetConversationStates[t]={conversationId:t,held:!1,muted:!1,offHook:!0,ringing:!1},e.abrupt("return",r.answerCall(t,n));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"rejectCall",value:(c=Qn(Jn().mark((function e(t){var n,r,i,o=arguments;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(o.length>1&&void 0!==o[1])||o[1],r=this.getConnectedImpl()){e.next=4;break}return e.abrupt("return");case 4:if(i={ringing:!1},!this.updateHeadsetState({conversationId:t,state:i},{expectExistingConversation:n})){e.next=9;break}return this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t),e.abrupt("return",r.rejectCall(t));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setMute",value:(s=Qn(Jn().mark((function e(t){var n;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(!Object.values(this.headsetConversationStates).some((function(e){return e.muted!==t}))){e.next=6;break}return Object.values(this.headsetConversationStates).forEach((function(e){return e.muted=t})),e.abrupt("return",n.setMute(t));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"setHold",value:(a=Qn(Jn().mark((function e(t,n){var r,i;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(i={held:n},!this.updateHeadsetState({conversationId:t,state:i})){e.next=6;break}return e.abrupt("return",r.setHold(t,n));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"endCall",value:(o=Qn(Jn().mark((function e(t,n){var r,i;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(i={offHook:!1},!this.updateHeadsetState({conversationId:t,state:i})){e.next=8;break}return this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t),e.abrupt("return",r.endCall(t,n));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"endAllCalls",value:(i=Qn(Jn().mark((function e(){var t,n=this;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:return Object.values(this.headsetConversationStates).forEach((function(e){e.removeTimer||(e.removeTimer=n.setRemoveTimer(e.conversationId))})),e.abrupt("return",t.endAllCalls());case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{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:"resetHeadsetStateForCall",value:function(e){var t=this.getConnectedImpl();if(t)return t.resetHeadsetStateForCall(e);this.logger.info("No active implementation, headset state does not require a reset")}},{key:"getConnectedImpl",value:function(){var e=this.selectedImplementation;return e&&e.isConnected?e:null}},{key:"subscribeToHeadsetEvents",value:function(e){e.on(qn.a.deviceAnsweredCall,this.handleDeviceAnsweredCall.bind(this)),e.on(qn.a.deviceRejectedCall,this.handleDeviceRejectedCall.bind(this)),e.on(qn.a.deviceEndedCall,this.handleDeviceEndedCall.bind(this)),e.on(qn.a.deviceMuteStatusChanged,this.handleDeviceMuteStatusChanged.bind(this)),e.on(qn.a.deviceHoldStatusChanged,this.handleDeviceHoldStatusChanged.bind(this)),e.on(qn.a.deviceEventLogs,this.handleDeviceLogs.bind(this)),e.on(qn.a.deviceConnectionStatusChanged,this.handleDeviceConnectionStatusChanged.bind(this)),e.on(qn.a.webHidPermissionRequested,this.handleWebHidPermissionRequested.bind(this))}},{key:"clearSelectedImplementation",value:function(e){this.selectedImplementation&&(this.selectedImplementation.disconnect(e),this._headsetEvents$.next({event:qn.a.implementationChanged,payload:null}),this.selectedImplementation=null,this.handleDeviceConnectionStatusChanged())}},{key:"setRemoveTimer",value:function(e){var t=this;return setTimeout((function(){t.headsetConversationStates[e].removeTimer&&delete t.headsetConversationStates[e]}),2e3)}},{key:"handleDeviceAnsweredCall",value:function(e){e.vendor===this.selectedImplementation&&(this.updateHeadsetState({conversationId:e.body.conversationId,state:{ringing:!1,offHook:!0}}),this.logger.info("Headset: device answered the call"),this._headsetEvents$.next({event:qn.a.deviceAnsweredCall,payload:$n({},e.body)}))}},{key:"handleDeviceRejectedCall",value:function(e){if(e.vendor===this.selectedImplementation){var t=e.body.conversationId;this.updateHeadsetState({conversationId:t,state:{ringing:!1}})&&(this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t)),this.logger.info("Headset: device rejected the call"),this._headsetEvents$.next({event:qn.a.deviceRejectedCall,payload:$n({},e.body)})}}},{key:"handleDeviceEndedCall",value:function(e){this.logger.info("Headset: device ended the call");var t=e.body.conversationId;this.updateHeadsetState({conversationId:t,state:{offHook:!1}})&&(this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t)),this._headsetEvents$.next({event:qn.a.deviceEndedCall,payload:$n({},e.body)})}},{key:"handleDeviceMuteStatusChanged",value:function(e){this.logger.info("Headset: device mute status changed: ",e.body.isMuted),Object.values(this.headsetConversationStates).some((function(t){return t.muted!==e.body.isMuted}))&&Object.values(this.headsetConversationStates).forEach((function(t){return t.muted=e.body.isMuted})),this._headsetEvents$.next({event:qn.a.deviceMuteStatusChanged,payload:$n({},e.body)})}},{key:"handleDeviceHoldStatusChanged",value:function(e){this.logger.info("Headset: device hold status changed",e.body.holdRequested);var t={held:e.body.holdRequested},n=e.body.conversationId;this.updateHeadsetState({conversationId:n,state:t}),this._headsetEvents$.next({event:qn.a.deviceHoldStatusChanged,payload:$n({},e.body)})}},{key:"handleDeviceConnectionStatusChanged",value:function(){this._headsetEvents$.next({event:qn.a.deviceConnectionStatusChanged,payload:this.connectionStatus()})}},{key:"handleWebHidPermissionRequested",value:function(e){this.logger.debug("Requesting Webhid Permissions"),this._headsetEvents$.next({event:qn.a.webHidPermissionRequested,payload:$n({},e.body)})}},{key:"handleDeviceLogs",value:function(e){this._headsetEvents$.next({event:qn.a.loggableEvent,payload:$n({},e.body)})}}],r=[{key:"getInstance",value:function(t){return e.instance&&!t.createNew||(e.instance=new e(t)),e.instance}}],n&&tr(t.prototype,n),r&&tr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r,i,o,a,s,c,u,l,f,h}();nr(ir,"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}));n(6);var o=n(1);n.d(t,"HeadsetEvents",(function(){return o.a}));var a=n(7);for(var s in a)["default","VendorImplementation","HeadsetEvents"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(s);n(8),n(9);t.default=r.a},,function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(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:a}catch(e){r=a}}();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=s(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===a||!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||s(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){
|
|
26
26
|
/*!
|
|
27
27
|
* The buffer module from node.js, for the browser.
|
|
28
28
|
*
|