microsoft.cognitiveservices.speech.sdk.bundle-min.js 473 KB

1
  1. (()=>{var e=[,function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0});new(r(2).AgentConfig),n(r(79),t)},function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.AutoDetectSourceLanguagesOpenRangeOptionName=t.ForceDictationPropertyName=t.ServicePropertiesPropertyName=t.CancellationErrorCodePropertyName=t.OutputFormatPropertyName=t.SpeechSynthesisAdapter=t.AvatarSynthesisAdapter=void 0,n(r(3),t),n(r(56),t),n(r(55),t),n(r(57),t),n(r(58),t),n(r(59),t),n(r(204),t),n(r(205),t),n(r(206),t),n(r(217),t),n(r(218),t),n(r(219),t),n(r(220),t),n(r(221),t),n(r(222),t),n(r(223),t),n(r(224),t),n(r(196),t),n(r(225),t),n(r(226),t),n(r(227),t),n(r(228),t),n(r(229),t),n(r(230),t),n(r(231),t),n(r(232),t),n(r(233),t),n(r(234),t),n(r(235),t),n(r(237),t),n(r(238),t),n(r(239),t),n(r(240),t),n(r(241),t),n(r(242),t),n(r(243),t),n(r(244),t),n(r(246),t),n(r(248),t),n(r(250),t),n(r(256),t),n(r(257),t),n(r(273),t),n(r(274),t),n(r(276),t);var s=r(277);Object.defineProperty(t,"AvatarSynthesisAdapter",{enumerable:!0,get:function(){return s.AvatarSynthesisAdapter}});var o=r(278);Object.defineProperty(t,"SpeechSynthesisAdapter",{enumerable:!0,get:function(){return o.SpeechSynthesisAdapter}}),n(r(279),t),n(r(280),t),n(r(281),t),n(r(282),t),n(r(283),t),n(r(284),t),n(r(285),t),t.OutputFormatPropertyName="OutputFormat",t.CancellationErrorCodePropertyName="CancellationErrorCode",t.ServicePropertiesPropertyName="ServiceProperties",t.ForceDictationPropertyName="ForceDictation",t.AutoDetectSourceLanguagesOpenRangeOptionName="UND"},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CognitiveSubscriptionKeyAuthentication=void 0;const i=r(4),n=r(54),s=r(55);t.CognitiveSubscriptionKeyAuthentication=class{constructor(e){if(!e)throw new i.ArgumentNullError("subscriptionKey");this.privAuthInfo=new s.AuthInfo(n.HeaderNames.AuthKey,e)}fetch(e){return Promise.resolve(this.privAuthInfo)}fetchOnExpiry(e){return Promise.resolve(this.privAuthInfo)}}},function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationStatus=void 0,n(r(5),t),n(r(24),t),n(r(25),t),n(r(27),t),n(r(28),t),n(r(29),t),n(r(26),t),n(r(30),t),n(r(31),t),n(r(7),t),n(r(32),t),n(r(33),t),n(r(34),t),n(r(35),t),n(r(36),t),n(r(37),t),n(r(38),t),n(r(39),t),n(r(40),t),n(r(41),t),n(r(42),t),n(r(6),t),n(r(43),t),n(r(44),t),n(r(45),t),n(r(46),t),n(r(47),t);var s=r(48);Object.defineProperty(t,"TranslationStatus",{enumerable:!0,get:function(){return s.TranslationStatus}}),n(r(49),t),n(r(50),t),n(r(51),t),n(r(52),t),n(r(53),t)},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AudioStreamNodeErrorEvent=t.AudioStreamNodeDetachedEvent=t.AudioStreamNodeAttachedEvent=t.AudioStreamNodeAttachingEvent=t.AudioStreamNodeEvent=t.AudioSourceErrorEvent=t.AudioSourceOffEvent=t.AudioSourceReadyEvent=t.AudioSourceInitializingEvent=t.AudioSourceEvent=void 0;const i=r(6);class n extends i.PlatformEvent{constructor(e,t,r=i.EventType.Info){super(e,r),this.privAudioSourceId=t}get audioSourceId(){return this.privAudioSourceId}}t.AudioSourceEvent=n;t.AudioSourceInitializingEvent=class extends n{constructor(e){super("AudioSourceInitializingEvent",e)}};t.AudioSourceReadyEvent=class extends n{constructor(e){super("AudioSourceReadyEvent",e)}};t.AudioSourceOffEvent=class extends n{constructor(e){super("AudioSourceOffEvent",e)}};t.AudioSourceErrorEvent=class extends n{constructor(e,t){super("AudioSourceErrorEvent",e,i.EventType.Error),this.privError=t}get error(){return this.privError}};class s extends n{constructor(e,t,r){super(e,t),this.privAudioNodeId=r}get audioNodeId(){return this.privAudioNodeId}}t.AudioStreamNodeEvent=s;t.AudioStreamNodeAttachingEvent=class extends s{constructor(e,t){super("AudioStreamNodeAttachingEvent",e,t)}};t.AudioStreamNodeAttachedEvent=class extends s{constructor(e,t){super("AudioStreamNodeAttachedEvent",e,t)}};t.AudioStreamNodeDetachedEvent=class extends s{constructor(e,t){super("AudioStreamNodeDetachedEvent",e,t)}};t.AudioStreamNodeErrorEvent=class extends s{constructor(e,t,r){super("AudioStreamNodeErrorEvent",e,t),this.privError=r}get error(){return this.privError}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformEvent=t.EventType=void 0;const i=r(7);!function(e){e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warning=2]="Warning",e[e.Error=3]="Error",e[e.None=4]="None"}(t.EventType||(t.EventType={}));t.PlatformEvent=class{constructor(e,t){this.privName=e,this.privEventId=(0,i.createNoDashGuid)(),this.privEventTime=(new Date).toISOString(),this.privEventType=t,this.privMetadata={}}get name(){return this.privName}get eventId(){return this.privEventId}get eventTime(){return this.privEventTime}get eventType(){return this.privEventType}get metadata(){return this.privMetadata}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createNoDashGuid=t.createGuid=void 0;const i=r(8),n=()=>(0,i.v4)();t.createGuid=n;t.createNoDashGuid=()=>n().replace(new RegExp("-","g"),"").toUpperCase()},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"NIL",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(t,"v1",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(t,"v3",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"v4",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(t,"v5",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(t,"validate",{enumerable:!0,get:function(){return p.default}}),Object.defineProperty(t,"version",{enumerable:!0,get:function(){return c.default}});var i=d(r(9)),n=d(r(14)),s=d(r(18)),o=d(r(20)),a=d(r(22)),c=d(r(23)),p=d(r(12)),h=d(r(11)),u=d(r(16));function d(e){return e&&e.__esModule?e:{default:e}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,n=(i=r(10))&&i.__esModule?i:{default:i},s=r(11);let o,a,c=0,p=0;var h=function(e,t,r){let i=t&&r||0;const h=t||new Array(16);let u=(e=e||{}).node||o,d=void 0!==e.clockseq?e.clockseq:a;if(null==u||null==d){const t=e.random||(e.rng||n.default)();null==u&&(u=o=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==d&&(d=a=16383&(t[6]<<8|t[7]))}let v=void 0!==e.msecs?e.msecs:Date.now(),l=void 0!==e.nsecs?e.nsecs:p+1;const g=v-c+(l-p)/1e4;if(g<0&&void 0===e.clockseq&&(d=d+1&16383),(g<0||v>c)&&void 0===e.nsecs&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");c=v,p=l,a=d,v+=122192928e5;const m=(1e4*(268435455&v)+l)%4294967296;h[i++]=m>>>24&255,h[i++]=m>>>16&255,h[i++]=m>>>8&255,h[i++]=255&m;const f=v/4294967296*1e4&268435455;h[i++]=f>>>8&255,h[i++]=255&f,h[i++]=f>>>24&15|16,h[i++]=f>>>16&255,h[i++]=d>>>8|128,h[i++]=255&d;for(let e=0;e<6;++e)h[i+e]=u[e];return t||(0,s.unsafeStringify)(h)};t.default=h},(e,t)=>{"use strict";let r;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(!r&&(r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!r))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(i)};const i=new Uint8Array(16)},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.unsafeStringify=o;var i,n=(i=r(12))&&i.__esModule?i:{default:i};const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));function o(e,t=0){return(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase()}var a=function(e,t=0){const r=o(e,t);if(!(0,n.default)(r))throw TypeError("Stringified UUID is invalid");return r};t.default=a},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,n=(i=r(13))&&i.__esModule?i:{default:i};var s=function(e){return"string"==typeof e&&n.default.test(e)};t.default=s},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=s(r(15)),n=s(r(17));function s(e){return e&&e.__esModule?e:{default:e}}var o=(0,i.default)("v3",48,n.default);t.default=o},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=void 0,t.default=function(e,t,r){function i(e,i,o,a){var c;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}(e)),"string"==typeof i&&(i=(0,s.default)(i)),16!==(null===(c=i)||void 0===c?void 0:c.length))throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let p=new Uint8Array(16+e.length);if(p.set(i),p.set(e,i.length),p=r(p),p[6]=15&p[6]|t,p[8]=63&p[8]|128,o){a=a||0;for(let e=0;e<16;++e)o[a+e]=p[e];return o}return(0,n.unsafeStringify)(p)}try{i.name=e}catch(e){}return i.DNS=o,i.URL=a,i};var i,n=r(11),s=(i=r(16))&&i.__esModule?i:{default:i};const o="6ba7b810-9dad-11d1-80b4-00c04fd430c8";t.DNS=o;const a="6ba7b811-9dad-11d1-80b4-00c04fd430c8";t.URL=a},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,n=(i=r(12))&&i.__esModule?i:{default:i};var s=function(e){if(!(0,n.default)(e))throw TypeError("Invalid UUID");let t;const r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r};t.default=s},(e,t)=>{"use strict";function r(e){return 14+(e+64>>>9<<4)+1}function i(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function n(e,t,r,n,s,o){return i((a=i(i(t,e),i(n,o)))<<(c=s)|a>>>32-c,r);var a,c}function s(e,t,r,i,s,o,a){return n(t&r|~t&i,e,t,s,o,a)}function o(e,t,r,i,s,o,a){return n(t&i|r&~i,e,t,s,o,a)}function a(e,t,r,i,s,o,a){return n(t^r^i,e,t,s,o,a)}function c(e,t,r,i,s,o,a){return n(r^(t|~i),e,t,s,o,a)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var p=function(e){if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r)}return function(e){const t=[],r=32*e.length,i="0123456789abcdef";for(let n=0;n<r;n+=8){const r=e[n>>5]>>>n%32&255,s=parseInt(i.charAt(r>>>4&15)+i.charAt(15&r),16);t.push(s)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[r(t)-1]=t;let n=1732584193,p=-271733879,h=-1732584194,u=271733878;for(let t=0;t<e.length;t+=16){const r=n,d=p,v=h,l=u;n=s(n,p,h,u,e[t],7,-680876936),u=s(u,n,p,h,e[t+1],12,-389564586),h=s(h,u,n,p,e[t+2],17,606105819),p=s(p,h,u,n,e[t+3],22,-1044525330),n=s(n,p,h,u,e[t+4],7,-176418897),u=s(u,n,p,h,e[t+5],12,1200080426),h=s(h,u,n,p,e[t+6],17,-1473231341),p=s(p,h,u,n,e[t+7],22,-45705983),n=s(n,p,h,u,e[t+8],7,1770035416),u=s(u,n,p,h,e[t+9],12,-1958414417),h=s(h,u,n,p,e[t+10],17,-42063),p=s(p,h,u,n,e[t+11],22,-1990404162),n=s(n,p,h,u,e[t+12],7,1804603682),u=s(u,n,p,h,e[t+13],12,-40341101),h=s(h,u,n,p,e[t+14],17,-1502002290),p=s(p,h,u,n,e[t+15],22,1236535329),n=o(n,p,h,u,e[t+1],5,-165796510),u=o(u,n,p,h,e[t+6],9,-1069501632),h=o(h,u,n,p,e[t+11],14,643717713),p=o(p,h,u,n,e[t],20,-373897302),n=o(n,p,h,u,e[t+5],5,-701558691),u=o(u,n,p,h,e[t+10],9,38016083),h=o(h,u,n,p,e[t+15],14,-660478335),p=o(p,h,u,n,e[t+4],20,-405537848),n=o(n,p,h,u,e[t+9],5,568446438),u=o(u,n,p,h,e[t+14],9,-1019803690),h=o(h,u,n,p,e[t+3],14,-187363961),p=o(p,h,u,n,e[t+8],20,1163531501),n=o(n,p,h,u,e[t+13],5,-1444681467),u=o(u,n,p,h,e[t+2],9,-51403784),h=o(h,u,n,p,e[t+7],14,1735328473),p=o(p,h,u,n,e[t+12],20,-1926607734),n=a(n,p,h,u,e[t+5],4,-378558),u=a(u,n,p,h,e[t+8],11,-2022574463),h=a(h,u,n,p,e[t+11],16,1839030562),p=a(p,h,u,n,e[t+14],23,-35309556),n=a(n,p,h,u,e[t+1],4,-1530992060),u=a(u,n,p,h,e[t+4],11,1272893353),h=a(h,u,n,p,e[t+7],16,-155497632),p=a(p,h,u,n,e[t+10],23,-1094730640),n=a(n,p,h,u,e[t+13],4,681279174),u=a(u,n,p,h,e[t],11,-358537222),h=a(h,u,n,p,e[t+3],16,-722521979),p=a(p,h,u,n,e[t+6],23,76029189),n=a(n,p,h,u,e[t+9],4,-640364487),u=a(u,n,p,h,e[t+12],11,-421815835),h=a(h,u,n,p,e[t+15],16,530742520),p=a(p,h,u,n,e[t+2],23,-995338651),n=c(n,p,h,u,e[t],6,-198630844),u=c(u,n,p,h,e[t+7],10,1126891415),h=c(h,u,n,p,e[t+14],15,-1416354905),p=c(p,h,u,n,e[t+5],21,-57434055),n=c(n,p,h,u,e[t+12],6,1700485571),u=c(u,n,p,h,e[t+3],10,-1894986606),h=c(h,u,n,p,e[t+10],15,-1051523),p=c(p,h,u,n,e[t+1],21,-2054922799),n=c(n,p,h,u,e[t+8],6,1873313359),u=c(u,n,p,h,e[t+15],10,-30611744),h=c(h,u,n,p,e[t+6],15,-1560198380),p=c(p,h,u,n,e[t+13],21,1309151649),n=c(n,p,h,u,e[t+4],6,-145523070),u=c(u,n,p,h,e[t+11],10,-1120210379),h=c(h,u,n,p,e[t+2],15,718787259),p=c(p,h,u,n,e[t+9],21,-343485551),n=i(n,r),p=i(p,d),h=i(h,v),u=i(u,l)}return[n,p,h,u]}(function(e){if(0===e.length)return[];const t=8*e.length,i=new Uint32Array(r(t));for(let r=0;r<t;r+=8)i[r>>5]|=(255&e[r/8])<<r%32;return i}(e),8*e.length))};t.default=p},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=o(r(19)),n=o(r(10)),s=r(11);function o(e){return e&&e.__esModule?e:{default:e}}var a=function(e,t,r){if(i.default.randomUUID&&!t&&!e)return i.default.randomUUID();const o=(e=e||{}).random||(e.rng||n.default)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=o[e];return t}return(0,s.unsafeStringify)(o)};t.default=a},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};t.default=r},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=s(r(15)),n=s(r(21));function s(e){return e&&e.__esModule?e:{default:e}}var o=(0,i.default)("v5",80,n.default);t.default=o},(e,t)=>{"use strict";function r(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:case 3:return t^r^i;case 2:return t&r^t&i^r&i}}function i(e,t){return e<<t|e>>>32-t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(e){const t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);const s=e.length/4+2,o=Math.ceil(s/16),a=new Array(o);for(let t=0;t<o;++t){const r=new Uint32Array(16);for(let i=0;i<16;++i)r[i]=e[64*t+4*i]<<24|e[64*t+4*i+1]<<16|e[64*t+4*i+2]<<8|e[64*t+4*i+3];a[t]=r}a[o-1][14]=8*(e.length-1)/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<o;++e){const s=new Uint32Array(80);for(let t=0;t<16;++t)s[t]=a[e][t];for(let e=16;e<80;++e)s[e]=i(s[e-3]^s[e-8]^s[e-14]^s[e-16],1);let o=n[0],c=n[1],p=n[2],h=n[3],u=n[4];for(let e=0;e<80;++e){const n=Math.floor(e/20),a=i(o,5)+r(n,c,p,h)+u+t[n]+s[e]>>>0;u=h,h=p,p=i(c,30)>>>0,c=o,o=a}n[0]=n[0]+o>>>0,n[1]=n[1]+c>>>0,n[2]=n[2]+p>>>0,n[3]=n[3]+h>>>0,n[4]=n[4]+u>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]};t.default=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default="00000000-0000-0000-0000-000000000000"},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,n=(i=r(12))&&i.__esModule?i:{default:i};var s=function(e){if(!(0,n.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)};t.default=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionRedirectEvent=t.ConnectionMessageSentEvent=t.ConnectionMessageReceivedEvent=t.ConnectionEstablishErrorEvent=t.ConnectionErrorEvent=t.ConnectionClosedEvent=t.ConnectionEstablishedEvent=t.ConnectionStartEvent=t.ConnectionEvent=t.ServiceEvent=void 0;const i=r(6);class n extends i.PlatformEvent{constructor(e,t,r=i.EventType.Info){super(e,r),this.privJsonResult=t}get jsonString(){return this.privJsonResult}}t.ServiceEvent=n;class s extends i.PlatformEvent{constructor(e,t,r=i.EventType.Info){super(e,r),this.privConnectionId=t}get connectionId(){return this.privConnectionId}}t.ConnectionEvent=s;t.ConnectionStartEvent=class extends s{constructor(e,t,r){super("ConnectionStartEvent",e),this.privUri=t,this.privHeaders=r}get uri(){return this.privUri}get headers(){return this.privHeaders}};t.ConnectionEstablishedEvent=class extends s{constructor(e){super("ConnectionEstablishedEvent",e)}};t.ConnectionClosedEvent=class extends s{constructor(e,t,r){super("ConnectionClosedEvent",e,i.EventType.Debug),this.privReason=r,this.privStatusCode=t}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};t.ConnectionErrorEvent=class extends s{constructor(e,t,r){super("ConnectionErrorEvent",e,i.EventType.Debug),this.privMessage=t,this.privType=r}get message(){return this.privMessage}get type(){return this.privType}};t.ConnectionEstablishErrorEvent=class extends s{constructor(e,t,r){super("ConnectionEstablishErrorEvent",e,i.EventType.Error),this.privStatusCode=t,this.privReason=r}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};t.ConnectionMessageReceivedEvent=class extends s{constructor(e,t,r){super("ConnectionMessageReceivedEvent",e),this.privNetworkReceivedTime=t,this.privMessage=r}get networkReceivedTime(){return this.privNetworkReceivedTime}get message(){return this.privMessage}};t.ConnectionMessageSentEvent=class extends s{constructor(e,t,r){super("ConnectionMessageSentEvent",e),this.privNetworkSentTime=t,this.privMessage=r}get networkSentTime(){return this.privNetworkSentTime}get message(){return this.privMessage}};t.ConnectionRedirectEvent=class extends s{constructor(e,t,r,n){super("ConnectionRedirectEvent",e,i.EventType.Info),this.privRedirectUrl=t,this.privOriginalUrl=r,this.privContext=n}get redirectUrl(){return this.privRedirectUrl}get originalUrl(){return this.privOriginalUrl}get context(){return this.privContext}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionMessage=t.MessageType=void 0;const i=r(26),n=r(7);var s;!function(e){e[e.Text=0]="Text",e[e.Binary=1]="Binary"}(s=t.MessageType||(t.MessageType={}));t.ConnectionMessage=class{constructor(e,t,r,o){if(this.privBody=null,e===s.Text&&t&&"string"!=typeof t)throw new i.InvalidOperationError("Payload must be a string");if(e===s.Binary&&t&&!(t instanceof ArrayBuffer))throw new i.InvalidOperationError("Payload must be ArrayBuffer");switch(this.privMessageType=e,this.privBody=t,this.privHeaders=r||{},this.privId=o||(0,n.createNoDashGuid)(),this.messageType){case s.Binary:this.privSize=null!==this.binaryBody?this.binaryBody.byteLength:0;break;case s.Text:this.privSize=this.textBody.length}}get messageType(){return this.privMessageType}get headers(){return this.privHeaders}get body(){return this.privBody}get textBody(){if(this.privMessageType===s.Binary)throw new i.InvalidOperationError("Not supported for binary message");return this.privBody}get binaryBody(){if(this.privMessageType===s.Text)throw new i.InvalidOperationError("Not supported for text message");return this.privBody}get id(){return this.privId}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ObjectDisposedError=t.InvalidOperationError=t.ArgumentNullError=void 0;class r extends Error{constructor(e){super(e),this.name="ArgumentNull",this.message=e}}t.ArgumentNullError=r;class i extends Error{constructor(e){super(e),this.name="InvalidOperation",this.message=e}}t.InvalidOperationError=i;class n extends Error{constructor(e,t){super(t),this.name=e+"ObjectDisposed",this.message=t}}t.ObjectDisposedError=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionOpenResponse=void 0;t.ConnectionOpenResponse=class{constructor(e,t){this.privStatusCode=e,this.privReason=t}get statusCode(){return this.privStatusCode}get reason(){return this.privReason}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DeferralMap=void 0;t.DeferralMap=class{constructor(){this.privMap={}}add(e,t){this.privMap[e]=t}getId(e){return this.privMap[e]}complete(e,t){try{this.privMap[e].resolve(t)}catch(t){this.privMap[e].reject(t)}finally{this.privMap[e]=void 0}}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SendingAgentContextMessageEvent=t.DialogEvent=void 0;const i=r(6);class n extends i.PlatformEvent{constructor(e,t=i.EventType.Info){super(e,t)}}t.DialogEvent=n;t.SendingAgentContextMessageEvent=class extends n{constructor(e){super("SendingAgentContextMessageEvent"),this.privAgentConfig=e}get agentConfig(){return this.privAgentConfig}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Events=void 0;const i=r(26),n=r(31);class s{static setEventSource(e){if(!e)throw new i.ArgumentNullError("eventSource");s.privInstance=e}static get instance(){return s.privInstance}}t.Events=s,s.privInstance=new n.EventSource},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventSource=void 0;const i=r(26),n=r(7);t.EventSource=class{constructor(e){this.privEventListeners={},this.privIsDisposed=!1,this.privConsoleListener=void 0,this.privMetadata=e}onEvent(e){if(this.isDisposed())throw new i.ObjectDisposedError("EventSource");if(this.metadata)for(const t in this.metadata)t&&e.metadata&&(e.metadata[t]||(e.metadata[t]=this.metadata[t]));for(const t in this.privEventListeners)t&&this.privEventListeners[t]&&this.privEventListeners[t](e)}attach(e){const t=(0,n.createNoDashGuid)();return this.privEventListeners[t]=e,{detach:()=>(delete this.privEventListeners[t],Promise.resolve())}}attachListener(e){return this.attach((t=>e.onEvent(t)))}attachConsoleListener(e){return this.privConsoleListener&&this.privConsoleListener.detach(),this.privConsoleListener=this.attach((t=>e.onEvent(t))),this.privConsoleListener}isDisposed(){return this.privIsDisposed}dispose(){this.privEventListeners=null,this.privIsDisposed=!0}get metadata(){return this.privMetadata}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionState=void 0,function(e){e[e.None=0]="None",e[e.Connected=1]="Connected",e[e.Connecting=2]="Connecting",e[e.Disconnected=3]="Disconnected"}(t.ConnectionState||(t.ConnectionState={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.List=void 0;const i=r(26);class n{constructor(e){if(this.privSubscriptionIdCounter=0,this.privAddSubscriptions={},this.privRemoveSubscriptions={},this.privDisposedSubscriptions={},this.privDisposeReason=null,this.privList=[],e)for(const t of e)this.privList.push(t)}get(e){return this.throwIfDisposed(),this.privList[e]}first(){return this.get(0)}last(){return this.get(this.length()-1)}add(e){this.throwIfDisposed(),this.insertAt(this.privList.length,e)}insertAt(e,t){this.throwIfDisposed(),0===e?this.privList.unshift(t):e===this.privList.length?this.privList.push(t):this.privList.splice(e,0,t),this.triggerSubscriptions(this.privAddSubscriptions)}removeFirst(){return this.throwIfDisposed(),this.removeAt(0)}removeLast(){return this.throwIfDisposed(),this.removeAt(this.length()-1)}removeAt(e){return this.throwIfDisposed(),this.remove(e,1)[0]}remove(e,t){this.throwIfDisposed();const r=this.privList.splice(e,t);return this.triggerSubscriptions(this.privRemoveSubscriptions),r}clear(){this.throwIfDisposed(),this.remove(0,this.length())}length(){return this.throwIfDisposed(),this.privList.length}onAdded(e){this.throwIfDisposed();const t=this.privSubscriptionIdCounter++;return this.privAddSubscriptions[t]=e,{detach:()=>(delete this.privAddSubscriptions[t],Promise.resolve())}}onRemoved(e){this.throwIfDisposed();const t=this.privSubscriptionIdCounter++;return this.privRemoveSubscriptions[t]=e,{detach:()=>(delete this.privRemoveSubscriptions[t],Promise.resolve())}}onDisposed(e){this.throwIfDisposed();const t=this.privSubscriptionIdCounter++;return this.privDisposedSubscriptions[t]=e,{detach:()=>(delete this.privDisposedSubscriptions[t],Promise.resolve())}}join(e){return this.throwIfDisposed(),this.privList.join(e)}toArray(){const e=Array();return this.privList.forEach((t=>{e.push(t)})),e}any(e){return this.throwIfDisposed(),e?this.where(e).length()>0:this.length()>0}all(e){return this.throwIfDisposed(),this.where(e).length()===this.length()}forEach(e){this.throwIfDisposed();for(let t=0;t<this.length();t++)e(this.privList[t],t)}select(e){this.throwIfDisposed();const t=[];for(let r=0;r<this.privList.length;r++)t.push(e(this.privList[r],r));return new n(t)}where(e){this.throwIfDisposed();const t=new n;for(let r=0;r<this.privList.length;r++)e(this.privList[r],r)&&t.add(this.privList[r]);return t}orderBy(e){this.throwIfDisposed();const t=this.toArray().sort(e);return new n(t)}orderByDesc(e){return this.throwIfDisposed(),this.orderBy(((t,r)=>e(r,t)))}clone(){return this.throwIfDisposed(),new n(this.toArray())}concat(e){return this.throwIfDisposed(),new n(this.privList.concat(e.toArray()))}concatArray(e){return this.throwIfDisposed(),new n(this.privList.concat(e))}isDisposed(){return null==this.privList}dispose(e){this.isDisposed()||(this.privDisposeReason=e,this.privList=null,this.privAddSubscriptions=null,this.privRemoveSubscriptions=null,this.triggerSubscriptions(this.privDisposedSubscriptions))}throwIfDisposed(){if(this.isDisposed())throw new i.ObjectDisposedError("List",this.privDisposeReason)}triggerSubscriptions(e){if(e)for(const t in e)t&&e[t]()}}t.List=n},(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.marshalPromiseToCallbacks=t.Sink=t.Deferred=t.PromiseResultEventSource=t.PromiseResult=t.PromiseState=void 0,function(e){e[e.None=0]="None",e[e.Resolved=1]="Resolved",e[e.Rejected=2]="Rejected"}(r=t.PromiseState||(t.PromiseState={}));class i{constructor(e){this.throwIfError=()=>{if(this.isError)throw this.error},e.on((e=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!1,this.privResult=e)}),(e=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!0,this.privError=e)}))}get isCompleted(){return this.privIsCompleted}get isError(){return this.privIsError}get error(){return this.privError}get result(){return this.privResult}}t.PromiseResult=i;class n{constructor(){this.setResult=e=>{this.privOnSetResult(e)},this.setError=e=>{this.privOnSetError(e)},this.on=(e,t)=>{this.privOnSetResult=e,this.privOnSetError=t}}}t.PromiseResultEventSource=n;t.Deferred=class{constructor(){this.resolve=e=>(this.privResolve(e),this),this.reject=e=>(this.privReject(e),this),this.privPromise=new Promise(((e,t)=>{this.privResolve=e,this.privReject=t}))}get promise(){return this.privPromise}};t.Sink=class{constructor(){this.privState=r.None,this.privPromiseResult=null,this.privPromiseResultEvents=null,this.privSuccessHandlers=[],this.privErrorHandlers=[],this.privPromiseResultEvents=new n,this.privPromiseResult=new i(this.privPromiseResultEvents)}get state(){return this.privState}get result(){return this.privPromiseResult}resolve(e){if(this.privState!==r.None)throw new Error("'Cannot resolve a completed promise'");this.privState=r.Resolved,this.privPromiseResultEvents.setResult(e);for(let t=0;t<this.privSuccessHandlers.length;t++)this.executeSuccessCallback(e,this.privSuccessHandlers[t],this.privErrorHandlers[t]);this.detachHandlers()}reject(e){if(this.privState!==r.None)throw new Error("'Cannot reject a completed promise'");this.privState=r.Rejected,this.privPromiseResultEvents.setError(e);for(const t of this.privErrorHandlers)this.executeErrorCallback(e,t);this.detachHandlers()}on(e,t){null==e&&(e=()=>{}),this.privState===r.None?(this.privSuccessHandlers.push(e),this.privErrorHandlers.push(t)):(this.privState===r.Resolved?this.executeSuccessCallback(this.privPromiseResult.result,e,t):this.privState===r.Rejected&&this.executeErrorCallback(this.privPromiseResult.error,t),this.detachHandlers())}executeSuccessCallback(e,t,r){try{t(e)}catch(e){this.executeErrorCallback(`'Unhandled callback error: ${e}'`,r)}}executeErrorCallback(e,t){if(!t)throw new Error(`'Unhandled error: ${e}'`);try{t(e)}catch(t){throw new Error(`'Unhandled callback error: ${t}. InnerError: ${e}'`)}}detachHandlers(){this.privErrorHandlers=[],this.privSuccessHandlers=[]}},t.marshalPromiseToCallbacks=function(e,t,r){e.then((e=>{try{t&&t(e)}catch(e){if(r)try{if(e instanceof Error){const t=e;r(t.name+": "+t.message)}else r(e)}catch(e){}}}),(e=>{if(r)try{if(e instanceof Error){const t=e;r(t.name+": "+t.message)}else r(e)}catch(e){}}))}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Queue=void 0;const i=r(26),n=r(42),s=r(43);var o;!function(e){e[e.Dequeue=0]="Dequeue",e[e.Peek=1]="Peek"}(o||(o={}));t.Queue=class{constructor(e){this.privPromiseStore=new n.List,this.privIsDrainInProgress=!1,this.privIsDisposing=!1,this.privDisposeReason=null,this.privList=e||new n.List,this.privDetachables=[],this.privSubscribers=new n.List,this.privDetachables.push(this.privList.onAdded((()=>this.drain())))}enqueue(e){this.throwIfDispose(),this.enqueueFromPromise(new Promise((t=>t(e))))}enqueueFromPromise(e){this.throwIfDispose(),e.then((e=>{this.privList.add(e)}),(()=>{}))}dequeue(){this.throwIfDispose();const e=new s.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:o.Dequeue}),this.drain()),e.promise}peek(){this.throwIfDispose();const e=new s.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:o.Peek}),this.drain()),e.promise}length(){return this.throwIfDispose(),this.privList.length()}isDisposed(){return null==this.privSubscribers}async drainAndDispose(e,t){if(!this.isDisposed()&&!this.privIsDisposing){this.privDisposeReason=t,this.privIsDisposing=!0;const r=this.privSubscribers;if(r){for(;r.length()>0;){r.removeFirst().deferral.resolve(void 0)}this.privSubscribers===r&&(this.privSubscribers=r)}for(const e of this.privDetachables)await e.detach();if(this.privPromiseStore.length()>0&&e){const t=[];return this.privPromiseStore.toArray().forEach((e=>{t.push(e)})),Promise.all(t).finally((()=>{this.privSubscribers=null,this.privList.forEach((t=>{e(t)})),this.privList=null})).then()}this.privSubscribers=null,this.privList=null}}async dispose(e){await this.drainAndDispose(null,e)}drain(){if(!this.privIsDrainInProgress&&!this.privIsDisposing){this.privIsDrainInProgress=!0;const e=this.privSubscribers,t=this.privList;if(e&&t){for(;t.length()>0&&e.length()>0&&!this.privIsDisposing;){const r=e.removeFirst();if(r.type===o.Peek)r.deferral.resolve(t.first());else{const e=t.removeFirst();r.deferral.resolve(e)}}this.privSubscribers===e&&(this.privSubscribers=e),this.privList===t&&(this.privList=t)}this.privIsDrainInProgress=!1}}throwIfDispose(){if(this.isDisposed()){if(this.privDisposeReason)throw new i.InvalidOperationError(this.privDisposeReason);throw new i.ObjectDisposedError("Queue")}if(this.privIsDisposing)throw new i.InvalidOperationError("Queue disposing")}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RawWebsocketMessage=void 0;const i=r(25),n=r(26),s=r(7);t.RawWebsocketMessage=class{constructor(e,t,r){if(this.privPayload=null,!t)throw new n.ArgumentNullError("payload");if(e===i.MessageType.Binary&&"ArrayBuffer"!==Object.getPrototypeOf(t).constructor.name)throw new n.InvalidOperationError("Payload must be ArrayBuffer");if(e===i.MessageType.Text&&"string"!=typeof t)throw new n.InvalidOperationError("Payload must be a string");this.privMessageType=e,this.privPayload=t,this.privId=r||(0,s.createNoDashGuid)()}get messageType(){return this.privMessageType}get payload(){return this.privPayload}get textContent(){if(this.privMessageType===i.MessageType.Binary)throw new n.InvalidOperationError("Not supported for binary message");return this.privPayload}get binaryContent(){if(this.privMessageType===i.MessageType.Text)throw new n.InvalidOperationError("Not supported for text message");return this.privPayload}get id(){return this.privId}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RiffPcmEncoder=void 0;t.RiffPcmEncoder=class{constructor(e,t){this.privActualSampleRate=e,this.privDesiredSampleRate=t}encode(e){const t=this.downSampleAudioFrame(e,this.privActualSampleRate,this.privDesiredSampleRate);if(!t)return null;const r=2*t.length,i=new ArrayBuffer(r),n=new DataView(i);return this.floatTo16BitPCM(n,0,t),i}setString(e,t,r){for(let i=0;i<r.length;i++)e.setUint8(t+i,r.charCodeAt(i))}floatTo16BitPCM(e,t,r){for(let i=0;i<r.length;i++,t+=2){const n=Math.max(-1,Math.min(1,r[i]));e.setInt16(t,n<0?32768*n:32767*n,!0)}}downSampleAudioFrame(e,t,r){if(!e)return null;if(r===t||r>t)return e;const i=t/r,n=Math.round(e.length/i),s=new Float32Array(n);let o=0,a=0;for(;a<n;){const t=Math.round((a+1)*i);let r=0,n=0;for(;o<t&&o<e.length;)r+=e[o++],n++;s[a++]=r/n}return s}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Stream=void 0;const i=r(26),n=r(7),s=r(44);t.Stream=class{constructor(e){this.privIsWriteEnded=!1,this.privIsReadEnded=!1,this.privId=e||(0,n.createNoDashGuid)(),this.privReaderQueue=new s.Queue}get isClosed(){return this.privIsWriteEnded}get isReadEnded(){return this.privIsReadEnded}get id(){return this.privId}close(){this.privIsWriteEnded||(this.writeStreamChunk({buffer:null,isEnd:!0,timeReceived:Date.now()}),this.privIsWriteEnded=!0)}writeStreamChunk(e){if(this.throwIfClosed(),!this.privReaderQueue.isDisposed())try{this.privReaderQueue.enqueue(e)}catch(e){}}read(){if(this.privIsReadEnded)throw new i.InvalidOperationError("Stream read has already finished");return this.privReaderQueue.dequeue().then((async e=>((void 0===e||e.isEnd)&&await this.privReaderQueue.dispose("End of stream reached"),e)))}readEnded(){this.privIsReadEnded||(this.privIsReadEnded=!0,this.privReaderQueue=new s.Queue)}throwIfClosed(){if(this.privIsWriteEnded)throw new i.InvalidOperationError("Stream closed")}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationStatus=void 0,function(e){e[e.Success=0]="Success",e[e.Error=1]="Error"}(t.TranslationStatus||(t.TranslationStatus={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChunkedArrayBufferStream=void 0;const i=r(4);class n extends i.Stream{constructor(e,t){super(t),this.privTargetChunkSize=Math.round(e),this.privNextBufferReadyBytes=0}writeStreamChunk(e){if(e.isEnd||0===this.privNextBufferReadyBytes&&e.buffer.byteLength===this.privTargetChunkSize)return void super.writeStreamChunk(e);let t=0;for(;t<e.buffer.byteLength;){void 0===this.privNextBufferToWrite&&(this.privNextBufferToWrite=new ArrayBuffer(this.privTargetChunkSize),this.privNextBufferStartTime=e.timeReceived);const r=Math.min(e.buffer.byteLength-t,this.privTargetChunkSize-this.privNextBufferReadyBytes),i=new Uint8Array(this.privNextBufferToWrite),n=new Uint8Array(e.buffer.slice(t,r+t));i.set(n,this.privNextBufferReadyBytes),this.privNextBufferReadyBytes+=r,t+=r,this.privNextBufferReadyBytes===this.privTargetChunkSize&&(super.writeStreamChunk({buffer:this.privNextBufferToWrite,isEnd:!1,timeReceived:this.privNextBufferStartTime}),this.privNextBufferReadyBytes=0,this.privNextBufferToWrite=void 0)}}close(){0===this.privNextBufferReadyBytes||this.isClosed||super.writeStreamChunk({buffer:this.privNextBufferToWrite.slice(0,this.privNextBufferReadyBytes),isEnd:!1,timeReceived:this.privNextBufferStartTime}),super.close()}}t.ChunkedArrayBufferStream=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0;class r{static load(){const e=new Map([[0,()=>{}]]),t=new Map,i="data:text/javascript;base64,"+btoa('!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return a})),n.d(t,"d",(function(){return d}));const r=new Map,o=new Map,i=e=>{const t=r.get(e);if(void 0===t)throw new Error(\'There is no interval scheduled with the given id "\'.concat(e,\'".\'));clearTimeout(t),r.delete(e)},u=e=>{const t=o.get(e);if(void 0===t)throw new Error(\'There is no timeout scheduled with the given id "\'.concat(e,\'".\'));clearTimeout(t),o.delete(e)},f=(e,t)=>{let n,r;if("performance"in self){const o=performance.now();n=o,r=e-Math.max(0,o-t)}else n=Date.now(),r=e;return{expected:n+r,remainingDelay:r}},c=(e,t,n,r)=>{const o="performance"in self?performance.now():Date.now();o>n?postMessage({id:null,method:"call",params:{timerId:t}}):e.set(t,setTimeout(c,n-o,e,t,n))},a=(e,t,n)=>{const{expected:o,remainingDelay:i}=f(e,n);r.set(t,setTimeout(c,i,r,t,o))},d=(e,t,n)=>{const{expected:r,remainingDelay:i}=f(e,n);o.set(t,setTimeout(c,i,o,t,r))}},function(e,t,n){"use strict";n.r(t);var r=n(2);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(3);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(4);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o);var f=n(5);for(var o in f)"default"!==o&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var c=n(6);for(var o in c)"default"!==o&&function(e){n.d(t,e,(function(){return c[e]}))}(o);var a=n(7);for(var o in a)"default"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var d=n(8);for(var o in d)"default"!==o&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var s=n(9);for(var o in s)"default"!==o&&function(e){n.d(t,e,(function(){return s[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(11);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(12);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(13);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(1);for(var i in o)"default"!==i&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var u=n(10);for(var i in u)"default"!==i&&function(e){n.d(t,e,(function(){return u[e]}))}(i);addEventListener("message",({data:e})=>{try{if("clear"===e.method){const{id:t,params:{timerId:n}}=e;Object(r.b)(n),postMessage({error:null,id:t})}else{if("set"!==e.method)throw new Error(\'The given method "\'.concat(e.method,\'" is not supported\'));{const{params:{delay:t,now:n,timerId:o}}=e;Object(r.d)(t,o,n)}}}catch(t){postMessage({error:{message:t.message},id:e.id,result:null})}})}]);'),n=new Worker(i);n.addEventListener("message",(({data:i})=>{if(r.isCallNotification(i)){const{params:{timerId:r}}=i,n=e.get(r);if("number"==typeof n){const e=t.get(n);if(void 0===e||e!==r)throw new Error("The timer is in an undefined state.")}else{if(void 0===n)throw new Error("The timer is in an undefined state.");n(),e.delete(r)}}else{if(!r.isClearResponse(i)){const{error:{message:e}}=i;throw new Error(e)}{const{id:r}=i,n=t.get(r);if(void 0===n)throw new Error("The timer is in an undefined state.");t.delete(r),e.delete(n)}}}));return{clearTimeout:r=>{const i=Math.random();t.set(i,r),e.set(r,i),n.postMessage({id:i,method:"clear",params:{timerId:r}})},setTimeout:(t,r)=>{const i=Math.random();return e.set(i,t),n.postMessage({id:null,method:"set",params:{delay:r,now:performance.now(),timerId:i}}),i}}}static loadWorkerTimers(){return()=>(null!==r.workerTimers||(r.workerTimers=r.load()),r.workerTimers)}static isCallNotification(e){return void 0!==e.method&&"call"===e.method}static isClearResponse(e){return null===e.error&&"number"==typeof e.id}}t.Timeout=r,r.workerTimers=null,r.clearTimeout=e=>r.timers().clearTimeout(e),r.setTimeout=(e,t)=>r.timers().setTimeout(e,t),r.timers=r.loadWorkerTimers()},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OCSPCacheUpdateErrorEvent=t.OCSPResponseRetrievedEvent=t.OCSPCacheFetchErrorEvent=t.OCSPVerificationFailedEvent=t.OCSPCacheHitEvent=t.OCSPCacheEntryNeedsRefreshEvent=t.OCSPCacheEntryExpiredEvent=t.OCSPWSUpgradeStartedEvent=t.OCSPStapleReceivedEvent=t.OCSPCacheUpdateCompleteEvent=t.OCSPDiskCacheStoreEvent=t.OCSPMemoryCacheStoreEvent=t.OCSPCacheUpdateNeededEvent=t.OCSPDiskCacheHitEvent=t.OCSPCacheMissEvent=t.OCSPMemoryCacheHitEvent=t.OCSPEvent=void 0;const i=r(6);class n extends i.PlatformEvent{constructor(e,t,r){super(e,t),this.privSignature=r}}t.OCSPEvent=n;t.OCSPMemoryCacheHitEvent=class extends n{constructor(e){super("OCSPMemoryCacheHitEvent",i.EventType.Debug,e)}};t.OCSPCacheMissEvent=class extends n{constructor(e){super("OCSPCacheMissEvent",i.EventType.Debug,e)}};t.OCSPDiskCacheHitEvent=class extends n{constructor(e){super("OCSPDiskCacheHitEvent",i.EventType.Debug,e)}};t.OCSPCacheUpdateNeededEvent=class extends n{constructor(e){super("OCSPCacheUpdateNeededEvent",i.EventType.Debug,e)}};t.OCSPMemoryCacheStoreEvent=class extends n{constructor(e){super("OCSPMemoryCacheStoreEvent",i.EventType.Debug,e)}};t.OCSPDiskCacheStoreEvent=class extends n{constructor(e){super("OCSPDiskCacheStoreEvent",i.EventType.Debug,e)}};t.OCSPCacheUpdateCompleteEvent=class extends n{constructor(e){super("OCSPCacheUpdateCompleteEvent",i.EventType.Debug,e)}};t.OCSPStapleReceivedEvent=class extends n{constructor(){super("OCSPStapleReceivedEvent",i.EventType.Debug,"")}};t.OCSPWSUpgradeStartedEvent=class extends n{constructor(e){super("OCSPWSUpgradeStartedEvent",i.EventType.Debug,e)}};t.OCSPCacheEntryExpiredEvent=class extends n{constructor(e,t){super("OCSPCacheEntryExpiredEvent",i.EventType.Debug,e),this.privExpireTime=t}};t.OCSPCacheEntryNeedsRefreshEvent=class extends n{constructor(e,t,r){super("OCSPCacheEntryNeedsRefreshEvent",i.EventType.Debug,e),this.privExpireTime=r,this.privStartTime=t}};t.OCSPCacheHitEvent=class extends n{constructor(e,t,r){super("OCSPCacheHitEvent",i.EventType.Debug,e),this.privExpireTime=r,this.privExpireTimeString=new Date(r).toLocaleDateString(),this.privStartTime=t,this.privStartTimeString=new Date(t).toLocaleTimeString()}};t.OCSPVerificationFailedEvent=class extends n{constructor(e,t){super("OCSPVerificationFailedEvent",i.EventType.Debug,e),this.privError=t}};t.OCSPCacheFetchErrorEvent=class extends n{constructor(e,t){super("OCSPCacheFetchErrorEvent",i.EventType.Debug,e),this.privError=t}};t.OCSPResponseRetrievedEvent=class extends n{constructor(e){super("OCSPResponseRetrievedEvent",i.EventType.Debug,e)}};t.OCSPCacheUpdateErrorEvent=class extends n{constructor(e,t){super("OCSPCacheUpdateErrorEvent",i.EventType.Debug,e),this.privError=t}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BackgroundEvent=void 0;const i=r(4);class n extends i.PlatformEvent{constructor(e){super("BackgroundEvent",i.EventType.Error),this.privError=e}get error(){return this.privError}}t.BackgroundEvent=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HeaderNames=void 0;class r{}t.HeaderNames=r,r.AuthKey="Ocp-Apim-Subscription-Key",r.Authorization="Authorization",r.SpIDAuthKey="Apim-Subscription-Id",r.ConnectionId="X-ConnectionId",r.ContentType="Content-Type",r.CustomCommandsAppId="X-CommandsAppId",r.Path="Path",r.RequestId="X-RequestId",r.RequestStreamId="X-StreamId",r.RequestTimestamp="X-Timestamp"},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AuthInfo=void 0;t.AuthInfo=class{constructor(e,t){this.privHeaderName=e,this.privToken=t}get headerName(){return this.privHeaderName}get token(){return this.privToken}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CognitiveTokenAuthentication=void 0;const i=r(4),n=r(55),s=r(54);class o{constructor(e,t){if(!e)throw new i.ArgumentNullError("fetchCallback");if(!t)throw new i.ArgumentNullError("fetchOnExpiryCallback");this.privFetchCallback=e,this.privFetchOnExpiryCallback=t}fetch(e){return this.privFetchCallback(e).then((e=>new n.AuthInfo(s.HeaderNames.Authorization,void 0===e?void 0:o.privTokenPrefix+e)))}fetchOnExpiry(e){return this.privFetchOnExpiryCallback(e).then((e=>new n.AuthInfo(s.HeaderNames.Authorization,void 0===e?void 0:o.privTokenPrefix+e)))}}t.CognitiveTokenAuthentication=o,o.privTokenPrefix="Bearer "},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntentConnectionFactory=void 0;const i=r(60),n=r(79),s=r(135),o=r(2),a=r(54);class c extends s.ConnectionFactoryBase{create(e,t,r){let c=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Endpoint);if(!c){const t=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_IntentRegion),r=s.ConnectionFactoryBase.getHostSuffix(t);c=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Host,"wss://"+t+".sr.speech"+r)+"/speech/recognition/interactive/cognitiveservices/v1"}const p={format:"simple",language:e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,p,c);const h={};void 0!==t.token&&""!==t.token&&(h[t.headerName]=t.token),h[a.HeaderNames.ConnectionId]=r,e.parameters.setProperty(n.PropertyId.SpeechServiceConnection_Url,c);const u="true"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false");return Promise.resolve(new i.WebsocketConnection(c,p,h,new o.WebsocketMessageFormatter,i.ProxyInfo.fromRecognizerConfig(e),u,r))}getSpeechRegionFromIntentRegion(e){switch(e){case"West US":case"US West":case"westus":return"uswest";case"West US 2":case"US West 2":case"westus2":return"uswest2";case"South Central US":case"US South Central":case"southcentralus":return"ussouthcentral";case"West Central US":case"US West Central":case"westcentralus":return"uswestcentral";case"East US":case"US East":case"eastus":return"useast";case"East US 2":case"US East 2":case"eastus2":return"useast2";case"West Europe":case"Europe West":case"westeurope":return"europewest";case"North Europe":case"Europe North":case"northeurope":return"europenorth";case"Brazil South":case"South Brazil":case"southbrazil":return"brazilsouth";case"Australia East":case"East Australia":case"eastaustralia":return"australiaeast";case"Southeast Asia":case"Asia Southeast":case"southeastasia":return"asiasoutheast";case"East Asia":case"Asia East":case"eastasia":return"asiaeast";default:return e}}}t.IntentConnectionFactory=c},function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),n(r(61),t),n(r(65),t),n(r(66),t),n(r(68),t),n(r(69),t),n(r(70),t),n(r(71),t),n(r(77),t),n(r(78),t),n(r(200),t),n(r(203),t)},function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLoggingListener=void 0;const o=s(r(62)),a=r(63),c=r(64);t.ConsoleLoggingListener=class{constructor(e=a.LogLevel.None){this.privLogPath=void 0,this.privEnableConsoleOutput=!0,this.privLogLevelFilter=e}set logPath(e){c.Contracts.throwIfNullOrUndefined(o.openSync,"\nFile System access not available"),this.privLogPath=e}set enableConsoleOutput(e){this.privEnableConsoleOutput=e}onEvent(e){if(e.eventType>=this.privLogLevelFilter){const t=this.toString(e);if(this.logCallback&&this.logCallback(t),this.privLogPath&&o.writeFileSync(this.privLogPath,t+"\n",{flag:"a+"}),this.privEnableConsoleOutput)switch(e.eventType){case a.LogLevel.Debug:console.debug(t);break;case a.LogLevel.Info:console.info(t);break;case a.LogLevel.Warning:console.warn(t);break;case a.LogLevel.Error:console.error(t);break;default:console.log(t)}}}toString(e){const t=[`${e.eventTime}`,`${e.name}`],r=e;for(const i in r)if(i&&e.hasOwnProperty(i)&&"eventTime"!==i&&"eventType"!==i&&"eventId"!==i&&"name"!==i&&"constructor"!==i){const e=r[i];let n="<NULL>";null!=e&&(n="number"==typeof e||"string"==typeof e?e.toString():JSON.stringify(e)),t.push(`${i}: ${n}`)}return t.join(" | ")}}},()=>{},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogLevel=void 0;const i=r(4);Object.defineProperty(t,"LogLevel",{enumerable:!0,get:function(){return i.EventType}})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Contracts=void 0;class r{static throwIfNullOrUndefined(e,t){if(null==e)throw new Error("throwIfNullOrUndefined:"+t)}static throwIfNull(e,t){if(null===e)throw new Error("throwIfNull:"+t)}static throwIfNullOrWhitespace(e,t){if(r.throwIfNullOrUndefined(e,t),(""+e).trim().length<1)throw new Error("throwIfNullOrWhitespace:"+t)}static throwIfNullOrTooLong(e,t,i){if(r.throwIfNullOrUndefined(e,t),(""+e).length>i)throw new Error("throwIfNullOrTooLong:"+t+" (more than "+i.toString()+" characters)")}static throwIfNullOrTooShort(e,t,i){if(r.throwIfNullOrUndefined(e,t),(""+e).length<i)throw new Error("throwIfNullOrTooShort:"+t+" (less than "+i.toString()+" characters)")}static throwIfDisposed(e){if(e)throw new Error("the object is already disposed")}static throwIfArrayEmptyOrWhitespace(e,t){if(r.throwIfNullOrUndefined(e,t),0===e.length)throw new Error("throwIfArrayEmptyOrWhitespace:"+t);for(const i of e)r.throwIfNullOrWhitespace(i,t)}static throwIfFileDoesNotExist(e,t){r.throwIfNullOrWhitespace(e,t)}static throwIfNotUndefined(e,t){if(void 0!==e)throw new Error("throwIfNotUndefined:"+t)}}t.Contracts=r},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MicAudioSource=t.AudioWorkletSourceURLPropertyName=void 0;const i=r(2),n=r(4),s=r(67);t.AudioWorkletSourceURLPropertyName="MICROPHONE-WorkletSourceUrl";class o{constructor(e,t,r,i){this.privRecorder=e,this.deviceId=t,this.privStreams={},this.privOutputChunkSize=o.AUDIOFORMAT.avgBytesPerSec/10,this.privId=r||(0,n.createNoDashGuid)(),this.privEvents=new n.EventSource,this.privMediaStream=i||null,this.privIsClosing=!1}get format(){return Promise.resolve(o.AUDIOFORMAT)}turnOn(){if(this.privInitializeDeferral)return this.privInitializeDeferral.promise;this.privInitializeDeferral=new n.Deferred;try{this.createAudioContext()}catch(e){if(e instanceof Error){const t=e;this.privInitializeDeferral.reject(t.name+": "+t.message)}else this.privInitializeDeferral.reject(e);return this.privInitializeDeferral.promise}const e=window.navigator;let t=e.getUserMedia||e.webkitGetUserMedia||e.mozGetUserMedia||e.msGetUserMedia;if(e.mediaDevices&&(t=(t,r,i)=>{e.mediaDevices.getUserMedia(t).then(r).catch(i)}),t){const e=()=>{this.onEvent(new n.AudioSourceInitializingEvent(this.privId)),this.privMediaStream&&this.privMediaStream.active?(this.onEvent(new n.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()):t({audio:!this.deviceId||{deviceId:this.deviceId},video:!1},(e=>{this.privMediaStream=e,this.onEvent(new n.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()}),(e=>{const t=`Error occurred during microphone initialization: ${e}`;this.privInitializeDeferral.reject(t),this.onEvent(new n.AudioSourceErrorEvent(this.privId,t))}))};"suspended"===this.privContext.state?this.privContext.resume().then(e).catch((e=>{this.privInitializeDeferral.reject(`Failed to initialize audio context: ${e}`)})):e()}else{const e="Browser does not support getUserMedia.";this.privInitializeDeferral.reject(e),this.onEvent(new n.AudioSourceErrorEvent(e,""))}return this.privInitializeDeferral.promise}id(){return this.privId}attach(e){return this.onEvent(new n.AudioStreamNodeAttachingEvent(this.privId,e)),this.listen(e).then((t=>(this.onEvent(new n.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(t.readEnded(),delete this.privStreams[e],this.onEvent(new n.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()})))}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new n.AudioStreamNodeDetachedEvent(this.privId,e)))}async turnOff(){for(const e in this.privStreams)if(e){const t=this.privStreams[e];t&&t.close()}this.onEvent(new n.AudioSourceOffEvent(this.privId)),this.privInitializeDeferral&&(await this.privInitializeDeferral,this.privInitializeDeferral=null),await this.destroyAudioContext()}get events(){return this.privEvents}get deviceInfo(){return this.getMicrophoneLabel().then((e=>({bitspersample:o.AUDIOFORMAT.bitsPerSample,channelcount:o.AUDIOFORMAT.channels,connectivity:i.connectivity.Unknown,manufacturer:"Speech SDK",model:e,samplerate:o.AUDIOFORMAT.samplesPerSec,type:i.type.Microphones})))}setProperty(e,r){if(e!==t.AudioWorkletSourceURLPropertyName)throw new Error("Property '"+e+"' is not supported on Microphone.");this.privRecorder.setWorkletUrl(r)}getMicrophoneLabel(){const e="microphone";if(void 0!==this.privMicrophoneLabel)return Promise.resolve(this.privMicrophoneLabel);if(void 0===this.privMediaStream||!this.privMediaStream.active)return Promise.resolve(e);this.privMicrophoneLabel=e;const t=this.privMediaStream.getTracks()[0].getSettings().deviceId;if(void 0===t)return Promise.resolve(this.privMicrophoneLabel);const r=new n.Deferred;return navigator.mediaDevices.enumerateDevices().then((e=>{for(const r of e)if(r.deviceId===t){this.privMicrophoneLabel=r.label;break}r.resolve(this.privMicrophoneLabel)}),(()=>r.resolve(this.privMicrophoneLabel))),r.promise}async listen(e){await this.turnOn();const t=new n.ChunkedArrayBufferStream(this.privOutputChunkSize,e);this.privStreams[e]=t;try{this.privRecorder.record(this.privContext,this.privMediaStream,t)}catch(t){throw this.onEvent(new n.AudioStreamNodeErrorEvent(this.privId,e,t)),t}return t}onEvent(e){this.privEvents.onEvent(e),n.Events.instance.onEvent(e)}createAudioContext(){this.privContext||(this.privContext=s.AudioStreamFormatImpl.getAudioContext(o.AUDIOFORMAT.samplesPerSec))}async destroyAudioContext(){if(!this.privContext)return;this.privRecorder.releaseMediaResources(this.privContext);let e=!1;"close"in this.privContext&&(e=!0),e?this.privIsClosing||(this.privIsClosing=!0,await this.privContext.close(),this.privContext=null,this.privIsClosing=!1):null!==this.privContext&&"running"===this.privContext.state&&await this.privContext.suspend()}}t.MicAudioSource=o,o.AUDIOFORMAT=s.AudioStreamFormat.getDefaultInputFormat()},(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.AudioStreamFormatImpl=t.AudioStreamFormat=t.AudioFormatTag=void 0,function(e){e[e.PCM=1]="PCM",e[e.MuLaw=2]="MuLaw",e[e.Siren=3]="Siren",e[e.MP3=4]="MP3",e[e.SILKSkype=5]="SILKSkype",e[e.OGG_OPUS=6]="OGG_OPUS",e[e.WEBM_OPUS=7]="WEBM_OPUS",e[e.ALaw=8]="ALaw",e[e.FLAC=9]="FLAC",e[e.OPUS=10]="OPUS",e[e.AMR_WB=11]="AMR_WB",e[e.G722=12]="G722"}(r=t.AudioFormatTag||(t.AudioFormatTag={}));class i{static getDefaultInputFormat(){return n.getDefaultInputFormat()}static getWaveFormat(e,t,r,i){return new n(e,t,r,i)}static getWaveFormatPCM(e,t,r){return new n(e,t,r)}}t.AudioStreamFormat=i;class n extends i{constructor(e=16e3,t=16,i=1,n=r.PCM){super();let s=!0;switch(n){case r.PCM:this.formatTag=1;break;case r.ALaw:this.formatTag=6;break;case r.MuLaw:this.formatTag=7;break;default:s=!1}if(this.bitsPerSample=t,this.samplesPerSec=e,this.channels=i,this.avgBytesPerSec=this.samplesPerSec*this.channels*(this.bitsPerSample/8),this.blockAlign=this.channels*Math.max(this.bitsPerSample,8),s){this.privHeader=new ArrayBuffer(44);const e=new DataView(this.privHeader);this.setString(e,0,"RIFF"),e.setUint32(4,0,!0),this.setString(e,8,"WAVEfmt "),e.setUint32(16,16,!0),e.setUint16(20,this.formatTag,!0),e.setUint16(22,this.channels,!0),e.setUint32(24,this.samplesPerSec,!0),e.setUint32(28,this.avgBytesPerSec,!0),e.setUint16(32,this.channels*(this.bitsPerSample/8),!0),e.setUint16(34,this.bitsPerSample,!0),this.setString(e,36,"data"),e.setUint32(40,0,!0)}}static getDefaultInputFormat(){return new n}static getAudioContext(e){const t=window.AudioContext||window.webkitAudioContext||!1;if(t)return void 0!==e&&navigator.mediaDevices.getSupportedConstraints().sampleRate?new t({sampleRate:e}):new t;throw new Error("Browser does not support Web Audio API (AudioContext is not available).")}close(){}get header(){return this.privHeader}setString(e,t,r){for(let i=0;i<r.length;i++)e.setUint8(t+i,r.charCodeAt(i))}}t.AudioStreamFormatImpl=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileAudioSource=void 0;const i=r(2),n=r(4),s=r(67);t.FileAudioSource=class{constructor(e,t,r){this.privStreams={},this.privHeaderEnd=44,this.privId=r||(0,n.createNoDashGuid)(),this.privEvents=new n.EventSource,this.privSource=e,"undefined"!=typeof window&&"undefined"!=typeof Blob&&this.privSource instanceof Blob?this.privFilename=e.name:this.privFilename=t||"unknown.wav",this.privAudioFormatPromise=this.readHeader()}get format(){return this.privAudioFormatPromise}turnOn(){if(this.privFilename.lastIndexOf(".wav")!==this.privFilename.length-4){const e=this.privFilename+" is not supported. Only WAVE files are allowed at the moment.";return this.onEvent(new n.AudioSourceErrorEvent(e,"")),Promise.reject(e)}this.onEvent(new n.AudioSourceInitializingEvent(this.privId)),this.onEvent(new n.AudioSourceReadyEvent(this.privId))}id(){return this.privId}async attach(e){this.onEvent(new n.AudioStreamNodeAttachingEvent(this.privId,e));const t=await this.upload(e);return this.onEvent(new n.AudioStreamNodeAttachedEvent(this.privId,e)),Promise.resolve({detach:async()=>{t.readEnded(),delete this.privStreams[e],this.onEvent(new n.AudioStreamNodeDetachedEvent(this.privId,e)),await this.turnOff()},id:()=>e,read:()=>t.read()})}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new n.AudioStreamNodeDetachedEvent(this.privId,e)))}turnOff(){for(const e in this.privStreams)if(e){const t=this.privStreams[e];t&&!t.isClosed&&t.close()}return this.onEvent(new n.AudioSourceOffEvent(this.privId)),Promise.resolve()}get events(){return this.privEvents}get deviceInfo(){return this.privAudioFormatPromise.then((e=>Promise.resolve({bitspersample:e.bitsPerSample,channelcount:e.channels,connectivity:i.connectivity.Unknown,manufacturer:"Speech SDK",model:"File",samplerate:e.samplesPerSec,type:i.type.File})))}readHeader(){const e=this.privSource.slice(0,4296),t=new n.Deferred,r=e=>{const r=new DataView(e),i=e=>String.fromCharCode(r.getUint8(e),r.getUint8(e+1),r.getUint8(e+2),r.getUint8(e+3));if("RIFF"!==i(0))return void t.reject("Invalid WAV header in file, RIFF was not found");if("WAVE"!==i(8)||"fmt "!==i(12))return void t.reject("Invalid WAV header in file, WAVEfmt was not found");const n=r.getInt32(16,!0),o=r.getUint16(22,!0),a=r.getUint32(24,!0),c=r.getUint16(34,!0);let p=36+Math.max(n-16,0);for(;"data"!==i(p);p+=2)if(p>4288)return void t.reject("Invalid WAV header in file, data block was not found");this.privHeaderEnd=p+8,t.resolve(s.AudioStreamFormat.getWaveFormatPCM(a,c,o))};if("undefined"!=typeof window&&"undefined"!=typeof Blob&&e instanceof Blob){const t=new FileReader;t.onload=e=>{const t=e.target.result;r(t)},t.readAsArrayBuffer(e)}else{const t=e;r(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength))}return t.promise}async upload(e){const t=t=>{const r=`Error occurred while processing '${this.privFilename}'. ${t}`;throw this.onEvent(new n.AudioStreamNodeErrorEvent(this.privId,e,r)),new Error(r)};try{await this.turnOn();const r=await this.privAudioFormatPromise,i=new n.ChunkedArrayBufferStream(r.avgBytesPerSec/10,e);this.privStreams[e]=i;const s=this.privSource.slice(this.privHeaderEnd),o=e=>{i.isClosed||(i.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()}),i.close())};if("undefined"!=typeof window&&"undefined"!=typeof Blob&&s instanceof Blob){const e=new FileReader;e.onerror=e=>t(e.toString()),e.onload=e=>{const t=e.target.result;o(t)},e.readAsArrayBuffer(s)}else{const e=s;o(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength))}return i}catch(e){t(e)}}onEvent(e){this.privEvents.onEvent(e),n.Events.instance.onEvent(e)}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PcmRecorder=void 0;const i=r(4);t.PcmRecorder=class{constructor(e){this.privStopInputOnRelease=e}record(e,t,r){const n=new i.RiffPcmEncoder(e.sampleRate,16e3),s=e.createMediaStreamSource(t),o=()=>{const i=(()=>{let t=0;try{return e.createScriptProcessor(t,1,1)}catch(r){t=2048;let i=e.sampleRate;for(;t<16384&&i>=32e3;)t<<=1,i>>=1;return e.createScriptProcessor(t,1,1)}})();i.onaudioprocess=e=>{const t=e.inputBuffer.getChannelData(0);if(r&&!r.isClosed){const e=n.encode(t);e&&r.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}},s.connect(i),i.connect(e.destination),this.privMediaResources={scriptProcessorNode:i,source:s,stream:t}},a=!!this.privSpeechProcessorScript&&"ignore"===this.privSpeechProcessorScript.toLowerCase();if(e.audioWorklet&&!a){if(!this.privSpeechProcessorScript){const e=new Blob(["class SP extends AudioWorkletProcessor {\n constructor(options) {\n super(options);\n }\n process(inputs, outputs) {\n const input = inputs[0];\n const output = [];\n for (let channel = 0; channel < input.length; channel += 1) {\n output[channel] = input[channel];\n }\n this.port.postMessage(output[0]);\n return true;\n }\n }\n registerProcessor('speech-processor', SP);"],{type:"application/javascript; charset=utf-8"});this.privSpeechProcessorScript=URL.createObjectURL(e)}e.audioWorklet.addModule(this.privSpeechProcessorScript).then((()=>{const i=new AudioWorkletNode(e,"speech-processor");i.port.onmessage=e=>{const t=e.data;if(r&&!r.isClosed){const e=n.encode(t);e&&r.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}},s.connect(i),i.connect(e.destination),this.privMediaResources={scriptProcessorNode:i,source:s,stream:t}})).catch((()=>{o()}))}else try{o()}catch(e){throw new Error(`Unable to start audio worklet node for PCMRecorder: ${e}`)}}releaseMediaResources(e){this.privMediaResources&&(this.privMediaResources.scriptProcessorNode&&(this.privMediaResources.scriptProcessorNode.disconnect(e.destination),this.privMediaResources.scriptProcessorNode=null),this.privMediaResources.source&&(this.privMediaResources.source.disconnect(),this.privStopInputOnRelease&&this.privMediaResources.stream.getTracks().forEach((e=>e.stop())),this.privMediaResources.source=null))}setWorkletUrl(e){this.privSpeechProcessorScript=e}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebsocketConnection=void 0;const i=r(4),n=r(71);t.WebsocketConnection=class{constructor(e,t,r,s,o,a=!1,c){if(this.privIsDisposed=!1,!e)throw new i.ArgumentNullError("uri");if(!s)throw new i.ArgumentNullError("messageFormatter");this.privMessageFormatter=s;let p="",h=0;if(t)for(const r in t)if(r){p+=0===h&&-1===e.indexOf("?")?"?":"&";p+=encodeURIComponent(r);let i=t[r];i&&(i=encodeURIComponent(i),p+=`=${i}`),h++}if(r)for(const t in r)if(t){p+=0===h&&-1===e.indexOf("?")?"?":"&";p+=`${t}=${encodeURIComponent(r[t])}`,h++}this.privUri=e+p,this.privId=c||(0,i.createNoDashGuid)(),this.privConnectionMessageAdapter=new n.WebsocketMessageAdapter(this.privUri,this.id,this.privMessageFormatter,o,r,a)}async dispose(){this.privIsDisposed=!0,this.privConnectionMessageAdapter&&await this.privConnectionMessageAdapter.close()}isDisposed(){return this.privIsDisposed}get id(){return this.privId}get uri(){return this.privUri}state(){return this.privConnectionMessageAdapter.state}open(){return this.privConnectionMessageAdapter.open()}send(e){return this.privConnectionMessageAdapter.send(e)}read(){return this.privConnectionMessageAdapter.read()}get events(){return this.privConnectionMessageAdapter.events}}},function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebsocketMessageAdapter=void 0;const a=s(r(72)),c=s(r(73)),p=o(r(74)),h=o(r(75)),u=o(r(76)),d=r(54),v=r(4);class l{constructor(e,t,r,i,n,s){if(!e)throw new v.ArgumentNullError("uri");if(!r)throw new v.ArgumentNullError("messageFormatter");this.proxyInfo=i,this.privConnectionEvents=new v.EventSource,this.privConnectionId=t,this.privMessageFormatter=r,this.privConnectionState=v.ConnectionState.None,this.privUri=e,this.privHeaders=n,this.privEnableCompression=s,this.privHeaders[d.HeaderNames.ConnectionId]=this.privConnectionId,this.privHeaders.connectionId=this.privConnectionId,this.privLastErrorReceived=""}get state(){return this.privConnectionState}open(){if(this.privConnectionState===v.ConnectionState.Disconnected)return Promise.reject(`Cannot open a connection that is in ${this.privConnectionState} state`);if(this.privConnectionEstablishDeferral)return this.privConnectionEstablishDeferral.promise;this.privConnectionEstablishDeferral=new v.Deferred,this.privCertificateValidatedDeferral=new v.Deferred,this.privConnectionState=v.ConnectionState.Connecting;try{if("undefined"==typeof WebSocket||l.forceNpmWebSocket){let e=new URL(this.privUri).protocol;"wss:"===e?.toLocaleLowerCase()?e="https:":"ws:"===e?.toLocaleLowerCase()&&(e="http:");const t={headers:this.privHeaders,perMessageDeflate:this.privEnableCompression,followRedirects:"https:"===e.toLocaleLowerCase()};this.privCertificateValidatedDeferral.resolve(),t.agent=this.getAgent(),t.agent.protocol=e,this.privWebsocketClient=new u.default(this.privUri,t),this.privWebsocketClient.on("redirect",(e=>{const t=new v.ConnectionRedirectEvent(this.privConnectionId,e,this.privUri,`Getting redirect URL from endpoint ${this.privUri} with redirect URL '${e}'`);v.Events.instance.onEvent(t)}))}else this.privCertificateValidatedDeferral.resolve(),this.privWebsocketClient=new WebSocket(this.privUri);this.privWebsocketClient.binaryType="arraybuffer",this.privReceivingMessageQueue=new v.Queue,this.privDisconnectDeferral=new v.Deferred,this.privSendMessageQueue=new v.Queue,this.processSendQueue().catch((e=>{v.Events.instance.onEvent(new v.BackgroundEvent(e))}))}catch(e){return this.privConnectionEstablishDeferral.resolve(new v.ConnectionOpenResponse(500,e)),this.privConnectionEstablishDeferral.promise}return this.onEvent(new v.ConnectionStartEvent(this.privConnectionId,this.privUri)),this.privWebsocketClient.onopen=()=>{this.privCertificateValidatedDeferral.promise.then((()=>{this.privConnectionState=v.ConnectionState.Connected,this.onEvent(new v.ConnectionEstablishedEvent(this.privConnectionId)),this.privConnectionEstablishDeferral.resolve(new v.ConnectionOpenResponse(200,""))}),(e=>{this.privConnectionEstablishDeferral.reject(e)}))},this.privWebsocketClient.onerror=e=>{this.onEvent(new v.ConnectionErrorEvent(this.privConnectionId,e.message,e.type)),this.privLastErrorReceived=e.message},this.privWebsocketClient.onclose=e=>{this.privConnectionState===v.ConnectionState.Connecting?(this.privConnectionState=v.ConnectionState.Disconnected,this.privConnectionEstablishDeferral.resolve(new v.ConnectionOpenResponse(e.code,e.reason+" "+this.privLastErrorReceived))):(this.privConnectionState=v.ConnectionState.Disconnected,this.privWebsocketClient=null,this.onEvent(new v.ConnectionClosedEvent(this.privConnectionId,e.code,e.reason))),this.onClose(e.code,e.reason).catch((e=>{v.Events.instance.onEvent(new v.BackgroundEvent(e))}))},this.privWebsocketClient.onmessage=e=>{const t=(new Date).toISOString();if(this.privConnectionState===v.ConnectionState.Connected){const r=new v.Deferred;if(this.privReceivingMessageQueue.enqueueFromPromise(r.promise),e.data instanceof ArrayBuffer){const i=new v.RawWebsocketMessage(v.MessageType.Binary,e.data);this.privMessageFormatter.toConnectionMessage(i).then((e=>{this.onEvent(new v.ConnectionMessageReceivedEvent(this.privConnectionId,t,e)),r.resolve(e)}),(e=>{r.reject(`Invalid binary message format. Error: ${e}`)}))}else{const i=new v.RawWebsocketMessage(v.MessageType.Text,e.data);this.privMessageFormatter.toConnectionMessage(i).then((e=>{this.onEvent(new v.ConnectionMessageReceivedEvent(this.privConnectionId,t,e)),r.resolve(e)}),(e=>{r.reject(`Invalid text message format. Error: ${e}`)}))}}},this.privConnectionEstablishDeferral.promise}send(e){if(this.privConnectionState!==v.ConnectionState.Connected)return Promise.reject(`Cannot send on connection that is in ${v.ConnectionState[this.privConnectionState]} state`);const t=new v.Deferred,r=new v.Deferred;return this.privSendMessageQueue.enqueueFromPromise(r.promise),this.privMessageFormatter.fromConnectionMessage(e).then((i=>{r.resolve({Message:e,RawWebsocketMessage:i,sendStatusDeferral:t})}),(e=>{r.reject(`Error formatting the message. ${e}`)})),t.promise}read(){return this.privConnectionState!==v.ConnectionState.Connected?Promise.reject(`Cannot read on connection that is in ${this.privConnectionState} state`):this.privReceivingMessageQueue.dequeue()}close(e){return this.privWebsocketClient?(this.privConnectionState!==v.ConnectionState.Disconnected&&this.privWebsocketClient.close(1e3,e||"Normal closure by client"),this.privDisconnectDeferral.promise):Promise.resolve()}get events(){return this.privConnectionEvents}sendRawMessage(e){try{return e?(this.onEvent(new v.ConnectionMessageSentEvent(this.privConnectionId,(new Date).toISOString(),e.Message)),this.isWebsocketOpen?(this.privWebsocketClient.send(e.RawWebsocketMessage.payload),Promise.resolve()):Promise.reject("websocket send error: Websocket not ready "+this.privConnectionId+" "+e.Message.id+" "+(new Error).stack)):Promise.resolve()}catch(e){return Promise.reject(`websocket send error: ${e}`)}}async onClose(e,t){const r=`Connection closed. ${e}: ${t}`;this.privConnectionState=v.ConnectionState.Disconnected,this.privDisconnectDeferral.resolve(),await this.privReceivingMessageQueue.drainAndDispose((()=>{}),r),await this.privSendMessageQueue.drainAndDispose((e=>{e.sendStatusDeferral.reject(r)}),r)}async processSendQueue(){for(;;){const e=this.privSendMessageQueue.dequeue(),t=await e;if(!t)return;try{await this.sendRawMessage(t),t.sendStatusDeferral.resolve()}catch(e){t.sendStatusDeferral.reject(e)}}}onEvent(e){this.privConnectionEvents.onEvent(e),v.Events.instance.onEvent(e)}getAgent(){const e=new p.default.Agent(this.createConnection);return void 0!==this.proxyInfo&&void 0!==this.proxyInfo.HostName&&this.proxyInfo.Port>0&&(e.proxyInfo=this.proxyInfo),e}static GetProxyAgent(e){const t={host:e.HostName,port:e.Port};e.UserName?t.headers={"Proxy-Authentication":"Basic "+new Buffer(`${e.UserName}:${void 0===e.Password?"":e.Password}`).toString("base64")}:t.headers={},t.headers.requestOCSP="true";return new h.default(t)}createConnection(e,t){let r;if(t={...t,requestOCSP:!0,servername:t.host},this.proxyInfo){const i=l.GetProxyAgent(this.proxyInfo);r=new Promise(((r,n)=>{i.callback(e,t,((e,t)=>{e?n(e):r(t)}))}))}else r=t.secureEndpoint?Promise.resolve(c.connect(t)):Promise.resolve(a.connect(t));return r}get isWebsocketOpen(){return this.privWebsocketClient&&this.privWebsocketClient.readyState===this.privWebsocketClient.OPEN}}t.WebsocketMessageAdapter=l,l.forceNpmWebSocket=!1},()=>{},()=>{},()=>{},()=>{},()=>{},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReplayableAudioNode=void 0;t.ReplayableAudioNode=class{constructor(e,t){this.privBuffers=[],this.privReplayOffset=0,this.privLastShrinkOffset=0,this.privBufferStartOffset=0,this.privBufferSerial=0,this.privBufferedBytes=0,this.privReplay=!1,this.privLastChunkAcquiredTime=0,this.privAudioNode=e,this.privBytesPerSecond=t}id(){return this.privAudioNode.id()}read(){if(this.privReplay&&0!==this.privBuffers.length){const e=this.privReplayOffset-this.privBufferStartOffset;let t=Math.round(e*this.privBytesPerSecond*1e-7);0!=t%2&&t++;let r=0;for(;r<this.privBuffers.length&&t>=this.privBuffers[r].chunk.buffer.byteLength;)t-=this.privBuffers[r++].chunk.buffer.byteLength;if(r<this.privBuffers.length){const e=this.privBuffers[r].chunk.buffer.slice(t);return this.privReplayOffset+=e.byteLength/this.privBytesPerSecond*1e7,r===this.privBuffers.length-1&&(this.privReplay=!1),Promise.resolve({buffer:e,isEnd:!1,timeReceived:this.privBuffers[r].chunk.timeReceived})}}return this.privAudioNode.read().then((e=>(e&&e.buffer&&(this.privBuffers.push(new r(e,this.privBufferSerial++,this.privBufferedBytes)),this.privBufferedBytes+=e.buffer.byteLength),e)))}detach(){return this.privBuffers=void 0,this.privAudioNode.detach()}replay(){this.privBuffers&&0!==this.privBuffers.length&&(this.privReplay=!0,this.privReplayOffset=this.privLastShrinkOffset)}shrinkBuffers(e){if(void 0===this.privBuffers||0===this.privBuffers.length)return;this.privLastShrinkOffset=e;const t=e-this.privBufferStartOffset;let r=Math.round(t*this.privBytesPerSecond*1e-7),i=0;for(;i<this.privBuffers.length&&r>=this.privBuffers[i].chunk.buffer.byteLength;)r-=this.privBuffers[i++].chunk.buffer.byteLength;this.privBufferStartOffset=Math.round(e-r/this.privBytesPerSecond*1e7),this.privBuffers=this.privBuffers.slice(i)}findTimeAtOffset(e){if(e<this.privBufferStartOffset||void 0===this.privBuffers)return 0;for(const t of this.privBuffers){const r=t.byteOffset/this.privBytesPerSecond*1e7,i=r+t.chunk.buffer.byteLength/this.privBytesPerSecond*1e7;if(e>=r&&e<=i)return t.chunk.timeReceived}return 0}};class r{constructor(e,t,r){this.chunk=e,this.serial=t,this.byteOffset=r}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProxyInfo=void 0;const i=r(79);class n{constructor(e,t,r,i){this.privProxyHostName=e,this.privProxyPort=t,this.privProxyUserName=r,this.privProxyPassword=i}static fromParameters(e){return new n(e.getProperty(i.PropertyId.SpeechServiceConnection_ProxyHostName),parseInt(e.getProperty(i.PropertyId.SpeechServiceConnection_ProxyPort),10),e.getProperty(i.PropertyId.SpeechServiceConnection_ProxyUserName),e.getProperty(i.PropertyId.SpeechServiceConnection_ProxyPassword))}static fromRecognizerConfig(e){return this.fromParameters(e.parameters)}get HostName(){return this.privProxyHostName}get Port(){return this.privProxyPort}get UserName(){return this.privProxyUserName}get Password(){return this.privProxyPassword}}t.ProxyInfo=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionEventArgs=t.CancellationErrorCode=t.CancellationDetails=t.CancellationDetailsBase=t.IntentRecognitionCanceledEventArgs=t.TranslationRecognitionCanceledEventArgs=t.NoMatchDetails=t.NoMatchReason=t.Translations=t.TranslationRecognizer=t.VoiceProfileType=t.IntentRecognizer=t.SpeechRecognizer=t.Recognizer=t.PropertyId=t.PropertyCollection=t.SpeechTranslationConfigImpl=t.SpeechTranslationConfig=t.SpeechConfigImpl=t.SpeechConfig=t.ResultReason=t.TranslationSynthesisResult=t.TranslationRecognitionResult=t.TranslationSynthesisEventArgs=t.TranslationRecognitionEventArgs=t.SpeechRecognitionCanceledEventArgs=t.MeetingTranscriptionEventArgs=t.ConversationTranscriptionEventArgs=t.SpeechRecognitionEventArgs=t.LanguageUnderstandingModel=t.IntentRecognitionResult=t.SpeechRecognitionResult=t.RecognitionResult=t.IntentRecognitionEventArgs=t.OutputFormat=t.RecognitionEventArgs=t.SessionEventArgs=t.KeywordRecognitionModel=t.PushAudioOutputStreamCallback=t.PullAudioInputStreamCallback=t.CancellationReason=t.PushAudioOutputStream=t.PullAudioOutputStream=t.AudioOutputStream=t.PushAudioInputStream=t.PullAudioInputStream=t.AudioInputStream=t.AudioFormatTag=t.AudioStreamFormat=t.AudioConfig=void 0,t.SpeechSynthesisEventArgs=t.SpeechSynthesisResult=t.SynthesisResult=t.SpeechSynthesizer=t.SpeechSynthesisOutputFormat=t.Synthesizer=t.User=t.ParticipantChangedReason=t.Participant=t.MeetingTranscriber=t.Meeting=t.ConversationTranscriptionResult=t.ConversationTranscriber=t.ConversationTranslator=t.ConversationTranslationResult=t.ConversationTranslationEventArgs=t.ConversationTranslationCanceledEventArgs=t.ConversationParticipantsChangedEventArgs=t.ConversationExpirationEventArgs=t.Conversation=t.SpeakerRecognitionCancellationDetails=t.SpeakerRecognitionResultType=t.SpeakerRecognitionResult=t.SourceLanguageConfig=t.AutoDetectSourceLanguageResult=t.AutoDetectSourceLanguageConfig=t.SpeakerVerificationModel=t.SpeakerIdentificationModel=t.SpeakerRecognizer=t.VoiceProfileClient=t.VoiceProfilePhraseResult=t.VoiceProfileCancellationDetails=t.VoiceProfileResult=t.VoiceProfileEnrollmentCancellationDetails=t.VoiceProfileEnrollmentResult=t.VoiceProfile=t.ConnectionMessage=t.ConnectionMessageEventArgs=t.BaseAudioPlayer=t.ProfanityOption=t.ServicePropertyChannel=t.TurnStatusReceivedEventArgs=t.ActivityReceivedEventArgs=t.DialogServiceConnector=t.CustomCommandsConfig=t.BotFrameworkConfig=t.DialogServiceConfig=t.PhraseListGrammar=t.Connection=t.ServiceEventArgs=void 0,t.LogLevel=t.Diagnostics=t.AvatarWebRTCConnectionResult=t.Coordinate=t.AvatarVideoFormat=t.AvatarSynthesizer=t.AvatarEventArgs=t.AvatarConfig=t.LanguageIdMode=t.PronunciationAssessmentResult=t.PronunciationAssessmentConfig=t.PronunciationAssessmentGranularity=t.PronunciationAssessmentGradingSystem=t.MeetingTranscriptionCanceledEventArgs=t.ConversationTranscriptionCanceledEventArgs=t.SpeakerAudioDestination=t.VoiceInfo=t.SynthesisVoiceType=t.SynthesisVoiceGender=t.SynthesisVoicesResult=t.SpeechSynthesisBoundaryType=t.SpeechSynthesisVisemeEventArgs=t.SpeechSynthesisBookmarkEventArgs=t.SpeechSynthesisWordBoundaryEventArgs=void 0;var i=r(80);Object.defineProperty(t,"AudioConfig",{enumerable:!0,get:function(){return i.AudioConfig}});var n=r(67);Object.defineProperty(t,"AudioStreamFormat",{enumerable:!0,get:function(){return n.AudioStreamFormat}}),Object.defineProperty(t,"AudioFormatTag",{enumerable:!0,get:function(){return n.AudioFormatTag}});var s=r(83);Object.defineProperty(t,"AudioInputStream",{enumerable:!0,get:function(){return s.AudioInputStream}}),Object.defineProperty(t,"PullAudioInputStream",{enumerable:!0,get:function(){return s.PullAudioInputStream}}),Object.defineProperty(t,"PushAudioInputStream",{enumerable:!0,get:function(){return s.PushAudioInputStream}});var o=r(84);Object.defineProperty(t,"AudioOutputStream",{enumerable:!0,get:function(){return o.AudioOutputStream}}),Object.defineProperty(t,"PullAudioOutputStream",{enumerable:!0,get:function(){return o.PullAudioOutputStream}}),Object.defineProperty(t,"PushAudioOutputStream",{enumerable:!0,get:function(){return o.PushAudioOutputStream}});var a=r(87);Object.defineProperty(t,"CancellationReason",{enumerable:!0,get:function(){return a.CancellationReason}});var c=r(88);Object.defineProperty(t,"PullAudioInputStreamCallback",{enumerable:!0,get:function(){return c.PullAudioInputStreamCallback}});var p=r(89);Object.defineProperty(t,"PushAudioOutputStreamCallback",{enumerable:!0,get:function(){return p.PushAudioOutputStreamCallback}});var h=r(90);Object.defineProperty(t,"KeywordRecognitionModel",{enumerable:!0,get:function(){return h.KeywordRecognitionModel}});var u=r(91);Object.defineProperty(t,"SessionEventArgs",{enumerable:!0,get:function(){return u.SessionEventArgs}});var d=r(92);Object.defineProperty(t,"RecognitionEventArgs",{enumerable:!0,get:function(){return d.RecognitionEventArgs}});var v=r(93);Object.defineProperty(t,"OutputFormat",{enumerable:!0,get:function(){return v.OutputFormat}});var l=r(94);Object.defineProperty(t,"IntentRecognitionEventArgs",{enumerable:!0,get:function(){return l.IntentRecognitionEventArgs}});var g=r(95);Object.defineProperty(t,"RecognitionResult",{enumerable:!0,get:function(){return g.RecognitionResult}});var m=r(96);Object.defineProperty(t,"SpeechRecognitionResult",{enumerable:!0,get:function(){return m.SpeechRecognitionResult}});var f=r(97);Object.defineProperty(t,"IntentRecognitionResult",{enumerable:!0,get:function(){return f.IntentRecognitionResult}});var S=r(98);Object.defineProperty(t,"LanguageUnderstandingModel",{enumerable:!0,get:function(){return S.LanguageUnderstandingModel}});var y=r(99);Object.defineProperty(t,"SpeechRecognitionEventArgs",{enumerable:!0,get:function(){return y.SpeechRecognitionEventArgs}}),Object.defineProperty(t,"ConversationTranscriptionEventArgs",{enumerable:!0,get:function(){return y.ConversationTranscriptionEventArgs}}),Object.defineProperty(t,"MeetingTranscriptionEventArgs",{enumerable:!0,get:function(){return y.MeetingTranscriptionEventArgs}});var C=r(100);Object.defineProperty(t,"SpeechRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return C.SpeechRecognitionCanceledEventArgs}});var P=r(102);Object.defineProperty(t,"TranslationRecognitionEventArgs",{enumerable:!0,get:function(){return P.TranslationRecognitionEventArgs}});var R=r(103);Object.defineProperty(t,"TranslationSynthesisEventArgs",{enumerable:!0,get:function(){return R.TranslationSynthesisEventArgs}});var I=r(104);Object.defineProperty(t,"TranslationRecognitionResult",{enumerable:!0,get:function(){return I.TranslationRecognitionResult}});var T=r(105);Object.defineProperty(t,"TranslationSynthesisResult",{enumerable:!0,get:function(){return T.TranslationSynthesisResult}});var w=r(106);Object.defineProperty(t,"ResultReason",{enumerable:!0,get:function(){return w.ResultReason}});var E=r(107);Object.defineProperty(t,"SpeechConfig",{enumerable:!0,get:function(){return E.SpeechConfig}}),Object.defineProperty(t,"SpeechConfigImpl",{enumerable:!0,get:function(){return E.SpeechConfigImpl}});var A=r(108);Object.defineProperty(t,"SpeechTranslationConfig",{enumerable:!0,get:function(){return A.SpeechTranslationConfig}}),Object.defineProperty(t,"SpeechTranslationConfigImpl",{enumerable:!0,get:function(){return A.SpeechTranslationConfigImpl}});var b=r(109);Object.defineProperty(t,"PropertyCollection",{enumerable:!0,get:function(){return b.PropertyCollection}});var O=r(110);Object.defineProperty(t,"PropertyId",{enumerable:!0,get:function(){return O.PropertyId}});var M=r(111);Object.defineProperty(t,"Recognizer",{enumerable:!0,get:function(){return M.Recognizer}});var D=r(112);Object.defineProperty(t,"SpeechRecognizer",{enumerable:!0,get:function(){return D.SpeechRecognizer}});var k=r(114);Object.defineProperty(t,"IntentRecognizer",{enumerable:!0,get:function(){return k.IntentRecognizer}});var N=r(115);Object.defineProperty(t,"VoiceProfileType",{enumerable:!0,get:function(){return N.VoiceProfileType}});var _=r(116);Object.defineProperty(t,"TranslationRecognizer",{enumerable:!0,get:function(){return _.TranslationRecognizer}});var z=r(119);Object.defineProperty(t,"Translations",{enumerable:!0,get:function(){return z.Translations}});var L=r(120);Object.defineProperty(t,"NoMatchReason",{enumerable:!0,get:function(){return L.NoMatchReason}});var x=r(121);Object.defineProperty(t,"NoMatchDetails",{enumerable:!0,get:function(){return x.NoMatchDetails}});var F=r(122);Object.defineProperty(t,"TranslationRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return F.TranslationRecognitionCanceledEventArgs}});var B=r(123);Object.defineProperty(t,"IntentRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return B.IntentRecognitionCanceledEventArgs}});var j=r(124);Object.defineProperty(t,"CancellationDetailsBase",{enumerable:!0,get:function(){return j.CancellationDetailsBase}});var U=r(125);Object.defineProperty(t,"CancellationDetails",{enumerable:!0,get:function(){return U.CancellationDetails}});var q=r(126);Object.defineProperty(t,"CancellationErrorCode",{enumerable:!0,get:function(){return q.CancellationErrorCode}});var W=r(127);Object.defineProperty(t,"ConnectionEventArgs",{enumerable:!0,get:function(){return W.ConnectionEventArgs}});var H=r(128);Object.defineProperty(t,"ServiceEventArgs",{enumerable:!0,get:function(){return H.ServiceEventArgs}});var V=r(117);Object.defineProperty(t,"Connection",{enumerable:!0,get:function(){return V.Connection}});var K=r(129);Object.defineProperty(t,"PhraseListGrammar",{enumerable:!0,get:function(){return K.PhraseListGrammar}});var J=r(130);Object.defineProperty(t,"DialogServiceConfig",{enumerable:!0,get:function(){return J.DialogServiceConfig}});var G=r(131);Object.defineProperty(t,"BotFrameworkConfig",{enumerable:!0,get:function(){return G.BotFrameworkConfig}});var $=r(132);Object.defineProperty(t,"CustomCommandsConfig",{enumerable:!0,get:function(){return $.CustomCommandsConfig}});var Q=r(133);Object.defineProperty(t,"DialogServiceConnector",{enumerable:!0,get:function(){return Q.DialogServiceConnector}});var X=r(137);Object.defineProperty(t,"ActivityReceivedEventArgs",{enumerable:!0,get:function(){return X.ActivityReceivedEventArgs}});var Z=r(138);Object.defineProperty(t,"TurnStatusReceivedEventArgs",{enumerable:!0,get:function(){return Z.TurnStatusReceivedEventArgs}});var Y=r(140);Object.defineProperty(t,"ServicePropertyChannel",{enumerable:!0,get:function(){return Y.ServicePropertyChannel}});var ee=r(141);Object.defineProperty(t,"ProfanityOption",{enumerable:!0,get:function(){return ee.ProfanityOption}});var te=r(142);Object.defineProperty(t,"BaseAudioPlayer",{enumerable:!0,get:function(){return te.BaseAudioPlayer}});var re=r(143);Object.defineProperty(t,"ConnectionMessageEventArgs",{enumerable:!0,get:function(){return re.ConnectionMessageEventArgs}});var ie=r(118);Object.defineProperty(t,"ConnectionMessage",{enumerable:!0,get:function(){return ie.ConnectionMessage}});var ne=r(144);Object.defineProperty(t,"VoiceProfile",{enumerable:!0,get:function(){return ne.VoiceProfile}});var se=r(145);Object.defineProperty(t,"VoiceProfileEnrollmentResult",{enumerable:!0,get:function(){return se.VoiceProfileEnrollmentResult}}),Object.defineProperty(t,"VoiceProfileEnrollmentCancellationDetails",{enumerable:!0,get:function(){return se.VoiceProfileEnrollmentCancellationDetails}});var oe=r(146);Object.defineProperty(t,"VoiceProfileResult",{enumerable:!0,get:function(){return oe.VoiceProfileResult}}),Object.defineProperty(t,"VoiceProfileCancellationDetails",{enumerable:!0,get:function(){return oe.VoiceProfileCancellationDetails}});var ae=r(147);Object.defineProperty(t,"VoiceProfilePhraseResult",{enumerable:!0,get:function(){return ae.VoiceProfilePhraseResult}});var ce=r(148);Object.defineProperty(t,"VoiceProfileClient",{enumerable:!0,get:function(){return ce.VoiceProfileClient}});var pe=r(149);Object.defineProperty(t,"SpeakerRecognizer",{enumerable:!0,get:function(){return pe.SpeakerRecognizer}});var he=r(150);Object.defineProperty(t,"SpeakerIdentificationModel",{enumerable:!0,get:function(){return he.SpeakerIdentificationModel}});var ue=r(151);Object.defineProperty(t,"SpeakerVerificationModel",{enumerable:!0,get:function(){return ue.SpeakerVerificationModel}});var de=r(152);Object.defineProperty(t,"AutoDetectSourceLanguageConfig",{enumerable:!0,get:function(){return de.AutoDetectSourceLanguageConfig}});var ve=r(154);Object.defineProperty(t,"AutoDetectSourceLanguageResult",{enumerable:!0,get:function(){return ve.AutoDetectSourceLanguageResult}});var le=r(155);Object.defineProperty(t,"SourceLanguageConfig",{enumerable:!0,get:function(){return le.SourceLanguageConfig}});var ge=r(156);Object.defineProperty(t,"SpeakerRecognitionResult",{enumerable:!0,get:function(){return ge.SpeakerRecognitionResult}}),Object.defineProperty(t,"SpeakerRecognitionResultType",{enumerable:!0,get:function(){return ge.SpeakerRecognitionResultType}}),Object.defineProperty(t,"SpeakerRecognitionCancellationDetails",{enumerable:!0,get:function(){return ge.SpeakerRecognitionCancellationDetails}});var me=r(157);Object.defineProperty(t,"Conversation",{enumerable:!0,get:function(){return me.Conversation}}),Object.defineProperty(t,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return me.ConversationExpirationEventArgs}}),Object.defineProperty(t,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return me.ConversationParticipantsChangedEventArgs}}),Object.defineProperty(t,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return me.ConversationTranslationCanceledEventArgs}}),Object.defineProperty(t,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return me.ConversationTranslationEventArgs}}),Object.defineProperty(t,"ConversationTranslationResult",{enumerable:!0,get:function(){return me.ConversationTranslationResult}}),Object.defineProperty(t,"ConversationTranslator",{enumerable:!0,get:function(){return me.ConversationTranslator}}),Object.defineProperty(t,"ConversationTranscriber",{enumerable:!0,get:function(){return me.ConversationTranscriber}}),Object.defineProperty(t,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return me.ConversationTranscriptionResult}}),Object.defineProperty(t,"Meeting",{enumerable:!0,get:function(){return me.Meeting}}),Object.defineProperty(t,"MeetingTranscriber",{enumerable:!0,get:function(){return me.MeetingTranscriber}}),Object.defineProperty(t,"Participant",{enumerable:!0,get:function(){return me.Participant}}),Object.defineProperty(t,"ParticipantChangedReason",{enumerable:!0,get:function(){return me.ParticipantChangedReason}}),Object.defineProperty(t,"User",{enumerable:!0,get:function(){return me.User}});var fe=r(175);Object.defineProperty(t,"Synthesizer",{enumerable:!0,get:function(){return fe.Synthesizer}});var Se=r(86);Object.defineProperty(t,"SpeechSynthesisOutputFormat",{enumerable:!0,get:function(){return Se.SpeechSynthesisOutputFormat}});var ye=r(176);Object.defineProperty(t,"SpeechSynthesizer",{enumerable:!0,get:function(){return ye.SpeechSynthesizer}});var Ce=r(177);Object.defineProperty(t,"SynthesisResult",{enumerable:!0,get:function(){return Ce.SynthesisResult}});var Pe=r(178);Object.defineProperty(t,"SpeechSynthesisResult",{enumerable:!0,get:function(){return Pe.SpeechSynthesisResult}});var Re=r(179);Object.defineProperty(t,"SpeechSynthesisEventArgs",{enumerable:!0,get:function(){return Re.SpeechSynthesisEventArgs}});var Ie=r(180);Object.defineProperty(t,"SpeechSynthesisWordBoundaryEventArgs",{enumerable:!0,get:function(){return Ie.SpeechSynthesisWordBoundaryEventArgs}});var Te=r(181);Object.defineProperty(t,"SpeechSynthesisBookmarkEventArgs",{enumerable:!0,get:function(){return Te.SpeechSynthesisBookmarkEventArgs}});var we=r(182);Object.defineProperty(t,"SpeechSynthesisVisemeEventArgs",{enumerable:!0,get:function(){return we.SpeechSynthesisVisemeEventArgs}});var Ee=r(183);Object.defineProperty(t,"SpeechSynthesisBoundaryType",{enumerable:!0,get:function(){return Ee.SpeechSynthesisBoundaryType}});var Ae=r(184);Object.defineProperty(t,"SynthesisVoicesResult",{enumerable:!0,get:function(){return Ae.SynthesisVoicesResult}});var be=r(185);Object.defineProperty(t,"SynthesisVoiceGender",{enumerable:!0,get:function(){return be.SynthesisVoiceGender}}),Object.defineProperty(t,"SynthesisVoiceType",{enumerable:!0,get:function(){return be.SynthesisVoiceType}}),Object.defineProperty(t,"VoiceInfo",{enumerable:!0,get:function(){return be.VoiceInfo}});var Oe=r(186);Object.defineProperty(t,"SpeakerAudioDestination",{enumerable:!0,get:function(){return Oe.SpeakerAudioDestination}});var Me=r(187);Object.defineProperty(t,"ConversationTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return Me.ConversationTranscriptionCanceledEventArgs}});var De=r(188);Object.defineProperty(t,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return De.MeetingTranscriptionCanceledEventArgs}});var ke=r(189);Object.defineProperty(t,"PronunciationAssessmentGradingSystem",{enumerable:!0,get:function(){return ke.PronunciationAssessmentGradingSystem}});var Ne=r(190);Object.defineProperty(t,"PronunciationAssessmentGranularity",{enumerable:!0,get:function(){return Ne.PronunciationAssessmentGranularity}});var _e=r(191);Object.defineProperty(t,"PronunciationAssessmentConfig",{enumerable:!0,get:function(){return _e.PronunciationAssessmentConfig}});var ze=r(192);Object.defineProperty(t,"PronunciationAssessmentResult",{enumerable:!0,get:function(){return ze.PronunciationAssessmentResult}});var Le=r(153);Object.defineProperty(t,"LanguageIdMode",{enumerable:!0,get:function(){return Le.LanguageIdMode}});var xe=r(193);Object.defineProperty(t,"AvatarConfig",{enumerable:!0,get:function(){return xe.AvatarConfig}});var Fe=r(194);Object.defineProperty(t,"AvatarEventArgs",{enumerable:!0,get:function(){return Fe.AvatarEventArgs}});var Be=r(195);Object.defineProperty(t,"AvatarSynthesizer",{enumerable:!0,get:function(){return Be.AvatarSynthesizer}});var je=r(197);Object.defineProperty(t,"AvatarVideoFormat",{enumerable:!0,get:function(){return je.AvatarVideoFormat}}),Object.defineProperty(t,"Coordinate",{enumerable:!0,get:function(){return je.Coordinate}});var Ue=r(198);Object.defineProperty(t,"AvatarWebRTCConnectionResult",{enumerable:!0,get:function(){return Ue.AvatarWebRTCConnectionResult}});var qe=r(199);Object.defineProperty(t,"Diagnostics",{enumerable:!0,get:function(){return qe.Diagnostics}});var We=r(63);Object.defineProperty(t,"LogLevel",{enumerable:!0,get:function(){return We.LogLevel}})},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AudioOutputConfigImpl=t.AudioConfigImpl=t.AudioConfig=void 0;const i=r(60),n=r(64),s=r(79),o=r(81),a=r(83),c=r(84);class p{static fromDefaultMicrophoneInput(){const e=new i.PcmRecorder(!0);return new h(new i.MicAudioSource(e))}static fromMicrophoneInput(e){const t=new i.PcmRecorder(!0);return new h(new i.MicAudioSource(t,e))}static fromWavFileInput(e,t="unnamedBuffer.wav"){return new h(new i.FileAudioSource(e,t))}static fromStreamInput(e){if(e instanceof s.PullAudioInputStreamCallback)return new h(new a.PullAudioInputStreamImpl(e));if(e instanceof s.AudioInputStream)return new h(e);if("undefined"!=typeof MediaStream&&e instanceof MediaStream){const t=new i.PcmRecorder(!1);return new h(new i.MicAudioSource(t,null,null,e))}throw new Error("Not Supported Type")}static fromDefaultSpeakerOutput(){return new u(new s.SpeakerAudioDestination)}static fromSpeakerOutput(e){if(void 0===e)return p.fromDefaultSpeakerOutput();if(e instanceof s.SpeakerAudioDestination)return new u(e);throw new Error("Not Supported Type")}static fromAudioFileOutput(e){return new u(new o.AudioFileWriter(e))}static fromStreamOutput(e){if(e instanceof s.PushAudioOutputStreamCallback)return new u(new c.PushAudioOutputStreamImpl(e));if(e instanceof s.PushAudioOutputStream)return new u(e);if(e instanceof s.PullAudioOutputStream)return new u(e);throw new Error("Not Supported Type")}}t.AudioConfig=p;class h extends p{constructor(e){super(),this.privSource=e}get format(){return this.privSource.format}close(e,t){this.privSource.turnOff().then((()=>{e&&e()}),(e=>{t&&t(e)}))}id(){return this.privSource.id()}turnOn(){return this.privSource.turnOn()}attach(e){return this.privSource.attach(e)}detach(e){return this.privSource.detach(e)}turnOff(){return this.privSource.turnOff()}get events(){return this.privSource.events}setProperty(e,t){if(n.Contracts.throwIfNull(t,"value"),void 0===this.privSource.setProperty)throw new Error("This AudioConfig instance does not support setting properties.");this.privSource.setProperty(e,t)}getProperty(e,t){if(void 0!==this.privSource.getProperty)return this.privSource.getProperty(e,t);throw new Error("This AudioConfig instance does not support getting properties.")}get deviceInfo(){return this.privSource.deviceInfo}}t.AudioConfigImpl=h;class u extends p{constructor(e){super(),this.privDestination=e}set format(e){this.privDestination.format=e}write(e){this.privDestination.write(e)}close(){this.privDestination.close()}id(){return this.privDestination.id()}setProperty(){throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(){throw new Error("This AudioConfig instance does not support getting properties.")}}t.AudioOutputConfigImpl=u},function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.AudioFileWriter=void 0;const o=s(r(82)),a=r(64);t.AudioFileWriter=class{constructor(e){a.Contracts.throwIfNullOrUndefined(o.openSync,"\nFile System access not available, please use Push or PullAudioOutputStream"),this.privFd=o.openSync(e,"w")}set format(e){a.Contracts.throwIfNotUndefined(this.privAudioFormat,"format is already set"),this.privAudioFormat=e;let t=0;this.privAudioFormat.hasHeader&&(t=this.privAudioFormat.header.byteLength),void 0!==this.privFd&&(this.privWriteStream=o.createWriteStream("",{fd:this.privFd,start:t,autoClose:!1}))}write(e){a.Contracts.throwIfNullOrUndefined(this.privAudioFormat,"must set format before writing."),void 0!==this.privWriteStream&&this.privWriteStream.write(new Uint8Array(e.slice(0)))}close(){void 0!==this.privFd&&(this.privWriteStream.on("finish",(()=>{this.privAudioFormat.hasHeader&&(this.privAudioFormat.updateHeader(this.privWriteStream.bytesWritten),o.writeSync(this.privFd,new Int8Array(this.privAudioFormat.header),0,this.privAudioFormat.header.byteLength,0)),o.closeSync(this.privFd),this.privFd=void 0})),this.privWriteStream.end())}id(){return this.privId}}},()=>{},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullAudioInputStreamImpl=t.PullAudioInputStream=t.PushAudioInputStreamImpl=t.PushAudioInputStream=t.AudioInputStream=void 0;const i=r(2),n=r(4),s=r(7),o=r(79),a=r(67);class c{constructor(){}static createPushStream(e){return p.create(e)}static createPullStream(e,t){return u.create(e,t)}}t.AudioInputStream=c;class p extends c{static create(e){return new h(e)}}t.PushAudioInputStream=p;class h extends p{constructor(e){super(),this.privFormat=void 0===e?a.AudioStreamFormatImpl.getDefaultInputFormat():e,this.privEvents=new n.EventSource,this.privId=(0,s.createNoDashGuid)(),this.privStream=new n.ChunkedArrayBufferStream(this.privFormat.avgBytesPerSec/10)}get format(){return Promise.resolve(this.privFormat)}write(e){this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}id(){return this.privId}turnOn(){this.onEvent(new n.AudioSourceInitializingEvent(this.privId)),this.onEvent(new n.AudioSourceReadyEvent(this.privId))}async attach(e){this.onEvent(new n.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn();const t=this.privStream;return this.onEvent(new n.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(this.onEvent(new n.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}}detach(e){this.onEvent(new n.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:i.connectivity.Unknown,manufacturer:"Speech SDK",model:"PushStream",samplerate:this.privFormat.samplesPerSec,type:i.type.Stream})}onEvent(e){this.privEvents.onEvent(e),n.Events.instance.onEvent(e)}toBuffer(e){const t=Buffer.alloc(e.byteLength),r=new Uint8Array(e);for(let e=0;e<t.length;++e)t[e]=r[e];return t}}t.PushAudioInputStreamImpl=h;class u extends c{constructor(){super()}static create(e,t){return new d(e,t)}}t.PullAudioInputStream=u;class d extends u{constructor(e,t){super(),this.privFormat=void 0===t?o.AudioStreamFormat.getDefaultInputFormat():t,this.privEvents=new n.EventSource,this.privId=(0,s.createNoDashGuid)(),this.privCallback=e,this.privIsClosed=!1,this.privBufferSize=this.privFormat.avgBytesPerSec/10}get format(){return Promise.resolve(this.privFormat)}close(){this.privIsClosed=!0,this.privCallback.close()}id(){return this.privId}turnOn(){this.onEvent(new n.AudioSourceInitializingEvent(this.privId)),this.onEvent(new n.AudioSourceReadyEvent(this.privId))}async attach(e){return this.onEvent(new n.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn(),this.onEvent(new n.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:()=>(this.privCallback.close(),this.onEvent(new n.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>{let e,t=0;for(;t<this.privBufferSize;){const r=new ArrayBuffer(this.privBufferSize-t),i=this.privCallback.read(r);if(void 0===e)e=r;else{new Int8Array(e).set(new Int8Array(r),t)}if(0===i)break;t+=i}return Promise.resolve({buffer:e.slice(0,t),isEnd:this.privIsClosed||0===t,timeReceived:Date.now()})}}}detach(e){this.onEvent(new n.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:i.connectivity.Unknown,manufacturer:"Speech SDK",model:"PullStream",samplerate:this.privFormat.samplesPerSec,type:i.type.Stream})}onEvent(e){this.privEvents.onEvent(e),n.Events.instance.onEvent(e)}}t.PullAudioInputStreamImpl=d},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushAudioOutputStreamImpl=t.PushAudioOutputStream=t.PullAudioOutputStreamImpl=t.PullAudioOutputStream=t.AudioOutputStream=void 0;const i=r(4),n=r(64),s=r(85);class o{constructor(){}static createPullStream(){return a.create()}}t.AudioOutputStream=o;class a extends o{static create(){return new c}}t.PullAudioOutputStream=a;class c extends a{constructor(){super(),this.privId=(0,i.createNoDashGuid)(),this.privStream=new i.Stream}set format(e){null==e&&(this.privFormat=s.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privFormat=e}get format(){return this.privFormat}get isClosed(){return this.privStream.isClosed}id(){return this.privId}async read(e){const t=new Int8Array(e);let r=0;if(void 0!==this.privLastChunkView){if(this.privLastChunkView.length>e.byteLength)return t.set(this.privLastChunkView.slice(0,e.byteLength)),this.privLastChunkView=this.privLastChunkView.slice(e.byteLength),Promise.resolve(e.byteLength);t.set(this.privLastChunkView),r=this.privLastChunkView.length,this.privLastChunkView=void 0}for(;r<e.byteLength&&!this.privStream.isReadEnded;){const i=await this.privStream.read();if(void 0===i||i.isEnd)this.privStream.readEnded();else{let n;i.buffer.byteLength>e.byteLength-r?(n=i.buffer.slice(0,e.byteLength-r),this.privLastChunkView=new Int8Array(i.buffer.slice(e.byteLength-r))):n=i.buffer,t.set(new Int8Array(n),r),r+=n.byteLength}}return r}write(e){n.Contracts.throwIfNullOrUndefined(this.privStream,"must set format before writing"),this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}}t.PullAudioOutputStreamImpl=c;class p extends o{constructor(){super()}static create(e){return new h(e)}}t.PushAudioOutputStream=p;class h extends p{constructor(e){super(),this.privId=(0,i.createNoDashGuid)(),this.privCallback=e}set format(e){}write(e){this.privCallback.write&&this.privCallback.write(e)}close(){this.privCallback.close&&this.privCallback.close()}id(){return this.privId}}t.PushAudioOutputStreamImpl=h},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AudioOutputFormatImpl=void 0;const i=r(86),n=r(67);class s extends n.AudioStreamFormatImpl{constructor(e,t,r,i,n,s,o,a,c){super(r,s,t,e),this.formatTag=e,this.avgBytesPerSec=i,this.blockAlign=n,this.priAudioFormatString=o,this.priRequestAudioFormatString=a,this.priHasHeader=c}static fromSpeechSynthesisOutputFormat(e){return void 0===e?s.getDefaultOutputFormat():s.fromSpeechSynthesisOutputFormatString(s.SpeechSynthesisOutputFormatToString[e])}static fromSpeechSynthesisOutputFormatString(e){switch(e){case"raw-8khz-8bit-mono-mulaw":return new s(n.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,e,!1);case"riff-16khz-16kbps-mono-siren":return new s(n.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,"audio-16khz-16kbps-mono-siren",!0);case"audio-16khz-16kbps-mono-siren":return new s(n.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,e,!1);case"audio-16khz-32kbitrate-mono-mp3":return new s(n.AudioFormatTag.MP3,1,16e3,4096,2,16,e,e,!1);case"audio-16khz-128kbitrate-mono-mp3":return new s(n.AudioFormatTag.MP3,1,16e3,16384,2,16,e,e,!1);case"audio-16khz-64kbitrate-mono-mp3":return new s(n.AudioFormatTag.MP3,1,16e3,8192,2,16,e,e,!1);case"audio-24khz-48kbitrate-mono-mp3":return new s(n.AudioFormatTag.MP3,1,24e3,6144,2,16,e,e,!1);case"audio-24khz-96kbitrate-mono-mp3":return new s(n.AudioFormatTag.MP3,1,24e3,12288,2,16,e,e,!1);case"audio-24khz-160kbitrate-mono-mp3":return new s(n.AudioFormatTag.MP3,1,24e3,20480,2,16,e,e,!1);case"raw-16khz-16bit-mono-truesilk":return new s(n.AudioFormatTag.SILKSkype,1,16e3,32e3,2,16,e,e,!1);case"riff-8khz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!0);case"riff-24khz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!0);case"riff-8khz-8bit-mono-mulaw":return new s(n.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-mulaw",!0);case"raw-16khz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,16e3,32e3,2,16,e,"raw-16khz-16bit-mono-pcm",!1);case"raw-24khz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!1);case"raw-8khz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!1);case"ogg-16khz-16bit-mono-opus":return new s(n.AudioFormatTag.OGG_OPUS,1,16e3,8192,2,16,e,e,!1);case"ogg-24khz-16bit-mono-opus":return new s(n.AudioFormatTag.OGG_OPUS,1,24e3,8192,2,16,e,e,!1);case"raw-48khz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!1);case"riff-48khz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!0);case"audio-48khz-96kbitrate-mono-mp3":return new s(n.AudioFormatTag.MP3,1,48e3,12288,2,16,e,e,!1);case"audio-48khz-192kbitrate-mono-mp3":return new s(n.AudioFormatTag.MP3,1,48e3,24576,2,16,e,e,!1);case"ogg-48khz-16bit-mono-opus":return new s(n.AudioFormatTag.OGG_OPUS,1,48e3,12e3,2,16,e,e,!1);case"webm-16khz-16bit-mono-opus":return new s(n.AudioFormatTag.WEBM_OPUS,1,16e3,4e3,2,16,e,e,!1);case"webm-24khz-16bit-mono-opus":return new s(n.AudioFormatTag.WEBM_OPUS,1,24e3,6e3,2,16,e,e,!1);case"webm-24khz-16bit-24kbps-mono-opus":return new s(n.AudioFormatTag.WEBM_OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-16khz-16bit-32kbps-mono-opus":return new s(n.AudioFormatTag.OPUS,1,16e3,4e3,2,16,e,e,!1);case"audio-24khz-16bit-48kbps-mono-opus":return new s(n.AudioFormatTag.OPUS,1,24e3,6e3,2,16,e,e,!1);case"audio-24khz-16bit-24kbps-mono-opus":return new s(n.AudioFormatTag.OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-24khz-16bit-mono-flac":return new s(n.AudioFormatTag.FLAC,1,24e3,24e3,2,16,e,e,!1);case"audio-48khz-16bit-mono-flac":return new s(n.AudioFormatTag.FLAC,1,48e3,3e4,2,16,e,e,!1);case"raw-24khz-16bit-mono-truesilk":return new s(n.AudioFormatTag.SILKSkype,1,24e3,48e3,2,16,e,e,!1);case"raw-8khz-8bit-mono-alaw":return new s(n.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,e,!1);case"riff-8khz-8bit-mono-alaw":return new s(n.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-alaw",!0);case"raw-22050hz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,22050,44100,2,16,e,e,!1);case"riff-22050hz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,22050,44100,2,16,e,"raw-22050hz-16bit-mono-pcm",!0);case"raw-44100hz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,44100,88200,2,16,e,e,!1);case"riff-44100hz-16bit-mono-pcm":return new s(n.AudioFormatTag.PCM,1,44100,88200,2,16,e,"raw-44100hz-16bit-mono-pcm",!0);case"amr-wb-16000h":return new s(n.AudioFormatTag.AMR_WB,1,16e3,3052,2,16,e,e,!1);case"g722-16khz-64kbps":return new s(n.AudioFormatTag.G722,1,16e3,8e3,2,16,e,e,!1);default:return new s(n.AudioFormatTag.PCM,1,16e3,32e3,2,16,"riff-16khz-16bit-mono-pcm","raw-16khz-16bit-mono-pcm",!0)}}static getDefaultOutputFormat(){return s.fromSpeechSynthesisOutputFormatString("undefined"!=typeof window?"audio-24khz-48kbitrate-mono-mp3":"riff-16khz-16bit-mono-pcm")}get hasHeader(){return this.priHasHeader}get header(){if(this.hasHeader)return this.privHeader}updateHeader(e){if(this.priHasHeader){const t=new DataView(this.privHeader);t.setUint32(4,e+this.privHeader.byteLength-8,!0),t.setUint32(40,e,!0)}}get requestAudioFormatString(){return this.priRequestAudioFormatString}addHeader(e){if(!this.hasHeader)return e;this.updateHeader(e.byteLength);const t=new Uint8Array(e.byteLength+this.header.byteLength);return t.set(new Uint8Array(this.header),0),t.set(new Uint8Array(e),this.header.byteLength),t.buffer}}t.AudioOutputFormatImpl=s,s.SpeechSynthesisOutputFormatToString={[i.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]:"raw-8khz-8bit-mono-mulaw",[i.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]:"riff-16khz-16kbps-mono-siren",[i.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]:"audio-16khz-16kbps-mono-siren",[i.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]:"audio-16khz-32kbitrate-mono-mp3",[i.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]:"audio-16khz-128kbitrate-mono-mp3",[i.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]:"audio-16khz-64kbitrate-mono-mp3",[i.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]:"audio-24khz-48kbitrate-mono-mp3",[i.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]:"audio-24khz-96kbitrate-mono-mp3",[i.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]:"audio-24khz-160kbitrate-mono-mp3",[i.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]:"raw-16khz-16bit-mono-truesilk",[i.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]:"riff-16khz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]:"riff-8khz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]:"riff-24khz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]:"riff-8khz-8bit-mono-mulaw",[i.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]:"raw-16khz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]:"raw-24khz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]:"raw-8khz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus]:"ogg-16khz-16bit-mono-opus",[i.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus]:"ogg-24khz-16bit-mono-opus",[i.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm]:"raw-48khz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm]:"riff-48khz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3]:"audio-48khz-96kbitrate-mono-mp3",[i.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3]:"audio-48khz-192kbitrate-mono-mp3",[i.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus]:"ogg-48khz-16bit-mono-opus",[i.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus]:"webm-16khz-16bit-mono-opus",[i.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus]:"webm-24khz-16bit-mono-opus",[i.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus]:"webm-24khz-16bit-24kbps-mono-opus",[i.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk]:"raw-24khz-16bit-mono-truesilk",[i.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw]:"raw-8khz-8bit-mono-alaw",[i.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw]:"riff-8khz-8bit-mono-alaw",[i.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus]:"audio-16khz-16bit-32kbps-mono-opus",[i.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus]:"audio-24khz-16bit-48kbps-mono-opus",[i.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus]:"audio-24khz-16bit-24kbps-mono-opus",[i.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm]:"raw-22050hz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]:"riff-22050hz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]:"raw-44100hz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]:"riff-44100hz-16bit-mono-pcm",[i.SpeechSynthesisOutputFormat.AmrWb16000Hz]:"amr-wb-16000hz",[i.SpeechSynthesisOutputFormat.G72216Khz64Kbps]:"g722-16khz-64kbps"}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisOutputFormat=void 0,function(e){e[e.Raw8Khz8BitMonoMULaw=0]="Raw8Khz8BitMonoMULaw",e[e.Riff16Khz16KbpsMonoSiren=1]="Riff16Khz16KbpsMonoSiren",e[e.Audio16Khz16KbpsMonoSiren=2]="Audio16Khz16KbpsMonoSiren",e[e.Audio16Khz32KBitRateMonoMp3=3]="Audio16Khz32KBitRateMonoMp3",e[e.Audio16Khz128KBitRateMonoMp3=4]="Audio16Khz128KBitRateMonoMp3",e[e.Audio16Khz64KBitRateMonoMp3=5]="Audio16Khz64KBitRateMonoMp3",e[e.Audio24Khz48KBitRateMonoMp3=6]="Audio24Khz48KBitRateMonoMp3",e[e.Audio24Khz96KBitRateMonoMp3=7]="Audio24Khz96KBitRateMonoMp3",e[e.Audio24Khz160KBitRateMonoMp3=8]="Audio24Khz160KBitRateMonoMp3",e[e.Raw16Khz16BitMonoTrueSilk=9]="Raw16Khz16BitMonoTrueSilk",e[e.Riff16Khz16BitMonoPcm=10]="Riff16Khz16BitMonoPcm",e[e.Riff8Khz16BitMonoPcm=11]="Riff8Khz16BitMonoPcm",e[e.Riff24Khz16BitMonoPcm=12]="Riff24Khz16BitMonoPcm",e[e.Riff8Khz8BitMonoMULaw=13]="Riff8Khz8BitMonoMULaw",e[e.Raw16Khz16BitMonoPcm=14]="Raw16Khz16BitMonoPcm",e[e.Raw24Khz16BitMonoPcm=15]="Raw24Khz16BitMonoPcm",e[e.Raw8Khz16BitMonoPcm=16]="Raw8Khz16BitMonoPcm",e[e.Ogg16Khz16BitMonoOpus=17]="Ogg16Khz16BitMonoOpus",e[e.Ogg24Khz16BitMonoOpus=18]="Ogg24Khz16BitMonoOpus",e[e.Raw48Khz16BitMonoPcm=19]="Raw48Khz16BitMonoPcm",e[e.Riff48Khz16BitMonoPcm=20]="Riff48Khz16BitMonoPcm",e[e.Audio48Khz96KBitRateMonoMp3=21]="Audio48Khz96KBitRateMonoMp3",e[e.Audio48Khz192KBitRateMonoMp3=22]="Audio48Khz192KBitRateMonoMp3",e[e.Ogg48Khz16BitMonoOpus=23]="Ogg48Khz16BitMonoOpus",e[e.Webm16Khz16BitMonoOpus=24]="Webm16Khz16BitMonoOpus",e[e.Webm24Khz16BitMonoOpus=25]="Webm24Khz16BitMonoOpus",e[e.Raw24Khz16BitMonoTrueSilk=26]="Raw24Khz16BitMonoTrueSilk",e[e.Raw8Khz8BitMonoALaw=27]="Raw8Khz8BitMonoALaw",e[e.Riff8Khz8BitMonoALaw=28]="Riff8Khz8BitMonoALaw",e[e.Webm24Khz16Bit24KbpsMonoOpus=29]="Webm24Khz16Bit24KbpsMonoOpus",e[e.Audio16Khz16Bit32KbpsMonoOpus=30]="Audio16Khz16Bit32KbpsMonoOpus",e[e.Audio24Khz16Bit48KbpsMonoOpus=31]="Audio24Khz16Bit48KbpsMonoOpus",e[e.Audio24Khz16Bit24KbpsMonoOpus=32]="Audio24Khz16Bit24KbpsMonoOpus",e[e.Raw22050Hz16BitMonoPcm=33]="Raw22050Hz16BitMonoPcm",e[e.Riff22050Hz16BitMonoPcm=34]="Riff22050Hz16BitMonoPcm",e[e.Raw44100Hz16BitMonoPcm=35]="Raw44100Hz16BitMonoPcm",e[e.Riff44100Hz16BitMonoPcm=36]="Riff44100Hz16BitMonoPcm",e[e.AmrWb16000Hz=37]="AmrWb16000Hz",e[e.G72216Khz64Kbps=38]="G72216Khz64Kbps"}(t.SpeechSynthesisOutputFormat||(t.SpeechSynthesisOutputFormat={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CancellationReason=void 0,function(e){e[e.Error=0]="Error",e[e.EndOfStream=1]="EndOfStream"}(t.CancellationReason||(t.CancellationReason={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullAudioInputStreamCallback=void 0;t.PullAudioInputStreamCallback=class{}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushAudioOutputStreamCallback=void 0;t.PushAudioOutputStreamCallback=class{}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordRecognitionModel=void 0;const i=r(64);t.KeywordRecognitionModel=class{constructor(){this.privDisposed=!1}static fromFile(e){throw i.Contracts.throwIfFileDoesNotExist(e,"fileName"),new Error("Not yet implemented.")}static fromStream(e){throw i.Contracts.throwIfNull(e,"file"),new Error("Not yet implemented.")}close(){this.privDisposed||(this.privDisposed=!0)}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SessionEventArgs=void 0;t.SessionEventArgs=class{constructor(e){this.privSessionId=e}get sessionId(){return this.privSessionId}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RecognitionEventArgs=void 0;const i=r(79);class n extends i.SessionEventArgs{constructor(e,t){super(t),this.privOffset=e}get offset(){return this.privOffset}}t.RecognitionEventArgs=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OutputFormat=void 0,function(e){e[e.Simple=0]="Simple",e[e.Detailed=1]="Detailed"}(t.OutputFormat||(t.OutputFormat={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntentRecognitionEventArgs=void 0;const i=r(79);class n extends i.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}}t.IntentRecognitionEventArgs=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RecognitionResult=void 0;t.RecognitionResult=class{constructor(e,t,r,i,n,s,o,a,c,p){this.privResultId=e,this.privReason=t,this.privText=r,this.privDuration=i,this.privOffset=n,this.privLanguage=s,this.privLanguageDetectionConfidence=o,this.privErrorDetails=a,this.privJson=c,this.privProperties=p}get resultId(){return this.privResultId}get reason(){return this.privReason}get text(){return this.privText}get duration(){return this.privDuration}get offset(){return this.privOffset}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}get errorDetails(){return this.privErrorDetails}get json(){return this.privJson}get properties(){return this.privProperties}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechRecognitionResult=void 0;const i=r(79);class n extends i.RecognitionResult{constructor(e,t,r,i,n,s,o,a,c,p,h){super(e,t,r,i,n,s,o,c,p,h),this.privSpeakerId=a}get speakerId(){return this.privSpeakerId}}t.SpeechRecognitionResult=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntentRecognitionResult=void 0;const i=r(79);class n extends i.SpeechRecognitionResult{constructor(e,t,r,i,n,s,o,a,c,p,h){super(t,r,i,n,s,o,a,void 0,c,p,h),this.privIntentId=e}get intentId(){return this.privIntentId}}t.IntentRecognitionResult=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LanguageUnderstandingModelImpl=t.LanguageUnderstandingModel=void 0;const i=r(64);class n{constructor(){}static fromEndpoint(e){i.Contracts.throwIfNull(e,"uri"),i.Contracts.throwIfNullOrWhitespace(e.hostname,"uri");const t=new s,r=e.host.indexOf(".");if(-1===r)throw new Error("Could not determine region from endpoint");t.region=e.host.substr(0,r);const n=e.pathname.lastIndexOf("/")+1;if(-1===n)throw new Error("Could not determine appId from endpoint");if(t.appId=e.pathname.substr(n),t.subscriptionKey=e.searchParams.get("subscription-key"),void 0===t.subscriptionKey)throw new Error("Could not determine subscription key from endpoint");return t}static fromAppId(e){i.Contracts.throwIfNullOrWhitespace(e,"appId");const t=new s;return t.appId=e,t}static fromSubscription(e,t,r){i.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),i.Contracts.throwIfNullOrWhitespace(t,"appId"),i.Contracts.throwIfNullOrWhitespace(r,"region");const n=new s;return n.appId=t,n.region=r,n.subscriptionKey=e,n}}t.LanguageUnderstandingModel=n;class s extends n{}t.LanguageUnderstandingModelImpl=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeetingTranscriptionEventArgs=t.ConversationTranscriptionEventArgs=t.SpeechRecognitionEventArgs=void 0;const i=r(79);class n extends i.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}}t.SpeechRecognitionEventArgs=n;class s extends i.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}}t.ConversationTranscriptionEventArgs=s;t.MeetingTranscriptionEventArgs=class extends n{}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechRecognitionCanceledEventArgs=void 0;const i=r(101);class n extends i.CancellationEventArgsBase{}t.SpeechRecognitionCanceledEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CancellationEventArgsBase=void 0;const i=r(79);class n extends i.RecognitionEventArgs{constructor(e,t,r,i,n){super(i,n),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}}t.CancellationEventArgsBase=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationRecognitionEventArgs=void 0;const i=r(79);class n extends i.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}}t.TranslationRecognitionEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationSynthesisEventArgs=void 0;const i=r(79);class n extends i.SessionEventArgs{constructor(e,t){super(t),this.privResult=e}get result(){return this.privResult}}t.TranslationSynthesisEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationRecognitionResult=void 0;const i=r(79);class n extends i.SpeechRecognitionResult{constructor(e,t,r,i,n,s,o,a,c,p,h){super(t,r,i,n,s,o,a,void 0,c,p,h),this.privTranslations=e}static fromSpeechRecognitionResult(e){return new n(void 0,e.resultId,e.reason,e.text,e.duration,e.offset,e.language,e.languageDetectionConfidence,e.errorDetails,e.json,e.properties)}get translations(){return this.privTranslations}}t.TranslationRecognitionResult=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationSynthesisResult=void 0;t.TranslationSynthesisResult=class{constructor(e,t){this.privReason=e,this.privAudio=t}get audio(){return this.privAudio}get reason(){return this.privReason}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ResultReason=void 0,function(e){e[e.NoMatch=0]="NoMatch",e[e.Canceled=1]="Canceled",e[e.RecognizingSpeech=2]="RecognizingSpeech",e[e.RecognizedSpeech=3]="RecognizedSpeech",e[e.RecognizedKeyword=4]="RecognizedKeyword",e[e.RecognizingIntent=5]="RecognizingIntent",e[e.RecognizedIntent=6]="RecognizedIntent",e[e.TranslatingSpeech=7]="TranslatingSpeech",e[e.TranslatedSpeech=8]="TranslatedSpeech",e[e.SynthesizingAudio=9]="SynthesizingAudio",e[e.SynthesizingAudioCompleted=10]="SynthesizingAudioCompleted",e[e.SynthesizingAudioStarted=11]="SynthesizingAudioStarted",e[e.EnrollingVoiceProfile=12]="EnrollingVoiceProfile",e[e.EnrolledVoiceProfile=13]="EnrolledVoiceProfile",e[e.RecognizedSpeakers=14]="RecognizedSpeakers",e[e.RecognizedSpeaker=15]="RecognizedSpeaker",e[e.ResetVoiceProfile=16]="ResetVoiceProfile",e[e.DeletedVoiceProfile=17]="DeletedVoiceProfile",e[e.VoicesListRetrieved=18]="VoicesListRetrieved",e[e.TranslatingParticipantSpeech=19]="TranslatingParticipantSpeech",e[e.TranslatedParticipantSpeech=20]="TranslatedParticipantSpeech",e[e.TranslatedInstantMessage=21]="TranslatedInstantMessage",e[e.TranslatedParticipantInstantMessage=22]="TranslatedParticipantInstantMessage"}(t.ResultReason||(t.ResultReason={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechConfigImpl=t.SpeechConfig=void 0;const i=r(2),n=r(64),s=r(79);class o{constructor(){}static fromSubscription(e,t){n.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),n.Contracts.throwIfNullOrWhitespace(t,"region");const r=new a;return r.setProperty(s.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(s.PropertyId.SpeechServiceConnection_IntentRegion,t),r.setProperty(s.PropertyId.SpeechServiceConnection_Key,e),r}static fromEndpoint(e,t){n.Contracts.throwIfNull(e,"endpoint");const r="string"==typeof t&&t.trim().length>0,i="object"==typeof t&&null!==t&&"function"==typeof t.getToken;if(void 0!==t&&!r&&!i)throw new Error("Invalid 'auth' parameter: must be a non-empty key string or a valid TokenCredential object.");const o="object"==typeof t?new a(t):new a;return o.setProperty(s.PropertyId.SpeechServiceConnection_Endpoint,e.href),"string"==typeof t&&t.trim().length>0&&o.setProperty(s.PropertyId.SpeechServiceConnection_Key,t),o}static fromHost(e,t){n.Contracts.throwIfNull(e,"hostName");const r=new a;return r.setProperty(s.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(""===e.port?"":":"+e.port)),r.setProperty(s.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"1"),void 0!==t&&r.setProperty(s.PropertyId.SpeechServiceConnection_Key,t),r}static fromAuthorizationToken(e,t){n.Contracts.throwIfNull(e,"authorizationToken"),n.Contracts.throwIfNullOrWhitespace(t,"region");const r=new a;return r.setProperty(s.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(s.PropertyId.SpeechServiceConnection_IntentRegion,t),r.authorizationToken=e,r}close(){}}t.SpeechConfig=o;class a extends o{constructor(e){super(),this.privProperties=new s.PropertyCollection,this.speechRecognitionLanguage="en-US",this.outputFormat=s.OutputFormat.Simple,this.privTokenCredential=e}get properties(){return this.privProperties}get endPoint(){return new URL(this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_Endpoint))}get subscriptionKey(){return this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_Key)}get region(){return this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_Region)}get authorizationToken(){return this.privProperties.getProperty(s.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.privProperties.setProperty(s.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage)}set speechRecognitionLanguage(e){this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get autoDetectSourceLanguages(){return this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)}set autoDetectSourceLanguages(e){this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e)}get outputFormat(){return s.OutputFormat[this.privProperties.getProperty(i.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privProperties.setProperty(i.OutputFormatPropertyName,s.OutputFormat[e])}get endpointId(){return this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_EndpointId,e)}get tokenCredential(){return this.privTokenCredential}setProperty(e,t){n.Contracts.throwIfNull(t,"value"),this.privProperties.setProperty(e,t)}getProperty(e,t){return this.privProperties.getProperty(e,t)}setProxy(e,t,r,i){this.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_ProxyPassword],i)}setServiceProperty(e,t){const r=JSON.parse(this.privProperties.getProperty(i.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(i.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privProperties.setProperty(s.PropertyId.SpeechServiceResponse_ProfanityOption,s.ProfanityOption[e])}enableAudioLogging(){this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privProperties.setProperty(s.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true"),this.privProperties.setProperty(i.OutputFormatPropertyName,s.OutputFormat[s.OutputFormat.Detailed])}enableDictation(){this.privProperties.setProperty(i.ForceDictationPropertyName,"true")}clone(){const e=new a(this.tokenCredential);return e.privProperties=this.privProperties.clone(),e}get speechSynthesisLanguage(){return this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return s.SpeechSynthesisOutputFormat[this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_SynthOutputFormat,s.SpeechSynthesisOutputFormat[e])}}t.SpeechConfigImpl=a},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechTranslationConfigImpl=t.SpeechTranslationConfig=void 0;const i=r(2),n=r(64),s=r(79);class o extends s.SpeechConfig{constructor(){super()}static fromSubscription(e,t){n.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),n.Contracts.throwIfNullOrWhitespace(t,"region");const r=new a;return r.properties.setProperty(s.PropertyId.SpeechServiceConnection_Key,e),r.properties.setProperty(s.PropertyId.SpeechServiceConnection_Region,t),r}static fromAuthorizationToken(e,t){n.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),n.Contracts.throwIfNullOrWhitespace(t,"region");const r=new a;return r.properties.setProperty(s.PropertyId.SpeechServiceAuthorization_Token,e),r.properties.setProperty(s.PropertyId.SpeechServiceConnection_Region,t),r}static fromHost(e,t){n.Contracts.throwIfNull(e,"hostName");const r=new a;return r.setProperty(s.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(""===e.port?"":":"+e.port)),void 0!==t&&r.setProperty(s.PropertyId.SpeechServiceConnection_Key,t),r}static fromEndpoint(e,t){n.Contracts.throwIfNull(e,"endpoint");const r="string"==typeof t&&t.trim().length>0,i="object"==typeof t&&null!==t&&"function"==typeof t.getToken;if(void 0!==t&&!r&&!i)throw new Error("Invalid 'auth' parameter: must be a non-empty key string or a valid TokenCredential object.");const o="object"==typeof t?new a(t):new a;return o.setProperty(s.PropertyId.SpeechServiceConnection_Endpoint,e.href),"string"==typeof t&&t.trim().length>0&&o.setProperty(s.PropertyId.SpeechServiceConnection_Key,t),o}}t.SpeechTranslationConfig=o;class a extends o{constructor(e){super(),this.privSpeechProperties=new s.PropertyCollection,this.outputFormat=s.OutputFormat.Simple,this.privTokenCredential=e}set authorizationToken(e){n.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceAuthorization_Token,e)}set speechRecognitionLanguage(e){n.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get speechRecognitionLanguage(){return this.privSpeechProperties.getProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_RecoLanguage])}get subscriptionKey(){return this.privSpeechProperties.getProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_Key])}get outputFormat(){return s.OutputFormat[this.privSpeechProperties.getProperty(i.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privSpeechProperties.setProperty(i.OutputFormatPropertyName,s.OutputFormat[e])}get endpointId(){return this.privSpeechProperties.getProperty(s.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceConnection_EndpointId,e)}addTargetLanguage(e){n.Contracts.throwIfNullOrWhitespace(e,"value");const t=this.targetLanguages;t.includes(e)||(t.push(e),this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))}get targetLanguages(){return void 0!==this.privSpeechProperties.getProperty(s.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)?this.privSpeechProperties.getProperty(s.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","):[]}get voiceName(){return this.getProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_TranslationVoice])}set voiceName(e){n.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceConnection_TranslationVoice,e)}get region(){return this.privSpeechProperties.getProperty(s.PropertyId.SpeechServiceConnection_Region)}get tokenCredential(){return this.privTokenCredential}setProxy(e,t,r,i){this.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_ProxyPassword],i)}getProperty(e,t){return this.privSpeechProperties.getProperty(e,t)}setProperty(e,t){this.privSpeechProperties.setProperty(e,t)}get properties(){return this.privSpeechProperties}close(){}setServiceProperty(e,t){const r=JSON.parse(this.privSpeechProperties.getProperty(i.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privSpeechProperties.setProperty(i.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceResponse_ProfanityOption,s.ProfanityOption[e])}enableAudioLogging(){this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privSpeechProperties.setProperty(i.ForceDictationPropertyName,"true")}get speechSynthesisLanguage(){return this.privSpeechProperties.getProperty(s.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privSpeechProperties.getProperty(s.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return s.SpeechSynthesisOutputFormat[this.privSpeechProperties.getProperty(s.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privSpeechProperties.setProperty(s.PropertyId.SpeechServiceConnection_SynthOutputFormat,s.SpeechSynthesisOutputFormat[e])}}t.SpeechTranslationConfigImpl=a},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PropertyCollection=void 0;const i=r(79);class n{constructor(){this.privKeys=[],this.privValues=[]}getProperty(e,t){let r;r="string"==typeof e?e:i.PropertyId[e];for(let e=0;e<this.privKeys.length;e++)if(this.privKeys[e]===r)return this.privValues[e];if(void 0!==t)return String(t)}setProperty(e,t){let r;r="string"==typeof e?e:i.PropertyId[e];for(let e=0;e<this.privKeys.length;e++)if(this.privKeys[e]===r)return void(this.privValues[e]=t);this.privKeys.push(r),this.privValues.push(t)}clone(){const e=new n;for(let t=0;t<this.privKeys.length;t++)e.privKeys.push(this.privKeys[t]),e.privValues.push(this.privValues[t]);return e}mergeTo(e){this.privKeys.forEach((t=>{if(void 0===e.getProperty(t,void 0)){const r=this.getProperty(t);e.setProperty(t,r)}}))}get keys(){return this.privKeys}}t.PropertyCollection=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PropertyId=void 0,function(e){e[e.SpeechServiceConnection_Key=0]="SpeechServiceConnection_Key",e[e.SpeechServiceConnection_Endpoint=1]="SpeechServiceConnection_Endpoint",e[e.SpeechServiceConnection_Region=2]="SpeechServiceConnection_Region",e[e.SpeechServiceAuthorization_Token=3]="SpeechServiceAuthorization_Token",e[e.SpeechServiceAuthorization_Type=4]="SpeechServiceAuthorization_Type",e[e.SpeechServiceConnection_EndpointId=5]="SpeechServiceConnection_EndpointId",e[e.SpeechServiceConnection_TranslationToLanguages=6]="SpeechServiceConnection_TranslationToLanguages",e[e.SpeechServiceConnection_TranslationVoice=7]="SpeechServiceConnection_TranslationVoice",e[e.SpeechServiceConnection_TranslationFeatures=8]="SpeechServiceConnection_TranslationFeatures",e[e.SpeechServiceConnection_TranslationCategoryId=9]="SpeechServiceConnection_TranslationCategoryId",e[e.SpeechServiceConnection_IntentRegion=10]="SpeechServiceConnection_IntentRegion",e[e.SpeechServiceConnection_ProxyHostName=11]="SpeechServiceConnection_ProxyHostName",e[e.SpeechServiceConnection_ProxyPort=12]="SpeechServiceConnection_ProxyPort",e[e.SpeechServiceConnection_ProxyUserName=13]="SpeechServiceConnection_ProxyUserName",e[e.SpeechServiceConnection_ProxyPassword=14]="SpeechServiceConnection_ProxyPassword",e[e.SpeechServiceConnection_RecoMode=15]="SpeechServiceConnection_RecoMode",e[e.SpeechServiceConnection_RecoLanguage=16]="SpeechServiceConnection_RecoLanguage",e[e.Speech_SessionId=17]="Speech_SessionId",e[e.SpeechServiceConnection_SynthLanguage=18]="SpeechServiceConnection_SynthLanguage",e[e.SpeechServiceConnection_SynthVoice=19]="SpeechServiceConnection_SynthVoice",e[e.SpeechServiceConnection_SynthOutputFormat=20]="SpeechServiceConnection_SynthOutputFormat",e[e.SpeechServiceConnection_AutoDetectSourceLanguages=21]="SpeechServiceConnection_AutoDetectSourceLanguages",e[e.SpeechServiceResponse_RequestDetailedResultTrueFalse=22]="SpeechServiceResponse_RequestDetailedResultTrueFalse",e[e.SpeechServiceResponse_RequestProfanityFilterTrueFalse=23]="SpeechServiceResponse_RequestProfanityFilterTrueFalse",e[e.SpeechServiceResponse_JsonResult=24]="SpeechServiceResponse_JsonResult",e[e.SpeechServiceResponse_JsonErrorDetails=25]="SpeechServiceResponse_JsonErrorDetails",e[e.CancellationDetails_Reason=26]="CancellationDetails_Reason",e[e.CancellationDetails_ReasonText=27]="CancellationDetails_ReasonText",e[e.CancellationDetails_ReasonDetailedText=28]="CancellationDetails_ReasonDetailedText",e[e.LanguageUnderstandingServiceResponse_JsonResult=29]="LanguageUnderstandingServiceResponse_JsonResult",e[e.SpeechServiceConnection_Url=30]="SpeechServiceConnection_Url",e[e.SpeechServiceConnection_InitialSilenceTimeoutMs=31]="SpeechServiceConnection_InitialSilenceTimeoutMs",e[e.SpeechServiceConnection_EndSilenceTimeoutMs=32]="SpeechServiceConnection_EndSilenceTimeoutMs",e[e.Speech_SegmentationSilenceTimeoutMs=33]="Speech_SegmentationSilenceTimeoutMs",e[e.Speech_SegmentationMaximumTimeMs=34]="Speech_SegmentationMaximumTimeMs",e[e.Speech_SegmentationStrategy=35]="Speech_SegmentationStrategy",e[e.SpeechServiceConnection_EnableAudioLogging=36]="SpeechServiceConnection_EnableAudioLogging",e[e.SpeechServiceConnection_LanguageIdMode=37]="SpeechServiceConnection_LanguageIdMode",e[e.SpeechServiceConnection_RecognitionEndpointVersion=38]="SpeechServiceConnection_RecognitionEndpointVersion",e[e.SpeechServiceConnection_SpeakerIdMode=39]="SpeechServiceConnection_SpeakerIdMode",e[e.SpeechServiceResponse_ProfanityOption=40]="SpeechServiceResponse_ProfanityOption",e[e.SpeechServiceResponse_PostProcessingOption=41]="SpeechServiceResponse_PostProcessingOption",e[e.SpeechServiceResponse_RequestWordLevelTimestamps=42]="SpeechServiceResponse_RequestWordLevelTimestamps",e[e.SpeechServiceResponse_StablePartialResultThreshold=43]="SpeechServiceResponse_StablePartialResultThreshold",e[e.SpeechServiceResponse_OutputFormatOption=44]="SpeechServiceResponse_OutputFormatOption",e[e.SpeechServiceResponse_TranslationRequestStablePartialResult=45]="SpeechServiceResponse_TranslationRequestStablePartialResult",e[e.SpeechServiceResponse_RequestWordBoundary=46]="SpeechServiceResponse_RequestWordBoundary",e[e.SpeechServiceResponse_RequestPunctuationBoundary=47]="SpeechServiceResponse_RequestPunctuationBoundary",e[e.SpeechServiceResponse_RequestSentenceBoundary=48]="SpeechServiceResponse_RequestSentenceBoundary",e[e.SpeechServiceResponse_DiarizeIntermediateResults=49]="SpeechServiceResponse_DiarizeIntermediateResults",e[e.Conversation_ApplicationId=50]="Conversation_ApplicationId",e[e.Conversation_DialogType=51]="Conversation_DialogType",e[e.Conversation_Initial_Silence_Timeout=52]="Conversation_Initial_Silence_Timeout",e[e.Conversation_From_Id=53]="Conversation_From_Id",e[e.Conversation_Conversation_Id=54]="Conversation_Conversation_Id",e[e.Conversation_Custom_Voice_Deployment_Ids=55]="Conversation_Custom_Voice_Deployment_Ids",e[e.Conversation_Speech_Activity_Template=56]="Conversation_Speech_Activity_Template",e[e.Conversation_Request_Bot_Status_Messages=57]="Conversation_Request_Bot_Status_Messages",e[e.Conversation_Agent_Connection_Id=58]="Conversation_Agent_Connection_Id",e[e.SpeechServiceConnection_Host=59]="SpeechServiceConnection_Host",e[e.ConversationTranslator_Host=60]="ConversationTranslator_Host",e[e.ConversationTranslator_Name=61]="ConversationTranslator_Name",e[e.ConversationTranslator_CorrelationId=62]="ConversationTranslator_CorrelationId",e[e.ConversationTranslator_Token=63]="ConversationTranslator_Token",e[e.PronunciationAssessment_ReferenceText=64]="PronunciationAssessment_ReferenceText",e[e.PronunciationAssessment_GradingSystem=65]="PronunciationAssessment_GradingSystem",e[e.PronunciationAssessment_Granularity=66]="PronunciationAssessment_Granularity",e[e.PronunciationAssessment_EnableMiscue=67]="PronunciationAssessment_EnableMiscue",e[e.PronunciationAssessment_Json=68]="PronunciationAssessment_Json",e[e.PronunciationAssessment_Params=69]="PronunciationAssessment_Params",e[e.SpeakerRecognition_Api_Version=70]="SpeakerRecognition_Api_Version",e[e.WebWorkerLoadType=71]="WebWorkerLoadType",e[e.TalkingAvatarService_WebRTC_SDP=72]="TalkingAvatarService_WebRTC_SDP"}(t.PropertyId||(t.PropertyId={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Recognizer=void 0;const i=r(2),n=r(4),s=r(64),o=r(79);class a{constructor(e,t,r,i){this.audioConfig=void 0!==e?e:o.AudioConfig.fromDefaultMicrophoneInput(),this.privDisposed=!1,this.privProperties=t.clone(),this.privConnectionFactory=r,this.tokenCredential=i,this.implCommonRecognizerSetup()}close(e,t){s.Contracts.throwIfDisposed(this.privDisposed),(0,n.marshalPromiseToCallbacks)(this.dispose(!0),e,t)}get internalData(){return this.privReco}async dispose(e){this.privDisposed||(this.privDisposed=!0,e&&this.privReco&&(await this.privReco.audioSource.turnOff(),await this.privReco.dispose()))}static get telemetryEnabled(){return i.ServiceRecognizerBase.telemetryDataEnabled}static enableTelemetry(e){i.ServiceRecognizerBase.telemetryDataEnabled=e}implCommonRecognizerSetup(){let e="undefined"!=typeof window?"Browser":"Node",t="unknown",r="unknown";"undefined"!=typeof navigator&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);const n=this.createRecognizerConfig(new i.SpeechServiceConfig(new i.Context(new i.OS(e,t,r))));this.privReco=this.createServiceRecognizer(a.getAuth(this.privProperties,this.tokenCredential),this.privConnectionFactory,this.audioConfig,n)}async recognizeOnceAsyncImpl(e){s.Contracts.throwIfDisposed(this.privDisposed);const t=new n.Deferred;await this.implRecognizerStop(),await this.privReco.recognize(e,t.resolve,t.reject);const r=await t.promise;return await this.implRecognizerStop(),r}async startContinuousRecognitionAsyncImpl(e){s.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop(),await this.privReco.recognize(e,void 0,void 0)}async stopContinuousRecognitionAsyncImpl(){s.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop()}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}static getAuth(e,t){const r=e.getProperty(o.PropertyId.SpeechServiceConnection_Key,void 0);return r&&""!==r?new i.CognitiveSubscriptionKeyAuthentication(r):t?new i.CognitiveTokenAuthentication((async()=>{try{const e=await t.getToken("https://cognitiveservices.azure.com/.default");return e?.token??""}catch(e){throw e}}),(async()=>{try{const e=await t.getToken("https://cognitiveservices.azure.com/.default");return e?.token??""}catch(e){throw e}})):new i.CognitiveTokenAuthentication((()=>{const t=e.getProperty(o.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(t)}),(()=>{const t=e.getProperty(o.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(t)}))}}t.Recognizer=a},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechRecognizer=void 0;const i=r(2),n=r(113),s=r(4),o=r(64),a=r(79);class c extends a.Recognizer{constructor(e,t){const r=e;o.Contracts.throwIfNull(r,"speechConfig"),o.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage),a.PropertyId[a.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new i.SpeechConnectionFactory,e.tokenCredential),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){const i=e;t.properties.mergeTo(i.properties);return new c(e,r)}get endpointId(){return o.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(a.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(a.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){o.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(a.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return o.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return o.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(i.OutputFormatPropertyName,a.OutputFormat[a.OutputFormat.Simple])===a.OutputFormat[a.OutputFormat.Simple]?a.OutputFormat.Simple:a.OutputFormat.Detailed}get properties(){return this.privProperties}recognizeOnceAsync(e,t){(0,s.marshalPromiseToCallbacks)(this.recognizeOnceAsyncImpl(n.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){(0,s.marshalPromiseToCallbacks)(this.startContinuousRecognitionAsyncImpl(n.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){(0,s.marshalPromiseToCallbacks)(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){o.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e){e&&e()}close(e,t){o.Contracts.throwIfDisposed(this.privDisposedRecognizer),(0,s.marshalPromiseToCallbacks)(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new i.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){const s=r;return new i.SpeechServiceRecognizer(e,t,s,n,this)}}t.SpeechRecognizer=c},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RecognitionMode=void 0,function(e){e.Interactive="Interactive",e.Dictation="Dictation",e.Conversation="Conversation",e.None="None"}(t.RecognitionMode||(t.RecognitionMode={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntentRecognizer=void 0;const i=r(2),n=r(113),s=r(4),o=r(64),a=r(79);class c extends a.Recognizer{constructor(e,t){o.Contracts.throwIfNullOrUndefined(e,"speechConfig");const r=e;o.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new i.IntentConnectionFactory),this.privAddedIntents=[],this.privAddedLmIntents={},this.privDisposedIntentRecognizer=!1,this.privProperties=r.properties,o.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage),a.PropertyId[a.PropertyId.SpeechServiceConnection_RecoLanguage])}get speechRecognitionLanguage(){return o.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage)}get authorizationToken(){return this.properties.getProperty(a.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(a.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}recognizeOnceAsync(e,t){if(o.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),0!==Object.keys(this.privAddedLmIntents).length||void 0!==this.privUmbrellaIntent){const e=this.buildSpeechContext();this.privReco.speechContext.getContext().intent=e.Intent,this.privReco.dynamicGrammar.addReferenceGrammar(e.ReferenceGrammars);this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}(0,s.marshalPromiseToCallbacks)(this.recognizeOnceAsyncImpl(n.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){if(0!==Object.keys(this.privAddedLmIntents).length||void 0!==this.privUmbrellaIntent){const e=this.buildSpeechContext();this.privReco.speechContext.getContext().intent=e.Intent,this.privReco.dynamicGrammar.addReferenceGrammar(e.ReferenceGrammars);this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}(0,s.marshalPromiseToCallbacks)(this.startContinuousRecognitionAsyncImpl(n.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){(0,s.marshalPromiseToCallbacks)(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){o.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e,t){if(e)try{e()}catch(e){t&&t(e)}}addIntent(e,t){o.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),o.Contracts.throwIfNullOrWhitespace(t,"intentId"),o.Contracts.throwIfNullOrWhitespace(e,"simplePhrase"),this.privAddedIntents.push([t,e])}addIntentWithLanguageModel(e,t,r){o.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),o.Contracts.throwIfNullOrWhitespace(e,"intentId"),o.Contracts.throwIfNull(t,"model");const n=t;o.Contracts.throwIfNullOrWhitespace(n.appId,"model.appId"),this.privAddedLmIntents[e]=new i.AddedLmIntent(n,r)}addAllIntents(e,t){o.Contracts.throwIfNull(e,"model");const r=e;o.Contracts.throwIfNullOrWhitespace(r.appId,"model.appId"),this.privUmbrellaIntent=new i.AddedLmIntent(r,t)}close(e,t){o.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),(0,s.marshalPromiseToCallbacks)(this.dispose(!0),e,t)}createRecognizerConfig(e){return new i.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){const s=r;return new i.IntentServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedIntentRecognizer||e&&(this.privDisposedIntentRecognizer=!0,await super.dispose(e))}buildSpeechContext(){let e,t,r;const i=[];void 0!==this.privUmbrellaIntent&&(e=this.privUmbrellaIntent.modelImpl.appId,t=this.privUmbrellaIntent.modelImpl.region,r=this.privUmbrellaIntent.modelImpl.subscriptionKey);for(const n of Object.keys(this.privAddedLmIntents)){const s=this.privAddedLmIntents[n];if(void 0===e)e=s.modelImpl.appId;else if(e!==s.modelImpl.appId)throw new Error("Intents must all be from the same LUIS model");if(void 0===t)t=s.modelImpl.region;else if(t!==s.modelImpl.region)throw new Error("Intents must all be from the same LUIS model in a single region");if(void 0===r)r=s.modelImpl.subscriptionKey;else if(r!==s.modelImpl.subscriptionKey)throw new Error("Intents must all use the same subscription key");const o="luis/"+e+"-PRODUCTION#"+n;i.push(o)}return{Intent:{id:e,key:void 0===r?this.privProperties.getProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_Key]):r,provider:"LUIS"},ReferenceGrammars:void 0===this.privUmbrellaIntent?i:["luis/"+e+"-PRODUCTION"]}}}t.IntentRecognizer=c},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceProfileType=void 0,function(e){e[e.TextIndependentIdentification=0]="TextIndependentIdentification",e[e.TextDependentVerification=1]="TextDependentVerification",e[e.TextIndependentVerification=2]="TextIndependentVerification"}(t.VoiceProfileType||(t.VoiceProfileType={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationRecognizer=void 0;const i=r(2),n=r(113),s=r(4),o=r(117),a=r(64),c=r(79);class p extends c.Recognizer{constructor(e,t,r){const n=e;a.Contracts.throwIfNull(n,"speechConfig"),super(t,n.properties,r||new i.TranslationConnectionFactory,e.tokenCredential),this.privDisposedTranslationRecognizer=!1,void 0!==this.properties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)&&a.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationVoice),c.PropertyId[c.PropertyId.SpeechServiceConnection_TranslationVoice]),a.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages),c.PropertyId[c.PropertyId.SpeechServiceConnection_TranslationToLanguages]),a.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(c.PropertyId.SpeechServiceConnection_RecoLanguage),c.PropertyId[c.PropertyId.SpeechServiceConnection_RecoLanguage])}static FromConfig(e,t,r){const n=e;return t.properties.mergeTo(n.properties),t.properties.getProperty(c.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,void 0)===i.AutoDetectSourceLanguagesOpenRangeOptionName&&n.properties.setProperty(c.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),new p(e,r)}get speechRecognitionLanguage(){return a.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(c.PropertyId.SpeechServiceConnection_RecoLanguage)}get targetLanguages(){return a.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",")}get voiceName(){return a.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(c.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(c.PropertyId.SpeechServiceAuthorization_Token,e)}recognizeOnceAsync(e,t){a.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),(0,s.marshalPromiseToCallbacks)(this.recognizeOnceAsyncImpl(n.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){(0,s.marshalPromiseToCallbacks)(this.startContinuousRecognitionAsyncImpl(n.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){(0,s.marshalPromiseToCallbacks)(this.stopContinuousRecognitionAsyncImpl(),e,t)}removeTargetLanguage(e){if(a.Contracts.throwIfNullOrUndefined(e,"language to be removed"),void 0!==this.properties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)){const t=this.properties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),r=t.indexOf(e);r>-1&&(t.splice(r,1),this.properties.setProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")),this.updateLanguages(t))}}addTargetLanguage(e){a.Contracts.throwIfNullOrUndefined(e,"language to be added");let t=[];void 0!==this.properties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)?(t=this.properties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),t.includes(e)||(t.push(e),this.properties.setProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))):(this.properties.setProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages,e),t=[e]),this.updateLanguages(t)}close(e,t){a.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),(0,s.marshalPromiseToCallbacks)(this.dispose(!0),e,t)}onConnection(){}async dispose(e){this.privDisposedTranslationRecognizer||(this.privDisposedTranslationRecognizer=!0,e&&(await this.implRecognizerStop(),await super.dispose(e)))}createRecognizerConfig(e){return new i.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){const s=r;return new i.TranslationServiceRecognizer(e,t,s,n,this)}updateLanguages(e){const t=o.Connection.fromRecognizer(this);t&&(t.setMessageProperty("speech.context","translationcontext",{to:e}),t.sendMessageAsync("event",JSON.stringify({id:"translation",name:"updateLanguage",to:e})))}}t.TranslationRecognizer=p},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Connection=void 0;const i=r(2),n=r(4),s=r(118),o=r(64),a=r(79);class c{static fromRecognizer(e){const t=e.internalData,r=new c;return r.privInternalData=t,r.setupEvents(),r}static fromSynthesizer(e){const t=e.internalData,r=new c;return r.privInternalData=t,r.setupEvents(),r}openConnection(e,t){(0,n.marshalPromiseToCallbacks)(this.privInternalData.connect(),e,t)}closeConnection(e,t){if(this.privInternalData instanceof i.SynthesisAdapterBase)throw new Error("Disconnecting a synthesizer's connection is currently not supported");(0,n.marshalPromiseToCallbacks)(this.privInternalData.disconnect(),e,t)}setMessageProperty(e,t,r){if(o.Contracts.throwIfNullOrWhitespace(t,"propertyName"),this.privInternalData instanceof i.ServiceRecognizerBase){if("speech.context"!==e.toLowerCase())throw new Error("Only speech.context message property sets are currently supported for recognizer");this.privInternalData.speechContext.getContext()[t]=r}else if(this.privInternalData instanceof i.SynthesisAdapterBase){if("synthesis.context"!==e.toLowerCase())throw new Error("Only synthesis.context message property sets are currently supported for synthesizer");this.privInternalData.synthesisContext.setSection(t,r)}}sendMessageAsync(e,t,r,i){(0,n.marshalPromiseToCallbacks)(this.privInternalData.sendNetworkMessage(e,t),r,i)}close(){}setupEvents(){this.privEventListener=this.privInternalData.connectionEvents.attach((e=>{"ConnectionEstablishedEvent"===e.name?this.connected&&this.connected(new a.ConnectionEventArgs(e.connectionId)):"ConnectionClosedEvent"===e.name?this.disconnected&&this.disconnected(new a.ConnectionEventArgs(e.connectionId)):"ConnectionMessageSentEvent"===e.name?this.messageSent&&this.messageSent(new a.ConnectionMessageEventArgs(new s.ConnectionMessageImpl(e.message))):"ConnectionMessageReceivedEvent"===e.name&&this.messageReceived&&this.messageReceived(new a.ConnectionMessageEventArgs(new s.ConnectionMessageImpl(e.message)))})),this.privServiceEventListener=this.privInternalData.serviceEvents.attach((e=>{this.receivedServiceMessage&&this.receivedServiceMessage(new a.ServiceEventArgs(e.jsonString,e.name))}))}}t.Connection=c},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionMessageImpl=t.ConnectionMessage=void 0;const i=r(54),n=r(4),s=r(109),o=r(110);t.ConnectionMessage=class{};t.ConnectionMessageImpl=class{constructor(e){this.privConnectionMessage=e,this.privProperties=new s.PropertyCollection,this.privConnectionMessage.headers[i.HeaderNames.ConnectionId]&&this.privProperties.setProperty(o.PropertyId.Speech_SessionId,this.privConnectionMessage.headers[i.HeaderNames.ConnectionId]),Object.keys(this.privConnectionMessage.headers).forEach((e=>{this.privProperties.setProperty(e,this.privConnectionMessage.headers[e])}))}get path(){return this.privConnectionMessage.headers[Object.keys(this.privConnectionMessage.headers).find((e=>e.toLowerCase()==="path".toLowerCase()))]}get isTextMessage(){return this.privConnectionMessage.messageType===n.MessageType.Text}get isBinaryMessage(){return this.privConnectionMessage.messageType===n.MessageType.Binary}get TextMessage(){return this.privConnectionMessage.textBody}get binaryMessage(){return this.privConnectionMessage.binaryBody}get properties(){return this.privProperties}toString(){return""}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Translations=void 0;const i=r(79);t.Translations=class{constructor(){this.privMap=new i.PropertyCollection}get languages(){return this.privMap.keys}get(e,t){return this.privMap.getProperty(e,t)}set(e,t){this.privMap.setProperty(e,t)}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoMatchReason=void 0,function(e){e[e.NotRecognized=0]="NotRecognized",e[e.InitialSilenceTimeout=1]="InitialSilenceTimeout",e[e.InitialBabbleTimeout=2]="InitialBabbleTimeout"}(t.NoMatchReason||(t.NoMatchReason={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoMatchDetails=void 0;const i=r(2),n=r(79);class s{constructor(e){this.privReason=e}static fromResult(e){const t=i.SimpleSpeechPhrase.fromJSON(e.json,0);let r=n.NoMatchReason.NotRecognized;switch(t.RecognitionStatus){case i.RecognitionStatus.BabbleTimeout:r=n.NoMatchReason.InitialBabbleTimeout;break;case i.RecognitionStatus.InitialSilenceTimeout:r=n.NoMatchReason.InitialSilenceTimeout;break;default:r=n.NoMatchReason.NotRecognized}return new s(r)}get reason(){return this.privReason}}t.NoMatchDetails=s},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationRecognitionCanceledEventArgs=void 0;t.TranslationRecognitionCanceledEventArgs=class{constructor(e,t,r,i,n){this.privCancelReason=t,this.privErrorDetails=r,this.privResult=n,this.privSessionId=e,this.privErrorCode=i}get result(){return this.privResult}get sessionId(){return this.privSessionId}get reason(){return this.privCancelReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntentRecognitionCanceledEventArgs=void 0;const i=r(79);class n extends i.IntentRecognitionEventArgs{constructor(e,t,r,i,n,s){super(i,n,s),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}}t.IntentRecognitionCanceledEventArgs=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CancellationDetailsBase=void 0;t.CancellationDetailsBase=class{constructor(e,t,r){this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get ErrorCode(){return this.privErrorCode}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CancellationDetails=void 0;const i=r(2),n=r(124),s=r(79);class o extends n.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=s.CancellationReason.Error,r=s.CancellationErrorCode.NoError;if(e instanceof s.RecognitionResult&&e.json){const r=i.SimpleSpeechPhrase.fromJSON(e.json,0);t=i.EnumTranslation.implTranslateCancelResult(r.RecognitionStatus)}return e.properties&&(r=s.CancellationErrorCode[e.properties.getProperty(i.CancellationErrorCodePropertyName,s.CancellationErrorCode[s.CancellationErrorCode.NoError])]),new o(t,e.errorDetails||i.EnumTranslation.implTranslateErrorDetails(r),r)}}t.CancellationDetails=o},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CancellationErrorCode=void 0,function(e){e[e.NoError=0]="NoError",e[e.AuthenticationFailure=1]="AuthenticationFailure",e[e.BadRequestParameters=2]="BadRequestParameters",e[e.TooManyRequests=3]="TooManyRequests",e[e.ConnectionFailure=4]="ConnectionFailure",e[e.ServiceTimeout=5]="ServiceTimeout",e[e.ServiceError=6]="ServiceError",e[e.RuntimeError=7]="RuntimeError",e[e.Forbidden=8]="Forbidden"}(t.CancellationErrorCode||(t.CancellationErrorCode={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionEventArgs=void 0;const i=r(79);class n extends i.SessionEventArgs{}t.ConnectionEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceEventArgs=void 0;const i=r(79);class n extends i.SessionEventArgs{constructor(e,t,r){super(r),this.privJsonResult=e,this.privEventName=t}get jsonString(){return this.privJsonResult}get eventName(){return this.privEventName}}t.ServiceEventArgs=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PhraseListGrammar=void 0;class r{constructor(e){this.privGrammerBuilder=e.dynamicGrammar}static fromRecognizer(e){const t=e.internalData;return new r(t)}addPhrase(e){this.privGrammerBuilder.addPhrase(e)}addPhrases(e){this.privGrammerBuilder.addPhrase(e)}clear(){this.privGrammerBuilder.clearPhrases()}}t.PhraseListGrammar=r},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DialogServiceConfigImpl=t.DialogServiceConfig=void 0;const i=r(64),n=r(79);class s{constructor(){}set applicationId(e){}static get DialogTypes(){return{BotFramework:"bot_framework",CustomCommands:"custom_commands"}}}t.DialogServiceConfig=s;t.DialogServiceConfigImpl=class extends s{constructor(){super(),this.privSpeechConfig=new n.SpeechConfigImpl}get properties(){return this.privSpeechConfig.properties}get speechRecognitionLanguage(){return this.privSpeechConfig.speechRecognitionLanguage}set speechRecognitionLanguage(e){i.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechConfig.speechRecognitionLanguage=e}get outputFormat(){return this.privSpeechConfig.outputFormat}set outputFormat(e){this.privSpeechConfig.outputFormat=e}setProperty(e,t){this.privSpeechConfig.setProperty(e,t)}getProperty(e,t){return this.privSpeechConfig.getProperty(e)}setProxy(e,t,r,i){this.setProperty(n.PropertyId.SpeechServiceConnection_ProxyHostName,e),this.setProperty(n.PropertyId.SpeechServiceConnection_ProxyPort,`${t}`),r&&this.setProperty(n.PropertyId.SpeechServiceConnection_ProxyUserName,r),i&&this.setProperty(n.PropertyId.SpeechServiceConnection_ProxyPassword,i)}setServiceProperty(e,t,r){this.privSpeechConfig.setServiceProperty(e,t)}close(){}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BotFrameworkConfig=void 0;const i=r(64),n=r(130),s=r(79);class o extends n.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){i.Contracts.throwIfNullOrWhitespace(e,"subscription"),i.Contracts.throwIfNullOrWhitespace(t,"region");const o=new n.DialogServiceConfigImpl;return o.setProperty(s.PropertyId.Conversation_DialogType,n.DialogServiceConfig.DialogTypes.BotFramework),o.setProperty(s.PropertyId.SpeechServiceConnection_Key,e),o.setProperty(s.PropertyId.SpeechServiceConnection_Region,t),r&&o.setProperty(s.PropertyId.Conversation_ApplicationId,r),o}static fromAuthorizationToken(e,t,r){i.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),i.Contracts.throwIfNullOrWhitespace(t,"region");const o=new n.DialogServiceConfigImpl;return o.setProperty(s.PropertyId.Conversation_DialogType,n.DialogServiceConfig.DialogTypes.BotFramework),o.setProperty(s.PropertyId.SpeechServiceAuthorization_Token,e),o.setProperty(s.PropertyId.SpeechServiceConnection_Region,t),r&&o.setProperty(s.PropertyId.Conversation_ApplicationId,r),o}static fromHost(e,t,r){i.Contracts.throwIfNullOrUndefined(e,"host");const o=e instanceof URL?e:new URL(`wss://${e}.convai.speech.azure.us`);i.Contracts.throwIfNullOrUndefined(o,"resolvedHost");const a=new n.DialogServiceConfigImpl;return a.setProperty(s.PropertyId.Conversation_DialogType,n.DialogServiceConfig.DialogTypes.BotFramework),a.setProperty(s.PropertyId.SpeechServiceConnection_Host,o.toString()),void 0!==t&&a.setProperty(s.PropertyId.SpeechServiceConnection_Key,t),a}static fromEndpoint(e,t){i.Contracts.throwIfNull(e,"endpoint");const r=new n.DialogServiceConfigImpl;return r.setProperty(s.PropertyId.Conversation_DialogType,n.DialogServiceConfig.DialogTypes.BotFramework),r.setProperty(s.PropertyId.SpeechServiceConnection_Endpoint,e.toString()),void 0!==t&&r.setProperty(s.PropertyId.SpeechServiceConnection_Key,t),r}}t.BotFrameworkConfig=o},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CustomCommandsConfig=void 0;const i=r(64),n=r(130),s=r(79);class o extends n.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){i.Contracts.throwIfNullOrWhitespace(e,"applicationId"),i.Contracts.throwIfNullOrWhitespace(t,"subscription"),i.Contracts.throwIfNullOrWhitespace(r,"region");const o=new n.DialogServiceConfigImpl;return o.setProperty(s.PropertyId.Conversation_DialogType,n.DialogServiceConfig.DialogTypes.CustomCommands),o.setProperty(s.PropertyId.Conversation_ApplicationId,e),o.setProperty(s.PropertyId.SpeechServiceConnection_Key,t),o.setProperty(s.PropertyId.SpeechServiceConnection_Region,r),o}static fromAuthorizationToken(e,t,r){i.Contracts.throwIfNullOrWhitespace(e,"applicationId"),i.Contracts.throwIfNullOrWhitespace(t,"authorizationToken"),i.Contracts.throwIfNullOrWhitespace(r,"region");const o=new n.DialogServiceConfigImpl;return o.setProperty(s.PropertyId.Conversation_DialogType,n.DialogServiceConfig.DialogTypes.CustomCommands),o.setProperty(s.PropertyId.Conversation_ApplicationId,e),o.setProperty(s.PropertyId.SpeechServiceAuthorization_Token,t),o.setProperty(s.PropertyId.SpeechServiceConnection_Region,r),o}set applicationId(e){i.Contracts.throwIfNullOrWhitespace(e,"value"),this.setProperty(s.PropertyId.Conversation_ApplicationId,e)}get applicationId(){return this.getProperty(s.PropertyId.Conversation_ApplicationId)}}t.CustomCommandsConfig=o},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DialogServiceConnector=void 0;const i=r(134),n=r(2),s=r(113),o=r(4),a=r(64),c=r(79),p=r(110);class h extends c.Recognizer{constructor(e,t){const r=e;a.Contracts.throwIfNull(e,"dialogConfig"),super(t,r.properties,new i.DialogConnectionFactory),this.isTurnComplete=!0,this.privIsDisposed=!1,this.privProperties=r.properties.clone();const n=this.buildAgentConfig();this.privReco.agentConfig.set(n)}connect(e,t){(0,o.marshalPromiseToCallbacks)(this.privReco.connect(),e,t)}disconnect(e,t){(0,o.marshalPromiseToCallbacks)(this.privReco.disconnect(),e,t)}get authorizationToken(){return this.properties.getProperty(p.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){a.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(p.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get speechActivityTemplate(){return this.properties.getProperty(p.PropertyId.Conversation_Speech_Activity_Template)}set speechActivityTemplate(e){this.properties.setProperty(p.PropertyId.Conversation_Speech_Activity_Template,e)}listenOnceAsync(e,t){if(this.isTurnComplete){a.Contracts.throwIfDisposed(this.privIsDisposed);const r=(async()=>{await this.privReco.connect(),await this.implRecognizerStop(),this.isTurnComplete=!1;const e=new o.Deferred;await this.privReco.recognize(s.RecognitionMode.Conversation,e.resolve,e.reject);const t=await e.promise;return await this.implRecognizerStop(),t})();r.catch((()=>{this.dispose(!0).catch((()=>{}))})),(0,o.marshalPromiseToCallbacks)(r.finally((()=>{this.isTurnComplete=!0})),e,t)}}sendActivityAsync(e,t,r){(0,o.marshalPromiseToCallbacks)(this.privReco.sendMessage(e),t,r)}close(e,t){a.Contracts.throwIfDisposed(this.privIsDisposed),(0,o.marshalPromiseToCallbacks)(this.dispose(!0),e,t)}async dispose(e){this.privIsDisposed||e&&(this.privIsDisposed=!0,await this.implRecognizerStop(),await super.dispose(e))}createRecognizerConfig(e){return new n.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,i){const s=r;return new n.DialogServiceAdapter(e,t,s,i,this)}buildAgentConfig(){return{botInfo:{commType:this.properties.getProperty("Conversation_Communication_Type","Default"),commandsCulture:void 0,connectionId:this.properties.getProperty(p.PropertyId.Conversation_Agent_Connection_Id),conversationId:this.properties.getProperty(p.PropertyId.Conversation_Conversation_Id,void 0),fromId:this.properties.getProperty(p.PropertyId.Conversation_From_Id,void 0),ttsAudioFormat:this.properties.getProperty(p.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)},version:.2}}}t.DialogServiceConnector=h},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DialogConnectionFactory=void 0;const i=r(60),n=r(2),s=r(79),o=r(135),a=r(2),c=r(54),p=r(136);class h extends o.ConnectionFactoryBase{create(e,t,r){const u=e.parameters.getProperty(s.PropertyId.Conversation_ApplicationId,""),d=e.parameters.getProperty(s.PropertyId.Conversation_DialogType),v=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Region),l=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),g=e.parameters.getProperty(s.PropertyId.Conversation_Request_Bot_Status_Messages,"true"),m={};m[c.HeaderNames.ConnectionId]=r,m[p.QueryParameterNames.Format]=e.parameters.getProperty(n.OutputFormatPropertyName,s.OutputFormat[s.OutputFormat.Simple]).toLowerCase(),m[p.QueryParameterNames.Language]=l,m[p.QueryParameterNames.RequestBotStatusMessages]=g,u&&(m[p.QueryParameterNames.BotId]=u,d===s.DialogServiceConfig.DialogTypes.CustomCommands&&(m[c.HeaderNames.CustomCommandsAppId]=u));const f=d===s.DialogServiceConfig.DialogTypes.CustomCommands?"commands/":"",S=d===s.DialogServiceConfig.DialogTypes.CustomCommands?"v1":d===s.DialogServiceConfig.DialogTypes.BotFramework?"v3":"v0",y={};null!=t.token&&""!==t.token&&(y[t.headerName]=t.token);let C=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Endpoint,"");if(!C){const t=o.ConnectionFactoryBase.getHostSuffix(v),r=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Host,`wss://${v}.${h.BaseUrl}${t}`);C=`${r.endsWith("/")?r:r+"/"}${f}${h.ApiKey}/${S}`}this.setCommonUrlParams(e,m,C);const P="true"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false");return Promise.resolve(new i.WebsocketConnection(C,m,y,new a.WebsocketMessageFormatter,i.ProxyInfo.fromRecognizerConfig(e),P,r))}}t.DialogConnectionFactory=h,h.ApiKey="api",h.BaseUrl="convai.speech"},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionFactoryBase=void 0;const i=r(2),n=r(4),s=r(79),o=r(136);t.ConnectionFactoryBase=class{static getHostSuffix(e){if(e){if(e.toLowerCase().startsWith("china"))return".azure.cn";if(e.toLowerCase().startsWith("usgov"))return".azure.us"}return".microsoft.com"}setCommonUrlParams(e,t,r){new Map([[s.PropertyId.Speech_SegmentationSilenceTimeoutMs,o.QueryParameterNames.SegmentationSilenceTimeoutMs],[s.PropertyId.SpeechServiceConnection_EnableAudioLogging,o.QueryParameterNames.EnableAudioLogging],[s.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,o.QueryParameterNames.EndSilenceTimeoutMs],[s.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,o.QueryParameterNames.InitialSilenceTimeoutMs],[s.PropertyId.SpeechServiceResponse_PostProcessingOption,o.QueryParameterNames.Postprocessing],[s.PropertyId.SpeechServiceResponse_ProfanityOption,o.QueryParameterNames.Profanity],[s.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,o.QueryParameterNames.EnableWordLevelTimestamps],[s.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,o.QueryParameterNames.StableIntermediateThreshold]]).forEach(((i,n)=>{this.setUrlParameter(n,i,e,t,r)}));const n=JSON.parse(e.parameters.getProperty(i.ServicePropertiesPropertyName,"{}"));Object.keys(n).forEach((e=>{t[e]=n[e]}))}setUrlParameter(e,t,r,i,n){const s=r.parameters.getProperty(e,void 0);!s||n&&-1!==n.search(t)||(i[t]=s.toLocaleLowerCase())}static async getRedirectUrlFromEndpoint(e){let t;if("undefined"!=typeof window&&void 0!==window.fetch){const r=new URL(e);r.protocol="https:",r.port="443";r.searchParams.append("GenerateRedirectResponse","true");const i=r.toString();n.Events.instance.onEvent(new n.ConnectionRedirectEvent("",i,void 0,"ConnectionFactoryBase: redirectUrl request"));const s=await fetch(i);if(200!==s.status)return e;t=await s.text()}else t=e;n.Events.instance.onEvent(new n.ConnectionRedirectEvent("",t,e,"ConnectionFactoryBase: redirectUrlString"));try{return new URL(t.trim()).toString()}catch(t){return e}}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QueryParameterNames=void 0;class r{}t.QueryParameterNames=r,r.BotId="botid",r.CustomSpeechDeploymentId="cid",r.CustomVoiceDeploymentId="deploymentId",r.EnableAudioLogging="storeAudio",r.EnableLanguageId="lidEnabled",r.EnableWordLevelTimestamps="wordLevelTimestamps",r.EndSilenceTimeoutMs="endSilenceTimeoutMs",r.SegmentationSilenceTimeoutMs="segmentationSilenceTimeoutMs",r.SegmentationMaximumTimeMs="segmentationMaximumTimeMs",r.SegmentationStrategy="segmentationStrategy",r.Format="format",r.InitialSilenceTimeoutMs="initialSilenceTimeoutMs",r.Language="language",r.Profanity="profanity",r.RequestBotStatusMessages="enableBotMessageStatus",r.StableIntermediateThreshold="stableIntermediateThreshold",r.StableTranslation="stableTranslation",r.TestHooks="testhooks",r.Postprocessing="postprocessing",r.CtsMeetingId="meetingId",r.CtsDeviceId="deviceId",r.CtsIsParticipant="isParticipant",r.EnableAvatar="enableTalkingAvatar"},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActivityReceivedEventArgs=void 0;t.ActivityReceivedEventArgs=class{constructor(e,t){this.privActivity=e,this.privAudioStream=t}get activity(){return this.privActivity}get audioStream(){return this.privAudioStream}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TurnStatusReceivedEventArgs=void 0;const i=r(139);t.TurnStatusReceivedEventArgs=class{constructor(e){this.privTurnStatus=i.TurnStatusResponsePayload.fromJSON(e)}get interactionId(){return this.privTurnStatus.interactionId}get conversationId(){return this.privTurnStatus.conversationId}get statusCode(){return this.privTurnStatus.statusCode}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TurnStatusResponsePayload=void 0;class r{constructor(e){this.privMessageStatusResponse=JSON.parse(e)}static fromJSON(e){return new r(e)}get interactionId(){return this.privMessageStatusResponse.interactionId}get conversationId(){return this.privMessageStatusResponse.conversationId}get statusCode(){switch(this.privMessageStatusResponse.statusCode){case"Success":return 200;case"Failed":return 400;case"TimedOut":return 429;default:return this.privMessageStatusResponse.statusCode}}}t.TurnStatusResponsePayload=r},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServicePropertyChannel=void 0,function(e){e[e.UriQueryParameter=0]="UriQueryParameter"}(t.ServicePropertyChannel||(t.ServicePropertyChannel={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProfanityOption=void 0,function(e){e[e.Masked=0]="Masked",e[e.Removed=1]="Removed",e[e.Raw=2]="Raw"}(t.ProfanityOption||(t.ProfanityOption={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseAudioPlayer=void 0;const i=r(26),n=r(79),s=r(67);t.BaseAudioPlayer=class{constructor(e){this.audioContext=null,this.gainNode=null,this.autoUpdateBufferTimer=0,void 0===e&&(e=n.AudioStreamFormat.getDefaultInputFormat()),this.init(e)}playAudioSample(e,t,r){try{this.ensureInitializedContext();const r=this.formatAudioData(e),i=new Float32Array(this.samples.length+r.length);i.set(this.samples,0),i.set(r,this.samples.length),this.samples=i,t&&t()}catch(e){r&&r(e)}}stopAudio(e,t){null!==this.audioContext&&(this.samples=new Float32Array,clearInterval(this.autoUpdateBufferTimer),this.audioContext.close().then((()=>{e&&e()}),(e=>{t&&t(e)})),this.audioContext=null)}init(e){this.audioFormat=e,this.samples=new Float32Array}ensureInitializedContext(){if(null===this.audioContext){this.createAudioContext();const e=200;this.autoUpdateBufferTimer=setInterval((()=>{this.updateAudioBuffer()}),e)}}createAudioContext(){this.audioContext=s.AudioStreamFormatImpl.getAudioContext(),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.gainNode.connect(this.audioContext.destination),this.startTime=this.audioContext.currentTime}formatAudioData(e){switch(this.audioFormat.bitsPerSample){case 8:return this.formatArrayBuffer(new Int8Array(e),128);case 16:return this.formatArrayBuffer(new Int16Array(e),32768);case 32:return this.formatArrayBuffer(new Int32Array(e),2147483648);default:throw new i.InvalidOperationError("Only WAVE_FORMAT_PCM (8/16/32 bps) format supported at this time")}}formatArrayBuffer(e,t){const r=new Float32Array(e.length);for(let i=0;i<e.length;i++)r[i]=e[i]/t;return r}updateAudioBuffer(){if(0===this.samples.length)return;const e=this.audioFormat.channels,t=this.audioContext.createBufferSource(),r=this.samples.length/e,i=this.audioContext.createBuffer(e,r,this.audioFormat.samplesPerSec);for(let t=0;t<e;t++){let r=t;const n=i.getChannelData(t);for(let t=0;t<this.samples.length;t++,r+=e)n[t]=this.samples[r]}this.startTime<this.audioContext.currentTime&&(this.startTime=this.audioContext.currentTime),t.buffer=i,t.connect(this.gainNode),t.start(this.startTime),this.startTime+=i.duration,this.samples=new Float32Array}async playAudio(e){null===this.audioContext&&this.createAudioContext();const t=this.audioContext.createBufferSource(),r=this.audioContext.destination;await this.audioContext.decodeAudioData(e,(e=>{t.buffer=e,t.connect(r),t.start(0)}))}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionMessageEventArgs=void 0;t.ConnectionMessageEventArgs=class{constructor(e){this.privConnectionMessage=e}get message(){return this.privConnectionMessage}toString(){return"Message: "+this.privConnectionMessage.toString()}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceProfile=void 0;t.VoiceProfile=class{constructor(e,t){this.privId=e,this.privProfileType=t}get profileId(){return this.privId}get profileType(){return this.privProfileType}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceProfileEnrollmentCancellationDetails=t.VoiceProfileEnrollmentResult=void 0;const i=r(2),n=r(79);class s{constructor(e,t,r){this.privReason=e,this.privProperties=new n.PropertyCollection,this.privReason!==n.ResultReason.Canceled?t&&(this.privDetails=JSON.parse(t),"enrolling"===this.privDetails.enrollmentStatus.toLowerCase()&&(this.privReason=n.ResultReason.EnrollingVoiceProfile)):(this.privErrorDetails=r,this.privProperties.setProperty(i.CancellationErrorCodePropertyName,n.CancellationErrorCode[n.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get enrollmentsCount(){return this.privDetails.enrollmentsCount}get enrollmentsLength(){return this.privDetails.enrollmentsLength}get properties(){return this.privProperties}get enrollmentResultDetails(){return this.privDetails}get errorDetails(){return this.privErrorDetails}static FromIdentificationProfileList(e){const t=[];for(const r of e.value){const e="enrolling"===r.enrollmentStatus.toLowerCase()?n.ResultReason.EnrollingVoiceProfile:"enrolled"===r.enrollmentStatus.toLowerCase()?n.ResultReason.EnrolledVoiceProfile:n.ResultReason.Canceled,i=new s(e,null,null);i.privDetails=this.getIdentificationDetails(r),t.push(i)}return t}static FromVerificationProfileList(e){const t=[];for(const r of e.value){const e="enrolling"===r.enrollmentStatus.toLowerCase()?n.ResultReason.EnrollingVoiceProfile:"enrolled"===r.enrollmentStatus.toLowerCase()?n.ResultReason.EnrolledVoiceProfile:n.ResultReason.Canceled,i=new s(e,null,null);i.privDetails=this.getVerificationDetails(r),t.push(i)}return t}static getIdentificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount||0,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.identificationProfileId,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}static getVerificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.verificationProfileId,remainingEnrollmentsCount:e.remainingEnrollments||e.remainingEnrollmentsCount,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}}t.VoiceProfileEnrollmentResult=s;class o extends n.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){const t=n.CancellationReason.Error;let r=n.CancellationErrorCode.NoError;return e.properties&&(r=n.CancellationErrorCode[e.properties.getProperty(i.CancellationErrorCodePropertyName,n.CancellationErrorCode[n.CancellationErrorCode.NoError])]),new o(t,e.errorDetails,r)}}t.VoiceProfileEnrollmentCancellationDetails=o},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceProfileCancellationDetails=t.VoiceProfileResult=void 0;const i=r(2),n=r(64),s=r(79);t.VoiceProfileResult=class{constructor(e,t){this.privReason=e,this.privProperties=new s.PropertyCollection,e===s.ResultReason.Canceled&&(n.Contracts.throwIfNullOrUndefined(t,"statusText"),this.privErrorDetails=t,this.privProperties.setProperty(i.CancellationErrorCodePropertyName,s.CancellationErrorCode[s.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get properties(){return this.privProperties}get errorDetails(){return this.privErrorDetails}};class o extends s.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){const t=s.CancellationReason.Error;let r=s.CancellationErrorCode.NoError;return e.properties&&(r=s.CancellationErrorCode[e.properties.getProperty(i.CancellationErrorCodePropertyName,s.CancellationErrorCode[s.CancellationErrorCode.NoError])]),new o(t,e.errorDetails,r)}}t.VoiceProfileCancellationDetails=o},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceProfilePhraseResult=void 0;const i=r(64),n=r(79);class s extends n.VoiceProfileResult{constructor(e,t,r,n){super(e,t),this.privPhrases=[],i.Contracts.throwIfNullOrUndefined(n,"phrase array"),this.privType=r,n&&n[0]&&(this.privPhrases=n)}get phrases(){return this.privPhrases}get type(){return this.privType}}t.VoiceProfilePhraseResult=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceProfileClient=void 0;const i=r(2),n=r(80),s=r(64),o=r(79);class a extends o.Recognizer{constructor(e){s.Contracts.throwIfNullOrUndefined(e,"speechConfig");const t=e;s.Contracts.throwIfNull(t,"speechConfig"),super(n.AudioConfig.fromStreamInput(o.AudioInputStream.createPushStream()),t.properties,new i.VoiceProfileConnectionFactory),this.privProperties=t.properties.clone(),this.privVoiceAdapter=this.privReco,this.privDisposedVoiceAdapter=!1}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(o.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){s.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(o.PropertyId.SpeechServiceAuthorization_Token,e)}async createProfileAsync(e,t){const r=await this.privVoiceAdapter.createProfile(e,t);return new o.VoiceProfile(r[0],e)}async retrieveEnrollmentResultAsync(e){return this.privVoiceAdapter.retrieveEnrollmentResult(e)}async getAllProfilesAsync(e){return this.privVoiceAdapter.getAllProfiles(e)}async getActivationPhrasesAsync(e,t){return this.privVoiceAdapter.getActivationPhrases(e,t)}async enrollProfileAsync(e,t){const r=t;return s.Contracts.throwIfNullOrUndefined(r,"audioConfig"),this.audioConfig=t,this.privVoiceAdapter.SpeakerAudioSource=r,this.privVoiceAdapter.enrollProfile(e)}async deleteProfileAsync(e){return this.privVoiceAdapter.deleteProfile(e)}async resetProfileAsync(e){return this.privVoiceAdapter.resetProfile(e)}async close(){await this.dispose(!0)}createServiceRecognizer(e,t,r,n){const s=r;return new i.VoiceServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedVoiceAdapter||(this.privDisposedVoiceAdapter=!0,e&&await super.dispose(e))}createRecognizerConfig(e){return new i.RecognizerConfig(e,this.properties)}getResult(e,t){return new o.VoiceProfileResult(e.ok?t:o.ResultReason.Canceled,e.statusText)}}t.VoiceProfileClient=a},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakerRecognizer=void 0;const i=r(2),n=r(64),s=r(79);class o extends s.Recognizer{constructor(e,t){n.Contracts.throwIfNullOrUndefined(e,"speechConfig");const r=e;n.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new i.SpeakerRecognitionConnectionFactory),this.privAudioConfigImpl=t,n.Contracts.throwIfNull(this.privAudioConfigImpl,"audioConfig"),this.privDisposedSpeakerRecognizer=!1,this.privProperties=r.properties}get authorizationToken(){return this.properties.getProperty(s.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){n.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(s.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}async recognizeOnceAsync(e){return n.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),this.recognizeSpeakerOnceAsyncImpl(e)}async close(){n.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.dispose(!0)}async recognizeSpeakerOnceAsyncImpl(e){n.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.implRecognizerStop();const t=await this.privReco.recognizeSpeaker(e);return await this.implRecognizerStop(),t}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}createRecognizerConfig(e){return new i.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){const s=r;return new i.SpeakerServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedSpeakerRecognizer||e&&(this.privDisposedSpeakerRecognizer=!0,await super.dispose(e))}}t.SpeakerRecognizer=o},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakerIdentificationModel=void 0;const i=r(64),n=r(79);class s{constructor(e){if(this.privVoiceProfiles=[],this.privProfileIds=[],i.Contracts.throwIfNullOrUndefined(e,"VoiceProfiles"),0===e.length)throw new Error("Empty Voice Profiles array");for(const t of e){if(t.profileType!==n.VoiceProfileType.TextIndependentIdentification)throw new Error("Identification model can only be created from Identification profile: "+t.profileId);this.privVoiceProfiles.push(t),this.privProfileIds.push(t.profileId)}}static fromProfiles(e){return new s(e)}get voiceProfileIds(){return this.privProfileIds.join(",")}get profileIds(){return this.privProfileIds}get scenario(){return"TextIndependentIdentification"}}t.SpeakerIdentificationModel=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakerVerificationModel=void 0;const i=r(64),n=r(79);class s{constructor(e){if(i.Contracts.throwIfNullOrUndefined(e,"VoiceProfile"),e.profileType===n.VoiceProfileType.TextIndependentIdentification)throw new Error("Verification model cannot be created from Identification profile");this.privVoiceProfile=e}static fromProfile(e){return new s(e)}get voiceProfile(){return this.privVoiceProfile}get profileIds(){return[this.voiceProfile.profileId]}get scenario(){return this.voiceProfile.profileType===n.VoiceProfileType.TextDependentVerification?"TextDependentVerification":"TextIndependentVerification"}}t.SpeakerVerificationModel=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoDetectSourceLanguageConfig=void 0;const i=r(2),n=r(64),s=r(79),o=r(153);class a{constructor(){this.privProperties=new s.PropertyCollection,this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart"),this.privLanguageIdMode=o.LanguageIdMode.AtStart}static fromOpenRange(){const e=new a;return e.properties.setProperty(s.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,i.AutoDetectSourceLanguagesOpenRangeOptionName),e.properties.setProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),e}static fromLanguages(e){n.Contracts.throwIfArrayEmptyOrWhitespace(e,"languages");const t=new a;return t.properties.setProperty(s.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e.join()),t}static fromSourceLanguageConfigs(e){if(e.length<1)throw new Error("Expected non-empty SourceLanguageConfig array.");const t=new a,r=[];return e.forEach((e=>{if(r.push(e.language),void 0!==e.endpointId&&""!==e.endpointId){const r=e.language+s.PropertyId.SpeechServiceConnection_EndpointId.toString();t.properties.setProperty(r,e.endpointId)}})),t.properties.setProperty(s.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,r.join()),t}get properties(){return this.privProperties}set mode(e){e===o.LanguageIdMode.Continuous?(this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_LanguageIdMode,"Continuous")):(this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"1"),this.privProperties.setProperty(s.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart")),this.privLanguageIdMode=e}}t.AutoDetectSourceLanguageConfig=a},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LanguageIdMode=void 0,function(e){e[e.AtStart=0]="AtStart",e[e.Continuous=1]="Continuous"}(t.LanguageIdMode||(t.LanguageIdMode={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoDetectSourceLanguageResult=void 0;const i=r(64);class n{constructor(e,t){i.Contracts.throwIfNullOrUndefined(e,"language"),i.Contracts.throwIfNullOrUndefined(t,"languageDetectionConfidence"),this.privLanguage=e,this.privLanguageDetectionConfidence=t}static fromResult(e){return new n(e.language,e.languageDetectionConfidence)}static fromConversationTranscriptionResult(e){return new n(e.language,e.languageDetectionConfidence)}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}}t.AutoDetectSourceLanguageResult=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SourceLanguageConfig=void 0;const i=r(64);class n{constructor(e,t){i.Contracts.throwIfNullOrUndefined(e,"language"),this.privLanguage=e,this.privEndpointId=t}static fromLanguage(e,t){return new n(e,t)}get language(){return this.privLanguage}get endpointId(){return this.privEndpointId}}t.SourceLanguageConfig=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakerRecognitionCancellationDetails=t.SpeakerRecognitionResult=t.SpeakerRecognitionResultType=void 0;const i=r(2),n=r(79);var s;!function(e){e[e.Verify=0]="Verify",e[e.Identify=1]="Identify"}(s=t.SpeakerRecognitionResultType||(t.SpeakerRecognitionResultType={}));t.SpeakerRecognitionResult=class{constructor(e,t=n.ResultReason.RecognizedSpeaker,r=n.CancellationErrorCode.NoError,o=""){this.privProperties=new n.PropertyCollection;const a="TextIndependentIdentification"===e.scenario?s.Identify:s.Verify;this.privReason=t,this.privReason!==n.ResultReason.Canceled?a===s.Identify?(this.privProfileId=e.identificationResult.identifiedProfile.profileId,this.privScore=e.identificationResult.identifiedProfile.score,this.privReason=n.ResultReason.RecognizedSpeakers):(this.privScore=e.verificationResult.score,"accept"!==e.verificationResult.recognitionResult.toLowerCase()&&(this.privReason=n.ResultReason.NoMatch),void 0!==e.verificationResult.profileId&&""!==e.verificationResult.profileId&&(this.privProfileId=e.verificationResult.profileId)):(this.privErrorDetails=o,this.privProperties.setProperty(i.CancellationErrorCodePropertyName,n.CancellationErrorCode[r])),this.privProperties.setProperty(n.PropertyId.SpeechServiceResponse_JsonResult,JSON.stringify(e))}get properties(){return this.privProperties}get reason(){return this.privReason}get profileId(){return this.privProfileId}get errorDetails(){return this.privErrorDetails}get score(){return this.privScore}};class o extends n.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){const t=n.CancellationReason.Error;let r=n.CancellationErrorCode.NoError;return e.properties&&(r=n.CancellationErrorCode[e.properties.getProperty(i.CancellationErrorCodePropertyName,n.CancellationErrorCode[n.CancellationErrorCode.NoError])]),new o(t,e.errorDetails,r)}}t.SpeakerRecognitionCancellationDetails=o},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranscriptionResult=t.MeetingTranscriber=t.MeetingTranscriptionCanceledEventArgs=t.MeetingImpl=t.Meeting=t.ParticipantChangedReason=t.User=t.Participant=t.ConversationTranscriber=t.ConversationTranslator=t.ConversationTranslationResult=t.ConversationTranslationEventArgs=t.ConversationTranslationCanceledEventArgs=t.ConversationParticipantsChangedEventArgs=t.ConversationExpirationEventArgs=t.ConversationCommon=t.ConversationImpl=t.Conversation=void 0;var i=r(158);Object.defineProperty(t,"Conversation",{enumerable:!0,get:function(){return i.Conversation}}),Object.defineProperty(t,"ConversationImpl",{enumerable:!0,get:function(){return i.ConversationImpl}});var n=r(159);Object.defineProperty(t,"ConversationCommon",{enumerable:!0,get:function(){return n.ConversationCommon}});var s=r(160);Object.defineProperty(t,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return s.ConversationExpirationEventArgs}});var o=r(161);Object.defineProperty(t,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return o.ConversationParticipantsChangedEventArgs}});var a=r(162);Object.defineProperty(t,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return a.ConversationTranslationCanceledEventArgs}});var c=r(163);Object.defineProperty(t,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return c.ConversationTranslationEventArgs}});var p=r(164);Object.defineProperty(t,"ConversationTranslationResult",{enumerable:!0,get:function(){return p.ConversationTranslationResult}});var h=r(165);Object.defineProperty(t,"ConversationTranslator",{enumerable:!0,get:function(){return h.ConversationTranslator}});var u=r(168);Object.defineProperty(t,"ConversationTranscriber",{enumerable:!0,get:function(){return u.ConversationTranscriber}});var d=r(169);Object.defineProperty(t,"Participant",{enumerable:!0,get:function(){return d.Participant}}),Object.defineProperty(t,"User",{enumerable:!0,get:function(){return d.User}});var v=r(170);Object.defineProperty(t,"ParticipantChangedReason",{enumerable:!0,get:function(){return v.ParticipantChangedReason}});var l=r(171);Object.defineProperty(t,"Meeting",{enumerable:!0,get:function(){return l.Meeting}}),Object.defineProperty(t,"MeetingImpl",{enumerable:!0,get:function(){return l.MeetingImpl}});var g=r(172);Object.defineProperty(t,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return g.MeetingTranscriptionCanceledEventArgs}});var m=r(173);Object.defineProperty(t,"MeetingTranscriber",{enumerable:!0,get:function(){return m.MeetingTranscriber}});var f=r(174);Object.defineProperty(t,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return f.ConversationTranscriptionResult}})},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationImpl=t.Conversation=void 0;const i=r(2),n=r(4),s=r(64),o=r(79);class a{constructor(){}static createConversationAsync(e,t,r,a){let p,h,u;return s.Contracts.throwIfNullOrUndefined(e,i.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),s.Contracts.throwIfNullOrUndefined(e.region,i.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),e.subscriptionKey||e.getProperty(o.PropertyId[o.PropertyId.SpeechServiceAuthorization_Token])||s.Contracts.throwIfNullOrUndefined(e.subscriptionKey,i.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key")),"string"==typeof t?(p=new c(e,t),(0,n.marshalPromiseToCallbacks)((async()=>{})(),r,a)):(p=new c(e),h=t,u=r,p.createConversationAsync((()=>{h&&h()}),(e=>{u&&u(e)}))),p}}t.Conversation=a;class c extends a{constructor(e,t){super(),this.privErrors=i.ConversationConnectionConfig.restErrors,this.onConnected=e=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,e)}catch(e){}},this.onDisconnected=e=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,e)}catch(e){}finally{this.close(!1)}},this.onCanceled=(e,t)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,t)}catch(t){}},this.onParticipantUpdateCommandReceived=(e,t)=>{try{const e=this.privParticipants.getParticipant(t.id);if(void 0!==e){switch(t.key){case i.ConversationTranslatorCommandTypes.changeNickname:e.displayName=t.value;break;case i.ConversationTranslatorCommandTypes.setUseTTS:e.isUsingTts=t.value;break;case i.ConversationTranslatorCommandTypes.setProfanityFiltering:e.profanity=t.value;break;case i.ConversationTranslatorCommandTypes.setMute:e.isMuted=t.value;break;case i.ConversationTranslatorCommandTypes.setTranslateToLanguages:e.translateToLanguages=t.value}this.privParticipants.addOrUpdateParticipant(e),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.Updated,[this.toParticipant(e)],t.sessionId))}}catch(t){}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(e,t)=>{try{this.privParticipants.participants.forEach((e=>e.isMuted=!e.isHost&&t.isMuted)),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.Updated,this.toParticipants(!1),t.sessionId))}catch(t){}},this.onParticipantJoinCommandReceived=(e,t)=>{try{const e=this.privParticipants.addOrUpdateParticipant(t.participant);void 0!==e&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.JoinedConversation,[this.toParticipant(e)],t.sessionId))}catch(t){}},this.onParticipantLeaveCommandReceived=(e,t)=>{try{const e=this.privParticipants.getParticipant(t.participant.id);void 0!==e&&(this.privParticipants.deleteParticipant(t.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.LeftConversation,[this.toParticipant(e)],t.sessionId)))}catch(t){}},this.onTranslationReceived=(e,t)=>{try{switch(t.command){case i.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new o.ConversationTranslationEventArgs(t.payload,void 0,t.sessionId));break;case i.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new o.ConversationTranslationEventArgs(t.payload,void 0,t.sessionId));break;case i.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new o.ConversationTranslationEventArgs(t.payload,void 0,t.sessionId))}}catch(t){}},this.onParticipantsListReceived=(e,t)=>{try{if(void 0!==t.sessionToken&&null!==t.sessionToken&&(this.privRoom.token=t.sessionToken),this.privParticipants.participants=[...t.participants],void 0!==this.privParticipants.me&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),t.sessionId)),this.me.isHost){const e=this.privConversationTranslator?.properties.getProperty(o.PropertyId.ConversationTranslator_Name);void 0!==e&&e.length>0&&e!==this.me.displayName&&this.changeNicknameAsync(e)}}catch(t){}},this.onConversationExpiration=(e,t)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,t)}catch(t){}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new o.PropertyCollection,this.privManager=new i.ConversationManager;if(e.getProperty(o.PropertyId[o.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(o.PropertyId[o.PropertyId.SpeechServiceConnection_RecoLanguage],i.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(o.PropertyId[o.PropertyId.SpeechServiceConnection_RecoLanguage]),t)this.privConversationId=t;else{0===e.targetLanguages.length&&e.addTargetLanguage(this.privLanguage);e.getProperty(o.PropertyId[o.PropertyId.SpeechServiceResponse_ProfanityOption])||e.setProfanity(o.ProfanityOption.Masked);let t=e.getProperty(o.PropertyId[o.PropertyId.ConversationTranslator_Name]);null==t&&(t="Host"),s.Contracts.throwIfNullOrTooLong(t,"nickname",50),s.Contracts.throwIfNullOrTooShort(t,"nickname",2),e.setProperty(o.PropertyId[o.PropertyId.ConversationTranslator_Name],t)}this.privConfig=e;const r=e;s.Contracts.throwIfNull(r,"speechConfig"),this.privProperties=r.properties.clone(),this.privIsConnected=!1,this.privParticipants=new i.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get conversationId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return!this.privParticipants.me?.isHost&&this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get conversationInfo(){const e=this.conversationId,t=this.participants.map((e=>({id:e.id,preferredLanguage:e.preferredLanguage,voice:e.voice}))),r={};for(const e of i.ConversationConnectionConfig.transcriptionEventKeys){const t=this.properties.getProperty(e,"");""!==t&&(r[e]=t)}return{id:e,participants:t,conversationProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){s.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}set conversationTranslator(e){this.privConversationTranslator=e}onToken(e){this.privConversationTranslator.onToken(e)}createConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,(r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}startConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer=i.ConversationRecognizerFactory.fromConfig(this,this.privConfig),this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.disconnected=this.onDisconnected,this.privConversationRecognizer.canceled=this.onCanceled,this.privConversationRecognizer.participantUpdateCommandReceived=this.onParticipantUpdateCommandReceived,this.privConversationRecognizer.lockRoomCommandReceived=this.onLockRoomCommandReceived,this.privConversationRecognizer.muteAllCommandReceived=this.onMuteAllCommandReceived,this.privConversationRecognizer.participantJoinCommandReceived=this.onParticipantJoinCommandReceived,this.privConversationRecognizer.participantLeaveCommandReceived=this.onParticipantLeaveCommandReceived,this.privConversationRecognizer.translationReceived=this.onTranslationReceived,this.privConversationRecognizer.participantsListReceived=this.onParticipantsListReceived,this.privConversationRecognizer.conversationExpiration=this.onConversationExpiration,this.privConversationRecognizer.connect(this.privRoom.token,(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}addParticipantAsync(e,t,r){s.Contracts.throwIfNullOrUndefined(e,"Participant"),(0,n.marshalPromiseToCallbacks)(this.addParticipantImplAsync(e),t,r)}joinConversationAsync(e,t,r,i,n){try{s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),s.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),s.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,(e=>{s.Contracts.throwIfNullOrUndefined(e,this.privErrors.permissionDeniedConnect),this.privRoom=e,this.privConfig.authorizationToken=e.cognitiveSpeechAuthToken,i&&i(e.cognitiveSpeechAuthToken)}),(e=>{this.handleError(e,n)}))}catch(e){this.handleError(e,n)}}deleteConversationAsync(e,t){(0,n.marshalPromiseToCallbacks)(this.deleteConversationImplAsync(),e,t)}async deleteConversationImplAsync(){s.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),s.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endConversationAsync(e,t){(0,n.marshalPromiseToCallbacks)(this.endConversationImplAsync(),e,t)}endConversationImplAsync(){return this.close(!0)}lockConversationAsync(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}muteAllParticipantsAsync(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}muteParticipantAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.me.isHost||this.me.id===e||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r);-1===this.privParticipants.getParticipantIndex(e)&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}removeParticipantAsync(e,t,r){try{if(s.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))(0,n.marshalPromiseToCallbacks)(this.removeParticipantImplAsync(e),t,r);else{s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let i="";if("string"==typeof e)i=e;else if(e.hasOwnProperty("id")){i=e.id}else if(e.hasOwnProperty("userId")){i=e.userId}s.Contracts.throwIfNullOrWhitespace(i,this.privErrors.invalidArgs.replace("{arg}","userId"));-1===this.participants.findIndex((e=>e.id===i))&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(i),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}}catch(e){this.handleError(e,r)}}unlockConversationAsync(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}unmuteAllParticipantsAsync(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}unmuteParticipantAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.me.isHost||this.me.id===e||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r);-1===this.privParticipants.getParticipantIndex(e)&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}sendTextMessageAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}setTranslatedLanguagesAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}changeNicknameAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),this.privConfig=void 0,this.privLanguage=void 0,this.privProperties=void 0,this.privRoom=void 0,this.privToken=void 0,this.privManager=void 0,this.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.conversation=this}getKeepAlive(){const e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(void 0!==this.privParticipants.addOrUpdateParticipant(e)&&this.privTranscriberRecognizer){const t=this.conversationInfo;return t.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(t,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);const t=this.conversationInfo;return t.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await(this.privConversationRecognizer?.close()),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(e){throw e}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(e){t&&t(e)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){const r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){const t=this.privParticipants.participants.map((e=>this.toParticipant(e)));return e?t:t.filter((e=>!1===e.isHost))}toParticipant(e){return new o.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(e,"nickname"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),s.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:i.ConversationTranslatorMessageTypes.instantMessage})}}t.ConversationImpl=c},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationCommon=void 0;t.ConversationCommon=class{constructor(e){this.privAudioConfig=e}handleCallback(e,t){if(e){try{e()}catch(e){t&&t(e)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){const r=e;t(r.name+": "+r.message)}else t(e)}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationExpirationEventArgs=void 0;const i=r(79);class n extends i.SessionEventArgs{constructor(e,t){super(t),this.privExpirationTime=e}get expirationTime(){return this.privExpirationTime}}t.ConversationExpirationEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationParticipantsChangedEventArgs=void 0;const i=r(79);class n extends i.SessionEventArgs{constructor(e,t,r){super(r),this.privReason=e,this.privParticipant=t}get reason(){return this.privReason}get participants(){return this.privParticipant}}t.ConversationParticipantsChangedEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranslationCanceledEventArgs=void 0;const i=r(101);class n extends i.CancellationEventArgsBase{}t.ConversationTranslationCanceledEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranslationEventArgs=void 0;const i=r(79);class n extends i.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}}t.ConversationTranslationEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranslationResult=void 0;const i=r(104);class n extends i.TranslationRecognitionResult{constructor(e,t,r,i,n,s,o,a,c,p,h){super(t,i,n,s,o,a,void 0,void 0,c,p,h),this.privId=e,this.privOrigLang=r}get participantId(){return this.privId}get originalLang(){return this.privOrigLang}}t.ConversationTranslationResult=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranslator=t.SpeechState=void 0;const i=r(2),n=r(166),s=r(4),o=r(64),a=r(79),c=r(158),p=r(157);var h;!function(e){e[e.Inactive=0]="Inactive",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected"}(h=t.SpeechState||(t.SpeechState={}));class u extends a.TranslationRecognizer{constructor(e,t,r,i){super(e,t,new n.ConversationTranslatorConnectionFactory(i)),this.privSpeechState=h.Inactive,r&&(this.privTranslator=r,this.sessionStarted=()=>{this.privSpeechState=h.Connected},this.sessionStopped=()=>{this.privSpeechState=h.Inactive},this.recognizing=(e,t)=>{this.privTranslator.recognizing&&this.privTranslator.recognizing(this.privTranslator,t)},this.recognized=async(e,t)=>{t.result?.errorDetails?(await this.cancelSpeech(),this.fireCancelEvent(t.result.errorDetails)):this.privTranslator.recognized&&this.privTranslator.recognized(this.privTranslator,t)},this.canceled=async()=>{if(this.privSpeechState!==h.Inactive)try{await this.cancelSpeech()}catch(e){this.privSpeechState=h.Inactive}})}get state(){return this.privSpeechState}set state(e){this.privSpeechState=e}set authentication(e){this.privReco.authentication=e}onConnection(){this.privSpeechState=h.Connected}async onCancelSpeech(){this.privSpeechState=h.Inactive,await this.cancelSpeech()}fireCancelEvent(e){try{if(this.privTranslator.canceled){const t=new p.ConversationTranslationCanceledEventArgs(a.CancellationReason.Error,e,a.CancellationErrorCode.RuntimeError);this.privTranslator.canceled(this.privTranslator,t)}}catch(e){}}async cancelSpeech(){try{this.stopContinuousRecognitionAsync(),await(this.privReco?.disconnect()),this.privSpeechState=h.Inactive}catch(e){}}}class d extends p.ConversationCommon{constructor(e){super(e),this.privErrors=i.ConversationConnectionConfig.restErrors,this.privIsDisposed=!1,this.privIsSpeaking=!1,this.privPlaceholderKey="abcdefghijklmnopqrstuvwxyz012345",this.privPlaceholderRegion="westus",this.privProperties=new a.PropertyCollection}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get participants(){return this.privConversation?.participants}get canSpeak(){return!(!this.privConversation.isConnected||!this.privCTRecognizer)&&(!this.privIsSpeaking&&this.privCTRecognizer.state!==h.Connected&&this.privCTRecognizer.state!==h.Connecting&&!this.privConversation.isMutedByHost)}onToken(e){this.privCTRecognizer.authentication=e}setServiceProperty(e,t){const r=JSON.parse(this.privProperties.getProperty(i.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(i.ServicePropertiesPropertyName,JSON.stringify(r))}joinConversationAsync(e,t,r,n,s){try{if("string"==typeof e){o.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),o.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privConversation&&this.handleError(new Error(this.privErrors.permissionDeniedStart),s);let p=r;null!=p&&""!==p||(p=i.ConversationConnectionConfig.defaultLanguageCode),this.privSpeechTranslationConfig=a.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey,this.privPlaceholderRegion),this.privSpeechTranslationConfig.setProfanity(a.ProfanityOption.Masked),this.privSpeechTranslationConfig.addTargetLanguage(p),this.privSpeechTranslationConfig.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_RecoLanguage],p),this.privSpeechTranslationConfig.setProperty(a.PropertyId[a.PropertyId.ConversationTranslator_Name],t);const h=[a.PropertyId.SpeechServiceConnection_Host,a.PropertyId.ConversationTranslator_Host,a.PropertyId.SpeechServiceConnection_Endpoint,a.PropertyId.SpeechServiceConnection_ProxyHostName,a.PropertyId.SpeechServiceConnection_ProxyPassword,a.PropertyId.SpeechServiceConnection_ProxyPort,a.PropertyId.SpeechServiceConnection_ProxyUserName,"ConversationTranslator_MultiChannelAudio","ConversationTranslator_Region"];for(const e of h){const t=this.privProperties.getProperty(e);if(t){const r="string"==typeof e?e:a.PropertyId[e];this.privSpeechTranslationConfig.setProperty(r,t)}}const u=JSON.parse(this.privProperties.getProperty(i.ServicePropertiesPropertyName,"{}"));for(const e of Object.keys(u))this.privSpeechTranslationConfig.setServiceProperty(e,u[e],a.ServicePropertyChannel.UriQueryParameter);this.privConversation=new c.ConversationImpl(this.privSpeechTranslationConfig),this.privConversation.conversationTranslator=this,this.privConversation.joinConversationAsync(e,t,p,(e=>{e||this.handleError(new Error(this.privErrors.permissionDeniedConnect),s),this.privSpeechTranslationConfig.authorizationToken=e,this.privConversation.room.isHost=!1,this.privConversation.startConversationAsync((()=>{this.handleCallback(n,s)}),(e=>{this.handleError(e,s)}))}),(e=>{this.handleError(e,s)}))}else"object"==typeof e?(o.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),o.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privProperties.setProperty(a.PropertyId.ConversationTranslator_Name,t),this.privConversation=e,this.privConversation.conversationTranslator=this,this.privConversation.room.isHost=!0,o.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedConnect),o.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privSpeechTranslationConfig=e.config,this.handleCallback(r,n)):this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","invalid conversation type")),n)}catch(e){this.handleError(e,"string"==typeof r?s:n)}}leaveConversationAsync(e,t){(0,s.marshalPromiseToCallbacks)((async()=>{await this.cancelSpeech(),await this.privConversation.endConversationImplAsync(),await this.privConversation.deleteConversationImplAsync(),this.dispose()})(),e,t)}sendTextMessageAsync(e,t,r){try{o.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),o.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}",e)),this.privConversation.sendTextMessageAsync(e,t,r)}catch(e){this.handleError(e,r)}}startTranscribingAsync(e,t){(0,s.marshalPromiseToCallbacks)((async()=>{try{o.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),o.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),void 0===this.privCTRecognizer&&await this.connectTranslatorRecognizer(),o.Contracts.throwIfNullOrUndefined(this.privCTRecognizer,this.privErrors.permissionDeniedSend),this.canSpeak||this.handleError(new Error(this.privErrors.permissionDeniedSend),t),await this.startContinuousRecognition(),this.privIsSpeaking=!0}catch(e){throw this.privIsSpeaking=!1,await this.cancelSpeech(),e}})(),e,t)}stopTranscribingAsync(e,t){(0,s.marshalPromiseToCallbacks)((async()=>{try{if(!this.privIsSpeaking)return void await this.cancelSpeech();this.privIsSpeaking=!1,await new Promise(((e,t)=>{this.privCTRecognizer.stopContinuousRecognitionAsync(e,t)}))}catch(e){await this.cancelSpeech()}})(),e,t)}isDisposed(){return this.privIsDisposed}dispose(e,t,r){(0,s.marshalPromiseToCallbacks)((async()=>{this.isDisposed&&!this.privIsSpeaking||(await this.cancelSpeech(),this.privIsDisposed=!0,this.privSpeechTranslationConfig.close(),this.privSpeechRecognitionLanguage=void 0,this.privProperties=void 0,this.privAudioConfig=void 0,this.privSpeechTranslationConfig=void 0,this.privConversation.dispose(),this.privConversation=void 0)})(),t,r)}async cancelSpeech(){try{this.privIsSpeaking=!1,await(this.privCTRecognizer?.onCancelSpeech()),this.privCTRecognizer=void 0}catch(e){}}async connectTranslatorRecognizer(){try{void 0===this.privAudioConfig&&(this.privAudioConfig=a.AudioConfig.fromDefaultMicrophoneInput()),this.privSpeechTranslationConfig.getProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_Key])===this.privPlaceholderKey&&this.privSpeechTranslationConfig.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_Key],"");const e=()=>this.privConversation;this.privCTRecognizer=new u(this.privSpeechTranslationConfig,this.privAudioConfig,this,e)}catch(e){throw await this.cancelSpeech(),e}}startContinuousRecognition(){return new Promise(((e,t)=>{this.privCTRecognizer.startContinuousRecognitionAsync(e,t)}))}}t.ConversationTranslator=d},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranslatorConnectionFactory=void 0;const i=r(60),n=r(167),s=r(64),o=r(79),a=r(54),c=r(136),p=r(135),h=r(2);class u extends p.ConnectionFactoryBase{constructor(e){super(),s.Contracts.throwIfNullOrUndefined(e,"convGetter"),this.privConvGetter=e}create(e,t,r){const s="TRUE"===e.parameters.getProperty("ConversationTranslator_MultiChannelAudio","").toUpperCase(),d=this.privConvGetter().room,v=d.cognitiveSpeechRegion||e.parameters.getProperty(o.PropertyId.SpeechServiceConnection_Region,""),l={hostSuffix:p.ConnectionFactoryBase.getHostSuffix(v),path:u.CTS_VIRT_MIC_PATH,region:encodeURIComponent(v)};l[c.QueryParameterNames.Language]=encodeURIComponent(e.parameters.getProperty(o.PropertyId.SpeechServiceConnection_RecoLanguage,"")),l[c.QueryParameterNames.CtsMeetingId]=encodeURIComponent(d.roomId),l[c.QueryParameterNames.CtsDeviceId]=encodeURIComponent(d.participantId),l[c.QueryParameterNames.CtsIsParticipant]=d.isHost?"":"&"+c.QueryParameterNames.CtsIsParticipant;let g="";const m={},f={};if(s){if(g=e.parameters.getProperty(o.PropertyId.SpeechServiceConnection_Endpoint),!g){g="wss://"+e.parameters.getProperty(o.PropertyId.SpeechServiceConnection_Host,"transcribe.{region}.cts.speech{hostSuffix}")+"{path}"}g=n.StringUtils.formatString(g,l);const t=new URL(g);t.searchParams.forEach(((e,t)=>{m[t]=e}));(new h.TranscriberConnectionFactory).setQueryParams(m,e,g),m[c.QueryParameterNames.CtsMeetingId]=l[c.QueryParameterNames.CtsMeetingId],m[c.QueryParameterNames.CtsDeviceId]=l[c.QueryParameterNames.CtsDeviceId],d.isHost||(m[c.QueryParameterNames.CtsIsParticipant]=""),c.QueryParameterNames.Format in m||(m[c.QueryParameterNames.Format]="simple"),t.searchParams.forEach(((e,r)=>{t.searchParams.set(r,m[r]),delete m[r]})),g=t.toString()}else{const t=new h.TranslationConnectionFactory;g=t.getEndpointUrl(e,!0),g=n.StringUtils.formatString(g,l),t.setQueryParams(m,e,g)}f[a.HeaderNames.ConnectionId]=r,f[i.RestConfigBase.configParams.token]=d.token,t.token&&(f[t.headerName]=t.token);const S="TRUE"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","").toUpperCase();return Promise.resolve(new i.WebsocketConnection(g,m,f,new h.WebsocketMessageFormatter,i.ProxyInfo.fromRecognizerConfig(e),S,r))}}t.ConversationTranslatorConnectionFactory=u,u.CTS_VIRT_MIC_PATH="/speech/recognition/dynamicaudio"},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringUtils=void 0;t.StringUtils=class{static formatString(e,t){if(!e)return"";if(!t)return e;let r="",i="";const n=e=>{r+=e},s=e=>{i+=e};let o=n;for(let a=0;a<e.length;a++){const c=e[a],p=a+1<e.length?e[a+1]:"";switch(c){case"{":"{"===p?(o("{"),a++):o=s;break;case"}":"}"===p?(o("}"),a++):(t.hasOwnProperty(i)&&(r+=t[i]),o=n,i="");break;default:o(c)}}return r}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranscriber=void 0;const i=r(2),n=r(113),s=r(4),o=r(64),a=r(79);class c extends a.Recognizer{constructor(e,t){const r=e;o.Contracts.throwIfNull(r,"speechConfig"),o.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage),a.PropertyId[a.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new i.ConversationTranscriberConnectionFactory,e.tokenCredential),this.privProperties.setProperty(a.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){const i=e;t.properties.mergeTo(i.properties);return new c(e,r)}get endpointId(){return o.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(a.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(a.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){o.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(a.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return o.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return o.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(i.OutputFormatPropertyName,a.OutputFormat[a.OutputFormat.Simple])===a.OutputFormat[a.OutputFormat.Simple]?a.OutputFormat.Simple:a.OutputFormat.Detailed}get properties(){return this.privProperties}startTranscribingAsync(e,t){(0,s.marshalPromiseToCallbacks)(this.startContinuousRecognitionAsyncImpl(n.RecognitionMode.Conversation),e,t)}stopTranscribingAsync(e,t){(0,s.marshalPromiseToCallbacks)(this.stopContinuousRecognitionAsyncImpl(),e,t)}close(e,t){o.Contracts.throwIfDisposed(this.privDisposedRecognizer),(0,s.marshalPromiseToCallbacks)(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new i.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){const s=r;return n.isSpeakerDiarizationEnabled=!0,new i.ConversationTranscriptionServiceRecognizer(e,t,s,n,this)}}t.ConversationTranscriber=c},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Participant=t.User=void 0;const i=r(79);t.User=class{constructor(e){this.privUserId=e}get userId(){return this.privUserId}};class n{constructor(e,t,r,n,s,o,a,c){this.privId=e,this.privAvatar=t,this.privDisplayName=r,this.privIsHost=n,this.privIsMuted=s,this.privIsUsingTts=o,this.privPreferredLanguage=a,this.privVoice=c,this.privProperties=new i.PropertyCollection}get avatar(){return this.privAvatar}get displayName(){return this.privDisplayName}get id(){return this.privId}get preferredLanguage(){return this.privPreferredLanguage}get isHost(){return this.privIsHost}get isMuted(){return this.privIsMuted}get isUsingTts(){return this.privIsUsingTts}get voice(){return this.privVoice}get properties(){return this.privProperties}static From(e,t,r){return new n(e,"",e,!1,!1,!1,t,r)}}t.Participant=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParticipantChangedReason=void 0,function(e){e[e.JoinedConversation=0]="JoinedConversation",e[e.LeftConversation=1]="LeftConversation",e[e.Updated=2]="Updated"}(t.ParticipantChangedReason||(t.ParticipantChangedReason={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeetingImpl=t.Meeting=void 0;const i=r(2),n=r(4),s=r(64),o=r(79);class a{constructor(){}static createMeetingAsync(e,t,r,a){if(s.Contracts.throwIfNullOrUndefined(e,i.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),s.Contracts.throwIfNullOrUndefined(e.region,i.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),s.Contracts.throwIfNull(t,"meetingId"),0===t.length)throw new Error("meetingId cannot be empty");e.subscriptionKey||e.getProperty(o.PropertyId[o.PropertyId.SpeechServiceAuthorization_Token])||s.Contracts.throwIfNullOrUndefined(e.subscriptionKey,i.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));const p=new c(e,t);return(0,n.marshalPromiseToCallbacks)((async()=>{})(),r,a),p}}t.Meeting=a;class c extends a{constructor(e,t){super(),this.privErrors=i.ConversationConnectionConfig.restErrors,this.onConnected=e=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,e)}catch(e){}},this.onDisconnected=e=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,e)}catch(e){}finally{this.close(!1)}},this.onCanceled=(e,t)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,t)}catch(t){}},this.onParticipantUpdateCommandReceived=(e,t)=>{try{const e=this.privParticipants.getParticipant(t.id);if(void 0!==e){switch(t.key){case i.ConversationTranslatorCommandTypes.changeNickname:e.displayName=t.value;break;case i.ConversationTranslatorCommandTypes.setUseTTS:e.isUsingTts=t.value;break;case i.ConversationTranslatorCommandTypes.setProfanityFiltering:e.profanity=t.value;break;case i.ConversationTranslatorCommandTypes.setMute:e.isMuted=t.value;break;case i.ConversationTranslatorCommandTypes.setTranslateToLanguages:e.translateToLanguages=t.value}this.privParticipants.addOrUpdateParticipant(e),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.Updated,[this.toParticipant(e)],t.sessionId))}}catch(t){}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(e,t)=>{try{this.privParticipants.participants.forEach((e=>e.isMuted=!e.isHost&&t.isMuted)),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.Updated,this.toParticipants(!1),t.sessionId))}catch(t){}},this.onParticipantJoinCommandReceived=(e,t)=>{try{const e=this.privParticipants.addOrUpdateParticipant(t.participant);void 0!==e&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.JoinedConversation,[this.toParticipant(e)],t.sessionId))}catch(t){}},this.onParticipantLeaveCommandReceived=(e,t)=>{try{const e=this.privParticipants.getParticipant(t.participant.id);void 0!==e&&(this.privParticipants.deleteParticipant(t.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.LeftConversation,[this.toParticipant(e)],t.sessionId)))}catch(t){}},this.onTranslationReceived=(e,t)=>{try{switch(t.command){case i.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new o.ConversationTranslationEventArgs(t.payload,void 0,t.sessionId));break;case i.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new o.ConversationTranslationEventArgs(t.payload,void 0,t.sessionId));break;case i.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new o.ConversationTranslationEventArgs(t.payload,void 0,t.sessionId))}}catch(t){}},this.onParticipantsListReceived=(e,t)=>{try{if(void 0!==t.sessionToken&&null!==t.sessionToken&&(this.privRoom.token=t.sessionToken),this.privParticipants.participants=[...t.participants],void 0!==this.privParticipants.me&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new o.ConversationParticipantsChangedEventArgs(o.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),t.sessionId)),this.me.isHost){const e=this.privConversationTranslator?.properties.getProperty(o.PropertyId.ConversationTranslator_Name);void 0!==e&&e.length>0&&e!==this.me.displayName&&this.changeNicknameAsync(e)}}catch(t){}},this.onConversationExpiration=(e,t)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,t)}catch(t){}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new o.PropertyCollection,this.privManager=new i.ConversationManager;e.getProperty(o.PropertyId[o.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(o.PropertyId[o.PropertyId.SpeechServiceConnection_RecoLanguage],i.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(o.PropertyId[o.PropertyId.SpeechServiceConnection_RecoLanguage]),this.privConversationId=t,this.privConfig=e;const r=e;s.Contracts.throwIfNull(r,"speechConfig"),this.privProperties=r.properties.clone(),this.privIsConnected=!1,this.privParticipants=new i.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get meetingId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return!this.privParticipants.me?.isHost&&this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get meetingInfo(){const e=this.meetingId,t=this.participants.map((e=>({id:e.id,preferredLanguage:e.preferredLanguage,voice:e.voice}))),r={};for(const e of i.ConversationConnectionConfig.transcriptionEventKeys){const t=this.properties.getProperty(e,"");""!==t&&(r[e]=t)}return{id:e,participants:t,meetingProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){s.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}createMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,(r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}startMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.disconnected=this.onDisconnected,this.privConversationRecognizer.canceled=this.onCanceled,this.privConversationRecognizer.participantUpdateCommandReceived=this.onParticipantUpdateCommandReceived,this.privConversationRecognizer.lockRoomCommandReceived=this.onLockRoomCommandReceived,this.privConversationRecognizer.muteAllCommandReceived=this.onMuteAllCommandReceived,this.privConversationRecognizer.participantJoinCommandReceived=this.onParticipantJoinCommandReceived,this.privConversationRecognizer.participantLeaveCommandReceived=this.onParticipantLeaveCommandReceived,this.privConversationRecognizer.translationReceived=this.onTranslationReceived,this.privConversationRecognizer.participantsListReceived=this.onParticipantsListReceived,this.privConversationRecognizer.conversationExpiration=this.onConversationExpiration,this.privConversationRecognizer.connect(this.privRoom.token,(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}addParticipantAsync(e,t,r){s.Contracts.throwIfNullOrUndefined(e,"Participant"),(0,n.marshalPromiseToCallbacks)(this.addParticipantImplAsync(e),t,r)}joinMeetingAsync(e,t,r,i,n){try{s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),s.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),s.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,(e=>{s.Contracts.throwIfNullOrUndefined(e,this.privErrors.permissionDeniedConnect),this.privRoom=e,this.privConfig.authorizationToken=e.cognitiveSpeechAuthToken,i&&i(e.cognitiveSpeechAuthToken)}),(e=>{this.handleError(e,n)}))}catch(e){this.handleError(e,n)}}deleteMeetingAsync(e,t){(0,n.marshalPromiseToCallbacks)(this.deleteMeetingImplAsync(),e,t)}async deleteMeetingImplAsync(){s.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),s.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endMeetingAsync(e,t){(0,n.marshalPromiseToCallbacks)(this.endMeetingImplAsync(),e,t)}endMeetingImplAsync(){return this.close(!0)}lockMeetingAsync(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}muteAllParticipantsAsync(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}muteParticipantAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.me.isHost||this.me.id===e||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r);-1===this.privParticipants.getParticipantIndex(e)&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}removeParticipantAsync(e,t,r){try{if(s.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))(0,n.marshalPromiseToCallbacks)(this.removeParticipantImplAsync(e),t,r);else{s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let i="";if("string"==typeof e)i=e;else if(e.hasOwnProperty("id")){i=e.id}else if(e.hasOwnProperty("userId")){i=e.userId}s.Contracts.throwIfNullOrWhitespace(i,this.privErrors.invalidArgs.replace("{arg}","userId"));-1===this.participants.findIndex((e=>e.id===i))&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(i),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}}catch(e){this.handleError(e,r)}}unlockMeetingAsync(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}unmuteAllParticipantsAsync(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),(()=>{this.handleCallback(e,t)}),(e=>{this.handleError(e,t)}))}catch(e){this.handleError(e,t)}}unmuteParticipantAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.me.isHost||this.me.id===e||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r);-1===this.privParticipants.getParticipantIndex(e)&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}sendTextMessageAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}setTranslatedLanguagesAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}changeNicknameAsync(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),s.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),s.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),(()=>{this.handleCallback(t,r)}),(e=>{this.handleError(e,r)}))}catch(e){this.handleError(e,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),this.privConfig=void 0,this.privLanguage=void 0,this.privProperties=void 0,this.privRoom=void 0,this.privToken=void 0,this.privManager=void 0,this.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.meeting=this}getKeepAlive(){const e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(void 0!==this.privParticipants.addOrUpdateParticipant(e)&&this.privTranscriberRecognizer){const t=this.meetingInfo;return t.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(t,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);const t=this.meetingInfo;return t.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await(this.privConversationRecognizer?.close()),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(e){throw e}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(e){t&&t(e)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){const r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){const t=this.privParticipants.participants.map((e=>this.toParticipant(e)));return e?t:t.filter((e=>!1===e.isHost))}toParticipant(e){return new o.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingd"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),s.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),s.Contracts.throwIfNullOrWhitespace(e,"nickname"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:i.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:i.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),s.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:i.ConversationTranslatorMessageTypes.instantMessage})}}t.MeetingImpl=c},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeetingTranscriptionCanceledEventArgs=void 0;const i=r(101);class n extends i.CancellationEventArgsBase{}t.MeetingTranscriptionCanceledEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeetingTranscriber=void 0;const i=r(2),n=r(4),s=r(64),o=r(79),a=r(157);t.MeetingTranscriber=class{constructor(e){this.privAudioConfig=e,this.privProperties=new o.PropertyCollection,this.privRecognizer=void 0,this.privDisposedRecognizer=!1}get speechRecognitionLanguage(){return s.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(o.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get internalData(){return this.privRecognizer.internalData}get connection(){return o.Connection.fromRecognizer(this.privRecognizer)}get authorizationToken(){return this.properties.getProperty(o.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){s.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(o.PropertyId.SpeechServiceAuthorization_Token,e)}joinMeetingAsync(e,t,r){const o=e;s.Contracts.throwIfNullOrUndefined(a.MeetingImpl,"Meeting"),this.privRecognizer=new i.TranscriberRecognizer(e.config,this.privAudioConfig),s.Contracts.throwIfNullOrUndefined(this.privRecognizer,"Recognizer"),this.privRecognizer.connectMeetingCallbacks(this),(0,n.marshalPromiseToCallbacks)(o.connectTranscriberRecognizer(this.privRecognizer),t,r)}startTranscribingAsync(e,t){this.privRecognizer.startContinuousRecognitionAsync(e,t)}stopTranscribingAsync(e,t){this.privRecognizer.stopContinuousRecognitionAsync(e,t)}leaveMeetingAsync(e,t){this.privRecognizer.disconnectCallbacks(),(0,n.marshalPromiseToCallbacks)((async()=>{})(),e,t)}close(e,t){s.Contracts.throwIfDisposed(this.privDisposedRecognizer),(0,n.marshalPromiseToCallbacks)(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(this.privRecognizer&&(await this.privRecognizer.close(),this.privRecognizer=void 0),e&&(this.privDisposedRecognizer=!0))}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranscriptionResult=void 0;const i=r(79);class n extends i.RecognitionResult{constructor(e,t,r,i,n,s,o,a,c,p,h){super(e,t,r,i,n,s,o,c,p,h),this.privSpeakerId=a}get speakerId(){return this.privSpeakerId}}t.ConversationTranscriptionResult=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisRequest=t.Synthesizer=void 0;const i=r(2),n=r(4),s=r(64),o=r(79);class a{constructor(e){const t=e;s.Contracts.throwIfNull(t,"speechConfig"),this.privProperties=t.properties.clone(),this.privDisposed=!1,this.privSynthesizing=!1,this.synthesisRequestQueue=new n.Queue,this.tokenCredential=e.tokenCredential}get authorizationToken(){return this.properties.getProperty(o.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){s.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(o.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get autoDetectSourceLanguage(){return this.properties.getProperty(o.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)===i.AutoDetectSourceLanguagesOpenRangeOptionName}buildSsml(e){const t={"af-ZA":"af-ZA-AdriNeural","am-ET":"am-ET-AmehaNeural","ar-AE":"ar-AE-FatimaNeural","ar-BH":"ar-BH-AliNeural","ar-DZ":"ar-DZ-AminaNeural","ar-EG":"ar-EG-SalmaNeural","ar-IQ":"ar-IQ-BasselNeural","ar-JO":"ar-JO-SanaNeural","ar-KW":"ar-KW-FahedNeural","ar-LY":"ar-LY-ImanNeural","ar-MA":"ar-MA-JamalNeural","ar-QA":"ar-QA-AmalNeural","ar-SA":"ar-SA-HamedNeural","ar-SY":"ar-SY-AmanyNeural","ar-TN":"ar-TN-HediNeural","ar-YE":"ar-YE-MaryamNeural","bg-BG":"bg-BG-BorislavNeural","bn-BD":"bn-BD-NabanitaNeural","bn-IN":"bn-IN-BashkarNeural","ca-ES":"ca-ES-JoanaNeural","cs-CZ":"cs-CZ-AntoninNeural","cy-GB":"cy-GB-AledNeural","da-DK":"da-DK-ChristelNeural","de-AT":"de-AT-IngridNeural","de-CH":"de-CH-JanNeural","de-DE":"de-DE-KatjaNeural","el-GR":"el-GR-AthinaNeural","en-AU":"en-AU-NatashaNeural","en-CA":"en-CA-ClaraNeural","en-GB":"en-GB-LibbyNeural","en-HK":"en-HK-SamNeural","en-IE":"en-IE-ConnorNeural","en-IN":"en-IN-NeerjaNeural","en-KE":"en-KE-AsiliaNeural","en-NG":"en-NG-AbeoNeural","en-NZ":"en-NZ-MitchellNeural","en-PH":"en-PH-JamesNeural","en-SG":"en-SG-LunaNeural","en-TZ":"en-TZ-ElimuNeural","en-US":"en-US-AvaMultilingualNeural","en-ZA":"en-ZA-LeahNeural","es-AR":"es-AR-ElenaNeural","es-BO":"es-BO-MarceloNeural","es-CL":"es-CL-CatalinaNeural","es-CO":"es-CO-GonzaloNeural","es-CR":"es-CR-JuanNeural","es-CU":"es-CU-BelkysNeural","es-DO":"es-DO-EmilioNeural","es-EC":"es-EC-AndreaNeural","es-ES":"es-ES-AlvaroNeural","es-GQ":"es-GQ-JavierNeural","es-GT":"es-GT-AndresNeural","es-HN":"es-HN-CarlosNeural","es-MX":"es-MX-DaliaNeural","es-NI":"es-NI-FedericoNeural","es-PA":"es-PA-MargaritaNeural","es-PE":"es-PE-AlexNeural","es-PR":"es-PR-KarinaNeural","es-PY":"es-PY-MarioNeural","es-SV":"es-SV-LorenaNeural","es-US":"es-US-AlonsoNeural","es-UY":"es-UY-MateoNeural","es-VE":"es-VE-PaolaNeural","et-EE":"et-EE-AnuNeural","fa-IR":"fa-IR-DilaraNeural","fi-FI":"fi-FI-SelmaNeural","fil-PH":"fil-PH-AngeloNeural","fr-BE":"fr-BE-CharlineNeural","fr-CA":"fr-CA-SylvieNeural","fr-CH":"fr-CH-ArianeNeural","fr-FR":"fr-FR-DeniseNeural","ga-IE":"ga-IE-ColmNeural","gl-ES":"gl-ES-RoiNeural","gu-IN":"gu-IN-DhwaniNeural","he-IL":"he-IL-AvriNeural","hi-IN":"hi-IN-MadhurNeural","hr-HR":"hr-HR-GabrijelaNeural","hu-HU":"hu-HU-NoemiNeural","id-ID":"id-ID-ArdiNeural","is-IS":"is-IS-GudrunNeural","it-IT":"it-IT-IsabellaNeural","ja-JP":"ja-JP-NanamiNeural","jv-ID":"jv-ID-DimasNeural","kk-KZ":"kk-KZ-AigulNeural","km-KH":"km-KH-PisethNeural","kn-IN":"kn-IN-GaganNeural","ko-KR":"ko-KR-SunHiNeural","lo-LA":"lo-LA-ChanthavongNeural","lt-LT":"lt-LT-LeonasNeural","lv-LV":"lv-LV-EveritaNeural","mk-MK":"mk-MK-AleksandarNeural","ml-IN":"ml-IN-MidhunNeural","mr-IN":"mr-IN-AarohiNeural","ms-MY":"ms-MY-OsmanNeural","mt-MT":"mt-MT-GraceNeural","my-MM":"my-MM-NilarNeural","nb-NO":"nb-NO-PernilleNeural","nl-BE":"nl-BE-ArnaudNeural","nl-NL":"nl-NL-ColetteNeural","pl-PL":"pl-PL-AgnieszkaNeural","ps-AF":"ps-AF-GulNawazNeural","pt-BR":"pt-BR-FranciscaNeural","pt-PT":"pt-PT-DuarteNeural","ro-RO":"ro-RO-AlinaNeural","ru-RU":"ru-RU-SvetlanaNeural","si-LK":"si-LK-SameeraNeural","sk-SK":"sk-SK-LukasNeural","sl-SI":"sl-SI-PetraNeural","so-SO":"so-SO-MuuseNeural","sr-RS":"sr-RS-NicholasNeural","su-ID":"su-ID-JajangNeural","sv-SE":"sv-SE-SofieNeural","sw-KE":"sw-KE-RafikiNeural","sw-TZ":"sw-TZ-DaudiNeural","ta-IN":"ta-IN-PallaviNeural","ta-LK":"ta-LK-KumarNeural","ta-SG":"ta-SG-AnbuNeural","te-IN":"te-IN-MohanNeural","th-TH":"th-TH-PremwadeeNeural","tr-TR":"tr-TR-AhmetNeural","uk-UA":"uk-UA-OstapNeural","ur-IN":"ur-IN-GulNeural","ur-PK":"ur-PK-AsadNeural","uz-UZ":"uz-UZ-MadinaNeural","vi-VN":"vi-VN-HoaiMyNeural","zh-CN":"zh-CN-XiaoxiaoNeural","zh-HK":"zh-HK-HiuMaanNeural","zh-TW":"zh-TW-HsiaoChenNeural","zu-ZA":"zu-ZA-ThandoNeural"};let r=this.properties.getProperty(o.PropertyId.SpeechServiceConnection_SynthLanguage,"en-US"),i=this.properties.getProperty(o.PropertyId.SpeechServiceConnection_SynthVoice,""),n=a.XMLEncode(e);return this.autoDetectSourceLanguage?r="en-US":i=i||t[r],i&&(n=`<voice name='${i}'>${n}</voice>`),n=`<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts' xmlns:emo='http://www.w3.org/2009/10/emotionml' xml:lang='${r}'>${n}</speak>`,n}async dispose(e){this.privDisposed||(e&&this.privAdapter&&await this.privAdapter.dispose(),this.privDisposed=!0)}async adapterSpeak(){if(!this.privDisposed&&!this.privSynthesizing){this.privSynthesizing=!0;const e=await this.synthesisRequestQueue.dequeue();return this.privAdapter.Speak(e.text,e.isSSML,e.requestId,e.cb,e.err,e.dataStream)}}createSynthesizerConfig(e){return new i.SynthesizerConfig(e,this.privProperties)}implCommonSynthesizeSetup(){let e="undefined"!=typeof window?"Browser":"Node",t="unknown",r="unknown";"undefined"!=typeof navigator&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);const n=this.createSynthesizerConfig(new i.SpeechServiceConfig(new i.Context(new i.OS(e,t,r)))),s=this.privProperties.getProperty(o.PropertyId.SpeechServiceConnection_Key,void 0),a=s&&""!==s?new i.CognitiveSubscriptionKeyAuthentication(s):this.tokenCredential?new i.CognitiveTokenAuthentication((async()=>{try{const e=await this.tokenCredential.getToken("https://cognitiveservices.azure.com/.default");return e?.token??""}catch(e){throw e}}),(async()=>{try{const e=await this.tokenCredential.getToken("https://cognitiveservices.azure.com/.default");return e?.token??""}catch(e){throw e}})):new i.CognitiveTokenAuthentication((()=>{const e=this.privProperties.getProperty(o.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(e)}),(()=>{const e=this.privProperties.getProperty(o.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(e)}));this.privAdapter=this.createSynthesisAdapter(a,this.privConnectionFactory,n),this.privRestAdapter=this.createRestSynthesisAdapter(a,n)}static XMLEncode(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}}t.Synthesizer=a;t.SynthesisRequest=class{constructor(e,t,r,i,n,s){this.requestId=e,this.text=t,this.isSSML=r,this.cb=i,this.err=n,this.dataStream=s}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesizer=void 0;const i=r(2),n=r(4),s=r(81),o=r(85),a=r(84),c=r(64),p=r(79),h=r(175);class u extends p.Synthesizer{constructor(e,t){super(e),null!==t&&(this.audioConfig=void 0===t?"undefined"==typeof window?void 0:p.AudioConfig.fromDefaultSpeakerOutput():t),this.privConnectionFactory=new i.SpeechSynthesisConnectionFactory,this.implCommonSynthesizeSetup()}static FromConfig(e,t,r){const i=e;return t.properties.mergeTo(i.properties),new u(e,r)}speakTextAsync(e,t,r,i){this.speakImpl(e,!1,t,r,i)}speakSsmlAsync(e,t,r,i){this.speakImpl(e,!0,t,r,i)}async getVoicesAsync(e=""){return this.getVoices(e)}close(e,t){c.Contracts.throwIfDisposed(this.privDisposed),(0,n.marshalPromiseToCallbacks)(this.dispose(!0),e,t)}get internalData(){return this.privAdapter}createSynthesisAdapter(e,t,r){return new i.SpeechSynthesisAdapter(e,t,r,this,this.audioConfig)}createRestSynthesisAdapter(e,t){return new i.SynthesisRestAdapter(t,e)}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=o.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(p.SpeechSynthesisOutputFormat[this.properties.getProperty(p.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)])}speakImpl(e,t,r,i,o){try{c.Contracts.throwIfDisposed(this.privDisposed);const u=(0,n.createNoDashGuid)();let d;d=o instanceof p.PushAudioOutputStreamCallback?new a.PushAudioOutputStreamImpl(o):o instanceof p.PullAudioOutputStream?o:void 0!==o?new s.AudioFileWriter(o):void 0,this.synthesisRequestQueue.enqueue(new h.SynthesisRequest(u,e,t,(e=>{if(this.privSynthesizing=!1,r)try{r(e)}catch(e){i&&i(e)}r=void 0,this.adapterSpeak().catch((()=>{}))}),(e=>{i&&i(e)}),d)),this.adapterSpeak().catch((()=>{}))}catch(e){if(i)if(e instanceof Error){const t=e;i(t.name+": "+t.message)}else i(e);this.dispose(!0).catch((()=>{}))}}async getVoices(e){const t=(0,n.createNoDashGuid)(),r=await this.privRestAdapter.getVoicesList(t);if(r.ok&&Array.isArray(r.json)){let i=r.json;return e&&e.length>0&&(i=i.filter((t=>!!t.Locale&&t.Locale.toLowerCase()===e.toLowerCase()))),new p.SynthesisVoicesResult(t,i,void 0)}return new p.SynthesisVoicesResult(t,void 0,`Error: ${r.status}: ${r.statusText}`)}}t.SpeechSynthesizer=u},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisResult=void 0;t.SynthesisResult=class{constructor(e,t,r,i){this.privResultId=e,this.privReason=t,this.privErrorDetails=r,this.privProperties=i}get resultId(){return this.privResultId}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get properties(){return this.privProperties}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisResult=void 0;const i=r(79);class n extends i.SynthesisResult{constructor(e,t,r,i,n,s){super(e,t,i,n),this.privAudioData=r,this.privAudioDuration=s}get audioData(){return this.privAudioData}get audioDuration(){return this.privAudioDuration}}t.SpeechSynthesisResult=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisEventArgs=void 0;t.SpeechSynthesisEventArgs=class{constructor(e){this.privResult=e}get result(){return this.privResult}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisWordBoundaryEventArgs=void 0;t.SpeechSynthesisWordBoundaryEventArgs=class{constructor(e,t,r,i,n,s){this.privAudioOffset=e,this.privDuration=t,this.privText=r,this.privWordLength=i,this.privTextOffset=n,this.privBoundaryType=s}get audioOffset(){return this.privAudioOffset}get duration(){return this.privDuration}get text(){return this.privText}get wordLength(){return this.privWordLength}get textOffset(){return this.privTextOffset}get boundaryType(){return this.privBoundaryType}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisBookmarkEventArgs=void 0;t.SpeechSynthesisBookmarkEventArgs=class{constructor(e,t){this.privAudioOffset=e,this.privText=t}get audioOffset(){return this.privAudioOffset}get text(){return this.privText}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisVisemeEventArgs=void 0;t.SpeechSynthesisVisemeEventArgs=class{constructor(e,t,r){this.privAudioOffset=e,this.privVisemeId=t,this.privAnimation=r}get audioOffset(){return this.privAudioOffset}get visemeId(){return this.privVisemeId}get animation(){return this.privAnimation}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisBoundaryType=void 0,function(e){e.Word="WordBoundary",e.Punctuation="PunctuationBoundary",e.Sentence="SentenceBoundary"}(t.SpeechSynthesisBoundaryType||(t.SpeechSynthesisBoundaryType={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisVoicesResult=void 0;const i=r(79);class n extends i.SynthesisResult{constructor(e,t,r){if(Array.isArray(t)){super(e,i.ResultReason.VoicesListRetrieved,void 0,new i.PropertyCollection),this.privVoices=[];for(const e of t)this.privVoices.push(new i.VoiceInfo(e))}else super(e,i.ResultReason.Canceled,r||"Error information unavailable",new i.PropertyCollection)}get voices(){return this.privVoices}}t.SynthesisVoicesResult=n},(e,t)=>{"use strict";var r,i;Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceInfo=t.SynthesisVoiceType=t.SynthesisVoiceGender=void 0,function(e){e[e.Unknown=0]="Unknown",e[e.Female=1]="Female",e[e.Male=2]="Male",e[e.Neutral=3]="Neutral"}(r=t.SynthesisVoiceGender||(t.SynthesisVoiceGender={})),function(e){e[e.Unknown=0]="Unknown",e[e.OnlineNeural=1]="OnlineNeural",e[e.OnlineStandard=2]="OnlineStandard",e[e.OfflineNeural=3]="OfflineNeural",e[e.OfflineStandard=4]="OfflineStandard",e[e.OnlineNeuralHD=5]="OnlineNeuralHD"}(i=t.SynthesisVoiceType||(t.SynthesisVoiceType={}));const n={[r[r.Neutral]]:r.Neutral,[r[r.Male]]:r.Male,[r[r.Female]]:r.Female},s={Neural:i.OnlineNeural,NeuralHD:i.OnlineNeuralHD};t.VoiceInfo=class{constructor(e){if(this.privStyleList=[],e){if(this.privName=e.Name,this.privLocale=e.Locale,this.privShortName=e.ShortName,this.privLocaleName=e.LocaleName,this.privDisplayName=e.DisplayName,this.privLocalName=e.LocalName,this.privVoiceType=s[e.VoiceType]||i.Unknown,this.privGender=n[e.Gender]||r.Unknown,e.StyleList&&Array.isArray(e.StyleList))for(const t of e.StyleList)this.privStyleList.push(t);this.privSampleRateHertz=e.SampleRateHertz,this.privStatus=e.Status,e.ExtendedPropertyMap&&(this.privExtendedPropertyMap=e.ExtendedPropertyMap),this.privWordsPerMinute=e.WordsPerMinute,Array.isArray(e.SecondaryLocaleList)&&(this.privSecondaryLocaleList=[...e.SecondaryLocaleList]),Array.isArray(e.RolePlayList)&&(this.privRolePlayList=[...e.RolePlayList]),e.VoiceTag&&(this.privVoiceTag=e.VoiceTag)}}get name(){return this.privName}get locale(){return this.privLocale}get shortName(){return this.privShortName}get displayName(){return this.privDisplayName}get localName(){return this.privLocalName}get localeName(){return this.privLocaleName}get gender(){return this.privGender}get voiceType(){return this.privVoiceType}get styleList(){return this.privStyleList}get sampleRateHertz(){return this.privSampleRateHertz}get status(){return this.privStatus}get extendedPropertyMap(){return this.privExtendedPropertyMap}get wordsPerMinute(){return this.privWordsPerMinute}get secondaryLocaleList(){return this.privSecondaryLocaleList}get rolePlayList(){return this.privRolePlayList}get voiceTag(){return this.privVoiceTag}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakerAudioDestination=void 0;const i=r(4),n=r(84),s=r(67),o={[s.AudioFormatTag.PCM]:"audio/wav",[s.AudioFormatTag.MuLaw]:"audio/x-wav",[s.AudioFormatTag.MP3]:"audio/mpeg",[s.AudioFormatTag.OGG_OPUS]:"audio/ogg",[s.AudioFormatTag.WEBM_OPUS]:"audio/webm; codecs=opus",[s.AudioFormatTag.ALaw]:"audio/x-wav",[s.AudioFormatTag.FLAC]:"audio/flac",[s.AudioFormatTag.AMR_WB]:"audio/amr-wb",[s.AudioFormatTag.G722]:"audio/G722"};t.SpeakerAudioDestination=class{constructor(e){this.privPlaybackStarted=!1,this.privAppendingToBuffer=!1,this.privMediaSourceOpened=!1,this.privBytesReceived=0,this.privId=e||(0,i.createNoDashGuid)(),this.privIsPaused=!1,this.privIsClosed=!1}id(){return this.privId}write(e,t,r){void 0!==this.privAudioBuffer?(this.privAudioBuffer.push(e),this.updateSourceBuffer().then((()=>{t&&t()}),(e=>{r&&r(e)}))):void 0!==this.privAudioOutputStream&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength)}close(e,t){if(this.privIsClosed=!0,void 0!==this.privSourceBuffer)this.handleSourceBufferUpdateEnd().then((()=>{e&&e()}),(e=>{t&&t(e)}));else if(void 0!==this.privAudioOutputStream&&"undefined"!=typeof window)if(this.privFormat.formatTag!==s.AudioFormatTag.PCM&&this.privFormat.formatTag!==s.AudioFormatTag.MuLaw&&this.privFormat.formatTag!==s.AudioFormatTag.ALaw||!1!==this.privFormat.hasHeader){let r=new ArrayBuffer(this.privBytesReceived);this.privAudioOutputStream.read(r).then((()=>{r=this.privFormat.addHeader(r);const i=new Blob([r],{type:o[this.privFormat.formatTag]});this.privAudio.src=window.URL.createObjectURL(i),this.notifyPlayback().then((()=>{e&&e()}),(e=>{t&&t(e)}))}),(e=>{t&&t(e)}))}else console.warn("Play back is not supported for raw PCM, mulaw or alaw format without header."),this.onAudioEnd&&this.onAudioEnd(this);else this.onAudioEnd&&this.onAudioEnd(this)}set format(e){if("undefined"!=typeof AudioContext||"undefined"!=typeof window&&void 0!==window.webkitAudioContext){this.privFormat=e;const t=o[this.privFormat.formatTag];void 0===t?console.warn(`Unknown mimeType for format ${s.AudioFormatTag[this.privFormat.formatTag]}; playback is not supported.`):"undefined"!=typeof MediaSource&&MediaSource.isTypeSupported(t)?(this.privAudio=new Audio,this.privAudioBuffer=[],this.privMediaSource=new MediaSource,this.privAudio.src=URL.createObjectURL(this.privMediaSource),this.privAudio.load(),this.privMediaSource.onsourceopen=()=>{this.privMediaSourceOpened=!0,this.privMediaSource.duration=1800,this.privSourceBuffer=this.privMediaSource.addSourceBuffer(t),this.privSourceBuffer.onupdate=()=>{this.updateSourceBuffer().catch((e=>{i.Events.instance.onEvent(new i.BackgroundEvent(e))}))},this.privSourceBuffer.onupdateend=()=>{this.handleSourceBufferUpdateEnd().catch((e=>{i.Events.instance.onEvent(new i.BackgroundEvent(e))}))},this.privSourceBuffer.onupdatestart=()=>{this.privAppendingToBuffer=!1}},this.updateSourceBuffer().catch((e=>{i.Events.instance.onEvent(new i.BackgroundEvent(e))}))):(console.warn(`Format ${s.AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`),this.privAudioOutputStream=new n.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privFormat,this.privAudio=new Audio)}}get volume(){return this.privAudio?.volume??-1}set volume(e){this.privAudio&&(this.privAudio.volume=e)}mute(){this.privAudio&&(this.privAudio.muted=!0)}unmute(){this.privAudio&&(this.privAudio.muted=!1)}get isClosed(){return this.privIsClosed}get currentTime(){return void 0!==this.privAudio?this.privAudio.currentTime:-1}pause(){this.privIsPaused||void 0===this.privAudio||(this.privAudio.pause(),this.privIsPaused=!0)}resume(e,t){this.privIsPaused&&void 0!==this.privAudio&&(this.privAudio.play().then((()=>{e&&e()}),(e=>{t&&t(e)})),this.privIsPaused=!1)}get internalAudio(){return this.privAudio}async updateSourceBuffer(){if(void 0!==this.privAudioBuffer&&this.privAudioBuffer.length>0&&this.sourceBufferAvailable()){this.privAppendingToBuffer=!0;const e=this.privAudioBuffer.shift();try{this.privSourceBuffer.appendBuffer(e)}catch(t){return this.privAudioBuffer.unshift(e),void console.log("buffer filled, pausing addition of binaries until space is made")}await this.notifyPlayback()}else this.canEndStream()&&await this.handleSourceBufferUpdateEnd()}async handleSourceBufferUpdateEnd(){this.canEndStream()&&this.sourceBufferAvailable()&&(this.privMediaSource.endOfStream(),await this.notifyPlayback())}async notifyPlayback(){this.privPlaybackStarted||void 0===this.privAudio||(this.privPlaybackStarted=!0,this.onAudioStart&&this.onAudioStart(this),this.privAudio.onended=()=>{this.onAudioEnd&&this.onAudioEnd(this)},this.privIsPaused||await this.privAudio.play())}canEndStream(){return this.isClosed&&void 0!==this.privSourceBuffer&&0===this.privAudioBuffer.length&&this.privMediaSourceOpened&&!this.privAppendingToBuffer&&"open"===this.privMediaSource.readyState}sourceBufferAvailable(){return void 0!==this.privSourceBuffer&&!this.privSourceBuffer.updating}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranscriptionCanceledEventArgs=void 0;const i=r(101);class n extends i.CancellationEventArgsBase{}t.ConversationTranscriptionCanceledEventArgs=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeetingTranscriptionCanceledEventArgs=void 0;const i=r(101);class n extends i.CancellationEventArgsBase{}t.MeetingTranscriptionCanceledEventArgs=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PronunciationAssessmentGradingSystem=void 0,function(e){e[e.FivePoint=1]="FivePoint",e[e.HundredMark=2]="HundredMark"}(t.PronunciationAssessmentGradingSystem||(t.PronunciationAssessmentGradingSystem={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PronunciationAssessmentGranularity=void 0,function(e){e[e.Phoneme=1]="Phoneme",e[e.Word=2]="Word",e[e.FullText=3]="FullText"}(t.PronunciationAssessmentGranularity||(t.PronunciationAssessmentGranularity={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PronunciationAssessmentConfig=void 0;const i=r(64),n=r(79);class s{constructor(e,t=n.PronunciationAssessmentGradingSystem.FivePoint,r=n.PronunciationAssessmentGranularity.Phoneme,s=!1){i.Contracts.throwIfNullOrUndefined(e,"referenceText"),this.privProperties=new n.PropertyCollection,this.privProperties.setProperty(n.PropertyId.PronunciationAssessment_ReferenceText,e),this.privProperties.setProperty(n.PropertyId.PronunciationAssessment_GradingSystem,n.PronunciationAssessmentGradingSystem[t]),this.privProperties.setProperty(n.PropertyId.PronunciationAssessment_Granularity,n.PronunciationAssessmentGranularity[r]),this.privProperties.setProperty(n.PropertyId.PronunciationAssessment_EnableMiscue,String(s))}static fromJSON(e){i.Contracts.throwIfNullOrUndefined(e,"json");const t=new s("");return t.privProperties=new n.PropertyCollection,t.properties.setProperty(n.PropertyId.PronunciationAssessment_Json,e),t}toJSON(){return this.updateJson(),this.privProperties.getProperty(n.PropertyId.PronunciationAssessment_Params)}applyTo(e){this.updateJson();const t=e.internalData;t.expectContentAssessmentResponse=!!this.privContentAssessmentTopic,t.speechContext.setPronunciationAssessmentParams(this.properties.getProperty(n.PropertyId.PronunciationAssessment_Params),this.privContentAssessmentTopic,t.isSpeakerDiarizationEnabled)}get referenceText(){return this.properties.getProperty(n.PropertyId.PronunciationAssessment_ReferenceText)}set referenceText(e){i.Contracts.throwIfNullOrWhitespace(e,"referenceText"),this.properties.setProperty(n.PropertyId.PronunciationAssessment_ReferenceText,e)}set phonemeAlphabet(e){i.Contracts.throwIfNullOrWhitespace(e,"phonemeAlphabet"),this.privPhonemeAlphabet=e}set enableMiscue(e){const t=e?"true":"false";this.properties.setProperty(n.PropertyId.PronunciationAssessment_EnableMiscue,t)}get enableMiscue(){return"true"===this.properties.getProperty(n.PropertyId.PronunciationAssessment_EnableMiscue,"false").toLowerCase()}set nbestPhonemeCount(e){this.privNBestPhonemeCount=e}set enableProsodyAssessment(e){this.privEnableProsodyAssessment=e}enableContentAssessmentWithTopic(e){this.privContentAssessmentTopic=e}get properties(){return this.privProperties}updateJson(){const e=this.privProperties.getProperty(n.PropertyId.PronunciationAssessment_Json,"{}"),t=JSON.parse(e),r=this.privProperties.getProperty(n.PropertyId.PronunciationAssessment_ReferenceText);r&&(t.referenceText=r);const i=this.privProperties.getProperty(n.PropertyId.PronunciationAssessment_GradingSystem);i&&(t.gradingSystem=i);const s=this.privProperties.getProperty(n.PropertyId.PronunciationAssessment_Granularity);s&&(t.granularity=s),this.privPhonemeAlphabet&&(t.phonemeAlphabet=this.privPhonemeAlphabet),this.privNBestPhonemeCount&&(t.nbestPhonemeCount=this.privNBestPhonemeCount),t.enableProsodyAssessment=this.privEnableProsodyAssessment,t.dimension="Comprehensive";this.privProperties.getProperty(n.PropertyId.PronunciationAssessment_EnableMiscue)&&(t.enableMiscue=this.enableMiscue),this.privProperties.setProperty(n.PropertyId.PronunciationAssessment_Params,JSON.stringify(t))}}t.PronunciationAssessmentConfig=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PronunciationAssessmentResult=t.ContentAssessmentResult=void 0;const i=r(64),n=r(79);class s{constructor(e){this.privPronJson=e}get grammarScore(){return this.privPronJson.ContentAssessment.GrammarScore}get vocabularyScore(){return this.privPronJson.ContentAssessment.VocabularyScore}get topicScore(){return this.privPronJson.ContentAssessment.TopicScore}}t.ContentAssessmentResult=s;class o{constructor(e){const t=JSON.parse(e);i.Contracts.throwIfNullOrUndefined(t.NBest[0],"NBest"),this.privPronJson=t.NBest[0]}static fromResult(e){i.Contracts.throwIfNullOrUndefined(e,"result");const t=e.properties.getProperty(n.PropertyId.SpeechServiceResponse_JsonResult);return i.Contracts.throwIfNullOrUndefined(t,"json"),new o(t)}get detailResult(){return this.privPronJson}get accuracyScore(){return this.detailResult.PronunciationAssessment?.AccuracyScore}get pronunciationScore(){return this.detailResult.PronunciationAssessment?.PronScore}get completenessScore(){return this.detailResult.PronunciationAssessment?.CompletenessScore}get fluencyScore(){return this.detailResult.PronunciationAssessment?.FluencyScore}get prosodyScore(){return this.detailResult.PronunciationAssessment?.ProsodyScore}get contentAssessmentResult(){if(void 0!==this.detailResult.ContentAssessment)return new s(this.detailResult)}}t.PronunciationAssessmentResult=o},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AvatarConfig=void 0;const i=r(64),n=r(79);t.AvatarConfig=class{constructor(e,t,r){this.privCustomized=!1,this.privUseBuiltInVoice=!1,i.Contracts.throwIfNullOrWhitespace(e,"character"),this.character=e,this.style=t,void 0===r&&(r=new n.AvatarVideoFormat),this.videoFormat=r}get customized(){return this.privCustomized}set customized(e){this.privCustomized=e}get useBuiltInVoice(){return this.privUseBuiltInVoice}set useBuiltInVoice(e){this.privUseBuiltInVoice=e}get backgroundColor(){return this.privBackgroundColor}set backgroundColor(e){this.privBackgroundColor=e}get backgroundImage(){return this.privBackgroundImage}set backgroundImage(e){this.privBackgroundImage=e}get remoteIceServers(){return this.privRemoteIceServers}set remoteIceServers(e){this.privRemoteIceServers=e}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AvatarEventArgs=t.AvatarEventTypes=void 0,function(e){e.SwitchedToSpeaking="SwitchedToSpeaking",e.SwitchedToIdle="SwitchedToIdle",e.SessionClosed="SessionClosed"}(t.AvatarEventTypes||(t.AvatarEventTypes={}));t.AvatarEventArgs=class{constructor(e,t){this.privOffset=e,this.privDescription=t}get type(){return this.privType}get offset(){return this.privOffset}get description(){return this.privDescription}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AvatarSynthesizer=void 0;const i=r(196),n=r(2),s=r(4),o=r(85),a=r(79),c=r(64),p=r(175);class h extends a.Synthesizer{constructor(e,t){super(e),c.Contracts.throwIfNullOrUndefined(t,"avatarConfig"),this.privConnectionFactory=new i.SpeechSynthesisConnectionFactory,this.privAvatarConfig=t,this.implCommonSynthesizeSetup()}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=o.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(a.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm)}async startAvatarAsync(e){c.Contracts.throwIfNullOrUndefined(e,"peerConnection"),this.privIceServers=e.getConfiguration().iceServers,c.Contracts.throwIfNullOrUndefined(this.privIceServers,"Ice servers must be set.");const t=new s.Deferred;e.onicegatheringstatechange=()=>{s.Events.instance.onEvent(new s.PlatformEvent("peer connection: ice gathering state: "+e.iceGatheringState,s.EventType.Debug)),"complete"===e.iceGatheringState&&(s.Events.instance.onEvent(new s.PlatformEvent("peer connection: ice gathering complete.",s.EventType.Info)),t.resolve())},e.onicecandidate=e=>{e.candidate?s.Events.instance.onEvent(new s.PlatformEvent("peer connection: ice candidate: "+e.candidate.candidate,s.EventType.Debug)):(s.Events.instance.onEvent(new s.PlatformEvent("peer connection: ice candidate: complete",s.EventType.Debug)),t.resolve())},setTimeout((()=>{"complete"!==e.iceGatheringState&&(s.Events.instance.onEvent(new s.PlatformEvent("peer connection: ice gathering timeout.",s.EventType.Warning)),t.resolve())}),2e3);const r=await e.createOffer();await e.setLocalDescription(r),await t.promise,s.Events.instance.onEvent(new s.PlatformEvent("peer connection: got local SDP.",s.EventType.Info)),this.privProperties.setProperty(a.PropertyId.TalkingAvatarService_WebRTC_SDP,JSON.stringify(e.localDescription));const i=await this.speak("",!1);if(i.reason!==a.ResultReason.SynthesizingAudioCompleted)return new a.SynthesisResult(i.resultId,i.reason,i.errorDetails,i.properties);const n=atob(i.properties.getProperty(a.PropertyId.TalkingAvatarService_WebRTC_SDP)),o=new RTCSessionDescription(JSON.parse(n));return await e.setRemoteDescription(o),new a.SynthesisResult(i.resultId,i.reason,void 0,i.properties)}async speakTextAsync(e){const t=await this.speak(e,!1);return new a.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async speakSsmlAsync(e){const t=await this.speak(e,!0);return new a.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async stopSpeakingAsync(){for(;this.synthesisRequestQueue.length()>0;){(await this.synthesisRequestQueue.dequeue()).err("Synthesis is canceled by user.")}return this.privAdapter.stopSpeaking()}async stopAvatarAsync(){return c.Contracts.throwIfDisposed(this.privDisposed),this.dispose(!0)}async close(){if(!this.privDisposed)return this.dispose(!0)}get iceServers(){return this.privIceServers}createSynthesisAdapter(e,t,r){return new n.AvatarSynthesisAdapter(e,t,r,this,this.privAvatarConfig)}createRestSynthesisAdapter(e,t){}createSynthesizerConfig(e){const t=super.createSynthesizerConfig(e);return t.avatarEnabled=!0,t}async speak(e,t){const r=(0,s.createNoDashGuid)(),i=new s.Deferred;return this.synthesisRequestQueue.enqueue(new p.SynthesisRequest(r,e,t,(e=>{i.resolve(e),this.privSynthesizing=!1,this.adapterSpeak()}),(e=>{i.reject(e),this.privSynthesizing=!1}))),this.adapterSpeak(),i.promise}}t.AvatarSynthesizer=h},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisConnectionFactory=void 0;const i=r(60),n=r(79),s=r(135),o=r(2),a=r(54),c=r(136);t.SpeechSynthesisConnectionFactory=class{constructor(){this.synthesisUri="/tts/cognitiveservices/websocket/v1"}async create(e,t,r){let p=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Endpoint,void 0);const h=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Region,void 0),u=s.ConnectionFactoryBase.getHostSuffix(h),d=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_EndpointId,void 0),v=void 0===d?"tts":"voice",l=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Host,"wss://"+h+"."+v+".speech"+u),g={},m={};if(void 0!==t.token&&""!==t.token&&(m[t.headerName]=t.token),m[a.HeaderNames.ConnectionId]=r,void 0!==d&&""!==d&&(p&&-1!==p.search(c.QueryParameterNames.CustomVoiceDeploymentId)||(g[c.QueryParameterNames.CustomVoiceDeploymentId]=d)),e.avatarEnabled&&(p&&-1!==p.search(c.QueryParameterNames.EnableAvatar)||(g[c.QueryParameterNames.EnableAvatar]="true")),p){const e=new URL(p),t=e.pathname;""!==t&&"/"!==t||(e.pathname=this.synthesisUri,p=await s.ConnectionFactoryBase.getRedirectUrlFromEndpoint(e.toString()))}p||(p=l+this.synthesisUri),e.parameters.setProperty(n.PropertyId.SpeechServiceConnection_Url,p);const f="true"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false");return new i.WebsocketConnection(p,g,m,new o.WebsocketMessageFormatter,i.ProxyInfo.fromParameters(e.parameters),f,r)}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AvatarVideoFormat=t.Coordinate=void 0;t.Coordinate=class{constructor(e,t){this.x=e,this.y=t}};t.AvatarVideoFormat=class{constructor(e="H264",t=2e6,r=1920,i=1080){this.codec=e,this.bitrate=t,this.width=r,this.height=i}setCropRange(e,t){this.cropRange={bottomRight:t,topLeft:e}}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AvatarWebRTCConnectionResult=void 0;const i=r(79);class n extends i.SynthesisResult{constructor(e,t,r,i,n){super(t,r,i,n),this.privSDPAnswer=e}get SDPAnswer(){return this.privSDPAnswer}}t.AvatarWebRTCConnectionResult=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Diagnostics=void 0;const i=r(60),n=r(4);class s{static SetLoggingLevel(e){this.privListener=new i.ConsoleLoggingListener(e),n.Events.instance.attachConsoleListener(this.privListener)}static StartConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!0)}static StopConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!1)}static SetLogOutputPath(e){if("undefined"!=typeof window)throw new Error("File system logging not available in browser.");this.privListener&&(this.privListener.logPath=e)}static set onLogOutput(e){this.privListener&&(this.privListener.logCallback=e)}}t.Diagnostics=s,s.privListener=void 0},function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RestMessageAdapter=t.RestRequestType=void 0;const n=i(r(201)),s=r(4);var o;!function(e){e.Get="GET",e.Post="POST",e.Delete="DELETE",e.File="file"}(o=t.RestRequestType||(t.RestRequestType={}));t.RestMessageAdapter=class{constructor(e){if(!e)throw new s.ArgumentNullError("configParams");this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}static extractHeaderValue(e,t){let r="";try{const i=t.trim().split(/[\r\n]+/),n={};i.forEach((e=>{const t=e.split(": "),r=t.shift().toLowerCase(),i=t.join(": ");n[r]=i})),r=n[e.toLowerCase()]}catch(e){}return r}set options(e){this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}setHeaders(e,t){this.privHeaders[e]=t}request(e,t,r={},i=null){const a=new s.Deferred,c=e===o.File?"POST":e,p=(e,t={})=>{const r=e;return{data:JSON.stringify(t),headers:JSON.stringify(e.headers),json:t,ok:e.statusCode>=200&&e.statusCode<300,status:e.statusCode,statusText:t.error?t.error.message:r.statusText?r.statusText:r.statusMessage}};return this.privIgnoreCache&&(this.privHeaders["Cache-Control"]="no-cache"),e===o.Post&&i&&(this.privHeaders["content-type"]="application/json",this.privHeaders["Content-Type"]="application/json"),(i=>{(0,n.default)(t,c,this.privHeaders,200,201,202,204,400,401,402,403,404)(""===this.queryParams(r)?"":`?${this.queryParams(r)}`,i).then((async t=>{if(e===o.Delete||204===t.statusCode)a.resolve(p(t));else try{const e=await t.json();a.resolve(p(t,e))}catch{a.resolve(p(t))}})).catch((e=>{a.reject(e)}))})(i),a.promise}queryParams(e={}){return Object.keys(e).map((t=>encodeURIComponent(t)+"="+encodeURIComponent(e[t]))).join("&")}}},(e,t,r)=>{"use strict";const i=r(202);class n extends Error{constructor(e,...t){let r;super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,n),this.name="StatusError",this.message=e.statusMessage,this.statusCode=e.status,this.res=e,this.json=e.json.bind(e),this.text=e.text.bind(e),this.arrayBuffer=e.arrayBuffer.bind(e);Object.defineProperty(this,"responseBody",{get:()=>(r||(r=this.arrayBuffer()),r)}),this.headers={};for(const[t,r]of e.headers.entries())this.headers[t.toLowerCase()]=r}}e.exports=i(((e,t,r,i,s)=>async(o,a,c={})=>{o=s+(o||"");let p=new URL(o);if(i||(i={}),p.username&&(i.Authorization="Basic "+btoa(p.username+":"+p.password),p=new URL(p.protocol+"//"+p.host+p.pathname+p.search)),"https:"!==p.protocol&&"http:"!==p.protocol)throw new Error(`Unknown protocol, ${p.protocol}`);if(a)if(a instanceof ArrayBuffer||ArrayBuffer.isView(a)||"string"==typeof a);else{if("object"!=typeof a)throw new Error("Unknown body type.");a=JSON.stringify(a),i["Content-Type"]="application/json"}c=new Headers({...i||{},...c});const h=await fetch(p,{method:t,headers:c,body:a});if(h.statusCode=h.status,!e.has(h.status))throw new n(h);return"json"===r?h.json():"buffer"===r?h.arrayBuffer():"string"===r?h.text():h}))},e=>{"use strict";const t=new Set(["json","buffer","string"]);e.exports=e=>(...r)=>{const i=new Set;let n,s,o,a="";return r.forEach((e=>{if("string"==typeof e)if(e.toUpperCase()===e){if(n){throw new Error(`Can't set method to ${e}, already set to ${n}.`)}n=e}else if(e.startsWith("http:")||e.startsWith("https:"))a=e;else{if(!t.has(e))throw new Error(`Unknown encoding, ${e}`);s=e}else if("number"==typeof e)i.add(e);else{if("object"!=typeof e)throw new Error("Unknown type: "+typeof e);if(Array.isArray(e)||e instanceof Set)e.forEach((e=>i.add(e)));else{if(o)throw new Error("Cannot set headers twice.");o=e}}})),n||(n="GET"),0===i.size&&i.add(200),e(i,n,s,o,a)}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RestConfigBase=void 0;class r{static get requestOptions(){return r.privDefaultRequestOptions}static get configParams(){return r.privDefaultParams}static get restErrors(){return r.privRestErrors}}t.RestConfigBase=r,r.privDefaultRequestOptions={headers:{Accept:"application/json"},ignoreCache:!1,timeout:1e4},r.privRestErrors={authInvalidSubscriptionKey:"You must specify either an authentication token to use, or a Cognitive Speech subscription key.",authInvalidSubscriptionRegion:"You must specify the Cognitive Speech region to use.",invalidArgs:"Required input not found: {arg}.",invalidCreateJoinConversationResponse:"Creating/Joining conversation failed with HTTP {status}.",invalidParticipantRequest:"The requested participant was not found.",permissionDeniedConnect:"Required credentials not found.",permissionDeniedConversation:"Invalid operation: only the host can {command} the conversation.",permissionDeniedParticipant:"Invalid operation: only the host can {command} a participant.",permissionDeniedSend:"Invalid operation: the conversation is not in a connected state.",permissionDeniedStart:"Invalid operation: there is already an active conversation."},r.privDefaultParams={apiVersion:"api-version",authorization:"Authorization",clientAppId:"X-ClientAppId",contentTypeKey:"Content-Type",correlationId:"X-CorrelationId",languageCode:"language",nickname:"nickname",profanity:"profanity",requestId:"X-RequestId",roomId:"roomid",sessionToken:"token",subscriptionKey:"Ocp-Apim-Subscription-Key",subscriptionRegion:"Ocp-Apim-Subscription-Region",token:"X-CapitoToken"}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceProfileConnectionFactory=t.SpeakerRecognitionConnectionFactory=void 0;const i=r(60),n=r(79),s=r(135),o=r(2),a=r(54);class c extends s.ConnectionFactoryBase{create(e,t,r,c){let p=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Endpoint);if(!p){const t=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Region),i=s.ConnectionFactoryBase.getHostSuffix(t),o=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Host,`wss://${t}.spr-frontend.speech${i}`),a=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_SpeakerIdMode,"TextIndependentIdentification");p=`${o}/speaker/ws/${this.scenarioToPath(a)}/${r}`}const h={format:"simple",language:e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,h,p);const u={};void 0!==t.token&&""!==t.token&&(u[t.headerName]=t.token),u[a.HeaderNames.ConnectionId]=c,u[a.HeaderNames.SpIDAuthKey]=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Key),e.parameters.setProperty(n.PropertyId.SpeechServiceConnection_Url,p);const d="true"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false");return Promise.resolve(new i.WebsocketConnection(p,h,u,new o.WebsocketMessageFormatter,i.ProxyInfo.fromRecognizerConfig(e),d,c))}scenarioToPath(e){switch(e){case"TextIndependentVerification":case"2":return"verification/text-independent";case"TextDependentVerification":case"1":return"verification/text-dependent";default:return"identification/text-independent"}}}t.SpeakerRecognitionConnectionFactory=class extends c{create(e,t,r){return super.create(e,t,"recognition",r)}};t.VoiceProfileConnectionFactory=class extends c{create(e,t,r){return super.create(e,t,"profile",r)}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RecognitionEndedEvent=t.RecognitionCompletionStatus=t.RecognitionStartedEvent=t.ConnectingToServiceEvent=t.ListeningStartedEvent=t.RecognitionTriggeredEvent=t.SpeechRecognitionEvent=void 0;const i=r(4);class n extends i.PlatformEvent{constructor(e,t,r,n=i.EventType.Info){super(e,n),this.privRequestId=t,this.privSessionId=r}get requestId(){return this.privRequestId}get sessionId(){return this.privSessionId}}t.SpeechRecognitionEvent=n;t.RecognitionTriggeredEvent=class extends n{constructor(e,t,r,i){super("RecognitionTriggeredEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=i}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};t.ListeningStartedEvent=class extends n{constructor(e,t,r,i){super("ListeningStartedEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=i}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};t.ConnectingToServiceEvent=class extends n{constructor(e,t,r){super("ConnectingToServiceEvent",e,r),this.privAuthFetchEventid=t}get authFetchEventid(){return this.privAuthFetchEventid}};var s;t.RecognitionStartedEvent=class extends n{constructor(e,t,r,i,n){super("RecognitionStartedEvent",e,n),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=i}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}},function(e){e[e.Success=0]="Success",e[e.AudioSourceError=1]="AudioSourceError",e[e.AudioSourceTimeout=2]="AudioSourceTimeout",e[e.AuthTokenFetchError=3]="AuthTokenFetchError",e[e.AuthTokenFetchTimeout=4]="AuthTokenFetchTimeout",e[e.UnAuthorized=5]="UnAuthorized",e[e.ConnectTimeout=6]="ConnectTimeout",e[e.ConnectError=7]="ConnectError",e[e.ClientRecognitionActivityTimeout=8]="ClientRecognitionActivityTimeout",e[e.UnknownError=9]="UnknownError"}(s=t.RecognitionCompletionStatus||(t.RecognitionCompletionStatus={}));t.RecognitionEndedEvent=class extends n{constructor(e,t,r,n,o,a,c,p){super("RecognitionEndedEvent",e,o,c===s.Success?i.EventType.Info:i.EventType.Error),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=n,this.privStatus=c,this.privError=p,this.privServiceTag=a}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}get serviceTag(){return this.privServiceTag}get status(){return this.privStatus}get error(){return this.privError}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceRecognizerBase=void 0;const i=r(60),n=r(4),s=r(79),o=r(2),a=r(207),c=r(208),p=r(113),h=r(209),u=r(210),d=r(211),v=r(212),l=r(213),g=r(214),m=r(215),f=r(216);class S{constructor(e,t,r,i,a){if(this.privConnectionConfigurationPromise=void 0,this.privConnectionPromise=void 0,this.privSetTimeout=setTimeout,this.privIsLiveAudio=!1,this.privAverageBytesPerMs=0,this.privEnableSpeakerId=!1,this.privExpectContentAssessmentResponse=!1,this.recognizeOverride=void 0,this.recognizeSpeaker=void 0,this.disconnectOverride=void 0,this.receiveMessageOverride=void 0,this.sendPrePayloadJSONOverride=void 0,this.postConnectImplOverride=void 0,this.configConnectionOverride=void 0,this.handleSpeechPhraseMessage=void 0,this.handleSpeechHypothesisMessage=void 0,!e)throw new n.ArgumentNullError("authentication");if(!t)throw new n.ArgumentNullError("connectionFactory");if(!r)throw new n.ArgumentNullError("audioSource");if(!i)throw new n.ArgumentNullError("recognizerConfig");this.privEnableSpeakerId=i.isSpeakerDiarizationEnabled,this.privMustReportEndOfStream=!1,this.privAuthentication=e,this.privConnectionFactory=t,this.privAudioSource=r,this.privRecognizerConfig=i,this.privIsDisposed=!1,this.privRecognizer=a,this.privRequestSession=new o.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new n.EventSource,this.privServiceEvents=new n.EventSource,this.privDynamicGrammar=new o.DynamicGrammarBuilder,this.privSpeechContext=new o.SpeechContext(this.privDynamicGrammar),this.privAgentConfig=new o.AgentConfig;"on"===this.privRecognizerConfig.parameters.getProperty(s.PropertyId.WebWorkerLoadType,"on").toLowerCase()&&"undefined"!=typeof Blob&&"undefined"!=typeof Worker?this.privSetTimeout=n.Timeout.setTimeout:("undefined"!=typeof window&&(this.privSetTimeout=window.setTimeout.bind(window)),"undefined"!=typeof globalThis&&(this.privSetTimeout=globalThis.setTimeout.bind(globalThis))),this.connectionEvents.attach((e=>{if("ConnectionClosedEvent"===e.name){const t=e;(1003===t.statusCode||1007===t.statusCode||1002===t.statusCode||4e3===t.statusCode||this.privRequestSession.numConnectionAttempts>this.privRecognizerConfig.maxRetryCount)&&this.cancelRecognitionLocal(s.CancellationReason.Error,1007===t.statusCode?s.CancellationErrorCode.BadRequestParameters:s.CancellationErrorCode.ConnectionFailure,`${t.reason} websocket error code: ${t.statusCode}`)}})),this.privEnableSpeakerId&&(this.privDiarizationSessionId=(0,n.createNoDashGuid)())}setTranslationJson(){const e=this.privRecognizerConfig.parameters.getProperty(s.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0);if(void 0!==e){const t=e.split(","),r=this.privRecognizerConfig.parameters.getProperty(s.PropertyId.SpeechServiceConnection_TranslationVoice,void 0),i=this.privRecognizerConfig.parameters.getProperty(s.PropertyId.SpeechServiceConnection_TranslationCategoryId,void 0),n=void 0!==r?h.NextAction.Synthesize:h.NextAction.None;if(this.privSpeechContext.getContext().translation={onPassthrough:{action:n},onSuccess:{action:n},output:{includePassThroughResults:!0,interimResults:{mode:u.Mode.Always}},targetLanguages:t},void 0!==i&&(this.privSpeechContext.getContext().translation.category=i),void 0!==r){const e={};for(const i of t)e[i]=r;this.privSpeechContext.getContext().synthesis={defaultVoices:e}}const o=this.privSpeechContext.getContext().phraseDetection||{};o.onSuccess={action:f.NextAction.Translate},o.onInterim={action:f.NextAction.Translate},this.privSpeechContext.getContext().phraseDetection=o}}setSpeechSegmentationTimeoutJson(){const e=this.privRecognizerConfig.parameters.getProperty(s.PropertyId.Speech_SegmentationSilenceTimeoutMs,void 0),t=this.privRecognizerConfig.parameters.getProperty(s.PropertyId.Speech_SegmentationMaximumTimeMs,void 0),r=this.privRecognizerConfig.parameters.getProperty(s.PropertyId.Speech_SegmentationStrategy,void 0),i={mode:c.SegmentationMode.Normal,segmentationForcedTimeoutMs:0,segmentationSilenceTimeoutMs:0};let n=!1;if(void 0!==r){n=!0;let e=c.SegmentationMode.Normal;switch(r.toLowerCase()){case"default":break;case"time":e=c.SegmentationMode.Custom;break;case"semantic":e=c.SegmentationMode.Semantic}i.mode=e}if(void 0!==e){n=!0;const t=parseInt(e,10);i.mode=c.SegmentationMode.Custom,i.segmentationSilenceTimeoutMs=t}if(void 0!==t){n=!0;const e=parseInt(t,10);i.mode=c.SegmentationMode.Custom,i.segmentationForcedTimeoutMs=e}if(n){const e=this.privSpeechContext.getContext().phraseDetection||{};switch(e.mode=this.recognitionMode,this.recognitionMode){case p.RecognitionMode.Conversation:e.conversation=e.conversation??{segmentation:{}},e.conversation.segmentation=i;break;case p.RecognitionMode.Interactive:e.interactive=e.interactive??{segmentation:{}},e.interactive.segmentation=i;break;case p.RecognitionMode.Dictation:e.dictation=e.dictation??{},e.dictation.segmentation=i}this.privSpeechContext.getContext().phraseDetection=e}}setLanguageIdJson(){const e=this.privSpeechContext.getContext().phraseDetection||{};if(void 0!==this.privRecognizerConfig.autoDetectSourceLanguages){const t=this.privRecognizerConfig.autoDetectSourceLanguages.split(",");let r;1===t.length&&t[0]===o.AutoDetectSourceLanguagesOpenRangeOptionName&&(t[0]="UND"),r="Continuous"===this.privRecognizerConfig.languageIdMode?d.LanguageIdDetectionMode.DetectContinuous:d.LanguageIdDetectionMode.DetectAtAudioStart,this.privSpeechContext.getContext().languageId={languages:t,mode:r,onSuccess:{action:v.NextAction.Recognize},onUnknown:{action:l.OnUnknownAction.None},priority:d.LanguageIdDetectionPriority.PrioritizeLatency},this.privSpeechContext.getContext().phraseOutput={interimResults:{resultType:g.ResultType.Auto},phraseResults:{resultType:m.PhraseResultOutputType.Always}};const i=this.privRecognizerConfig.sourceLanguageModels;void 0!==i&&(e.customModels=i,e.onInterim={action:f.NextAction.None},e.onSuccess={action:f.NextAction.None})}this.privSpeechContext.getContext().phraseDetection=e}setOutputDetailLevelJson(){if(this.privEnableSpeakerId){if("true"===this.privRecognizerConfig.parameters.getProperty(s.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase())this.privSpeechContext.setWordLevelTimings();else{this.privRecognizerConfig.parameters.getProperty(o.OutputFormatPropertyName,s.OutputFormat[s.OutputFormat.Simple]).toLowerCase()===s.OutputFormat[s.OutputFormat.Detailed].toLocaleLowerCase()&&this.privSpeechContext.setDetailedOutputFormat()}}}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}get audioSource(){return this.privAudioSource}get speechContext(){return this.privSpeechContext}get dynamicGrammar(){return this.privDynamicGrammar}get agentConfig(){return this.privAgentConfig}set conversationTranslatorToken(e){this.privRecognizerConfig.parameters.setProperty(s.PropertyId.ConversationTranslator_Token,e)}set voiceProfileType(e){this.privRecognizerConfig.parameters.setProperty(s.PropertyId.SpeechServiceConnection_SpeakerIdMode,e)}set authentication(e){this.privAuthentication=e}isDisposed(){return this.privIsDisposed}async dispose(e){if(this.privIsDisposed=!0,void 0!==this.privConnectionPromise)try{const t=await this.privConnectionPromise;await t.dispose(e)}catch(e){return}}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}get recognitionMode(){return this.privRecognizerConfig.recognitionMode}async recognize(e,t,r){if(void 0!==this.recognizeOverride)return void await this.recognizeOverride(e,t,r);if(this.privConnectionConfigurationPromise=void 0,this.privRecognizerConfig.recognitionMode=e,"2"===this.privRecognizerConfig.recognitionEndpointVersion){const t=this.privSpeechContext.getContext().phraseDetection||{};t.mode=e,this.privSpeechContext.getContext().phraseDetection=t}this.setLanguageIdJson(),this.setTranslationJson(),void 0!==this.privRecognizerConfig.autoDetectSourceLanguages&&void 0!==this.privRecognizerConfig.parameters.getProperty(s.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)&&this.setupTranslationWithLanguageId(),this.setSpeechSegmentationTimeoutJson(),this.setOutputDetailLevelJson(),this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events);const n=this.connectImpl();let a;try{const e=await this.audioSource.attach(this.privRequestSession.audioNodeId),t=await this.audioSource.format,r=await this.audioSource.deviceInfo;this.privIsLiveAudio=r.type&&r.type===o.type.Microphones,a=new i.ReplayableAudioNode(e,t.avgBytesPerSec),await this.privRequestSession.onAudioSourceAttachCompleted(a,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:r}}catch(e){throw await this.privRequestSession.onStopRecognizing(),e}try{await n}catch(e){return void await this.cancelRecognitionLocal(s.CancellationReason.Error,s.CancellationErrorCode.ConnectionFailure,e)}const c=new s.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,c),this.receiveMessage();this.sendAudio(a).catch((async e=>{await this.cancelRecognitionLocal(s.CancellationReason.Error,s.CancellationErrorCode.RuntimeError,e)}))}async stopRecognizing(){if(this.privRequestSession.isRecognizing)try{await this.audioSource.turnOff(),await this.sendFinalAudio(),await this.privRequestSession.onStopRecognizing(),await this.privRequestSession.turnCompletionPromise}finally{await this.privRequestSession.dispose()}}async connect(){return await this.connectImpl(),Promise.resolve()}connectAsync(e,t){this.connectImpl().then((()=>{try{e&&e()}catch(e){t&&t(e)}}),(e=>{try{t&&t(e)}catch(e){}}))}async disconnect(){if(await this.cancelRecognitionLocal(s.CancellationReason.Error,s.CancellationErrorCode.NoError,"Disconnecting"),void 0!==this.disconnectOverride&&await this.disconnectOverride(),void 0!==this.privConnectionPromise)try{await(await this.privConnectionPromise).dispose()}catch(e){}this.privConnectionPromise=void 0}sendMessage(e){}async sendNetworkMessage(e,t){const r="string"==typeof t?n.MessageType.Text:n.MessageType.Binary,i="string"==typeof t?"application/json":"";return(await this.fetchConnection()).send(new a.SpeechConnectionMessage(r,e,this.privRequestSession.requestId,i,t))}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set expectContentAssessmentResponse(e){this.privExpectContentAssessmentResponse=e}async sendTelemetryData(){const e=this.privRequestSession.getTelemetry();if(!0!==S.telemetryDataEnabled||this.privIsDisposed||null===e)return;if(S.telemetryData)try{S.telemetryData(e)}catch{}const t=await this.fetchConnection();await t.send(new a.SpeechConnectionMessage(n.MessageType.Text,"telemetry",this.privRequestSession.requestId,"application/json",e))}async cancelRecognitionLocal(e,t,r){this.privRequestSession.isRecognizing&&(await this.privRequestSession.onStopRecognizing(),this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,e,t,r))}async receiveMessage(){try{if(this.privIsDisposed)return;let e=await this.fetchConnection();const t=await e.read();if(void 0!==this.receiveMessageOverride)return this.receiveMessageOverride();if(!t)return this.receiveMessage();this.privServiceHasSentMessage=!0;const r=a.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privRequestSession.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privMustReportEndOfStream=!0,this.privRequestSession.onServiceTurnStartResponse();break;case"speech.startdetected":const t=o.SpeechDetected.fromJSON(r.textBody,this.privRequestSession.currentTurnAudioOffset),i=new s.RecognitionEventArgs(t.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,i);break;case"speech.enddetected":let a;a=r.textBody.length>0?r.textBody:"{ Offset: 0 }";const c=o.SpeechDetected.fromJSON(a,this.privRequestSession.currentTurnAudioOffset),p=new s.RecognitionEventArgs(c.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,p);break;case"turn.end":await this.sendTelemetryData(),this.privRequestSession.isSpeechEnded&&this.privMustReportEndOfStream&&(this.privMustReportEndOfStream=!1,await this.cancelRecognitionLocal(s.CancellationReason.EndOfStream,s.CancellationErrorCode.NoError,void 0));const h=new s.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition),!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing)return void(this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,h));e=await this.fetchConnection(),await this.sendPrePayloadJSON(e);break;default:await this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new n.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch(e){return null}}updateSpeakerDiarizationAudioOffset(){const e=this.privRequestSession.recognitionBytesSent,t=0!==this.privAverageBytesPerMs?e/this.privAverageBytesPerMs:0;this.privSpeechContext.setSpeakerDiarizationAudioOffsetMs(t)}sendSpeechContext(e,t){this.privEnableSpeakerId&&this.updateSpeakerDiarizationAudioOffset();const r=this.speechContext.toJSON();if(t&&this.privRequestSession.onSpeechContext(),r)return e.send(new a.SpeechConnectionMessage(n.MessageType.Text,"speech.context",this.privRequestSession.requestId,"application/json",r))}setupTranslationWithLanguageId(){const e=this.privRecognizerConfig.parameters.getProperty(s.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0),t=void 0!==this.privRecognizerConfig.autoDetectSourceLanguages;if(void 0!==e&&t){this.privSpeechContext.getContext().phraseOutput={interimResults:{resultType:g.ResultType.None},phraseResults:{resultType:m.PhraseResultOutputType.None}};const e=this.privSpeechContext.getContext().translation;if(e){const t=this.privRecognizerConfig.sourceLanguageModels;if(void 0!==t&&t.length>0){const e=this.privSpeechContext.getContext().phraseDetection||{};e.customModels=t,this.privSpeechContext.getContext().phraseDetection=e}void 0!==this.privRecognizerConfig.parameters.getProperty(s.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)&&(e.onSuccess={action:h.NextAction.Synthesize},e.onPassthrough={action:h.NextAction.Synthesize})}}}noOp(){}async sendPrePayloadJSON(e,t=!0){if(void 0!==this.sendPrePayloadJSONOverride)return this.sendPrePayloadJSONOverride(e);await this.sendSpeechContext(e,t),await this.sendWaveHeader(e)}async sendWaveHeader(e){const t=await this.audioSource.format;return e.send(new a.SpeechConnectionMessage(n.MessageType.Binary,"audio",this.privRequestSession.requestId,"audio/x-wav",t.header))}connectImpl(){return void 0!==this.privConnectionPromise?this.privConnectionPromise.then((e=>e.state()===n.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl()):this.privConnectionPromise),(()=>(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl()))):(this.privConnectionPromise=this.retryableConnect(),this.privConnectionPromise.catch((()=>{})),void 0!==this.postConnectImplOverride?this.postConnectImplOverride(this.privConnectionPromise):this.privConnectionPromise)}sendSpeechServiceConfig(e,t,r){if(t.onSpeechContext(),!0!==S.telemetryDataEnabled){const e={context:{system:JSON.parse(r).context.system}};r=JSON.stringify(e)}if("true"===this.privRecognizerConfig.parameters.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()){const e=JSON.parse(r);e.context.DisableReferenceChannel="True",e.context.MicSpec="1_0_0",r=JSON.stringify(e)}if(r)return e.send(new a.SpeechConnectionMessage(n.MessageType.Text,"speech.config",t.requestId,"application/json",r))}async fetchConnection(){return void 0!==this.privConnectionConfigurationPromise?this.privConnectionConfigurationPromise.then((e=>e.state()===n.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection()):this.privConnectionConfigurationPromise),(()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection()))):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async sendAudio(e){const t=await this.audioSource.format;this.privAverageBytesPerMs=t.avgBytesPerSec/1e3;let r=Date.now();const i=this.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs","5000"),s=t.avgBytesPerSec/1e3*parseInt(i,10),o=this.privRequestSession.recogNumber,c=async()=>{if(!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o){const i=await this.fetchConnection(),p=await e.read();if(this.privRequestSession.isSpeechEnded)return;let h,u;if(!p||p.isEnd?(h=null,u=0):(h=p.buffer,this.privRequestSession.onAudioSent(h.byteLength),u=s>=this.privRequestSession.bytesSent?0:Math.max(0,r-Date.now())),0!==u&&await this.delay(u),null!==h&&(r=Date.now()+1e3*h.byteLength/(2*t.avgBytesPerSec)),!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o){if(i.send(new a.SpeechConnectionMessage(n.MessageType.Binary,"audio",this.privRequestSession.requestId,null,h)).catch((()=>{this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition).catch((()=>{}))})),!p?.isEnd)return c();this.privIsLiveAudio||this.privRequestSession.onSpeechEnded()}}};return c()}async retryableConnect(){let e=!1;this.privAuthFetchEventId=(0,n.createNoDashGuid)();const t=this.privRequestSession.sessionId;this.privConnectionId=void 0!==t?t:(0,n.createNoDashGuid)(),this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId,this.privConnectionId);let r=0,i="";for(;this.privRequestSession.numConnectionAttempts<=this.privRecognizerConfig.maxRetryCount;){this.privRequestSession.onRetryConnection();const t=e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId),n=await t;await this.privRequestSession.onAuthCompleted(!1);const s=await this.privConnectionFactory.create(this.privRecognizerConfig,n,this.privConnectionId);this.privRequestSession.listenForServiceTelemetry(s.events),s.events.attach((e=>{this.connectionEvents.onEvent(e)}));const o=await s.open();if(200===o.statusCode)return await this.privRequestSession.onConnectionEstablishCompleted(o.statusCode),Promise.resolve(s);1006===o.statusCode&&(e=!0),r=o.statusCode,i=o.reason}return await this.privRequestSession.onConnectionEstablishCompleted(r,i),Promise.reject(`Unable to contact server. StatusCode: ${r}, ${this.privRecognizerConfig.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${i}`)}delay(e){return new Promise((t=>this.privSetTimeout(t,e)))}writeBufferToConsole(e){let t="Buffer Size: ";if(null===e)t+="null";else{const r=new Uint8Array(e);t+=`${e.byteLength}\r\n`;for(let i=0;i<e.byteLength;i++)t+=r[i].toString(16).padStart(2,"0")+" ",(i+1)%16==0&&(console.info(t),t="")}console.info(t)}async sendFinalAudio(){const e=await this.fetchConnection();await e.send(new a.SpeechConnectionMessage(n.MessageType.Binary,"audio",this.privRequestSession.requestId,null,null))}async configureConnection(){const e=await this.connectImpl();return void 0!==this.configConnectionOverride?this.configConnectionOverride(e):(await this.sendSpeechServiceConfig(e,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendPrePayloadJSON(e,!1),e)}}t.ServiceRecognizerBase=S,S.telemetryDataEnabled=!0},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechConnectionMessage=void 0;const i=r(4),n=r(54);class s extends i.ConnectionMessage{constructor(e,t,r,s,o,a,c,p){if(!t)throw new i.ArgumentNullError("path");if(!r)throw new i.ArgumentNullError("requestId");const h={};if(h[n.HeaderNames.Path]=t,h[n.HeaderNames.RequestId]=r,h[n.HeaderNames.RequestTimestamp]=(new Date).toISOString(),s&&(h[n.HeaderNames.ContentType]=s),a&&(h[n.HeaderNames.RequestStreamId]=a),c)for(const e in c)e&&(h[e]=c[e]);p?super(e,o,h,p):super(e,o,h),this.privPath=t,this.privRequestId=r,this.privContentType=s,this.privStreamId=a,this.privAdditionalHeaders=c}get path(){return this.privPath}get requestId(){return this.privRequestId}get contentType(){return this.privContentType}get streamId(){return this.privStreamId}get additionalHeaders(){return this.privAdditionalHeaders}static fromConnectionMessage(e){let t=null,r=null,i=null,o=null;const a={};if(e.headers)for(const s in e.headers)s&&(s.toLowerCase()===n.HeaderNames.Path.toLowerCase()?t=e.headers[s]:s.toLowerCase()===n.HeaderNames.RequestId.toLowerCase()?r=e.headers[s]:s.toLowerCase()===n.HeaderNames.ContentType.toLowerCase()?i=e.headers[s]:s.toLowerCase()===n.HeaderNames.RequestStreamId.toLowerCase()?o=e.headers[s]:a[s]=e.headers[s]);return new s(e.messageType,t,r,i,e.body,o,a,e.id)}}t.SpeechConnectionMessage=s},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SegmentationMode=void 0,function(e){e.Normal="Normal",e.Disabled="Disabled",e.Custom="Custom",e.Semantic="Semantic"}(t.SegmentationMode||(t.SegmentationMode={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NextAction=void 0,function(e){e.None="None",e.Synthesize="Synthesize"}(t.NextAction||(t.NextAction={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Mode=void 0,function(e){e.None="None",e.Always="Always"}(t.Mode||(t.Mode={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LanguageIdDetectionPriority=t.LanguageIdDetectionMode=void 0,function(e){e.DetectAtAudioStart="DetectAtAudioStart",e.DetectContinuous="DetectContinuous",e.DetectSegments="DetectSegments"}(t.LanguageIdDetectionMode||(t.LanguageIdDetectionMode={})),function(e){e.Auto="Auto",e.PrioritizeLatency="PrioritizeLatency",e.PrioritizeAccuracy="PrioritizeAccuracy"}(t.LanguageIdDetectionPriority||(t.LanguageIdDetectionPriority={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NextAction=void 0,function(e){e.Recognize="Recognize",e.None="None"}(t.NextAction||(t.NextAction={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OnUnknownAction=void 0,function(e){e.RecognizeWithDefaultLanguage="RecognizeWithDefaultLanguage",e.None="None"}(t.OnUnknownAction||(t.OnUnknownAction={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ResultType=void 0,function(e){e.Auto="Auto",e.StableFragment="StableFragment",e.Hypothesis="Hypothesis",e.None="None"}(t.ResultType||(t.ResultType={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PhraseResultOutputType=void 0,function(e){e.Always="Always",e.None="None"}(t.PhraseResultOutputType||(t.PhraseResultOutputType={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NextAction=void 0,function(e){e.None="None",e.Translate="Translate"}(t.NextAction||(t.NextAction={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationServiceRecognizer=void 0;const i=r(79),n=r(2);class s extends n.ServiceRecognizerBase{constructor(e,t,r,i,n){super(e,t,r,i,n),this.handleSpeechPhraseMessage=async e=>this.handleSpeechPhrase(e),this.handleSpeechHypothesisMessage=e=>this.handleSpeechHypothesis(e)}processTypeSpecificMessages(e){}handleRecognizedCallback(e,t,r){}handleRecognizingCallback(e,t,r){}async processSpeechMessages(e){let t=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":this.handleSpeechHypothesisMessage&&this.handleSpeechHypothesisMessage(e.textBody),t=!0;break;case"speech.phrase":this.handleSpeechPhraseMessage&&await this.handleSpeechPhraseMessage(e.textBody),t=!0}return t}cancelRecognition(e,t,r,i,n){}async handleSpeechPhrase(e){const t=n.SimpleSpeechPhrase.fromJSON(e,this.privRequestSession.currentTurnAudioOffset),r=n.EnumTranslation.implTranslateRecognitionResult(t.RecognitionStatus);let s;const o=new i.PropertyCollection;if(o.setProperty(i.PropertyId.SpeechServiceResponse_JsonResult,e),this.privRequestSession.onPhraseRecognized(t.Offset+t.Duration),i.ResultReason.Canceled===r){const e=n.EnumTranslation.implTranslateCancelResult(t.RecognitionStatus),r=n.EnumTranslation.implTranslateCancelErrorCode(t.RecognitionStatus);await this.cancelRecognitionLocal(e,r,n.EnumTranslation.implTranslateErrorDetails(r))}else if(t.RecognitionStatus!==n.RecognitionStatus.EndOfDictation){if(this.privRecognizerConfig.parameters.getProperty(n.OutputFormatPropertyName)===i.OutputFormat[i.OutputFormat.Simple])s=new i.SpeechRecognitionResult(this.privRequestSession.requestId,r,t.DisplayText,t.Duration,t.Offset,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,t.asJson(),o);else{const t=n.DetailedSpeechPhrase.fromJSON(e,this.privRequestSession.currentTurnAudioOffset);s=new i.SpeechRecognitionResult(this.privRequestSession.requestId,r,t.Text,t.Duration,t.Offset,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,t.asJson(),o)}this.handleRecognizedCallback(s,s.offset,this.privRequestSession.sessionId)}}handleSpeechHypothesis(e){const t=n.SpeechHypothesis.fromJSON(e,this.privRequestSession.currentTurnAudioOffset),r=new i.PropertyCollection;r.setProperty(i.PropertyId.SpeechServiceResponse_JsonResult,e);const s=new i.SpeechRecognitionResult(this.privRequestSession.requestId,i.ResultReason.RecognizingSpeech,t.Text,t.Duration,t.Offset,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,t.asJson(),r);this.privRequestSession.onHypothesis(t.Offset),this.handleRecognizingCallback(s,t.Duration,this.privRequestSession.sessionId)}}t.ConversationServiceRecognizer=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RecognizerConfig=t.SpeechResultFormat=void 0;const i=r(79),n=r(2),s=r(113);!function(e){e[e.Simple=0]="Simple",e[e.Detailed=1]="Detailed"}(t.SpeechResultFormat||(t.SpeechResultFormat={}));t.RecognizerConfig=class{constructor(e,t){this.privSpeechServiceConfig=e||new n.SpeechServiceConfig(new n.Context(null)),this.privParameters=t,this.privMaxRetryCount=parseInt(t.getProperty("SPEECH-Error-MaxRetryCount","4"),10),this.privLanguageIdMode=t.getProperty(i.PropertyId.SpeechServiceConnection_LanguageIdMode,void 0),this.privEnableSpeakerId=!1}get parameters(){return this.privParameters}get recognitionMode(){return this.privRecognitionMode}set recognitionMode(e){this.privRecognitionMode=e,this.privRecognitionActivityTimeout=e===s.RecognitionMode.Interactive?8e3:25e3,this.privSpeechServiceConfig.Recognition=s.RecognitionMode[e]}get SpeechServiceConfig(){return this.privSpeechServiceConfig}get recognitionActivityTimeout(){return this.privRecognitionActivityTimeout}get isContinuousRecognition(){return this.privRecognitionMode!==s.RecognitionMode.Interactive}get languageIdMode(){return this.privLanguageIdMode}get autoDetectSourceLanguages(){return this.parameters.getProperty(i.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,void 0)}get recognitionEndpointVersion(){return this.parameters.getProperty(i.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2")}set recognitionEndpointVersion(e){this.parameters.setProperty(i.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,e)}get sourceLanguageModels(){const e=[];let t=!1;if(void 0!==this.autoDetectSourceLanguages)for(const r of this.autoDetectSourceLanguages.split(",")){const n=r+i.PropertyId.SpeechServiceConnection_EndpointId.toString(),s=this.parameters.getProperty(n,void 0);void 0!==s?(e.push({language:r,endpoint:s}),t=!0):e.push({language:r,endpoint:""})}return t?e:void 0}get maxRetryCount(){return this.privMaxRetryCount}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}set isSpeakerDiarizationEnabled(e){this.privEnableSpeakerId=e}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebsocketMessageFormatter=void 0;const i=r(4);t.WebsocketMessageFormatter=class{toConnectionMessage(e){const t=new i.Deferred;try{if(e.messageType===i.MessageType.Text){const r=e.textContent;let n={},s=null;if(r){const e=r.split("\r\n\r\n");e&&e.length>0&&(n=this.parseHeaders(e[0]),e.length>1&&(s=e[1]))}t.resolve(new i.ConnectionMessage(e.messageType,s,n,e.id))}else if(e.messageType===i.MessageType.Binary){const r=e.binaryContent;let n={},s=null;if(!r||r.byteLength<2)throw new Error("Invalid binary message format. Header length missing.");const o=new DataView(r),a=o.getInt16(0);if(r.byteLength<a+2)throw new Error("Invalid binary message format. Header content missing.");let c="";for(let e=0;e<a;e++)c+=String.fromCharCode(o.getInt8(e+2));n=this.parseHeaders(c),r.byteLength>a+2&&(s=r.slice(2+a)),t.resolve(new i.ConnectionMessage(e.messageType,s,n,e.id))}}catch(e){t.reject(`Error formatting the message. Error: ${e}`)}return t.promise}fromConnectionMessage(e){const t=new i.Deferred;try{if(e.messageType===i.MessageType.Text){const r=`${this.makeHeaders(e)}\r\n${e.textBody?e.textBody:""}`;t.resolve(new i.RawWebsocketMessage(i.MessageType.Text,r,e.id))}else if(e.messageType===i.MessageType.Binary){const r=this.makeHeaders(e),n=e.binaryBody,s=this.stringToArrayBuffer(r),o=new Int8Array(s),a=o.byteLength,c=new Int8Array(2+a+(n?n.byteLength:0));if(c[0]=a>>8&255,c[1]=255&a,c.set(o,2),n){const e=new Int8Array(n);c.set(e,2+a)}const p=c.buffer;t.resolve(new i.RawWebsocketMessage(i.MessageType.Binary,p,e.id))}}catch(e){t.reject(`Error formatting the message. ${e}`)}return t.promise}makeHeaders(e){let t="";if(e.headers)for(const r in e.headers)r&&(t+=`${r}: ${e.headers[r]}\r\n`);return t}parseHeaders(e){const t={};if(e){const r=e.match(/[^\r\n]+/g);if(t)for(const e of r)if(e){const r=e.indexOf(":"),i=r>0?e.substr(0,r).trim().toLowerCase():e,n=r>0&&e.length>r+1?e.substr(r+1).trim():"";t[i]=n}}return t}stringToArrayBuffer(e){const t=new ArrayBuffer(e.length),r=new DataView(t);for(let t=0;t<e.length;t++)r.setUint8(t,e.charCodeAt(t));return t}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechConnectionFactory=void 0;const i=r(60),n=r(2),s=r(79),o=r(135),a=r(2),c=r(54),p=r(136),h=r(113);class u extends o.ConnectionFactoryBase{constructor(){super(...arguments),this.interactiveRelativeUri="/speech/recognition/interactive/cognitiveservices/v1",this.conversationRelativeUri="/speech/recognition/conversation/cognitiveservices/v1",this.dictationRelativeUri="/speech/recognition/dictation/cognitiveservices/v1",this.universalUri="/stt/speech/universal/v"}async create(e,t,r){let u=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Endpoint,void 0);const d=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Region,void 0),v=o.ConnectionFactoryBase.getHostSuffix(d),l=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Host,"wss://"+d+".stt.speech"+v),g={},m=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_EndpointId,void 0),f=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(m?u&&-1!==u.search(p.QueryParameterNames.CustomSpeechDeploymentId)||(g[p.QueryParameterNames.CustomSpeechDeploymentId]=m):f&&(u&&-1!==u.search(p.QueryParameterNames.Language)||(g[p.QueryParameterNames.Language]=f)),u&&-1!==u.search(p.QueryParameterNames.Format)||(g[p.QueryParameterNames.Format]=e.parameters.getProperty(n.OutputFormatPropertyName,s.OutputFormat[s.OutputFormat.Simple]).toLowerCase()),void 0!==e.autoDetectSourceLanguages&&(g[p.QueryParameterNames.EnableLanguageId]="true"),this.setCommonUrlParams(e,g,u),u){const t=new URL(u),r=t.pathname;""!==r&&"/"!==r||(t.pathname=this.universalUri+e.recognitionEndpointVersion,u=await o.ConnectionFactoryBase.getRedirectUrlFromEndpoint(t.toString()))}if(!u)switch(e.recognitionMode){case h.RecognitionMode.Conversation:u="true"===e.parameters.getProperty(n.ForceDictationPropertyName,"false")?l+this.dictationRelativeUri:void 0!==e.recognitionEndpointVersion&&parseInt(e.recognitionEndpointVersion,10)>1?`${l}${this.universalUri}${e.recognitionEndpointVersion}`:l+this.conversationRelativeUri;break;case h.RecognitionMode.Dictation:u=l+this.dictationRelativeUri;break;default:u=void 0!==e.recognitionEndpointVersion&&parseInt(e.recognitionEndpointVersion,10)>1?`${l}${this.universalUri}${e.recognitionEndpointVersion}`:l+this.interactiveRelativeUri}const S={};void 0!==t.token&&""!==t.token&&(S[t.headerName]=t.token),S[c.HeaderNames.ConnectionId]=r,S.connectionId=r;const y="true"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false"),C=new i.WebsocketConnection(u,g,S,new a.WebsocketMessageFormatter,i.ProxyInfo.fromRecognizerConfig(e),y,r),P=C.uri;return e.parameters.setProperty(s.PropertyId.SpeechServiceConnection_Url,P),C}}t.SpeechConnectionFactory=u},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranscriberConnectionFactory=void 0;const i=r(60),n=r(79),s=r(2),o=r(135),a=r(2),c=r(54),p=r(136);class h extends o.ConnectionFactoryBase{constructor(){super(...arguments),this.universalUri="/speech/universal/v2"}async create(e,t,r){let s=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Endpoint,void 0);const h=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Region,void 0),u=o.ConnectionFactoryBase.getHostSuffix(h),d=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Host,"wss://"+h+".stt.speech"+u),v={},l=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_EndpointId,void 0),g=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(l?s&&-1!==s.search(p.QueryParameterNames.CustomSpeechDeploymentId)||(v[p.QueryParameterNames.CustomSpeechDeploymentId]=l):g&&(s&&-1!==s.search(p.QueryParameterNames.Language)||(v[p.QueryParameterNames.Language]=g)),void 0!==e.autoDetectSourceLanguages&&(v[p.QueryParameterNames.EnableLanguageId]="true"),this.setV2UrlParams(e,v,s),s){const e=new URL(s),t=e.pathname;""!==t&&"/"!==t||(e.pathname=this.universalUri,s=await o.ConnectionFactoryBase.getRedirectUrlFromEndpoint(e.toString()))}s||(s=`${d}${this.universalUri}`);const m={};void 0!==t.token&&""!==t.token&&(m[t.headerName]=t.token),m[c.HeaderNames.ConnectionId]=r;const f="true"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false"),S=new i.WebsocketConnection(s,v,m,new a.WebsocketMessageFormatter,i.ProxyInfo.fromRecognizerConfig(e),f,r),y=S.uri;return e.parameters.setProperty(n.PropertyId.SpeechServiceConnection_Url,y),S}setV2UrlParams(e,t,r){new Map([[n.PropertyId.Speech_SegmentationSilenceTimeoutMs,p.QueryParameterNames.SegmentationSilenceTimeoutMs],[n.PropertyId.SpeechServiceConnection_EnableAudioLogging,p.QueryParameterNames.EnableAudioLogging],[n.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,p.QueryParameterNames.EndSilenceTimeoutMs],[n.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,p.QueryParameterNames.InitialSilenceTimeoutMs],[n.PropertyId.SpeechServiceResponse_PostProcessingOption,p.QueryParameterNames.Postprocessing],[n.PropertyId.SpeechServiceResponse_ProfanityOption,p.QueryParameterNames.Profanity],[n.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,p.QueryParameterNames.StableIntermediateThreshold]]).forEach(((i,n)=>{this.setUrlParameter(n,i,e,t,r)}));const i=JSON.parse(e.parameters.getProperty(s.ServicePropertiesPropertyName,"{}"));Object.keys(i).forEach((e=>{t[e]=i[e]}))}}t.ConversationTranscriberConnectionFactory=h},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranscriberConnectionFactory=void 0;const i=r(60),n=r(79),s=r(135),o=r(2),a=r(54),c=r(136);class p extends s.ConnectionFactoryBase{constructor(){super(...arguments),this.multiaudioRelativeUri="/speech/recognition/multiaudio"}create(e,t,r){let c=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Endpoint,void 0);const p=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Region,"centralus"),h="wss://transcribe."+p+".cts.speech"+s.ConnectionFactoryBase.getHostSuffix(p)+this.multiaudioRelativeUri,u=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Host,h),d={};this.setQueryParams(d,e,c),c||(c=u);const v={};void 0!==t.token&&""!==t.token&&(v[t.headerName]=t.token),v[a.HeaderNames.ConnectionId]=r,e.parameters.setProperty(n.PropertyId.SpeechServiceConnection_Url,c);const l="true"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false");return Promise.resolve(new i.WebsocketConnection(c,d,v,new o.WebsocketMessageFormatter,i.ProxyInfo.fromRecognizerConfig(e),l,r))}setQueryParams(e,t,r){const i=t.parameters.getProperty(n.PropertyId.SpeechServiceConnection_EndpointId,void 0),s=t.parameters.getProperty(n.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);i&&!(c.QueryParameterNames.CustomSpeechDeploymentId in e)&&(e[c.QueryParameterNames.CustomSpeechDeploymentId]=i),s&&!(c.QueryParameterNames.Language in e)&&(e[c.QueryParameterNames.Language]=s);const a="true"===t.parameters.getProperty(n.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase(),p=t.parameters.getProperty(o.OutputFormatPropertyName,n.OutputFormat[n.OutputFormat.Simple])!==n.OutputFormat[n.OutputFormat.Simple];(a||p)&&(e[c.QueryParameterNames.Format]=n.OutputFormat[n.OutputFormat.Detailed].toLowerCase()),this.setCommonUrlParams(t,e,r)}}t.TranscriberConnectionFactory=p},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationConnectionFactory=void 0;const i=r(60),n=r(167),s=r(79),o=r(135),a=r(2),c=r(54),p=r(136),h=r(113);class u extends o.ConnectionFactoryBase{constructor(){super(...arguments),this.universalUri="/stt/speech/universal/v2",this.translationV1Uri="/speech/translation/cognitiveservices/v1"}async create(e,t,r){let n=this.getEndpointUrl(e);const p={};if(this.setQueryParams(p,e,n),n){const e=new URL(n),t=e.pathname;""!==t&&"/"!==t||(e.pathname=this.universalUri,n=await o.ConnectionFactoryBase.getRedirectUrlFromEndpoint(e.toString()))}const h={};void 0!==t.token&&""!==t.token&&(h[t.headerName]=t.token),h[c.HeaderNames.ConnectionId]=r,e.parameters.setProperty(s.PropertyId.SpeechServiceConnection_Url,n);const u="true"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false");return new i.WebsocketConnection(n,p,h,new a.WebsocketMessageFormatter,i.ProxyInfo.fromRecognizerConfig(e),u,r)}getEndpointUrl(e,t){const r=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Region),i=o.ConnectionFactoryBase.getHostSuffix(r);let a=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Endpoint,void 0);if(a)return!0===t?a:n.StringUtils.formatString(a,{region:r});if("true"===e.parameters.getProperty("SPEECH-ForceV1Endpoint","false")){a=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Host,"wss://{region}.s2s.speech"+i)+this.translationV1Uri}else{a=e.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Host,"wss://{region}.stt.speech"+i)+this.universalUri}return!0===t?a:n.StringUtils.formatString(a,{region:r})}setQueryParams(e,t,r){e.from=t.parameters.getProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage),e.to=t.parameters.getProperty(s.PropertyId.SpeechServiceConnection_TranslationToLanguages),e.scenario=t.recognitionMode===h.RecognitionMode.Interactive?"interactive":t.recognitionMode===h.RecognitionMode.Conversation?"conversation":"",this.setCommonUrlParams(t,e,r),this.setUrlParameter(s.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,p.QueryParameterNames.StableTranslation,t,e,r);const i=t.parameters.getProperty(s.PropertyId.SpeechServiceConnection_TranslationVoice,void 0);void 0!==i&&(e.voice=i,e.features="requireVoice")}}t.TranslationConnectionFactory=u},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnumTranslation=void 0;const i=r(79),n=r(2);t.EnumTranslation=class{static implTranslateRecognitionResult(e,t=!1){let r=i.ResultReason.Canceled;switch(e){case n.RecognitionStatus.Success:r=i.ResultReason.RecognizedSpeech;break;case n.RecognitionStatus.EndOfDictation:r=t?i.ResultReason.RecognizedSpeech:i.ResultReason.NoMatch;break;case n.RecognitionStatus.NoMatch:case n.RecognitionStatus.InitialSilenceTimeout:case n.RecognitionStatus.BabbleTimeout:r=i.ResultReason.NoMatch;break;case n.RecognitionStatus.Error:case n.RecognitionStatus.BadRequest:case n.RecognitionStatus.Forbidden:default:r=i.ResultReason.Canceled}return r}static implTranslateCancelResult(e){let t=i.CancellationReason.EndOfStream;switch(e){case n.RecognitionStatus.Success:case n.RecognitionStatus.EndOfDictation:case n.RecognitionStatus.NoMatch:t=i.CancellationReason.EndOfStream;break;case n.RecognitionStatus.InitialSilenceTimeout:case n.RecognitionStatus.BabbleTimeout:case n.RecognitionStatus.Error:case n.RecognitionStatus.BadRequest:case n.RecognitionStatus.Forbidden:default:t=i.CancellationReason.Error}return t}static implTranslateCancelErrorCode(e){let t=i.CancellationErrorCode.NoError;switch(e){case n.RecognitionStatus.Error:t=i.CancellationErrorCode.ServiceError;break;case n.RecognitionStatus.TooManyRequests:t=i.CancellationErrorCode.TooManyRequests;break;case n.RecognitionStatus.BadRequest:t=i.CancellationErrorCode.BadRequestParameters;break;case n.RecognitionStatus.Forbidden:t=i.CancellationErrorCode.Forbidden;break;default:t=i.CancellationErrorCode.NoError}return t}static implTranslateErrorDetails(e){let t="The speech service encountered an internal error and could not continue.";switch(e){case i.CancellationErrorCode.Forbidden:t="The recognizer is using a free subscription that ran out of quota.";break;case i.CancellationErrorCode.BadRequestParameters:t="Invalid parameter or unsupported audio format in the request.";break;case i.CancellationErrorCode.TooManyRequests:t="The number of parallel requests exceeded the number of allowed concurrent transcriptions."}return t}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RecognitionStatus=t.SynthesisStatus=void 0,function(e){e[e.Success=0]="Success",e[e.SynthesisEnd=1]="SynthesisEnd",e[e.Error=2]="Error"}(t.SynthesisStatus||(t.SynthesisStatus={})),function(e){e[e.Success=0]="Success",e[e.NoMatch=1]="NoMatch",e[e.InitialSilenceTimeout=2]="InitialSilenceTimeout",e[e.BabbleTimeout=3]="BabbleTimeout",e[e.Error=4]="Error",e[e.EndOfDictation=5]="EndOfDictation",e[e.TooManyRequests=6]="TooManyRequests",e[e.BadRequest=7]="BadRequest",e[e.Forbidden=8]="Forbidden"}(t.RecognitionStatus||(t.RecognitionStatus={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationSynthesisEnd=void 0;const i=r(2);class n{constructor(e){this.privSynthesisEnd=JSON.parse(e),this.privSynthesisEnd.SynthesisStatus&&(this.privSynthesisEnd.SynthesisStatus=i.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]),this.privSynthesisEnd.Status&&(this.privSynthesisEnd.SynthesisStatus=i.SynthesisStatus[this.privSynthesisEnd.Status])}static fromJSON(e){return new n(e)}get SynthesisStatus(){return this.privSynthesisEnd.SynthesisStatus}get FailureReason(){return this.privSynthesisEnd.FailureReason}}t.TranslationSynthesisEnd=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationHypothesis=void 0;const i=r(64),n=r(48);class s{constructor(e,t){this.privTranslationHypothesis=e,this.privTranslationHypothesis.Offset+=t,this.privTranslationHypothesis.Translation.TranslationStatus=this.mapTranslationStatus(this.privTranslationHypothesis.Translation.TranslationStatus)}static fromJSON(e,t){return new s(JSON.parse(e),t)}static fromTranslationResponse(e,t){i.Contracts.throwIfNullOrUndefined(e,"translationHypothesis");const r=e.SpeechHypothesis;return e.SpeechHypothesis=void 0,r.Translation=e,new s(r,t)}get Duration(){return this.privTranslationHypothesis.Duration}get Offset(){return this.privTranslationHypothesis.Offset}get Text(){return this.privTranslationHypothesis.Text}get Translation(){return this.privTranslationHypothesis.Translation}get Language(){return this.privTranslationHypothesis.PrimaryLanguage?.Language}asJson(){const e={...this.privTranslationHypothesis};return void 0!==e.Translation?JSON.stringify({...e,TranslationStatus:n.TranslationStatus[e.Translation.TranslationStatus]}):JSON.stringify(e)}mapTranslationStatus(e){return"string"==typeof e?n.TranslationStatus[e]:"number"==typeof e?e:void 0}}t.TranslationHypothesis=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationPhrase=void 0;const i=r(64),n=r(2),s=r(48);class o{constructor(e,t){this.privTranslationPhrase=e,this.privTranslationPhrase.Offset+=t,this.privTranslationPhrase.RecognitionStatus=this.mapRecognitionStatus(this.privTranslationPhrase.RecognitionStatus),void 0!==this.privTranslationPhrase.Translation&&(this.privTranslationPhrase.Translation.TranslationStatus=this.mapTranslationStatus(this.privTranslationPhrase.Translation.TranslationStatus))}static fromJSON(e,t){return new o(JSON.parse(e),t)}static fromTranslationResponse(e,t){i.Contracts.throwIfNullOrUndefined(e,"translationResponse");const r=e.SpeechPhrase;return e.SpeechPhrase=void 0,r.Translation=e,r.Text=r.DisplayText,new o(r,t)}get RecognitionStatus(){return this.privTranslationPhrase.RecognitionStatus}get Offset(){return this.privTranslationPhrase.Offset}get Duration(){return this.privTranslationPhrase.Duration}get Text(){return this.privTranslationPhrase.Text}get Language(){return this.privTranslationPhrase.PrimaryLanguage?.Language}get Confidence(){return this.privTranslationPhrase.PrimaryLanguage?.Confidence}get Translation(){return this.privTranslationPhrase.Translation}asJson(){const e={...this.privTranslationPhrase},t={...e,RecognitionStatus:n.RecognitionStatus[e.RecognitionStatus]};return e.Translation&&(t.Translation={...e.Translation,TranslationStatus:s.TranslationStatus[e.Translation.TranslationStatus]}),JSON.stringify(t)}mapRecognitionStatus(e){return"string"==typeof e?n.RecognitionStatus[e]:"number"==typeof e?e:void 0}mapTranslationStatus(e){return"string"==typeof e?s.TranslationStatus[e]:"number"==typeof e?e:void 0}}t.TranslationPhrase=o},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationServiceRecognizer=void 0;const i=r(4),n=r(79),s=r(2);class o extends s.ConversationServiceRecognizer{constructor(e,t,r,i,n){super(e,t,r,i,n),this.privTranslationRecognizer=n,this.connectionEvents.attach((e=>{"ConnectionEstablishedEvent"===e.name&&this.privTranslationRecognizer.onConnection()}))}async processTypeSpecificMessages(e){const t=new n.PropertyCollection;let r=await this.processSpeechMessages(e);if(r)return!0;const o=async e=>{if(t.setProperty(n.PropertyId.SpeechServiceResponse_JsonResult,e.asJson()),this.privRequestSession.onPhraseRecognized(e.Offset+e.Duration),e.RecognitionStatus===s.RecognitionStatus.Success){const r=this.fireEventForResult(e,t);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,r)}catch(e){}if(this.privSuccessCallback){try{this.privSuccessCallback(r.result)}catch(e){this.privErrorCallback&&this.privErrorCallback(e)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}else{const i=s.EnumTranslation.implTranslateRecognitionResult(e.RecognitionStatus),o=new n.TranslationRecognitionResult(void 0,this.privRequestSession.requestId,i,e.Text,e.Duration,e.Offset,e.Language,e.Confidence,void 0,e.asJson(),t);if(i===n.ResultReason.Canceled){const t=s.EnumTranslation.implTranslateCancelResult(e.RecognitionStatus),r=s.EnumTranslation.implTranslateCancelErrorCode(e.RecognitionStatus);await this.cancelRecognitionLocal(t,r,s.EnumTranslation.implTranslateErrorDetails(r))}else if(e.RecognitionStatus!==s.RecognitionStatus.EndOfDictation){const e=new n.TranslationRecognitionEventArgs(o,o.offset,this.privRequestSession.sessionId);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,e)}catch(e){}if(this.privSuccessCallback){try{this.privSuccessCallback(o)}catch(e){this.privErrorCallback&&this.privErrorCallback(e)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}r=!0}},a=e=>{t.setProperty(n.PropertyId.SpeechServiceResponse_JsonResult,e.asJson());const i=this.fireEventForResult(e,t);if(this.privRequestSession.onHypothesis(i.offset),this.privTranslationRecognizer.recognizing)try{this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,i)}catch(e){}r=!0};switch(e.messageType===i.MessageType.Text&&t.setProperty(n.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"translation.hypothesis":a(s.TranslationHypothesis.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset));break;case"translation.response":const t=JSON.parse(e.textBody);if(t.SpeechPhrase)await o(s.TranslationPhrase.fromTranslationResponse(t,this.privRequestSession.currentTurnAudioOffset));else{const t=JSON.parse(e.textBody);t.SpeechHypothesis&&a(s.TranslationHypothesis.fromTranslationResponse(t,this.privRequestSession.currentTurnAudioOffset))}break;case"translation.phrase":await o(s.TranslationPhrase.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset));break;case"translation.synthesis":case"audio":this.sendSynthesisAudio(e.binaryBody,this.privRequestSession.sessionId),r=!0;break;case"audio.end":case"translation.synthesis.end":const i=s.TranslationSynthesisEnd.fromJSON(e.textBody);switch(i.SynthesisStatus){case s.SynthesisStatus.Error:if(this.privTranslationRecognizer.synthesizing){const e=new n.TranslationSynthesisResult(n.ResultReason.Canceled,void 0),t=new n.TranslationSynthesisEventArgs(e,this.privRequestSession.sessionId);try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,t)}catch(e){}}if(this.privTranslationRecognizer.canceled){const e=new n.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId,n.CancellationReason.Error,i.FailureReason,n.CancellationErrorCode.ServiceError,null);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,e)}catch(e){}}break;case s.SynthesisStatus.Success:this.sendSynthesisAudio(void 0,this.privRequestSession.sessionId)}r=!0}return r}cancelRecognition(e,t,r,i,o){const a=new n.PropertyCollection;if(a.setProperty(s.CancellationErrorCodePropertyName,n.CancellationErrorCode[i]),this.privTranslationRecognizer.canceled){const t=new n.TranslationRecognitionCanceledEventArgs(e,r,o,i,void 0);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,t)}catch{}}if(this.privSuccessCallback){const e=new n.TranslationRecognitionResult(void 0,t,n.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,o,void 0,a);try{this.privSuccessCallback(e),this.privSuccessCallback=void 0}catch{}}}handleRecognizingCallback(e,t,r){try{const i=new n.TranslationRecognitionEventArgs(n.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,i)}catch(e){}}handleRecognizedCallback(e,t,r){try{const i=new n.TranslationRecognitionEventArgs(n.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,i)}catch(e){}}fireEventForResult(e,t){let r,o,a;if(void 0!==e.Translation.Translations){r=new n.Translations;for(const t of e.Translation.Translations)r.set(t.Language,t.Text||t.DisplayText)}e instanceof s.TranslationPhrase?(o=e.Translation&&e.Translation.TranslationStatus===i.TranslationStatus.Success?n.ResultReason.TranslatedSpeech:n.ResultReason.RecognizedSpeech,a=e.Confidence):o=n.ResultReason.TranslatingSpeech;const c=e.Language,p=new n.TranslationRecognitionResult(r,this.privRequestSession.requestId,o,e.Text,e.Duration,e.Offset,c,a,e.Translation.FailureReason,e.asJson(),t);return new n.TranslationRecognitionEventArgs(p,e.Offset,this.privRequestSession.sessionId)}sendSynthesisAudio(e,t){const r=void 0===e?n.ResultReason.SynthesizingAudioCompleted:n.ResultReason.SynthesizingAudio,i=new n.TranslationSynthesisResult(r,e),s=new n.TranslationSynthesisEventArgs(i,t);if(this.privTranslationRecognizer.synthesizing)try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,s)}catch(e){}}}t.TranslationServiceRecognizer=o},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechDetected=void 0;class r{constructor(e,t){this.privSpeechStartDetected=JSON.parse(e),this.privSpeechStartDetected.Offset+=t}static fromJSON(e,t){return new r(e,t)}get Offset(){return this.privSpeechStartDetected.Offset}}t.SpeechDetected=r},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechHypothesis=void 0;class r{constructor(e,t){this.privSpeechHypothesis=JSON.parse(e),this.updateOffset(t)}static fromJSON(e,t){return new r(e,t)}updateOffset(e){this.privSpeechHypothesis.Offset+=e}asJson(){return JSON.stringify(this.privSpeechHypothesis)}get Text(){return this.privSpeechHypothesis.Text}get Offset(){return this.privSpeechHypothesis.Offset}get Duration(){return this.privSpeechHypothesis.Duration}get Language(){return void 0===this.privSpeechHypothesis.PrimaryLanguage?void 0:this.privSpeechHypothesis.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return void 0===this.privSpeechHypothesis.PrimaryLanguage?void 0:this.privSpeechHypothesis.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSpeechHypothesis.SpeakerId}}t.SpeechHypothesis=r},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechKeyword=void 0;class r{constructor(e,t){this.privSpeechKeyword=JSON.parse(e),this.privSpeechKeyword.Offset+=t}static fromJSON(e,t){return new r(e,t)}get Status(){return this.privSpeechKeyword.Status}get Text(){return this.privSpeechKeyword.Text}get Offset(){return this.privSpeechKeyword.Offset}get Duration(){return this.privSpeechKeyword.Duration}asJson(){return JSON.stringify(this.privSpeechKeyword)}}t.SpeechKeyword=r},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechServiceRecognizer=void 0;const i=r(79),n=r(2);class s extends n.ServiceRecognizerBase{constructor(e,t,r,i,n){super(e,t,r,i,n),this.privSpeechRecognizer=n}async processTypeSpecificMessages(e){let t;const r=new i.PropertyCollection;let s=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":const o=n.SpeechHypothesis.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);r.setProperty(i.PropertyId.SpeechServiceResponse_JsonResult,o.asJson()),t=new i.SpeechRecognitionResult(this.privRequestSession.requestId,i.ResultReason.RecognizingSpeech,o.Text,o.Duration,o.Offset,o.Language,o.LanguageDetectionConfidence,void 0,void 0,o.asJson(),r),this.privRequestSession.onHypothesis(o.Offset);const a=new i.SpeechRecognitionEventArgs(t,o.Offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognizing)try{this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer,a)}catch(e){}s=!0;break;case"speech.phrase":const c=n.SimpleSpeechPhrase.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);r.setProperty(i.PropertyId.SpeechServiceResponse_JsonResult,c.asJson());const p=n.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus,this.privExpectContentAssessmentResponse);if(this.privRequestSession.onPhraseRecognized(c.Offset+c.Duration),i.ResultReason.Canceled===p){const e=n.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),t=n.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(e,t,n.EnumTranslation.implTranslateErrorDetails(t))}else{if(c.RecognitionStatus===n.RecognitionStatus.EndOfDictation)break;if(this.privRecognizerConfig.parameters.getProperty(n.OutputFormatPropertyName)===i.OutputFormat[i.OutputFormat.Simple])t=new i.SpeechRecognitionResult(this.privRequestSession.requestId,p,c.DisplayText,c.Duration,c.Offset,c.Language,c.LanguageDetectionConfidence,void 0,void 0,c.asJson(),r);else{const s=n.DetailedSpeechPhrase.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);r.setProperty(i.PropertyId.SpeechServiceResponse_JsonResult,s.asJson()),t=new i.SpeechRecognitionResult(this.privRequestSession.requestId,p,s.RecognitionStatus===n.RecognitionStatus.Success?s.NBest[0].Display:"",s.Duration,s.Offset,s.Language,s.LanguageDetectionConfidence,void 0,void 0,s.asJson(),r)}const s=new i.SpeechRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognized)try{this.privSpeechRecognizer.recognized(this.privSpeechRecognizer,s)}catch(e){}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(e){this.privErrorCallback&&this.privErrorCallback(e)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}s=!0}return s}cancelRecognition(e,t,r,s,o){const a=new i.PropertyCollection;if(a.setProperty(n.CancellationErrorCodePropertyName,i.CancellationErrorCode[s]),this.privSpeechRecognizer.canceled){const t=new i.SpeechRecognitionCanceledEventArgs(r,o,s,void 0,e);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,t)}catch{}}if(this.privSuccessCallback){const e=new i.SpeechRecognitionResult(t,i.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,o,void 0,a);try{this.privSuccessCallback(e),this.privSuccessCallback=void 0}catch{}}}}t.SpeechServiceRecognizer=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranscriptionServiceRecognizer=void 0;const i=r(79),n=r(2),s=r(236),o=r(113);class a extends n.ServiceRecognizerBase{constructor(e,t,r,i,n){super(e,t,r,i,n),this.privConversationTranscriber=n,this.setSpeakerDiarizationJson()}setSpeakerDiarizationJson(){if(this.privEnableSpeakerId){const e=this.privSpeechContext.getContext().phraseDetection||{};e.mode=o.RecognitionMode.Conversation;const t={};t.mode=s.SpeakerDiarizationMode.Anonymous,t.audioSessionId=this.privDiarizationSessionId,t.audioOffsetMs=0,t.diarizeIntermediates="true"===this.privRecognizerConfig.parameters.getProperty(i.PropertyId.SpeechServiceResponse_DiarizeIntermediateResults,"false"),e.speakerDiarization=t,this.privSpeechContext.getContext().phraseDetection=e}}async processTypeSpecificMessages(e){let t;const r=new i.PropertyCollection;r.setProperty(i.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let s=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":const o=n.SpeechHypothesis.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);t=new i.ConversationTranscriptionResult(this.privRequestSession.requestId,i.ResultReason.RecognizingSpeech,o.Text,o.Duration,o.Offset,o.Language,o.LanguageDetectionConfidence,o.SpeakerId,void 0,o.asJson(),r),this.privRequestSession.onHypothesis(o.Offset);const a=new i.ConversationTranscriptionEventArgs(t,o.Duration,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribing)try{this.privConversationTranscriber.transcribing(this.privConversationTranscriber,a)}catch(e){}s=!0;break;case"speech.phrase":const c=n.SimpleSpeechPhrase.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset),p=n.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus);if(this.privRequestSession.onPhraseRecognized(c.Offset+c.Duration),i.ResultReason.Canceled===p){const e=n.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),t=n.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(e,t,n.EnumTranslation.implTranslateErrorDetails(t))}else if(!this.privRequestSession.isSpeechEnded||p!==i.ResultReason.NoMatch||c.RecognitionStatus===n.RecognitionStatus.InitialSilenceTimeout){if(this.privRecognizerConfig.parameters.getProperty(n.OutputFormatPropertyName)===i.OutputFormat[i.OutputFormat.Simple])t=new i.ConversationTranscriptionResult(this.privRequestSession.requestId,p,c.DisplayText,c.Duration,c.Offset,c.Language,c.LanguageDetectionConfidence,c.SpeakerId,void 0,c.asJson(),r);else{const s=n.DetailedSpeechPhrase.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);t=new i.ConversationTranscriptionResult(this.privRequestSession.requestId,p,s.RecognitionStatus===n.RecognitionStatus.Success?s.NBest[0].Display:void 0,s.Duration,s.Offset,s.Language,s.LanguageDetectionConfidence,c.SpeakerId,void 0,s.asJson(),r)}const s=new i.ConversationTranscriptionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribed)try{this.privConversationTranscriber.transcribed(this.privConversationTranscriber,s)}catch(e){}}s=!0}return s}cancelRecognition(e,t,r,s,o){if((new i.PropertyCollection).setProperty(n.CancellationErrorCodePropertyName,i.CancellationErrorCode[s]),this.privConversationTranscriber.canceled){const t=new i.ConversationTranscriptionCanceledEventArgs(r,o,s,void 0,e);try{this.privConversationTranscriber.canceled(this.privConversationTranscriber,t)}catch{}}}}t.ConversationTranscriptionServiceRecognizer=a},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IdentityProvider=t.SpeakerDiarizationMode=void 0,function(e){e.None="None",e.Identity="Identity",e.Anonymous="Anonymous"}(t.SpeakerDiarizationMode||(t.SpeakerDiarizationMode={})),function(e){e.CallCenter="CallCenter"}(t.IdentityProvider||(t.IdentityProvider={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranscriptionServiceRecognizer=void 0;const i=r(4),n=r(79),s=r(2),o=r(207);class a extends s.ConversationServiceRecognizer{constructor(e,t,r,i,s){super(e,t,r,i,s),this.privTranscriberRecognizer=s,this.sendPrePayloadJSONOverride=e=>this.sendTranscriptionStartJSON(e),"true"===this.privRecognizerConfig.parameters.getProperty(n.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps)&&this.privSpeechContext.setWordLevelTimings()}async sendSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){const r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createSpeechEventPayload(e,t))}}async sendMeetingSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){const r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createMeetingSpeechEventPayload(e,t))}}processTypeSpecificMessages(e){return this.processSpeechMessages(e)}handleRecognizedCallback(e,t,r){try{const i=new n.SpeechRecognitionEventArgs(e,t,r);if(this.privTranscriberRecognizer.recognized(this.privTranscriberRecognizer,i),this.privSuccessCallback){try{this.privSuccessCallback(e)}catch(e){this.privErrorCallback&&this.privErrorCallback(e)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}catch(e){}}handleRecognizingCallback(e,t,r){try{const i=new n.SpeechRecognitionEventArgs(e,t,r);this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer,i)}catch(e){}}cancelRecognition(e,t,r,i,o){const a=new n.PropertyCollection;if(a.setProperty(s.CancellationErrorCodePropertyName,n.CancellationErrorCode[i]),this.privTranscriberRecognizer.IsMeetingRecognizer()){if(this.privTranscriberRecognizer.canceled){const t=new n.MeetingTranscriptionCanceledEventArgs(r,o,i,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,t)}catch{}}}else if(this.privTranscriberRecognizer.canceled){const t=new n.ConversationTranscriptionCanceledEventArgs(r,o,i,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,t)}catch{}}if(this.privSuccessCallback){const e=new n.SpeechRecognitionResult(t,n.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,o,void 0,a);try{this.privSuccessCallback(e),this.privSuccessCallback=void 0}catch{}}}async sendTranscriptionStartJSON(e){if(await this.sendSpeechContext(e,!0),this.privTranscriberRecognizer.IsMeetingRecognizer()){const t=this.privTranscriberRecognizer.getMeetingInfo(),r=this.createMeetingSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}else{const t=this.privTranscriberRecognizer.getConversationInfo(),r=this.createSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}await this.sendWaveHeader(e)}sendSpeechEvent(e,t){const r=JSON.stringify(t);if(r)return e.send(new o.SpeechConnectionMessage(i.MessageType.Text,"speech.event",this.privRequestSession.requestId,"application/json",r))}createSpeechEventPayload(e,t){const r={id:"meeting",name:t,meeting:e.conversationProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}createMeetingSpeechEventPayload(e,t){const r={id:"meeting",name:t,meeting:e.meetingProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}}t.TranscriptionServiceRecognizer=a},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DetailedSpeechPhrase=void 0;const i=r(2);class n{constructor(e,t){this.privDetailedSpeechPhrase=JSON.parse(e),this.privDetailedSpeechPhrase.RecognitionStatus=this.mapRecognitionStatus(this.privDetailedSpeechPhrase.RecognitionStatus),this.updateOffsets(t)}static fromJSON(e,t){return new n(e,t)}updateOffsets(e){if(this.privDetailedSpeechPhrase.Offset+=e,this.privDetailedSpeechPhrase.NBest)for(const t of this.privDetailedSpeechPhrase.NBest){if(t.Words)for(const r of t.Words)r.Offset+=e;if(t.DisplayWords)for(const r of t.DisplayWords)r.Offset+=e}}asJson(){const e={...this.privDetailedSpeechPhrase};return JSON.stringify({...e,RecognitionStatus:i.RecognitionStatus[e.RecognitionStatus]})}get RecognitionStatus(){return this.privDetailedSpeechPhrase.RecognitionStatus}get NBest(){return this.privDetailedSpeechPhrase.NBest}get Duration(){return this.privDetailedSpeechPhrase.Duration}get Offset(){return this.privDetailedSpeechPhrase.Offset}get Language(){return void 0===this.privDetailedSpeechPhrase.PrimaryLanguage?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return void 0===this.privDetailedSpeechPhrase.PrimaryLanguage?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Confidence}get Text(){return this.privDetailedSpeechPhrase.NBest&&this.privDetailedSpeechPhrase.NBest[0]?this.privDetailedSpeechPhrase.NBest[0].Display||this.privDetailedSpeechPhrase.NBest[0].DisplayText:this.privDetailedSpeechPhrase.DisplayText}get SpeakerId(){return this.privDetailedSpeechPhrase.SpeakerId}mapRecognitionStatus(e){return"string"==typeof e?i.RecognitionStatus[e]:"number"==typeof e?e:void 0}}t.DetailedSpeechPhrase=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleSpeechPhrase=void 0;const i=r(2);class n{constructor(e,t=0){this.privSimpleSpeechPhrase=JSON.parse(e),this.privSimpleSpeechPhrase.RecognitionStatus=this.mapRecognitionStatus(this.privSimpleSpeechPhrase.RecognitionStatus),this.updateOffset(t)}static fromJSON(e,t){return new n(e,t)}updateOffset(e){this.privSimpleSpeechPhrase.Offset+=e}asJson(){const e={...this.privSimpleSpeechPhrase};return JSON.stringify({...e,RecognitionStatus:i.RecognitionStatus[e.RecognitionStatus]})}get RecognitionStatus(){return this.privSimpleSpeechPhrase.RecognitionStatus}get DisplayText(){return this.privSimpleSpeechPhrase.DisplayText}get Offset(){return this.privSimpleSpeechPhrase.Offset}get Duration(){return this.privSimpleSpeechPhrase.Duration}get Language(){return void 0===this.privSimpleSpeechPhrase.PrimaryLanguage?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return void 0===this.privSimpleSpeechPhrase.PrimaryLanguage?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSimpleSpeechPhrase.SpeakerId}mapRecognitionStatus(e){return"string"==typeof e?i.RecognitionStatus[e]:"number"==typeof e?e:void 0}}t.SimpleSpeechPhrase=n},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AddedLmIntent=void 0;t.AddedLmIntent=class{constructor(e,t){this.modelImpl=e,this.intentName=t}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntentServiceRecognizer=void 0;const i=r(4),n=r(79),s=r(2);class o extends s.ServiceRecognizerBase{constructor(e,t,r,i,n){super(e,t,r,i,n),this.privIntentRecognizer=n,this.privIntentDataSent=!1,i.recognitionEndpointVersion="1"}setIntents(e,t){this.privAddedLmIntents=e,this.privUmbrellaIntent=t,this.privIntentDataSent=!0}processTypeSpecificMessages(e){let t,r,o=!1;const a=new n.PropertyCollection;switch(e.messageType===i.MessageType.Text&&a.setProperty(n.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.hypothesis":const i=s.SpeechHypothesis.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);if(t=new n.IntentRecognitionResult(void 0,this.privRequestSession.requestId,n.ResultReason.RecognizingIntent,i.Text,i.Duration,i.Offset,i.Language,i.LanguageDetectionConfidence,void 0,i.asJson(),a),this.privRequestSession.onHypothesis(t.offset),r=new n.IntentRecognitionEventArgs(t,i.Offset,this.privRequestSession.sessionId),this.privIntentRecognizer.recognizing)try{this.privIntentRecognizer.recognizing(this.privIntentRecognizer,r)}catch(e){}o=!0;break;case"speech.phrase":const c=s.SimpleSpeechPhrase.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);t=new n.IntentRecognitionResult(void 0,this.privRequestSession.requestId,s.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus),c.DisplayText,c.Duration,c.Offset,c.Language,c.LanguageDetectionConfidence,void 0,c.asJson(),a),r=new n.IntentRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);const p=()=>{if(this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch(e){}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(e){this.privErrorCallback&&this.privErrorCallback(e)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}};!1===this.privIntentDataSent||n.ResultReason.NoMatch===r.result.reason?(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),p()):this.privPendingIntentArgs=r,o=!0;break;case"response":if(r=this.privPendingIntentArgs,this.privPendingIntentArgs=void 0,void 0===r){if(""===e.textBody)return;r=new n.IntentRecognitionEventArgs(new n.IntentRecognitionResult,0,this.privRequestSession.sessionId)}const h=s.IntentResponse.fromJSON(e.textBody);if(null!==h&&h.topScoringIntent&&h.topScoringIntent.intent){let t=this.privAddedLmIntents[h.topScoringIntent.intent];if(void 0!==this.privUmbrellaIntent&&(t=this.privUmbrellaIntent),t){const i=void 0===t||void 0===t.intentName?h.topScoringIntent.intent:t.intentName;let s=r.result.reason;void 0!==i&&(s=n.ResultReason.RecognizedIntent);const o=void 0!==r.result.properties?r.result.properties:new n.PropertyCollection;o.setProperty(n.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,e.textBody),r=new n.IntentRecognitionEventArgs(new n.IntentRecognitionResult(i,r.result.resultId,s,r.result.text,r.result.duration,r.result.offset,void 0,void 0,r.result.errorDetails,r.result.json,o),r.offset,r.sessionId)}}if(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch(e){}if(this.privSuccessCallback){try{this.privSuccessCallback(r.result)}catch(e){this.privErrorCallback&&this.privErrorCallback(e)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}o=!0}const c=new i.Deferred;return c.resolve(o),c.promise}cancelRecognition(e,t,r,i,o){const a=new n.PropertyCollection;if(a.setProperty(s.CancellationErrorCodePropertyName,n.CancellationErrorCode[i]),this.privIntentRecognizer.canceled){const t=new n.IntentRecognitionCanceledEventArgs(r,o,i,void 0,void 0,e);try{this.privIntentRecognizer.canceled(this.privIntentRecognizer,t)}catch{}}if(this.privSuccessCallback){const e=new n.IntentRecognitionResult(void 0,t,n.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,o,void 0,a);try{this.privSuccessCallback(e),this.privSuccessCallback=void 0}catch{}}}}t.IntentServiceRecognizer=o},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntentResponse=void 0;class r{constructor(e){this.privIntentResponse=""===e?{}:JSON.parse(e)}static fromJSON(e){return new r(e)}get query(){return this.privIntentResponse.query}get topScoringIntent(){return this.privIntentResponse.topScoringIntent}get entities(){return this.privIntentResponse.entities}}t.IntentResponse=r},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RequestSession=void 0;const i=r(4),n=r(205),s=r(245);t.RequestSession=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privIsAudioNodeDetached=!1,this.privIsRecognizing=!1,this.privIsSpeechEnded=!1,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privHypothesisReceived=!1,this.privBytesSent=0,this.privRecognitionBytesSent=0,this.privRecogNumber=0,this.privInTurn=!1,this.privConnectionAttempts=0,this.privAudioSourceId=e,this.privRequestId=(0,i.createNoDashGuid)(),this.privAudioNodeId=(0,i.createNoDashGuid)(),this.privTurnDeferral=new i.Deferred,this.privTurnDeferral.resolve()}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get audioNodeId(){return this.privAudioNodeId}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSpeechEnded(){return this.privIsSpeechEnded}get isRecognizing(){return this.privIsRecognizing}get currentTurnAudioOffset(){return this.privTurnStartAudioOffset}get recogNumber(){return this.privRecogNumber}get numConnectionAttempts(){return this.privConnectionAttempts}get bytesSent(){return this.privBytesSent}get recognitionBytesSent(){return this.privRecognitionBytesSent}listenForServiceTelemetry(e){this.privServiceTelemetryListener&&this.privDetachables.push(e.attachListener(this.privServiceTelemetryListener))}startNewRecognition(){this.privRecognitionBytesSent=0,this.privIsSpeechEnded=!1,this.privIsRecognizing=!0,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privRecogNumber++,this.privServiceTelemetryListener=new s.ServiceTelemetryListener(this.privRequestId,this.privAudioSourceId,this.privAudioNodeId),this.onEvent(new n.RecognitionTriggeredEvent(this.requestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}async onAudioSourceAttachCompleted(e,t){this.privAudioNode=e,this.privIsAudioNodeDetached=!1,t?await this.onComplete():this.onEvent(new n.ListeningStartedEvent(this.privRequestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}onPreConnectionStart(e,t){this.privAuthFetchEventId=e,this.privSessionId=t,this.onEvent(new n.ConnectingToServiceEvent(this.privRequestId,this.privAuthFetchEventId,this.privSessionId))}async onAuthCompleted(e){e&&await this.onComplete()}async onConnectionEstablishCompleted(e,t){if(200===e)return this.onEvent(new n.RecognitionStartedEvent(this.requestId,this.privAudioSourceId,this.privAudioNodeId,this.privAuthFetchEventId,this.privSessionId)),this.privAudioNode&&this.privAudioNode.replay(),this.privTurnStartAudioOffset=this.privLastRecoOffset,void(this.privBytesSent=0);403===e&&await this.onComplete()}async onServiceTurnEndResponse(e){this.privTurnDeferral.resolve(),!e||this.isSpeechEnded?(await this.onComplete(),this.privInTurn=!1):(this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privAudioNode.replay())}onSpeechContext(){this.privRequestId=(0,i.createNoDashGuid)()}onServiceTurnStartResponse(){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch((()=>{}))),this.privInTurn=!0,this.privTurnDeferral=new i.Deferred}onHypothesis(e){this.privHypothesisReceived||(this.privHypothesisReceived=!0,this.privServiceTelemetryListener.hypothesisReceived(this.privAudioNode.findTimeAtOffset(e)))}onPhraseRecognized(e){this.privServiceTelemetryListener.phraseReceived(this.privAudioNode.findTimeAtOffset(e)),this.onServiceRecognized(e)}onServiceRecognized(e){this.privLastRecoOffset=e,this.privHypothesisReceived=!1,this.privAudioNode.shrinkBuffers(e),this.privConnectionAttempts=0}onAudioSent(e){this.privBytesSent+=e,this.privRecognitionBytesSent+=e}onRetryConnection(){this.privConnectionAttempts++}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(const e of this.privDetachables)await e.detach();this.privServiceTelemetryListener&&this.privServiceTelemetryListener.dispose(),this.privIsRecognizing=!1}}getTelemetry(){return this.privServiceTelemetryListener.hasTelemetry?this.privServiceTelemetryListener.getTelemetry():null}async onStopRecognizing(){await this.onComplete()}onSpeechEnded(){this.privIsSpeechEnded=!0}onEvent(e){this.privServiceTelemetryListener&&this.privServiceTelemetryListener.onEvent(e),i.Events.instance.onEvent(e)}async onComplete(){this.privIsRecognizing&&(this.privIsRecognizing=!1,await this.detachAudioNode())}async detachAudioNode(){this.privIsAudioNodeDetached||(this.privIsAudioNodeDetached=!0,this.privAudioNode&&await this.privAudioNode.detach())}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceTelemetryListener=void 0;const i=r(4),n=r(205);t.ServiceTelemetryListener=class{constructor(e,t,r){this.privIsDisposed=!1,this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privRequestId=e,this.privAudioSourceId=t,this.privAudioNodeId=r,this.privReceivedMessages={},this.privPhraseLatencies=[],this.privHypothesisLatencies=[]}phraseReceived(e){e>0&&this.privPhraseLatencies.push(Date.now()-e)}hypothesisReceived(e){e>0&&this.privHypothesisLatencies.push(Date.now()-e)}onEvent(e){if(!this.privIsDisposed&&(e instanceof n.RecognitionTriggeredEvent&&e.requestId===this.privRequestId&&(this.privListeningTriggerMetric={End:e.eventTime,Name:"ListeningTrigger",Start:e.eventTime}),e instanceof i.AudioStreamNodeAttachingEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof i.AudioStreamNodeAttachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof i.AudioSourceErrorEvent&&e.audioSourceId===this.privAudioSourceId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof i.AudioStreamNodeErrorEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof i.AudioStreamNodeDetachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Name:"Microphone",Start:this.privMicStartTime})),e instanceof n.ConnectingToServiceEvent&&e.requestId===this.privRequestId&&(this.privConnectionId=e.sessionId),e instanceof i.ConnectionStartEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionStartTime=e.eventTime),e instanceof i.ConnectionEstablishedEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof i.ConnectionEstablishErrorEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Error:this.getConnectionError(e.statusCode),Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof i.ConnectionMessageReceivedEvent&&e.connectionId===this.privConnectionId&&e.message&&e.message.headers&&e.message.headers.path)){this.privReceivedMessages[e.message.headers.path]||(this.privReceivedMessages[e.message.headers.path]=new Array);const t=50;this.privReceivedMessages[e.message.headers.path].length<t&&this.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime)}}getTelemetry(){const e=new Array;this.privListeningTriggerMetric&&e.push(this.privListeningTriggerMetric),this.privMicMetric&&e.push(this.privMicMetric),this.privConnectionEstablishMetric&&e.push(this.privConnectionEstablishMetric),this.privPhraseLatencies.length>0&&e.push({PhraseLatencyMs:this.privPhraseLatencies}),this.privHypothesisLatencies.length>0&&e.push({FirstHypothesisLatencyMs:this.privHypothesisLatencies});const t={Metrics:e,ReceivedMessages:this.privReceivedMessages},r=JSON.stringify(t);return this.privReceivedMessages={},this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privPhraseLatencies=[],this.privHypothesisLatencies=[],r}get hasTelemetry(){return 0!==Object.keys(this.privReceivedMessages).length||null!==this.privListeningTriggerMetric||null!==this.privMicMetric||null!==this.privConnectionEstablishMetric||0!==this.privPhraseLatencies.length||0!==this.privHypothesisLatencies.length}dispose(){this.privIsDisposed=!0}getConnectionError(e){switch(e){case 400:case 1002:case 1003:case 1005:case 1007:case 1008:case 1009:return"BadRequest";case 401:return"Unauthorized";case 403:return"Forbidden";case 503:case 1001:return"ServerUnavailable";case 500:case 1011:return"ServerError";case 408:case 504:return"Timeout";default:return"statuscode:"+e.toString()}}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechContext=void 0;const i=r(113),n=r(247);t.SpeechContext=class{constructor(e){this.privContext={},this.privDynamicGrammar=e}getContext(){return this.privContext}setPronunciationAssessmentParams(e,t,r=!1){void 0===this.privContext.phraseDetection&&(this.privContext.phraseDetection={enrichment:{pronunciationAssessment:{}}}),void 0===this.privContext.phraseDetection.enrichment&&(this.privContext.phraseDetection.enrichment={pronunciationAssessment:{}}),this.privContext.phraseDetection.enrichment.pronunciationAssessment=JSON.parse(e)||{},r&&(this.privContext.phraseDetection.mode=i.RecognitionMode.Conversation),this.setWordLevelTimings(),this.privContext.phraseOutput.detailed.options.push(n.PhraseOption.PronunciationAssessment),-1===this.privContext.phraseOutput.detailed.options.indexOf(n.PhraseOption.SNR)&&this.privContext.phraseOutput.detailed.options.push(n.PhraseOption.SNR),t&&(this.privContext.phraseDetection.enrichment.contentAssessment={topic:t},this.privContext.phraseOutput.detailed.options.push(n.PhraseOption.ContentAssessment))}setDetailedOutputFormat(){void 0===this.privContext.phraseOutput&&(this.privContext.phraseOutput={detailed:{options:[]}}),void 0===this.privContext.phraseOutput.detailed&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format=n.OutputFormat.Detailed}setWordLevelTimings(){void 0===this.privContext.phraseOutput&&(this.privContext.phraseOutput={detailed:{options:[]}}),void 0===this.privContext.phraseOutput.detailed&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format=n.OutputFormat.Detailed,-1===this.privContext.phraseOutput.detailed.options.indexOf(n.PhraseOption.WordTimings)&&this.privContext.phraseOutput.detailed.options.push(n.PhraseOption.WordTimings)}setSpeakerDiarizationAudioOffsetMs(e){this.privContext.phraseDetection.speakerDiarization.audioOffsetMs=e}toJSON(){const e=this.privDynamicGrammar.generateGrammarObject();this.privContext.dgi=e;return JSON.stringify(this.privContext)}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TentativePhraseResultsOption=t.OutputFormat=t.PhraseExtension=t.PhraseOption=void 0,function(e){e.WordTimings="WordTimings",e.SNR="SNR",e.Pronunciation="Pronunciation",e.WordPronunciation="WordPronunciation",e.WordConfidence="WordConfidence",e.Words="Words",e.Sentiment="Sentiment",e.PronunciationAssessment="PronunciationAssessment",e.ContentAssessment="ContentAssessment",e.PhraseAMScore="PhraseAMScore",e.PhraseLMScore="PhraseLMScore",e.WordAMScore="WordAMScore",e.WordLMScore="WordLMScore",e.RuleTree="RuleTree",e.NBestTimings="NBestTimings",e.DecoderDiagnostics="DecoderDiagnostics",e.DisplayWordTimings="DisplayWordTimings",e.DisplayWords="DisplayWords"}(t.PhraseOption||(t.PhraseOption={})),function(e){e.Graph="Graph",e.Corrections="Corrections",e.Sentiment="Sentiment"}(t.PhraseExtension||(t.PhraseExtension={})),function(e){e.Simple="Simple",e.Detailed="Detailed"}(t.OutputFormat||(t.OutputFormat={})),function(e){e.None="None",e.Always="Always"}(t.TentativePhraseResultsOption||(t.TentativePhraseResultsOption={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DynamicGrammarBuilder=void 0;const i=r(249);t.DynamicGrammarBuilder=class{addPhrase(e){this.privPhrases||(this.privPhrases=[]),e instanceof Array?this.privPhrases=this.privPhrases.concat(e):this.privPhrases.push(e)}clearPhrases(){this.privPhrases=void 0}addReferenceGrammar(e){this.privGrammars||(this.privGrammars=[]),e instanceof Array?this.privGrammars=this.privGrammars.concat(e):this.privGrammars.push(e)}clearGrammars(){this.privGrammars=void 0}generateGrammarObject(){if(void 0===this.privGrammars&&void 0===this.privPhrases)return;const e={};if(e.referenceGrammars=this.privGrammars,void 0!==this.privPhrases&&0!==this.privPhrases.length){const t=[];this.privPhrases.forEach((e=>{t.push({text:e})})),e.groups=[{type:i.GroupType.Generic,items:t}]}return e}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubstringMatchType=t.GroupType=void 0,function(e){e.IntentText="IntentText",e.IntentEntity="IntentEntity",e.Generic="Generic",e.People="People",e.Place="Place",e.DynamicEntity="DynamicEntity"}(t.GroupType||(t.GroupType={})),function(e){e.None="None",e.LeftRooted="LeftRooted",e.PartialName="PartialName",e.MiddleOfSentence="MiddleOfSentence"}(t.SubstringMatchType||(t.SubstringMatchType={}))},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DialogServiceAdapter=void 0;const i=r(60),n=r(29),s=r(4),o=r(85),a=r(79),c=r(251),p=r(2),h=r(253),u=r(254),d=r(255),v=r(207);class l extends p.ServiceRecognizerBase{constructor(e,t,r,i,n){super(e,t,r,i,n),this.privEvents=new s.EventSource,this.privDialogServiceConnector=n,this.receiveMessageOverride=()=>this.receiveDialogMessageOverride(),this.privTurnStateManager=new c.DialogServiceTurnStateManager,this.recognizeOverride=(e,t,r)=>this.listenOnce(e,t,r),this.postConnectImplOverride=e=>this.dialogConnectImpl(e),this.configConnectionOverride=e=>this.configConnection(e),this.disconnectOverride=()=>this.privDisconnect(),this.privDialogAudioSource=r,this.agentConfigSent=!1,this.privLastResult=null,this.connectionEvents.attach((e=>{"ConnectionClosedEvent"===e.name&&(this.terminateMessageLoop=!0)}))}async sendMessage(e){const t=(0,s.createGuid)(),r=(0,s.createNoDashGuid)(),i={context:{interactionId:t},messagePayload:JSON.parse(e),version:.5},n=JSON.stringify(i),o=await this.fetchConnection();await o.send(new v.SpeechConnectionMessage(s.MessageType.Text,"agent",r,"application/json",n))}async privDisconnect(){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,a.CancellationReason.Error,a.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.agentConfigSent=!1}processTypeSpecificMessages(e){const t=new a.PropertyCollection;let r,i;switch(e.messageType===s.MessageType.Text&&t.setProperty(a.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.phrase":const n=p.SimpleSpeechPhrase.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);if(this.privRequestSession.onPhraseRecognized(n.Offset+n.Duration),n.RecognitionStatus!==p.RecognitionStatus.TooManyRequests&&n.RecognitionStatus!==p.RecognitionStatus.Error){const e=this.fireEventForResult(n,t);if(this.privLastResult=e.result,this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,e)}catch(e){}}i=!0;break;case"speech.hypothesis":const s=p.SpeechHypothesis.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);r=new a.SpeechRecognitionResult(this.privRequestSession.requestId,a.ResultReason.RecognizingSpeech,s.Text,s.Duration,s.Offset,s.Language,s.LanguageDetectionConfidence,void 0,void 0,s.asJson(),t),this.privRequestSession.onHypothesis(s.Offset);const o=new a.SpeechRecognitionEventArgs(r,s.Offset,this.privRequestSession.sessionId);if(this.privDialogServiceConnector.recognizing)try{this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector,o)}catch(e){}i=!0;break;case"speech.keyword":const c=p.SpeechKeyword.fromJSON(e.textBody,this.privRequestSession.currentTurnAudioOffset);r=new a.SpeechRecognitionResult(this.privRequestSession.requestId,"Accepted"===c.Status?a.ResultReason.RecognizedKeyword:a.ResultReason.NoMatch,c.Text,c.Duration,c.Offset,void 0,void 0,void 0,void 0,c.asJson(),t),"Accepted"!==c.Status&&(this.privLastResult=r);const h=new a.SpeechRecognitionEventArgs(r,r.duration,r.resultId);if(this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,h)}catch(e){}i=!0;break;case"audio":{const t=e.requestId.toUpperCase(),r=this.privTurnStateManager.GetTurn(t);try{e.binaryBody?r.audioStream.write(e.binaryBody):r.endAudioStream()}catch(e){}}i=!0;break;case"response":this.handleResponseMessage(e),i=!0}const n=new s.Deferred;return n.resolve(i),n.promise}async cancelRecognition(e,t,r,i,n){if(this.terminateMessageLoop=!0,this.privRequestSession.isRecognizing&&await this.privRequestSession.onStopRecognizing(),this.privDialogServiceConnector.canceled){const t=new a.PropertyCollection;t.setProperty(p.CancellationErrorCodePropertyName,a.CancellationErrorCode[i]);const s=new a.SpeechRecognitionCanceledEventArgs(r,n,i,void 0,e);try{this.privDialogServiceConnector.canceled(this.privDialogServiceConnector,s)}catch{}if(this.privSuccessCallback){const e=new a.SpeechRecognitionResult(void 0,a.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,n,void 0,t);try{this.privSuccessCallback(e),this.privSuccessCallback=void 0}catch{}}}}async listenOnce(e,t,r){this.privRecognizerConfig.recognitionMode=e,this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privDialogAudioSource.events),this.privRecognizerConfig.parameters.setProperty(a.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);const n=this.connectImpl(),s=this.sendPreAudioMessages(),o=await this.privDialogAudioSource.attach(this.privRequestSession.audioNodeId),c=await this.privDialogAudioSource.format,p=await this.privDialogAudioSource.deviceInfo,h=new i.ReplayableAudioNode(o,c.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(h,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:p};try{await n,await s}catch(e){return await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,a.CancellationReason.Error,a.CancellationErrorCode.ConnectionFailure,e),Promise.resolve()}const u=new a.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,u);this.sendAudio(h).then((()=>{}),(async e=>{await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,a.CancellationReason.Error,a.CancellationErrorCode.RuntimeError,e)}))}dialogConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}receiveDialogMessageOverride(){const e=new s.Deferred,t=async()=>{try{const r=this.isDisposed(),i=!this.isDisposed()&&this.terminateMessageLoop;if(r||i)return void e.resolve(void 0);const n=await this.fetchConnection(),o=await n.read();if(!o)return t();const c=v.SpeechConnectionMessage.fromConnectionMessage(o);switch(c.path.toLowerCase()){case"turn.start":{const e=c.requestId.toUpperCase();e!==this.privRequestSession.requestId.toUpperCase()?this.privTurnStateManager.StartTurn(e):this.privRequestSession.onServiceTurnStartResponse()}break;case"speech.startdetected":const e=p.SpeechDetected.fromJSON(c.textBody,this.privRequestSession.currentTurnAudioOffset),t=new a.RecognitionEventArgs(e.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,t);break;case"speech.enddetected":let r;r=c.textBody.length>0?c.textBody:"{ Offset: 0 }";const i=p.SpeechDetected.fromJSON(r,this.privRequestSession.currentTurnAudioOffset);this.privRequestSession.onServiceRecognized(i.Offset);const n=new a.RecognitionEventArgs(i.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,n);break;case"turn.end":{const e=c.requestId.toUpperCase();if(e!==this.privRequestSession.requestId.toUpperCase())this.privTurnStateManager.CompleteTurn(e);else{const e=new a.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(!1),this.privRecognizerConfig.isContinuousRecognition&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing||this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,e),this.privSuccessCallback&&this.privLastResult){try{this.privSuccessCallback(this.privLastResult),this.privLastResult=null}catch(e){this.privErrorCallback&&this.privErrorCallback(e)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}}break;default:try{await this.processTypeSpecificMessages(c)||this.serviceEvents&&this.serviceEvents.onEvent(new s.ServiceEvent(c.path.toLowerCase(),c.textBody))}catch(e){}}return t()}catch(t){this.terminateMessageLoop=!0,e.resolve()}};return t().catch((e=>{s.Events.instance.onEvent(new s.BackgroundEvent(e))})),e.promise}async startMessageLoop(){this.terminateMessageLoop=!1;try{await this.receiveDialogMessageOverride()}catch(e){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,a.CancellationReason.Error,a.CancellationErrorCode.RuntimeError,e)}return Promise.resolve()}async configConnection(e){return this.terminateMessageLoop?(this.terminateMessageLoop=!1,Promise.reject("Connection to service terminated.")):(await this.sendSpeechServiceConfig(e,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendAgentConfig(e),e)}async sendPreAudioMessages(){const e=await this.fetchConnection();this.addKeywordContextData(),await this.sendSpeechContext(e,!0),await this.sendAgentContext(e),await this.sendWaveHeader(e)}sendAgentConfig(e){if(this.agentConfig&&!this.agentConfigSent){if(this.privRecognizerConfig.parameters.getProperty(a.PropertyId.Conversation_DialogType)===a.DialogServiceConfig.DialogTypes.CustomCommands){const e=this.agentConfig.get();e.botInfo.commandsCulture=this.privRecognizerConfig.parameters.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage,"en-us"),this.agentConfig.set(e)}this.onEvent(new n.SendingAgentContextMessageEvent(this.agentConfig));const t=this.agentConfig.toJsonString();return this.agentConfigSent=!0,e.send(new v.SpeechConnectionMessage(s.MessageType.Text,"agent.config",this.privRequestSession.requestId,"application/json",t))}}sendAgentContext(e){const t=(0,s.createGuid)(),r=this.privDialogServiceConnector.properties.getProperty(a.PropertyId.Conversation_Speech_Activity_Template),i={channelData:"",context:{interactionId:t},messagePayload:void 0===typeof r?void 0:r,version:.5},n=JSON.stringify(i);return e.send(new v.SpeechConnectionMessage(s.MessageType.Text,"speech.agent.context",this.privRequestSession.requestId,"application/json",n))}fireEventForResult(e,t){const r=p.EnumTranslation.implTranslateRecognitionResult(e.RecognitionStatus),i=new a.SpeechRecognitionResult(this.privRequestSession.requestId,r,e.DisplayText,e.Duration,e.Offset,e.Language,e.LanguageDetectionConfidence,void 0,void 0,e.asJson(),t);return new a.SpeechRecognitionEventArgs(i,e.Offset,this.privRequestSession.sessionId)}handleResponseMessage(e){const t=JSON.parse(e.textBody);switch(t.messageType.toLowerCase()){case"message":const r=e.requestId.toUpperCase(),i=h.ActivityPayloadResponse.fromJSON(e.textBody),n=this.privTurnStateManager.GetTurn(r);if(i.conversationId){const e=this.agentConfig.get();e.botInfo.conversationId=i.conversationId,this.agentConfig.set(e)}const c=n.processActivityPayload(i,o.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(a.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0))),p=new a.ActivityReceivedEventArgs(i.messagePayload,c);if(this.privDialogServiceConnector.activityReceived)try{this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector,p)}catch(e){}break;case"messagestatus":if(this.privDialogServiceConnector.turnStatusReceived)try{this.privDialogServiceConnector.turnStatusReceived(this.privDialogServiceConnector,new a.TurnStatusReceivedEventArgs(e.textBody))}catch(e){}break;default:s.Events.instance.onEvent(new s.BackgroundEvent(`Unexpected response of type ${t.messageType}. Ignoring.`))}}onEvent(e){this.privEvents.onEvent(e),s.Events.instance.onEvent(e)}addKeywordContextData(){const e=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect");if(void 0===e)return;const t=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Offsets"),r=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Durations"),i=e.split(";"),n=void 0===t?[]:t.split(";"),s=void 0===r?[]:r.split(";"),o=[];for(let e=0;e<i.length;e++){const t={text:i[e]};e<n.length&&(t.startOffset=Number(n[e])),e<s.length&&(t.duration=Number(s[e])),o.push(t)}this.speechContext.getContext().invocationSource=u.InvocationSource.VoiceActivationWithKeyword,this.speechContext.getContext().keywordDetection=[{clientDetectedKeywords:o,onReject:{action:d.OnRejectAction.EndOfTurn},type:d.KeywordDetectionType.StartTrigger}]}}t.DialogServiceAdapter=l},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DialogServiceTurnStateManager=void 0;const i=r(26),n=r(252);t.DialogServiceTurnStateManager=class{constructor(){this.privTurnMap=new Map}StartTurn(e){if(this.privTurnMap.has(e))throw new i.InvalidOperationError("Service error: There is already a turn with id:"+e);const t=new n.DialogServiceTurnState(this,e);return this.privTurnMap.set(e,t),this.privTurnMap.get(e)}GetTurn(e){return this.privTurnMap.get(e)}CompleteTurn(e){if(!this.privTurnMap.has(e))throw new i.InvalidOperationError("Service error: Received turn end for an unknown turn id:"+e);const t=this.privTurnMap.get(e);return t.complete(),this.privTurnMap.delete(e),t}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DialogServiceTurnState=void 0;const i=r(85),n=r(84),s=r(253);t.DialogServiceTurnState=class{constructor(e,t){this.privRequestId=t,this.privIsCompleted=!1,this.privAudioStream=null,this.privTurnManager=e,this.resetTurnEndTimeout()}get audioStream(){return this.resetTurnEndTimeout(),this.privAudioStream}processActivityPayload(e,t){return e.messageDataStreamType===s.MessageDataStreamType.TextToSpeechAudio&&(this.privAudioStream=n.AudioOutputStream.createPullStream(),this.privAudioStream.format=void 0!==t?t:i.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privAudioStream}endAudioStream(){null===this.privAudioStream||this.privAudioStream.isClosed||this.privAudioStream.close()}complete(){void 0!==this.privTimeoutToken&&clearTimeout(this.privTimeoutToken),this.endAudioStream()}resetTurnEndTimeout(){void 0!==this.privTimeoutToken&&clearTimeout(this.privTimeoutToken),this.privTimeoutToken=setTimeout((()=>{this.privTurnManager.CompleteTurn(this.privRequestId)}),2e3)}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MessageDataStreamType=t.ActivityPayloadResponse=void 0;class r{constructor(e){this.privActivityResponse=JSON.parse(e)}static fromJSON(e){return new r(e)}get conversationId(){return this.privActivityResponse.conversationId}get messageDataStreamType(){return this.privActivityResponse.messageDataStreamType}get messagePayload(){return this.privActivityResponse.messagePayload}get version(){return this.privActivityResponse.version}}t.ActivityPayloadResponse=r,function(e){e[e.None=0]="None",e[e.TextToSpeechAudio=1]="TextToSpeechAudio"}(t.MessageDataStreamType||(t.MessageDataStreamType={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InvocationSource=void 0,function(e){e.None="None",e.VoiceActivationWithKeyword="VoiceActivationWithKeyword"}(t.InvocationSource||(t.InvocationSource={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OnRejectAction=t.KeywordDetectionType=void 0,function(e){e.StartTrigger="StartTrigger"}(t.KeywordDetectionType||(t.KeywordDetectionType={})),function(e){e.EndOfTurn="EndOfTurn",e.Continue="Continue"}(t.OnRejectAction||(t.OnRejectAction={}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AgentConfig=void 0;t.AgentConfig=class{toJsonString(){return JSON.stringify(this.iPrivConfig)}get(){return this.iPrivConfig}set(e){this.iPrivConfig=e}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalParticipants=t.ConversationTranslatorMessageTypes=t.ConversationTranslatorCommandTypes=t.ParticipantsListEventArgs=t.ParticipantEventArgs=t.ParticipantAttributeEventArgs=t.MuteAllEventArgs=t.LockRoomEventArgs=t.ConversationReceivedTranslationEventArgs=t.TranscriberRecognizer=t.ConversationRecognizerFactory=t.ConversationConnectionConfig=t.ConversationManager=void 0;var i=r(258);Object.defineProperty(t,"ConversationManager",{enumerable:!0,get:function(){return i.ConversationManager}});var n=r(259);Object.defineProperty(t,"ConversationConnectionConfig",{enumerable:!0,get:function(){return n.ConversationConnectionConfig}});var s=r(260);Object.defineProperty(t,"ConversationRecognizerFactory",{enumerable:!0,get:function(){return s.ConversationRecognizerFactory}});var o=r(272);Object.defineProperty(t,"TranscriberRecognizer",{enumerable:!0,get:function(){return o.TranscriberRecognizer}});var a=r(266);Object.defineProperty(t,"ConversationReceivedTranslationEventArgs",{enumerable:!0,get:function(){return a.ConversationReceivedTranslationEventArgs}}),Object.defineProperty(t,"LockRoomEventArgs",{enumerable:!0,get:function(){return a.LockRoomEventArgs}}),Object.defineProperty(t,"MuteAllEventArgs",{enumerable:!0,get:function(){return a.MuteAllEventArgs}}),Object.defineProperty(t,"ParticipantAttributeEventArgs",{enumerable:!0,get:function(){return a.ParticipantAttributeEventArgs}}),Object.defineProperty(t,"ParticipantEventArgs",{enumerable:!0,get:function(){return a.ParticipantEventArgs}}),Object.defineProperty(t,"ParticipantsListEventArgs",{enumerable:!0,get:function(){return a.ParticipantsListEventArgs}});var c=r(267);Object.defineProperty(t,"ConversationTranslatorCommandTypes",{enumerable:!0,get:function(){return c.ConversationTranslatorCommandTypes}}),Object.defineProperty(t,"ConversationTranslatorMessageTypes",{enumerable:!0,get:function(){return c.ConversationTranslatorMessageTypes}}),Object.defineProperty(t,"InternalParticipants",{enumerable:!0,get:function(){return c.InternalParticipants}})},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationManager=void 0;const i=r(60),n=r(64),s=r(79),o=r(259);t.ConversationManager=class{constructor(){this.privRequestParams=o.ConversationConnectionConfig.configParams,this.privErrors=o.ConversationConnectionConfig.restErrors,this.privHost=o.ConversationConnectionConfig.host,this.privApiVersion=o.ConversationConnectionConfig.apiVersion,this.privRestPath=o.ConversationConnectionConfig.restPath,this.privRestAdapter=new i.RestMessageAdapter({})}createOrJoin(e,t,r,a){try{n.Contracts.throwIfNullOrUndefined(e,"args");const c=e.getProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage,o.ConversationConnectionConfig.defaultLanguageCode),p=e.getProperty(s.PropertyId.ConversationTranslator_Name,"conversation_host"),h=e.getProperty(s.PropertyId.ConversationTranslator_Host,this.privHost),u=e.getProperty(s.PropertyId.ConversationTranslator_CorrelationId),d=e.getProperty(s.PropertyId.SpeechServiceConnection_Key),v=e.getProperty(s.PropertyId.SpeechServiceConnection_Region),l=e.getProperty(s.PropertyId.SpeechServiceAuthorization_Token);n.Contracts.throwIfNullOrWhitespace(c,"languageCode"),n.Contracts.throwIfNullOrWhitespace(p,"nickname"),n.Contracts.throwIfNullOrWhitespace(h,"endpointHost");const g={};g[this.privRequestParams.apiVersion]=this.privApiVersion,g[this.privRequestParams.languageCode]=c,g[this.privRequestParams.nickname]=p;const m={};u&&(m[this.privRequestParams.correlationId]=u),m[this.privRequestParams.clientAppId]=o.ConversationConnectionConfig.clientAppId,void 0!==t?g[this.privRequestParams.roomId]=t:(n.Contracts.throwIfNullOrUndefined(v,this.privErrors.authInvalidSubscriptionRegion),m[this.privRequestParams.subscriptionRegion]=v,d?m[this.privRequestParams.subscriptionKey]=d:l?m[this.privRequestParams.authorization]=`Bearer ${l}`:n.Contracts.throwIfNullOrUndefined(d,this.privErrors.authInvalidSubscriptionKey));const f={};f.headers=m,this.privRestAdapter.options=f;const S=`https://${h}${this.privRestPath}`;this.privRestAdapter.request(i.RestRequestType.Post,S,g,null).then((e=>{const t=i.RestMessageAdapter.extractHeaderValue(this.privRequestParams.requestId,e.headers);if(!e.ok){if(a){let r,i=this.privErrors.invalidCreateJoinConversationResponse.replace("{status}",e.status.toString());try{r=JSON.parse(e.data),i+=` [${r.error.code}: ${r.error.message}]`}catch(t){i+=` [${e.data}]`}t&&(i+=` ${t}`),a(i)}return}const n=JSON.parse(e.data);if(n&&(n.requestId=t),r){try{r(n)}catch(e){a&&a(e)}r=void 0}})).catch((()=>{}))}catch(e){if(a)if(e instanceof Error){const t=e;a(t.name+": "+t.message)}else a(e)}}leave(e,t){return new Promise(((r,o)=>{try{n.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","config")),n.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","token"));const o=e.getProperty(s.PropertyId.ConversationTranslator_Host,this.privHost),a=e.getProperty(s.PropertyId.ConversationTranslator_CorrelationId),c={};c[this.privRequestParams.apiVersion]=this.privApiVersion,c[this.privRequestParams.sessionToken]=t;const p={};a&&(p[this.privRequestParams.correlationId]=a);const h={};h.headers=p,this.privRestAdapter.options=h;const u=`https://${o}${this.privRestPath}`;this.privRestAdapter.request(i.RestRequestType.Delete,u,c,null).then((e=>{e.ok,r()})).catch((()=>{}))}catch(e){if(e instanceof Error){const t=e;o(t.name+": "+t.message)}else o(e)}}))}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationConnectionConfig=void 0;const i=r(203);class n extends i.RestConfigBase{static get host(){return n.privHost}static get apiVersion(){return n.privApiVersion}static get clientAppId(){return n.privClientAppId}static get defaultLanguageCode(){return n.privDefaultLanguageCode}static get restPath(){return n.privRestPath}static get webSocketPath(){return n.privWebSocketPath}static get transcriptionEventKeys(){return n.privTranscriptionEventKeys}}t.ConversationConnectionConfig=n,n.privHost="dev.microsofttranslator.com",n.privRestPath="/capito/room",n.privApiVersion="2.0",n.privDefaultLanguageCode="en-US",n.privClientAppId="FC539C22-1767-4F1F-84BC-B4D811114F15",n.privWebSocketPath="/capito/translate",n.privTranscriptionEventKeys=["iCalUid","callId","organizer","FLAC","MTUri","DifferentiateGuestSpeakers","audiorecording","Threadid","OrganizerMri","OrganizerTenantId","UserToken"]},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranslatorRecognizer=t.ConversationRecognizerFactory=void 0;const i=r(2),n=r(4),s=r(64),o=r(79),a=r(261),c=r(264);t.ConversationRecognizerFactory=class{static fromConfig(e,t,r){return new p(e,t,r)}};class p extends o.Recognizer{constructor(e,t,r){const i=t;s.Contracts.throwIfNull(i,"speechConfig");const c=e;s.Contracts.throwIfNull(c,"conversationImpl"),super(r,i.properties,new a.ConversationConnectionFactory),this.privConversation=c,this.privIsDisposed=!1,this.privProperties=i.properties.clone(),this.privConnection=o.Connection.fromRecognizer(this);"on"===this.privProperties.getProperty(o.PropertyId.WebWorkerLoadType,"on").toLowerCase()&&"undefined"!=typeof Blob&&"undefined"!=typeof Worker?(this.privSetTimeout=n.Timeout.setTimeout,this.privClearTimeout=n.Timeout.clearTimeout):"undefined"!=typeof window?(this.privSetTimeout=window.setTimeout.bind(window),this.privClearTimeout=window.clearTimeout.bind(window)):(this.privSetTimeout=setTimeout,this.privClearTimeout=clearTimeout)}set connected(e){this.privConnection.connected=e}set disconnected(e){this.privConnection.disconnected=e}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get properties(){return this.privProperties}isDisposed(){return this.privIsDisposed}connect(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfNullOrWhitespace(e,"token"),this.privReco.conversationTranslatorToken=e,this.resetConversationTimeout(),this.privReco.connectAsync(t,r)}catch(e){if(r)if(e instanceof Error){const t=e;r(t.name+": "+t.message)}else r(e)}}disconnect(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),void 0!==this.privTimeoutToken&&this.privClearTimeout(this.privTimeoutToken),this.privReco.disconnect().then((()=>{e&&e()}),(e=>{t&&t(e)}))}catch(e){if(t)if(e instanceof Error){const r=e;t(r.name+": "+r.message)}else t(e);this.dispose(!0).catch((e=>{n.Events.instance.onEvent(new n.BackgroundEvent(e))}))}}sendRequest(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),this.sendMessage(e,t,r)}catch(e){if(r)if(e instanceof Error){const t=e;r(t.name+": "+t.message)}else r(e);this.dispose(!0).catch((e=>{n.Events.instance.onEvent(new n.BackgroundEvent(e))}))}}onToken(e){this.privConversation.onToken(e)}async close(){this.privIsDisposed||(this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close()),this.privConnection=void 0,await this.dispose(!0))}async dispose(e){this.privIsDisposed||e&&(void 0!==this.privTimeoutToken&&this.privClearTimeout(this.privTimeoutToken),this.privIsDisposed=!0,this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close(),this.privConnection=void 0),await super.dispose(e))}createRecognizerConfig(e){return new i.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,i){const n=r;return new c.ConversationServiceAdapter(e,t,n,i,this)}sendMessage(e,t,r){((e,t,r)=>{void 0!==e?e.then((()=>{try{t&&t()}catch(e){r&&r(`'Unhandled error on promise callback: ${e}'`)}}),(e=>{try{r&&r(e)}catch(e){}})):r&&r("Null promise")})(this.privReco.sendMessageAsync(e),t,r),this.resetConversationTimeout()}resetConversationTimeout(){void 0!==this.privTimeoutToken&&this.privClearTimeout(this.privTimeoutToken),this.privTimeoutToken=this.privSetTimeout((()=>{this.sendRequest(this.privConversation.getKeepAlive())}),6e4)}}t.ConversationTranslatorRecognizer=p},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationConnectionFactory=void 0;const i=r(60),n=r(4),s=r(64),o=r(79),a=r(135),c=r(259),p=r(262);class h extends a.ConnectionFactoryBase{create(e,t,r){const a=e.parameters.getProperty(o.PropertyId.ConversationTranslator_Host,c.ConversationConnectionConfig.host),h=e.parameters.getProperty(o.PropertyId.ConversationTranslator_CorrelationId,(0,n.createGuid)()),u=`wss://${a}${c.ConversationConnectionConfig.webSocketPath}`,d=e.parameters.getProperty(o.PropertyId.ConversationTranslator_Token,void 0);s.Contracts.throwIfNullOrUndefined(d,"token");const v={};v[c.ConversationConnectionConfig.configParams.apiVersion]=c.ConversationConnectionConfig.apiVersion,v[c.ConversationConnectionConfig.configParams.token]=d,v[c.ConversationConnectionConfig.configParams.correlationId]=h;const l="true"===e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false");return Promise.resolve(new i.WebsocketConnection(u,v,{},new p.ConversationWebsocketMessageFormatter,i.ProxyInfo.fromRecognizerConfig(e),l,r))}}t.ConversationConnectionFactory=h},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationWebsocketMessageFormatter=void 0;const i=r(4),n=r(263);t.ConversationWebsocketMessageFormatter=class{toConnectionMessage(e){const t=new i.Deferred;try{if(e.messageType===i.MessageType.Text){const r=new n.ConversationConnectionMessage(e.messageType,e.textContent,{},e.id);t.resolve(r)}else e.messageType===i.MessageType.Binary&&t.resolve(new n.ConversationConnectionMessage(e.messageType,e.binaryContent,void 0,e.id))}catch(e){t.reject(`Error formatting the message. Error: ${e}`)}return t.promise}fromConnectionMessage(e){const t=new i.Deferred;try{if(e.messageType===i.MessageType.Text){const r=`${e.textBody?e.textBody:""}`;t.resolve(new i.RawWebsocketMessage(i.MessageType.Text,r,e.id))}}catch(e){t.reject(`Error formatting the message. ${e}`)}return t.promise}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationConnectionMessage=void 0;const i=r(4);class n extends i.ConnectionMessage{constructor(e,t,r,i){super(e,t,r,i);const n=JSON.parse(this.textBody);void 0!==n.type&&(this.privConversationMessageType=n.type)}get conversationMessageType(){return this.privConversationMessageType}}t.ConversationConnectionMessage=n},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationServiceAdapter=void 0;const i=r(4),n=r(79),s=r(2),o=r(263),a=r(265),c=r(266),p=r(267),h=r(268);class u extends s.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privConnectionConfigPromise=void 0,this.privLastPartialUtteranceId="",this.privConversationServiceConnector=s,this.privConversationAuthentication=e,this.receiveMessageOverride=()=>this.receiveConversationMessageOverride(),this.recognizeOverride=()=>this.noOp(),this.postConnectImplOverride=e=>this.conversationConnectImpl(e),this.configConnectionOverride=()=>this.configConnection(),this.disconnectOverride=()=>this.privDisconnect(),this.privConversationRequestSession=new a.ConversationRequestSession((0,i.createNoDashGuid)()),this.privConversationConnectionFactory=t,this.privConversationIsDisposed=!1}isDisposed(){return super.isDisposed()||this.privConversationIsDisposed}async dispose(e){if(this.privConversationIsDisposed=!0,void 0!==this.privConnectionConfigPromise){const t=await this.privConnectionConfigPromise;await t.dispose(e)}await super.dispose(e)}async sendMessage(e){return(await this.fetchConnection()).send(new o.ConversationConnectionMessage(i.MessageType.Text,e))}async sendMessageAsync(e){const t=await this.fetchConnection();await t.send(new o.ConversationConnectionMessage(i.MessageType.Text,e))}privDisconnect(){if(!this.terminateMessageLoop)return this.cancelRecognition(this.privConversationRequestSession.sessionId,this.privConversationRequestSession.requestId,n.CancellationReason.Error,n.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,Promise.resolve()}async processTypeSpecificMessages(){return!0}cancelRecognition(e,t,r,i,s){this.terminateMessageLoop=!0;const o=new n.ConversationTranslationCanceledEventArgs(r,s,i,void 0,e);try{this.privConversationServiceConnector.canceled&&this.privConversationServiceConnector.canceled(this.privConversationServiceConnector,o)}catch{}}async conversationConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}async receiveConversationMessageOverride(){if(this.isDisposed()||this.terminateMessageLoop)return Promise.resolve();const e=new i.Deferred;try{const t=await this.fetchConnection(),r=await t.read();if(this.isDisposed()||this.terminateMessageLoop)return e.resolve(),Promise.resolve();if(!r)return this.receiveConversationMessageOverride();const i=this.privConversationRequestSession.sessionId,o=r.conversationMessageType.toLowerCase();let a=!1;try{switch(o){case"info":case"participant_command":case"command":const e=h.CommandResponsePayload.fromJSON(r.textBody);switch(e.command.toLowerCase()){case"participantlist":const t=h.ParticipantsListPayloadResponse.fromJSON(r.textBody),o=t.participants.map((e=>({avatar:e.avatar,displayName:e.nickname,id:e.participantId,isHost:e.ishost,isMuted:e.ismuted,isUsingTts:e.usetts,preferredLanguage:e.locale})));this.privConversationServiceConnector.participantsListReceived&&this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector,new c.ParticipantsListEventArgs(t.roomid,t.token,t.translateTo,t.profanityFilter,t.roomProfanityFilter,t.roomLocked,t.muteAll,o,i));break;case"settranslatetolanguages":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new c.ParticipantAttributeEventArgs(e.participantId,p.ConversationTranslatorCommandTypes.setTranslateToLanguages,e.value,i));break;case"setprofanityfiltering":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new c.ParticipantAttributeEventArgs(e.participantId,p.ConversationTranslatorCommandTypes.setProfanityFiltering,e.value,i));break;case"setmute":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new c.ParticipantAttributeEventArgs(e.participantId,p.ConversationTranslatorCommandTypes.setMute,e.value,i));break;case"setmuteall":this.privConversationServiceConnector.muteAllCommandReceived&&this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector,new c.MuteAllEventArgs(e.value,i));break;case"roomexpirationwarning":this.privConversationServiceConnector.conversationExpiration&&this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector,new n.ConversationExpirationEventArgs(e.value,this.privConversationRequestSession.sessionId));break;case"setusetts":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new c.ParticipantAttributeEventArgs(e.participantId,p.ConversationTranslatorCommandTypes.setUseTTS,e.value,i));break;case"setlockstate":this.privConversationServiceConnector.lockRoomCommandReceived&&this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector,new c.LockRoomEventArgs(e.value,i));break;case"changenickname":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new c.ParticipantAttributeEventArgs(e.participantId,p.ConversationTranslatorCommandTypes.changeNickname,e.value,i));break;case"joinsession":const a=h.ParticipantPayloadResponse.fromJSON(r.textBody),u={avatar:a.avatar,displayName:a.nickname,id:a.participantId,isHost:a.ishost,isMuted:a.ismuted,isUsingTts:a.usetts,preferredLanguage:a.locale};this.privConversationServiceConnector.participantJoinCommandReceived&&this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector,new c.ParticipantEventArgs(u,i));break;case"leavesession":const d={id:e.participantId};this.privConversationServiceConnector.participantLeaveCommandReceived&&this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector,new c.ParticipantEventArgs(d,i));break;case"disconnectsession":e.participantId;break;case"token":const v=new s.CognitiveTokenAuthentication((()=>{const t=e.token;return Promise.resolve(t)}),(()=>{const t=e.token;return Promise.resolve(t)}));this.authentication=v,this.privConversationServiceConnector.onToken(v)}break;case"partial":case"final":const t=h.SpeechResponsePayload.fromJSON(r.textBody),u="final"===o?n.ResultReason.TranslatedParticipantSpeech:n.ResultReason.TranslatingParticipantSpeech,d=new n.ConversationTranslationResult(t.participantId,this.getTranslations(t.translations),t.language,t.id,u,t.recognition,void 0,void 0,r.textBody,void 0);t.isFinal?((void 0!==d.text&&d.text.length>0||t.id===this.privLastPartialUtteranceId)&&(a=!0),a&&this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new c.ConversationReceivedTranslationEventArgs(p.ConversationTranslatorMessageTypes.final,d,i))):void 0!==d.text&&(this.privLastPartialUtteranceId=t.id,this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new c.ConversationReceivedTranslationEventArgs(p.ConversationTranslatorMessageTypes.partial,d,i)));break;case"translated_message":const v=h.TextResponsePayload.fromJSON(r.textBody),l=new n.ConversationTranslationResult(v.participantId,this.getTranslations(v.translations),v.language,void 0,void 0,v.originalText,void 0,void 0,void 0,r.textBody,void 0);this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new c.ConversationReceivedTranslationEventArgs(p.ConversationTranslatorMessageTypes.instantMessage,l,i))}}catch(e){}return this.receiveConversationMessageOverride()}catch(e){this.terminateMessageLoop=!0}return e.promise}async startMessageLoop(){if(this.isDisposed())return Promise.resolve();this.terminateMessageLoop=!1;const e=this.receiveConversationMessageOverride();try{return await e}catch(e){return this.cancelRecognition(this.privRequestSession?this.privRequestSession.sessionId:"",this.privRequestSession?this.privRequestSession.requestId:"",n.CancellationReason.Error,n.CancellationErrorCode.RuntimeError,e),null}}configConnection(){return this.isDisposed()?Promise.resolve(void 0):void 0!==this.privConnectionConfigPromise?this.privConnectionConfigPromise.then((e=>e.state()===i.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection()):this.privConnectionConfigPromise),(()=>(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection()))):this.terminateMessageLoop?Promise.resolve(void 0):(this.privConnectionConfigPromise=this.connectImpl().then((e=>e)),this.privConnectionConfigPromise)}getTranslations(e){let t;if(void 0!==e){t=new n.Translations;for(const r of e)t.set(r.lang,r.translation)}return t}}t.ConversationServiceAdapter=u},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationRequestSession=void 0;const i=r(4);t.ConversationRequestSession=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privSessionId=e,this.privRequestId=(0,i.createNoDashGuid)(),this.privRequestCompletionDeferral=new i.Deferred}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get completionPromise(){return this.privRequestCompletionDeferral.promise}onPreConnectionStart(e,t){this.privSessionId=t}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){200!==e&&403===e&&this.onComplete()}onServiceTurnEndResponse(e){e?this.privRequestId=(0,i.createNoDashGuid)():this.onComplete()}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(const e of this.privDetachables)await e.detach()}}onComplete(){}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationReceivedTranslationEventArgs=t.ParticipantsListEventArgs=t.ParticipantAttributeEventArgs=t.ParticipantEventArgs=t.LockRoomEventArgs=t.MuteAllEventArgs=void 0;const i=r(79);class n extends i.SessionEventArgs{constructor(e,t){super(t),this.privIsMuted=e}get isMuted(){return this.privIsMuted}}t.MuteAllEventArgs=n;class s extends i.SessionEventArgs{constructor(e,t){super(t),this.privIsLocked=e}get isMuted(){return this.privIsLocked}}t.LockRoomEventArgs=s;class o extends i.SessionEventArgs{constructor(e,t){super(t),this.privParticipant=e}get participant(){return this.privParticipant}}t.ParticipantEventArgs=o;class a extends i.SessionEventArgs{constructor(e,t,r,i){super(i),this.privKey=t,this.privValue=r,this.privParticipantId=e}get value(){return this.privValue}get key(){return this.privKey}get id(){return this.privParticipantId}}t.ParticipantAttributeEventArgs=a;class c extends i.SessionEventArgs{constructor(e,t,r,i,n,s,o,a,c){super(c),this.privRoomId=e,this.privSessionToken=t,this.privTranslateTo=r,this.privProfanityFilter=i,this.privRoomProfanityFilter=n,this.privIsRoomLocked=s,this.privIsRoomLocked=o,this.privParticipants=a}get sessionToken(){return this.privSessionToken}get conversationId(){return this.privRoomId}get translateTo(){return this.privTranslateTo}get profanityFilter(){return this.privProfanityFilter}get roomProfanityFilter(){return this.privRoomProfanityFilter}get isRoomLocked(){return this.privIsRoomLocked}get isMuteAll(){return this.privIsMuteAll}get participants(){return this.privParticipants}}t.ParticipantsListEventArgs=c;t.ConversationReceivedTranslationEventArgs=class{constructor(e,t,r){this.privPayload=t,this.privCommand=e,this.privSessionId=r}get payload(){return this.privPayload}get command(){return this.privCommand}get sessionId(){return this.privSessionId}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranslatorCommandTypes=t.ConversationTranslatorMessageTypes=t.InternalParticipants=void 0;t.InternalParticipants=class{constructor(e=[],t){this.participants=e,this.meId=t}addOrUpdateParticipant(e){if(void 0===e)return;const t=this.getParticipantIndex(e.id);return t>-1?this.participants.splice(t,1,e):this.participants.push(e),this.getParticipant(e.id)}getParticipantIndex(e){return this.participants.findIndex((t=>t.id===e))}getParticipant(e){return this.participants.find((t=>t.id===e))}deleteParticipant(e){this.participants=this.participants.filter((t=>t.id!==e))}get host(){return this.participants.find((e=>!0===e.isHost))}get me(){return this.getParticipant(this.meId)}},t.ConversationTranslatorMessageTypes={command:"command",final:"final",info:"info",instantMessage:"instant_message",keepAlive:"keep_alive",partial:"partial",participantCommand:"participant_command",translatedMessage:"translated_message"},t.ConversationTranslatorCommandTypes={changeNickname:"ChangeNickname",disconnectSession:"DisconnectSession",ejectParticipant:"EjectParticipant",instant_message:"instant_message",joinSession:"JoinSession",leaveSession:"LeaveSession",participantList:"ParticipantList",roomExpirationWarning:"RoomExpirationWarning",setLockState:"SetLockState",setMute:"SetMute",setMuteAll:"SetMuteAll",setProfanityFiltering:"SetProfanityFiltering",setTranslateToLanguages:"SetTranslateToLanguages",setUseTTS:"SetUseTTS"}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TextResponsePayload=t.SpeechResponsePayload=t.ParticipantPayloadResponse=t.ParticipantsListPayloadResponse=t.CommandResponsePayload=void 0;var i=r(269);Object.defineProperty(t,"CommandResponsePayload",{enumerable:!0,get:function(){return i.CommandResponsePayload}});var n=r(270);Object.defineProperty(t,"ParticipantsListPayloadResponse",{enumerable:!0,get:function(){return n.ParticipantsListPayloadResponse}}),Object.defineProperty(t,"ParticipantPayloadResponse",{enumerable:!0,get:function(){return n.ParticipantPayloadResponse}});var s=r(271);Object.defineProperty(t,"SpeechResponsePayload",{enumerable:!0,get:function(){return s.SpeechResponsePayload}}),Object.defineProperty(t,"TextResponsePayload",{enumerable:!0,get:function(){return s.TextResponsePayload}})},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommandResponsePayload=void 0;class r{constructor(e){this.privCommandResponse=(e=>JSON.parse(e))(e)}get type(){return this.privCommandResponse.type}get command(){return this.privCommandResponse.command}get id(){return this.privCommandResponse.id}get nickname(){return this.privCommandResponse.nickname}get participantId(){return this.privCommandResponse.participantId}get roomid(){return this.privCommandResponse.roomid}get value(){return this.privCommandResponse.value}get token(){return this.privCommandResponse.token}static fromJSON(e){return new r(e)}}t.CommandResponsePayload=r},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParticipantPayloadResponse=t.ParticipantsListPayloadResponse=void 0;class r{constructor(e){this.privParticipantsPayloadResponse=(e=>JSON.parse(e))(e)}get roomid(){return this.privParticipantsPayloadResponse.roomid}get id(){return this.privParticipantsPayloadResponse.id}get command(){return this.privParticipantsPayloadResponse.command}get participants(){return this.privParticipantsPayloadResponse.participants}get token(){return this.privParticipantsPayloadResponse.token}get translateTo(){return this.privParticipantsPayloadResponse.translateTo}get profanityFilter(){return this.privParticipantsPayloadResponse.profanityFilter}get roomProfanityFilter(){return this.privParticipantsPayloadResponse.roomProfanityFilter}get roomLocked(){return this.privParticipantsPayloadResponse.roomLocked}get muteAll(){return this.privParticipantsPayloadResponse.muteAll}get type(){return this.privParticipantsPayloadResponse.type}static fromJSON(e){return new r(e)}}t.ParticipantsListPayloadResponse=r;class i{constructor(e){this.privParticipantPayloadResponse=(e=>JSON.parse(e))(e)}get nickname(){return this.privParticipantPayloadResponse.nickname}get locale(){return this.privParticipantPayloadResponse.locale}get usetts(){return this.privParticipantPayloadResponse.usetts}get ismuted(){return this.privParticipantPayloadResponse.ismuted}get ishost(){return this.privParticipantPayloadResponse.ishost}get participantId(){return this.privParticipantPayloadResponse.participantId}get avatar(){return this.privParticipantPayloadResponse.avatar}static fromJSON(e){return new i(e)}}t.ParticipantPayloadResponse=i},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TextResponsePayload=t.SpeechResponsePayload=void 0;class r{constructor(e){this.privSpeechResponse=(e=>JSON.parse(e))(e)}get recognition(){return this.privSpeechResponse.recognition}get translations(){return this.privSpeechResponse.translations}get id(){return this.privSpeechResponse.id}get language(){return this.privSpeechResponse.language}get nickname(){return this.privSpeechResponse.nickname}get participantId(){return this.privSpeechResponse.participantId}get roomid(){return this.privSpeechResponse.roomid}get timestamp(){return this.privSpeechResponse.timestamp}get type(){return this.privSpeechResponse.type}get isFinal(){return"final"===this.privSpeechResponse.type}static fromJSON(e){return new r(e)}}t.SpeechResponsePayload=r;class i{constructor(e){this.privTextResponse=(e=>JSON.parse(e))(e)}get originalText(){return this.privTextResponse.originalText}get translations(){return this.privTextResponse.translations}get id(){return this.privTextResponse.id}get language(){return this.privTextResponse.language}get nickname(){return this.privTextResponse.nickname}get participantId(){return this.privTextResponse.participantId}get roomid(){return this.privTextResponse.roomid}get timestamp(){return this.privTextResponse.timestamp}get type(){return this.privTextResponse.type}static fromJSON(e){return new i(e)}}t.TextResponsePayload=i},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranscriberRecognizer=void 0;const i=r(4),n=r(64),s=r(79),o=r(2),a=r(113);class c extends s.Recognizer{constructor(e,t){const r=e;n.Contracts.throwIfNull(r,"speechTranslationConfig");const i=t;n.Contracts.throwIfNull(i,"audioConfigImpl"),n.Contracts.throwIfNullOrWhitespace(r.speechRecognitionLanguage,s.PropertyId[s.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new o.TranscriberConnectionFactory),this.privDisposedRecognizer=!1,this.isMeetingRecognizer=!1}get speechRecognitionLanguage(){return n.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(s.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){n.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(s.PropertyId.SpeechServiceAuthorization_Token,e)}set conversation(e){n.Contracts.throwIfNullOrUndefined(e,"Conversation"),this.isMeetingRecognizer=!1,this.privConversation=e}getConversationInfo(){return n.Contracts.throwIfNullOrUndefined(this.privConversation,"Conversation"),this.privConversation.conversationInfo}set meeting(e){n.Contracts.throwIfNullOrUndefined(e,"Meeting"),this.isMeetingRecognizer=!0,this.privMeeting=e}getMeetingInfo(){return n.Contracts.throwIfNullOrUndefined(this.privMeeting,"Meeting"),this.privMeeting.meetingInfo}IsMeetingRecognizer(){return this.isMeetingRecognizer}startContinuousRecognitionAsync(e,t){(0,i.marshalPromiseToCallbacks)(this.startContinuousRecognitionAsyncImpl(a.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){(0,i.marshalPromiseToCallbacks)(this.stopContinuousRecognitionAsyncImpl(),e,t)}async close(){this.privDisposedRecognizer||await this.dispose(!0)}async pushConversationEvent(e,t){const r=this.privReco;n.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendSpeechEventAsync(e,t)}async pushMeetingEvent(e,t){const r=this.privReco;n.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendMeetingSpeechEventAsync(e,t)}async enforceAudioGating(){const e=this.audioConfig,t=(await e.format).channels;if(1===t){if("true"!==this.properties.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase())throw new Error("Single channel audio configuration for MeetingTranscriber is currently under private preview, please contact diarizationrequest@microsoft.com for more details")}else if(8!==t)throw new Error(`Unsupported audio configuration: Detected ${t}-channel audio`)}connectMeetingCallbacks(e){this.isMeetingRecognizer=!0,this.canceled=(t,r)=>{e.canceled&&e.canceled(e,r)},this.recognizing=(t,r)=>{e.transcribing&&e.transcribing(e,r)},this.recognized=(t,r)=>{e.transcribed&&e.transcribed(e,r)},this.sessionStarted=(t,r)=>{e.sessionStarted&&e.sessionStarted(e,r)},this.sessionStopped=(t,r)=>{e.sessionStopped&&e.sessionStopped(e,r)}}disconnectCallbacks(){this.canceled=void 0,this.recognizing=void 0,this.recognized=void 0,this.sessionStarted=void 0,this.sessionStopped=void 0}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new o.RecognizerConfig(e,this.properties)}createServiceRecognizer(e,t,r,i){const n=r;return new o.TranscriptionServiceRecognizer(e,t,n,i,this)}}t.TranscriberRecognizer=c},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisAudioMetadata=t.MetadataType=void 0,function(e){e.WordBoundary="WordBoundary",e.Bookmark="Bookmark",e.Viseme="Viseme",e.SentenceBoundary="SentenceBoundary",e.SessionEnd="SessionEnd",e.AvatarSignal="TalkingAvatarSignal"}(t.MetadataType||(t.MetadataType={}));class r{constructor(e){this.privSynthesisAudioMetadata=JSON.parse(e)}static fromJSON(e){return new r(e)}get Metadata(){return this.privSynthesisAudioMetadata.Metadata}}t.SynthesisAudioMetadata=r},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisTurn=void 0;const i=r(4),n=r(84),s=r(79),o=r(273),a=r(275);class c{constructor(){this.privIsDisposed=!1,this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!1,this.privBytesReceived=0,this.privInTurn=!1,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privRequestId=(0,i.createNoDashGuid)(),this.privTurnDeferral=new i.Deferred,this.privTurnDeferral.resolve()}get requestId(){return this.privRequestId}get streamId(){return this.privStreamId}set streamId(e){this.privStreamId=e}get audioOutputFormat(){return this.privAudioOutputFormat}set audioOutputFormat(e){this.privAudioOutputFormat=e}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSynthesisEnded(){return this.privIsSynthesisEnded}get isSynthesizing(){return this.privIsSynthesizing}get currentTextOffset(){return this.privTextOffset}get currentSentenceOffset(){return this.privSentenceOffset}get bytesReceived(){return this.privBytesReceived}get audioDuration(){return this.privAudioDuration}get extraProperties(){if(this.privWebRTCSDP){const e=new s.PropertyCollection;return e.setProperty(s.PropertyId.TalkingAvatarService_WebRTC_SDP,this.privWebRTCSDP),e}}async getAllReceivedAudio(){return this.privReceivedAudio?Promise.resolve(this.privReceivedAudio):this.privIsSynthesisEnded?(await this.readAllAudioFromStream(),Promise.resolve(this.privReceivedAudio)):null}async getAllReceivedAudioWithHeader(){if(this.privReceivedAudioWithHeader)return this.privReceivedAudioWithHeader;if(!this.privIsSynthesisEnded)return null;if(this.audioOutputFormat.hasHeader){const e=await this.getAllReceivedAudio();return this.privReceivedAudioWithHeader=this.audioOutputFormat.addHeader(e),this.privReceivedAudioWithHeader}return this.getAllReceivedAudio()}startNewSynthesis(e,t,r,i){this.privIsSynthesisEnded=!1,this.privIsSynthesizing=!0,this.privRequestId=e,this.privRawText=t,this.privIsSSML=r,this.privAudioOutputStream=new n.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privAudioOutputFormat,this.privReceivedAudio=null,this.privReceivedAudioWithHeader=null,this.privBytesReceived=0,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privPartialVisemeAnimation="",this.privWebRTCSDP="",void 0!==i&&(this.privTurnAudioDestination=i,this.privTurnAudioDestination.format=this.privAudioOutputFormat),this.onEvent(new a.SynthesisTriggeredEvent(this.requestId,void 0,void 0===i?void 0:i.id()))}onPreConnectionStart(e){this.privAuthFetchEventId=e,this.onEvent(new a.ConnectingToSynthesisServiceEvent(this.privRequestId,this.privAuthFetchEventId))}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){if(200===e)return this.onEvent(new a.SynthesisStartedEvent(this.requestId,this.privAuthFetchEventId)),void(this.privBytesReceived=0);403===e&&this.onComplete()}onServiceResponseMessage(e){const t=JSON.parse(e);this.streamId=t.audio.streamId}onServiceTurnEndResponse(){this.privInTurn=!1,this.privTurnDeferral.resolve(),this.onComplete()}onServiceTurnStartResponse(e){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch((()=>{}))),this.privInTurn=!0,this.privTurnDeferral=new i.Deferred;const t=JSON.parse(e);t.webrtc&&(this.privWebRTCSDP=t.webrtc.connectionString)}onAudioChunkReceived(e){this.isSynthesizing&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength,void 0!==this.privTurnAudioDestination&&this.privTurnAudioDestination.write(e))}onTextBoundaryEvent(e){this.updateTextOffset(e.Data.text.Text,e.Type)}onVisemeMetadataReceived(e){void 0!==e.Data.AnimationChunk&&(this.privPartialVisemeAnimation+=e.Data.AnimationChunk)}onSessionEnd(e){this.privAudioDuration=e.Data.Offset}async constructSynthesisResult(){const e=await this.getAllReceivedAudioWithHeader();return new s.SpeechSynthesisResult(this.requestId,s.ResultReason.SynthesizingAudioCompleted,e,void 0,this.extraProperties,this.audioDuration)}dispose(){this.privIsDisposed||(this.privIsDisposed=!0)}onStopSynthesizing(){this.onComplete()}getAndClearVisemeAnimation(){const e=this.privPartialVisemeAnimation;return this.privPartialVisemeAnimation="",e}onEvent(e){i.Events.instance.onEvent(e)}static isXmlTag(e){return e.length>=2&&"<"===e[0]&&">"===e[e.length-1]}updateTextOffset(e,t){t===o.MetadataType.WordBoundary?(this.privTextOffset=this.privRawText.indexOf(e,this.privNextSearchTextIndex),this.privTextOffset>=0&&(this.privNextSearchTextIndex=this.privTextOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privTextOffset)&&!c.isXmlTag(e)&&this.updateTextOffset(e,t))):(this.privSentenceOffset=this.privRawText.indexOf(e,this.privNextSearchSentenceIndex),this.privSentenceOffset>=0&&(this.privNextSearchSentenceIndex=this.privSentenceOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privSentenceOffset)&&!c.isXmlTag(e)&&this.updateTextOffset(e,t)))}onComplete(){this.privIsSynthesizing&&(this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!0,this.privAudioOutputStream.close(),this.privInTurn=!1,void 0!==this.privTurnAudioDestination&&(this.privTurnAudioDestination.close(),this.privTurnAudioDestination=void 0))}async readAllAudioFromStream(){if(this.privIsSynthesisEnded){this.privReceivedAudio=new ArrayBuffer(this.bytesReceived);try{await this.privAudioOutputStream.read(this.privReceivedAudio)}catch(e){this.privReceivedAudio=new ArrayBuffer(0)}}}withinXmlTag(e){return this.privRawText.indexOf("<",e+1)>this.privRawText.indexOf(">",e+1)}}t.SynthesisTurn=c},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisStartedEvent=t.ConnectingToSynthesisServiceEvent=t.SynthesisTriggeredEvent=t.SpeechSynthesisEvent=void 0;const i=r(4);class n extends i.PlatformEvent{constructor(e,t,r=i.EventType.Info){super(e,r),this.privRequestId=t}get requestId(){return this.privRequestId}}t.SpeechSynthesisEvent=n;t.SynthesisTriggeredEvent=class extends n{constructor(e,t,r){super("SynthesisTriggeredEvent",e),this.privSessionAudioDestinationId=t,this.privTurnAudioDestinationId=r}get audioSessionDestinationId(){return this.privSessionAudioDestinationId}get audioTurnDestinationId(){return this.privTurnAudioDestinationId}};t.ConnectingToSynthesisServiceEvent=class extends n{constructor(e,t){super("ConnectingToSynthesisServiceEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};t.SynthesisStartedEvent=class extends n{constructor(e,t){super("SynthesisStartedEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisAdapterBase=void 0;const i=r(4),n=r(79),s=r(2),o=r(207);class a{constructor(e,t,r,o){if(this.speakOverride=void 0,this.receiveMessageOverride=void 0,this.connectImplOverride=void 0,this.configConnectionOverride=void 0,this.privConnectionConfigurationPromise=void 0,!e)throw new i.ArgumentNullError("authentication");if(!t)throw new i.ArgumentNullError("connectionFactory");if(!r)throw new i.ArgumentNullError("synthesizerConfig");this.privAuthentication=e,this.privConnectionFactory=t,this.privSynthesizerConfig=r,this.privIsDisposed=!1,this.privSessionAudioDestination=o,this.privSynthesisTurn=new s.SynthesisTurn,this.privConnectionEvents=new i.EventSource,this.privServiceEvents=new i.EventSource,this.privSynthesisContext=new s.SynthesisContext,this.privAgentConfig=new s.AgentConfig,this.connectionEvents.attach((e=>{if("ConnectionClosedEvent"===e.name){const t=e;1e3!==t.statusCode&&this.cancelSynthesisLocal(n.CancellationReason.Error,1007===t.statusCode?n.CancellationErrorCode.BadRequestParameters:n.CancellationErrorCode.ConnectionFailure,`${t.reason} websocket error code: ${t.statusCode}`)}}))}get synthesisContext(){return this.privSynthesisContext}get agentConfig(){return this.privAgentConfig}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set audioOutputFormat(e){this.privAudioOutputFormat=e,this.privSynthesisTurn.audioOutputFormat=e,void 0!==this.privSessionAudioDestination&&(this.privSessionAudioDestination.format=e),void 0!==this.synthesisContext&&(this.synthesisContext.audioOutputFormat=e)}isDisposed(){return this.privIsDisposed}async dispose(e){if(this.privIsDisposed=!0,void 0!==this.privSessionAudioDestination&&this.privSessionAudioDestination.close(),void 0!==this.privConnectionConfigurationPromise){const t=await this.privConnectionConfigurationPromise;await t.dispose(e)}}async connect(){await this.connectImpl()}async sendNetworkMessage(e,t){const r="string"==typeof t?i.MessageType.Text:i.MessageType.Binary,n="string"==typeof t?"application/json":"";return(await this.fetchConnection()).send(new o.SpeechConnectionMessage(r,e,this.privSynthesisTurn.requestId,n,t))}async Speak(e,t,r,i,s,o){let a;if(a=t?e:this.privSynthesizer.buildSsml(e),void 0!==this.speakOverride)return this.speakOverride(a,r,i,s);this.privSuccessCallback=i,this.privErrorCallback=s,this.privSynthesisTurn.startNewSynthesis(r,e,t,o);try{await this.connectImpl();const e=await this.fetchConnection();await this.sendSynthesisContext(e),await this.sendSsmlMessage(e,a,r),this.onSynthesisStarted(r),this.receiveMessage()}catch(e){return this.cancelSynthesisLocal(n.CancellationReason.Error,n.CancellationErrorCode.ConnectionFailure,e),Promise.reject(e)}}async stopSpeaking(){await this.connectImpl();return(await this.fetchConnection()).send(new o.SpeechConnectionMessage(i.MessageType.Text,"synthesis.control",this.privSynthesisTurn.requestId,"application/json",JSON.stringify({action:"stop"})))}cancelSynthesis(e,t,r,i){const o=new n.PropertyCollection;o.setProperty(s.CancellationErrorCodePropertyName,n.CancellationErrorCode[r]);const a=new n.SpeechSynthesisResult(e,n.ResultReason.Canceled,void 0,i,o);if(this.onSynthesisCancelled(a),this.privSuccessCallback)try{this.privSuccessCallback(a)}catch{}}cancelSynthesisLocal(e,t,r){this.privSynthesisTurn.isSynthesizing&&(this.privSynthesisTurn.onStopSynthesizing(),this.cancelSynthesis(this.privSynthesisTurn.requestId,e,t,r))}processTypeSpecificMessages(e){return!0}async receiveMessage(){try{const e=await this.fetchConnection(),t=await e.read();if(void 0!==this.receiveMessageOverride)return this.receiveMessageOverride();if(this.privIsDisposed)return;if(!t)return this.privSynthesisTurn.isSynthesizing?this.receiveMessage():void 0;const r=o.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privSynthesisTurn.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privSynthesisTurn.onServiceTurnStartResponse(r.textBody);break;case"response":this.privSynthesisTurn.onServiceResponseMessage(r.textBody);break;case"audio":this.privSynthesisTurn.streamId.toLowerCase()===r.streamId.toLowerCase()&&r.binaryBody&&(this.privSynthesisTurn.onAudioChunkReceived(r.binaryBody),this.onSynthesizing(r.binaryBody),void 0!==this.privSessionAudioDestination&&this.privSessionAudioDestination.write(r.binaryBody));break;case"audio.metadata":const e=s.SynthesisAudioMetadata.fromJSON(r.textBody).Metadata;for(const t of e)switch(t.Type){case s.MetadataType.WordBoundary:case s.MetadataType.SentenceBoundary:this.privSynthesisTurn.onTextBoundaryEvent(t);const e=new n.SpeechSynthesisWordBoundaryEventArgs(t.Data.Offset,t.Data.Duration,t.Data.text.Text,t.Data.text.Length,t.Type===s.MetadataType.WordBoundary?this.privSynthesisTurn.currentTextOffset:this.privSynthesisTurn.currentSentenceOffset,t.Data.text.BoundaryType);this.onWordBoundary(e);break;case s.MetadataType.Bookmark:const r=new n.SpeechSynthesisBookmarkEventArgs(t.Data.Offset,t.Data.Bookmark);this.onBookmarkReached(r);break;case s.MetadataType.Viseme:if(this.privSynthesisTurn.onVisemeMetadataReceived(t),t.Data.IsLastAnimation){const e=new n.SpeechSynthesisVisemeEventArgs(t.Data.Offset,t.Data.VisemeId,this.privSynthesisTurn.getAndClearVisemeAnimation());this.onVisemeReceived(e)}break;case s.MetadataType.AvatarSignal:this.onAvatarEvent(t);break;case s.MetadataType.SessionEnd:this.privSynthesisTurn.onSessionEnd(t)}break;case"turn.end":let t;this.privSynthesisTurn.onServiceTurnEndResponse();try{t=await this.privSynthesisTurn.constructSynthesisResult(),this.privSuccessCallback&&this.privSuccessCallback(t)}catch(e){this.privErrorCallback&&this.privErrorCallback(e)}this.onSynthesisCompleted(t);break;default:this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new i.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch(e){}}sendSynthesisContext(e){this.setSynthesisContextSynthesisSection();const t=this.synthesisContext.toJSON();if(t)return e.send(new o.SpeechConnectionMessage(i.MessageType.Text,"synthesis.context",this.privSynthesisTurn.requestId,"application/json",t))}setSpeechConfigSynthesisSection(){}connectImpl(e=!1){if(null!=this.privConnectionPromise)return this.privConnectionPromise.then((e=>e.state()===i.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()):this.privConnectionPromise),(()=>(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl())));this.privAuthFetchEventId=(0,i.createNoDashGuid)(),this.privConnectionId=(0,i.createNoDashGuid)(),this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId);const t=e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId);return this.privConnectionPromise=t.then((async t=>{this.privSynthesisTurn.onAuthCompleted(!1);const r=await this.privConnectionFactory.create(this.privSynthesizerConfig,t,this.privConnectionId);r.events.attach((e=>{this.connectionEvents.onEvent(e)}));const i=await r.open();return 200===i.statusCode?(this.privSynthesisTurn.onConnectionEstablishCompleted(i.statusCode),Promise.resolve(r)):403!==i.statusCode||e?(this.privSynthesisTurn.onConnectionEstablishCompleted(i.statusCode),Promise.reject(`Unable to contact server. StatusCode: ${i.statusCode},\n ${this.privSynthesizerConfig.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Url)} Reason: ${i.reason}`)):this.connectImpl(!0)}),(e=>{throw this.privSynthesisTurn.onAuthCompleted(!0),new Error(e)})),this.privConnectionPromise.catch((()=>{})),this.privConnectionPromise}sendSpeechServiceConfig(e,t){if(t)return e.send(new o.SpeechConnectionMessage(i.MessageType.Text,"speech.config",this.privSynthesisTurn.requestId,"application/json",t))}sendSsmlMessage(e,t,r){return e.send(new o.SpeechConnectionMessage(i.MessageType.Text,"ssml",r,"application/ssml+xml",t))}async fetchConnection(){return void 0!==this.privConnectionConfigurationPromise?this.privConnectionConfigurationPromise.then((e=>e.state()===i.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection()):this.privConnectionConfigurationPromise),(()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection()))):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async configureConnection(){const e=await this.connectImpl();return void 0!==this.configConnectionOverride?this.configConnectionOverride(e):(this.setSpeechConfigSynthesisSection(),await this.sendSpeechServiceConfig(e,this.privSynthesizerConfig.SpeechServiceConfig.serialize()),e)}onAvatarEvent(e){}onSynthesisStarted(e){}onSynthesizing(e){}onSynthesisCancelled(e){}onSynthesisCompleted(e){}onWordBoundary(e){}onVisemeReceived(e){}onBookmarkReached(e){}}t.SynthesisAdapterBase=a,a.telemetryDataEnabled=!0},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AvatarSynthesisAdapter=void 0;const i=r(79),n=r(2);class s extends n.SynthesisAdapterBase{constructor(e,t,r,i,n){super(e,t,r,void 0),this.privAvatarSynthesizer=i,this.privSynthesizer=i,this.privAvatarConfig=n}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(void 0)}setSpeechConfigSynthesisSection(){this.privSynthesizerConfig.synthesisVideoSection={format:{bitrate:this.privAvatarConfig.videoFormat?.bitrate,codec:this.privAvatarConfig.videoFormat?.codec,crop:{bottomRight:{x:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.y},topLeft:{x:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.y}},resolution:{height:this.privAvatarConfig.videoFormat?.height,width:this.privAvatarConfig.videoFormat?.width}},protocol:{name:"WebRTC",webrtcConfig:{clientDescription:btoa(this.privSynthesizerConfig.parameters.getProperty(i.PropertyId.TalkingAvatarService_WebRTC_SDP)),iceServers:this.privAvatarConfig.remoteIceServers??this.privAvatarSynthesizer.iceServers}},talkingAvatar:{background:{color:this.privAvatarConfig.backgroundColor,image:{url:this.privAvatarConfig.backgroundImage?.toString()}},character:this.privAvatarConfig.character,customized:this.privAvatarConfig.customized,style:this.privAvatarConfig.style,useBuiltInVoice:this.privAvatarConfig.useBuiltInVoice}}}onAvatarEvent(e){if(this.privAvatarSynthesizer.avatarEventReceived){const t=new i.AvatarEventArgs(e.Data.Offset,e.Data.Name);try{this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer,t)}catch(e){}}}}t.AvatarSynthesisAdapter=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisAdapter=void 0;const i=r(79),n=r(2);class s extends n.SynthesisAdapterBase{constructor(e,t,r,i,n){super(e,t,r,n),this.privSpeechSynthesizer=i,this.privSynthesizer=i}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(this.privSpeechSynthesizer)}onSynthesisStarted(e){const t=new i.SpeechSynthesisEventArgs(new i.SpeechSynthesisResult(e,i.ResultReason.SynthesizingAudioStarted));this.privSpeechSynthesizer.synthesisStarted&&this.privSpeechSynthesizer.synthesisStarted(this.privSpeechSynthesizer,t)}onSynthesizing(e){if(this.privSpeechSynthesizer.synthesizing)try{const t=this.privSynthesisTurn.audioOutputFormat.addHeader(e),r=new i.SpeechSynthesisEventArgs(new i.SpeechSynthesisResult(this.privSynthesisTurn.requestId,i.ResultReason.SynthesizingAudio,t));this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer,r)}catch(e){}}onSynthesisCancelled(e){if(this.privSpeechSynthesizer.SynthesisCanceled){const t=new i.SpeechSynthesisEventArgs(e);try{this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer,t)}catch{}}}onSynthesisCompleted(e){if(this.privSpeechSynthesizer.synthesisCompleted)try{this.privSpeechSynthesizer.synthesisCompleted(this.privSpeechSynthesizer,new i.SpeechSynthesisEventArgs(e))}catch(e){}}onWordBoundary(e){if(this.privSpeechSynthesizer.wordBoundary)try{this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer,e)}catch(e){}}onVisemeReceived(e){if(this.privSpeechSynthesizer.visemeReceived)try{this.privSpeechSynthesizer.visemeReceived(this.privSpeechSynthesizer,e)}catch(e){}}onBookmarkReached(e){if(this.privSpeechSynthesizer.bookmarkReached)try{this.privSpeechSynthesizer.bookmarkReached(this.privSpeechSynthesizer,e)}catch(e){}}}t.SpeechSynthesisAdapter=s},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisRestAdapter=void 0;const i=r(60),n=r(79),s=r(135),o=r(54);t.SynthesisRestAdapter=class{constructor(e,t){let r=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Endpoint,void 0);if(!r){const t=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Region,"westus"),i=s.ConnectionFactoryBase.getHostSuffix(t);r=e.parameters.getProperty(n.PropertyId.SpeechServiceConnection_Host,`https://${t}.tts.speech${i}`)}this.privUri=`${r}/cognitiveservices/voices/list`;const o=i.RestConfigBase.requestOptions;this.privRestAdapter=new i.RestMessageAdapter(o),this.privAuthentication=t}getVoicesList(e){return this.privRestAdapter.setHeaders(o.HeaderNames.ConnectionId,e),this.privAuthentication.fetch(e).then((e=>(this.privRestAdapter.setHeaders(e.headerName,e.token),this.privRestAdapter.request(i.RestRequestType.Get,this.privUri))))}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesizerConfig=t.SynthesisServiceType=void 0;const i=r(2);var n;!function(e){e[e.Standard=0]="Standard",e[e.Custom=1]="Custom"}(n=t.SynthesisServiceType||(t.SynthesisServiceType={}));t.SynthesizerConfig=class{constructor(e,t){this.privSynthesisServiceType=n.Standard,this.avatarEnabled=!1,this.privSpeechServiceConfig=e||new i.SpeechServiceConfig(new i.Context(null)),this.privParameters=t}get parameters(){return this.privParameters}get synthesisServiceType(){return this.privSynthesisServiceType}set synthesisServiceType(e){this.privSynthesisServiceType=e}set synthesisVideoSection(e){this.privSpeechServiceConfig.Context.synthesis={video:e}}get SpeechServiceConfig(){return this.privSpeechServiceConfig}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisContext=void 0;const i=r(79);t.SynthesisContext=class{constructor(){this.privContext={}}setSection(e,t){this.privContext[e]=t}set audioOutputFormat(e){this.privAudioOutputFormat=e}toJSON(){return JSON.stringify(this.privContext)}setSynthesisSection(e){const t=this.buildSynthesisContext(e);this.setSection("synthesis",t)}buildSynthesisContext(e){return{audio:{metadataOptions:{bookmarkEnabled:!!e?.bookmarkReached,punctuationBoundaryEnabled:e?.properties.getProperty(i.PropertyId.SpeechServiceResponse_RequestPunctuationBoundary,!!e?.wordBoundary),sentenceBoundaryEnabled:e?.properties.getProperty(i.PropertyId.SpeechServiceResponse_RequestSentenceBoundary,!1),sessionEndEnabled:!0,visemeEnabled:!!e?.visemeReceived,wordBoundaryEnabled:e?.properties.getProperty(i.PropertyId.SpeechServiceResponse_RequestWordBoundary,!!e?.wordBoundary)},outputFormat:this.privAudioOutputFormat.requestAudioFormatString},language:{autoDetection:e?.autoDetectSourceLanguage}}}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakerRecognitionConfig=void 0;const i=r(2);t.SpeakerRecognitionConfig=class{constructor(e,t){this.privContext=e||new i.Context(null),this.privParameters=t}get parameters(){return this.privParameters}get Context(){return this.privContext}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakerServiceRecognizer=void 0;const i=r(60),n=r(4),s=r(79),o=r(2),a=r(207);class c extends o.ServiceRecognizerBase{constructor(e,t,r,i,n){super(e,t,r,i,n),this.privSpeakerRecognizer=n,this.privSpeakerAudioSource=r,this.recognizeSpeaker=e=>this.recognizeSpeakerOnce(e),this.sendPrePayloadJSONOverride=()=>this.noOp()}processTypeSpecificMessages(e){let t=!1;const r=new s.PropertyCollection;if(e.messageType===n.MessageType.Text&&r.setProperty(s.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),"speaker.response"===e.path.toLowerCase()){const r=JSON.parse(e.textBody);let i;i="success"!==r.status.statusCode.toLowerCase()?new s.SpeakerRecognitionResult(r,s.ResultReason.Canceled,s.CancellationErrorCode.ServiceError,r.status.reason):new s.SpeakerRecognitionResult(r,s.ResultReason.RecognizedSpeaker),this.privResultDeferral&&this.privResultDeferral.resolve(i),t=!0}const i=new n.Deferred;return i.resolve(t),i.promise}cancelRecognition(e,t,r,i,n){if((new s.PropertyCollection).setProperty(o.CancellationErrorCodePropertyName,s.CancellationErrorCode[i]),this.privResultDeferral){const e=new s.SpeakerRecognitionResult({scenario:this.privSpeakerModel.scenario,status:{statusCode:n,reason:n}},s.ResultReason.Canceled,i,n);try{this.privResultDeferral.resolve(e)}catch(n){this.privResultDeferral.reject(n)}}}async recognizeSpeakerOnce(e){this.privSpeakerModel=e,this.voiceProfileType=e.scenario,this.privResultDeferral||(this.privResultDeferral=new n.Deferred),this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(s.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);const t=this.connectImpl(),r=this.sendPreAudioMessages(this.extractSpeakerContext(e)),o=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),a=await this.privSpeakerAudioSource.format,c=await this.privSpeakerAudioSource.deviceInfo,p=new i.ReplayableAudioNode(o,a.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(p,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:c};try{await t,await r}catch(e){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,s.CancellationReason.Error,s.CancellationErrorCode.ConnectionFailure,e)}const h=new s.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,h),this.receiveMessage();return this.sendAudio(p).then((()=>{}),(e=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,s.CancellationReason.Error,s.CancellationErrorCode.RuntimeError,e)})),this.privResultDeferral.promise}async sendPreAudioMessages(e){const t=await this.fetchConnection();await this.sendSpeakerRecognition(t,e)}async sendSpeakerRecognition(e,t){const r=JSON.stringify(t);return e.send(new a.SpeechConnectionMessage(n.MessageType.Text,"speaker.context",this.privRequestSession.requestId,"application/json; charset=utf-8",r))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}}t.SpeakerServiceRecognizer=c},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceServiceRecognizer=void 0;const i=r(60),n=r(4),s=r(79),o=r(2),a=r(207);class c extends o.ServiceRecognizerBase{constructor(e,t,r,i,s){super(e,t,r,i,s),this.privDeferralMap=new n.DeferralMap,this.privSpeakerAudioSource=r,this.sendPrePayloadJSONOverride=()=>this.noOp()}set SpeakerAudioSource(e){this.privSpeakerAudioSource=e}processTypeSpecificMessages(e){let t=!1;const r=new s.PropertyCollection;switch(e.messageType===n.MessageType.Text&&r.setProperty(s.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.profiles":const r=JSON.parse(e.textBody);switch(r.operation.toLowerCase()){case"create":this.handleCreateResponse(r,e.requestId);break;case"delete":case"reset":this.handleResultResponse(r,e.requestId);break;case"fetch":const t=JSON.parse(e.textBody);this.handleFetchResponse(t,e.requestId)}t=!0;break;case"speaker.phrases":const i=JSON.parse(e.textBody);this.handlePhrasesResponse(i,e.requestId),t=!0;break;case"speaker.profile.enrollment":const n=JSON.parse(e.textBody),o=new s.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(n.enrollment?n.enrollment.enrollmentStatus:n.status.statusCode),n.enrollment?JSON.stringify(n.enrollment):void 0,n.status.reason);this.privDeferralMap.getId(e.requestId)&&this.privDeferralMap.complete(e.requestId,o),this.privRequestSession.onSpeechEnded(),t=!0}const i=new n.Deferred;return i.resolve(t),i.promise}cancelRecognition(e,t,r,i,n){(new s.PropertyCollection).setProperty(o.CancellationErrorCodePropertyName,s.CancellationErrorCode[i]);const a=new s.VoiceProfileEnrollmentResult(s.ResultReason.Canceled,n,n);this.privDeferralMap.getId(t)&&this.privDeferralMap.complete(t,a)}async createProfile(e,t){this.voiceProfileType=e.toString();const r=this.connectImpl();try{const i=new n.Deferred;return await r,await this.sendCreateProfile(i,e,t),this.receiveMessage(),i.promise}catch(e){throw e}}async resetProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("reset",e.profileType,e)}async deleteProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("delete",e.profileType,e)}async retrieveEnrollmentResult(e){return this.voiceProfileType=e.profileType.toString(),this.privExpectedProfileId=e.profileId,this.sendCommonRequest("fetch",e.profileType,e)}async getAllProfiles(e){return this.voiceProfileType=e.toString(),this.sendCommonRequest("fetch",e)}async getActivationPhrases(e,t){this.voiceProfileType=e.toString();const r=this.connectImpl();try{const i=new n.Deferred;return await r,await this.sendPhrasesRequest(i,e,t),this.receiveMessage(),i.promise}catch(e){throw e}}async enrollProfile(e){this.voiceProfileType=e.profileType.toString();const t=new n.Deferred;this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(s.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);const r=this.connectImpl(),o=this.sendPreAudioMessages(e,t),a=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),c=await this.privSpeakerAudioSource.format,p=await this.privSpeakerAudioSource.deviceInfo,h=new i.ReplayableAudioNode(a,c.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(h,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:p};try{await r,await o}catch(e){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,s.CancellationReason.Error,s.CancellationErrorCode.ConnectionFailure,e)}const u=new s.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,u),this.receiveMessage();return this.sendAudio(h).then((()=>{}),(e=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,s.CancellationReason.Error,s.CancellationErrorCode.RuntimeError,e)})),t.promise}async sendPreAudioMessages(e,t){const r=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,t),await this.sendBaseRequest(r,"enroll",this.scenarioFrom(e.profileType),e)}async sendPhrasesRequest(e,t,r){const i=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);const s={locale:r,scenario:this.scenarioFrom(t)};return i.send(new a.SpeechConnectionMessage(n.MessageType.Text,"speaker.profile.phrases",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(s)))}async sendCreateProfile(e,t,r){const i=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);const o={locale:r,number:"1",scenario:t===s.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":t===s.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification"};return i.send(new a.SpeechConnectionMessage(n.MessageType.Text,"speaker.profile.create",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(o)))}async sendCommonRequest(e,t,r=void 0){const i=this.connectImpl();try{const s=new n.Deferred;this.privRequestSession.onSpeechContext(),await i;const o=await this.fetchConnection();return this.privDeferralMap.add(this.privRequestSession.requestId,s),await this.sendBaseRequest(o,e,this.scenarioFrom(t),r),this.receiveMessage(),s.promise}catch(e){throw e}}async sendBaseRequest(e,t,r,i){const s={scenario:r};return i?s.profileIds=[i.profileId]:s.maxPageSize=-1,e.send(new a.SpeechConnectionMessage(n.MessageType.Text,`speaker.profile.${t}`,this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(s)))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}handlePhrasesResponse(e,t){if(!this.privDeferralMap.getId(t))throw new Error(`Voice Profile get activation phrases request for requestID ${t} not found`);if("success"!==e.status.statusCode.toLowerCase()){const r=s.ResultReason.Canceled,i=new s.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,[]);this.privDeferralMap.complete(t,i)}else{if(!(e.phrases&&e.phrases.length>0))throw new Error("Voice Profile get activation phrases failed, no phrases received");{const r=s.ResultReason.EnrollingVoiceProfile,i=new s.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,e.phrases);this.privDeferralMap.complete(t,i)}}}handleCreateResponse(e,t){if(!(e.profiles&&e.profiles.length>0))throw new Error("Voice Profile create failed, no profile id received");if(!this.privDeferralMap.getId(t))throw new Error(`Voice Profile create request for requestID ${t} not found`);{const r=e.profiles.map((e=>e.profileId));this.privDeferralMap.complete(t,r)}}handleResultResponse(e,t){if(!this.privDeferralMap.getId(t))throw new Error(`Voice Profile create request for requestID ${t} not found`);{const r="delete"===e.operation.toLowerCase()?s.ResultReason.DeletedVoiceProfile:s.ResultReason.ResetVoiceProfile,i="success"===e.status.statusCode.toLowerCase()?r:s.ResultReason.Canceled,n=new s.VoiceProfileResult(i,`statusCode: ${e.status.statusCode}, errorDetails: ${e.status.reason}`);this.privDeferralMap.complete(t,n)}}handleFetchResponse(e,t){if(!this.privDeferralMap.getId(t)||!e.profiles[0])throw new Error(`Voice Profile fetch request for requestID ${t} not found`);if(this.privExpectedProfileId&&1===e.profiles.length&&e.profiles[0].profileId===this.privExpectedProfileId){this.privExpectedProfileId=void 0;const r=e.profiles[0],i=new s.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(r.enrollmentStatus),JSON.stringify(r),e.status.reason);this.privDeferralMap.complete(t,i)}else if(e.profiles.length>0){const r=e.profiles,i=[];for(const t of r)i.push(new s.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(t.enrollmentStatus),JSON.stringify(t),e.status.reason));this.privDeferralMap.complete(t,i)}}enrollmentReasonFrom(e){switch(e.toLowerCase()){case"enrolled":return s.ResultReason.EnrolledVoiceProfile;case"invalidlocale":case"invalidphrase":case"invalidaudioformat":case"invalidscenario":case"invalidprofilecount":case"invalidoperation":case"audiotooshort":case"audiotoolong":case"toomanyenrollments":case"storageconflict":case"profilenotfound":case"incompatibleprofiles":case"incompleteenrollment":return s.ResultReason.Canceled;default:return s.ResultReason.EnrollingVoiceProfile}}scenarioFrom(e){return e===s.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":e===s.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification"}}t.VoiceServiceRecognizer=c},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.type=t.connectivity=t.Device=t.OS=t.System=t.Context=t.SpeechServiceConfig=void 0;t.SpeechServiceConfig=class{constructor(e){this.context=e}serialize(){return JSON.stringify(this,((e,t)=>{if(t&&"object"==typeof t&&!Array.isArray(t)){const e={};for(const r in t)Object.hasOwnProperty.call(t,r)&&(e[r&&r.charAt(0).toLowerCase()+r.substring(1)]=t[r]);return e}return t}))}get Context(){return this.context}get Recognition(){return this.recognition}set Recognition(e){this.recognition=e.toLowerCase()}};t.Context=class{constructor(e){this.system=new r,this.os=e}};class r{constructor(){this.name="SpeechSDK",this.version="1.44.0",this.build="JavaScript",this.lang="JavaScript"}}t.System=r;t.OS=class{constructor(e,t,r){this.platform=e,this.name=t,this.version=r}};t.Device=class{constructor(e,t,r){this.manufacturer=e,this.model=t,this.version=r}},function(e){e.Bluetooth="Bluetooth",e.Wired="Wired",e.WiFi="WiFi",e.Cellular="Cellular",e.InBuilt="InBuilt",e.Unknown="Unknown"}(t.connectivity||(t.connectivity={})),function(e){e.Phone="Phone",e.Speaker="Speaker",e.Car="Car",e.Headset="Headset",e.Thermostat="Thermostat",e.Microphones="Microphones",e.Deskphone="Deskphone",e.RemoteControl="RemoteControl",e.Unknown="Unknown",e.File="File",e.Stream="Stream"}(t.type||(t.type={}))}],t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{"use strict";r.r(i);var e=r(1);window.SpeechSDK=e})()})();