-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicrosoft.cognitiveservices.speech.sdk.bundle-min.js
1 lines (1 loc) · 155 KB
/
microsoft.cognitiveservices.speech.sdk.bundle-min.js
1
!function(r){var n={};function i(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.m=r,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=20)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(38);t.AudioConfig=n.AudioConfig;var i=r(7);t.AudioStreamFormat=i.AudioStreamFormat;var o=r(18);t.AudioInputStream=o.AudioInputStream,t.PullAudioInputStream=o.PullAudioInputStream,t.PushAudioInputStream=o.PushAudioInputStream;var s=r(39);t.CancellationReason=s.CancellationReason;var c=r(40);t.PullAudioInputStreamCallback=c.PullAudioInputStreamCallback;var a=r(41);t.KeywordRecognitionModel=a.KeywordRecognitionModel;var u=r(42);t.SessionEventArgs=u.SessionEventArgs;var p=r(43);t.RecognitionEventArgs=p.RecognitionEventArgs;var f=r(44);t.OutputFormat=f.OutputFormat;var v=r(45);t.IntentRecognitionEventArgs=v.IntentRecognitionEventArgs;var l=r(46);t.RecognitionResult=l.RecognitionResult;var d=r(47);t.SpeechRecognitionResult=d.SpeechRecognitionResult;var h=r(48);t.IntentRecognitionResult=h.IntentRecognitionResult;var g=r(49);t.LanguageUnderstandingModel=g.LanguageUnderstandingModel;var y=r(50);t.SpeechRecognitionEventArgs=y.SpeechRecognitionEventArgs;var m=r(51);t.SpeechRecognitionCanceledEventArgs=m.SpeechRecognitionCanceledEventArgs;var S=r(52);t.TranslationRecognitionEventArgs=S.TranslationRecognitionEventArgs;var b=r(53);t.TranslationSynthesisEventArgs=b.TranslationSynthesisEventArgs;var R=r(54);t.TranslationRecognitionResult=R.TranslationRecognitionResult;var P=r(55);t.TranslationSynthesisResult=P.TranslationSynthesisResult;var C=r(56);t.ResultReason=C.ResultReason;var I=r(57);t.SpeechConfig=I.SpeechConfig;var E=r(85);t.SpeechTranslationConfig=E.SpeechTranslationConfig;var O=r(86);t.PropertyCollection=O.PropertyCollection;var w=r(87);t.PropertyId=w.PropertyId;var _=r(88);t.Recognizer=_.Recognizer;var A=r(89);t.SpeechRecognizer=A.SpeechRecognizer;var T=r(90);t.IntentRecognizer=T.IntentRecognizer;var j=r(91);t.TranslationRecognizer=j.TranslationRecognizer;var D=r(92);t.Translations=D.Translations;var M=r(93);t.NoMatchReason=M.NoMatchReason;var N=r(94);t.NoMatchDetails=N.NoMatchDetails;var z=r(95);t.TranslationRecognitionCanceledEventArgs=z.TranslationRecognitionCanceledEventArgs;var x=r(96);t.IntentRecognitionCanceledEventArgs=x.IntentRecognitionCanceledEventArgs;var L=r(97);t.CancellationDetails=L.CancellationDetails;var F=r(98);t.CancellationErrorCode=F.CancellationErrorCode;var k=r(99);t.ConnectionEventArgs=k.ConnectionEventArgs;var q=r(100);t.Connection=q.Connection;var B=r(101);t.PhraseListGrammar=B.PhraseListGrammar},function(e,r,t){"use strict";function n(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}Object.defineProperty(r,"__esModule",{value:!0}),n(t(58)),n(t(59)),n(t(10)),n(t(60)),n(t(11)),n(t(61)),n(t(63)),n(t(64)),n(t(19)),n(t(66)),n(t(67)),n(t(68)),n(t(69)),n(t(70)),n(t(71)),n(t(72)),n(t(73)),n(t(74)),n(t(75)),n(t(76)),n(t(77)),n(t(78)),n(t(79)),n(t(80)),n(t(81)),n(t(83)),n(t(84)),r.OutputFormatPropertyName="OutputFormat",r.CancellationErrorCodePropertyName="CancellationErrorCode"},function(e,r,t){"use strict";function n(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}Object.defineProperty(r,"__esModule",{value:!0}),n(t(23)),n(t(24)),n(t(12)),n(t(25)),n(t(3)),n(t(26)),n(t(13)),n(t(5)),n(t(27)),n(t(14)),n(t(8)),n(t(15)),n(t(16)),n(t(28)),n(t(29)),n(t(30));var i=t(9);r.TranslationStatus=i.TranslationStatus},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(r){function e(e){var t=r.call(this,e)||this;return t.name="ArgumentNull",t.message=e,t}return i(e,r),e}(Error);t.ArgumentNullError=o;var s=function(r){function e(e){var t=r.call(this,e)||this;return t.name="InvalidOperation",t.message=e,t}return i(e,r),e}(Error);t.InvalidOperationError=s;var c=function(n){function e(e,t){var r=n.call(this,t)||this;return r.name=e+"ObjectDisposed",r.message=t,r}return i(e,n),e}(Error);t.ObjectDisposedError=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function o(){}return o.throwIfNullOrUndefined=function(e,t){if(null==e)throw new Error("throwIfNullOrUndefined:"+t)},o.throwIfNull=function(e,t){if(null===e)throw new Error("throwIfNull:"+t)},o.throwIfNullOrWhitespace=function(e,t){if(o.throwIfNullOrUndefined(e,t),(""+e).trim().length<1)throw new Error("throwIfNullOrWhitespace:"+t)},o.throwIfDisposed=function(e){if(e)throw new Error("the object is already disposed")},o.throwIfArrayEmptyOrWhitespace=function(e,t){if(o.throwIfNullOrUndefined(e,t),0===e.length)throw new Error("throwIfArrayEmptyOrWhitespace:"+t);for(var r=0,n=e;r<n.length;r++){var i=n[r];o.throwIfNullOrWhitespace(i,t)}},o.throwIfFileDoesNotExist=function(e,t){o.throwIfNullOrWhitespace(e,t)},o}();t.Contracts=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){var r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"===e?t:3&t|8).toString(16)})};t.createGuid=n;t.createNoDashGuid=function(){return n().replace(new RegExp("-","g"),"").toUpperCase()}},function(e,r,t){"use strict";function n(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}Object.defineProperty(r,"__esModule",{value:!0}),n(t(22)),n(t(31)),n(t(32)),n(t(33)),n(t(34)),n(t(35)),n(t(17)),n(t(37))},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){}return e.getDefaultInputFormat=function(){return s.getDefaultInputFormat()},e.getWaveFormatPCM=function(e,t,r){return new s(e,t,r)},e}(),s=function(i){function e(e,t,r){void 0===e&&(e=16e3),void 0===t&&(t=16),void 0===r&&(r=1);var n=i.call(this)||this;return n.formatTag=1,n.bitsPerSample=t,n.samplesPerSec=e,n.channels=r,n.avgBytesPerSec=n.samplesPerSec*n.channels*(n.bitsPerSample/8),n.blockAlign=n.channels*Math.max(n.bitsPerSample,8),n}return o(e,i),e.getDefaultInputFormat=function(){return new e},e.prototype.close=function(){},e}(t.AudioStreamFormat=i);t.AudioStreamFormatImpl=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(5);(n=t.EventType||(t.EventType={}))[n.Debug=0]="Debug",n[n.Info=1]="Info",n[n.Warning=2]="Warning",n[n.Error=3]="Error";var o=function(){function e(e,t){this.privName=e,this.privEventId=i.createNoDashGuid(),this.privEventTime=(new Date).toISOString(),this.privEventType=t,this.privMetadata={}}return Object.defineProperty(e.prototype,"name",{get:function(){return this.privName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventId",{get:function(){return this.privEventId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventTime",{get:function(){return this.privEventTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventType",{get:function(){return this.privEventType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"metadata",{get:function(){return this.privMetadata},enumerable:!0,configurable:!0}),e}();t.PlatformEvent=o},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.TranslationStatus||(t.TranslationStatus={}))[n.Success=0]="Success",n[n.Error=1]="Error"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){this.privHeaderName=e,this.privToken=t}return Object.defineProperty(e.prototype,"headerName",{get:function(){return this.privHeaderName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"token",{get:function(){return this.privToken},enumerable:!0,configurable:!0}),e}();t.AuthInfo=n},function(e,t,r){"use strict";var n,c=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var p=r(2),i=function(o){function e(e,t,r,n){void 0===n&&(n=p.EventType.Info);var i=o.call(this,e,n)||this;return i.privRequestId=t,i.privSessionId=r,i}return c(e,o),Object.defineProperty(e.prototype,"requestId",{get:function(){return this.privRequestId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sessionId",{get:function(){return this.privSessionId},enumerable:!0,configurable:!0}),e}(p.PlatformEvent),o=function(o){function e(e,t,r,n){var i=o.call(this,"RecognitionTriggeredEvent",e,t)||this;return i.privAudioSourceId=r,i.privAudioNodeId=n,i}return c(e,o),Object.defineProperty(e.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),e}(t.SpeechRecognitionEvent=i);t.RecognitionTriggeredEvent=o;var s=function(o){function e(e,t,r,n){var i=o.call(this,"ListeningStartedEvent",e,t)||this;return i.privAudioSourceId=r,i.privAudioNodeId=n,i}return c(e,o),Object.defineProperty(e.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),e}(i);t.ListeningStartedEvent=s;var a=function(i){function e(e,t,r){var n=i.call(this,"ConnectingToServiceEvent",e,r)||this;return n.privAuthFetchEventid=t,n}return c(e,i),Object.defineProperty(e.prototype,"authFetchEventid",{get:function(){return this.privAuthFetchEventid},enumerable:!0,configurable:!0}),e}(i);t.ConnectingToServiceEvent=a;var f,u,v=function(s){function e(e,t,r,n,i){var o=s.call(this,"RecognitionStartedEvent",e,i)||this;return o.privAudioSourceId=t,o.privAudioNodeId=r,o.privAuthFetchEventId=n,o}return c(e,s),Object.defineProperty(e.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authFetchEventId",{get:function(){return this.privAuthFetchEventId},enumerable:!0,configurable:!0}),e}(i);t.RecognitionStartedEvent=v,(u=f=t.RecognitionCompletionStatus||(t.RecognitionCompletionStatus={}))[u.Success=0]="Success",u[u.AudioSourceError=1]="AudioSourceError",u[u.AudioSourceTimeout=2]="AudioSourceTimeout",u[u.AuthTokenFetchError=3]="AuthTokenFetchError",u[u.AuthTokenFetchTimeout=4]="AuthTokenFetchTimeout",u[u.UnAuthorized=5]="UnAuthorized",u[u.ConnectTimeout=6]="ConnectTimeout",u[u.ConnectError=7]="ConnectError",u[u.ClientRecognitionActivityTimeout=8]="ClientRecognitionActivityTimeout",u[u.UnknownError=9]="UnknownError";var l=function(u){function e(e,t,r,n,i,o,s,c){var a=u.call(this,"RecognitionEndedEvent",e,i,s===f.Success?p.EventType.Info:p.EventType.Error)||this;return a.privAudioSourceId=t,a.privAudioNodeId=r,a.privAuthFetchEventId=n,a.privStatus=s,a.privError=c,a.privServiceTag=o,a}return c(e,u),Object.defineProperty(e.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authFetchEventId",{get:function(){return this.privAuthFetchEventId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"serviceTag",{get:function(){return this.privServiceTag},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.privStatus},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this.privError},enumerable:!0,configurable:!0}),e}(i);t.RecognitionEndedEvent=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,n,o=r(3),s=r(5);(n=i=t.MessageType||(t.MessageType={}))[n.Text=0]="Text",n[n.Binary=1]="Binary";var c=function(){function e(e,t,r,n){if(this.privBody=null,e===i.Text&&t&&"string"!=typeof t)throw new o.InvalidOperationError("Payload must be a string");if(e===i.Binary&&t&&!(t instanceof ArrayBuffer))throw new o.InvalidOperationError("Payload must be ArrayBuffer");this.privMessageType=e,this.privBody=t,this.privHeaders=r||{},this.privId=n||s.createNoDashGuid()}return Object.defineProperty(e.prototype,"messageType",{get:function(){return this.privMessageType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"headers",{get:function(){return this.privHeaders},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this.privBody},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textBody",{get:function(){if(this.privMessageType===i.Binary)throw new o.InvalidOperationError("Not supported for binary message");return this.privBody},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryBody",{get:function(){if(this.privMessageType===i.Text)throw new o.InvalidOperationError("Not supported for text message");return this.privBody},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privId},enumerable:!0,configurable:!0}),e}();t.ConnectionMessage=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(3),o=r(5),n=function(){function e(e){var n=this;this.privEventListeners={},this.privIsDisposed=!1,this.onEvent=function(e){if(n.isDisposed())throw new i.ObjectDisposedError("EventSource");if(n.metadata)for(var t in n.metadata)t&&e.metadata&&(e.metadata[t]||(e.metadata[t]=n.metadata[t]));for(var r in n.privEventListeners)r&&n.privEventListeners[r]&&n.privEventListeners[r](e)},this.attach=function(e){var t=o.createNoDashGuid();return n.privEventListeners[t]=e,{detach:function(){delete n.privEventListeners[t]}}},this.attachListener=function(e){return n.attach(e.onEvent)},this.isDisposed=function(){return n.privIsDisposed},this.dispose=function(){n.privEventListeners=null,n.privIsDisposed=!0},this.privMetadata=e}return Object.defineProperty(e.prototype,"metadata",{get:function(){return this.privMetadata},enumerable:!0,configurable:!0}),e}();t.EventSource=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=r(3),n=function n(e){var i=this;if(this.privSubscriptionIdCounter=0,this.privAddSubscriptions={},this.privRemoveSubscriptions={},this.privDisposedSubscriptions={},this.privDisposeReason=null,this.get=function(e){return i.throwIfDisposed(),i.privList[e]},this.first=function(){return i.get(0)},this.last=function(){return i.get(i.length()-1)},this.add=function(e){i.throwIfDisposed(),i.insertAt(i.privList.length,e)},this.insertAt=function(e,t){i.throwIfDisposed(),0===e?i.privList.unshift(t):e===i.privList.length?i.privList.push(t):i.privList.splice(e,0,t),i.triggerSubscriptions(i.privAddSubscriptions)},this.removeFirst=function(){return i.throwIfDisposed(),i.removeAt(0)},this.removeLast=function(){return i.throwIfDisposed(),i.removeAt(i.length()-1)},this.removeAt=function(e){return i.throwIfDisposed(),i.remove(e,1)[0]},this.remove=function(e,t){i.throwIfDisposed();var r=i.privList.splice(e,t);return i.triggerSubscriptions(i.privRemoveSubscriptions),r},this.clear=function(){i.throwIfDisposed(),i.remove(0,i.length())},this.length=function(){return i.throwIfDisposed(),i.privList.length},this.onAdded=function(e){i.throwIfDisposed();var t=i.privSubscriptionIdCounter++;return i.privAddSubscriptions[t]=e,{detach:function(){delete i.privAddSubscriptions[t]}}},this.onRemoved=function(e){i.throwIfDisposed();var t=i.privSubscriptionIdCounter++;return i.privRemoveSubscriptions[t]=e,{detach:function(){delete i.privRemoveSubscriptions[t]}}},this.onDisposed=function(e){i.throwIfDisposed();var t=i.privSubscriptionIdCounter++;return i.privDisposedSubscriptions[t]=e,{detach:function(){delete i.privDisposedSubscriptions[t]}}},this.join=function(e){return i.throwIfDisposed(),i.privList.join(e)},this.toArray=function(){var t=Array();return i.privList.forEach(function(e){t.push(e)}),t},this.any=function(e){return i.throwIfDisposed(),e?0<i.where(e).length():0<i.length()},this.all=function(e){return i.throwIfDisposed(),i.where(e).length()===i.length()},this.forEach=function(e){i.throwIfDisposed();for(var t=0;t<i.length();t++)e(i.privList[t],t)},this.select=function(e){i.throwIfDisposed();for(var t=[],r=0;r<i.privList.length;r++)t.push(e(i.privList[r],r));return new n(t)},this.where=function(e){i.throwIfDisposed();for(var t=new n,r=0;r<i.privList.length;r++)e(i.privList[r],r)&&t.add(i.privList[r]);return t},this.orderBy=function(e){return i.throwIfDisposed(),new n(i.toArray().sort(e))},this.orderByDesc=function(r){return i.throwIfDisposed(),i.orderBy(function(e,t){return r(t,e)})},this.clone=function(){return i.throwIfDisposed(),new n(i.toArray())},this.concat=function(e){return i.throwIfDisposed(),new n(i.privList.concat(e.toArray()))},this.concatArray=function(e){return i.throwIfDisposed(),new n(i.privList.concat(e))},this.isDisposed=function(){return null==i.privList},this.dispose=function(e){i.isDisposed()||(i.privDisposeReason=e,i.privList=null,i.privAddSubscriptions=null,i.privRemoveSubscriptions=null,i.triggerSubscriptions(i.privDisposedSubscriptions))},this.throwIfDisposed=function(){if(i.isDisposed())throw new s.ObjectDisposedError("List",i.privDisposeReason)},this.triggerSubscriptions=function(e){if(e)for(var t in e)t&&e[t]()},this.privList=[],e)for(var t=0,r=e;t<r.length;t++){var o=r[t];this.privList.push(o)}};t.List=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,n,c=r(3);(n=o=t.PromiseState||(t.PromiseState={}))[n.None=0]="None",n[n.Resolved=1]="Resolved",n[n.Rejected=2]="Rejected";var s=function(){function e(e){var t=this;this.throwIfError=function(){if(t.isError)throw t.error},e.on(function(e){t.privIsCompleted||(t.privIsCompleted=!0,t.privIsError=!1,t.privResult=e)},function(e){t.privIsCompleted||(t.privIsCompleted=!0,t.privIsError=!0,t.privError=e)})}return Object.defineProperty(e.prototype,"isCompleted",{get:function(){return this.privIsCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isError",{get:function(){return this.privIsError},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this.privError},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),e}();t.PromiseResult=s;var a=function(){var r=this;this.setResult=function(e){r.privOnSetResult(e)},this.setError=function(e){r.privOnSetError(e)},this.on=function(e,t){r.privOnSetResult=e,r.privOnSetError=t}};t.PromiseResultEventSource=a;var i=function(){function e(){}return e.whenAll=function(e){if(!e||0===e.length)throw new c.ArgumentNullError("promises");for(var t=new p,r=[],n=0,i=function(){++n===e.length&&(0===r.length?t.resolve(!0):t.reject(r.join(", ")))},o=0,s=e;o<s.length;o++){s[o].on(function(e){i()},function(e){r.push(e),i()})}return t.promise()},e.fromResult=function(e){var t=new p;return t.resolve(e),t.promise()},e.fromError=function(e){var t=new p;return t.reject(e),t.promise()},e}();t.PromiseHelper=i;var u=function(e){var i=this;this.result=function(){return i.privSink.result},this.continueWith=function(r){if(!r)throw new c.ArgumentNullError("continuationCallback");var n=new p;return i.privSink.on(function(e){try{var t=r(i.privSink.result);n.resolve(t)}catch(e){n.reject(e)}},function(t){try{var e=r(i.privSink.result);n.resolve(e)}catch(e){n.reject("'Error handler for error "+t+" threw error "+e+"'")}}),n.promise()},this.onSuccessContinueWith=function(r){if(!r)throw new c.ArgumentNullError("continuationCallback");var n=new p;return i.privSink.on(function(e){try{var t=r(e);n.resolve(t)}catch(e){n.reject(e)}},function(e){n.reject(e)}),n.promise()},this.continueWithPromise=function(r){if(!r)throw new c.ArgumentNullError("continuationCallback");var n=new p;return i.privSink.on(function(e){try{var t=r(i.privSink.result);if(!t)throw new Error("'Continuation callback did not return promise'");t.on(function(e){n.resolve(e)},function(e){n.reject(e)})}catch(e){n.reject(e)}},function(t){try{var e=r(i.privSink.result);if(!e)throw new Error("Continuation callback did not return promise");e.on(function(e){n.resolve(e)},function(e){n.reject(e)})}catch(e){n.reject("'Error handler for error "+t+" threw error "+e+"'")}}),n.promise()},this.onSuccessContinueWithPromise=function(r){if(!r)throw new c.ArgumentNullError("continuationCallback");var n=new p;return i.privSink.on(function(e){try{var t=r(e);if(!t)throw new Error("Continuation callback did not return promise");t.on(function(e){n.resolve(e)},function(e){n.reject(e)})}catch(e){n.reject(e)}},function(e){n.reject(e)}),n.promise()},this.on=function(e,t){if(!e)throw new c.ArgumentNullError("successCallback");if(!t)throw new c.ArgumentNullError("errorCallback");return i.privSink.on(e,t),i},this.finally=function(t){if(!t)throw new c.ArgumentNullError("callback");var e=function(e){t()};return i.on(e,e)},this.privSink=e};t.Promise=u;var p=function(){var t=this;this.state=function(){return t.privSink.state},this.promise=function(){return t.privPromise},this.resolve=function(e){return t.privSink.resolve(e),t},this.reject=function(e){return t.privSink.reject(e),t},this.privSink=new f,this.privPromise=new u(this.privSink)};t.Deferred=p;var f=function(){function e(){var i=this;this.privState=o.None,this.privPromiseResult=null,this.privPromiseResultEvents=null,this.privSuccessHandlers=[],this.privErrorHandlers=[],this.resolve=function(e){if(i.privState!==o.None)throw new Error("'Cannot resolve a completed promise'");i.privState=o.Resolved,i.privPromiseResultEvents.setResult(e);for(var t=0;t<i.privSuccessHandlers.length;t++)i.executeSuccessCallback(e,i.privSuccessHandlers[t],i.privErrorHandlers[t]);i.detachHandlers()},this.reject=function(e){if(i.privState!==o.None)throw new Error("'Cannot reject a completed promise'");i.privState=o.Rejected,i.privPromiseResultEvents.setError(e);for(var t=0,r=i.privErrorHandlers;t<r.length;t++){var n=r[t];i.executeErrorCallback(e,n)}i.detachHandlers()},this.on=function(e,t){null==e&&(e=function(e){}),i.privState===o.None?(i.privSuccessHandlers.push(e),i.privErrorHandlers.push(t)):(i.privState===o.Resolved?i.executeSuccessCallback(i.privPromiseResult.result,e,t):i.privState===o.Rejected&&i.executeErrorCallback(i.privPromiseResult.error,t),i.detachHandlers())},this.executeSuccessCallback=function(e,t,r){try{t(e)}catch(e){i.executeErrorCallback("'Unhandled callback error: "+e+"'",r)}},this.executeErrorCallback=function(t,e){if(!e)throw new Error("'Unhandled error: "+t+"'");try{e(t)}catch(e){throw new Error("'Unhandled callback error: "+e+". InnerError: "+t+"'")}},this.detachHandlers=function(){i.privErrorHandlers=[],i.privSuccessHandlers=[]},this.privPromiseResultEvents=new a,this.privPromiseResult=new s(this.privPromiseResultEvents)}return Object.defineProperty(e.prototype,"state",{get:function(){return this.privState},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"result",{get:function(){return this.privPromiseResult},enumerable:!0,configurable:!0}),e}();t.Sink=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,n,s=r(3),c=r(14),a=r(15);(n=i||(i={}))[n.Dequeue=0]="Dequeue",n[n.Peek=1]="Peek";var o=function(e){var o=this;this.privPromiseStore=new c.List,this.privIsDrainInProgress=!1,this.privIsDisposing=!1,this.privDisposeReason=null,this.enqueue=function(e){o.throwIfDispose(),o.enqueueFromPromise(a.PromiseHelper.fromResult(e))},this.enqueueFromPromise=function(e){o.throwIfDispose(),o.privPromiseStore.add(e),e.finally(function(){for(;0<o.privPromiseStore.length()&&o.privPromiseStore.first().result().isCompleted;){var e=o.privPromiseStore.removeFirst();e.result().isError||o.privList.add(e.result().result)}})},this.dequeue=function(){o.throwIfDispose();var e=new a.Deferred;return o.privSubscribers&&(o.privSubscribers.add({deferral:e,type:i.Dequeue}),o.drain()),e.promise()},this.peek=function(){o.throwIfDispose();var e=new a.Deferred;return o.privSubscribers&&(o.privSubscribers.add({deferral:e,type:i.Peek}),o.drain()),e.promise()},this.length=function(){return o.throwIfDispose(),o.privList.length()},this.isDisposed=function(){return null==o.privSubscribers},this.drainAndDispose=function(r,e){if(!o.isDisposed()&&!o.privIsDisposing){o.privDisposeReason=e,o.privIsDisposing=!0;var t=o.privSubscribers;if(t){for(;0<t.length();)t.removeFirst().deferral.resolve(void 0);o.privSubscribers===t&&(o.privSubscribers=t)}for(var n=0,i=o.privDetachables;n<i.length;n++)i[n].detach();if(0<o.privPromiseStore.length()&&r)return a.PromiseHelper.whenAll(o.privPromiseStore.toArray()).continueWith(function(){return o.privSubscribers=null,o.privList.forEach(function(e,t){r(e)}),!(o.privList=null)});o.privSubscribers=null,o.privList=null}return a.PromiseHelper.fromResult(!0)},this.dispose=function(e){o.drainAndDispose(null,e)},this.drain=function(){if(!o.privIsDrainInProgress&&!o.privIsDisposing){o.privIsDrainInProgress=!0;var e=o.privSubscribers,t=o.privList;if(e&&t){for(;0<t.length()&&0<e.length()&&!o.privIsDisposing;){var r=e.removeFirst();if(r.type===i.Peek)r.deferral.resolve(t.first());else{var n=t.removeFirst();r.deferral.resolve(n)}}o.privSubscribers===e&&(o.privSubscribers=e),o.privList===t&&(o.privList=t)}o.privIsDrainInProgress=!1}},this.throwIfDispose=function(){if(o.isDisposed()){if(o.privDisposeReason)throw new s.InvalidOperationError(o.privDisposeReason);throw new s.ObjectDisposedError("Queue")}if(o.privIsDisposing)throw new s.InvalidOperationError("Queue disposing")},this.privList=e||new c.List,this.privDetachables=[],this.privSubscribers=new c.List,this.privDetachables.push(this.privList.onAdded(this.drain))};t.Queue=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),s=r(36),n=function(){function n(e,t,r){var i=this;if(this.open=function(){if(i.privConnectionState===o.ConnectionState.Disconnected)return o.PromiseHelper.fromError("Cannot open a connection that is in "+i.privConnectionState+" state");if(i.privConnectionEstablishDeferral)return i.privConnectionEstablishDeferral.promise();i.privConnectionEstablishDeferral=new o.Deferred,i.privConnectionState=o.ConnectionState.Connecting;try{"undefined"==typeof WebSocket||n.forceNpmWebSocket?i.privWebsocketClient=new s(i.privUri):i.privWebsocketClient=new WebSocket(i.privUri),i.privWebsocketClient.binaryType="arraybuffer",i.privReceivingMessageQueue=new o.Queue,i.privDisconnectDeferral=new o.Deferred,i.privSendMessageQueue=new o.Queue,i.processSendQueue()}catch(e){return i.privConnectionEstablishDeferral.resolve(new o.ConnectionOpenResponse(500,e)),i.privConnectionEstablishDeferral.promise()}return i.onEvent(new o.ConnectionStartEvent(i.privConnectionId,i.privUri)),i.privWebsocketClient.onopen=function(e){i.privConnectionState=o.ConnectionState.Connected,i.onEvent(new o.ConnectionEstablishedEvent(i.privConnectionId)),i.privConnectionEstablishDeferral.resolve(new o.ConnectionOpenResponse(200,""))},i.privWebsocketClient.onerror=function(e){i.privConnectionState,o.ConnectionState.Connecting},i.privWebsocketClient.onclose=function(e){i.privConnectionState===o.ConnectionState.Connecting?(i.privConnectionState=o.ConnectionState.Disconnected,i.privConnectionEstablishDeferral.resolve(new o.ConnectionOpenResponse(e.code,e.reason))):i.onEvent(new o.ConnectionClosedEvent(i.privConnectionId,e.code,e.reason)),i.onClose(e.code,e.reason)},i.privWebsocketClient.onmessage=function(e){var t=(new Date).toISOString();if(i.privConnectionState===o.ConnectionState.Connected){var r=new o.Deferred;if(i.privReceivingMessageQueue.enqueueFromPromise(r.promise()),e.data instanceof ArrayBuffer){var n=new o.RawWebsocketMessage(o.MessageType.Binary,e.data);i.privMessageFormatter.toConnectionMessage(n).on(function(e){i.onEvent(new o.ConnectionMessageReceivedEvent(i.privConnectionId,t,e)),r.resolve(e)},function(e){r.reject("Invalid binary message format. Error: "+e)})}else{n=new o.RawWebsocketMessage(o.MessageType.Text,e.data);i.privMessageFormatter.toConnectionMessage(n).on(function(e){i.onEvent(new o.ConnectionMessageReceivedEvent(i.privConnectionId,t,e)),r.resolve(e)},function(e){r.reject("Invalid text message format. Error: "+e)})}}},i.privConnectionEstablishDeferral.promise()},this.send=function(t){if(i.privConnectionState!==o.ConnectionState.Connected)return o.PromiseHelper.fromError("Cannot send on connection that is in "+i.privConnectionState+" state");var r=new o.Deferred,n=new o.Deferred;return i.privSendMessageQueue.enqueueFromPromise(n.promise()),i.privMessageFormatter.fromConnectionMessage(t).on(function(e){n.resolve({Message:t,RawWebsocketMessage:e,sendStatusDeferral:r})},function(e){n.reject("Error formatting the message. "+e)}),r.promise()},this.read=function(){return i.privConnectionState!==o.ConnectionState.Connected?o.PromiseHelper.fromError("Cannot read on connection that is in "+i.privConnectionState+" state"):i.privReceivingMessageQueue.dequeue()},this.close=function(e){if(i.privWebsocketClient)return i.privConnectionState!==o.ConnectionState.Disconnected&&i.privWebsocketClient.close(1e3,e||"Normal closure by client"),i.privDisconnectDeferral.promise();var t=new o.Deferred;return t.resolve(!0),t.promise()},this.sendRawMessage=function(e){try{return e&&(i.onEvent(new o.ConnectionMessageSentEvent(i.privConnectionId,(new Date).toISOString(),e.Message)),i.privWebsocketClient.send(e.RawWebsocketMessage.payload)),o.PromiseHelper.fromResult(!0)}catch(e){return o.PromiseHelper.fromError("websocket send error: "+e)}},this.onClose=function(e,t){var r="Connection closed. "+e+": "+t;i.privConnectionState=o.ConnectionState.Disconnected,i.privDisconnectDeferral.resolve(!0),i.privReceivingMessageQueue.dispose(t),i.privReceivingMessageQueue.drainAndDispose(function(e){},r),i.privSendMessageQueue.drainAndDispose(function(e){e.sendStatusDeferral.reject(r)},r)},this.processSendQueue=function(){i.privSendMessageQueue.dequeue().on(function(t){t&&i.sendRawMessage(t).on(function(e){t.sendStatusDeferral.resolve(e),i.processSendQueue()},function(e){t.sendStatusDeferral.reject(e),i.processSendQueue()})},function(e){})},this.onEvent=function(e){i.privConnectionEvents.onEvent(e),o.Events.instance.onEvent(e)},!e)throw new o.ArgumentNullError("uri");if(!r)throw new o.ArgumentNullError("messageFormatter");this.privConnectionEvents=new o.EventSource,this.privConnectionId=t,this.privMessageFormatter=r,this.privConnectionState=o.ConnectionState.None,this.privUri=e}return Object.defineProperty(n.prototype,"state",{get:function(){return this.privConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"events",{get:function(){return this.privConnectionEvents},enumerable:!0,configurable:!0}),n.forceNpmWebSocket=!1,n}();t.WebsocketMessageAdapter=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(5),s=r(2),c=r(0),a=r(7),u=4096,p=function(){function e(){}return e.createPushStream=function(e){return f.create(e)},e.createPullStream=function(e,t){return l.create(e,t)},e}(),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.create=function(e){return new v(e)},t}(t.AudioInputStream=p),v=function(r){function e(e){var t=r.call(this)||this;return t.privStream=new s.Stream,t.onEvent=function(e){t.privEvents.onEvent(e),s.Events.instance.onEvent(e)},t.privFormat=void 0===e?a.AudioStreamFormatImpl.getDefaultInputFormat():e,t.privEvents=new s.EventSource,t.privId=o.createNoDashGuid(),t}return i(e,r),Object.defineProperty(e.prototype,"format",{get:function(){return this.privFormat},enumerable:!0,configurable:!0}),e.prototype.write=function(e){var t;for(t=4095;t<e.byteLength;t+=u)this.privStream.write(e.slice(t-4095,t+1));t-4095!==e.byteLength&&this.privStream.write(e.slice(t-4095,e.byteLength))},e.prototype.close=function(){this.privStream.close()},e.prototype.id=function(){return this.privId},e.prototype.turnOn=function(){return this.onEvent(new s.AudioSourceInitializingEvent(this.privId)),this.onEvent(new s.AudioSourceReadyEvent(this.privId)),s.PromiseHelper.fromResult(!0)},e.prototype.attach=function(t){var r=this;return this.onEvent(new s.AudioStreamNodeAttachingEvent(this.privId,t)),this.turnOn().onSuccessContinueWith(function(e){return r.privStream.getReader()}).onSuccessContinueWith(function(e){return r.onEvent(new s.AudioStreamNodeAttachedEvent(r.privId,t)),{detach:function(){e.close(),r.onEvent(new s.AudioStreamNodeDetachedEvent(r.privId,t)),r.turnOff()},id:function(){return t},read:function(){return e.read()}}})},e.prototype.detach=function(e){this.onEvent(new s.AudioStreamNodeDetachedEvent(this.privId,e))},e.prototype.turnOff=function(){return s.PromiseHelper.fromResult(!1)},Object.defineProperty(e.prototype,"events",{get:function(){return this.privEvents},enumerable:!0,configurable:!0}),e}(t.PushAudioInputStream=f);t.PushAudioInputStreamImpl=v;var l=function(e){function t(){return e.call(this)||this}return i(t,e),t.create=function(e,t){return new d(e,t)},t}(p),d=function(n){function e(e,t){var r=n.call(this)||this;return r.onEvent=function(e){r.privEvents.onEvent(e),s.Events.instance.onEvent(e)},r.privFormat=void 0===t?c.AudioStreamFormat.getDefaultInputFormat():t,r.privEvents=new s.EventSource,r.privId=o.createNoDashGuid(),r.privCallback=e,r.privIsClosed=!1,r}return i(e,n),Object.defineProperty(e.prototype,"format",{get:function(){return this.privFormat},enumerable:!0,configurable:!0}),e.prototype.close=function(){this.privIsClosed=!0,this.privCallback.close()},e.prototype.id=function(){return this.privId},e.prototype.turnOn=function(){return this.onEvent(new s.AudioSourceInitializingEvent(this.privId)),this.onEvent(new s.AudioSourceReadyEvent(this.privId)),s.PromiseHelper.fromResult(!0)},e.prototype.attach=function(t){var r=this;return this.onEvent(new s.AudioStreamNodeAttachingEvent(this.privId,t)),this.turnOn().onSuccessContinueWith(function(e){return r.onEvent(new s.AudioStreamNodeAttachedEvent(r.privId,t)),{detach:function(){r.privCallback.close(),r.onEvent(new s.AudioStreamNodeDetachedEvent(r.privId,t)),r.turnOff()},id:function(){return t},read:function(){var e=new ArrayBuffer(u),t=r.privCallback.read(e);return s.PromiseHelper.fromResult({buffer:e.slice(0,t),isEnd:r.privIsClosed})}}})},e.prototype.detach=function(e){this.onEvent(new s.AudioStreamNodeDetachedEvent(this.privId,e))},e.prototype.turnOff=function(){return s.PromiseHelper.fromResult(!1)},Object.defineProperty(e.prototype,"events",{get:function(){return this.privEvents},enumerable:!0,configurable:!0}),e}(t.PullAudioInputStream=l);t.PullAudioInputStreamImpl=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var p=r(6),f=r(1),v=r(0),l=r(1),d=r(65),n=function(){var u=this;this.interactiveRelativeUri="/speech/recognition/interactive/cognitiveservices/v1",this.conversationRelativeUri="/speech/recognition/conversation/cognitiveservices/v1",this.dictationRelativeUri="/speech/recognition/dictation/cognitiveservices/v1",this.create=function(e,t,r){var n=e.parameters.getProperty(v.PropertyId.SpeechServiceConnection_Endpoint,void 0),i={},o=e.parameters.getProperty(v.PropertyId.SpeechServiceConnection_EndpointId,void 0),s=e.parameters.getProperty(v.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(o?n&&-1!==n.search(d.QueryParameterNames.DeploymentIdParamName)||(i[d.QueryParameterNames.DeploymentIdParamName]=o):s&&(n&&-1!==n.search(d.QueryParameterNames.LanguageParamName)||(i[d.QueryParameterNames.LanguageParamName]=s)),n&&-1!==n.search(d.QueryParameterNames.FormatParamName)||(i[d.QueryParameterNames.FormatParamName]=e.parameters.getProperty(f.OutputFormatPropertyName,v.OutputFormat[v.OutputFormat.Simple]).toLowerCase()),!n){var c="wss://"+e.parameters.getProperty(v.PropertyId.SpeechServiceConnection_Region,void 0)+".stt.speech.microsoft.com";switch(e.recognitionMode){case l.RecognitionMode.Conversation:n=c+u.conversationRelativeUri;break;case l.RecognitionMode.Dictation:n=c+u.dictationRelativeUri;break;default:n=c+u.interactiveRelativeUri}}var a={};return a[t.headerName]=t.token,a[d.QueryParameterNames.ConnectionIdHeader]=r,new p.WebsocketConnection(n,i,a,new l.WebsocketMessageFormatter,r)}};t.SpeechConnectionFactory=n},function(e,t,r){window.SpeechSDK=r(21)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(6);t(2).Events.instance.attachListener(new n.ConsoleLoggingListener),function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(t(0))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=function(e){void 0===e&&(e=n.EventType.Warning);var r=this;this.onEvent=function(e){if(e.eventType>=r.privLogLevelFilter){var t=r.toString(e);switch(e.eventType){case n.EventType.Debug:console.debug(t);break;case n.EventType.Info:console.info(t);break;case n.EventType.Warning:console.warn(t);break;case n.EventType.Error:console.error(t);break;default:console.log(t)}}},this.toString=function(e){var t=[""+e.EventTime,""+e.Name];for(var r in e)if(r&&e.hasOwnProperty(r)&&"eventTime"!==r&&"eventType"!==r&&"eventId"!==r&&"name"!==r&&"constructor"!==r){var n=e[r],i="<NULL>";null!=n&&(i="number"==typeof n||"string"==typeof n?n.toString():JSON.stringify(n)),t.push(r+": "+i)}return t.join(" | ")},this.privLogLevelFilter=e};t.ConsoleLoggingListener=i},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var s=r(8),i=function(i){function e(e,t,r){void 0===r&&(r=s.EventType.Info);var n=i.call(this,e,r)||this;return n.privAudioSourceId=t,n}return o(e,i),Object.defineProperty(e.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),e}(s.PlatformEvent),c=function(t){function e(e){return t.call(this,"AudioSourceInitializingEvent",e)||this}return o(e,t),e}(t.AudioSourceEvent=i);t.AudioSourceInitializingEvent=c;var a=function(t){function e(e){return t.call(this,"AudioSourceReadyEvent",e)||this}return o(e,t),e}(i);t.AudioSourceReadyEvent=a;var u=function(t){function e(e){return t.call(this,"AudioSourceOffEvent",e)||this}return o(e,t),e}(i);t.AudioSourceOffEvent=u;var p=function(n){function e(e,t){var r=n.call(this,"AudioSourceErrorEvent",e,s.EventType.Error)||this;return r.privError=t,r}return o(e,n),Object.defineProperty(e.prototype,"error",{get:function(){return this.privError},enumerable:!0,configurable:!0}),e}(i);t.AudioSourceErrorEvent=p;var f=function(i){function e(e,t,r){var n=i.call(this,e,t)||this;return n.privAudioNodeId=r,n}return o(e,i),Object.defineProperty(e.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),e}(i),v=function(r){function e(e,t){return r.call(this,"AudioStreamNodeAttachingEvent",e,t)||this}return o(e,r),e}(t.AudioStreamNodeEvent=f);t.AudioStreamNodeAttachingEvent=v;var l=function(r){function e(e,t){return r.call(this,"AudioStreamNodeAttachedEvent",e,t)||this}return o(e,r),e}(f);t.AudioStreamNodeAttachedEvent=l;var d=function(r){function e(e,t){return r.call(this,"AudioStreamNodeDetachedEvent",e,t)||this}return o(e,r),e}(f);t.AudioStreamNodeDetachedEvent=d;var h=function(i){function e(e,t,r){var n=i.call(this,"AudioStreamNodeErrorEvent",e,t)||this;return n.privError=r,n}return o(e,i),Object.defineProperty(e.prototype,"error",{get:function(){return this.privError},enumerable:!0,configurable:!0}),e}(f);t.AudioStreamNodeErrorEvent=h},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var s=r(8),i=function(i){function e(e,t,r){void 0===r&&(r=s.EventType.Info);var n=i.call(this,e,r)||this;return n.privConnectionId=t,n}return o(e,i),Object.defineProperty(e.prototype,"connectionId",{get:function(){return this.privConnectionId},enumerable:!0,configurable:!0}),e}(s.PlatformEvent),c=function(i){function e(e,t,r){var n=i.call(this,"ConnectionStartEvent",e)||this;return n.privUri=t,n.privHeaders=r,n}return o(e,i),Object.defineProperty(e.prototype,"uri",{get:function(){return this.privUri},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"headers",{get:function(){return this.privHeaders},enumerable:!0,configurable:!0}),e}(t.ConnectionEvent=i);t.ConnectionStartEvent=c;var a=function(r){function e(e,t){return r.call(this,"ConnectionEstablishedEvent",e)||this}return o(e,r),e}(i);t.ConnectionEstablishedEvent=a;var u=function(i){function e(e,t,r){var n=i.call(this,"ConnectionClosedEvent",e,s.EventType.Debug)||this;return n.privRreason=r,n.privStatusCode=t,n}return o(e,i),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privRreason},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"statusCode",{get:function(){return this.privStatusCode},enumerable:!0,configurable:!0}),e}(i);t.ConnectionClosedEvent=u;var p=function(i){function e(e,t,r){var n=i.call(this,"ConnectionEstablishErrorEvent",e,s.EventType.Error)||this;return n.privStatusCode=t,n.privReason=r,n}return o(e,i),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"statusCode",{get:function(){return this.privStatusCode},enumerable:!0,configurable:!0}),e}(i);t.ConnectionEstablishErrorEvent=p;var f=function(i){function e(e,t,r){var n=i.call(this,"ConnectionMessageReceivedEvent",e)||this;return n.privNetworkReceivedTime=t,n.privMessage=r,n}return o(e,i),Object.defineProperty(e.prototype,"networkReceivedTime",{get:function(){return this.privNetworkReceivedTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this.privMessage},enumerable:!0,configurable:!0}),e}(i);t.ConnectionMessageReceivedEvent=f;var v=function(i){function e(e,t,r){var n=i.call(this,"ConnectionMessageSentEvent",e)||this;return n.privNetworkSentTime=t,n.privMessage=r,n}return o(e,i),Object.defineProperty(e.prototype,"networkSentTime",{get:function(){return this.privNetworkSentTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this.privMessage},enumerable:!0,configurable:!0}),e}(i);t.ConnectionMessageSentEvent=v},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){this.privStatusCode=e,this.privReason=t}return Object.defineProperty(e.prototype,"statusCode",{get:function(){return this.privStatusCode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),e}();t.ConnectionOpenResponse=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(3),i=r(13),o=function(){function t(){}return Object.defineProperty(t,"instance",{get:function(){return t.privInstance},enumerable:!0,configurable:!0}),t.privInstance=new i.EventSource,t.setEventSource=function(e){if(!e)throw new n.ArgumentNullError("eventSource");t.privInstance=e},t}();t.Events=o},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.ConnectionState||(t.ConnectionState={}))[n.None=0]="None",n[n.Connected=1]="Connected",n[n.Connecting=2]="Connecting",n[n.Disconnected=3]="Disconnected"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(12),i=r(3),o=r(5),s=function(){function e(e,t,r){if(this.privPayload=null,!t)throw new i.ArgumentNullError("payload");if(e===n.MessageType.Binary&&!(t instanceof ArrayBuffer))throw new i.InvalidOperationError("Payload must be ArrayBuffer");if(e===n.MessageType.Text&&"string"!=typeof t)throw new i.InvalidOperationError("Payload must be a string");this.privMessageType=e,this.privPayload=t,this.privId=r||o.createNoDashGuid()}return Object.defineProperty(e.prototype,"messageType",{get:function(){return this.privMessageType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"payload",{get:function(){return this.privPayload},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textContent",{get:function(){if(this.privMessageType===n.MessageType.Binary)throw new i.InvalidOperationError("Not supported for binary message");return this.privPayload},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryContent",{get:function(){if(this.privMessageType===n.MessageType.Text)throw new i.InvalidOperationError("Not supported for text message");return this.privPayload},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privId},enumerable:!0,configurable:!0}),e}();t.RawWebsocketMessage=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t){var a=this;this.privChannelCount=1,this.encode=function(e,t){var r=a.downSampleAudioFrame(t,a.privActualSampleRate,a.privDesiredSampleRate);if(!r)return null;var n=2*r.length;if(!e){var i=new ArrayBuffer(n),o=new DataView(i);return a.floatTo16BitPCM(o,0,r),i}var s=new ArrayBuffer(44+n),c=new DataView(s);return a.setString(c,0,"RIFF"),c.setUint32(4,0,!0),a.setString(c,8,"WAVEfmt "),c.setUint32(16,16,!0),c.setUint16(20,1,!0),c.setUint16(22,a.privChannelCount,!0),c.setUint32(24,a.privDesiredSampleRate,!0),c.setUint32(28,a.privDesiredSampleRate*a.privChannelCount*2,!0),c.setUint16(32,2*a.privChannelCount,!0),c.setUint16(34,16,!0),a.setString(c,36,"data"),c.setUint32(40,0,!0),a.floatTo16BitPCM(c,44,r),s},this.setString=function(e,t,r){for(var n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))},this.floatTo16BitPCM=function(e,t,r){for(var n=0;n<r.length;n++,t+=2){var i=Math.max(-1,Math.min(1,r[n]));e.setInt16(t,i<0?32768*i:32767*i,!0)}},this.downSampleAudioFrame=function(e,t,r){if(r===t||t<r)return e;for(var n=t/r,i=Math.round(e.length/n),o=new Float32Array(i),s=0,c=0;c<i;){for(var a=Math.round((c+1)*n),u=0,p=0;s<a&&s<e.length;)u+=e[s++],p++;o[c++]=u/p}return o},this.privActualSampleRate=e,this.privDesiredSampleRate=t};t.RiffPcmEncoder=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=r(3),n=r(5),s=r(16),i=function(){function e(e){var i=this;this.privReaderIdCounter=1,this.privIsEnded=!1,this.write=function(e){i.throwIfClosed(),i.writeStreamChunk({buffer:e,isEnd:!1})},this.getReader=function(){var e=i.privReaderIdCounter;i.privReaderIdCounter++;var t=new s.Queue,r=i.privStreambuffer.length;i.privReaderQueues[e]=t;for(var n=0;n<r;n++)t.enqueue(i.privStreambuffer[n]);return new c(i.privId,t,function(){delete i.privReaderQueues[e]})},this.close=function(){i.privIsEnded||(i.writeStreamChunk({buffer:null,isEnd:!0}),i.privIsEnded=!0)},this.writeStreamChunk=function(e){for(var t in i.throwIfClosed(),i.privStreambuffer.push(e),i.privReaderQueues)if(!i.privReaderQueues[t].isDisposed())try{i.privReaderQueues[t].enqueue(e)}catch(e){}},this.throwIfClosed=function(){if(i.privIsEnded)throw new o.InvalidOperationError("Stream closed")},this.privId=e||n.createNoDashGuid(),this.privStreambuffer=[],this.privReaderQueues={}}return Object.defineProperty(e.prototype,"isClosed",{get:function(){return this.privIsEnded},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privId},enumerable:!0,configurable:!0}),e}();t.Stream=i;var c=function(){function e(e,t,r){var n=this;this.privIsClosed=!1,this.read=function(){if(n.isClosed)throw new o.InvalidOperationError("StreamReader closed");return n.privReaderQueue.dequeue().onSuccessContinueWith(function(e){return e.isEnd&&n.privReaderQueue.dispose("End of stream reached"),e})},this.close=function(){n.privIsClosed||(n.privIsClosed=!0,n.privReaderQueue.dispose("StreamReader closed"),n.privOnClose())},this.privReaderQueue=t,this.privOnClose=r,this.privStreamId=e}return Object.defineProperty(e.prototype,"isClosed",{get:function(){return this.privIsClosed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"streamId",{get:function(){return this.privStreamId},enumerable:!0,configurable:!0}),e}();t.StreamReader=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(7),o=r(2),i=function(){function e(e,t){var i=this;this.privStreams={},this.turnOn=function(){if(i.privInitializeDeferral)return i.privInitializeDeferral.promise();i.privInitializeDeferral=new o.Deferred,i.createAudioContext();var n=window.navigator,e=n.getUserMedia||n.webkitGetUserMedia||n.mozGetUserMedia||n.msGetUserMedia;if(n.mediaDevices&&(e=function(e,t,r){n.mediaDevices.getUserMedia(e).then(t).catch(r)}),e){var t=function(){i.onEvent(new o.AudioSourceInitializingEvent(i.privId)),e({audio:!0,video:!1},function(e){i.privMediaStream=e,i.onEvent(new o.AudioSourceReadyEvent(i.privId)),i.privInitializeDeferral.resolve(!0)},function(e){var t="Error occurred during microphone initialization: "+e,r=i.privInitializeDeferral;i.privInitializeDeferral=null,r.reject(t),i.onEvent(new o.AudioSourceErrorEvent(i.privId,t))})};"suspended"===i.privContext.state?i.privContext.resume().then(t,function(e){i.privInitializeDeferral.reject("Failed to initialize audio context: "+e)}):t()}else{var r="Browser does not support getUserMedia.";i.privInitializeDeferral.reject(r),i.onEvent(new o.AudioSourceErrorEvent(r,""))}return i.privInitializeDeferral.promise()},this.id=function(){return i.privId},this.attach=function(t){return i.onEvent(new o.AudioStreamNodeAttachingEvent(i.privId,t)),i.listen(t).onSuccessContinueWith(function(e){return i.onEvent(new o.AudioStreamNodeAttachedEvent(i.privId,t)),{detach:function(){e.close(),delete i.privStreams[t],i.onEvent(new o.AudioStreamNodeDetachedEvent(i.privId,t)),i.turnOff()},id:function(){return t},read:function(){return e.read()}}})},this.detach=function(e){e&&i.privStreams[e]&&(i.privStreams[e].close(),delete i.privStreams[e],i.onEvent(new o.AudioStreamNodeDetachedEvent(i.privId,e)))},this.turnOff=function(){for(var e in i.privStreams)if(e){var t=i.privStreams[e];t&&t.close()}return i.onEvent(new o.AudioSourceOffEvent(i.privId)),i.privInitializeDeferral=null,i.destroyAudioContext(),o.PromiseHelper.fromResult(!0)},this.listen=function(r){return i.turnOn().onSuccessContinueWith(function(e){var t=new o.Stream(r);i.privStreams[r]=t;try{i.privRecorder.record(i.privContext,i.privMediaStream,t)}catch(e){throw i.onEvent(new o.AudioStreamNodeErrorEvent(i.privId,r,e)),e}return t.getReader()})},this.onEvent=function(e){i.privEvents.onEvent(e),o.Events.instance.onEvent(e)},this.createAudioContext=function(){if(!i.privContext){var e=window.AudioContext||window.webkitAudioContext||!1;if(!e)throw new Error("Browser does not support Web Audio API (AudioContext is not available).");i.privContext=new e}},this.destroyAudioContext=function(){if(i.privContext){i.privRecorder.releaseMediaResources(i.privContext);var e=!1;"close"in i.privContext&&(e=!0),e?(i.privContext.close(),i.privContext=null):null!==i.privContext&&"running"===i.privContext.state&&i.privContext.suspend()}},this.privId=t||o.createNoDashGuid(),this.privEvents=new o.EventSource,this.privRecorder=e}return Object.defineProperty(e.prototype,"format",{get:function(){return e.AUDIOFORMAT},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"events",{get:function(){return this.privEvents},enumerable:!0,configurable:!0}),e.AUDIOFORMAT=n.AudioStreamFormat.getDefaultInputFormat(),e}();t.MicAudioSource=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(7),u=r(2),i=function(){function a(e,t){var c=this;this.privStreams={},this.turnOn=function(){if("undefined"==typeof FileReader){var e="Browser does not support FileReader.";return c.onEvent(new u.AudioSourceErrorEvent(e,"")),u.PromiseHelper.fromError(e)}if(c.privFile.name.lastIndexOf(".wav")!==c.privFile.name.length-4){e=c.privFile.name+" is not supported. Only WAVE files are allowed at the moment.";return c.onEvent(new u.AudioSourceErrorEvent(e,"")),u.PromiseHelper.fromError(e)}if(c.privFile.size>a.MAX_SIZE){e=c.privFile.name+" exceeds the maximum allowed file size ("+a.MAX_SIZE+").";return c.onEvent(new u.AudioSourceErrorEvent(e,"")),u.PromiseHelper.fromError(e)}return c.onEvent(new u.AudioSourceInitializingEvent(c.privId)),c.onEvent(new u.AudioSourceReadyEvent(c.privId)),u.PromiseHelper.fromResult(!0)},this.id=function(){return c.privId},this.attach=function(t){return c.onEvent(new u.AudioStreamNodeAttachingEvent(c.privId,t)),c.upload(t).onSuccessContinueWith(function(e){return c.onEvent(new u.AudioStreamNodeAttachedEvent(c.privId,t)),{detach:function(){e.close(),delete c.privStreams[t],c.onEvent(new u.AudioStreamNodeDetachedEvent(c.privId,t)),c.turnOff()},id:function(){return t},read:function(){return e.read()}}})},this.detach=function(e){e&&c.privStreams[e]&&(c.privStreams[e].close(),delete c.privStreams[e],c.onEvent(new u.AudioStreamNodeDetachedEvent(c.privId,e)))},this.turnOff=function(){for(var e in c.privStreams)if(e){var t=c.privStreams[e];t&&!t.isClosed&&t.close()}return c.onEvent(new u.AudioSourceOffEvent(c.privId)),u.PromiseHelper.fromResult(!0)},this.upload=function(s){return c.turnOn().onSuccessContinueWith(function(e){var r=new u.Stream(s);c.privStreams[s]=r;var n=new FileReader,i=0,o=a.CHUNK_SIZE;n.onload=function(e){if(!r.isClosed)if(r.write(n.result),o<c.privFile.size){i=o,o=Math.min(o+a.CHUNK_SIZE,c.privFile.size);var t=c.privFile.slice(i,o);n.readAsArrayBuffer(t)}else r.close()},n.onerror=function(e){var t="Error occurred while processing '"+c.privFile.name+"'. "+e;throw c.onEvent(new u.AudioStreamNodeErrorEvent(c.privId,s,t)),new Error(t)};var t=c.privFile.slice(i,o);return n.readAsArrayBuffer(t),r.getReader()})},this.onEvent=function(e){c.privEvents.onEvent(e),u.Events.instance.onEvent(e)},this.privId=t||u.createNoDashGuid(),this.privEvents=new u.EventSource,this.privFile=e}return Object.defineProperty(a.prototype,"format",{get:function(){return a.FILEFORMAT},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"events",{get:function(){return this.privEvents},enumerable:!0,configurable:!0}),a.CHUNK_SIZE=2*(a.SAMPLE_RATE=32e3)/5,a.UPLOAD_INTERVAL=200,a.MAX_SIZE=600*a.SAMPLE_RATE+44,a.FILEFORMAT=n.AudioStreamFormat.getWaveFormatPCM(16e3,16,1),a}();t.FileAudioSource=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){var i=this;this.record=function(e,t,r){var n=new MediaRecorder(t,i.privMediaRecorderOptions);n.ondataavailable=function(e){if(r){var t=new FileReader;t.readAsArrayBuffer(e.data),t.onloadend=function(e){r.write(t.result)}}},i.privMediaResources={recorder:n,stream:t},n.start(100)},this.releaseMediaResources=function(e){"inactive"!==i.privMediaResources.recorder.state&&i.privMediaResources.recorder.stop(),i.privMediaResources.stream.getTracks().forEach(function(e){return e.stop()})},this.privMediaRecorderOptions=e};t.OpusRecorder=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),n=function(){var c=this;this.record=function(n,e,i){var t=function(){var t=0;try{return n.createScriptProcessor(t,1,1)}catch(e){t=2048;for(var r=n.sampleRate;t<16384&&32e3<=r;)t<<=1,r>>=1;return n.createScriptProcessor(t,1,1)}}(),o=new a.RiffPcmEncoder(n.sampleRate,16e3),s=!0;t.onaudioprocess=function(e){var t=e.inputBuffer.getChannelData(0);if(i&&!i.isClosed){var r=o.encode(s,t);r&&(i.write(r),s=!1)}};var r=n.createMediaStreamSource(e);c.privMediaResources={scriptProcessorNode:t,source:r,stream:e},r.connect(t),t.connect(n.destination)},this.releaseMediaResources=function(e){c.privMediaResources&&(c.privMediaResources.scriptProcessorNode&&(c.privMediaResources.scriptProcessorNode.disconnect(e.destination),c.privMediaResources.scriptProcessorNode=null),c.privMediaResources.source&&(c.privMediaResources.source.disconnect(),c.privMediaResources.stream.getTracks().forEach(function(e){return e.stop()}),c.privMediaResources.source=null))}};t.PcmRecorder=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var p=r(2),f=r(17),n=function(){function e(e,t,r,n,i){var o=this;if(this.privIsDisposed=!1,this.dispose=function(){o.privIsDisposed=!0,o.privConnectionMessageAdapter&&o.privConnectionMessageAdapter.close()},this.isDisposed=function(){return o.privIsDisposed},this.state=function(){return o.privConnectionMessageAdapter.state},this.open=function(){return o.privConnectionMessageAdapter.open()},this.send=function(e){return o.privConnectionMessageAdapter.send(e)},this.read=function(){return o.privConnectionMessageAdapter.read()},!e)throw new p.ArgumentNullError("uri");if(!n)throw new p.ArgumentNullError("messageFormatter");this.privMessageFormatter=n;var s="",c=0;if(t)for(var a in t){if(a)s+=0===c&&-1===e.indexOf("?")?"?":"&",s+=a+"="+encodeURIComponent(t[a]),c++}if(r)for(var u in r){if(u)s+=0===c?"?":"&",s+=u+"="+encodeURIComponent(r[u]),c++}this.privUri=e+s,this.privId=i||p.createNoDashGuid(),this.privConnectionMessageAdapter=new f.WebsocketMessageAdapter(this.privUri,this.id,this.privMessageFormatter)}return Object.defineProperty(e.prototype,"id",{get:function(){return this.privId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"events",{get:function(){return this.privConnectionMessageAdapter.events},enumerable:!0,configurable:!0}),e}();t.WebsocketConnection=n},function(e,t,r){"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),n=function(){function e(e,t){var r=this;this.privBuffers=[],this.privReplayOffset=0,this.privLastShrinkOffset=0,this.privBufferStartOffset=0,this.privBufferSerial=0,this.privBufferedBytes=0,this.privReplay=!1,this.id=function(){return r.privAudioNode.id()},this.privAudioNode=e,this.privFormat=t}return e.prototype.read=function(){var t=this;if(this.privReplay&&0!==this.privBuffers.length){var e=this.privReplayOffset-this.privBufferStartOffset,r=Math.round(e*this.privFormat.avgBytesPerSec*1e-7);0!=r%2&&r++;for(var n=0;n<this.privBuffers.length&&r>=this.privBuffers[n].buffer.byteLength;)r-=this.privBuffers[n++].buffer.byteLength;var i=this.privBuffers[n].buffer.slice(r);return this.privReplayOffset+=i.byteLength/this.privFormat.avgBytesPerSec*1e7,n===this.privBuffers.length-1&&(this.privReplay=!1),o.PromiseHelper.fromResult({buffer:i,isEnd:!1})}return this.privAudioNode.read().onSuccessContinueWith(function(e){return e.buffer&&(t.privBuffers.push(new s(e.buffer,t.privBufferSerial++,t.privBufferedBytes)),t.privBufferedBytes+=e.buffer.byteLength),e})},e.prototype.detach=function(){this.privAudioNode.detach(),this.privBuffers=void 0},e.prototype.replay=function(){0!==this.privBuffers.length&&(this.privReplay=!0,this.privReplayOffset=this.privLastShrinkOffset)},e.prototype.shrinkBuffers=function(e){for(var t=(this.privLastShrinkOffset=e)-this.privBufferStartOffset,r=Math.round(t*this.privFormat.avgBytesPerSec*1e-7),n=0;n<this.privBuffers.length&&r>=this.privBuffers[n].buffer.byteLength;)r-=this.privBuffers[n++].buffer.byteLength;this.privBufferStartOffset=Math.round(e-r/this.privFormat.avgBytesPerSec*1e7),this.privBuffers=this.privBuffers.slice(n)},e}();t.ReplayableAudioNode=n;var s=function(e,t,r){this.buffer=e,this.serial=t,this.byteOffset=r}},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(6),s=r(0),c=r(18),a=function(){function e(){}return e.fromDefaultMicrophoneInput=function(){var e=new o.PcmRecorder;return new u(new o.MicAudioSource(e))},e.fromWavFileInput=function(e){return new u(new o.FileAudioSource(e))},e.fromStreamInput=function(e){if(e instanceof s.PullAudioInputStreamCallback)return new u(new c.PullAudioInputStreamImpl(e));if(e instanceof s.AudioInputStream)return new u(e);throw new Error("Not Supported Type")},e}(),u=function(r){function e(e){var t=r.call(this)||this;return t.privSource=e,t}return i(e,r),Object.defineProperty(e.prototype,"format",{get:function(){return this.privSource.format},enumerable:!0,configurable:!0}),e.prototype.close=function(){this.privSource.turnOff()},e.prototype.id=function(){return this.privSource.id()},e.prototype.turnOn=function(){return this.privSource.turnOn()},e.prototype.attach=function(e){return this.privSource.attach(e)},e.prototype.detach=function(e){return this.detach(e)},e.prototype.turnOff=function(){return this.privSource.turnOff()},Object.defineProperty(e.prototype,"events",{get:function(){return this.privSource.events},enumerable:!0,configurable:!0}),e}(t.AudioConfig=a);t.AudioConfigImpl=u},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.CancellationReason||(t.CancellationReason={}))[n.Error=0]="Error",n[n.EndOfStream=1]="EndOfStream"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){};t.PullAudioInputStreamCallback=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=function(){function e(){this.privDisposed=!1}return e.fromFile=function(e){throw n.Contracts.throwIfFileDoesNotExist(e,"fileName"),new Error("Not yet implemented.")},e.fromStream=function(e){throw n.Contracts.throwIfNull(e,"file"),new Error("Not yet implemented.")},e.prototype.close=function(){this.privDisposed||(this.privDisposed=!0)},e}();t.KeywordRecognitionModel=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privSessionId=e}return Object.defineProperty(e.prototype,"sessionId",{get:function(){return this.privSessionId},enumerable:!0,configurable:!0}),e}();t.SessionEventArgs=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(n){function e(e,t){var r=n.call(this,t)||this;return r.privOffset=e,r}return i(e,n),Object.defineProperty(e.prototype,"offset",{get:function(){return this.privOffset},enumerable:!0,configurable:!0}),e}(r(0).SessionEventArgs);t.RecognitionEventArgs=o},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.OutputFormat||(t.OutputFormat={}))[n.Simple=0]="Simple",n[n.Detailed=1]="Detailed"},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var i=function(i){function e(e,t,r){var n=i.call(this,t,r)||this;return n.privResult=e,n}return o(e,i),Object.defineProperty(e.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),e}(r(0).RecognitionEventArgs);t.IntentRecognitionEventArgs=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,r,n,i,o,s,c){this.privResultId=e,this.privReason=t,this.privText=r,this.privDuration=n,this.privOffset=i,this.privErrorDetails=o,this.privJson=s,this.privProperties=c}return Object.defineProperty(e.prototype,"resultId",{get:function(){return this.privResultId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this.privText},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this.privDuration},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"offset",{get:function(){return this.privOffset},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorDetails",{get:function(){return this.privErrorDetails},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"json",{get:function(){return this.privJson},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),e}();t.RecognitionResult=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(a){function e(e,t,r,n,i,o,s,c){return a.call(this,e,t,r,n,i,o,s,c)||this}return i(e,a),e}(r(0).RecognitionResult);t.SpeechRecognitionResult=o},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(p){function e(e,t,r,n,i,o,s,c,a){var u=p.call(this,t,r,n,i,o,s,c,a)||this;return u.privIntentId=e,u}return i(e,p),Object.defineProperty(e.prototype,"intentId",{get:function(){return this.privIntentId},enumerable:!0,configurable:!0}),e}(r(0).SpeechRecognitionResult);t.IntentRecognitionResult=o},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),s=function(){function e(){}return e.fromEndpoint=function(e){o.Contracts.throwIfNull(e,"uri"),o.Contracts.throwIfNullOrWhitespace(e.hostname,"uri");var t=new c,r=e.host.indexOf(".");if(-1===r)throw new Error("Could not determine region from endpoint");t.region=e.host.substr(0,r);var 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},e.fromAppId=function(e){o.Contracts.throwIfNullOrWhitespace(e,"appId");var t=new c;return t.appId=e,t},e.fromSubscription=function(e,t,r){o.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),o.Contracts.throwIfNullOrWhitespace(t,"appId"),o.Contracts.throwIfNullOrWhitespace(r,"region");var n=new c;return n.appId=t,n.region=r,n.subscriptionKey=e,n},e}(),c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(t.LanguageUnderstandingModel=s);t.LanguageUnderstandingModelImpl=c},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var i=function(i){function e(e,t,r){var n=i.call(this,t,r)||this;return n.privResult=e,n}return o(e,i),Object.defineProperty(e.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),e}(r(0).RecognitionEventArgs);t.SpeechRecognitionEventArgs=i},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(s){function e(e,t,r,n,i){var o=s.call(this,n,i)||this;return o.privReason=e,o.privErrorDetails=t,o.privErrorCode=r,o}return i(e,s),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorCode",{get:function(){return this.privErrorCode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorDetails",{get:function(){return this.privErrorDetails},enumerable:!0,configurable:!0}),e}(r(0).RecognitionEventArgs);t.SpeechRecognitionCanceledEventArgs=o},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var i=function(i){function e(e,t,r){var n=i.call(this,t,r)||this;return n.privResult=e,n}return o(e,i),Object.defineProperty(e.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),e}(r(0).RecognitionEventArgs);t.TranslationRecognitionEventArgs=i},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(n){function e(e,t){var r=n.call(this,t)||this;return r.privResult=e,r}return i(e,n),Object.defineProperty(e.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),e}(r(0).SessionEventArgs);t.TranslationSynthesisEventArgs=o},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(p){function e(e,t,r,n,i,o,s,c,a){var u=p.call(this,t,r,n,i,o,s,c,a)||this;return u.privTranslations=e,u}return i(e,p),Object.defineProperty(e.prototype,"translations",{get:function(){return this.privTranslations},enumerable:!0,configurable:!0}),e}(r(0).SpeechRecognitionResult);t.TranslationRecognitionResult=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){this.privReason=e,this.privAudio=t}return Object.defineProperty(e.prototype,"audio",{get:function(){return this.privAudio},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),e}();t.TranslationSynthesisResult=n},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.ResultReason||(t.ResultReason={}))[n.NoMatch=0]="NoMatch",n[n.Canceled=1]="Canceled",n[n.RecognizingSpeech=2]="RecognizingSpeech",n[n.RecognizedSpeech=3]="RecognizedSpeech",n[n.RecognizingIntent=4]="RecognizingIntent",n[n.RecognizedIntent=5]="RecognizedIntent",n[n.TranslatingSpeech=6]="TranslatingSpeech",n[n.TranslatedSpeech=7]="TranslatedSpeech",n[n.SynthesizingAudio=8]="SynthesizingAudio",n[n.SynthesizingAudioCompleted=9]="SynthesizingAudioCompleted"},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=r(4),c=r(0),a=function(){function e(){}return e.fromSubscription=function(e,t){s.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),s.Contracts.throwIfNullOrWhitespace(t,"region");var r=new u;return r.setProperty(c.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(c.PropertyId.SpeechServiceConnection_IntentRegion,t),r.setProperty(c.PropertyId.SpeechServiceConnection_Key,e),r},e.fromEndpoint=function(e,t){s.Contracts.throwIfNull(e,"endpoint"),s.Contracts.throwIfNull(t,"subscriptionKey");var r=new u;return r.setProperty(c.PropertyId.SpeechServiceConnection_Endpoint,e.href),r.setProperty(c.PropertyId.SpeechServiceConnection_Key,t),r},e.fromAuthorizationToken=function(e,t){s.Contracts.throwIfNull(e,"authorizationToken"),s.Contracts.throwIfNullOrWhitespace(t,"region");var r=new u;return r.setProperty(c.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(c.PropertyId.SpeechServiceConnection_IntentRegion,t),r.authorizationToken=e,r},e.prototype.close=function(){},e}(),u=function(t){function r(){var e=t.call(this)||this;return e.privProperties=new c.PropertyCollection,e.speechRecognitionLanguage="en-US",e.outputFormat=c.OutputFormat.Simple,e}return i(r,t),Object.defineProperty(r.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"endPoint",{get:function(){return new URL(this.privProperties.getProperty(c.PropertyId.SpeechServiceConnection_Endpoint))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"subscriptionKey",{get:function(){return this.privProperties.getProperty(c.PropertyId.SpeechServiceConnection_Key)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"region",{get:function(){return this.privProperties.getProperty(c.PropertyId.SpeechServiceConnection_Region)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"authorizationToken",{get:function(){return this.privProperties.getProperty(c.PropertyId.SpeechServiceAuthorization_Token)},set:function(e){this.privProperties.setProperty(c.PropertyId.SpeechServiceAuthorization_Token,e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"speechRecognitionLanguage",{get:function(){return this.privProperties.getProperty(c.PropertyId.SpeechServiceConnection_RecoLanguage)},set:function(e){this.privProperties.setProperty(c.PropertyId.SpeechServiceConnection_RecoLanguage,e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"outputFormat",{get:function(){return c.OutputFormat[this.privProperties.getProperty(o.OutputFormatPropertyName,void 0)]},set:function(e){this.privProperties.setProperty(o.OutputFormatPropertyName,c.OutputFormat[e])},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"endpointId",{get:function(){return this.privProperties.getProperty(c.PropertyId.SpeechServiceConnection_EndpointId)},set:function(e){this.privProperties.setProperty(c.PropertyId.SpeechServiceConnection_EndpointId,e)},enumerable:!0,configurable:!0}),r.prototype.setProperty=function(e,t){s.Contracts.throwIfNull(t,"value"),this.privProperties.setProperty(e,t)},r.prototype.getProperty=function(e,t){return this.privProperties.getProperty(e,t)},r.prototype.clone=function(){var e=new r;return e.privProperties=this.privProperties.clone(),e},r}(t.SpeechConfig=a);t.SpeechConfigImpl=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(10),o=function(e){var t=this;if(this.fetch=function(e){return n.PromiseHelper.fromResult(t.privAuthInfo)},this.fetchOnExpiry=function(e){return n.PromiseHelper.fromResult(t.privAuthInfo)},!e)throw new n.ArgumentNullError("subscriptionKey");this.privAuthInfo=new i.AuthInfo("Ocp-Apim-Subscription-Key",e)};t.CognitiveSubscriptionKeyAuthentication=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(10),o="Authorization",s=function(e,t){var r=this;if(this.fetch=function(e){return r.privFetchCallback(e).onSuccessContinueWith(function(e){return new i.AuthInfo(o,e)})},this.fetchOnExpiry=function(e){return r.privFetchOnExpiryCallback(e).onSuccessContinueWith(function(e){return new i.AuthInfo(o,e)})},!e)throw new n.ArgumentNullError("fetchCallback");if(!t)throw new n.ArgumentNullError("fetchOnExpiryCallback");this.privFetchCallback=e,this.privFetchOnExpiryCallback=t};t.CognitiveTokenAuthentication=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=r(6),u=r(0),p=r(1),n=function(){function e(){var c=this;this.create=function(e,t,r){var n=e.parameters.getProperty(u.PropertyId.SpeechServiceConnection_Endpoint);if(!n){var i=e.parameters.getProperty(u.PropertyId.SpeechServiceConnection_IntentRegion);n="wss://speech.platform.bing.com/speech/"+c.getSpeechRegionFromIntentRegion(i)+"/recognition/interactive/cognitiveservices/v1"}var o={format:"simple",language:e.parameters.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage)},s={};return s[t.headerName]=t.token,s["X-ConnectionId"]=r,new a.WebsocketConnection(n,o,s,new p.WebsocketMessageFormatter,r)}}return e.prototype.getSpeechRegionFromIntentRegion=function(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}},e}();t.IntentConnectionFactory=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),f=r(2),v=r(0),l=r(1),d=r(62),i=function(){function o(e,t,r,n,i){var p=this;if(this.sendTelemetryData=function(){var t=p.privRequestSession.getTelemetry();if(!0!==o.telemetryDataEnabled||p.privIsDisposed)return f.PromiseHelper.fromResult(!0);if(o.telemetryData)try{o.telemetryData(t)}catch(e){}return p.fetchConnection().onSuccessContinueWith(function(e){return e.send(new d.SpeechConnectionMessage(f.MessageType.Text,"telemetry",p.privRequestSession.requestId,"application/json",t))})},this.fetchConnection=function(){return p.configureConnection()},this.receiveMessage=function(a,u){return p.fetchConnection().on(function(e){return e.read().onSuccessContinueWithPromise(function(e){if(p.privIsDisposed||!p.privRequestSession.isRecognizing)return f.PromiseHelper.fromResult(void 0);if(!e)return p.privRequestSession.isRecognizing?p.receiveMessage(a,u):f.PromiseHelper.fromResult(!0);var t=d.SpeechConnectionMessage.fromConnectionMessage(e);if(t.requestId.toLowerCase()===p.privRequestSession.requestId.toLowerCase())switch(t.path.toLowerCase()){case"turn.start":p.privMustReportEndOfStream=!0;break;case"speech.startdetected":var r=l.SpeechDetected.fromJSON(t.textBody),n=new v.RecognitionEventArgs(r.Offset,p.privRequestSession.sessionId);p.privRecognizer.speechStartDetected&&p.privRecognizer.speechStartDetected(p.privRecognizer,n);break;case"speech.enddetected":var i=void 0;i=0<t.textBody.length?t.textBody:"{ Offset: 0 }";var o=l.SpeechDetected.fromJSON(i);p.privRequestSession.onServiceRecognized(o.Offset+p.privRequestSession.currentTurnAudioOffset);var s=new v.RecognitionEventArgs(o.Offset+p.privRequestSession.currentTurnAudioOffset,p.privRequestSession.sessionId);p.privRecognizer.speechEndDetected&&p.privRecognizer.speechEndDetected(p.privRecognizer,s);break;case"turn.end":p.privRequestSession.isSpeechEnded&&p.privMustReportEndOfStream&&(p.privMustReportEndOfStream=!1,p.cancelRecognitionLocal(v.CancellationReason.EndOfStream,v.CancellationErrorCode.NoError,void 0,a));var c=new v.SessionEventArgs(p.privRequestSession.sessionId);if(p.privRequestSession.onServiceTurnEndResponse(p.privRecognizerConfig.isContinuousRecognition),!p.privRecognizerConfig.isContinuousRecognition||p.privRequestSession.isSpeechEnded)return p.privRecognizer.sessionStopped&&p.privRecognizer.sessionStopped(p.privRecognizer,c),f.PromiseHelper.fromResult(!0);p.fetchConnection().onSuccessContinueWith(function(e){p.sendSpeechContext(e)});default:p.processTypeSpecificMessages(t,a,u)}return p.receiveMessage(a,u)})},function(e){})},this.sendSpeechServiceConfig=function(e,t,r){if(!0!==o.telemetryDataEnabled){var n={context:{system:JSON.parse(r).context.system}};r=JSON.stringify(n)}return r?(p.privSpeechServiceConfigConnectionId=p.privConnectionId,e.send(new d.SpeechConnectionMessage(f.MessageType.Text,"speech.config",t.requestId,"application/json",r))):f.PromiseHelper.fromResult(!0)},this.sendSpeechContext=function(e){var t=p.speechContext.toJSON();return t?e.send(new d.SpeechConnectionMessage(f.MessageType.Text,"speech.context",p.privRequestSession.requestId,"application/json",t)):f.PromiseHelper.fromResult(!0)},this.sendAudio=function(e){var s=new f.Deferred,c=Date.now(),a=p.privAudioSource.format,u=function(){p.privIsDisposed||p.privRequestSession.isSpeechEnded||!p.privRequestSession.isRecognizing||p.fetchConnection().on(function(o){e.read().on(function(e){if(p.privRequestSession.isSpeechEnded)s.resolve(!0);else{var t=e.isEnd?null:e.buffer,r=o.send(new d.SpeechConnectionMessage(f.MessageType.Binary,"audio",p.privRequestSession.requestId,null,t));if(e.isEnd)p.privRequestSession.onSpeechEnded(),s.resolve(!0);else{var n=t.byteLength/a.avgBytesPerSec/2*1e3,i=Math.max(0,c-Date.now()+n);r.continueWith(function(e){setTimeout(function(){c=Date.now(),u()},i)})}}},function(e){p.privRequestSession.isSpeechEnded?s.resolve(!0):s.reject(e)})},function(e){s.reject(e)})};return u(),s.promise()},!e)throw new f.ArgumentNullError("authentication");if(!t)throw new f.ArgumentNullError("connectionFactory");if(!r)throw new f.ArgumentNullError("audioSource");if(!n)throw new f.ArgumentNullError("recognizerConfig");this.privMustReportEndOfStream=!1,this.privAuthentication=e,this.privConnectionFactory=t,this.privAudioSource=r,this.privRecognizerConfig=n,this.privIsDisposed=!1,this.privRecognizer=i,this.privRequestSession=new l.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new f.EventSource,this.privDynamicGrammar=new l.DynamicGrammarBuilder,this.privSpeechContext=new l.SpeechContext(this.privDynamicGrammar)}return Object.defineProperty(o.prototype,"audioSource",{get:function(){return this.privAudioSource},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"speechContext",{get:function(){return this.privSpeechContext},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"dynamicGrammar",{get:function(){return this.privDynamicGrammar},enumerable:!0,configurable:!0}),o.prototype.isDisposed=function(){return this.privIsDisposed},o.prototype.dispose=function(t){this.privIsDisposed=!0,this.privConnectionConfigurationPromise&&this.privConnectionConfigurationPromise.onSuccessContinueWith(function(e){e.dispose(t)})},Object.defineProperty(o.prototype,"connectionEvents",{get:function(){return this.privConnectionEvents},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"recognitionMode",{get:function(){return this.privRecognizerConfig.recognitionMode},enumerable:!0,configurable:!0}),o.prototype.recognize=function(e,o,s){var c=this;return this.privConnectionConfigurationPromise=null,this.privRecognizerConfig.recognitionMode=e,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events),this.audioSource.attach(this.privRequestSession.audioNodeId).continueWithPromise(function(e){var i;return e.isError?(c.cancelRecognitionLocal(v.CancellationReason.Error,v.CancellationErrorCode.ConnectionFailure,e.error,o),f.PromiseHelper.fromError(e.error)):(i=new n.ReplayableAudioNode(e.result,c.audioSource.format),c.privRequestSession.onAudioSourceAttachCompleted(i,!1),c.configureConnection().on(function(e){var t=new v.SessionEventArgs(c.privRequestSession.sessionId);c.privRecognizer.sessionStarted&&c.privRecognizer.sessionStarted(c.privRecognizer,t);var r=c.receiveMessage(o,s),n=c.sendAudio(i);return n.on(function(e){},function(e){c.cancelRecognitionLocal(v.CancellationReason.Error,v.CancellationErrorCode.RuntimeError,e,o)}),f.PromiseHelper.whenAll([r,n]).on(function(e){c.privRequestSession.dispose(),c.sendTelemetryData()},function(e){c.privRequestSession.dispose(e),c.sendTelemetryData(),c.cancelRecognitionLocal(v.CancellationReason.Error,v.CancellationErrorCode.RuntimeError,e,o)})},function(e){c.cancelRecognitionLocal(v.CancellationReason.Error,v.CancellationErrorCode.ConnectionFailure,e,o)}).on(function(){return c.privRequestSession.completionPromise},function(e){c.cancelRecognitionLocal(v.CancellationReason.Error,v.CancellationErrorCode.RuntimeError,e,o)}).onSuccessContinueWithPromise(function(e){return f.PromiseHelper.fromResult(!0)}))})},o.prototype.stopRecognizing=function(){this.privRequestSession.isRecognizing&&(this.privRequestSession.onStopRecognizing(),this.audioSource.turnOff(),this.sendFinalAudio())},o.prototype.connect=function(){this.connectImpl().result()},o.prototype.disconnect=function(){this.cancelRecognitionLocal(v.CancellationReason.Error,v.CancellationErrorCode.NoError,"Disconnecting",void 0),this.privConnectionPromise.result().isCompleted?this.privConnectionPromise.result().isError||(this.privConnectionPromise.result().result.dispose(),this.privConnectionPromise=null):this.privConnectionPromise.onSuccessContinueWith(function(e){e.dispose()})},o.prototype.cancelRecognitionLocal=function(e,t,r,n){this.privRequestSession.isRecognizing&&(this.privRequestSession.onStopRecognizing(),this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,e,t,r,n))},o.prototype.connectImpl=function(r){var n=this;if(void 0===r&&(r=!1),this.privConnectionPromise)return this.privConnectionPromise.result().isCompleted&&(this.privConnectionPromise.result().isError||this.privConnectionPromise.result().result.state()===f.ConnectionState.Disconnected)?(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()):this.privConnectionPromise;this.privAuthFetchEventId=f.createNoDashGuid(),this.privConnectionId=f.createNoDashGuid(),this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId,this.privConnectionId);var e=r?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId);return this.privConnectionPromise=e.continueWithPromise(function(e){if(e.isError)throw n.privRequestSession.onAuthCompleted(!0,e.error),new Error(e.error);n.privRequestSession.onAuthCompleted(!1);var t=n.privConnectionFactory.create(n.privRecognizerConfig,e.result,n.privConnectionId);return n.privRequestSession.listenForServiceTelemetry(t.events),t.events.attach(function(e){n.connectionEvents.onEvent(e)}),t.open().onSuccessContinueWithPromise(function(e){return 200===e.statusCode?(n.privRequestSession.onPreConnectionStart(n.privAuthFetchEventId,n.privConnectionId),n.privRequestSession.onConnectionEstablishCompleted(e.statusCode),f.PromiseHelper.fromResult(t)):403!==e.statusCode||r?(n.privRequestSession.onConnectionEstablishCompleted(e.statusCode,e.reason),f.PromiseHelper.fromError("Unable to contact server. StatusCode: "+e.statusCode+", "+n.privRecognizerConfig.parameters.getProperty(v.PropertyId.SpeechServiceConnection_Endpoint)+" Reason: "+e.reason)):n.connectImpl(!0)})}),this.privConnectionPromise},o.prototype.configureConnection=function(){var r=this;return this.privConnectionConfigurationPromise?this.privConnectionConfigurationPromise.result().isCompleted&&(this.privConnectionConfigurationPromise.result().isError||this.privConnectionConfigurationPromise.result().result.state()===f.ConnectionState.Disconnected)?(this.privConnectionConfigurationPromise=null,this.configureConnection()):this.privConnectionConfigurationPromise:(this.privConnectionConfigurationPromise=this.connectImpl().onSuccessContinueWithPromise(function(t){return r.sendSpeechServiceConfig(t,r.privRequestSession,r.privRecognizerConfig.SpeechServiceConfig.serialize()).onSuccessContinueWithPromise(function(e){return r.sendSpeechContext(t).onSuccessContinueWith(function(e){return t})})}),this.privConnectionConfigurationPromise)},o.prototype.sendFinalAudio=function(){var t=this,r=new f.Deferred;return this.fetchConnection().on(function(e){e.send(new d.SpeechConnectionMessage(f.MessageType.Binary,"audio",t.privRequestSession.requestId,null,null)).on(function(e){r.resolve(!0)},function(e){r.reject(e)})},function(e){r.reject(e)}),r.promise()},o.telemetryDataEnabled=!0,o}();t.ServiceRecognizerBase=i},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var f=r(2),v="content-type",l="x-requestid",d="x-timestamp",o=function(p){function s(e,t,r,n,i,o,s){var c=this;if(!t)throw new f.ArgumentNullError("path");if(!r)throw new f.ArgumentNullError("requestId");var a={};if(a.path=t,a[l]=r,a[d]=(new Date).toISOString(),n&&(a[v]=n),o)for(var u in o)u&&(a[u]=o[u]);return(c=s?p.call(this,e,i,a,s)||this:p.call(this,e,i,a)||this).privPath=t,c.privRequestId=r,c.privContentType=n,c.privAdditionalHeaders=o,c}return i(s,p),Object.defineProperty(s.prototype,"path",{get:function(){return this.privPath},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"requestId",{get:function(){return this.privRequestId},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"contentType",{get:function(){return this.privContentType},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"additionalHeaders",{get:function(){return this.privAdditionalHeaders},enumerable:!0,configurable:!0}),s.fromConnectionMessage=function(e){var t=null,r=null,n=null,i={};if(e.headers)for(var o in e.headers)o&&(o.toLowerCase()==="path".toLowerCase()?t=e.headers[o]:o.toLowerCase()===l.toLowerCase()?r=e.headers[o]:o.toLowerCase()===d.toLowerCase()?e.headers[o]:o.toLowerCase()===v.toLowerCase()?n=e.headers[o]:i[o]=e.headers[o]);return new s(e.messageType,t,r,n,e.body,i,e.id)},s}(f.ConnectionMessage);t.SpeechConnectionMessage=o},function(e,t,r){"use strict";var n,i,o;Object.defineProperty(t,"__esModule",{value:!0}),(i=n=t.RecognitionMode||(t.RecognitionMode={}))[i.Interactive=0]="Interactive",i[i.Conversation=1]="Conversation",i[i.Dictation=2]="Dictation",(o=t.SpeechResultFormat||(t.SpeechResultFormat={}))[o.Simple=0]="Simple",o[o.Detailed=1]="Detailed";var s=function(){function e(e,t){this.privRecognitionMode=n.Interactive,this.privSpeechServiceConfig=e||new c(new a(null)),this.privParameters=t}return Object.defineProperty(e.prototype,"parameters",{get:function(){return this.privParameters},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recognitionMode",{get:function(){return this.privRecognitionMode},set:function(e){this.privRecognitionMode=e,this.privRecognitionActivityTimeout=e===n.Interactive?8e3:25e3,this.privSpeechServiceConfig.Recognition=n[e]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"SpeechServiceConfig",{get:function(){return this.privSpeechServiceConfig},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recognitionActivityTimeout",{get:function(){return this.privRecognitionActivityTimeout},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isContinuousRecognition",{get:function(){return this.privRecognitionMode!==n.Interactive},enumerable:!0,configurable:!0}),e}();t.RecognizerConfig=s;var c=function(){function e(e){var t=this;this.serialize=function(){return JSON.stringify(t,function(e,t){if(t&&"object"==typeof t){var r={};for(var n in t)Object.hasOwnProperty.call(t,n)&&(r[n&&n.charAt(0).toLowerCase()+n.substring(1)]=t[n]);return r}return t})},this.context=e}return Object.defineProperty(e.prototype,"Context",{get:function(){return this.context},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Recognition",{get:function(){return this.recognition},set:function(e){this.recognition=e.toLowerCase()},enumerable:!0,configurable:!0}),e}();t.SpeechServiceConfig=c;var a=function(e){this.system=new u,this.os=e};t.Context=a;var u=function(){this.name="SpeechSDK",this.version="1.3.0",this.build="JavaScript",this.lang="JavaScript"};t.System=u;var p=function(e,t,r){this.platform=e,this.name=t,this.version=r};t.OS=p;var f=function(e,t,r){this.manufacturer=e,this.model=t,this.version=r};t.Device=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var v=r(2),n=function(){var f=this;this.toConnectionMessage=function(e){var t=new v.Deferred;try{if(e.messageType===v.MessageType.Text){var r=e.textContent,n={},i=null;if(r){var o=r.split("\r\n\r\n");o&&0<o.length&&(n=f.parseHeaders(o[0]),1<o.length&&(i=o[1]))}t.resolve(new v.ConnectionMessage(e.messageType,i,n,e.id))}else if(e.messageType===v.MessageType.Binary){var s=e.binaryContent;if(n={},i=null,!s||s.byteLength<2)throw new Error("Invalid binary message format. Header length missing.");var c=new DataView(s),a=c.getInt16(0);if(s.byteLength<a+2)throw new Error("Invalid binary message format. Header content missing.");for(var u="",p=0;p<a;p++)u+=String.fromCharCode(c.getInt8(p+2));n=f.parseHeaders(u),s.byteLength>a+2&&(i=s.slice(2+a)),t.resolve(new v.ConnectionMessage(e.messageType,i,n,e.id))}}catch(e){t.reject("Error formatting the message. Error: "+e)}return t.promise()},this.fromConnectionMessage=function(e){var t=new v.Deferred;try{if(e.messageType===v.MessageType.Text){var r=f.makeHeaders(e)+"\r\n"+(e.textBody?e.textBody:"");t.resolve(new v.RawWebsocketMessage(v.MessageType.Text,r,e.id))}else if(e.messageType===v.MessageType.Binary){var n=f.makeHeaders(e),i=e.binaryBody,o=new Int8Array(f.stringToArrayBuffer(n)),s=(r=new ArrayBuffer(2+o.byteLength+(i?i.byteLength:0)),new DataView(r));s.setInt16(0,o.length);for(var c=0;c<o.byteLength;c++)s.setInt8(2+c,o[c]);if(i){var a=new Int8Array(i);for(c=0;c<a.byteLength;c++)s.setInt8(2+o.byteLength+c,a[c])}t.resolve(new v.RawWebsocketMessage(v.MessageType.Binary,r,e.id))}}catch(e){t.reject("Error formatting the message. "+e)}return t.promise()},this.makeHeaders=function(e){var t="";if(e.headers)for(var r in e.headers)r&&(t+=r+": "+e.headers[r]+"\r\n");return t},this.parseHeaders=function(e){var t={};if(e){var r=e.match(/[^\r\n]+/g);if(t)for(var n=0,i=r;n<i.length;n++){var o=i[n];if(o){var s=o.indexOf(":"),c=0<s?o.substr(0,s).trim().toLowerCase():o,a=0<s&&o.length>s+1?o.substr(s+1).trim():"";t[c]=a}}}return t},this.stringToArrayBuffer=function(e){for(var t=new ArrayBuffer(e.length),r=new DataView(t),n=0;n<e.length;n++)r.setUint8(n,e.charCodeAt(n));return t}};t.WebsocketMessageFormatter=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return Object.defineProperty(e,"TestHooksParamName",{get:function(){return"testhooks"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ConnectionIdHeader",{get:function(){return"X-ConnectionId"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"DeploymentIdParamName",{get:function(){return"cid"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"FormatParamName",{get:function(){return"format"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"LanguageParamName",{get:function(){return"language"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"TranslationFromParamName",{get:function(){return"from"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"TranslationToParamName",{get:function(){return"to"},enumerable:!0,configurable:!0}),e}();t.QueryParameterNames=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=r(6),c=r(0),a=r(1),n=function(){this.create=function(e,t,r){var n=e.parameters.getProperty(c.PropertyId.SpeechServiceConnection_Endpoint,void 0);n||(n="wss://"+e.parameters.getProperty(c.PropertyId.SpeechServiceConnection_Region,void 0)+".s2s.speech.microsoft.com/speech/translation/cognitiveservices/v1");var i={from:e.parameters.getProperty(c.PropertyId.SpeechServiceConnection_RecoLanguage),to:e.parameters.getProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages)};void 0!==e.parameters.getProperty(c.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)&&(i.voice=e.parameters.getProperty(c.PropertyId.SpeechServiceConnection_TranslationVoice),i.features="texttospeech");var o={};return o[t.headerName]=t.token,o["X-ConnectionId"]=r,new s.WebsocketConnection(n,i,o,new a.WebsocketMessageFormatter,r)}};t.TranslationConnectionFactory=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=r(1),o=function(){function e(){}return e.implTranslateRecognitionResult=function(e){var t=n.ResultReason.Canceled;switch(e){case i.RecognitionStatus.Success:t=n.ResultReason.RecognizedSpeech;break;case i.RecognitionStatus.NoMatch:case i.RecognitionStatus.InitialSilenceTimeout:case i.RecognitionStatus.BabbleTimeout:case i.RecognitionStatus.EndOfDictation:t=n.ResultReason.NoMatch;break;case i.RecognitionStatus.Error:default:t=n.ResultReason.Canceled}return t},e.implTranslateCancelResult=function(e){var t=n.CancellationReason.EndOfStream;switch(e){case i.RecognitionStatus.Success:case i.RecognitionStatus.EndOfDictation:case i.RecognitionStatus.NoMatch:t=n.CancellationReason.EndOfStream;break;case i.RecognitionStatus.InitialSilenceTimeout:case i.RecognitionStatus.BabbleTimeout:case i.RecognitionStatus.Error:default:t=n.CancellationReason.Error}return t},e}();t.EnumTranslation=o},function(e,t,r){"use strict";var n,i;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.SynthesisStatus||(t.SynthesisStatus={}))[n.Success=0]="Success",n[n.SynthesisEnd=1]="SynthesisEnd",n[n.Error=2]="Error",(i=t.RecognitionStatus||(t.RecognitionStatus={}))[i.Success=0]="Success",i[i.NoMatch=1]="NoMatch",i[i.InitialSilenceTimeout=2]="InitialSilenceTimeout",i[i.BabbleTimeout=3]="BabbleTimeout",i[i.Error=4]="Error",i[i.EndOfDictation=5]="EndOfDictation"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),i=function(){function t(e){this.privSynthesisEnd=JSON.parse(e),this.privSynthesisEnd.SynthesisStatus=n.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]}return t.fromJSON=function(e){return new t(e)},Object.defineProperty(t.prototype,"SynthesisStatus",{get:function(){return this.privSynthesisEnd.SynthesisStatus},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"FailureReason",{get:function(){return this.privSynthesisEnd.FailureReason},enumerable:!0,configurable:!0}),t}();t.TranslationSynthesisEnd=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(9),i=function(){function t(e){this.privTranslationHypothesis=JSON.parse(e),this.privTranslationHypothesis.Translation.TranslationStatus=n.TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus]}return t.fromJSON=function(e){return new t(e)},Object.defineProperty(t.prototype,"Duration",{get:function(){return this.privTranslationHypothesis.Duration},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Offset",{get:function(){return this.privTranslationHypothesis.Offset},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Text",{get:function(){return this.privTranslationHypothesis.Text},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Translation",{get:function(){return this.privTranslationHypothesis.Translation},enumerable:!0,configurable:!0}),t}();t.TranslationHypothesis=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),i=r(9),o=function(){function t(e){this.privTranslationPhrase=JSON.parse(e),this.privTranslationPhrase.RecognitionStatus=n.RecognitionStatus[this.privTranslationPhrase.RecognitionStatus],void 0!==this.privTranslationPhrase.Translation&&(this.privTranslationPhrase.Translation.TranslationStatus=i.TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus])}return t.fromJSON=function(e){return new t(e)},Object.defineProperty(t.prototype,"RecognitionStatus",{get:function(){return this.privTranslationPhrase.RecognitionStatus},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Offset",{get:function(){return this.privTranslationPhrase.Offset},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Duration",{get:function(){return this.privTranslationPhrase.Duration},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Text",{get:function(){return this.privTranslationPhrase.Text},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Translation",{get:function(){return this.privTranslationPhrase.Translation},enumerable:!0,configurable:!0}),t}();t.TranslationPhrase=o},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var h=r(2),g=r(0),y=r(1),o=function(s){function e(e,t,r,n,i){var o=s.call(this,e,t,r,n,i)||this;return o.privTranslationRecognizer=i,o}return i(e,s),e.prototype.processTypeSpecificMessages=function(e,t,r){var n=new g.PropertyCollection;switch(e.messageType===h.MessageType.Text&&n.setProperty(g.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"translation.hypothesis":var i=this.fireEventForResult(y.TranslationHypothesis.fromJSON(e.textBody),n);if(this.privTranslationRecognizer.recognizing)try{this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,i)}catch(e){}break;case"translation.phrase":this.privRecognizerConfig.isContinuousRecognition&&this.sendTelemetryData();var o=y.TranslationPhrase.fromJSON(e.textBody);if(o.RecognitionStatus===y.RecognitionStatus.Success){this.privRequestSession.onServiceRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration);var s=this.fireEventForResult(o,n);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,s)}catch(e){}if(t){try{t(s.result)}catch(e){r&&r(e)}r=t=void 0}break}var c=y.EnumTranslation.implTranslateRecognitionResult(o.RecognitionStatus),a=new g.TranslationRecognitionResult(void 0,this.privRequestSession.requestId,c,o.Text,o.Duration,o.Offset,void 0,e.textBody,n);if(c===g.ResultReason.Canceled){var u=y.EnumTranslation.implTranslateCancelResult(o.RecognitionStatus),p=new g.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId,u,null,u===g.CancellationReason.Error?g.CancellationErrorCode.ServiceError:g.CancellationErrorCode.NoError,a);if(this.privTranslationRecognizer.canceled)try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,p)}catch(e){}}else if(!this.privRequestSession.isSpeechEnded||c!==g.ResultReason.NoMatch||o.RecognitionStatus===y.RecognitionStatus.InitialSilenceTimeout){p=new g.TranslationRecognitionEventArgs(a,0,this.privRequestSession.sessionId);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,p)}catch(e){}}if(t){try{t(a)}catch(e){r&&r(e)}r=t=void 0}break;case"translation.synthesis":this.sendSynthesisAudio(e.binaryBody,this.privRequestSession.sessionId);break;case"translation.synthesis.end":var f=y.TranslationSynthesisEnd.fromJSON(e.textBody);switch(f.SynthesisStatus){case y.SynthesisStatus.Error:if(this.privTranslationRecognizer.synthesizing){var v=new g.TranslationSynthesisResult(g.ResultReason.Canceled,void 0),l=new g.TranslationSynthesisEventArgs(v,this.privRequestSession.sessionId);try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,l)}catch(e){}}if(this.privTranslationRecognizer.canceled){var d=new g.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId,g.CancellationReason.Error,f.FailureReason,g.CancellationErrorCode.ServiceError,null);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,d)}catch(e){}}break;case y.SynthesisStatus.Success:this.sendSynthesisAudio(void 0,this.privRequestSession.sessionId)}}},e.prototype.cancelRecognition=function(e,t,r,n,i,o){if(this.privTranslationRecognizer.canceled){var s=new g.PropertyCollection;s.setProperty(y.CancellationErrorCodePropertyName,g.CancellationErrorCode[n]);var c=new g.TranslationRecognitionCanceledEventArgs(e,r,i,n,void 0);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,c)}catch(e){}if(o){var a=new g.TranslationRecognitionResult(void 0,t,g.ResultReason.Canceled,void 0,void 0,void 0,i,void 0,s);try{o(a)}catch(e){}}}},e.prototype.fireEventForResult=function(e,t){var r,n;if(void 0!==e.Translation.Translations){r=new g.Translations;for(var i=0,o=e.Translation.Translations;i<o.length;i++){var s=o[i];r.set(s.Language,s.Text)}}n=e instanceof y.TranslationPhrase?e.Translation.TranslationStatus===h.TranslationStatus.Success?g.ResultReason.TranslatedSpeech:g.ResultReason.RecognizedSpeech:g.ResultReason.TranslatingSpeech;var c=e.Offset+this.privRequestSession.currentTurnAudioOffset,a=new g.TranslationRecognitionResult(r,this.privRequestSession.requestId,n,e.Text,e.Duration,c,e.Translation.FailureReason,JSON.stringify(e),t);return new g.TranslationRecognitionEventArgs(a,c,this.privRequestSession.sessionId)},e.prototype.sendSynthesisAudio=function(e,t){var r=void 0===e?g.ResultReason.SynthesizingAudioCompleted:g.ResultReason.SynthesizingAudio,n=new g.TranslationSynthesisResult(r,e),i=new g.TranslationSynthesisEventArgs(n,t);if(this.privTranslationRecognizer.synthesizing)try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,i)}catch(e){}},e}(y.ServiceRecognizerBase);t.TranslationServiceRecognizer=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function t(e){this.privSpeechStartDetected=JSON.parse(e)}return t.fromJSON=function(e){return new t(e)},Object.defineProperty(t.prototype,"Offset",{get:function(){return this.privSpeechStartDetected.Offset},enumerable:!0,configurable:!0}),t}();t.SpeechDetected=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function t(e){this.privSpeechHypothesis=JSON.parse(e)}return t.fromJSON=function(e){return new t(e)},Object.defineProperty(t.prototype,"Text",{get:function(){return this.privSpeechHypothesis.Text},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Offset",{get:function(){return this.privSpeechHypothesis.Offset},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Duration",{get:function(){return this.privSpeechHypothesis.Duration},enumerable:!0,configurable:!0}),t}();t.SpeechHypothesis=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var l=r(0),d=r(1),o=function(s){function e(e,t,r,n,i){var o=s.call(this,e,t,r,n,i)||this;return o.privSpeechRecognizer=i,o}return i(e,s),e.prototype.processTypeSpecificMessages=function(e,t,r){var n,i=new l.PropertyCollection;switch(i.setProperty(l.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.hypothesis":var o=d.SpeechHypothesis.fromJSON(e.textBody);n=new l.SpeechRecognitionResult(this.privRequestSession.requestId,l.ResultReason.RecognizingSpeech,o.Text,o.Duration,o.Offset+this.privRequestSession.currentTurnAudioOffset,void 0,e.textBody,i);var s=new l.SpeechRecognitionEventArgs(n,o.Duration,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognizing)try{this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer,s)}catch(e){}break;case"speech.phrase":this.sendTelemetryData();var c=d.SimpleSpeechPhrase.fromJSON(e.textBody),a=d.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus);if(this.privRequestSession.onServiceRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),l.ResultReason.Canceled===a){var u=d.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus);if(n=new l.SpeechRecognitionResult(this.privRequestSession.requestId,a,void 0,void 0,void 0,void 0,e.textBody,i),this.privSpeechRecognizer.canceled){var p=new l.SpeechRecognitionCanceledEventArgs(u,void 0,u===l.CancellationReason.Error?l.CancellationErrorCode.ServiceError:l.CancellationErrorCode.NoError,void 0,this.privRequestSession.sessionId);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,p)}catch(e){}}}else if(!this.privRequestSession.isSpeechEnded||a!==l.ResultReason.NoMatch||c.RecognitionStatus===d.RecognitionStatus.InitialSilenceTimeout){if(this.privRecognizerConfig.parameters.getProperty(d.OutputFormatPropertyName)===l.OutputFormat[l.OutputFormat.Simple])n=new l.SpeechRecognitionResult(this.privRequestSession.requestId,a,c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,void 0,e.textBody,i);else{var f=d.DetailedSpeechPhrase.fromJSON(e.textBody);n=new l.SpeechRecognitionResult(this.privRequestSession.requestId,a,f.RecognitionStatus===d.RecognitionStatus.Success?f.NBest[0].Display:void 0,f.Duration,f.Offset+this.privRequestSession.currentTurnAudioOffset,void 0,e.textBody,i)}var v=new l.SpeechRecognitionEventArgs(n,n.offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognized)try{this.privSpeechRecognizer.recognized(this.privSpeechRecognizer,v)}catch(e){}}if(t){try{t(n)}catch(e){r&&r(e)}r=t=void 0}}},e.prototype.cancelRecognition=function(e,t,r,n,i,o){var s=new l.PropertyCollection;if(s.setProperty(d.CancellationErrorCodePropertyName,l.CancellationErrorCode[n]),this.privSpeechRecognizer.canceled){var c=new l.SpeechRecognitionCanceledEventArgs(r,i,n,void 0,e);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,c)}catch(e){}}if(o){var a=new l.SpeechRecognitionResult(t,l.ResultReason.Canceled,void 0,void 0,void 0,i,void 0,s);try{o(a)}catch(e){}}},e}(d.ServiceRecognizerBase);t.SpeechServiceRecognizer=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),i=function(){function t(e){this.privDetailedSpeechPhrase=JSON.parse(e),this.privDetailedSpeechPhrase.RecognitionStatus=n.RecognitionStatus[this.privDetailedSpeechPhrase.RecognitionStatus]}return t.fromJSON=function(e){return new t(e)},Object.defineProperty(t.prototype,"RecognitionStatus",{get:function(){return this.privDetailedSpeechPhrase.RecognitionStatus},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"NBest",{get:function(){return this.privDetailedSpeechPhrase.NBest},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Duration",{get:function(){return this.privDetailedSpeechPhrase.Duration},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Offset",{get:function(){return this.privDetailedSpeechPhrase.Offset},enumerable:!0,configurable:!0}),t}();t.DetailedSpeechPhrase=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),i=function(){function t(e){this.privSimpleSpeechPhrase=JSON.parse(e),this.privSimpleSpeechPhrase.RecognitionStatus=n.RecognitionStatus[this.privSimpleSpeechPhrase.RecognitionStatus]}return t.fromJSON=function(e){return new t(e)},Object.defineProperty(t.prototype,"RecognitionStatus",{get:function(){return this.privSimpleSpeechPhrase.RecognitionStatus},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"DisplayText",{get:function(){return this.privSimpleSpeechPhrase.DisplayText},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Offset",{get:function(){return this.privSimpleSpeechPhrase.Offset},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Duration",{get:function(){return this.privSimpleSpeechPhrase.Duration},enumerable:!0,configurable:!0}),t}();t.SimpleSpeechPhrase=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t){this.modelImpl=e,this.intentName=t};t.AddedLmIntent=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var d=r(2),h=r(0),g=r(1),o=function(s){function e(e,t,r,n,i){var o=s.call(this,e,t,r,n,i)||this;return o.privIntentRecognizer=i,o.privIntentDataSent=!1,o}return i(e,s),e.prototype.setIntents=function(e,t){this.privAddedLmIntents=e,this.privUmbrellaIntent=t,this.privIntentDataSent=!0},e.prototype.processTypeSpecificMessages=function(e,t,r){var n,i,o=this,s=new h.PropertyCollection;switch(e.messageType===d.MessageType.Text&&s.setProperty(h.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.hypothesis":var c=g.SpeechHypothesis.fromJSON(e.textBody);if(n=new h.IntentRecognitionResult(void 0,this.privRequestSession.requestId,h.ResultReason.RecognizingIntent,c.Text,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,void 0,e.textBody,s),i=new h.IntentRecognitionEventArgs(n,c.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId),this.privIntentRecognizer.recognizing)try{this.privIntentRecognizer.recognizing(this.privIntentRecognizer,i)}catch(e){}break;case"speech.phrase":var a=g.SimpleSpeechPhrase.fromJSON(e.textBody);n=new h.IntentRecognitionResult(void 0,this.privRequestSession.requestId,g.EnumTranslation.implTranslateRecognitionResult(a.RecognitionStatus),a.DisplayText,a.Duration,a.Offset+this.privRequestSession.currentTurnAudioOffset,void 0,e.textBody,s),i=new h.IntentRecognitionEventArgs(n,n.offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);!1===this.privIntentDataSent||h.ResultReason.NoMatch===i.result.reason?function(){if(o.privRecognizerConfig.isContinuousRecognition&&o.sendTelemetryData(),o.privIntentRecognizer.recognized)try{o.privIntentRecognizer.recognized(o.privIntentRecognizer,i)}catch(e){}if(t){try{t(n)}catch(e){r&&r(e)}r=t=void 0}}():this.privPendingIntentArgs=i;break;case"response":if(this.privRecognizerConfig.isContinuousRecognition&&this.sendTelemetryData(),i=this.privPendingIntentArgs,(this.privPendingIntentArgs=void 0)===i){if(""===e.textBody)return;i=new h.IntentRecognitionEventArgs(new h.IntentRecognitionResult,0,this.privRequestSession.sessionId)}var u=g.IntentResponse.fromJSON(e.textBody),p=this.privAddedLmIntents[u.topScoringIntent.intent];if(void 0!==this.privUmbrellaIntent&&(p=this.privUmbrellaIntent),null!==u&&void 0!==p){var f=void 0===p.intentName?u.topScoringIntent.intent:p.intentName,v=i.result.reason;void 0!==f&&(v=h.ResultReason.RecognizedIntent);var l=void 0!==i.result.properties?i.result.properties:new h.PropertyCollection;l.setProperty(h.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,e.textBody),i=new h.IntentRecognitionEventArgs(new h.IntentRecognitionResult(f,i.result.resultId,v,i.result.text,i.result.duration,i.result.offset+this.privRequestSession.currentTurnAudioOffset,i.result.errorDetails,i.result.json,l),i.offset+this.privRequestSession.currentTurnAudioOffset,i.sessionId)}if(this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,i)}catch(e){}if(t){try{t(i.result)}catch(e){r&&r(e)}r=t=void 0}}},e.prototype.cancelRecognition=function(e,t,r,n,i,o){if(this.privIntentRecognizer.canceled){var s=new h.PropertyCollection;s.setProperty(g.CancellationErrorCodePropertyName,h.CancellationErrorCode[n]);var c=new h.IntentRecognitionCanceledEventArgs(r,i,n,void 0,void 0,e);try{this.privIntentRecognizer.canceled(this.privIntentRecognizer,c)}catch(e){}if(o){var a=new h.IntentRecognitionResult(void 0,t,h.ResultReason.Canceled,void 0,void 0,void 0,i,void 0,s);try{o(a)}catch(e){}}}},e}(g.ServiceRecognizerBase);t.IntentServiceRecognizer=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function t(e){this.privIntentResponse=JSON.parse(e)}return t.fromJSON=function(e){return new t(e)},Object.defineProperty(t.prototype,"query",{get:function(){return this.privIntentResponse.query},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topScoringIntent",{get:function(){return this.privIntentResponse.topScoringIntent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"entities",{get:function(){return this.privIntentResponse.entities},enumerable:!0,configurable:!0}),t}();t.IntentResponse=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),o=r(11),n=r(82),s=function(){function e(e){var n=this;this.privIsDisposed=!1,this.privDetachables=new Array,this.privIsAudioNodeDetached=!1,this.privIsRecognizing=!1,this.privIsSpeechEnded=!1,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.onAudioSourceAttachCompleted=function(e,t,r){n.privAudioNode=e,t?n.onComplete():n.onEvent(new o.ListeningStartedEvent(n.privRequestId,n.privSessionId,n.privAudioSourceId,n.privAudioNodeId))},this.onPreConnectionStart=function(e,t){n.privAuthFetchEventId=e,n.privSessionId=t,n.onEvent(new o.ConnectingToServiceEvent(n.privRequestId,n.privAuthFetchEventId,n.privSessionId))},this.onAuthCompleted=function(e,t){e&&n.onComplete()},this.onConnectionEstablishCompleted=function(e,t){if(200===e)return n.onEvent(new o.RecognitionStartedEvent(n.requestId,n.privAudioSourceId,n.privAudioNodeId,n.privAuthFetchEventId,n.privSessionId)),n.privAudioNode&&n.privAudioNode.replay(),void(n.privTurnStartAudioOffset=n.privLastRecoOffset);403===e&&n.onComplete()},this.onServiceTurnEndResponse=function(e){!e||n.isSpeechEnded?n.onComplete():(n.privTurnStartAudioOffset=n.privLastRecoOffset,n.privRequestId=i.createNoDashGuid(),n.privAudioNode.replay())},this.dispose=function(e){if(!n.privIsDisposed){n.privIsDisposed=!0;for(var t=0,r=n.privDetachables;t<r.length;t++){r[t].detach()}n.privServiceTelemetryListener.dispose()}},this.getTelemetry=function(){return n.privServiceTelemetryListener.getTelemetry()},this.onEvent=function(e){n.privServiceTelemetryListener&&n.privServiceTelemetryListener.onEvent(e),i.Events.instance.onEvent(e)},this.onComplete=function(){n.privIsRecognizing&&(n.privIsRecognizing=!1,n.detachAudioNode())},this.detachAudioNode=function(){n.privIsAudioNodeDetached||(n.privIsAudioNodeDetached=!0,n.privAudioNode&&n.privAudioNode.detach())},this.privAudioSourceId=e,this.privRequestId=i.createNoDashGuid(),this.privAudioNodeId=i.createNoDashGuid(),this.privRequestCompletionDeferral=new i.Deferred}return Object.defineProperty(e.prototype,"sessionId",{get:function(){return this.privSessionId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"requestId",{get:function(){return this.privRequestId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"completionPromise",{get:function(){return this.privRequestCompletionDeferral.promise()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSpeechEnded",{get:function(){return this.privIsSpeechEnded},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRecognizing",{get:function(){return this.privIsRecognizing},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTurnAudioOffset",{get:function(){return this.privTurnStartAudioOffset},enumerable:!0,configurable:!0}),e.prototype.listenForServiceTelemetry=function(e){this.privServiceTelemetryListener&&this.privDetachables.push(e.attachListener(this.privServiceTelemetryListener))},e.prototype.startNewRecognition=function(){this.privIsRecognizing=!0,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privRequestId=i.createNoDashGuid(),this.privServiceTelemetryListener=new n.ServiceTelemetryListener(this.privRequestId,this.privAudioSourceId,this.privAudioNodeId),this.onEvent(new o.RecognitionTriggeredEvent(this.requestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))},e.prototype.onServiceRecognized=function(e){this.privLastRecoOffset=e,this.privAudioNode.shrinkBuffers(e)},e.prototype.onStopRecognizing=function(){this.privIsRecognizing=!1},e.prototype.onSpeechEnded=function(){this.privIsSpeechEnded=!0},e}();t.RequestSession=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),o=r(11),n=function(e,t,r){var n=this;this.privIsDisposed=!1,this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.onEvent=function(e){n.privIsDisposed||(e instanceof o.RecognitionTriggeredEvent&&e.requestId===n.privRequestId&&(n.privListeningTriggerMetric={End:e.eventTime,Name:"ListeningTrigger",Start:e.eventTime}),e instanceof i.AudioStreamNodeAttachingEvent&&e.audioSourceId===n.privAudioSourceId&&e.audioNodeId===n.privAudioNodeId&&(n.privMicStartTime=e.eventTime),e instanceof i.AudioStreamNodeAttachedEvent&&e.audioSourceId===n.privAudioSourceId&&e.audioNodeId===n.privAudioNodeId&&(n.privMicStartTime=e.eventTime),e instanceof i.AudioSourceErrorEvent&&e.audioSourceId===n.privAudioSourceId&&(n.privMicMetric||(n.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:n.privMicStartTime})),e instanceof i.AudioStreamNodeErrorEvent&&e.audioSourceId===n.privAudioSourceId&&e.audioNodeId===n.privAudioNodeId&&(n.privMicMetric||(n.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:n.privMicStartTime})),e instanceof i.AudioStreamNodeDetachedEvent&&e.audioSourceId===n.privAudioSourceId&&e.audioNodeId===n.privAudioNodeId&&(n.privMicMetric||(n.privMicMetric={End:e.eventTime,Name:"Microphone",Start:n.privMicStartTime})),e instanceof o.ConnectingToServiceEvent&&e.requestId===n.privRequestId&&(n.privConnectionId=e.sessionId),e instanceof i.ConnectionStartEvent&&e.connectionId===n.privConnectionId&&(n.privConnectionStartTime=e.eventTime),e instanceof i.ConnectionEstablishedEvent&&e.connectionId===n.privConnectionId&&(n.privConnectionEstablishMetric||(n.privConnectionEstablishMetric={End:e.eventTime,Id:n.privConnectionId,Name:"Connection",Start:n.privConnectionStartTime})),e instanceof i.ConnectionEstablishErrorEvent&&e.connectionId===n.privConnectionId&&(n.privConnectionEstablishMetric||(n.privConnectionEstablishMetric={End:e.eventTime,Error:n.getConnectionError(e.statusCode),Id:n.privConnectionId,Name:"Connection",Start:n.privConnectionStartTime})),e instanceof i.ConnectionMessageReceivedEvent&&e.connectionId===n.privConnectionId&&e.message&&e.message.headers&&e.message.headers.path&&(n.privReceivedMessages[e.message.headers.path]||(n.privReceivedMessages[e.message.headers.path]=new Array),n.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime)))},this.getTelemetry=function(){var e=new Array;n.privListeningTriggerMetric&&e.push(n.privListeningTriggerMetric),n.privMicMetric&&e.push(n.privMicMetric),n.privConnectionEstablishMetric&&e.push(n.privConnectionEstablishMetric);var t={Metrics:e,ReceivedMessages:n.privReceivedMessages},r=JSON.stringify(t);return n.privReceivedMessages={},n.privListeningTriggerMetric=null,n.privMicMetric=null,n.privConnectionEstablishMetric=null,r},this.dispose=function(){n.privIsDisposed=!0},this.getConnectionError=function(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()}},this.privRequestId=e,this.privAudioSourceId=t,this.privAudioNodeId=r,this.privReceivedMessages={}};t.ServiceTelemetryListener=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privContext={},this.privDynamicGrammar=e}return e.prototype.setSection=function(e,t){this.privContext[e]=t},e.prototype.toJSON=function(){var e=this.privDynamicGrammar.generateGrammarObject();return this.setSection("dgi",e),JSON.stringify(this.privContext)},e}();t.SpeechContext=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e.prototype.addPhrase=function(e){this.privPhrases||(this.privPhrases=[]),e instanceof Array?this.privPhrases=this.privPhrases.concat(e):this.privPhrases.push(e)},e.prototype.clearPhrases=function(){this.privPhrases=void 0},e.prototype.addReferenceGrammar=function(e){this.privGrammars||(this.privGrammars=[]),e instanceof Array?this.privGrammars=this.privGrammars.concat(e):this.privGrammars.push(e)},e.prototype.clearGrammars=function(){this.privGrammars=void 0},e.prototype.generateGrammarObject=function(){if(void 0!==this.privGrammars||void 0!==this.privPhrases){var e={};if(e.ReferenceGrammars=this.privGrammars,void 0!==this.privPhrases&&0!==this.privPhrases.length){var n=[];this.privPhrases.forEach(function(e,t,r){n.push({Text:e})}),e.Groups=[{Type:"Generic",Items:n}]}return e}},e}();t.DynamicGrammarBuilder=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=r(4),c=r(0),a=function(e){function t(){return e.call(this)||this}return i(t,e),t.fromSubscription=function(e,t){s.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),s.Contracts.throwIfNullOrWhitespace(t,"region");var r=new u;return r.properties.setProperty(c.PropertyId.SpeechServiceConnection_Key,e),r.properties.setProperty(c.PropertyId.SpeechServiceConnection_Region,t),r},t.fromAuthorizationToken=function(e,t){s.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),s.Contracts.throwIfNullOrWhitespace(t,"region");var r=new u;return r.properties.setProperty(c.PropertyId.SpeechServiceAuthorization_Token,e),r.properties.setProperty(c.PropertyId.SpeechServiceConnection_Region,t),r},t.fromEndpoint=function(e,t){s.Contracts.throwIfNull(e,"endpoint"),s.Contracts.throwIfNull(t,"subscriptionKey");var r=new u;return r.properties.setProperty(c.PropertyId.SpeechServiceConnection_Endpoint,e.href),r.properties.setProperty(c.PropertyId.SpeechServiceConnection_Key,t),r},t}(c.SpeechConfig),u=function(t){function e(){var e=t.call(this)||this;return e.privSpeechProperties=new c.PropertyCollection,e.outputFormat=c.OutputFormat.Simple,e}return i(e,t),Object.defineProperty(e.prototype,"authorizationToken",{set:function(e){s.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(c.PropertyId.SpeechServiceAuthorization_Token,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speechRecognitionLanguage",{set:function(e){s.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(c.PropertyId.SpeechServiceConnection_RecoLanguage,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"subscriptionKey",{get:function(){return this.privSpeechProperties.getProperty(c.PropertyId[c.PropertyId.SpeechServiceConnection_Key])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outputFormat",{get:function(){return c.OutputFormat[this.privSpeechProperties.getProperty(o.OutputFormatPropertyName,void 0)]},set:function(e){this.privSpeechProperties.setProperty(o.OutputFormatPropertyName,c.OutputFormat[e])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endpointId",{get:function(){return this.privSpeechProperties.getProperty(c.PropertyId.SpeechServiceConnection_EndpointId)},set:function(e){this.privSpeechProperties.setProperty(c.PropertyId.SpeechServiceConnection_Endpoint,e)},enumerable:!0,configurable:!0}),e.prototype.addTargetLanguage=function(e){s.Contracts.throwIfNullOrWhitespace(e,"value");var t=this.targetLanguages;t.push(e),this.privSpeechProperties.setProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(","))},Object.defineProperty(e.prototype,"targetLanguages",{get:function(){return void 0!==this.privSpeechProperties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)?this.privSpeechProperties.getProperty(c.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","):[]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"voiceName",{get:function(){return this.getProperty(c.PropertyId[c.PropertyId.SpeechServiceConnection_TranslationVoice])},set:function(e){s.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(c.PropertyId.SpeechServiceConnection_TranslationVoice,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"region",{get:function(){return this.privSpeechProperties.getProperty(c.PropertyId.SpeechServiceConnection_Region)},enumerable:!0,configurable:!0}),e.prototype.getProperty=function(e,t){return this.privSpeechProperties.getProperty(e,t)},e.prototype.setProperty=function(e,t){this.privSpeechProperties.setProperty(e,t)},Object.defineProperty(e.prototype,"properties",{get:function(){return this.privSpeechProperties},enumerable:!0,configurable:!0}),e.prototype.close=function(){},e}(t.SpeechTranslationConfig=a);t.SpeechTranslationConfigImpl=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(){function r(){this.privKeys=[],this.privValues=[]}return r.prototype.getProperty=function(e,t){var r;r="string"==typeof e?e:i.PropertyId[e];for(var n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r)return this.privValues[n];return t},r.prototype.setProperty=function(e,t){var r;r="string"==typeof e?e:i.PropertyId[e];for(var n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r)return void(this.privValues[n]=t);this.privKeys.push(r),this.privValues.push(t)},r.prototype.clone=function(){for(var e=new r,t=0;t<this.privKeys.length;t++)e.privKeys.push(this.privKeys[t]),e.privValues.push(this.privValues[t]);return e},r}();t.PropertyCollection=n},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.PropertyId||(t.PropertyId={}))[n.SpeechServiceConnection_Key=0]="SpeechServiceConnection_Key",n[n.SpeechServiceConnection_Endpoint=1]="SpeechServiceConnection_Endpoint",n[n.SpeechServiceConnection_Region=2]="SpeechServiceConnection_Region",n[n.SpeechServiceAuthorization_Token=3]="SpeechServiceAuthorization_Token",n[n.SpeechServiceAuthorization_Type=4]="SpeechServiceAuthorization_Type",n[n.SpeechServiceConnection_EndpointId=5]="SpeechServiceConnection_EndpointId",n[n.SpeechServiceConnection_TranslationToLanguages=6]="SpeechServiceConnection_TranslationToLanguages",n[n.SpeechServiceConnection_TranslationVoice=7]="SpeechServiceConnection_TranslationVoice",n[n.SpeechServiceConnection_TranslationFeatures=8]="SpeechServiceConnection_TranslationFeatures",n[n.SpeechServiceConnection_IntentRegion=9]="SpeechServiceConnection_IntentRegion",n[n.SpeechServiceConnection_RecoMode=10]="SpeechServiceConnection_RecoMode",n[n.SpeechServiceConnection_RecoLanguage=11]="SpeechServiceConnection_RecoLanguage",n[n.Speech_SessionId=12]="Speech_SessionId",n[n.SpeechServiceResponse_RequestDetailedResultTrueFalse=13]="SpeechServiceResponse_RequestDetailedResultTrueFalse",n[n.SpeechServiceResponse_RequestProfanityFilterTrueFalse=14]="SpeechServiceResponse_RequestProfanityFilterTrueFalse",n[n.SpeechServiceResponse_JsonResult=15]="SpeechServiceResponse_JsonResult",n[n.SpeechServiceResponse_JsonErrorDetails=16]="SpeechServiceResponse_JsonErrorDetails",n[n.CancellationDetails_Reason=17]="CancellationDetails_Reason",n[n.CancellationDetails_ReasonText=18]="CancellationDetails_ReasonText",n[n.CancellationDetails_ReasonDetailedText=19]="CancellationDetails_ReasonDetailedText",n[n.LanguageUnderstandingServiceResponse_JsonResult=20]="LanguageUnderstandingServiceResponse_JsonResult"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var c=r(1),a=r(2),n=r(4),u=r(0),i=function(){function e(e,t,r){this.audioConfig=void 0!==e?e:u.AudioConfig.fromDefaultMicrophoneInput(),this.privDisposed=!1,this.privProperties=t.clone(),this.privConnectionFactory=r,this.implCommonRecognizerSetup()}return e.prototype.close=function(){n.Contracts.throwIfDisposed(this.privDisposed),this.dispose(!0)},Object.defineProperty(e.prototype,"internalData",{get:function(){return this.privReco},enumerable:!0,configurable:!0}),e.prototype.dispose=function(e){this.privDisposed||(e&&this.privReco&&(this.privReco.audioSource.turnOff(),this.privReco.dispose()),this.privDisposed=!0)},Object.defineProperty(e,"telemetryEnabled",{get:function(){return c.ServiceRecognizerBase.telemetryDataEnabled},enumerable:!0,configurable:!0}),e.enableTelemetry=function(e){c.ServiceRecognizerBase.telemetryDataEnabled=e},e.prototype.implCommonRecognizerSetup=function(){var r=this,e="undefined"!=typeof window?"Browser":"Node",t="unknown",n="unknown";"undefined"!=typeof navigator&&(e=e+"/"+navigator.platform,t=navigator.userAgent,n=navigator.appVersion);var i=this.createRecognizerConfig(new c.SpeechServiceConfig(new c.Context(new c.OS(e,t,n)))),o=this.privProperties.getProperty(u.PropertyId.SpeechServiceConnection_Key,void 0),s=o&&""!==o?new c.CognitiveSubscriptionKeyAuthentication(o):new c.CognitiveTokenAuthentication(function(e){var t=r.privProperties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token,void 0);return a.PromiseHelper.fromResult(t)},function(e){var t=r.privProperties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token,void 0);return a.PromiseHelper.fromResult(t)});this.privReco=this.createServiceRecognizer(s,this.privConnectionFactory,this.audioConfig,i)},e.prototype.implRecognizerStart=function(e,t,r){this.privReco.recognize(e,t,r).on(function(e){},function(e){r&&r("Runtime error: "+e)})},e.prototype.implRecognizerStop=function(){this.privReco&&this.privReco.stopRecognizing()},e}();t.Recognizer=i},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var s=r(1),c=r(19),a=r(4),u=r(0),i=function(i){function e(e,t){var r=this,n=e;return a.Contracts.throwIfNull(n,"speechConfig"),a.Contracts.throwIfNullOrWhitespace(n.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage),u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage]),(r=i.call(this,t,n.properties,new c.SpeechConnectionFactory)||this).privDisposedSpeechRecognizer=!1,r}return o(e,i),Object.defineProperty(e.prototype,"endpointId",{get:function(){return a.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer),this.properties.getProperty(u.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authorizationToken",{get:function(){return this.properties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token)},set:function(e){a.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(u.PropertyId.SpeechServiceAuthorization_Token,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speechRecognitionLanguage",{get:function(){return a.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer),this.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outputFormat",{get:function(){return a.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer),this.properties.getProperty(s.OutputFormatPropertyName,u.OutputFormat[u.OutputFormat.Simple])===u.OutputFormat[u.OutputFormat.Simple]?u.OutputFormat.Simple:u.OutputFormat.Detailed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),e.prototype.recognizeOnceAsync=function(t,r){var n=this;try{a.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer),this.implRecognizerStop(),this.implRecognizerStart(s.RecognitionMode.Interactive,function(e){n.implRecognizerStop(),t&&t(e)},function(e){n.implRecognizerStop(),r&&r(e)})}catch(e){if(r)if(e instanceof Error){var i=e;r(i.name+": "+i.message)}else r(e)}},e.prototype.startContinuousRecognitionAsync=function(e,t){try{if(a.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer),this.implRecognizerStop(),this.implRecognizerStart(s.RecognitionMode.Conversation,void 0,void 0),e){try{e()}catch(e){t&&t(e)}e=void 0}}catch(e){if(t)if(e instanceof Error){var r=e;t(r.name+": "+r.message)}else t(e)}},e.prototype.stopContinuousRecognitionAsync=function(e,t){try{if(a.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer),this.implRecognizerStop(),e)try{e()}catch(e){t&&t(e)}}catch(e){if(t)if(e instanceof Error){var r=e;t(r.name+": "+r.message)}else t(e)}},e.prototype.startKeywordRecognitionAsync=function(e,t,r){a.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")},e.prototype.stopKeywordRecognitionAsync=function(e,t){e&&e()},e.prototype.close=function(){a.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer),this.dispose(!0)},e.prototype.dispose=function(e){this.privDisposedSpeechRecognizer||(e&&(this.implRecognizerStop(),this.privDisposedSpeechRecognizer=!0),i.prototype.dispose.call(this,e))},e.prototype.createRecognizerConfig=function(e){return new s.RecognizerConfig(e,this.properties)},e.prototype.createServiceRecognizer=function(e,t,r,n){var i=r;return new s.SpeechServiceRecognizer(e,t,i,n,this)},e}(u.Recognizer);t.SpeechRecognizer=i},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var s=r(1),c=r(4),u=r(0),i=function(i){function e(e,t){var r=this;c.Contracts.throwIfNullOrUndefined(e,"speechConfig");var n=e;return c.Contracts.throwIfNullOrUndefined(n,"speechConfig"),(r=i.call(this,t,n.properties,new s.IntentConnectionFactory)||this).privAddedIntents=[],r.privAddedLmIntents={},r.privDisposedIntentRecognizer=!1,r.privProperties=n.properties,c.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage),u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage]),r}return o(e,i),Object.defineProperty(e.prototype,"speechRecognitionLanguage",{get:function(){return c.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authorizationToken",{get:function(){return this.properties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token)},set:function(e){this.properties.setProperty(u.PropertyId.SpeechServiceAuthorization_Token,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),e.prototype.recognizeOnceAsync=function(t,r){var n=this;try{if(c.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.implRecognizerStop(),0!==Object.keys(this.privAddedLmIntents).length||void 0!==this.privUmbrellaIntent){var e=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",e.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(e.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}this.implRecognizerStart(s.RecognitionMode.Interactive,function(e){n.implRecognizerStop(),t&&t(e)},function(e){n.implRecognizerStop(),r&&r(e)})}catch(e){if(r)if(e instanceof Error){var i=e;r(i.name+": "+i.message)}else r(e)}},e.prototype.startContinuousRecognitionAsync=function(e,t){try{if(c.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.implRecognizerStop(),0!==Object.keys(this.privAddedLmIntents).length){var r=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",r.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(r.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}if(this.implRecognizerStart(s.RecognitionMode.Conversation,void 0,void 0),e){try{e()}catch(e){t&&t(e)}e=void 0}}catch(e){if(t)if(e instanceof Error){var n=e;t(n.name+": "+n.message)}else t(e)}},e.prototype.stopContinuousRecognitionAsync=function(e,t){try{if(c.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.implRecognizerStop(),e)try{e()}catch(e){t&&t(e)}}catch(e){if(t)if(e instanceof Error){var r=e;t(r.name+": "+r.message)}else t(e)}},e.prototype.startKeywordRecognitionAsync=function(e,t,r){c.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")},e.prototype.stopKeywordRecognitionAsync=function(e,t){e&&e()},e.prototype.addIntent=function(e,t){c.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),c.Contracts.throwIfNullOrWhitespace(t,"intentId"),c.Contracts.throwIfNullOrWhitespace(e,"simplePhrase"),this.privAddedIntents.push([t,e])},e.prototype.addIntentWithLanguageModel=function(e,t,r){c.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),c.Contracts.throwIfNullOrWhitespace(e,"intentId"),c.Contracts.throwIfNull(t,"model");var n=t;c.Contracts.throwIfNullOrWhitespace(n.appId,"model.appId"),this.privAddedLmIntents[e]=new s.AddedLmIntent(n,r)},e.prototype.addAllIntents=function(e,t){c.Contracts.throwIfNull(e,"model");var r=e;c.Contracts.throwIfNullOrWhitespace(r.appId,"model.appId"),this.privUmbrellaIntent=new s.AddedLmIntent(r,t)},e.prototype.close=function(){c.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.dispose(!0)},e.prototype.createRecognizerConfig=function(e){return new s.RecognizerConfig(e,this.properties)},e.prototype.createServiceRecognizer=function(e,t,r,n){var i=r;return new s.IntentServiceRecognizer(e,t,i,n,this)},e.prototype.dispose=function(e){this.privDisposedIntentRecognizer||e&&(this.privDisposedIntentRecognizer=!0,i.prototype.dispose.call(this,e))},e.prototype.buildSpeechContext=function(){var e,t,r,n=[];void 0!==this.privUmbrellaIntent&&(e=this.privUmbrellaIntent.modelImpl.appId,t=this.privUmbrellaIntent.modelImpl.region,r=this.privUmbrellaIntent.modelImpl.subscriptionKey);for(var i=0,o=Object.keys(this.privAddedLmIntents);i<o.length;i++){var s=o[i],c=this.privAddedLmIntents[s];if(void 0===e)e=c.modelImpl.appId;else if(e!==c.modelImpl.appId)throw new Error("Intents must all be from the same LUIS model");if(void 0===t)t=c.modelImpl.region;else if(t!==c.modelImpl.region)throw new Error("Intents must all be from the same LUIS model in a single region");if(void 0===r)r=c.modelImpl.subscriptionKey;else if(r!==c.modelImpl.subscriptionKey)throw new Error("Intents must all use the same subscription key");var a="luis/"+e+"-PRODUCTION#"+s;n.push(a)}return{Intent:{id:e,key:void 0===r?this.privProperties.getProperty(u.PropertyId[u.PropertyId.SpeechServiceConnection_Key]):r,provider:"LUIS"},ReferenceGrammars:void 0===this.privUmbrellaIntent?n:["luis/"+e+"-PRODUCTION"]}},e}(u.Recognizer);t.IntentRecognizer=i},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var s=r(1),c=r(4),a=r(0),i=function(i){function e(e,t){var r=this,n=e;return c.Contracts.throwIfNull(n,"speechConfig"),(r=i.call(this,t,n.properties,new s.TranslationConnectionFactory)||this).privDisposedTranslationRecognizer=!1,r.privProperties=n.properties.clone(),void 0!==r.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)&&c.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationVoice),a.PropertyId[a.PropertyId.SpeechServiceConnection_TranslationVoice]),c.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages),a.PropertyId[a.PropertyId.SpeechServiceConnection_TranslationToLanguages]),c.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage),a.PropertyId[a.PropertyId.SpeechServiceConnection_RecoLanguage]),r}return o(e,i),Object.defineProperty(e.prototype,"speechRecognitionLanguage",{get:function(){return c.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetLanguages",{get:function(){return c.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"voiceName",{get:function(){return c.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authorizationToken",{get:function(){return this.properties.getProperty(a.PropertyId.SpeechServiceAuthorization_Token)},set:function(e){this.properties.setProperty(a.PropertyId.SpeechServiceAuthorization_Token,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),e.prototype.recognizeOnceAsync=function(t,r){var n=this;try{c.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.implRecognizerStop(),this.implRecognizerStart(s.RecognitionMode.Conversation,function(e){n.implRecognizerStop(),t&&t(e)},function(e){n.implRecognizerStop(),r&&r(e)})}catch(e){if(r)if(e instanceof Error){var i=e;r(i.name+": "+i.message)}else r(e)}},e.prototype.startContinuousRecognitionAsync=function(e,t){try{if(c.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.implRecognizerStop(),this.implRecognizerStart(s.RecognitionMode.Conversation,void 0,void 0),e){try{e()}catch(e){t&&t(e)}e=void 0}}catch(e){if(t)if(e instanceof Error){var r=e;t(r.name+": "+r.message)}else t(e)}},e.prototype.stopContinuousRecognitionAsync=function(e,t){try{if(c.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.implRecognizerStop(),e)try{e()}catch(e){t&&t(e)}}catch(e){if(t)if(e instanceof Error){var r=e;t(r.name+": "+r.message)}else t(e)}},e.prototype.close=function(){c.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.dispose(!0)},e.prototype.dispose=function(e){this.privDisposedTranslationRecognizer||e&&(this.implRecognizerStop(),this.privDisposedTranslationRecognizer=!0,i.prototype.dispose.call(this,e))},e.prototype.createRecognizerConfig=function(e){return new s.RecognizerConfig(e,this.properties)},e.prototype.createServiceRecognizer=function(e,t,r,n){var i=r;return new s.TranslationServiceRecognizer(e,t,i,n,this)},e}(a.Recognizer);t.TranslationRecognizer=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=function(){function e(){this.privMap=new n.PropertyCollection}return e.prototype.get=function(e,t){return this.privMap.getProperty(e,t)},e.prototype.set=function(e,t){this.privMap.setProperty(e,t)},e}();t.Translations=i},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.NoMatchReason||(t.NoMatchReason={}))[n.NotRecognized=0]="NotRecognized",n[n.InitialSilenceTimeout=1]="InitialSilenceTimeout",n[n.InitialBabbleTimeout=2]="InitialBabbleTimeout"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(1),o=r(0),n=function(){function n(e){this.privReason=e}return n.fromResult=function(e){var t=i.SimpleSpeechPhrase.fromJSON(e.json),r=o.NoMatchReason.NotRecognized;switch(t.RecognitionStatus){case i.RecognitionStatus.BabbleTimeout:r=o.NoMatchReason.InitialBabbleTimeout;break;case i.RecognitionStatus.InitialSilenceTimeout:r=o.NoMatchReason.InitialSilenceTimeout;break;default:r=o.NoMatchReason.NotRecognized}return new n(r)},Object.defineProperty(n.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),n}();t.NoMatchDetails=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,r,n,i){this.privCancelReason=t,this.privErrorDetails=r,this.privResult=i,this.privSessionId=e,this.privErrorCode=n}return Object.defineProperty(e.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sessionId",{get:function(){return this.privSessionId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privCancelReason},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorCode",{get:function(){return this.privErrorCode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorDetails",{get:function(){return this.privErrorDetails},enumerable:!0,configurable:!0}),e}();t.TranslationRecognitionCanceledEventArgs=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(c){function e(e,t,r,n,i,o){var s=c.call(this,n,i,o)||this;return s.privReason=e,s.privErrorDetails=t,s.privErrorCode=r,s}return i(e,c),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorCode",{get:function(){return this.privErrorCode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorDetails",{get:function(){return this.privErrorDetails},enumerable:!0,configurable:!0}),e}(r(0).IntentRecognitionEventArgs);t.IntentRecognitionCanceledEventArgs=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=r(0),n=function(){function i(e,t,r){this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}return i.fromResult=function(e){var t=s.CancellationReason.Error,r=s.CancellationErrorCode.NoError;if(e.json){var n=o.SimpleSpeechPhrase.fromJSON(e.json);t=o.EnumTranslation.implTranslateCancelResult(n.RecognitionStatus)}return e.properties&&(r=s.CancellationErrorCode[e.properties.getProperty(o.CancellationErrorCodePropertyName,s.CancellationErrorCode[s.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)},Object.defineProperty(i.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"errorDetails",{get:function(){return this.privErrorDetails},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"ErrorCode",{get:function(){return this.privErrorCode},enumerable:!0,configurable:!0}),i}();t.CancellationDetails=n},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.CancellationErrorCode||(t.CancellationErrorCode={}))[n.NoError=0]="NoError",n[n.AuthenticationFailure=1]="AuthenticationFailure",n[n.BadRequestParameters=2]="BadRequestParameters",n[n.TooManyRequests=3]="TooManyRequests",n[n.ConnectionFailure=4]="ConnectionFailure",n[n.ServiceTimeout=5]="ServiceTimeout",n[n.ServiceError=6]="ServiceError",n[n.RuntimeError=7]="RuntimeError"},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(r(0).SessionEventArgs);t.ConnectionEventArgs=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(){function n(){}return n.fromRecognizer=function(e){var t=e.internalData,r=new n;return r.privServiceRecognizer=t,r.privEventListener=r.privServiceRecognizer.connectionEvents.attach(function(e){"ConnectionEstablishedEvent"===e.name?r.connected&&r.connected(new i.ConnectionEventArgs(e.connectionId)):"ConnectionClosedEvent"===e.name&&r.disconnected&&r.disconnected(new i.ConnectionEventArgs(e.connectionId))}),r},n.prototype.openConnection=function(){this.privServiceRecognizer.connect()},n.prototype.closeConnection=function(){this.privServiceRecognizer.disconnect()},n.prototype.close=function(){},n}();t.Connection=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function t(e){this.privGrammerBuilder=e.dynamicGrammar}return t.fromRecognizer=function(e){return new t(e.internalData)},t.prototype.addPhrase=function(e){this.privGrammerBuilder.addPhrase(e)},t.prototype.addPhrases=function(e){this.privGrammerBuilder.addPhrase(e)},t.prototype.clear=function(){this.privGrammerBuilder.clearPhrases()},t}();t.PhraseListGrammar=n}]);