web-speech-cognitive-services 8.0.0-main.478b2e9 → 8.0.0-main.aa5b13b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- "use strict";(()=>{var VR=Object.create;var Jf=Object.defineProperty;var UR=Object.getOwnPropertyDescriptor;var WR=Object.getOwnPropertyNames;var HR=Object.getPrototypeOf,KR=Object.prototype.hasOwnProperty;var p=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var JR=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of WR(e))!KR.call(i,n)&&n!==t&&Jf(i,n,{get:()=>e[n],enumerable:!(r=UR(e,n))||r.enumerable});return i};var kp=(i,e,t)=>(t=i!=null?VR(HR(i)):{},JR(e||!i||!i.__esModule?Jf(t,"default",{value:i,enumerable:!0}):t,i));var Fp=p(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});Bp.default=gE;var ts,fE=new Uint8Array(16);function gE(){if(!ts&&(ts=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ts))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ts(fE)}});var Cg=p(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.default=void 0;var mE=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;rs.default=mE});var Qi=p(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.default=void 0;var SE=yE(Cg());function yE(i){return i&&i.__esModule?i:{default:i}}function CE(i){return typeof i=="string"&&SE.default.test(i)}var PE=CE;is.default=PE});var Xi=p(Yi=>{"use strict";Object.defineProperty(Yi,"__esModule",{value:!0});Yi.default=void 0;Yi.unsafeStringify=Pg;var RE=EE(Qi());function EE(i){return i&&i.__esModule?i:{default:i}}var de=[];for(let i=0;i<256;++i)de.push((i+256).toString(16).slice(1));function Pg(i,e=0){return de[i[e+0]]+de[i[e+1]]+de[i[e+2]]+de[i[e+3]]+"-"+de[i[e+4]]+de[i[e+5]]+"-"+de[i[e+6]]+de[i[e+7]]+"-"+de[i[e+8]]+de[i[e+9]]+"-"+de[i[e+10]]+de[i[e+11]]+de[i[e+12]]+de[i[e+13]]+de[i[e+14]]+de[i[e+15]]}function IE(i,e=0){let t=Pg(i,e);if(!(0,RE.default)(t))throw TypeError("Stringified UUID is invalid");return t}var wE=IE;Yi.default=wE});var Eg=p(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.default=void 0;var _E=AE(Fp()),TE=Xi();function AE(i){return i&&i.__esModule?i:{default:i}}var Rg,Vp,Up=0,Wp=0;function bE(i,e,t){let r=e&&t||0,n=e||new Array(16);i=i||{};let s=i.node||Rg,o=i.clockseq!==void 0?i.clockseq:Vp;if(s==null||o==null){let v=i.random||(i.rng||_E.default)();s==null&&(s=Rg=[v[0]|1,v[1],v[2],v[3],v[4],v[5]]),o==null&&(o=Vp=(v[6]<<8|v[7])&16383)}let a=i.msecs!==void 0?i.msecs:Date.now(),c=i.nsecs!==void 0?i.nsecs:Wp+1,u=a-Up+(c-Wp)/1e4;if(u<0&&i.clockseq===void 0&&(o=o+1&16383),(u<0||a>Up)&&i.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Up=a,Wp=c,Vp=o,a+=122192928e5;let h=((a&268435455)*1e4+c)%4294967296;n[r++]=h>>>24&255,n[r++]=h>>>16&255,n[r++]=h>>>8&255,n[r++]=h&255;let d=a/4294967296*1e4&268435455;n[r++]=d>>>8&255,n[r++]=d&255,n[r++]=d>>>24&15|16,n[r++]=d>>>16&255,n[r++]=o>>>8|128,n[r++]=o&255;for(let v=0;v<6;++v)n[r+v]=s[v];return e||(0,TE.unsafeStringify)(n)}var OE=bE;ns.default=OE});var Hp=p(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.default=void 0;var ME=DE(Qi());function DE(i){return i&&i.__esModule?i:{default:i}}function kE(i){if(!(0,ME.default)(i))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(i.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(i.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(i.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(i.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(i.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var NE=kE;ss.default=NE});var Kp=p(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.URL=Rr.DNS=void 0;Rr.default=LE;var qE=Xi(),xE=zE(Hp());function zE(i){return i&&i.__esModule?i:{default:i}}function jE(i){i=unescape(encodeURIComponent(i));let e=[];for(let t=0;t<i.length;++t)e.push(i.charCodeAt(t));return e}var Ig="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Rr.DNS=Ig;var wg="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Rr.URL=wg;function LE(i,e,t){function r(n,s,o,a){var c;if(typeof n=="string"&&(n=jE(n)),typeof s=="string"&&(s=(0,xE.default)(s)),((c=s)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+n.length);if(u.set(s),u.set(n,s.length),u=t(u),u[6]=u[6]&15|e,u[8]=u[8]&63|128,o){a=a||0;for(let h=0;h<16;++h)o[a+h]=u[h];return o}return(0,qE.unsafeStringify)(u)}try{r.name=i}catch{}return r.DNS=Ig,r.URL=wg,r}});var Tg=p(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.default=void 0;function BE(i){if(typeof i=="string"){let e=unescape(encodeURIComponent(i));i=new Uint8Array(e.length);for(let t=0;t<e.length;++t)i[t]=e.charCodeAt(t)}return FE(VE(UE(i),i.length*8))}function FE(i){let e=[],t=i.length*32,r="0123456789abcdef";for(let n=0;n<t;n+=8){let s=i[n>>5]>>>n%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);e.push(o)}return e}function _g(i){return(i+64>>>9<<4)+14+1}function VE(i,e){i[e>>5]|=128<<e%32,i[_g(e)-1]=e;let t=1732584193,r=-271733879,n=-1732584194,s=271733878;for(let o=0;o<i.length;o+=16){let a=t,c=r,u=n,h=s;t=Pe(t,r,n,s,i[o],7,-680876936),s=Pe(s,t,r,n,i[o+1],12,-389564586),n=Pe(n,s,t,r,i[o+2],17,606105819),r=Pe(r,n,s,t,i[o+3],22,-1044525330),t=Pe(t,r,n,s,i[o+4],7,-176418897),s=Pe(s,t,r,n,i[o+5],12,1200080426),n=Pe(n,s,t,r,i[o+6],17,-1473231341),r=Pe(r,n,s,t,i[o+7],22,-45705983),t=Pe(t,r,n,s,i[o+8],7,1770035416),s=Pe(s,t,r,n,i[o+9],12,-1958414417),n=Pe(n,s,t,r,i[o+10],17,-42063),r=Pe(r,n,s,t,i[o+11],22,-1990404162),t=Pe(t,r,n,s,i[o+12],7,1804603682),s=Pe(s,t,r,n,i[o+13],12,-40341101),n=Pe(n,s,t,r,i[o+14],17,-1502002290),r=Pe(r,n,s,t,i[o+15],22,1236535329),t=Re(t,r,n,s,i[o+1],5,-165796510),s=Re(s,t,r,n,i[o+6],9,-1069501632),n=Re(n,s,t,r,i[o+11],14,643717713),r=Re(r,n,s,t,i[o],20,-373897302),t=Re(t,r,n,s,i[o+5],5,-701558691),s=Re(s,t,r,n,i[o+10],9,38016083),n=Re(n,s,t,r,i[o+15],14,-660478335),r=Re(r,n,s,t,i[o+4],20,-405537848),t=Re(t,r,n,s,i[o+9],5,568446438),s=Re(s,t,r,n,i[o+14],9,-1019803690),n=Re(n,s,t,r,i[o+3],14,-187363961),r=Re(r,n,s,t,i[o+8],20,1163531501),t=Re(t,r,n,s,i[o+13],5,-1444681467),s=Re(s,t,r,n,i[o+2],9,-51403784),n=Re(n,s,t,r,i[o+7],14,1735328473),r=Re(r,n,s,t,i[o+12],20,-1926607734),t=Ee(t,r,n,s,i[o+5],4,-378558),s=Ee(s,t,r,n,i[o+8],11,-2022574463),n=Ee(n,s,t,r,i[o+11],16,1839030562),r=Ee(r,n,s,t,i[o+14],23,-35309556),t=Ee(t,r,n,s,i[o+1],4,-1530992060),s=Ee(s,t,r,n,i[o+4],11,1272893353),n=Ee(n,s,t,r,i[o+7],16,-155497632),r=Ee(r,n,s,t,i[o+10],23,-1094730640),t=Ee(t,r,n,s,i[o+13],4,681279174),s=Ee(s,t,r,n,i[o],11,-358537222),n=Ee(n,s,t,r,i[o+3],16,-722521979),r=Ee(r,n,s,t,i[o+6],23,76029189),t=Ee(t,r,n,s,i[o+9],4,-640364487),s=Ee(s,t,r,n,i[o+12],11,-421815835),n=Ee(n,s,t,r,i[o+15],16,530742520),r=Ee(r,n,s,t,i[o+2],23,-995338651),t=Ie(t,r,n,s,i[o],6,-198630844),s=Ie(s,t,r,n,i[o+7],10,1126891415),n=Ie(n,s,t,r,i[o+14],15,-1416354905),r=Ie(r,n,s,t,i[o+5],21,-57434055),t=Ie(t,r,n,s,i[o+12],6,1700485571),s=Ie(s,t,r,n,i[o+3],10,-1894986606),n=Ie(n,s,t,r,i[o+10],15,-1051523),r=Ie(r,n,s,t,i[o+1],21,-2054922799),t=Ie(t,r,n,s,i[o+8],6,1873313359),s=Ie(s,t,r,n,i[o+15],10,-30611744),n=Ie(n,s,t,r,i[o+6],15,-1560198380),r=Ie(r,n,s,t,i[o+13],21,1309151649),t=Ie(t,r,n,s,i[o+4],6,-145523070),s=Ie(s,t,r,n,i[o+11],10,-1120210379),n=Ie(n,s,t,r,i[o+2],15,718787259),r=Ie(r,n,s,t,i[o+9],21,-343485551),t=er(t,a),r=er(r,c),n=er(n,u),s=er(s,h)}return[t,r,n,s]}function UE(i){if(i.length===0)return[];let e=i.length*8,t=new Uint32Array(_g(e));for(let r=0;r<e;r+=8)t[r>>5]|=(i[r/8]&255)<<r%32;return t}function er(i,e){let t=(i&65535)+(e&65535);return(i>>16)+(e>>16)+(t>>16)<<16|t&65535}function WE(i,e){return i<<e|i>>>32-e}function os(i,e,t,r,n,s){return er(WE(er(er(e,i),er(r,s)),n),t)}function Pe(i,e,t,r,n,s,o){return os(e&t|~e&r,i,e,n,s,o)}function Re(i,e,t,r,n,s,o){return os(e&r|t&~r,i,e,n,s,o)}function Ee(i,e,t,r,n,s,o){return os(e^t^r,i,e,n,s,o)}function Ie(i,e,t,r,n,s,o){return os(t^(e|~r),i,e,n,s,o)}var HE=BE;as.default=HE});var bg=p(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.default=void 0;var KE=Ag(Kp()),JE=Ag(Tg());function Ag(i){return i&&i.__esModule?i:{default:i}}var GE=(0,KE.default)("v3",48,JE.default),$E=GE;cs.default=$E});var Og=p(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.default=void 0;var QE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),YE={randomUUID:QE};ps.default=YE});var kg=p(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.default=void 0;var Mg=Dg(Og()),XE=Dg(Fp()),ZE=Xi();function Dg(i){return i&&i.__esModule?i:{default:i}}function eI(i,e,t){if(Mg.default.randomUUID&&!e&&!i)return Mg.default.randomUUID();i=i||{};let r=i.random||(i.rng||XE.default)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=r[n];return e}return(0,ZE.unsafeStringify)(r)}var tI=eI;us.default=tI});var Ng=p(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.default=void 0;function rI(i,e,t,r){switch(i){case 0:return e&t^~e&r;case 1:return e^t^r;case 2:return e&t^e&r^t&r;case 3:return e^t^r}}function Jp(i,e){return i<<e|i>>>32-e}function iI(i){let e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof i=="string"){let o=unescape(encodeURIComponent(i));i=[];for(let a=0;a<o.length;++a)i.push(o.charCodeAt(a))}else Array.isArray(i)||(i=Array.prototype.slice.call(i));i.push(128);let r=i.length/4+2,n=Math.ceil(r/16),s=new Array(n);for(let o=0;o<n;++o){let a=new Uint32Array(16);for(let c=0;c<16;++c)a[c]=i[o*64+c*4]<<24|i[o*64+c*4+1]<<16|i[o*64+c*4+2]<<8|i[o*64+c*4+3];s[o]=a}s[n-1][14]=(i.length-1)*8/Math.pow(2,32),s[n-1][14]=Math.floor(s[n-1][14]),s[n-1][15]=(i.length-1)*8&4294967295;for(let o=0;o<n;++o){let a=new Uint32Array(80);for(let g=0;g<16;++g)a[g]=s[o][g];for(let g=16;g<80;++g)a[g]=Jp(a[g-3]^a[g-8]^a[g-14]^a[g-16],1);let c=t[0],u=t[1],h=t[2],d=t[3],v=t[4];for(let g=0;g<80;++g){let w=Math.floor(g/20),k=Jp(c,5)+rI(w,u,h,d)+v+e[w]+a[g]>>>0;v=d,d=h,h=Jp(u,30)>>>0,u=c,c=k}t[0]=t[0]+c>>>0,t[1]=t[1]+u>>>0,t[2]=t[2]+h>>>0,t[3]=t[3]+d>>>0,t[4]=t[4]+v>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var nI=iI;hs.default=nI});var xg=p(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.default=void 0;var sI=qg(Kp()),oI=qg(Ng());function qg(i){return i&&i.__esModule?i:{default:i}}var aI=(0,sI.default)("v5",80,oI.default),cI=aI;ds.default=cI});var zg=p(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.default=void 0;var pI="00000000-0000-0000-0000-000000000000";ls.default=pI});var jg=p(vs=>{"use strict";Object.defineProperty(vs,"__esModule",{value:!0});vs.default=void 0;var uI=hI(Qi());function hI(i){return i&&i.__esModule?i:{default:i}}function dI(i){if(!(0,uI.default)(i))throw TypeError("Invalid UUID");return parseInt(i.slice(14,15),16)}var lI=dI;vs.default=lI});var Lg=p(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});Object.defineProperty(ut,"NIL",{enumerable:!0,get:function(){return SI.default}});Object.defineProperty(ut,"parse",{enumerable:!0,get:function(){return RI.default}});Object.defineProperty(ut,"stringify",{enumerable:!0,get:function(){return PI.default}});Object.defineProperty(ut,"v1",{enumerable:!0,get:function(){return vI.default}});Object.defineProperty(ut,"v3",{enumerable:!0,get:function(){return fI.default}});Object.defineProperty(ut,"v4",{enumerable:!0,get:function(){return gI.default}});Object.defineProperty(ut,"v5",{enumerable:!0,get:function(){return mI.default}});Object.defineProperty(ut,"validate",{enumerable:!0,get:function(){return CI.default}});Object.defineProperty(ut,"version",{enumerable:!0,get:function(){return yI.default}});var vI=xt(Eg()),fI=xt(bg()),gI=xt(kg()),mI=xt(xg()),SI=xt(zg()),yI=xt(jg()),CI=xt(Qi()),PI=xt(Xi()),RI=xt(Hp());function xt(i){return i&&i.__esModule?i:{default:i}}});var tr=p(oi=>{"use strict";Object.defineProperty(oi,"__esModule",{value:!0});oi.createNoDashGuid=oi.createGuid=void 0;var EI=Lg(),Bg=()=>EI.v4();oi.createGuid=Bg;var II=()=>Bg().replace(new RegExp("-","g"),"").toUpperCase();oi.createNoDashGuid=II});var ai=p(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.PlatformEvent=Er.EventType=void 0;var wI=tr(),_I;(function(i){i[i.Debug=0]="Debug",i[i.Info=1]="Info",i[i.Warning=2]="Warning",i[i.Error=3]="Error",i[i.None=4]="None"})(_I=Er.EventType||(Er.EventType={}));var Gp=class{constructor(e,t){this.privName=e,this.privEventId=wI.createNoDashGuid(),this.privEventTime=new Date().toISOString(),this.privEventType=t,this.privMetadata={}}get name(){return this.privName}get eventId(){return this.privEventId}get eventTime(){return this.privEventTime}get eventType(){return this.privEventType}get metadata(){return this.privMetadata}};Er.PlatformEvent=Gp});var Fg=p(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.AudioStreamNodeErrorEvent=X.AudioStreamNodeDetachedEvent=X.AudioStreamNodeAttachedEvent=X.AudioStreamNodeAttachingEvent=X.AudioStreamNodeEvent=X.AudioSourceErrorEvent=X.AudioSourceOffEvent=X.AudioSourceReadyEvent=X.AudioSourceInitializingEvent=X.AudioSourceEvent=void 0;var $p=ai(),rr=class extends $p.PlatformEvent{constructor(e,t,r=$p.EventType.Info){super(e,r),this.privAudioSourceId=t}get audioSourceId(){return this.privAudioSourceId}};X.AudioSourceEvent=rr;var Qp=class extends rr{constructor(e){super("AudioSourceInitializingEvent",e)}};X.AudioSourceInitializingEvent=Qp;var Yp=class extends rr{constructor(e){super("AudioSourceReadyEvent",e)}};X.AudioSourceReadyEvent=Yp;var Xp=class extends rr{constructor(e){super("AudioSourceOffEvent",e)}};X.AudioSourceOffEvent=Xp;var Zp=class extends rr{constructor(e,t){super("AudioSourceErrorEvent",e,$p.EventType.Error),this.privError=t}get error(){return this.privError}};X.AudioSourceErrorEvent=Zp;var Ir=class extends rr{constructor(e,t,r){super(e,t),this.privAudioNodeId=r}get audioNodeId(){return this.privAudioNodeId}};X.AudioStreamNodeEvent=Ir;var eu=class extends Ir{constructor(e,t){super("AudioStreamNodeAttachingEvent",e,t)}};X.AudioStreamNodeAttachingEvent=eu;var tu=class extends Ir{constructor(e,t){super("AudioStreamNodeAttachedEvent",e,t)}};X.AudioStreamNodeAttachedEvent=tu;var ru=class extends Ir{constructor(e,t){super("AudioStreamNodeDetachedEvent",e,t)}};X.AudioStreamNodeDetachedEvent=ru;var iu=class extends Ir{constructor(e,t,r){super("AudioStreamNodeErrorEvent",e,t),this.privError=r}get error(){return this.privError}};X.AudioStreamNodeErrorEvent=iu});var Vg=p(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.ConnectionMessageSentEvent=ie.ConnectionMessageReceivedEvent=ie.ConnectionEstablishErrorEvent=ie.ConnectionErrorEvent=ie.ConnectionClosedEvent=ie.ConnectionEstablishedEvent=ie.ConnectionStartEvent=ie.ConnectionEvent=ie.ServiceEvent=void 0;var wr=ai(),nu=class extends wr.PlatformEvent{constructor(e,t,r=wr.EventType.Info){super(e,r),this.privJsonResult=t}get jsonString(){return this.privJsonResult}};ie.ServiceEvent=nu;var Ct=class extends wr.PlatformEvent{constructor(e,t,r=wr.EventType.Info){super(e,r),this.privConnectionId=t}get connectionId(){return this.privConnectionId}};ie.ConnectionEvent=Ct;var su=class extends Ct{constructor(e,t,r){super("ConnectionStartEvent",e),this.privUri=t,this.privHeaders=r}get uri(){return this.privUri}get headers(){return this.privHeaders}};ie.ConnectionStartEvent=su;var ou=class extends Ct{constructor(e){super("ConnectionEstablishedEvent",e)}};ie.ConnectionEstablishedEvent=ou;var au=class extends Ct{constructor(e,t,r){super("ConnectionClosedEvent",e,wr.EventType.Debug),this.privReason=r,this.privStatusCode=t}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};ie.ConnectionClosedEvent=au;var cu=class extends Ct{constructor(e,t,r){super("ConnectionErrorEvent",e,wr.EventType.Debug),this.privMessage=t,this.privType=r}get message(){return this.privMessage}get type(){return this.privType}};ie.ConnectionErrorEvent=cu;var pu=class extends Ct{constructor(e,t,r){super("ConnectionEstablishErrorEvent",e,wr.EventType.Error),this.privStatusCode=t,this.privReason=r}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};ie.ConnectionEstablishErrorEvent=pu;var uu=class extends Ct{constructor(e,t,r){super("ConnectionMessageReceivedEvent",e),this.privNetworkReceivedTime=t,this.privMessage=r}get networkReceivedTime(){return this.privNetworkReceivedTime}get message(){return this.privMessage}};ie.ConnectionMessageReceivedEvent=uu;var hu=class extends Ct{constructor(e,t,r){super("ConnectionMessageSentEvent",e),this.privNetworkSentTime=t,this.privMessage=r}get networkSentTime(){return this.privNetworkSentTime}get message(){return this.privMessage}};ie.ConnectionMessageSentEvent=hu});var ht=p(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.ObjectDisposedError=ir.InvalidOperationError=ir.ArgumentNullError=void 0;var du=class extends Error{constructor(e){super(e),this.name="ArgumentNull",this.message=e}};ir.ArgumentNullError=du;var lu=class extends Error{constructor(e){super(e),this.name="InvalidOperation",this.message=e}};ir.InvalidOperationError=lu;var vu=class extends Error{constructor(e,t){super(t),this.name=e+"ObjectDisposed",this.message=t}};ir.ObjectDisposedError=vu});var gu=p(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.ConnectionMessage=Tr.MessageType=void 0;var fs=ht(),TI=tr(),_r;(function(i){i[i.Text=0]="Text",i[i.Binary=1]="Binary"})(_r=Tr.MessageType||(Tr.MessageType={}));var fu=class{constructor(e,t,r,n){if(this.privBody=null,e===_r.Text&&t&&typeof t!="string")throw new fs.InvalidOperationError("Payload must be a string");if(e===_r.Binary&&t&&!(t instanceof ArrayBuffer))throw new fs.InvalidOperationError("Payload must be ArrayBuffer");switch(this.privMessageType=e,this.privBody=t,this.privHeaders=r||{},this.privId=n||TI.createNoDashGuid(),this.messageType){case _r.Binary:this.privSize=this.binaryBody!==null?this.binaryBody.byteLength:0;break;case _r.Text:this.privSize=this.textBody.length}}get messageType(){return this.privMessageType}get headers(){return this.privHeaders}get body(){return this.privBody}get textBody(){if(this.privMessageType===_r.Binary)throw new fs.InvalidOperationError("Not supported for binary message");return this.privBody}get binaryBody(){if(this.privMessageType===_r.Text)throw new fs.InvalidOperationError("Not supported for text message");return this.privBody}get id(){return this.privId}};Tr.ConnectionMessage=fu});var Ug=p(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.ConnectionOpenResponse=void 0;var mu=class{constructor(e,t){this.privStatusCode=e,this.privReason=t}get statusCode(){return this.privStatusCode}get reason(){return this.privReason}};gs.ConnectionOpenResponse=mu});var Wg=p(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.DeferralMap=void 0;var Su=class{constructor(){this.privMap={}}add(e,t){this.privMap[e]=t}getId(e){return this.privMap[e]}complete(e,t){try{this.privMap[e].resolve(t)}catch(r){this.privMap[e].reject(r)}finally{this.privMap[e]=void 0}}};ms.DeferralMap=Su});var Cu=p(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.SendingAgentContextMessageEvent=ci.DialogEvent=void 0;var Hg=ai(),Ss=class extends Hg.PlatformEvent{constructor(e,t=Hg.EventType.Info){super(e,t)}};ci.DialogEvent=Ss;var yu=class extends Ss{constructor(e){super("SendingAgentContextMessageEvent"),this.privAgentConfig=e}get agentConfig(){return this.privAgentConfig}};ci.SendingAgentContextMessageEvent=yu});var Ru=p(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.EventSource=void 0;var AI=ht(),bI=tr(),Pu=class{constructor(e){this.privEventListeners={},this.privIsDisposed=!1,this.privConsoleListener=void 0,this.privMetadata=e}onEvent(e){if(this.isDisposed())throw new AI.ObjectDisposedError("EventSource");if(this.metadata)for(let t in this.metadata)t&&e.metadata&&(e.metadata[t]||(e.metadata[t]=this.metadata[t]));for(let t in this.privEventListeners)t&&this.privEventListeners[t]&&this.privEventListeners[t](e)}attach(e){let t=bI.createNoDashGuid();return this.privEventListeners[t]=e,{detach:()=>(delete this.privEventListeners[t],Promise.resolve())}}attachListener(e){return this.attach(t=>e.onEvent(t))}attachConsoleListener(e){return this.privConsoleListener&&this.privConsoleListener.detach(),this.privConsoleListener=this.attach(t=>e.onEvent(t)),this.privConsoleListener}isDisposed(){return this.privIsDisposed}dispose(){this.privEventListeners=null,this.privIsDisposed=!0}get metadata(){return this.privMetadata}};ys.EventSource=Pu});var Kg=p(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.Events=void 0;var OI=ht(),MI=Ru(),Cs=class i{static setEventSource(e){if(!e)throw new OI.ArgumentNullError("eventSource");i.privInstance=e}static get instance(){return i.privInstance}};Ps.Events=Cs;Cs.privInstance=new MI.EventSource});var Gg=p(Jg=>{"use strict";Object.defineProperty(Jg,"__esModule",{value:!0})});var $g=p(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.ConnectionState=void 0;var DI;(function(i){i[i.None=0]="None",i[i.Connected=1]="Connected",i[i.Connecting=2]="Connecting",i[i.Disconnected=3]="Disconnected"})(DI=Zi.ConnectionState||(Zi.ConnectionState={}))});var Yg=p(Qg=>{"use strict";Object.defineProperty(Qg,"__esModule",{value:!0})});var Zg=p(Xg=>{"use strict";Object.defineProperty(Xg,"__esModule",{value:!0})});var tm=p(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0})});var im=p(rm=>{"use strict";Object.defineProperty(rm,"__esModule",{value:!0})});var sm=p(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0})});var am=p(om=>{"use strict";Object.defineProperty(om,"__esModule",{value:!0})});var pm=p(cm=>{"use strict";Object.defineProperty(cm,"__esModule",{value:!0})});var hm=p(um=>{"use strict";Object.defineProperty(um,"__esModule",{value:!0})});var Iu=p(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});Rs.List=void 0;var kI=ht(),Eu=class i{constructor(e){if(this.privSubscriptionIdCounter=0,this.privAddSubscriptions={},this.privRemoveSubscriptions={},this.privDisposedSubscriptions={},this.privDisposeReason=null,this.privList=[],e)for(let t of e)this.privList.push(t)}get(e){return this.throwIfDisposed(),this.privList[e]}first(){return this.get(0)}last(){return this.get(this.length()-1)}add(e){this.throwIfDisposed(),this.insertAt(this.privList.length,e)}insertAt(e,t){this.throwIfDisposed(),e===0?this.privList.unshift(t):e===this.privList.length?this.privList.push(t):this.privList.splice(e,0,t),this.triggerSubscriptions(this.privAddSubscriptions)}removeFirst(){return this.throwIfDisposed(),this.removeAt(0)}removeLast(){return this.throwIfDisposed(),this.removeAt(this.length()-1)}removeAt(e){return this.throwIfDisposed(),this.remove(e,1)[0]}remove(e,t){this.throwIfDisposed();let r=this.privList.splice(e,t);return this.triggerSubscriptions(this.privRemoveSubscriptions),r}clear(){this.throwIfDisposed(),this.remove(0,this.length())}length(){return this.throwIfDisposed(),this.privList.length}onAdded(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privAddSubscriptions[t]=e,{detach:()=>(delete this.privAddSubscriptions[t],Promise.resolve())}}onRemoved(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privRemoveSubscriptions[t]=e,{detach:()=>(delete this.privRemoveSubscriptions[t],Promise.resolve())}}onDisposed(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privDisposedSubscriptions[t]=e,{detach:()=>(delete this.privDisposedSubscriptions[t],Promise.resolve())}}join(e){return this.throwIfDisposed(),this.privList.join(e)}toArray(){let e=Array();return this.privList.forEach(t=>{e.push(t)}),e}any(e){return this.throwIfDisposed(),e?this.where(e).length()>0:this.length()>0}all(e){return this.throwIfDisposed(),this.where(e).length()===this.length()}forEach(e){this.throwIfDisposed();for(let t=0;t<this.length();t++)e(this.privList[t],t)}select(e){this.throwIfDisposed();let t=[];for(let r=0;r<this.privList.length;r++)t.push(e(this.privList[r],r));return new i(t)}where(e){this.throwIfDisposed();let t=new i;for(let r=0;r<this.privList.length;r++)e(this.privList[r],r)&&t.add(this.privList[r]);return t}orderBy(e){this.throwIfDisposed();let r=this.toArray().sort(e);return new i(r)}orderByDesc(e){return this.throwIfDisposed(),this.orderBy((t,r)=>e(r,t))}clone(){return this.throwIfDisposed(),new i(this.toArray())}concat(e){return this.throwIfDisposed(),new i(this.privList.concat(e.toArray()))}concatArray(e){return this.throwIfDisposed(),new i(this.privList.concat(e))}isDisposed(){return this.privList==null}dispose(e){this.isDisposed()||(this.privDisposeReason=e,this.privList=null,this.privAddSubscriptions=null,this.privRemoveSubscriptions=null,this.triggerSubscriptions(this.privDisposedSubscriptions))}throwIfDisposed(){if(this.isDisposed())throw new kI.ObjectDisposedError("List",this.privDisposeReason)}triggerSubscriptions(e){if(e)for(let t in e)t&&e[t]()}};Rs.List=Eu});var Tu=p(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.marshalPromiseToCallbacks=De.Sink=De.Deferred=De.PromiseResultEventSource=De.PromiseResult=De.PromiseState=void 0;var zt;(function(i){i[i.None=0]="None",i[i.Resolved=1]="Resolved",i[i.Rejected=2]="Rejected"})(zt=De.PromiseState||(De.PromiseState={}));var Es=class{constructor(e){this.throwIfError=()=>{if(this.isError)throw this.error},e.on(t=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!1,this.privResult=t)},t=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!0,this.privError=t)})}get isCompleted(){return this.privIsCompleted}get isError(){return this.privIsError}get error(){return this.privError}get result(){return this.privResult}};De.PromiseResult=Es;var Is=class{constructor(){this.setResult=e=>{this.privOnSetResult(e)},this.setError=e=>{this.privOnSetError(e)},this.on=(e,t)=>{this.privOnSetResult=e,this.privOnSetError=t}}};De.PromiseResultEventSource=Is;var wu=class{constructor(){this.resolve=e=>(this.privResolve(e),this),this.reject=e=>(this.privReject(e),this),this.privPromise=new Promise((e,t)=>{this.privResolve=e,this.privReject=t})}get promise(){return this.privPromise}};De.Deferred=wu;var _u=class{constructor(){this.privState=zt.None,this.privPromiseResult=null,this.privPromiseResultEvents=null,this.privSuccessHandlers=[],this.privErrorHandlers=[],this.privPromiseResultEvents=new Is,this.privPromiseResult=new Es(this.privPromiseResultEvents)}get state(){return this.privState}get result(){return this.privPromiseResult}resolve(e){if(this.privState!==zt.None)throw new Error("'Cannot resolve a completed promise'");this.privState=zt.Resolved,this.privPromiseResultEvents.setResult(e);for(let t=0;t<this.privSuccessHandlers.length;t++)this.executeSuccessCallback(e,this.privSuccessHandlers[t],this.privErrorHandlers[t]);this.detachHandlers()}reject(e){if(this.privState!==zt.None)throw new Error("'Cannot reject a completed promise'");this.privState=zt.Rejected,this.privPromiseResultEvents.setError(e);for(let t of this.privErrorHandlers)this.executeErrorCallback(e,t);this.detachHandlers()}on(e,t){e==null&&(e=()=>{}),this.privState===zt.None?(this.privSuccessHandlers.push(e),this.privErrorHandlers.push(t)):(this.privState===zt.Resolved?this.executeSuccessCallback(this.privPromiseResult.result,e,t):this.privState===zt.Rejected&&this.executeErrorCallback(this.privPromiseResult.error,t),this.detachHandlers())}executeSuccessCallback(e,t,r){try{t(e)}catch(n){this.executeErrorCallback(`'Unhandled callback error: ${n}'`,r)}}executeErrorCallback(e,t){if(t)try{t(e)}catch(r){throw new Error(`'Unhandled callback error: ${r}. InnerError: ${e}'`)}else throw new Error(`'Unhandled error: ${e}'`)}detachHandlers(){this.privErrorHandlers=[],this.privSuccessHandlers=[]}};De.Sink=_u;function NI(i,e,t){i.then(r=>{try{e&&e(r)}catch(n){if(t)try{if(n instanceof Error){let s=n;t(s.name+": "+s.message)}else t(n)}catch{}}},r=>{if(t)try{if(r instanceof Error){let n=r;t(n.name+": "+n.message)}else t(r)}catch{}})}De.marshalPromiseToCallbacks=NI});var Mu=p(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.Queue=void 0;var Au=ht(),bu=Iu(),dm=Tu(),en;(function(i){i[i.Dequeue=0]="Dequeue",i[i.Peek=1]="Peek"})(en||(en={}));var Ou=class{constructor(e){this.privPromiseStore=new bu.List,this.privIsDrainInProgress=!1,this.privIsDisposing=!1,this.privDisposeReason=null,this.privList=e||new bu.List,this.privDetachables=[],this.privSubscribers=new bu.List,this.privDetachables.push(this.privList.onAdded(()=>this.drain()))}enqueue(e){this.throwIfDispose(),this.enqueueFromPromise(new Promise(t=>t(e)))}enqueueFromPromise(e){this.throwIfDispose(),e.then(t=>{this.privList.add(t)},()=>{})}dequeue(){this.throwIfDispose();let e=new dm.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:en.Dequeue}),this.drain()),e.promise}peek(){this.throwIfDispose();let e=new dm.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:en.Peek}),this.drain()),e.promise}length(){return this.throwIfDispose(),this.privList.length()}isDisposed(){return this.privSubscribers==null}async drainAndDispose(e,t){if(!this.isDisposed()&&!this.privIsDisposing){this.privDisposeReason=t,this.privIsDisposing=!0;let r=this.privSubscribers;if(r){for(;r.length()>0;)r.removeFirst().deferral.resolve(void 0);this.privSubscribers===r&&(this.privSubscribers=r)}for(let n of this.privDetachables)await n.detach();if(this.privPromiseStore.length()>0&&e){let n=[];return this.privPromiseStore.toArray().forEach(s=>{n.push(s)}),Promise.all(n).finally(()=>{this.privSubscribers=null,this.privList.forEach(s=>{e(s)}),this.privList=null}).then()}else this.privSubscribers=null,this.privList=null}}async dispose(e){await this.drainAndDispose(null,e)}drain(){if(!this.privIsDrainInProgress&&!this.privIsDisposing){this.privIsDrainInProgress=!0;let e=this.privSubscribers,t=this.privList;if(e&&t){for(;t.length()>0&&e.length()>0&&!this.privIsDisposing;){let r=e.removeFirst();if(r.type===en.Peek)r.deferral.resolve(t.first());else{let n=t.removeFirst();r.deferral.resolve(n)}}this.privSubscribers===e&&(this.privSubscribers=e),this.privList===t&&(this.privList=t)}this.privIsDrainInProgress=!1}}throwIfDispose(){if(this.isDisposed())throw this.privDisposeReason?new Au.InvalidOperationError(this.privDisposeReason):new Au.ObjectDisposedError("Queue");if(this.privIsDisposing)throw new Au.InvalidOperationError("Queue disposing")}};ws.Queue=Ou});var lm=p(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.RawWebsocketMessage=void 0;var _s=gu(),tn=ht(),qI=tr(),Du=class{constructor(e,t,r){if(this.privPayload=null,!t)throw new tn.ArgumentNullError("payload");if(e===_s.MessageType.Binary&&Object.getPrototypeOf(t).constructor.name!=="ArrayBuffer")throw new tn.InvalidOperationError("Payload must be ArrayBuffer");if(e===_s.MessageType.Text&&typeof t!="string")throw new tn.InvalidOperationError("Payload must be a string");this.privMessageType=e,this.privPayload=t,this.privId=r||qI.createNoDashGuid()}get messageType(){return this.privMessageType}get payload(){return this.privPayload}get textContent(){if(this.privMessageType===_s.MessageType.Binary)throw new tn.InvalidOperationError("Not supported for binary message");return this.privPayload}get binaryContent(){if(this.privMessageType===_s.MessageType.Text)throw new tn.InvalidOperationError("Not supported for text message");return this.privPayload}get id(){return this.privId}};Ts.RawWebsocketMessage=Du});var vm=p(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});As.RiffPcmEncoder=void 0;var ku=class{constructor(e,t){this.privActualSampleRate=e,this.privDesiredSampleRate=t}encode(e){let t=this.downSampleAudioFrame(e,this.privActualSampleRate,this.privDesiredSampleRate);if(!t)return null;let r=t.length*2,n=new ArrayBuffer(r),s=new DataView(n);return this.floatTo16BitPCM(s,0,t),n}setString(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))}floatTo16BitPCM(e,t,r){for(let n=0;n<r.length;n++,t+=2){let s=Math.max(-1,Math.min(1,r[n]));e.setInt16(t,s<0?s*32768:s*32767,!0)}}downSampleAudioFrame(e,t,r){if(!e)return null;if(r===t||r>t)return e;let n=t/r,s=Math.round(e.length/n),o=new Float32Array(s),a=0,c=0;for(;c<s;){let u=Math.round((c+1)*n),h=0,d=0;for(;a<u&&a<e.length;)h+=e[a++],d++;o[c++]=h/d}return o}};As.RiffPcmEncoder=ku});var mm=p(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.Stream=void 0;var fm=ht(),xI=tr(),gm=Mu(),Nu=class{constructor(e){this.privIsWriteEnded=!1,this.privIsReadEnded=!1,this.privId=e||xI.createNoDashGuid(),this.privReaderQueue=new gm.Queue}get isClosed(){return this.privIsWriteEnded}get isReadEnded(){return this.privIsReadEnded}get id(){return this.privId}close(){this.privIsWriteEnded||(this.writeStreamChunk({buffer:null,isEnd:!0,timeReceived:Date.now()}),this.privIsWriteEnded=!0)}writeStreamChunk(e){if(this.throwIfClosed(),!this.privReaderQueue.isDisposed())try{this.privReaderQueue.enqueue(e)}catch{}}read(){if(this.privIsReadEnded)throw new fm.InvalidOperationError("Stream read has already finished");return this.privReaderQueue.dequeue().then(async e=>((e===void 0||e.isEnd)&&await this.privReaderQueue.dispose("End of stream reached"),e))}readEnded(){this.privIsReadEnded||(this.privIsReadEnded=!0,this.privReaderQueue=new gm.Queue)}throwIfClosed(){if(this.privIsWriteEnded)throw new fm.InvalidOperationError("Stream closed")}};bs.Stream=Nu});var Os=p(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.TranslationStatus=void 0;var zI;(function(i){i[i.Success=0]="Success",i[i.Error=1]="Error"})(zI=rn.TranslationStatus||(rn.TranslationStatus={}))});var Sm=p(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.ChunkedArrayBufferStream=void 0;var jI=P(),qu=class extends jI.Stream{constructor(e,t){super(t),this.privTargetChunkSize=e,this.privNextBufferReadyBytes=0}writeStreamChunk(e){if(e.isEnd||this.privNextBufferReadyBytes===0&&e.buffer.byteLength===this.privTargetChunkSize){super.writeStreamChunk(e);return}let t=0;for(;t<e.buffer.byteLength;){this.privNextBufferToWrite===void 0&&(this.privNextBufferToWrite=new ArrayBuffer(this.privTargetChunkSize),this.privNextBufferStartTime=e.timeReceived);let r=Math.min(e.buffer.byteLength-t,this.privTargetChunkSize-this.privNextBufferReadyBytes),n=new Uint8Array(this.privNextBufferToWrite),s=new Uint8Array(e.buffer.slice(t,r+t));n.set(s,this.privNextBufferReadyBytes),this.privNextBufferReadyBytes+=r,t+=r,this.privNextBufferReadyBytes===this.privTargetChunkSize&&(super.writeStreamChunk({buffer:this.privNextBufferToWrite,isEnd:!1,timeReceived:this.privNextBufferStartTime}),this.privNextBufferReadyBytes=0,this.privNextBufferToWrite=void 0)}}close(){this.privNextBufferReadyBytes!==0&&!this.isClosed&&super.writeStreamChunk({buffer:this.privNextBufferToWrite.slice(0,this.privNextBufferReadyBytes),isEnd:!1,timeReceived:this.privNextBufferStartTime}),super.close()}};Ms.ChunkedArrayBufferStream=qu});var Cm=p(ym=>{"use strict";Object.defineProperty(ym,"__esModule",{value:!0})});var Pm=p(Ds=>{"use strict";Object.defineProperty(Ds,"__esModule",{value:!0});Ds.Timeout=void 0;var Pt=class i{static load(){let e=new Map([[0,()=>{}]]),t=new Map,n="data:text/javascript;base64,"+btoa(`!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return a})),n.d(t,"d",(function(){return d}));const r=new Map,o=new Map,i=e=>{const t=r.get(e);if(void 0===t)throw new Error('There is no interval scheduled with the given id "'.concat(e,'".'));clearTimeout(t),r.delete(e)},u=e=>{const t=o.get(e);if(void 0===t)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(t),o.delete(e)},f=(e,t)=>{let n,r;if("performance"in self){const o=performance.now();n=o,r=e-Math.max(0,o-t)}else n=Date.now(),r=e;return{expected:n+r,remainingDelay:r}},c=(e,t,n,r)=>{const o="performance"in self?performance.now():Date.now();o>n?postMessage({id:null,method:"call",params:{timerId:t}}):e.set(t,setTimeout(c,n-o,e,t,n))},a=(e,t,n)=>{const{expected:o,remainingDelay:i}=f(e,n);r.set(t,setTimeout(c,i,r,t,o))},d=(e,t,n)=>{const{expected:r,remainingDelay:i}=f(e,n);o.set(t,setTimeout(c,i,o,t,r))}},function(e,t,n){"use strict";n.r(t);var r=n(2);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(3);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(4);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o);var f=n(5);for(var o in f)"default"!==o&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var c=n(6);for(var o in c)"default"!==o&&function(e){n.d(t,e,(function(){return c[e]}))}(o);var a=n(7);for(var o in a)"default"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var d=n(8);for(var o in d)"default"!==o&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var s=n(9);for(var o in s)"default"!==o&&function(e){n.d(t,e,(function(){return s[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(11);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(12);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(13);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(1);for(var i in o)"default"!==i&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var u=n(10);for(var i in u)"default"!==i&&function(e){n.d(t,e,(function(){return u[e]}))}(i);addEventListener("message",({data:e})=>{try{if("clear"===e.method){const{id:t,params:{timerId:n}}=e;Object(r.b)(n),postMessage({error:null,id:t})}else{if("set"!==e.method)throw new Error('The given method "'.concat(e.method,'" is not supported'));{const{params:{delay:t,now:n,timerId:o}}=e;Object(r.d)(t,o,n)}}}catch(t){postMessage({error:{message:t.message},id:e.id,result:null})}})}]);`),s=new Worker(n);return s.addEventListener("message",({data:c})=>{if(i.isCallNotification(c)){let{params:{timerId:u}}=c,h=e.get(u);if(typeof h=="number"){let d=t.get(h);if(d===void 0||d!==u)throw new Error("The timer is in an undefined state.")}else if(typeof h<"u")h(),e.delete(u);else throw new Error("The timer is in an undefined state.")}else if(i.isClearResponse(c)){let{id:u}=c,h=t.get(u);if(h===void 0)throw new Error("The timer is in an undefined state.");t.delete(u),e.delete(h)}else{let{error:{message:u}}=c;throw new Error(u)}}),{clearTimeout:c=>{let u=Math.random();t.set(u,c),e.set(c,u),s.postMessage({id:u,method:"clear",params:{timerId:c}})},setTimeout:(c,u)=>{let h=Math.random();return e.set(h,c),s.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:h}}),h}}}static loadWorkerTimers(){return()=>(i.workerTimers!==null||(i.workerTimers=i.load()),i.workerTimers)}static isCallNotification(e){return e.method!==void 0&&e.method==="call"}static isClearResponse(e){return e.error===null&&typeof e.id=="number"}};Ds.Timeout=Pt;Pt.workerTimers=null;Pt.clearTimeout=i=>Pt.timers().clearTimeout(i);Pt.setTimeout=(i,e)=>Pt.timers().setTimeout(i,e);Pt.timers=Pt.loadWorkerTimers()});var Rm=p(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.OCSPCacheUpdateErrorEvent=M.OCSPResponseRetrievedEvent=M.OCSPCacheFetchErrorEvent=M.OCSPVerificationFailedEvent=M.OCSPCacheHitEvent=M.OCSPCacheEntryNeedsRefreshEvent=M.OCSPCacheEntryExpiredEvent=M.OCSPWSUpgradeStartedEvent=M.OCSPStapleReceivedEvent=M.OCSPCacheUpdateCompleteEvent=M.OCSPDiskCacheStoreEvent=M.OCSPMemoryCacheStoreEvent=M.OCSPCacheUpdateNeededEvent=M.OCSPDiskCacheHitEvent=M.OCSPCacheMissEvent=M.OCSPMemoryCacheHitEvent=M.OCSPEvent=void 0;var le=ai(),ce=class extends le.PlatformEvent{constructor(e,t,r){super(e,t),this.privSignature=r}};M.OCSPEvent=ce;var xu=class extends ce{constructor(e){super("OCSPMemoryCacheHitEvent",le.EventType.Debug,e)}};M.OCSPMemoryCacheHitEvent=xu;var zu=class extends ce{constructor(e){super("OCSPCacheMissEvent",le.EventType.Debug,e)}};M.OCSPCacheMissEvent=zu;var ju=class extends ce{constructor(e){super("OCSPDiskCacheHitEvent",le.EventType.Debug,e)}};M.OCSPDiskCacheHitEvent=ju;var Lu=class extends ce{constructor(e){super("OCSPCacheUpdateNeededEvent",le.EventType.Debug,e)}};M.OCSPCacheUpdateNeededEvent=Lu;var Bu=class extends ce{constructor(e){super("OCSPMemoryCacheStoreEvent",le.EventType.Debug,e)}};M.OCSPMemoryCacheStoreEvent=Bu;var Fu=class extends ce{constructor(e){super("OCSPDiskCacheStoreEvent",le.EventType.Debug,e)}};M.OCSPDiskCacheStoreEvent=Fu;var Vu=class extends ce{constructor(e){super("OCSPCacheUpdateCompleteEvent",le.EventType.Debug,e)}};M.OCSPCacheUpdateCompleteEvent=Vu;var Uu=class extends ce{constructor(){super("OCSPStapleReceivedEvent",le.EventType.Debug,"")}};M.OCSPStapleReceivedEvent=Uu;var Wu=class extends ce{constructor(e){super("OCSPWSUpgradeStartedEvent",le.EventType.Debug,e)}};M.OCSPWSUpgradeStartedEvent=Wu;var Hu=class extends ce{constructor(e,t){super("OCSPCacheEntryExpiredEvent",le.EventType.Debug,e),this.privExpireTime=t}};M.OCSPCacheEntryExpiredEvent=Hu;var Ku=class extends ce{constructor(e,t,r){super("OCSPCacheEntryNeedsRefreshEvent",le.EventType.Debug,e),this.privExpireTime=r,this.privStartTime=t}};M.OCSPCacheEntryNeedsRefreshEvent=Ku;var Ju=class extends ce{constructor(e,t,r){super("OCSPCacheHitEvent",le.EventType.Debug,e),this.privExpireTime=r,this.privExpireTimeString=new Date(r).toLocaleDateString(),this.privStartTime=t,this.privStartTimeString=new Date(t).toLocaleTimeString()}};M.OCSPCacheHitEvent=Ju;var Gu=class extends ce{constructor(e,t){super("OCSPVerificationFailedEvent",le.EventType.Debug,e),this.privError=t}};M.OCSPVerificationFailedEvent=Gu;var $u=class extends ce{constructor(e,t){super("OCSPCacheFetchErrorEvent",le.EventType.Debug,e),this.privError=t}};M.OCSPCacheFetchErrorEvent=$u;var Qu=class extends ce{constructor(e){super("OCSPResponseRetrievedEvent",le.EventType.Debug,e)}};M.OCSPResponseRetrievedEvent=Qu;var Yu=class extends ce{constructor(e,t){super("OCSPCacheUpdateErrorEvent",le.EventType.Debug,e),this.privError=t}};M.OCSPCacheUpdateErrorEvent=Yu});var Im=p(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.BackgroundEvent=void 0;var Em=P(),Xu=class extends Em.PlatformEvent{constructor(e){super("BackgroundEvent",Em.EventType.Error),this.privError=e}get error(){return this.privError}};ks.BackgroundEvent=Xu});var P=p(b=>{"use strict";var LI=b&&b.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),N=b&&b.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&LI(e,i,t)};Object.defineProperty(b,"__esModule",{value:!0});N(Fg(),b);N(Vg(),b);N(gu(),b);N(Ug(),b);N(Wg(),b);N(Cu(),b);N(ht(),b);N(Kg(),b);N(Ru(),b);N(tr(),b);N(Gg(),b);N($g(),b);N(Yg(),b);N(Zg(),b);N(tm(),b);N(im(),b);N(sm(),b);N(am(),b);N(pm(),b);N(hm(),b);N(Iu(),b);N(ai(),b);N(Tu(),b);N(Mu(),b);N(lm(),b);N(vm(),b);N(mm(),b);var BI=Os();Object.defineProperty(b,"TranslationStatus",{enumerable:!0,get:function(){return BI.TranslationStatus}});N(Sm(),b);N(Cm(),b);N(Pm(),b);N(Rm(),b);N(Im(),b)});var we=p(Ns=>{"use strict";Object.defineProperty(Ns,"__esModule",{value:!0});Ns.HeaderNames=void 0;var Ve=class{};Ns.HeaderNames=Ve;Ve.AuthKey="Ocp-Apim-Subscription-Key";Ve.Authorization="Authorization";Ve.SpIDAuthKey="Apim-Subscription-Id";Ve.ConnectionId="X-ConnectionId";Ve.ContentType="Content-Type";Ve.CustomCommandsAppId="X-CommandsAppId";Ve.Path="Path";Ve.RequestId="X-RequestId";Ve.RequestStreamId="X-StreamId";Ve.RequestTimestamp="X-Timestamp"});var xs=p(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.AuthInfo=void 0;var Zu=class{constructor(e,t){this.privHeaderName=e,this.privToken=t}get headerName(){return this.privHeaderName}get token(){return this.privToken}};qs.AuthInfo=Zu});var wm=p(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.CognitiveSubscriptionKeyAuthentication=void 0;var FI=P(),VI=we(),UI=xs(),eh=class{constructor(e){if(!e)throw new FI.ArgumentNullError("subscriptionKey");this.privAuthInfo=new UI.AuthInfo(VI.HeaderNames.AuthKey,e)}fetch(e){return Promise.resolve(this.privAuthInfo)}fetchOnExpiry(e){return Promise.resolve(this.privAuthInfo)}};zs.CognitiveSubscriptionKeyAuthentication=eh});var bm=p(Ls=>{"use strict";Object.defineProperty(Ls,"__esModule",{value:!0});Ls.CognitiveTokenAuthentication=void 0;var _m=P(),Tm=xs(),Am=we(),js=class i{constructor(e,t){if(!e)throw new _m.ArgumentNullError("fetchCallback");if(!t)throw new _m.ArgumentNullError("fetchOnExpiryCallback");this.privFetchCallback=e,this.privFetchOnExpiryCallback=t}fetch(e){return this.privFetchCallback(e).then(t=>new Tm.AuthInfo(Am.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}fetchOnExpiry(e){return this.privFetchOnExpiryCallback(e).then(t=>new Tm.AuthInfo(Am.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}};Ls.CognitiveTokenAuthentication=js;js.privTokenPrefix="Bearer "});var Mm=p(Om=>{"use strict";Object.defineProperty(Om,"__esModule",{value:!0})});var km=p(Dm=>{"use strict";Object.defineProperty(Dm,"__esModule",{value:!0})});var th=p(()=>{});var rh=p(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.LogLevel=void 0;var WI=P();Object.defineProperty(Bs,"LogLevel",{enumerable:!0,get:function(){return WI.EventType}})});var I=p(Fs=>{"use strict";Object.defineProperty(Fs,"__esModule",{value:!0});Fs.Contracts=void 0;var ih=class i{static throwIfNullOrUndefined(e,t){if(e==null)throw new Error("throwIfNullOrUndefined:"+t)}static throwIfNull(e,t){if(e===null)throw new Error("throwIfNull:"+t)}static throwIfNullOrWhitespace(e,t){if(i.throwIfNullOrUndefined(e,t),(""+e).trim().length<1)throw new Error("throwIfNullOrWhitespace:"+t)}static throwIfNullOrTooLong(e,t,r){if(i.throwIfNullOrUndefined(e,t),(""+e).length>r)throw new Error("throwIfNullOrTooLong:"+t+" (more than "+r.toString()+" characters)")}static throwIfNullOrTooShort(e,t,r){if(i.throwIfNullOrUndefined(e,t),(""+e).length<r)throw new Error("throwIfNullOrTooShort:"+t+" (less than "+r.toString()+" characters)")}static throwIfDisposed(e){if(e)throw new Error("the object is already disposed")}static throwIfArrayEmptyOrWhitespace(e,t){if(i.throwIfNullOrUndefined(e,t),e.length===0)throw new Error("throwIfArrayEmptyOrWhitespace:"+t);for(let r of e)i.throwIfNullOrWhitespace(r,t)}static throwIfFileDoesNotExist(e,t){i.throwIfNullOrWhitespace(e,t)}static throwIfNotUndefined(e,t){if(e!==void 0)throw new Error("throwIfNotUndefined:"+t)}};Fs.Contracts=ih});var qm=p(Rt=>{"use strict";var HI=Rt&&Rt.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),KI=Rt&&Rt.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),JI=Rt&&Rt.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&HI(e,i,t);return KI(e,i),e};Object.defineProperty(Rt,"__esModule",{value:!0});Rt.ConsoleLoggingListener=void 0;var Nm=JI(th()),nn=rh(),GI=I(),nh=class{constructor(e=nn.LogLevel.None){this.privLogPath=void 0,this.privEnableConsoleOutput=!0,this.privLogLevelFilter=e}set logPath(e){GI.Contracts.throwIfNullOrUndefined(Nm.openSync,`
2
- File System access not available`),this.privLogPath=e}set enableConsoleOutput(e){this.privEnableConsoleOutput=e}onEvent(e){if(e.eventType>=this.privLogLevelFilter){let t=this.toString(e);if(this.logCallback&&this.logCallback(t),this.privLogPath&&Nm.writeFileSync(this.privLogPath,t+`
3
- `,{flag:"a+"}),this.privEnableConsoleOutput)switch(e.eventType){case nn.LogLevel.Debug:console.debug(t);break;case nn.LogLevel.Info:console.info(t);break;case nn.LogLevel.Warning:console.warn(t);break;case nn.LogLevel.Error:console.error(t);break;default:console.log(t);break}}}toString(e){let t=[`${e.eventTime}`,`${e.name}`],r=e;for(let n in r)if(n&&e.hasOwnProperty(n)&&n!=="eventTime"&&n!=="eventType"&&n!=="eventId"&&n!=="name"&&n!=="constructor"){let s=r[n],o="<NULL>";s!=null&&(typeof s=="number"||typeof s=="string"?o=s.toString():o=JSON.stringify(s)),t.push(`${n}: ${o}`)}return t.join(" | ")}};Rt.ConsoleLoggingListener=nh});var zm=p(xm=>{"use strict";Object.defineProperty(xm,"__esModule",{value:!0})});var nr=p(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.AudioStreamFormatImpl=jt.AudioStreamFormat=jt.AudioFormatTag=void 0;var sn;(function(i){i[i.PCM=1]="PCM",i[i.MuLaw=2]="MuLaw",i[i.Siren=3]="Siren",i[i.MP3=4]="MP3",i[i.SILKSkype=5]="SILKSkype",i[i.OGG_OPUS=6]="OGG_OPUS",i[i.WEBM_OPUS=7]="WEBM_OPUS",i[i.ALaw=8]="ALaw",i[i.FLAC=9]="FLAC",i[i.OPUS=10]="OPUS"})(sn=jt.AudioFormatTag||(jt.AudioFormatTag={}));var Vs=class{static getDefaultInputFormat(){return pi.getDefaultInputFormat()}static getWaveFormat(e,t,r,n){return new pi(e,t,r,n)}static getWaveFormatPCM(e,t,r){return new pi(e,t,r)}};jt.AudioStreamFormat=Vs;var pi=class i extends Vs{constructor(e=16e3,t=16,r=1,n=sn.PCM){super();let s=!0;switch(n){case sn.PCM:this.formatTag=1;break;case sn.ALaw:this.formatTag=6;break;case sn.MuLaw:this.formatTag=7;break;default:s=!1}if(this.bitsPerSample=t,this.samplesPerSec=e,this.channels=r,this.avgBytesPerSec=this.samplesPerSec*this.channels*(this.bitsPerSample/8),this.blockAlign=this.channels*Math.max(this.bitsPerSample,8),s){this.privHeader=new ArrayBuffer(44);let o=new DataView(this.privHeader);this.setString(o,0,"RIFF"),o.setUint32(4,0,!0),this.setString(o,8,"WAVEfmt "),o.setUint32(16,16,!0),o.setUint16(20,this.formatTag,!0),o.setUint16(22,this.channels,!0),o.setUint32(24,this.samplesPerSec,!0),o.setUint32(28,this.avgBytesPerSec,!0),o.setUint16(32,this.channels*(this.bitsPerSample/8),!0),o.setUint16(34,this.bitsPerSample,!0),this.setString(o,36,"data"),o.setUint32(40,0,!0)}}static getDefaultInputFormat(){return new i}static getAudioContext(e){let t=window.AudioContext||window.webkitAudioContext||!1;if(t)return e!==void 0&&navigator.mediaDevices.getSupportedConstraints().sampleRate?new t({sampleRate:e}):new t;throw new Error("Browser does not support Web Audio API (AudioContext is not available).")}close(){}get header(){return this.privHeader}setString(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))}};jt.AudioStreamFormatImpl=pi});var Bm=p(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.MicAudioSource=Ar.AudioWorkletSourceURLPropertyName=void 0;var jm=C(),ve=P(),Lm=nr();Ar.AudioWorkletSourceURLPropertyName="MICROPHONE-WorkletSourceUrl";var Us=class i{constructor(e,t,r,n){this.privRecorder=e,this.deviceId=t,this.privStreams={},this.privOutputChunkSize=i.AUDIOFORMAT.avgBytesPerSec/10,this.privId=r||ve.createNoDashGuid(),this.privEvents=new ve.EventSource,this.privMediaStream=n||null,this.privIsClosing=!1}get format(){return Promise.resolve(i.AUDIOFORMAT)}turnOn(){if(this.privInitializeDeferral)return this.privInitializeDeferral.promise;this.privInitializeDeferral=new ve.Deferred;try{this.createAudioContext()}catch(r){if(r instanceof Error){let n=r;this.privInitializeDeferral.reject(n.name+": "+n.message)}else this.privInitializeDeferral.reject(r);return this.privInitializeDeferral.promise}let e=window.navigator,t=e.getUserMedia||e.webkitGetUserMedia||e.mozGetUserMedia||e.msGetUserMedia;if(e.mediaDevices&&(t=(r,n,s)=>{e.mediaDevices.getUserMedia(r).then(n).catch(s)}),t){let r=()=>{this.onEvent(new ve.AudioSourceInitializingEvent(this.privId)),this.privMediaStream&&this.privMediaStream.active?(this.onEvent(new ve.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()):t({audio:this.deviceId?{deviceId:this.deviceId}:!0,video:!1},n=>{this.privMediaStream=n,this.onEvent(new ve.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()},n=>{let s=`Error occurred during microphone initialization: ${n}`;this.privInitializeDeferral.reject(s),this.onEvent(new ve.AudioSourceErrorEvent(this.privId,s))})};this.privContext.state==="suspended"?this.privContext.resume().then(r).catch(n=>{this.privInitializeDeferral.reject(`Failed to initialize audio context: ${n}`)}):r()}else{let r="Browser does not support getUserMedia.";this.privInitializeDeferral.reject(r),this.onEvent(new ve.AudioSourceErrorEvent(r,""))}return this.privInitializeDeferral.promise}id(){return this.privId}attach(e){return this.onEvent(new ve.AudioStreamNodeAttachingEvent(this.privId,e)),this.listen(e).then(t=>(this.onEvent(new ve.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(t.readEnded(),delete this.privStreams[e],this.onEvent(new ve.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}))}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new ve.AudioStreamNodeDetachedEvent(this.privId,e)))}async turnOff(){for(let e in this.privStreams)if(e){let t=this.privStreams[e];t&&t.close()}this.onEvent(new ve.AudioSourceOffEvent(this.privId)),this.privInitializeDeferral&&(await this.privInitializeDeferral,this.privInitializeDeferral=null),await this.destroyAudioContext()}get events(){return this.privEvents}get deviceInfo(){return this.getMicrophoneLabel().then(e=>({bitspersample:i.AUDIOFORMAT.bitsPerSample,channelcount:i.AUDIOFORMAT.channels,connectivity:jm.connectivity.Unknown,manufacturer:"Speech SDK",model:e,samplerate:i.AUDIOFORMAT.samplesPerSec,type:jm.type.Microphones}))}setProperty(e,t){if(e===Ar.AudioWorkletSourceURLPropertyName)this.privRecorder.setWorkletUrl(t);else throw new Error("Property '"+e+"' is not supported on Microphone.")}getMicrophoneLabel(){let e="microphone";if(this.privMicrophoneLabel!==void 0)return Promise.resolve(this.privMicrophoneLabel);if(this.privMediaStream===void 0||!this.privMediaStream.active)return Promise.resolve(e);this.privMicrophoneLabel=e;let t=this.privMediaStream.getTracks()[0].getSettings().deviceId;if(t===void 0)return Promise.resolve(this.privMicrophoneLabel);let r=new ve.Deferred;return navigator.mediaDevices.enumerateDevices().then(n=>{for(let s of n)if(s.deviceId===t){this.privMicrophoneLabel=s.label;break}r.resolve(this.privMicrophoneLabel)},()=>r.resolve(this.privMicrophoneLabel)),r.promise}async listen(e){await this.turnOn();let t=new ve.ChunkedArrayBufferStream(this.privOutputChunkSize,e);this.privStreams[e]=t;try{this.privRecorder.record(this.privContext,this.privMediaStream,t)}catch(n){throw this.onEvent(new ve.AudioStreamNodeErrorEvent(this.privId,e,n)),n}return t}onEvent(e){this.privEvents.onEvent(e),ve.Events.instance.onEvent(e)}createAudioContext(){this.privContext||(this.privContext=Lm.AudioStreamFormatImpl.getAudioContext(i.AUDIOFORMAT.samplesPerSec))}async destroyAudioContext(){if(!this.privContext)return;this.privRecorder.releaseMediaResources(this.privContext);let e=!1;"close"in this.privContext&&(e=!0),e?this.privIsClosing||(this.privIsClosing=!0,await this.privContext.close(),this.privContext=null,this.privIsClosing=!1):this.privContext!==null&&this.privContext.state==="running"&&await this.privContext.suspend()}};Ar.MicAudioSource=Us;Us.AUDIOFORMAT=Lm.AudioStreamFormat.getDefaultInputFormat()});var Vm=p(Ws=>{"use strict";Object.defineProperty(Ws,"__esModule",{value:!0});Ws.FileAudioSource=void 0;var Fm=C(),xe=P(),$I=nr(),sh=class{constructor(e,t,r){this.privStreams={},this.privHeaderEnd=44,this.privId=r||xe.createNoDashGuid(),this.privEvents=new xe.EventSource,this.privSource=e,typeof window<"u"&&typeof Blob<"u"&&this.privSource instanceof Blob?this.privFilename=e.name:this.privFilename=t||"unknown.wav",this.privAudioFormatPromise=this.readHeader()}get format(){return this.privAudioFormatPromise}turnOn(){if(this.privFilename.lastIndexOf(".wav")!==this.privFilename.length-4){let e=this.privFilename+" is not supported. Only WAVE files are allowed at the moment.";return this.onEvent(new xe.AudioSourceErrorEvent(e,"")),Promise.reject(e)}this.onEvent(new xe.AudioSourceInitializingEvent(this.privId)),this.onEvent(new xe.AudioSourceReadyEvent(this.privId))}id(){return this.privId}async attach(e){this.onEvent(new xe.AudioStreamNodeAttachingEvent(this.privId,e));let t=await this.upload(e);return this.onEvent(new xe.AudioStreamNodeAttachedEvent(this.privId,e)),Promise.resolve({detach:async()=>{t.readEnded(),delete this.privStreams[e],this.onEvent(new xe.AudioStreamNodeDetachedEvent(this.privId,e)),await this.turnOff()},id:()=>e,read:()=>t.read()})}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new xe.AudioStreamNodeDetachedEvent(this.privId,e)))}turnOff(){for(let e in this.privStreams)if(e){let t=this.privStreams[e];t&&!t.isClosed&&t.close()}return this.onEvent(new xe.AudioSourceOffEvent(this.privId)),Promise.resolve()}get events(){return this.privEvents}get deviceInfo(){return this.privAudioFormatPromise.then(e=>Promise.resolve({bitspersample:e.bitsPerSample,channelcount:e.channels,connectivity:Fm.connectivity.Unknown,manufacturer:"Speech SDK",model:"File",samplerate:e.samplesPerSec,type:Fm.type.File}))}readHeader(){let t=this.privSource.slice(0,4296),r=new xe.Deferred,n=s=>{let o=new DataView(s),a=g=>String.fromCharCode(o.getUint8(g),o.getUint8(g+1),o.getUint8(g+2),o.getUint8(g+3));if(a(0)!=="RIFF"){r.reject("Invalid WAV header in file, RIFF was not found");return}if(a(8)!=="WAVE"||a(12)!=="fmt "){r.reject("Invalid WAV header in file, WAVEfmt was not found");return}let c=o.getInt32(16,!0),u=o.getUint16(22,!0),h=o.getUint32(24,!0),d=o.getUint16(34,!0),v=36+Math.max(c-16,0);for(;a(v)!=="data";v+=2)if(v>4288){r.reject("Invalid WAV header in file, data block was not found");return}this.privHeaderEnd=v+8,r.resolve($I.AudioStreamFormat.getWaveFormatPCM(h,d,u))};if(typeof window<"u"&&typeof Blob<"u"&&t instanceof Blob){let s=new FileReader;s.onload=o=>{let a=o.target.result;n(a)},s.readAsArrayBuffer(t)}else{let s=t;n(s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength))}return r.promise}async upload(e){let t=r=>{let n=`Error occurred while processing '${this.privFilename}'. ${r}`;throw this.onEvent(new xe.AudioStreamNodeErrorEvent(this.privId,e,n)),new Error(n)};try{await this.turnOn();let r=await this.privAudioFormatPromise,n=new xe.ChunkedArrayBufferStream(r.avgBytesPerSec/10,e);this.privStreams[e]=n;let s=this.privSource.slice(this.privHeaderEnd),o=a=>{n.isClosed||(n.writeStreamChunk({buffer:a,isEnd:!1,timeReceived:Date.now()}),n.close())};if(typeof window<"u"&&typeof Blob<"u"&&s instanceof Blob){let a=new FileReader;a.onerror=c=>t(c.toString()),a.onload=c=>{let u=c.target.result;o(u)},a.readAsArrayBuffer(s)}else{let a=s;o(a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength))}return n}catch(r){t(r)}}onEvent(e){this.privEvents.onEvent(e),xe.Events.instance.onEvent(e)}};Ws.FileAudioSource=sh});var Um=p(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});Hs.PcmRecorder=void 0;var QI=P(),oh=class{constructor(e){this.privStopInputOnRelease=e}record(e,t,r){let s=new QI.RiffPcmEncoder(e.sampleRate,16e3),o=e.createMediaStreamSource(t),a=()=>{let u=(()=>{let h=0;try{return e.createScriptProcessor(h,1,1)}catch{h=2048;let v=e.sampleRate;for(;h<16384&&v>=32e3;)h<<=1,v>>=1;return e.createScriptProcessor(h,1,1)}})();u.onaudioprocess=h=>{let d=h.inputBuffer.getChannelData(0);if(r&&!r.isClosed){let v=s.encode(d);v&&r.writeStreamChunk({buffer:v,isEnd:!1,timeReceived:Date.now()})}},o.connect(u),u.connect(e.destination),this.privMediaResources={scriptProcessorNode:u,source:o,stream:t}},c=!!this.privSpeechProcessorScript&&this.privSpeechProcessorScript.toLowerCase()==="ignore";if(e.audioWorklet&&!c){if(!this.privSpeechProcessorScript){let u=`class SP extends AudioWorkletProcessor {
1
+ "use strict";(()=>{var BR=Object.create;var Wf=Object.defineProperty;var FR=Object.getOwnPropertyDescriptor;var VR=Object.getOwnPropertyNames;var UR=Object.getPrototypeOf,WR=Object.prototype.hasOwnProperty;var p=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var HR=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of VR(e))!WR.call(i,n)&&n!==t&&Wf(i,n,{get:()=>e[n],enumerable:!(r=FR(e,n))||r.enumerable});return i};var Hf=(i,e,t)=>(t=i!=null?BR(UR(i)):{},HR(e||!i||!i.__esModule?Wf(t,"default",{value:i,enumerable:!0}):t,i));var Lp=p(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});jp.default=vE;var es,lE=new Uint8Array(16);function vE(){if(!es&&(es=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!es))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return es(lE)}});var Sg=p(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.default=void 0;var fE=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;ts.default=fE});var Qi=p(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.default=void 0;var gE=mE(Sg());function mE(i){return i&&i.__esModule?i:{default:i}}function SE(i){return typeof i=="string"&&gE.default.test(i)}var yE=SE;rs.default=yE});var Xi=p(Yi=>{"use strict";Object.defineProperty(Yi,"__esModule",{value:!0});Yi.default=void 0;Yi.unsafeStringify=yg;var CE=PE(Qi());function PE(i){return i&&i.__esModule?i:{default:i}}var de=[];for(let i=0;i<256;++i)de.push((i+256).toString(16).slice(1));function yg(i,e=0){return de[i[e+0]]+de[i[e+1]]+de[i[e+2]]+de[i[e+3]]+"-"+de[i[e+4]]+de[i[e+5]]+"-"+de[i[e+6]]+de[i[e+7]]+"-"+de[i[e+8]]+de[i[e+9]]+"-"+de[i[e+10]]+de[i[e+11]]+de[i[e+12]]+de[i[e+13]]+de[i[e+14]]+de[i[e+15]]}function RE(i,e=0){let t=yg(i,e);if(!(0,CE.default)(t))throw TypeError("Stringified UUID is invalid");return t}var EE=RE;Yi.default=EE});var Pg=p(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.default=void 0;var IE=_E(Lp()),wE=Xi();function _E(i){return i&&i.__esModule?i:{default:i}}var Cg,Bp,Fp=0,Vp=0;function TE(i,e,t){let r=e&&t||0,n=e||new Array(16);i=i||{};let s=i.node||Cg,o=i.clockseq!==void 0?i.clockseq:Bp;if(s==null||o==null){let v=i.random||(i.rng||IE.default)();s==null&&(s=Cg=[v[0]|1,v[1],v[2],v[3],v[4],v[5]]),o==null&&(o=Bp=(v[6]<<8|v[7])&16383)}let a=i.msecs!==void 0?i.msecs:Date.now(),c=i.nsecs!==void 0?i.nsecs:Vp+1,u=a-Fp+(c-Vp)/1e4;if(u<0&&i.clockseq===void 0&&(o=o+1&16383),(u<0||a>Fp)&&i.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Fp=a,Vp=c,Bp=o,a+=122192928e5;let h=((a&268435455)*1e4+c)%4294967296;n[r++]=h>>>24&255,n[r++]=h>>>16&255,n[r++]=h>>>8&255,n[r++]=h&255;let d=a/4294967296*1e4&268435455;n[r++]=d>>>8&255,n[r++]=d&255,n[r++]=d>>>24&15|16,n[r++]=d>>>16&255,n[r++]=o>>>8|128,n[r++]=o&255;for(let v=0;v<6;++v)n[r+v]=s[v];return e||(0,wE.unsafeStringify)(n)}var AE=TE;is.default=AE});var Up=p(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.default=void 0;var bE=OE(Qi());function OE(i){return i&&i.__esModule?i:{default:i}}function ME(i){if(!(0,bE.default)(i))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(i.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(i.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(i.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(i.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(i.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var DE=ME;ns.default=DE});var Wp=p(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.URL=Rr.DNS=void 0;Rr.default=zE;var kE=Xi(),NE=qE(Up());function qE(i){return i&&i.__esModule?i:{default:i}}function xE(i){i=unescape(encodeURIComponent(i));let e=[];for(let t=0;t<i.length;++t)e.push(i.charCodeAt(t));return e}var Rg="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Rr.DNS=Rg;var Eg="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Rr.URL=Eg;function zE(i,e,t){function r(n,s,o,a){var c;if(typeof n=="string"&&(n=xE(n)),typeof s=="string"&&(s=(0,NE.default)(s)),((c=s)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+n.length);if(u.set(s),u.set(n,s.length),u=t(u),u[6]=u[6]&15|e,u[8]=u[8]&63|128,o){a=a||0;for(let h=0;h<16;++h)o[a+h]=u[h];return o}return(0,kE.unsafeStringify)(u)}try{r.name=i}catch{}return r.DNS=Rg,r.URL=Eg,r}});var wg=p(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});os.default=void 0;function jE(i){if(typeof i=="string"){let e=unescape(encodeURIComponent(i));i=new Uint8Array(e.length);for(let t=0;t<e.length;++t)i[t]=e.charCodeAt(t)}return LE(BE(FE(i),i.length*8))}function LE(i){let e=[],t=i.length*32,r="0123456789abcdef";for(let n=0;n<t;n+=8){let s=i[n>>5]>>>n%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);e.push(o)}return e}function Ig(i){return(i+64>>>9<<4)+14+1}function BE(i,e){i[e>>5]|=128<<e%32,i[Ig(e)-1]=e;let t=1732584193,r=-271733879,n=-1732584194,s=271733878;for(let o=0;o<i.length;o+=16){let a=t,c=r,u=n,h=s;t=Pe(t,r,n,s,i[o],7,-680876936),s=Pe(s,t,r,n,i[o+1],12,-389564586),n=Pe(n,s,t,r,i[o+2],17,606105819),r=Pe(r,n,s,t,i[o+3],22,-1044525330),t=Pe(t,r,n,s,i[o+4],7,-176418897),s=Pe(s,t,r,n,i[o+5],12,1200080426),n=Pe(n,s,t,r,i[o+6],17,-1473231341),r=Pe(r,n,s,t,i[o+7],22,-45705983),t=Pe(t,r,n,s,i[o+8],7,1770035416),s=Pe(s,t,r,n,i[o+9],12,-1958414417),n=Pe(n,s,t,r,i[o+10],17,-42063),r=Pe(r,n,s,t,i[o+11],22,-1990404162),t=Pe(t,r,n,s,i[o+12],7,1804603682),s=Pe(s,t,r,n,i[o+13],12,-40341101),n=Pe(n,s,t,r,i[o+14],17,-1502002290),r=Pe(r,n,s,t,i[o+15],22,1236535329),t=Re(t,r,n,s,i[o+1],5,-165796510),s=Re(s,t,r,n,i[o+6],9,-1069501632),n=Re(n,s,t,r,i[o+11],14,643717713),r=Re(r,n,s,t,i[o],20,-373897302),t=Re(t,r,n,s,i[o+5],5,-701558691),s=Re(s,t,r,n,i[o+10],9,38016083),n=Re(n,s,t,r,i[o+15],14,-660478335),r=Re(r,n,s,t,i[o+4],20,-405537848),t=Re(t,r,n,s,i[o+9],5,568446438),s=Re(s,t,r,n,i[o+14],9,-1019803690),n=Re(n,s,t,r,i[o+3],14,-187363961),r=Re(r,n,s,t,i[o+8],20,1163531501),t=Re(t,r,n,s,i[o+13],5,-1444681467),s=Re(s,t,r,n,i[o+2],9,-51403784),n=Re(n,s,t,r,i[o+7],14,1735328473),r=Re(r,n,s,t,i[o+12],20,-1926607734),t=Ee(t,r,n,s,i[o+5],4,-378558),s=Ee(s,t,r,n,i[o+8],11,-2022574463),n=Ee(n,s,t,r,i[o+11],16,1839030562),r=Ee(r,n,s,t,i[o+14],23,-35309556),t=Ee(t,r,n,s,i[o+1],4,-1530992060),s=Ee(s,t,r,n,i[o+4],11,1272893353),n=Ee(n,s,t,r,i[o+7],16,-155497632),r=Ee(r,n,s,t,i[o+10],23,-1094730640),t=Ee(t,r,n,s,i[o+13],4,681279174),s=Ee(s,t,r,n,i[o],11,-358537222),n=Ee(n,s,t,r,i[o+3],16,-722521979),r=Ee(r,n,s,t,i[o+6],23,76029189),t=Ee(t,r,n,s,i[o+9],4,-640364487),s=Ee(s,t,r,n,i[o+12],11,-421815835),n=Ee(n,s,t,r,i[o+15],16,530742520),r=Ee(r,n,s,t,i[o+2],23,-995338651),t=Ie(t,r,n,s,i[o],6,-198630844),s=Ie(s,t,r,n,i[o+7],10,1126891415),n=Ie(n,s,t,r,i[o+14],15,-1416354905),r=Ie(r,n,s,t,i[o+5],21,-57434055),t=Ie(t,r,n,s,i[o+12],6,1700485571),s=Ie(s,t,r,n,i[o+3],10,-1894986606),n=Ie(n,s,t,r,i[o+10],15,-1051523),r=Ie(r,n,s,t,i[o+1],21,-2054922799),t=Ie(t,r,n,s,i[o+8],6,1873313359),s=Ie(s,t,r,n,i[o+15],10,-30611744),n=Ie(n,s,t,r,i[o+6],15,-1560198380),r=Ie(r,n,s,t,i[o+13],21,1309151649),t=Ie(t,r,n,s,i[o+4],6,-145523070),s=Ie(s,t,r,n,i[o+11],10,-1120210379),n=Ie(n,s,t,r,i[o+2],15,718787259),r=Ie(r,n,s,t,i[o+9],21,-343485551),t=er(t,a),r=er(r,c),n=er(n,u),s=er(s,h)}return[t,r,n,s]}function FE(i){if(i.length===0)return[];let e=i.length*8,t=new Uint32Array(Ig(e));for(let r=0;r<e;r+=8)t[r>>5]|=(i[r/8]&255)<<r%32;return t}function er(i,e){let t=(i&65535)+(e&65535);return(i>>16)+(e>>16)+(t>>16)<<16|t&65535}function VE(i,e){return i<<e|i>>>32-e}function ss(i,e,t,r,n,s){return er(VE(er(er(e,i),er(r,s)),n),t)}function Pe(i,e,t,r,n,s,o){return ss(e&t|~e&r,i,e,n,s,o)}function Re(i,e,t,r,n,s,o){return ss(e&r|t&~r,i,e,n,s,o)}function Ee(i,e,t,r,n,s,o){return ss(e^t^r,i,e,n,s,o)}function Ie(i,e,t,r,n,s,o){return ss(t^(e|~r),i,e,n,s,o)}var UE=jE;os.default=UE});var Tg=p(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.default=void 0;var WE=_g(Wp()),HE=_g(wg());function _g(i){return i&&i.__esModule?i:{default:i}}var KE=(0,WE.default)("v3",48,HE.default),JE=KE;as.default=JE});var Ag=p(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.default=void 0;var GE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$E={randomUUID:GE};cs.default=$E});var Mg=p(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.default=void 0;var bg=Og(Ag()),QE=Og(Lp()),YE=Xi();function Og(i){return i&&i.__esModule?i:{default:i}}function XE(i,e,t){if(bg.default.randomUUID&&!e&&!i)return bg.default.randomUUID();i=i||{};let r=i.random||(i.rng||QE.default)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=r[n];return e}return(0,YE.unsafeStringify)(r)}var ZE=XE;ps.default=ZE});var Dg=p(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.default=void 0;function eI(i,e,t,r){switch(i){case 0:return e&t^~e&r;case 1:return e^t^r;case 2:return e&t^e&r^t&r;case 3:return e^t^r}}function Hp(i,e){return i<<e|i>>>32-e}function tI(i){let e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof i=="string"){let o=unescape(encodeURIComponent(i));i=[];for(let a=0;a<o.length;++a)i.push(o.charCodeAt(a))}else Array.isArray(i)||(i=Array.prototype.slice.call(i));i.push(128);let r=i.length/4+2,n=Math.ceil(r/16),s=new Array(n);for(let o=0;o<n;++o){let a=new Uint32Array(16);for(let c=0;c<16;++c)a[c]=i[o*64+c*4]<<24|i[o*64+c*4+1]<<16|i[o*64+c*4+2]<<8|i[o*64+c*4+3];s[o]=a}s[n-1][14]=(i.length-1)*8/Math.pow(2,32),s[n-1][14]=Math.floor(s[n-1][14]),s[n-1][15]=(i.length-1)*8&4294967295;for(let o=0;o<n;++o){let a=new Uint32Array(80);for(let g=0;g<16;++g)a[g]=s[o][g];for(let g=16;g<80;++g)a[g]=Hp(a[g-3]^a[g-8]^a[g-14]^a[g-16],1);let c=t[0],u=t[1],h=t[2],d=t[3],v=t[4];for(let g=0;g<80;++g){let w=Math.floor(g/20),k=Hp(c,5)+eI(w,u,h,d)+v+e[w]+a[g]>>>0;v=d,d=h,h=Hp(u,30)>>>0,u=c,c=k}t[0]=t[0]+c>>>0,t[1]=t[1]+u>>>0,t[2]=t[2]+h>>>0,t[3]=t[3]+d>>>0,t[4]=t[4]+v>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var rI=tI;us.default=rI});var Ng=p(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.default=void 0;var iI=kg(Wp()),nI=kg(Dg());function kg(i){return i&&i.__esModule?i:{default:i}}var sI=(0,iI.default)("v5",80,nI.default),oI=sI;hs.default=oI});var qg=p(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.default=void 0;var aI="00000000-0000-0000-0000-000000000000";ds.default=aI});var xg=p(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.default=void 0;var cI=pI(Qi());function pI(i){return i&&i.__esModule?i:{default:i}}function uI(i){if(!(0,cI.default)(i))throw TypeError("Invalid UUID");return parseInt(i.slice(14,15),16)}var hI=uI;ls.default=hI});var zg=p(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});Object.defineProperty(ut,"NIL",{enumerable:!0,get:function(){return gI.default}});Object.defineProperty(ut,"parse",{enumerable:!0,get:function(){return CI.default}});Object.defineProperty(ut,"stringify",{enumerable:!0,get:function(){return yI.default}});Object.defineProperty(ut,"v1",{enumerable:!0,get:function(){return dI.default}});Object.defineProperty(ut,"v3",{enumerable:!0,get:function(){return lI.default}});Object.defineProperty(ut,"v4",{enumerable:!0,get:function(){return vI.default}});Object.defineProperty(ut,"v5",{enumerable:!0,get:function(){return fI.default}});Object.defineProperty(ut,"validate",{enumerable:!0,get:function(){return SI.default}});Object.defineProperty(ut,"version",{enumerable:!0,get:function(){return mI.default}});var dI=xt(Pg()),lI=xt(Tg()),vI=xt(Mg()),fI=xt(Ng()),gI=xt(qg()),mI=xt(xg()),SI=xt(Qi()),yI=xt(Xi()),CI=xt(Up());function xt(i){return i&&i.__esModule?i:{default:i}}});var tr=p(oi=>{"use strict";Object.defineProperty(oi,"__esModule",{value:!0});oi.createNoDashGuid=oi.createGuid=void 0;var PI=zg(),jg=()=>PI.v4();oi.createGuid=jg;var RI=()=>jg().replace(new RegExp("-","g"),"").toUpperCase();oi.createNoDashGuid=RI});var ai=p(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.PlatformEvent=Er.EventType=void 0;var EI=tr(),II;(function(i){i[i.Debug=0]="Debug",i[i.Info=1]="Info",i[i.Warning=2]="Warning",i[i.Error=3]="Error",i[i.None=4]="None"})(II=Er.EventType||(Er.EventType={}));var Kp=class{constructor(e,t){this.privName=e,this.privEventId=EI.createNoDashGuid(),this.privEventTime=new Date().toISOString(),this.privEventType=t,this.privMetadata={}}get name(){return this.privName}get eventId(){return this.privEventId}get eventTime(){return this.privEventTime}get eventType(){return this.privEventType}get metadata(){return this.privMetadata}};Er.PlatformEvent=Kp});var Lg=p(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.AudioStreamNodeErrorEvent=X.AudioStreamNodeDetachedEvent=X.AudioStreamNodeAttachedEvent=X.AudioStreamNodeAttachingEvent=X.AudioStreamNodeEvent=X.AudioSourceErrorEvent=X.AudioSourceOffEvent=X.AudioSourceReadyEvent=X.AudioSourceInitializingEvent=X.AudioSourceEvent=void 0;var Jp=ai(),rr=class extends Jp.PlatformEvent{constructor(e,t,r=Jp.EventType.Info){super(e,r),this.privAudioSourceId=t}get audioSourceId(){return this.privAudioSourceId}};X.AudioSourceEvent=rr;var Gp=class extends rr{constructor(e){super("AudioSourceInitializingEvent",e)}};X.AudioSourceInitializingEvent=Gp;var $p=class extends rr{constructor(e){super("AudioSourceReadyEvent",e)}};X.AudioSourceReadyEvent=$p;var Qp=class extends rr{constructor(e){super("AudioSourceOffEvent",e)}};X.AudioSourceOffEvent=Qp;var Yp=class extends rr{constructor(e,t){super("AudioSourceErrorEvent",e,Jp.EventType.Error),this.privError=t}get error(){return this.privError}};X.AudioSourceErrorEvent=Yp;var Ir=class extends rr{constructor(e,t,r){super(e,t),this.privAudioNodeId=r}get audioNodeId(){return this.privAudioNodeId}};X.AudioStreamNodeEvent=Ir;var Xp=class extends Ir{constructor(e,t){super("AudioStreamNodeAttachingEvent",e,t)}};X.AudioStreamNodeAttachingEvent=Xp;var Zp=class extends Ir{constructor(e,t){super("AudioStreamNodeAttachedEvent",e,t)}};X.AudioStreamNodeAttachedEvent=Zp;var eu=class extends Ir{constructor(e,t){super("AudioStreamNodeDetachedEvent",e,t)}};X.AudioStreamNodeDetachedEvent=eu;var tu=class extends Ir{constructor(e,t,r){super("AudioStreamNodeErrorEvent",e,t),this.privError=r}get error(){return this.privError}};X.AudioStreamNodeErrorEvent=tu});var Bg=p(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.ConnectionMessageSentEvent=ie.ConnectionMessageReceivedEvent=ie.ConnectionEstablishErrorEvent=ie.ConnectionErrorEvent=ie.ConnectionClosedEvent=ie.ConnectionEstablishedEvent=ie.ConnectionStartEvent=ie.ConnectionEvent=ie.ServiceEvent=void 0;var wr=ai(),ru=class extends wr.PlatformEvent{constructor(e,t,r=wr.EventType.Info){super(e,r),this.privJsonResult=t}get jsonString(){return this.privJsonResult}};ie.ServiceEvent=ru;var Ct=class extends wr.PlatformEvent{constructor(e,t,r=wr.EventType.Info){super(e,r),this.privConnectionId=t}get connectionId(){return this.privConnectionId}};ie.ConnectionEvent=Ct;var iu=class extends Ct{constructor(e,t,r){super("ConnectionStartEvent",e),this.privUri=t,this.privHeaders=r}get uri(){return this.privUri}get headers(){return this.privHeaders}};ie.ConnectionStartEvent=iu;var nu=class extends Ct{constructor(e){super("ConnectionEstablishedEvent",e)}};ie.ConnectionEstablishedEvent=nu;var su=class extends Ct{constructor(e,t,r){super("ConnectionClosedEvent",e,wr.EventType.Debug),this.privReason=r,this.privStatusCode=t}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};ie.ConnectionClosedEvent=su;var ou=class extends Ct{constructor(e,t,r){super("ConnectionErrorEvent",e,wr.EventType.Debug),this.privMessage=t,this.privType=r}get message(){return this.privMessage}get type(){return this.privType}};ie.ConnectionErrorEvent=ou;var au=class extends Ct{constructor(e,t,r){super("ConnectionEstablishErrorEvent",e,wr.EventType.Error),this.privStatusCode=t,this.privReason=r}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};ie.ConnectionEstablishErrorEvent=au;var cu=class extends Ct{constructor(e,t,r){super("ConnectionMessageReceivedEvent",e),this.privNetworkReceivedTime=t,this.privMessage=r}get networkReceivedTime(){return this.privNetworkReceivedTime}get message(){return this.privMessage}};ie.ConnectionMessageReceivedEvent=cu;var pu=class extends Ct{constructor(e,t,r){super("ConnectionMessageSentEvent",e),this.privNetworkSentTime=t,this.privMessage=r}get networkSentTime(){return this.privNetworkSentTime}get message(){return this.privMessage}};ie.ConnectionMessageSentEvent=pu});var ht=p(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.ObjectDisposedError=ir.InvalidOperationError=ir.ArgumentNullError=void 0;var uu=class extends Error{constructor(e){super(e),this.name="ArgumentNull",this.message=e}};ir.ArgumentNullError=uu;var hu=class extends Error{constructor(e){super(e),this.name="InvalidOperation",this.message=e}};ir.InvalidOperationError=hu;var du=class extends Error{constructor(e,t){super(t),this.name=e+"ObjectDisposed",this.message=t}};ir.ObjectDisposedError=du});var vu=p(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.ConnectionMessage=Tr.MessageType=void 0;var vs=ht(),wI=tr(),_r;(function(i){i[i.Text=0]="Text",i[i.Binary=1]="Binary"})(_r=Tr.MessageType||(Tr.MessageType={}));var lu=class{constructor(e,t,r,n){if(this.privBody=null,e===_r.Text&&t&&typeof t!="string")throw new vs.InvalidOperationError("Payload must be a string");if(e===_r.Binary&&t&&!(t instanceof ArrayBuffer))throw new vs.InvalidOperationError("Payload must be ArrayBuffer");switch(this.privMessageType=e,this.privBody=t,this.privHeaders=r||{},this.privId=n||wI.createNoDashGuid(),this.messageType){case _r.Binary:this.privSize=this.binaryBody!==null?this.binaryBody.byteLength:0;break;case _r.Text:this.privSize=this.textBody.length}}get messageType(){return this.privMessageType}get headers(){return this.privHeaders}get body(){return this.privBody}get textBody(){if(this.privMessageType===_r.Binary)throw new vs.InvalidOperationError("Not supported for binary message");return this.privBody}get binaryBody(){if(this.privMessageType===_r.Text)throw new vs.InvalidOperationError("Not supported for text message");return this.privBody}get id(){return this.privId}};Tr.ConnectionMessage=lu});var Fg=p(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.ConnectionOpenResponse=void 0;var fu=class{constructor(e,t){this.privStatusCode=e,this.privReason=t}get statusCode(){return this.privStatusCode}get reason(){return this.privReason}};fs.ConnectionOpenResponse=fu});var Vg=p(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.DeferralMap=void 0;var gu=class{constructor(){this.privMap={}}add(e,t){this.privMap[e]=t}getId(e){return this.privMap[e]}complete(e,t){try{this.privMap[e].resolve(t)}catch(r){this.privMap[e].reject(r)}finally{this.privMap[e]=void 0}}};gs.DeferralMap=gu});var Su=p(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.SendingAgentContextMessageEvent=ci.DialogEvent=void 0;var Ug=ai(),ms=class extends Ug.PlatformEvent{constructor(e,t=Ug.EventType.Info){super(e,t)}};ci.DialogEvent=ms;var mu=class extends ms{constructor(e){super("SendingAgentContextMessageEvent"),this.privAgentConfig=e}get agentConfig(){return this.privAgentConfig}};ci.SendingAgentContextMessageEvent=mu});var Cu=p(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.EventSource=void 0;var _I=ht(),TI=tr(),yu=class{constructor(e){this.privEventListeners={},this.privIsDisposed=!1,this.privConsoleListener=void 0,this.privMetadata=e}onEvent(e){if(this.isDisposed())throw new _I.ObjectDisposedError("EventSource");if(this.metadata)for(let t in this.metadata)t&&e.metadata&&(e.metadata[t]||(e.metadata[t]=this.metadata[t]));for(let t in this.privEventListeners)t&&this.privEventListeners[t]&&this.privEventListeners[t](e)}attach(e){let t=TI.createNoDashGuid();return this.privEventListeners[t]=e,{detach:()=>(delete this.privEventListeners[t],Promise.resolve())}}attachListener(e){return this.attach(t=>e.onEvent(t))}attachConsoleListener(e){return this.privConsoleListener&&this.privConsoleListener.detach(),this.privConsoleListener=this.attach(t=>e.onEvent(t)),this.privConsoleListener}isDisposed(){return this.privIsDisposed}dispose(){this.privEventListeners=null,this.privIsDisposed=!0}get metadata(){return this.privMetadata}};Ss.EventSource=yu});var Wg=p(Cs=>{"use strict";Object.defineProperty(Cs,"__esModule",{value:!0});Cs.Events=void 0;var AI=ht(),bI=Cu(),ys=class i{static setEventSource(e){if(!e)throw new AI.ArgumentNullError("eventSource");i.privInstance=e}static get instance(){return i.privInstance}};Cs.Events=ys;ys.privInstance=new bI.EventSource});var Kg=p(Hg=>{"use strict";Object.defineProperty(Hg,"__esModule",{value:!0})});var Jg=p(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.ConnectionState=void 0;var OI;(function(i){i[i.None=0]="None",i[i.Connected=1]="Connected",i[i.Connecting=2]="Connecting",i[i.Disconnected=3]="Disconnected"})(OI=Zi.ConnectionState||(Zi.ConnectionState={}))});var $g=p(Gg=>{"use strict";Object.defineProperty(Gg,"__esModule",{value:!0})});var Yg=p(Qg=>{"use strict";Object.defineProperty(Qg,"__esModule",{value:!0})});var Zg=p(Xg=>{"use strict";Object.defineProperty(Xg,"__esModule",{value:!0})});var tm=p(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0})});var im=p(rm=>{"use strict";Object.defineProperty(rm,"__esModule",{value:!0})});var sm=p(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0})});var am=p(om=>{"use strict";Object.defineProperty(om,"__esModule",{value:!0})});var pm=p(cm=>{"use strict";Object.defineProperty(cm,"__esModule",{value:!0})});var Ru=p(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.List=void 0;var MI=ht(),Pu=class i{constructor(e){if(this.privSubscriptionIdCounter=0,this.privAddSubscriptions={},this.privRemoveSubscriptions={},this.privDisposedSubscriptions={},this.privDisposeReason=null,this.privList=[],e)for(let t of e)this.privList.push(t)}get(e){return this.throwIfDisposed(),this.privList[e]}first(){return this.get(0)}last(){return this.get(this.length()-1)}add(e){this.throwIfDisposed(),this.insertAt(this.privList.length,e)}insertAt(e,t){this.throwIfDisposed(),e===0?this.privList.unshift(t):e===this.privList.length?this.privList.push(t):this.privList.splice(e,0,t),this.triggerSubscriptions(this.privAddSubscriptions)}removeFirst(){return this.throwIfDisposed(),this.removeAt(0)}removeLast(){return this.throwIfDisposed(),this.removeAt(this.length()-1)}removeAt(e){return this.throwIfDisposed(),this.remove(e,1)[0]}remove(e,t){this.throwIfDisposed();let r=this.privList.splice(e,t);return this.triggerSubscriptions(this.privRemoveSubscriptions),r}clear(){this.throwIfDisposed(),this.remove(0,this.length())}length(){return this.throwIfDisposed(),this.privList.length}onAdded(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privAddSubscriptions[t]=e,{detach:()=>(delete this.privAddSubscriptions[t],Promise.resolve())}}onRemoved(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privRemoveSubscriptions[t]=e,{detach:()=>(delete this.privRemoveSubscriptions[t],Promise.resolve())}}onDisposed(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privDisposedSubscriptions[t]=e,{detach:()=>(delete this.privDisposedSubscriptions[t],Promise.resolve())}}join(e){return this.throwIfDisposed(),this.privList.join(e)}toArray(){let e=Array();return this.privList.forEach(t=>{e.push(t)}),e}any(e){return this.throwIfDisposed(),e?this.where(e).length()>0:this.length()>0}all(e){return this.throwIfDisposed(),this.where(e).length()===this.length()}forEach(e){this.throwIfDisposed();for(let t=0;t<this.length();t++)e(this.privList[t],t)}select(e){this.throwIfDisposed();let t=[];for(let r=0;r<this.privList.length;r++)t.push(e(this.privList[r],r));return new i(t)}where(e){this.throwIfDisposed();let t=new i;for(let r=0;r<this.privList.length;r++)e(this.privList[r],r)&&t.add(this.privList[r]);return t}orderBy(e){this.throwIfDisposed();let r=this.toArray().sort(e);return new i(r)}orderByDesc(e){return this.throwIfDisposed(),this.orderBy((t,r)=>e(r,t))}clone(){return this.throwIfDisposed(),new i(this.toArray())}concat(e){return this.throwIfDisposed(),new i(this.privList.concat(e.toArray()))}concatArray(e){return this.throwIfDisposed(),new i(this.privList.concat(e))}isDisposed(){return this.privList==null}dispose(e){this.isDisposed()||(this.privDisposeReason=e,this.privList=null,this.privAddSubscriptions=null,this.privRemoveSubscriptions=null,this.triggerSubscriptions(this.privDisposedSubscriptions))}throwIfDisposed(){if(this.isDisposed())throw new MI.ObjectDisposedError("List",this.privDisposeReason)}triggerSubscriptions(e){if(e)for(let t in e)t&&e[t]()}};Ps.List=Pu});var wu=p(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.marshalPromiseToCallbacks=De.Sink=De.Deferred=De.PromiseResultEventSource=De.PromiseResult=De.PromiseState=void 0;var zt;(function(i){i[i.None=0]="None",i[i.Resolved=1]="Resolved",i[i.Rejected=2]="Rejected"})(zt=De.PromiseState||(De.PromiseState={}));var Rs=class{constructor(e){this.throwIfError=()=>{if(this.isError)throw this.error},e.on(t=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!1,this.privResult=t)},t=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!0,this.privError=t)})}get isCompleted(){return this.privIsCompleted}get isError(){return this.privIsError}get error(){return this.privError}get result(){return this.privResult}};De.PromiseResult=Rs;var Es=class{constructor(){this.setResult=e=>{this.privOnSetResult(e)},this.setError=e=>{this.privOnSetError(e)},this.on=(e,t)=>{this.privOnSetResult=e,this.privOnSetError=t}}};De.PromiseResultEventSource=Es;var Eu=class{constructor(){this.resolve=e=>(this.privResolve(e),this),this.reject=e=>(this.privReject(e),this),this.privPromise=new Promise((e,t)=>{this.privResolve=e,this.privReject=t})}get promise(){return this.privPromise}};De.Deferred=Eu;var Iu=class{constructor(){this.privState=zt.None,this.privPromiseResult=null,this.privPromiseResultEvents=null,this.privSuccessHandlers=[],this.privErrorHandlers=[],this.privPromiseResultEvents=new Es,this.privPromiseResult=new Rs(this.privPromiseResultEvents)}get state(){return this.privState}get result(){return this.privPromiseResult}resolve(e){if(this.privState!==zt.None)throw new Error("'Cannot resolve a completed promise'");this.privState=zt.Resolved,this.privPromiseResultEvents.setResult(e);for(let t=0;t<this.privSuccessHandlers.length;t++)this.executeSuccessCallback(e,this.privSuccessHandlers[t],this.privErrorHandlers[t]);this.detachHandlers()}reject(e){if(this.privState!==zt.None)throw new Error("'Cannot reject a completed promise'");this.privState=zt.Rejected,this.privPromiseResultEvents.setError(e);for(let t of this.privErrorHandlers)this.executeErrorCallback(e,t);this.detachHandlers()}on(e,t){e==null&&(e=()=>{}),this.privState===zt.None?(this.privSuccessHandlers.push(e),this.privErrorHandlers.push(t)):(this.privState===zt.Resolved?this.executeSuccessCallback(this.privPromiseResult.result,e,t):this.privState===zt.Rejected&&this.executeErrorCallback(this.privPromiseResult.error,t),this.detachHandlers())}executeSuccessCallback(e,t,r){try{t(e)}catch(n){this.executeErrorCallback(`'Unhandled callback error: ${n}'`,r)}}executeErrorCallback(e,t){if(t)try{t(e)}catch(r){throw new Error(`'Unhandled callback error: ${r}. InnerError: ${e}'`)}else throw new Error(`'Unhandled error: ${e}'`)}detachHandlers(){this.privErrorHandlers=[],this.privSuccessHandlers=[]}};De.Sink=Iu;function DI(i,e,t){i.then(r=>{try{e&&e(r)}catch(n){if(t)try{if(n instanceof Error){let s=n;t(s.name+": "+s.message)}else t(n)}catch{}}},r=>{if(t)try{if(r instanceof Error){let n=r;t(n.name+": "+n.message)}else t(r)}catch{}})}De.marshalPromiseToCallbacks=DI});var bu=p(Is=>{"use strict";Object.defineProperty(Is,"__esModule",{value:!0});Is.Queue=void 0;var _u=ht(),Tu=Ru(),um=wu(),en;(function(i){i[i.Dequeue=0]="Dequeue",i[i.Peek=1]="Peek"})(en||(en={}));var Au=class{constructor(e){this.privPromiseStore=new Tu.List,this.privIsDrainInProgress=!1,this.privIsDisposing=!1,this.privDisposeReason=null,this.privList=e||new Tu.List,this.privDetachables=[],this.privSubscribers=new Tu.List,this.privDetachables.push(this.privList.onAdded(()=>this.drain()))}enqueue(e){this.throwIfDispose(),this.enqueueFromPromise(new Promise(t=>t(e)))}enqueueFromPromise(e){this.throwIfDispose(),e.then(t=>{this.privList.add(t)},()=>{})}dequeue(){this.throwIfDispose();let e=new um.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:en.Dequeue}),this.drain()),e.promise}peek(){this.throwIfDispose();let e=new um.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:en.Peek}),this.drain()),e.promise}length(){return this.throwIfDispose(),this.privList.length()}isDisposed(){return this.privSubscribers==null}async drainAndDispose(e,t){if(!this.isDisposed()&&!this.privIsDisposing){this.privDisposeReason=t,this.privIsDisposing=!0;let r=this.privSubscribers;if(r){for(;r.length()>0;)r.removeFirst().deferral.resolve(void 0);this.privSubscribers===r&&(this.privSubscribers=r)}for(let n of this.privDetachables)await n.detach();if(this.privPromiseStore.length()>0&&e){let n=[];return this.privPromiseStore.toArray().forEach(s=>{n.push(s)}),Promise.all(n).finally(()=>{this.privSubscribers=null,this.privList.forEach(s=>{e(s)}),this.privList=null}).then()}else this.privSubscribers=null,this.privList=null}}async dispose(e){await this.drainAndDispose(null,e)}drain(){if(!this.privIsDrainInProgress&&!this.privIsDisposing){this.privIsDrainInProgress=!0;let e=this.privSubscribers,t=this.privList;if(e&&t){for(;t.length()>0&&e.length()>0&&!this.privIsDisposing;){let r=e.removeFirst();if(r.type===en.Peek)r.deferral.resolve(t.first());else{let n=t.removeFirst();r.deferral.resolve(n)}}this.privSubscribers===e&&(this.privSubscribers=e),this.privList===t&&(this.privList=t)}this.privIsDrainInProgress=!1}}throwIfDispose(){if(this.isDisposed())throw this.privDisposeReason?new _u.InvalidOperationError(this.privDisposeReason):new _u.ObjectDisposedError("Queue");if(this.privIsDisposing)throw new _u.InvalidOperationError("Queue disposing")}};Is.Queue=Au});var hm=p(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.RawWebsocketMessage=void 0;var ws=vu(),tn=ht(),kI=tr(),Ou=class{constructor(e,t,r){if(this.privPayload=null,!t)throw new tn.ArgumentNullError("payload");if(e===ws.MessageType.Binary&&Object.getPrototypeOf(t).constructor.name!=="ArrayBuffer")throw new tn.InvalidOperationError("Payload must be ArrayBuffer");if(e===ws.MessageType.Text&&typeof t!="string")throw new tn.InvalidOperationError("Payload must be a string");this.privMessageType=e,this.privPayload=t,this.privId=r||kI.createNoDashGuid()}get messageType(){return this.privMessageType}get payload(){return this.privPayload}get textContent(){if(this.privMessageType===ws.MessageType.Binary)throw new tn.InvalidOperationError("Not supported for binary message");return this.privPayload}get binaryContent(){if(this.privMessageType===ws.MessageType.Text)throw new tn.InvalidOperationError("Not supported for text message");return this.privPayload}get id(){return this.privId}};_s.RawWebsocketMessage=Ou});var dm=p(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.RiffPcmEncoder=void 0;var Mu=class{constructor(e,t){this.privActualSampleRate=e,this.privDesiredSampleRate=t}encode(e){let t=this.downSampleAudioFrame(e,this.privActualSampleRate,this.privDesiredSampleRate);if(!t)return null;let r=t.length*2,n=new ArrayBuffer(r),s=new DataView(n);return this.floatTo16BitPCM(s,0,t),n}setString(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))}floatTo16BitPCM(e,t,r){for(let n=0;n<r.length;n++,t+=2){let s=Math.max(-1,Math.min(1,r[n]));e.setInt16(t,s<0?s*32768:s*32767,!0)}}downSampleAudioFrame(e,t,r){if(!e)return null;if(r===t||r>t)return e;let n=t/r,s=Math.round(e.length/n),o=new Float32Array(s),a=0,c=0;for(;c<s;){let u=Math.round((c+1)*n),h=0,d=0;for(;a<u&&a<e.length;)h+=e[a++],d++;o[c++]=h/d}return o}};Ts.RiffPcmEncoder=Mu});var fm=p(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});As.Stream=void 0;var lm=ht(),NI=tr(),vm=bu(),Du=class{constructor(e){this.privIsWriteEnded=!1,this.privIsReadEnded=!1,this.privId=e||NI.createNoDashGuid(),this.privReaderQueue=new vm.Queue}get isClosed(){return this.privIsWriteEnded}get isReadEnded(){return this.privIsReadEnded}get id(){return this.privId}close(){this.privIsWriteEnded||(this.writeStreamChunk({buffer:null,isEnd:!0,timeReceived:Date.now()}),this.privIsWriteEnded=!0)}writeStreamChunk(e){if(this.throwIfClosed(),!this.privReaderQueue.isDisposed())try{this.privReaderQueue.enqueue(e)}catch{}}read(){if(this.privIsReadEnded)throw new lm.InvalidOperationError("Stream read has already finished");return this.privReaderQueue.dequeue().then(async e=>((e===void 0||e.isEnd)&&await this.privReaderQueue.dispose("End of stream reached"),e))}readEnded(){this.privIsReadEnded||(this.privIsReadEnded=!0,this.privReaderQueue=new vm.Queue)}throwIfClosed(){if(this.privIsWriteEnded)throw new lm.InvalidOperationError("Stream closed")}};As.Stream=Du});var bs=p(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.TranslationStatus=void 0;var qI;(function(i){i[i.Success=0]="Success",i[i.Error=1]="Error"})(qI=rn.TranslationStatus||(rn.TranslationStatus={}))});var gm=p(Os=>{"use strict";Object.defineProperty(Os,"__esModule",{value:!0});Os.ChunkedArrayBufferStream=void 0;var xI=P(),ku=class extends xI.Stream{constructor(e,t){super(t),this.privTargetChunkSize=e,this.privNextBufferReadyBytes=0}writeStreamChunk(e){if(e.isEnd||this.privNextBufferReadyBytes===0&&e.buffer.byteLength===this.privTargetChunkSize){super.writeStreamChunk(e);return}let t=0;for(;t<e.buffer.byteLength;){this.privNextBufferToWrite===void 0&&(this.privNextBufferToWrite=new ArrayBuffer(this.privTargetChunkSize),this.privNextBufferStartTime=e.timeReceived);let r=Math.min(e.buffer.byteLength-t,this.privTargetChunkSize-this.privNextBufferReadyBytes),n=new Uint8Array(this.privNextBufferToWrite),s=new Uint8Array(e.buffer.slice(t,r+t));n.set(s,this.privNextBufferReadyBytes),this.privNextBufferReadyBytes+=r,t+=r,this.privNextBufferReadyBytes===this.privTargetChunkSize&&(super.writeStreamChunk({buffer:this.privNextBufferToWrite,isEnd:!1,timeReceived:this.privNextBufferStartTime}),this.privNextBufferReadyBytes=0,this.privNextBufferToWrite=void 0)}}close(){this.privNextBufferReadyBytes!==0&&!this.isClosed&&super.writeStreamChunk({buffer:this.privNextBufferToWrite.slice(0,this.privNextBufferReadyBytes),isEnd:!1,timeReceived:this.privNextBufferStartTime}),super.close()}};Os.ChunkedArrayBufferStream=ku});var Sm=p(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0})});var ym=p(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.Timeout=void 0;var Pt=class i{static load(){let e=new Map([[0,()=>{}]]),t=new Map,n="data:text/javascript;base64,"+btoa(`!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return a})),n.d(t,"d",(function(){return d}));const r=new Map,o=new Map,i=e=>{const t=r.get(e);if(void 0===t)throw new Error('There is no interval scheduled with the given id "'.concat(e,'".'));clearTimeout(t),r.delete(e)},u=e=>{const t=o.get(e);if(void 0===t)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(t),o.delete(e)},f=(e,t)=>{let n,r;if("performance"in self){const o=performance.now();n=o,r=e-Math.max(0,o-t)}else n=Date.now(),r=e;return{expected:n+r,remainingDelay:r}},c=(e,t,n,r)=>{const o="performance"in self?performance.now():Date.now();o>n?postMessage({id:null,method:"call",params:{timerId:t}}):e.set(t,setTimeout(c,n-o,e,t,n))},a=(e,t,n)=>{const{expected:o,remainingDelay:i}=f(e,n);r.set(t,setTimeout(c,i,r,t,o))},d=(e,t,n)=>{const{expected:r,remainingDelay:i}=f(e,n);o.set(t,setTimeout(c,i,o,t,r))}},function(e,t,n){"use strict";n.r(t);var r=n(2);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(3);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(4);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o);var f=n(5);for(var o in f)"default"!==o&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var c=n(6);for(var o in c)"default"!==o&&function(e){n.d(t,e,(function(){return c[e]}))}(o);var a=n(7);for(var o in a)"default"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var d=n(8);for(var o in d)"default"!==o&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var s=n(9);for(var o in s)"default"!==o&&function(e){n.d(t,e,(function(){return s[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(11);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(12);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(13);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(1);for(var i in o)"default"!==i&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var u=n(10);for(var i in u)"default"!==i&&function(e){n.d(t,e,(function(){return u[e]}))}(i);addEventListener("message",({data:e})=>{try{if("clear"===e.method){const{id:t,params:{timerId:n}}=e;Object(r.b)(n),postMessage({error:null,id:t})}else{if("set"!==e.method)throw new Error('The given method "'.concat(e.method,'" is not supported'));{const{params:{delay:t,now:n,timerId:o}}=e;Object(r.d)(t,o,n)}}}catch(t){postMessage({error:{message:t.message},id:e.id,result:null})}})}]);`),s=new Worker(n);return s.addEventListener("message",({data:c})=>{if(i.isCallNotification(c)){let{params:{timerId:u}}=c,h=e.get(u);if(typeof h=="number"){let d=t.get(h);if(d===void 0||d!==u)throw new Error("The timer is in an undefined state.")}else if(typeof h<"u")h(),e.delete(u);else throw new Error("The timer is in an undefined state.")}else if(i.isClearResponse(c)){let{id:u}=c,h=t.get(u);if(h===void 0)throw new Error("The timer is in an undefined state.");t.delete(u),e.delete(h)}else{let{error:{message:u}}=c;throw new Error(u)}}),{clearTimeout:c=>{let u=Math.random();t.set(u,c),e.set(c,u),s.postMessage({id:u,method:"clear",params:{timerId:c}})},setTimeout:(c,u)=>{let h=Math.random();return e.set(h,c),s.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:h}}),h}}}static loadWorkerTimers(){return()=>(i.workerTimers!==null||(i.workerTimers=i.load()),i.workerTimers)}static isCallNotification(e){return e.method!==void 0&&e.method==="call"}static isClearResponse(e){return e.error===null&&typeof e.id=="number"}};Ms.Timeout=Pt;Pt.workerTimers=null;Pt.clearTimeout=i=>Pt.timers().clearTimeout(i);Pt.setTimeout=(i,e)=>Pt.timers().setTimeout(i,e);Pt.timers=Pt.loadWorkerTimers()});var Cm=p(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.OCSPCacheUpdateErrorEvent=M.OCSPResponseRetrievedEvent=M.OCSPCacheFetchErrorEvent=M.OCSPVerificationFailedEvent=M.OCSPCacheHitEvent=M.OCSPCacheEntryNeedsRefreshEvent=M.OCSPCacheEntryExpiredEvent=M.OCSPWSUpgradeStartedEvent=M.OCSPStapleReceivedEvent=M.OCSPCacheUpdateCompleteEvent=M.OCSPDiskCacheStoreEvent=M.OCSPMemoryCacheStoreEvent=M.OCSPCacheUpdateNeededEvent=M.OCSPDiskCacheHitEvent=M.OCSPCacheMissEvent=M.OCSPMemoryCacheHitEvent=M.OCSPEvent=void 0;var le=ai(),ce=class extends le.PlatformEvent{constructor(e,t,r){super(e,t),this.privSignature=r}};M.OCSPEvent=ce;var Nu=class extends ce{constructor(e){super("OCSPMemoryCacheHitEvent",le.EventType.Debug,e)}};M.OCSPMemoryCacheHitEvent=Nu;var qu=class extends ce{constructor(e){super("OCSPCacheMissEvent",le.EventType.Debug,e)}};M.OCSPCacheMissEvent=qu;var xu=class extends ce{constructor(e){super("OCSPDiskCacheHitEvent",le.EventType.Debug,e)}};M.OCSPDiskCacheHitEvent=xu;var zu=class extends ce{constructor(e){super("OCSPCacheUpdateNeededEvent",le.EventType.Debug,e)}};M.OCSPCacheUpdateNeededEvent=zu;var ju=class extends ce{constructor(e){super("OCSPMemoryCacheStoreEvent",le.EventType.Debug,e)}};M.OCSPMemoryCacheStoreEvent=ju;var Lu=class extends ce{constructor(e){super("OCSPDiskCacheStoreEvent",le.EventType.Debug,e)}};M.OCSPDiskCacheStoreEvent=Lu;var Bu=class extends ce{constructor(e){super("OCSPCacheUpdateCompleteEvent",le.EventType.Debug,e)}};M.OCSPCacheUpdateCompleteEvent=Bu;var Fu=class extends ce{constructor(){super("OCSPStapleReceivedEvent",le.EventType.Debug,"")}};M.OCSPStapleReceivedEvent=Fu;var Vu=class extends ce{constructor(e){super("OCSPWSUpgradeStartedEvent",le.EventType.Debug,e)}};M.OCSPWSUpgradeStartedEvent=Vu;var Uu=class extends ce{constructor(e,t){super("OCSPCacheEntryExpiredEvent",le.EventType.Debug,e),this.privExpireTime=t}};M.OCSPCacheEntryExpiredEvent=Uu;var Wu=class extends ce{constructor(e,t,r){super("OCSPCacheEntryNeedsRefreshEvent",le.EventType.Debug,e),this.privExpireTime=r,this.privStartTime=t}};M.OCSPCacheEntryNeedsRefreshEvent=Wu;var Hu=class extends ce{constructor(e,t,r){super("OCSPCacheHitEvent",le.EventType.Debug,e),this.privExpireTime=r,this.privExpireTimeString=new Date(r).toLocaleDateString(),this.privStartTime=t,this.privStartTimeString=new Date(t).toLocaleTimeString()}};M.OCSPCacheHitEvent=Hu;var Ku=class extends ce{constructor(e,t){super("OCSPVerificationFailedEvent",le.EventType.Debug,e),this.privError=t}};M.OCSPVerificationFailedEvent=Ku;var Ju=class extends ce{constructor(e,t){super("OCSPCacheFetchErrorEvent",le.EventType.Debug,e),this.privError=t}};M.OCSPCacheFetchErrorEvent=Ju;var Gu=class extends ce{constructor(e){super("OCSPResponseRetrievedEvent",le.EventType.Debug,e)}};M.OCSPResponseRetrievedEvent=Gu;var $u=class extends ce{constructor(e,t){super("OCSPCacheUpdateErrorEvent",le.EventType.Debug,e),this.privError=t}};M.OCSPCacheUpdateErrorEvent=$u});var Rm=p(Ds=>{"use strict";Object.defineProperty(Ds,"__esModule",{value:!0});Ds.BackgroundEvent=void 0;var Pm=P(),Qu=class extends Pm.PlatformEvent{constructor(e){super("BackgroundEvent",Pm.EventType.Error),this.privError=e}get error(){return this.privError}};Ds.BackgroundEvent=Qu});var P=p(b=>{"use strict";var zI=b&&b.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),N=b&&b.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&zI(e,i,t)};Object.defineProperty(b,"__esModule",{value:!0});N(Lg(),b);N(Bg(),b);N(vu(),b);N(Fg(),b);N(Vg(),b);N(Su(),b);N(ht(),b);N(Wg(),b);N(Cu(),b);N(tr(),b);N(Kg(),b);N(Jg(),b);N($g(),b);N(Yg(),b);N(Zg(),b);N(tm(),b);N(im(),b);N(sm(),b);N(am(),b);N(pm(),b);N(Ru(),b);N(ai(),b);N(wu(),b);N(bu(),b);N(hm(),b);N(dm(),b);N(fm(),b);var jI=bs();Object.defineProperty(b,"TranslationStatus",{enumerable:!0,get:function(){return jI.TranslationStatus}});N(gm(),b);N(Sm(),b);N(ym(),b);N(Cm(),b);N(Rm(),b)});var we=p(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.HeaderNames=void 0;var Ve=class{};ks.HeaderNames=Ve;Ve.AuthKey="Ocp-Apim-Subscription-Key";Ve.Authorization="Authorization";Ve.SpIDAuthKey="Apim-Subscription-Id";Ve.ConnectionId="X-ConnectionId";Ve.ContentType="Content-Type";Ve.CustomCommandsAppId="X-CommandsAppId";Ve.Path="Path";Ve.RequestId="X-RequestId";Ve.RequestStreamId="X-StreamId";Ve.RequestTimestamp="X-Timestamp"});var qs=p(Ns=>{"use strict";Object.defineProperty(Ns,"__esModule",{value:!0});Ns.AuthInfo=void 0;var Yu=class{constructor(e,t){this.privHeaderName=e,this.privToken=t}get headerName(){return this.privHeaderName}get token(){return this.privToken}};Ns.AuthInfo=Yu});var Em=p(xs=>{"use strict";Object.defineProperty(xs,"__esModule",{value:!0});xs.CognitiveSubscriptionKeyAuthentication=void 0;var LI=P(),BI=we(),FI=qs(),Xu=class{constructor(e){if(!e)throw new LI.ArgumentNullError("subscriptionKey");this.privAuthInfo=new FI.AuthInfo(BI.HeaderNames.AuthKey,e)}fetch(e){return Promise.resolve(this.privAuthInfo)}fetchOnExpiry(e){return Promise.resolve(this.privAuthInfo)}};xs.CognitiveSubscriptionKeyAuthentication=Xu});var Tm=p(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.CognitiveTokenAuthentication=void 0;var Im=P(),wm=qs(),_m=we(),zs=class i{constructor(e,t){if(!e)throw new Im.ArgumentNullError("fetchCallback");if(!t)throw new Im.ArgumentNullError("fetchOnExpiryCallback");this.privFetchCallback=e,this.privFetchOnExpiryCallback=t}fetch(e){return this.privFetchCallback(e).then(t=>new wm.AuthInfo(_m.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}fetchOnExpiry(e){return this.privFetchOnExpiryCallback(e).then(t=>new wm.AuthInfo(_m.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}};js.CognitiveTokenAuthentication=zs;zs.privTokenPrefix="Bearer "});var bm=p(Am=>{"use strict";Object.defineProperty(Am,"__esModule",{value:!0})});var Mm=p(Om=>{"use strict";Object.defineProperty(Om,"__esModule",{value:!0})});var Zu=p(()=>{});var eh=p(Ls=>{"use strict";Object.defineProperty(Ls,"__esModule",{value:!0});Ls.LogLevel=void 0;var VI=P();Object.defineProperty(Ls,"LogLevel",{enumerable:!0,get:function(){return VI.EventType}})});var I=p(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.Contracts=void 0;var th=class i{static throwIfNullOrUndefined(e,t){if(e==null)throw new Error("throwIfNullOrUndefined:"+t)}static throwIfNull(e,t){if(e===null)throw new Error("throwIfNull:"+t)}static throwIfNullOrWhitespace(e,t){if(i.throwIfNullOrUndefined(e,t),(""+e).trim().length<1)throw new Error("throwIfNullOrWhitespace:"+t)}static throwIfNullOrTooLong(e,t,r){if(i.throwIfNullOrUndefined(e,t),(""+e).length>r)throw new Error("throwIfNullOrTooLong:"+t+" (more than "+r.toString()+" characters)")}static throwIfNullOrTooShort(e,t,r){if(i.throwIfNullOrUndefined(e,t),(""+e).length<r)throw new Error("throwIfNullOrTooShort:"+t+" (less than "+r.toString()+" characters)")}static throwIfDisposed(e){if(e)throw new Error("the object is already disposed")}static throwIfArrayEmptyOrWhitespace(e,t){if(i.throwIfNullOrUndefined(e,t),e.length===0)throw new Error("throwIfArrayEmptyOrWhitespace:"+t);for(let r of e)i.throwIfNullOrWhitespace(r,t)}static throwIfFileDoesNotExist(e,t){i.throwIfNullOrWhitespace(e,t)}static throwIfNotUndefined(e,t){if(e!==void 0)throw new Error("throwIfNotUndefined:"+t)}};Bs.Contracts=th});var km=p(Rt=>{"use strict";var UI=Rt&&Rt.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),WI=Rt&&Rt.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),HI=Rt&&Rt.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&UI(e,i,t);return WI(e,i),e};Object.defineProperty(Rt,"__esModule",{value:!0});Rt.ConsoleLoggingListener=void 0;var Dm=HI(Zu()),nn=eh(),KI=I(),rh=class{constructor(e=nn.LogLevel.None){this.privLogPath=void 0,this.privEnableConsoleOutput=!0,this.privLogLevelFilter=e}set logPath(e){KI.Contracts.throwIfNullOrUndefined(Dm.openSync,`
2
+ File System access not available`),this.privLogPath=e}set enableConsoleOutput(e){this.privEnableConsoleOutput=e}onEvent(e){if(e.eventType>=this.privLogLevelFilter){let t=this.toString(e);if(this.logCallback&&this.logCallback(t),this.privLogPath&&Dm.writeFileSync(this.privLogPath,t+`
3
+ `,{flag:"a+"}),this.privEnableConsoleOutput)switch(e.eventType){case nn.LogLevel.Debug:console.debug(t);break;case nn.LogLevel.Info:console.info(t);break;case nn.LogLevel.Warning:console.warn(t);break;case nn.LogLevel.Error:console.error(t);break;default:console.log(t);break}}}toString(e){let t=[`${e.eventTime}`,`${e.name}`],r=e;for(let n in r)if(n&&e.hasOwnProperty(n)&&n!=="eventTime"&&n!=="eventType"&&n!=="eventId"&&n!=="name"&&n!=="constructor"){let s=r[n],o="<NULL>";s!=null&&(typeof s=="number"||typeof s=="string"?o=s.toString():o=JSON.stringify(s)),t.push(`${n}: ${o}`)}return t.join(" | ")}};Rt.ConsoleLoggingListener=rh});var qm=p(Nm=>{"use strict";Object.defineProperty(Nm,"__esModule",{value:!0})});var nr=p(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.AudioStreamFormatImpl=jt.AudioStreamFormat=jt.AudioFormatTag=void 0;var sn;(function(i){i[i.PCM=1]="PCM",i[i.MuLaw=2]="MuLaw",i[i.Siren=3]="Siren",i[i.MP3=4]="MP3",i[i.SILKSkype=5]="SILKSkype",i[i.OGG_OPUS=6]="OGG_OPUS",i[i.WEBM_OPUS=7]="WEBM_OPUS",i[i.ALaw=8]="ALaw",i[i.FLAC=9]="FLAC",i[i.OPUS=10]="OPUS"})(sn=jt.AudioFormatTag||(jt.AudioFormatTag={}));var Fs=class{static getDefaultInputFormat(){return pi.getDefaultInputFormat()}static getWaveFormat(e,t,r,n){return new pi(e,t,r,n)}static getWaveFormatPCM(e,t,r){return new pi(e,t,r)}};jt.AudioStreamFormat=Fs;var pi=class i extends Fs{constructor(e=16e3,t=16,r=1,n=sn.PCM){super();let s=!0;switch(n){case sn.PCM:this.formatTag=1;break;case sn.ALaw:this.formatTag=6;break;case sn.MuLaw:this.formatTag=7;break;default:s=!1}if(this.bitsPerSample=t,this.samplesPerSec=e,this.channels=r,this.avgBytesPerSec=this.samplesPerSec*this.channels*(this.bitsPerSample/8),this.blockAlign=this.channels*Math.max(this.bitsPerSample,8),s){this.privHeader=new ArrayBuffer(44);let o=new DataView(this.privHeader);this.setString(o,0,"RIFF"),o.setUint32(4,0,!0),this.setString(o,8,"WAVEfmt "),o.setUint32(16,16,!0),o.setUint16(20,this.formatTag,!0),o.setUint16(22,this.channels,!0),o.setUint32(24,this.samplesPerSec,!0),o.setUint32(28,this.avgBytesPerSec,!0),o.setUint16(32,this.channels*(this.bitsPerSample/8),!0),o.setUint16(34,this.bitsPerSample,!0),this.setString(o,36,"data"),o.setUint32(40,0,!0)}}static getDefaultInputFormat(){return new i}static getAudioContext(e){let t=window.AudioContext||window.webkitAudioContext||!1;if(t)return e!==void 0&&navigator.mediaDevices.getSupportedConstraints().sampleRate?new t({sampleRate:e}):new t;throw new Error("Browser does not support Web Audio API (AudioContext is not available).")}close(){}get header(){return this.privHeader}setString(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))}};jt.AudioStreamFormatImpl=pi});var jm=p(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.MicAudioSource=Ar.AudioWorkletSourceURLPropertyName=void 0;var xm=C(),ve=P(),zm=nr();Ar.AudioWorkletSourceURLPropertyName="MICROPHONE-WorkletSourceUrl";var Vs=class i{constructor(e,t,r,n){this.privRecorder=e,this.deviceId=t,this.privStreams={},this.privOutputChunkSize=i.AUDIOFORMAT.avgBytesPerSec/10,this.privId=r||ve.createNoDashGuid(),this.privEvents=new ve.EventSource,this.privMediaStream=n||null,this.privIsClosing=!1}get format(){return Promise.resolve(i.AUDIOFORMAT)}turnOn(){if(this.privInitializeDeferral)return this.privInitializeDeferral.promise;this.privInitializeDeferral=new ve.Deferred;try{this.createAudioContext()}catch(r){if(r instanceof Error){let n=r;this.privInitializeDeferral.reject(n.name+": "+n.message)}else this.privInitializeDeferral.reject(r);return this.privInitializeDeferral.promise}let e=window.navigator,t=e.getUserMedia||e.webkitGetUserMedia||e.mozGetUserMedia||e.msGetUserMedia;if(e.mediaDevices&&(t=(r,n,s)=>{e.mediaDevices.getUserMedia(r).then(n).catch(s)}),t){let r=()=>{this.onEvent(new ve.AudioSourceInitializingEvent(this.privId)),this.privMediaStream&&this.privMediaStream.active?(this.onEvent(new ve.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()):t({audio:this.deviceId?{deviceId:this.deviceId}:!0,video:!1},n=>{this.privMediaStream=n,this.onEvent(new ve.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()},n=>{let s=`Error occurred during microphone initialization: ${n}`;this.privInitializeDeferral.reject(s),this.onEvent(new ve.AudioSourceErrorEvent(this.privId,s))})};this.privContext.state==="suspended"?this.privContext.resume().then(r).catch(n=>{this.privInitializeDeferral.reject(`Failed to initialize audio context: ${n}`)}):r()}else{let r="Browser does not support getUserMedia.";this.privInitializeDeferral.reject(r),this.onEvent(new ve.AudioSourceErrorEvent(r,""))}return this.privInitializeDeferral.promise}id(){return this.privId}attach(e){return this.onEvent(new ve.AudioStreamNodeAttachingEvent(this.privId,e)),this.listen(e).then(t=>(this.onEvent(new ve.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(t.readEnded(),delete this.privStreams[e],this.onEvent(new ve.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}))}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new ve.AudioStreamNodeDetachedEvent(this.privId,e)))}async turnOff(){for(let e in this.privStreams)if(e){let t=this.privStreams[e];t&&t.close()}this.onEvent(new ve.AudioSourceOffEvent(this.privId)),this.privInitializeDeferral&&(await this.privInitializeDeferral,this.privInitializeDeferral=null),await this.destroyAudioContext()}get events(){return this.privEvents}get deviceInfo(){return this.getMicrophoneLabel().then(e=>({bitspersample:i.AUDIOFORMAT.bitsPerSample,channelcount:i.AUDIOFORMAT.channels,connectivity:xm.connectivity.Unknown,manufacturer:"Speech SDK",model:e,samplerate:i.AUDIOFORMAT.samplesPerSec,type:xm.type.Microphones}))}setProperty(e,t){if(e===Ar.AudioWorkletSourceURLPropertyName)this.privRecorder.setWorkletUrl(t);else throw new Error("Property '"+e+"' is not supported on Microphone.")}getMicrophoneLabel(){let e="microphone";if(this.privMicrophoneLabel!==void 0)return Promise.resolve(this.privMicrophoneLabel);if(this.privMediaStream===void 0||!this.privMediaStream.active)return Promise.resolve(e);this.privMicrophoneLabel=e;let t=this.privMediaStream.getTracks()[0].getSettings().deviceId;if(t===void 0)return Promise.resolve(this.privMicrophoneLabel);let r=new ve.Deferred;return navigator.mediaDevices.enumerateDevices().then(n=>{for(let s of n)if(s.deviceId===t){this.privMicrophoneLabel=s.label;break}r.resolve(this.privMicrophoneLabel)},()=>r.resolve(this.privMicrophoneLabel)),r.promise}async listen(e){await this.turnOn();let t=new ve.ChunkedArrayBufferStream(this.privOutputChunkSize,e);this.privStreams[e]=t;try{this.privRecorder.record(this.privContext,this.privMediaStream,t)}catch(n){throw this.onEvent(new ve.AudioStreamNodeErrorEvent(this.privId,e,n)),n}return t}onEvent(e){this.privEvents.onEvent(e),ve.Events.instance.onEvent(e)}createAudioContext(){this.privContext||(this.privContext=zm.AudioStreamFormatImpl.getAudioContext(i.AUDIOFORMAT.samplesPerSec))}async destroyAudioContext(){if(!this.privContext)return;this.privRecorder.releaseMediaResources(this.privContext);let e=!1;"close"in this.privContext&&(e=!0),e?this.privIsClosing||(this.privIsClosing=!0,await this.privContext.close(),this.privContext=null,this.privIsClosing=!1):this.privContext!==null&&this.privContext.state==="running"&&await this.privContext.suspend()}};Ar.MicAudioSource=Vs;Vs.AUDIOFORMAT=zm.AudioStreamFormat.getDefaultInputFormat()});var Bm=p(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});Us.FileAudioSource=void 0;var Lm=C(),xe=P(),JI=nr(),ih=class{constructor(e,t,r){this.privStreams={},this.privHeaderEnd=44,this.privId=r||xe.createNoDashGuid(),this.privEvents=new xe.EventSource,this.privSource=e,typeof window<"u"&&typeof Blob<"u"&&this.privSource instanceof Blob?this.privFilename=e.name:this.privFilename=t||"unknown.wav",this.privAudioFormatPromise=this.readHeader()}get format(){return this.privAudioFormatPromise}turnOn(){if(this.privFilename.lastIndexOf(".wav")!==this.privFilename.length-4){let e=this.privFilename+" is not supported. Only WAVE files are allowed at the moment.";return this.onEvent(new xe.AudioSourceErrorEvent(e,"")),Promise.reject(e)}this.onEvent(new xe.AudioSourceInitializingEvent(this.privId)),this.onEvent(new xe.AudioSourceReadyEvent(this.privId))}id(){return this.privId}async attach(e){this.onEvent(new xe.AudioStreamNodeAttachingEvent(this.privId,e));let t=await this.upload(e);return this.onEvent(new xe.AudioStreamNodeAttachedEvent(this.privId,e)),Promise.resolve({detach:async()=>{t.readEnded(),delete this.privStreams[e],this.onEvent(new xe.AudioStreamNodeDetachedEvent(this.privId,e)),await this.turnOff()},id:()=>e,read:()=>t.read()})}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new xe.AudioStreamNodeDetachedEvent(this.privId,e)))}turnOff(){for(let e in this.privStreams)if(e){let t=this.privStreams[e];t&&!t.isClosed&&t.close()}return this.onEvent(new xe.AudioSourceOffEvent(this.privId)),Promise.resolve()}get events(){return this.privEvents}get deviceInfo(){return this.privAudioFormatPromise.then(e=>Promise.resolve({bitspersample:e.bitsPerSample,channelcount:e.channels,connectivity:Lm.connectivity.Unknown,manufacturer:"Speech SDK",model:"File",samplerate:e.samplesPerSec,type:Lm.type.File}))}readHeader(){let t=this.privSource.slice(0,4296),r=new xe.Deferred,n=s=>{let o=new DataView(s),a=g=>String.fromCharCode(o.getUint8(g),o.getUint8(g+1),o.getUint8(g+2),o.getUint8(g+3));if(a(0)!=="RIFF"){r.reject("Invalid WAV header in file, RIFF was not found");return}if(a(8)!=="WAVE"||a(12)!=="fmt "){r.reject("Invalid WAV header in file, WAVEfmt was not found");return}let c=o.getInt32(16,!0),u=o.getUint16(22,!0),h=o.getUint32(24,!0),d=o.getUint16(34,!0),v=36+Math.max(c-16,0);for(;a(v)!=="data";v+=2)if(v>4288){r.reject("Invalid WAV header in file, data block was not found");return}this.privHeaderEnd=v+8,r.resolve(JI.AudioStreamFormat.getWaveFormatPCM(h,d,u))};if(typeof window<"u"&&typeof Blob<"u"&&t instanceof Blob){let s=new FileReader;s.onload=o=>{let a=o.target.result;n(a)},s.readAsArrayBuffer(t)}else{let s=t;n(s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength))}return r.promise}async upload(e){let t=r=>{let n=`Error occurred while processing '${this.privFilename}'. ${r}`;throw this.onEvent(new xe.AudioStreamNodeErrorEvent(this.privId,e,n)),new Error(n)};try{await this.turnOn();let r=await this.privAudioFormatPromise,n=new xe.ChunkedArrayBufferStream(r.avgBytesPerSec/10,e);this.privStreams[e]=n;let s=this.privSource.slice(this.privHeaderEnd),o=a=>{n.isClosed||(n.writeStreamChunk({buffer:a,isEnd:!1,timeReceived:Date.now()}),n.close())};if(typeof window<"u"&&typeof Blob<"u"&&s instanceof Blob){let a=new FileReader;a.onerror=c=>t(c.toString()),a.onload=c=>{let u=c.target.result;o(u)},a.readAsArrayBuffer(s)}else{let a=s;o(a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength))}return n}catch(r){t(r)}}onEvent(e){this.privEvents.onEvent(e),xe.Events.instance.onEvent(e)}};Us.FileAudioSource=ih});var Fm=p(Ws=>{"use strict";Object.defineProperty(Ws,"__esModule",{value:!0});Ws.PcmRecorder=void 0;var GI=P(),nh=class{constructor(e){this.privStopInputOnRelease=e}record(e,t,r){let s=new GI.RiffPcmEncoder(e.sampleRate,16e3),o=e.createMediaStreamSource(t),a=()=>{let u=(()=>{let h=0;try{return e.createScriptProcessor(h,1,1)}catch{h=2048;let v=e.sampleRate;for(;h<16384&&v>=32e3;)h<<=1,v>>=1;return e.createScriptProcessor(h,1,1)}})();u.onaudioprocess=h=>{let d=h.inputBuffer.getChannelData(0);if(r&&!r.isClosed){let v=s.encode(d);v&&r.writeStreamChunk({buffer:v,isEnd:!1,timeReceived:Date.now()})}},o.connect(u),u.connect(e.destination),this.privMediaResources={scriptProcessorNode:u,source:o,stream:t}},c=!!this.privSpeechProcessorScript&&this.privSpeechProcessorScript.toLowerCase()==="ignore";if(e.audioWorklet&&!c){if(!this.privSpeechProcessorScript){let u=`class SP extends AudioWorkletProcessor {
4
4
  constructor(options) {
5
5
  super(options);
6
6
  }
@@ -14,18 +14,18 @@ File System access not available`),this.privLogPath=e}set enableConsoleOutput(e)
14
14
  return true;
15
15
  }
16
16
  }
17
- registerProcessor('speech-processor', SP);`,h=new Blob([u],{type:"application/javascript; charset=utf-8"});this.privSpeechProcessorScript=URL.createObjectURL(h)}e.audioWorklet.addModule(this.privSpeechProcessorScript).then(()=>{let u=new AudioWorkletNode(e,"speech-processor");u.port.onmessage=h=>{let d=h.data;if(r&&!r.isClosed){let v=s.encode(d);v&&r.writeStreamChunk({buffer:v,isEnd:!1,timeReceived:Date.now()})}},o.connect(u),u.connect(e.destination),this.privMediaResources={scriptProcessorNode:u,source:o,stream:t}}).catch(()=>{a()})}else try{a()}catch(u){throw new Error(`Unable to start audio worklet node for PCMRecorder: ${u}`)}}releaseMediaResources(e){this.privMediaResources&&(this.privMediaResources.scriptProcessorNode&&(this.privMediaResources.scriptProcessorNode.disconnect(e.destination),this.privMediaResources.scriptProcessorNode=null),this.privMediaResources.source&&(this.privMediaResources.source.disconnect(),this.privStopInputOnRelease&&this.privMediaResources.stream.getTracks().forEach(t=>t.stop()),this.privMediaResources.source=null))}setWorkletUrl(e){this.privSpeechProcessorScript=e}};Hs.PcmRecorder=oh});var Wm=p(()=>{});var Hm=p(()=>{});var Km=p(()=>{});var Jm=p(()=>{});var Gm=p(()=>{});var ch=p(Ge=>{"use strict";var YI=Ge&&Ge.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),XI=Ge&&Ge.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),$m=Ge&&Ge.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&YI(e,i,t);return XI(e,i),e},ah=Ge&&Ge.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.WebsocketMessageAdapter=void 0;var ZI=$m(Wm()),ew=$m(Hm()),tw=ah(Km()),rw=ah(Jm()),iw=ah(Gm()),nw=we(),T=P(),Ks=class i{constructor(e,t,r,n,s,o){if(!e)throw new T.ArgumentNullError("uri");if(!r)throw new T.ArgumentNullError("messageFormatter");this.proxyInfo=n,this.privConnectionEvents=new T.EventSource,this.privConnectionId=t,this.privMessageFormatter=r,this.privConnectionState=T.ConnectionState.None,this.privUri=e,this.privHeaders=s,this.privEnableCompression=o,this.privHeaders[nw.HeaderNames.ConnectionId]=this.privConnectionId,this.privLastErrorReceived=""}get state(){return this.privConnectionState}open(){if(this.privConnectionState===T.ConnectionState.Disconnected)return Promise.reject(`Cannot open a connection that is in ${this.privConnectionState} state`);if(this.privConnectionEstablishDeferral)return this.privConnectionEstablishDeferral.promise;this.privConnectionEstablishDeferral=new T.Deferred,this.privCertificateValidatedDeferral=new T.Deferred,this.privConnectionState=T.ConnectionState.Connecting;try{if(typeof WebSocket<"u"&&!i.forceNpmWebSocket)this.privCertificateValidatedDeferral.resolve(),this.privWebsocketClient=new WebSocket(this.privUri);else{let e={headers:this.privHeaders,perMessageDeflate:this.privEnableCompression};this.privCertificateValidatedDeferral.resolve(),e.agent=this.getAgent();let r=new URL(this.privUri).protocol;r?.toLocaleLowerCase()==="wss:"?r="https:":r?.toLocaleLowerCase()==="ws:"&&(r="http:"),e.agent.protocol=r,this.privWebsocketClient=new iw.default(this.privUri,e)}this.privWebsocketClient.binaryType="arraybuffer",this.privReceivingMessageQueue=new T.Queue,this.privDisconnectDeferral=new T.Deferred,this.privSendMessageQueue=new T.Queue,this.processSendQueue().catch(e=>{T.Events.instance.onEvent(new T.BackgroundEvent(e))})}catch(e){return this.privConnectionEstablishDeferral.resolve(new T.ConnectionOpenResponse(500,e)),this.privConnectionEstablishDeferral.promise}return this.onEvent(new T.ConnectionStartEvent(this.privConnectionId,this.privUri)),this.privWebsocketClient.onopen=()=>{this.privCertificateValidatedDeferral.promise.then(()=>{this.privConnectionState=T.ConnectionState.Connected,this.onEvent(new T.ConnectionEstablishedEvent(this.privConnectionId)),this.privConnectionEstablishDeferral.resolve(new T.ConnectionOpenResponse(200,""))},e=>{this.privConnectionEstablishDeferral.reject(e)})},this.privWebsocketClient.onerror=e=>{this.onEvent(new T.ConnectionErrorEvent(this.privConnectionId,e.message,e.type)),this.privLastErrorReceived=e.message},this.privWebsocketClient.onclose=e=>{this.privConnectionState===T.ConnectionState.Connecting?(this.privConnectionState=T.ConnectionState.Disconnected,this.privConnectionEstablishDeferral.resolve(new T.ConnectionOpenResponse(e.code,e.reason+" "+this.privLastErrorReceived))):(this.privConnectionState=T.ConnectionState.Disconnected,this.privWebsocketClient=null,this.onEvent(new T.ConnectionClosedEvent(this.privConnectionId,e.code,e.reason))),this.onClose(e.code,e.reason).catch(t=>{T.Events.instance.onEvent(new T.BackgroundEvent(t))})},this.privWebsocketClient.onmessage=e=>{let t=new Date().toISOString();if(this.privConnectionState===T.ConnectionState.Connected){let r=new T.Deferred;if(this.privReceivingMessageQueue.enqueueFromPromise(r.promise),e.data instanceof ArrayBuffer){let n=new T.RawWebsocketMessage(T.MessageType.Binary,e.data);this.privMessageFormatter.toConnectionMessage(n).then(s=>{this.onEvent(new T.ConnectionMessageReceivedEvent(this.privConnectionId,t,s)),r.resolve(s)},s=>{r.reject(`Invalid binary message format. Error: ${s}`)})}else{let n=new T.RawWebsocketMessage(T.MessageType.Text,e.data);this.privMessageFormatter.toConnectionMessage(n).then(s=>{this.onEvent(new T.ConnectionMessageReceivedEvent(this.privConnectionId,t,s)),r.resolve(s)},s=>{r.reject(`Invalid text message format. Error: ${s}`)})}}},this.privConnectionEstablishDeferral.promise}send(e){if(this.privConnectionState!==T.ConnectionState.Connected)return Promise.reject(`Cannot send on connection that is in ${T.ConnectionState[this.privConnectionState]} state`);let t=new T.Deferred,r=new T.Deferred;return this.privSendMessageQueue.enqueueFromPromise(r.promise),this.privMessageFormatter.fromConnectionMessage(e).then(n=>{r.resolve({Message:e,RawWebsocketMessage:n,sendStatusDeferral:t})},n=>{r.reject(`Error formatting the message. ${n}`)}),t.promise}read(){return this.privConnectionState!==T.ConnectionState.Connected?Promise.reject(`Cannot read on connection that is in ${this.privConnectionState} state`):this.privReceivingMessageQueue.dequeue()}close(e){if(this.privWebsocketClient)this.privConnectionState!==T.ConnectionState.Disconnected&&this.privWebsocketClient.close(1e3,e||"Normal closure by client");else return Promise.resolve();return this.privDisconnectDeferral.promise}get events(){return this.privConnectionEvents}sendRawMessage(e){try{if(!e)return Promise.resolve();if(this.onEvent(new T.ConnectionMessageSentEvent(this.privConnectionId,new Date().toISOString(),e.Message)),this.isWebsocketOpen)this.privWebsocketClient.send(e.RawWebsocketMessage.payload);else return Promise.reject("websocket send error: Websocket not ready "+this.privConnectionId+" "+e.Message.id+" "+new Error().stack);return Promise.resolve()}catch(t){return Promise.reject(`websocket send error: ${t}`)}}async onClose(e,t){let r=`Connection closed. ${e}: ${t}`;this.privConnectionState=T.ConnectionState.Disconnected,this.privDisconnectDeferral.resolve(),await this.privReceivingMessageQueue.drainAndDispose(()=>{},r),await this.privSendMessageQueue.drainAndDispose(n=>{n.sendStatusDeferral.reject(r)},r)}async processSendQueue(){for(;;){let t=await this.privSendMessageQueue.dequeue();if(!t)return;try{await this.sendRawMessage(t),t.sendStatusDeferral.resolve()}catch(r){t.sendStatusDeferral.reject(r)}}}onEvent(e){this.privConnectionEvents.onEvent(e),T.Events.instance.onEvent(e)}getAgent(){let e=new tw.default.Agent(this.createConnection);return this.proxyInfo!==void 0&&this.proxyInfo.HostName!==void 0&&this.proxyInfo.Port>0&&(e.proxyInfo=this.proxyInfo),e}static GetProxyAgent(e){let t={host:e.HostName,port:e.Port};return e.UserName?t.headers={"Proxy-Authentication":"Basic "+new Buffer(`${e.UserName}:${e.Password===void 0?"":e.Password}`).toString("base64")}:t.headers={},t.headers.requestOCSP="true",new rw.default(t)}createConnection(e,t){let r;if(t={...t,requestOCSP:!0,servername:t.host},this.proxyInfo){let s=i.GetProxyAgent(this.proxyInfo);r=new Promise((o,a)=>{s.callback(e,t,(c,u)=>{c?a(c):o(u)})})}else t.secureEndpoint?r=Promise.resolve(ew.connect(t)):r=Promise.resolve(ZI.connect(t));return r}get isWebsocketOpen(){return this.privWebsocketClient&&this.privWebsocketClient.readyState===this.privWebsocketClient.OPEN}};Ge.WebsocketMessageAdapter=Ks;Ks.forceNpmWebSocket=!1});var Qm=p(Js=>{"use strict";Object.defineProperty(Js,"__esModule",{value:!0});Js.WebsocketConnection=void 0;var ph=P(),sw=ch(),uh=class{constructor(e,t,r,n,s,o=!1,a){if(this.privIsDisposed=!1,!e)throw new ph.ArgumentNullError("uri");if(!n)throw new ph.ArgumentNullError("messageFormatter");this.privMessageFormatter=n;let c="",u=0;if(t){for(let h in t)if(h){c+=u===0&&e.indexOf("?")===-1?"?":"&";let d=encodeURIComponent(h);c+=d;let v=t[h];v&&(v=encodeURIComponent(v),c+=`=${v}`),u++}}if(r){for(let h in r)if(h){c+=u===0&&e.indexOf("?")===-1?"?":"&";let d=encodeURIComponent(r[h]);c+=`${h}=${d}`,u++}}this.privUri=e+c,this.privId=a||ph.createNoDashGuid(),this.privConnectionMessageAdapter=new sw.WebsocketMessageAdapter(this.privUri,this.id,this.privMessageFormatter,s,r,o)}async dispose(){this.privIsDisposed=!0,this.privConnectionMessageAdapter&&await this.privConnectionMessageAdapter.close()}isDisposed(){return this.privIsDisposed}get id(){return this.privId}get uri(){return this.privUri}state(){return this.privConnectionMessageAdapter.state}open(){return this.privConnectionMessageAdapter.open()}send(e){return this.privConnectionMessageAdapter.send(e)}read(){return this.privConnectionMessageAdapter.read()}get events(){return this.privConnectionMessageAdapter.events}};Js.WebsocketConnection=uh});var Ym=p(Gs=>{"use strict";Object.defineProperty(Gs,"__esModule",{value:!0});Gs.ReplayableAudioNode=void 0;var hh=class{constructor(e,t){this.privBuffers=[],this.privReplayOffset=0,this.privLastShrinkOffset=0,this.privBufferStartOffset=0,this.privBufferSerial=0,this.privBufferedBytes=0,this.privReplay=!1,this.privLastChunkAcquiredTime=0,this.privAudioNode=e,this.privBytesPerSecond=t}id(){return this.privAudioNode.id()}read(){if(this.privReplay&&this.privBuffers.length!==0){let e=this.privReplayOffset-this.privBufferStartOffset,t=Math.round(e*this.privBytesPerSecond*1e-7);t%2!==0&&t++;let r=0;for(;r<this.privBuffers.length&&t>=this.privBuffers[r].chunk.buffer.byteLength;)t-=this.privBuffers[r++].chunk.buffer.byteLength;if(r<this.privBuffers.length){let n=this.privBuffers[r].chunk.buffer.slice(t);return this.privReplayOffset+=n.byteLength/this.privBytesPerSecond*1e7,r===this.privBuffers.length-1&&(this.privReplay=!1),Promise.resolve({buffer:n,isEnd:!1,timeReceived:this.privBuffers[r].chunk.timeReceived})}}return this.privAudioNode.read().then(e=>(e&&e.buffer&&(this.privBuffers.push(new dh(e,this.privBufferSerial++,this.privBufferedBytes)),this.privBufferedBytes+=e.buffer.byteLength),e))}detach(){return this.privBuffers=void 0,this.privAudioNode.detach()}replay(){this.privBuffers&&this.privBuffers.length!==0&&(this.privReplay=!0,this.privReplayOffset=this.privLastShrinkOffset)}shrinkBuffers(e){if(this.privBuffers===void 0||this.privBuffers.length===0)return;this.privLastShrinkOffset=e;let t=e-this.privBufferStartOffset,r=Math.round(t*this.privBytesPerSecond*1e-7),n=0;for(;n<this.privBuffers.length&&r>=this.privBuffers[n].chunk.buffer.byteLength;)r-=this.privBuffers[n++].chunk.buffer.byteLength;this.privBufferStartOffset=Math.round(e-r/this.privBytesPerSecond*1e7),this.privBuffers=this.privBuffers.slice(n)}findTimeAtOffset(e){if(e<this.privBufferStartOffset||this.privBuffers===void 0)return 0;for(let t of this.privBuffers){let r=t.byteOffset/this.privBytesPerSecond*1e7,n=r+t.chunk.buffer.byteLength/this.privBytesPerSecond*1e7;if(e>=r&&e<=n)return t.chunk.timeReceived}return 0}};Gs.ReplayableAudioNode=hh;var dh=class{constructor(e,t,r){this.chunk=e,this.serial=t,this.byteOffset=r}}});var fh=p(Et=>{"use strict";var ow=Et&&Et.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),aw=Et&&Et.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),cw=Et&&Et.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&ow(e,i,t);return aw(e,i),e};Object.defineProperty(Et,"__esModule",{value:!0});Et.AudioFileWriter=void 0;var on=cw(th()),lh=I(),vh=class{constructor(e){lh.Contracts.throwIfNullOrUndefined(on.openSync,`
18
- File System access not available, please use Push or PullAudioOutputStream`),this.privFd=on.openSync(e,"w")}set format(e){lh.Contracts.throwIfNotUndefined(this.privAudioFormat,"format is already set"),this.privAudioFormat=e;let t=0;this.privAudioFormat.hasHeader&&(t=this.privAudioFormat.header.byteLength),this.privFd!==void 0&&(this.privWriteStream=on.createWriteStream("",{fd:this.privFd,start:t,autoClose:!1}))}write(e){lh.Contracts.throwIfNullOrUndefined(this.privAudioFormat,"must set format before writing."),this.privWriteStream!==void 0&&this.privWriteStream.write(new Uint8Array(e.slice(0)))}close(){this.privFd!==void 0&&(this.privWriteStream.on("finish",()=>{this.privAudioFormat.hasHeader&&(this.privAudioFormat.updateHeader(this.privWriteStream.bytesWritten),on.writeSync(this.privFd,new Int8Array(this.privAudioFormat.header),0,this.privAudioFormat.header.byteLength,0)),on.closeSync(this.privFd),this.privFd=void 0}),this.privWriteStream.end())}id(){return this.privId}};Et.AudioFileWriter=vh});var gh=p($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.PullAudioInputStreamImpl=$e.PullAudioInputStream=$e.PushAudioInputStreamImpl=$e.PushAudioInputStream=$e.AudioInputStream=void 0;var $s=C(),fe=P(),Xm=tr(),pw=f(),uw=nr(),an=class{constructor(){}static createPushStream(e){return cn.create(e)}static createPullStream(e,t){return pn.create(e,t)}};$e.AudioInputStream=an;var cn=class extends an{static create(e){return new Qs(e)}};$e.PushAudioInputStream=cn;var Qs=class extends cn{constructor(e){super(),e===void 0?this.privFormat=uw.AudioStreamFormatImpl.getDefaultInputFormat():this.privFormat=e,this.privEvents=new fe.EventSource,this.privId=Xm.createNoDashGuid(),this.privStream=new fe.ChunkedArrayBufferStream(this.privFormat.avgBytesPerSec/10)}get format(){return Promise.resolve(this.privFormat)}write(e){this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}id(){return this.privId}turnOn(){this.onEvent(new fe.AudioSourceInitializingEvent(this.privId)),this.onEvent(new fe.AudioSourceReadyEvent(this.privId))}async attach(e){this.onEvent(new fe.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn();let t=this.privStream;return this.onEvent(new fe.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(this.onEvent(new fe.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}}detach(e){this.onEvent(new fe.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:$s.connectivity.Unknown,manufacturer:"Speech SDK",model:"PushStream",samplerate:this.privFormat.samplesPerSec,type:$s.type.Stream})}onEvent(e){this.privEvents.onEvent(e),fe.Events.instance.onEvent(e)}toBuffer(e){let t=Buffer.alloc(e.byteLength),r=new Uint8Array(e);for(let n=0;n<t.length;++n)t[n]=r[n];return t}};$e.PushAudioInputStreamImpl=Qs;var pn=class extends an{constructor(){super()}static create(e,t){return new Ys(e,t)}};$e.PullAudioInputStream=pn;var Ys=class extends pn{constructor(e,t){super(),t===void 0?this.privFormat=pw.AudioStreamFormat.getDefaultInputFormat():this.privFormat=t,this.privEvents=new fe.EventSource,this.privId=Xm.createNoDashGuid(),this.privCallback=e,this.privIsClosed=!1,this.privBufferSize=this.privFormat.avgBytesPerSec/10}get format(){return Promise.resolve(this.privFormat)}close(){this.privIsClosed=!0,this.privCallback.close()}id(){return this.privId}turnOn(){this.onEvent(new fe.AudioSourceInitializingEvent(this.privId)),this.onEvent(new fe.AudioSourceReadyEvent(this.privId))}async attach(e){return this.onEvent(new fe.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn(),this.onEvent(new fe.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:()=>(this.privCallback.close(),this.onEvent(new fe.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>{let t=0,r;for(;t<this.privBufferSize;){let n=new ArrayBuffer(this.privBufferSize-t),s=this.privCallback.read(n);if(r===void 0?r=n:new Int8Array(r).set(new Int8Array(n),t),s===0)break;t+=s}return Promise.resolve({buffer:r.slice(0,t),isEnd:this.privIsClosed||t===0,timeReceived:Date.now()})}}}detach(e){this.onEvent(new fe.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:$s.connectivity.Unknown,manufacturer:"Speech SDK",model:"PullStream",samplerate:this.privFormat.samplesPerSec,type:$s.type.Stream})}onEvent(e){this.privEvents.onEvent(e),fe.Events.instance.onEvent(e)}};$e.PullAudioInputStreamImpl=Ys});var mh=p(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.SpeechSynthesisOutputFormat=void 0;var hw;(function(i){i[i.Raw8Khz8BitMonoMULaw=0]="Raw8Khz8BitMonoMULaw",i[i.Riff16Khz16KbpsMonoSiren=1]="Riff16Khz16KbpsMonoSiren",i[i.Audio16Khz16KbpsMonoSiren=2]="Audio16Khz16KbpsMonoSiren",i[i.Audio16Khz32KBitRateMonoMp3=3]="Audio16Khz32KBitRateMonoMp3",i[i.Audio16Khz128KBitRateMonoMp3=4]="Audio16Khz128KBitRateMonoMp3",i[i.Audio16Khz64KBitRateMonoMp3=5]="Audio16Khz64KBitRateMonoMp3",i[i.Audio24Khz48KBitRateMonoMp3=6]="Audio24Khz48KBitRateMonoMp3",i[i.Audio24Khz96KBitRateMonoMp3=7]="Audio24Khz96KBitRateMonoMp3",i[i.Audio24Khz160KBitRateMonoMp3=8]="Audio24Khz160KBitRateMonoMp3",i[i.Raw16Khz16BitMonoTrueSilk=9]="Raw16Khz16BitMonoTrueSilk",i[i.Riff16Khz16BitMonoPcm=10]="Riff16Khz16BitMonoPcm",i[i.Riff8Khz16BitMonoPcm=11]="Riff8Khz16BitMonoPcm",i[i.Riff24Khz16BitMonoPcm=12]="Riff24Khz16BitMonoPcm",i[i.Riff8Khz8BitMonoMULaw=13]="Riff8Khz8BitMonoMULaw",i[i.Raw16Khz16BitMonoPcm=14]="Raw16Khz16BitMonoPcm",i[i.Raw24Khz16BitMonoPcm=15]="Raw24Khz16BitMonoPcm",i[i.Raw8Khz16BitMonoPcm=16]="Raw8Khz16BitMonoPcm",i[i.Ogg16Khz16BitMonoOpus=17]="Ogg16Khz16BitMonoOpus",i[i.Ogg24Khz16BitMonoOpus=18]="Ogg24Khz16BitMonoOpus",i[i.Raw48Khz16BitMonoPcm=19]="Raw48Khz16BitMonoPcm",i[i.Riff48Khz16BitMonoPcm=20]="Riff48Khz16BitMonoPcm",i[i.Audio48Khz96KBitRateMonoMp3=21]="Audio48Khz96KBitRateMonoMp3",i[i.Audio48Khz192KBitRateMonoMp3=22]="Audio48Khz192KBitRateMonoMp3",i[i.Ogg48Khz16BitMonoOpus=23]="Ogg48Khz16BitMonoOpus",i[i.Webm16Khz16BitMonoOpus=24]="Webm16Khz16BitMonoOpus",i[i.Webm24Khz16BitMonoOpus=25]="Webm24Khz16BitMonoOpus",i[i.Raw24Khz16BitMonoTrueSilk=26]="Raw24Khz16BitMonoTrueSilk",i[i.Raw8Khz8BitMonoALaw=27]="Raw8Khz8BitMonoALaw",i[i.Riff8Khz8BitMonoALaw=28]="Riff8Khz8BitMonoALaw",i[i.Webm24Khz16Bit24KbpsMonoOpus=29]="Webm24Khz16Bit24KbpsMonoOpus",i[i.Audio16Khz16Bit32KbpsMonoOpus=30]="Audio16Khz16Bit32KbpsMonoOpus",i[i.Audio24Khz16Bit48KbpsMonoOpus=31]="Audio24Khz16Bit48KbpsMonoOpus",i[i.Audio24Khz16Bit24KbpsMonoOpus=32]="Audio24Khz16Bit24KbpsMonoOpus",i[i.Raw22050Hz16BitMonoPcm=33]="Raw22050Hz16BitMonoPcm",i[i.Riff22050Hz16BitMonoPcm=34]="Riff22050Hz16BitMonoPcm",i[i.Raw44100Hz16BitMonoPcm=35]="Raw44100Hz16BitMonoPcm",i[i.Riff44100Hz16BitMonoPcm=36]="Riff44100Hz16BitMonoPcm"})(hw=un.SpeechSynthesisOutputFormat||(un.SpeechSynthesisOutputFormat={}))});var ui=p(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.AudioOutputFormatImpl=void 0;var O=mh(),A=nr(),Xs=class i extends A.AudioStreamFormatImpl{constructor(e,t,r,n,s,o,a,c,u){super(r,o,t,e),this.formatTag=e,this.avgBytesPerSec=n,this.blockAlign=s,this.priAudioFormatString=a,this.priRequestAudioFormatString=c,this.priHasHeader=u}static fromSpeechSynthesisOutputFormat(e){return e===void 0?i.getDefaultOutputFormat():i.fromSpeechSynthesisOutputFormatString(i.SpeechSynthesisOutputFormatToString[e])}static fromSpeechSynthesisOutputFormatString(e){switch(e){case"raw-8khz-8bit-mono-mulaw":return new i(A.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,e,!1);case"riff-16khz-16kbps-mono-siren":return new i(A.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,"audio-16khz-16kbps-mono-siren",!0);case"audio-16khz-16kbps-mono-siren":return new i(A.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,e,!1);case"audio-16khz-32kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,16e3,4096,2,16,e,e,!1);case"audio-16khz-128kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,16e3,16384,2,16,e,e,!1);case"audio-16khz-64kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,16e3,8192,2,16,e,e,!1);case"audio-24khz-48kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,24e3,6144,2,16,e,e,!1);case"audio-24khz-96kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,24e3,12288,2,16,e,e,!1);case"audio-24khz-160kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,24e3,20480,2,16,e,e,!1);case"raw-16khz-16bit-mono-truesilk":return new i(A.AudioFormatTag.SILKSkype,1,16e3,32e3,2,16,e,e,!1);case"riff-8khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!0);case"riff-24khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!0);case"riff-8khz-8bit-mono-mulaw":return new i(A.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-mulaw",!0);case"raw-16khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,16e3,32e3,2,16,e,"raw-16khz-16bit-mono-pcm",!1);case"raw-24khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!1);case"raw-8khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!1);case"ogg-16khz-16bit-mono-opus":return new i(A.AudioFormatTag.OGG_OPUS,1,16e3,8192,2,16,e,e,!1);case"ogg-24khz-16bit-mono-opus":return new i(A.AudioFormatTag.OGG_OPUS,1,24e3,8192,2,16,e,e,!1);case"raw-48khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!1);case"riff-48khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!0);case"audio-48khz-96kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,48e3,12288,2,16,e,e,!1);case"audio-48khz-192kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,48e3,24576,2,16,e,e,!1);case"ogg-48khz-16bit-mono-opus":return new i(A.AudioFormatTag.OGG_OPUS,1,48e3,12e3,2,16,e,e,!1);case"webm-16khz-16bit-mono-opus":return new i(A.AudioFormatTag.WEBM_OPUS,1,16e3,4e3,2,16,e,e,!1);case"webm-24khz-16bit-mono-opus":return new i(A.AudioFormatTag.WEBM_OPUS,1,24e3,6e3,2,16,e,e,!1);case"webm-24khz-16bit-24kbps-mono-opus":return new i(A.AudioFormatTag.WEBM_OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-16khz-16bit-32kbps-mono-opus":return new i(A.AudioFormatTag.OPUS,1,16e3,4e3,2,16,e,e,!1);case"audio-24khz-16bit-48kbps-mono-opus":return new i(A.AudioFormatTag.OPUS,1,24e3,6e3,2,16,e,e,!1);case"audio-24khz-16bit-24kbps-mono-opus":return new i(A.AudioFormatTag.OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-24khz-16bit-mono-flac":return new i(A.AudioFormatTag.FLAC,1,24e3,24e3,2,16,e,e,!1);case"audio-48khz-16bit-mono-flac":return new i(A.AudioFormatTag.FLAC,1,48e3,3e4,2,16,e,e,!1);case"raw-24khz-16bit-mono-truesilk":return new i(A.AudioFormatTag.SILKSkype,1,24e3,48e3,2,16,e,e,!1);case"raw-8khz-8bit-mono-alaw":return new i(A.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,e,!1);case"riff-8khz-8bit-mono-alaw":return new i(A.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-alaw",!0);case"raw-22050hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,22050,44100,2,16,e,e,!1);case"riff-22050hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,22050,44100,2,16,e,"raw-22050hz-16bit-mono-pcm",!0);case"raw-44100hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,44100,88200,2,16,e,e,!1);case"riff-44100hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,44100,88200,2,16,e,"raw-44100hz-16bit-mono-pcm",!0);case"riff-16khz-16bit-mono-pcm":default:return new i(A.AudioFormatTag.PCM,1,16e3,32e3,2,16,"riff-16khz-16bit-mono-pcm","raw-16khz-16bit-mono-pcm",!0)}}static getDefaultOutputFormat(){return i.fromSpeechSynthesisOutputFormatString(typeof window<"u"?"audio-24khz-48kbitrate-mono-mp3":"riff-16khz-16bit-mono-pcm")}get hasHeader(){return this.priHasHeader}get header(){if(this.hasHeader)return this.privHeader}updateHeader(e){if(this.priHasHeader){let t=new DataView(this.privHeader);t.setUint32(4,e+this.privHeader.byteLength-8,!0),t.setUint32(40,e,!0)}}get requestAudioFormatString(){return this.priRequestAudioFormatString}addHeader(e){if(!this.hasHeader)return e;this.updateHeader(e.byteLength);let t=new Uint8Array(e.byteLength+this.header.byteLength);return t.set(new Uint8Array(this.header),0),t.set(new Uint8Array(e),this.header.byteLength),t.buffer}};Zs.AudioOutputFormatImpl=Xs;Xs.SpeechSynthesisOutputFormatToString={[O.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]:"raw-8khz-8bit-mono-mulaw",[O.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]:"riff-16khz-16kbps-mono-siren",[O.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]:"audio-16khz-16kbps-mono-siren",[O.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]:"audio-16khz-32kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]:"audio-16khz-128kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]:"audio-16khz-64kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]:"audio-24khz-48kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]:"audio-24khz-96kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]:"audio-24khz-160kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]:"raw-16khz-16bit-mono-truesilk",[O.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]:"riff-16khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]:"riff-8khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]:"riff-24khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]:"riff-8khz-8bit-mono-mulaw",[O.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]:"raw-16khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]:"raw-24khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]:"raw-8khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus]:"ogg-16khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus]:"ogg-24khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm]:"raw-48khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm]:"riff-48khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3]:"audio-48khz-96kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3]:"audio-48khz-192kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus]:"ogg-48khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus]:"webm-16khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus]:"webm-24khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus]:"webm-24khz-16bit-24kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk]:"raw-24khz-16bit-mono-truesilk",[O.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw]:"raw-8khz-8bit-mono-alaw",[O.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw]:"riff-8khz-8bit-mono-alaw",[O.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus]:"audio-16khz-16bit-32kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus]:"audio-24khz-16bit-48kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus]:"audio-24khz-16bit-24kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm]:"raw-22050hz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]:"riff-22050hz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]:"raw-44100hz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]:"riff-44100hz-16bit-mono-pcm"}});var br=p(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.PushAudioOutputStreamImpl=Qe.PushAudioOutputStream=Qe.PullAudioOutputStreamImpl=Qe.PullAudioOutputStream=Qe.AudioOutputStream=void 0;var Sh=P(),dw=I(),lw=ui(),hn=class{constructor(){}static createPullStream(){return dn.create()}};Qe.AudioOutputStream=hn;var dn=class extends hn{static create(){return new eo}};Qe.PullAudioOutputStream=dn;var eo=class extends dn{constructor(){super(),this.privId=Sh.createNoDashGuid(),this.privStream=new Sh.Stream}set format(e){e==null&&(this.privFormat=lw.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privFormat=e}get format(){return this.privFormat}get isClosed(){return this.privStream.isClosed}id(){return this.privId}async read(e){let t=new Int8Array(e),r=0;if(this.privLastChunkView!==void 0){if(this.privLastChunkView.length>e.byteLength)return t.set(this.privLastChunkView.slice(0,e.byteLength)),this.privLastChunkView=this.privLastChunkView.slice(e.byteLength),Promise.resolve(e.byteLength);t.set(this.privLastChunkView),r=this.privLastChunkView.length,this.privLastChunkView=void 0}for(;r<e.byteLength&&!this.privStream.isReadEnded;){let n=await this.privStream.read();if(n!==void 0&&!n.isEnd){let s;n.buffer.byteLength>e.byteLength-r?(s=n.buffer.slice(0,e.byteLength-r),this.privLastChunkView=new Int8Array(n.buffer.slice(e.byteLength-r))):s=n.buffer,t.set(new Int8Array(s),r),r+=s.byteLength}else this.privStream.readEnded()}return r}write(e){dw.Contracts.throwIfNullOrUndefined(this.privStream,"must set format before writing"),this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}};Qe.PullAudioOutputStreamImpl=eo;var to=class extends hn{constructor(){super()}static create(e){return new ro(e)}};Qe.PushAudioOutputStream=to;var ro=class extends to{constructor(e){super(),this.privId=Sh.createNoDashGuid(),this.privCallback=e}set format(e){}write(e){this.privCallback.write&&this.privCallback.write(e)}close(){this.privCallback.close&&this.privCallback.close()}id(){return this.privId}};Qe.PushAudioOutputStreamImpl=ro});var yh=p(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.AudioOutputConfigImpl=sr.AudioConfigImpl=sr.AudioConfig=void 0;var Or=pe(),vw=I(),Mr=f(),fw=fh(),gw=gh(),mw=br(),ln=class i{static fromDefaultMicrophoneInput(){let e=new Or.PcmRecorder(!0);return new Lt(new Or.MicAudioSource(e))}static fromMicrophoneInput(e){let t=new Or.PcmRecorder(!0);return new Lt(new Or.MicAudioSource(t,e))}static fromWavFileInput(e,t="unnamedBuffer.wav"){return new Lt(new Or.FileAudioSource(e,t))}static fromStreamInput(e){if(e instanceof Mr.PullAudioInputStreamCallback)return new Lt(new gw.PullAudioInputStreamImpl(e));if(e instanceof Mr.AudioInputStream)return new Lt(e);if(typeof MediaStream<"u"&&e instanceof MediaStream){let t=new Or.PcmRecorder(!1);return new Lt(new Or.MicAudioSource(t,null,null,e))}throw new Error("Not Supported Type")}static fromDefaultSpeakerOutput(){return new Bt(new Mr.SpeakerAudioDestination)}static fromSpeakerOutput(e){if(e===void 0)return i.fromDefaultSpeakerOutput();if(e instanceof Mr.SpeakerAudioDestination)return new Bt(e);throw new Error("Not Supported Type")}static fromAudioFileOutput(e){return new Bt(new fw.AudioFileWriter(e))}static fromStreamOutput(e){if(e instanceof Mr.PushAudioOutputStreamCallback)return new Bt(new mw.PushAudioOutputStreamImpl(e));if(e instanceof Mr.PushAudioOutputStream)return new Bt(e);if(e instanceof Mr.PullAudioOutputStream)return new Bt(e);throw new Error("Not Supported Type")}};sr.AudioConfig=ln;var Lt=class extends ln{constructor(e){super(),this.privSource=e}get format(){return this.privSource.format}close(e,t){this.privSource.turnOff().then(()=>{e&&e()},r=>{t&&t(r)})}id(){return this.privSource.id()}turnOn(){return this.privSource.turnOn()}attach(e){return this.privSource.attach(e)}detach(e){return this.privSource.detach(e)}turnOff(){return this.privSource.turnOff()}get events(){return this.privSource.events}setProperty(e,t){if(vw.Contracts.throwIfNull(t,"value"),this.privSource.setProperty!==void 0)this.privSource.setProperty(e,t);else throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(e,t){if(this.privSource.getProperty!==void 0)return this.privSource.getProperty(e,t);throw new Error("This AudioConfig instance does not support getting properties.")}get deviceInfo(){return this.privSource.deviceInfo}};sr.AudioConfigImpl=Lt;var Bt=class extends ln{constructor(e){super(),this.privDestination=e}set format(e){this.privDestination.format=e}write(e){this.privDestination.write(e)}close(){this.privDestination.close()}id(){return this.privDestination.id()}setProperty(){throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(){throw new Error("This AudioConfig instance does not support getting properties.")}};sr.AudioOutputConfigImpl=Bt});var Zm=p(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.CancellationReason=void 0;var Sw;(function(i){i[i.Error=0]="Error",i[i.EndOfStream=1]="EndOfStream"})(Sw=vn.CancellationReason||(vn.CancellationReason={}))});var eS=p(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.PullAudioInputStreamCallback=void 0;var Ch=class{};io.PullAudioInputStreamCallback=Ch});var tS=p(no=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});no.PushAudioOutputStreamCallback=void 0;var Ph=class{};no.PushAudioOutputStreamCallback=Ph});var iS=p(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.KeywordRecognitionModel=void 0;var rS=I(),Rh=class{constructor(){this.privDisposed=!1}static fromFile(e){throw rS.Contracts.throwIfFileDoesNotExist(e,"fileName"),new Error("Not yet implemented.")}static fromStream(e){throw rS.Contracts.throwIfNull(e,"file"),new Error("Not yet implemented.")}close(){this.privDisposed||(this.privDisposed=!0)}};so.KeywordRecognitionModel=Rh});var nS=p(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.SessionEventArgs=void 0;var Eh=class{constructor(e){this.privSessionId=e}get sessionId(){return this.privSessionId}};oo.SessionEventArgs=Eh});var sS=p(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.RecognitionEventArgs=void 0;var yw=f(),Ih=class extends yw.SessionEventArgs{constructor(e,t){super(t),this.privOffset=e}get offset(){return this.privOffset}};ao.RecognitionEventArgs=Ih});var oS=p(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.OutputFormat=void 0;var Cw;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(Cw=fn.OutputFormat||(fn.OutputFormat={}))});var aS=p(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.IntentRecognitionEventArgs=void 0;var Pw=f(),wh=class extends Pw.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};co.IntentRecognitionEventArgs=wh});var cS=p(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.RecognitionResult=void 0;var _h=class{constructor(e,t,r,n,s,o,a,c,u,h){this.privResultId=e,this.privReason=t,this.privText=r,this.privDuration=n,this.privOffset=s,this.privLanguage=o,this.privLanguageDetectionConfidence=a,this.privErrorDetails=c,this.privJson=u,this.privProperties=h}get resultId(){return this.privResultId}get reason(){return this.privReason}get text(){return this.privText}get duration(){return this.privDuration}get offset(){return this.privOffset}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}get errorDetails(){return this.privErrorDetails}get json(){return this.privJson}get properties(){return this.privProperties}};po.RecognitionResult=_h});var pS=p(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.SpeechRecognitionResult=void 0;var Rw=f(),Th=class extends Rw.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(e,t,r,n,s,o,a,u,h,d),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};uo.SpeechRecognitionResult=Th});var uS=p(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.IntentRecognitionResult=void 0;var Ew=f(),Ah=class extends Ew.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(t,r,n,s,o,a,c,void 0,u,h,d),this.privIntentId=e}get intentId(){return this.privIntentId}};ho.IntentRecognitionResult=Ah});var hS=p(li=>{"use strict";Object.defineProperty(li,"__esModule",{value:!0});li.LanguageUnderstandingModelImpl=li.LanguageUnderstandingModel=void 0;var hi=I(),lo=class{constructor(){}static fromEndpoint(e){hi.Contracts.throwIfNull(e,"uri"),hi.Contracts.throwIfNullOrWhitespace(e.hostname,"uri");let t=new di,r=e.host.indexOf(".");if(r===-1)throw new Error("Could not determine region from endpoint");t.region=e.host.substr(0,r);let n=e.pathname.lastIndexOf("/")+1;if(n===-1)throw new Error("Could not determine appId from endpoint");if(t.appId=e.pathname.substr(n),t.subscriptionKey=e.searchParams.get("subscription-key"),t.subscriptionKey===void 0)throw new Error("Could not determine subscription key from endpoint");return t}static fromAppId(e){hi.Contracts.throwIfNullOrWhitespace(e,"appId");let t=new di;return t.appId=e,t}static fromSubscription(e,t,r){hi.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),hi.Contracts.throwIfNullOrWhitespace(t,"appId"),hi.Contracts.throwIfNullOrWhitespace(r,"region");let n=new di;return n.appId=t,n.region=r,n.subscriptionKey=e,n}};li.LanguageUnderstandingModel=lo;var di=class extends lo{};li.LanguageUnderstandingModelImpl=di});var lS=p(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.MeetingTranscriptionEventArgs=or.ConversationTranscriptionEventArgs=or.SpeechRecognitionEventArgs=void 0;var dS=f(),vo=class extends dS.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};or.SpeechRecognitionEventArgs=vo;var bh=class extends dS.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};or.ConversationTranscriptionEventArgs=bh;var Oh=class extends vo{};or.MeetingTranscriptionEventArgs=Oh});var vi=p(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.CancellationEventArgsBase=void 0;var Iw=f(),Mh=class extends Iw.RecognitionEventArgs{constructor(e,t,r,n,s){super(n,s),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};fo.CancellationEventArgsBase=Mh});var vS=p(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.SpeechRecognitionCanceledEventArgs=void 0;var ww=vi(),Dh=class extends ww.CancellationEventArgsBase{};go.SpeechRecognitionCanceledEventArgs=Dh});var fS=p(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.TranslationRecognitionEventArgs=void 0;var _w=f(),kh=class extends _w.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};mo.TranslationRecognitionEventArgs=kh});var gS=p(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.TranslationSynthesisEventArgs=void 0;var Tw=f(),Nh=class extends Tw.SessionEventArgs{constructor(e,t){super(t),this.privResult=e}get result(){return this.privResult}};So.TranslationSynthesisEventArgs=Nh});var xh=p(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.TranslationRecognitionResult=void 0;var Aw=f(),qh=class i extends Aw.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(t,r,n,s,o,a,c,void 0,u,h,d),this.privTranslations=e}static fromSpeechRecognitionResult(e){return new i(void 0,e.resultId,e.reason,e.text,e.duration,e.offset,e.language,e.languageDetectionConfidence,e.errorDetails,e.json,e.properties)}get translations(){return this.privTranslations}};yo.TranslationRecognitionResult=qh});var mS=p(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});Co.TranslationSynthesisResult=void 0;var zh=class{constructor(e,t){this.privReason=e,this.privAudio=t}get audio(){return this.privAudio}get reason(){return this.privReason}};Co.TranslationSynthesisResult=zh});var SS=p(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.ResultReason=void 0;var bw;(function(i){i[i.NoMatch=0]="NoMatch",i[i.Canceled=1]="Canceled",i[i.RecognizingSpeech=2]="RecognizingSpeech",i[i.RecognizedSpeech=3]="RecognizedSpeech",i[i.RecognizedKeyword=4]="RecognizedKeyword",i[i.RecognizingIntent=5]="RecognizingIntent",i[i.RecognizedIntent=6]="RecognizedIntent",i[i.TranslatingSpeech=7]="TranslatingSpeech",i[i.TranslatedSpeech=8]="TranslatedSpeech",i[i.SynthesizingAudio=9]="SynthesizingAudio",i[i.SynthesizingAudioCompleted=10]="SynthesizingAudioCompleted",i[i.SynthesizingAudioStarted=11]="SynthesizingAudioStarted",i[i.EnrollingVoiceProfile=12]="EnrollingVoiceProfile",i[i.EnrolledVoiceProfile=13]="EnrolledVoiceProfile",i[i.RecognizedSpeakers=14]="RecognizedSpeakers",i[i.RecognizedSpeaker=15]="RecognizedSpeaker",i[i.ResetVoiceProfile=16]="ResetVoiceProfile",i[i.DeletedVoiceProfile=17]="DeletedVoiceProfile",i[i.VoicesListRetrieved=18]="VoicesListRetrieved",i[i.TranslatingParticipantSpeech=19]="TranslatingParticipantSpeech",i[i.TranslatedParticipantSpeech=20]="TranslatedParticipantSpeech",i[i.TranslatedInstantMessage=21]="TranslatedInstantMessage",i[i.TranslatedParticipantInstantMessage=22]="TranslatedParticipantInstantMessage"})(bw=gn.ResultReason||(gn.ResultReason={}))});var yS=p(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.SpeechConfigImpl=fi.SpeechConfig=void 0;var mn=C(),Dr=I(),_=f(),Po=class{constructor(){}static fromSubscription(e,t){Dr.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),Dr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new kr;return r.setProperty(_.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(_.PropertyId.SpeechServiceConnection_IntentRegion,t),r.setProperty(_.PropertyId.SpeechServiceConnection_Key,e),r}static fromEndpoint(e,t){Dr.Contracts.throwIfNull(e,"endpoint");let r=new kr;return r.setProperty(_.PropertyId.SpeechServiceConnection_Endpoint,e.href),t!==void 0&&r.setProperty(_.PropertyId.SpeechServiceConnection_Key,t),r}static fromHost(e,t){Dr.Contracts.throwIfNull(e,"hostName");let r=new kr;return r.setProperty(_.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(_.PropertyId.SpeechServiceConnection_Key,t),r}static fromAuthorizationToken(e,t){Dr.Contracts.throwIfNull(e,"authorizationToken"),Dr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new kr;return r.setProperty(_.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(_.PropertyId.SpeechServiceConnection_IntentRegion,t),r.authorizationToken=e,r}close(){}};fi.SpeechConfig=Po;var kr=class i extends Po{constructor(){super(),this.privProperties=new _.PropertyCollection,this.speechRecognitionLanguage="en-US",this.outputFormat=_.OutputFormat.Simple}get properties(){return this.privProperties}get endPoint(){return new URL(this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_Endpoint))}get subscriptionKey(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_Key)}get region(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_Region)}get authorizationToken(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_RecoLanguage)}set speechRecognitionLanguage(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get autoDetectSourceLanguages(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)}set autoDetectSourceLanguages(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e)}get outputFormat(){return _.OutputFormat[this.privProperties.getProperty(mn.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privProperties.setProperty(mn.OutputFormatPropertyName,_.OutputFormat[e])}get endpointId(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_EndpointId,e)}setProperty(e,t){Dr.Contracts.throwIfNull(t,"value"),this.privProperties.setProperty(e,t)}getProperty(e,t){return this.privProperties.getProperty(e,t)}setProxy(e,t,r,n){this.setProperty(_.PropertyId[_.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(_.PropertyId[_.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(_.PropertyId[_.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(_.PropertyId[_.PropertyId.SpeechServiceConnection_ProxyPassword],n)}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(mn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(mn.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceResponse_ProfanityOption,_.ProfanityOption[e])}enableAudioLogging(){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privProperties.setProperty(_.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privProperties.setProperty(mn.ForceDictationPropertyName,"true")}clone(){let e=new i;return e.privProperties=this.privProperties.clone(),e}get speechSynthesisLanguage(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return _.SpeechSynthesisOutputFormat[this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_SynthOutputFormat,_.SpeechSynthesisOutputFormat[e])}};fi.SpeechConfigImpl=kr});var CS=p(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.SpeechTranslationConfigImpl=gi.SpeechTranslationConfig=void 0;var Sn=C(),dt=I(),E=f(),Ro=class extends E.SpeechConfig{constructor(){super()}static fromSubscription(e,t){dt.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),dt.Contracts.throwIfNullOrWhitespace(t,"region");let r=new Nr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromAuthorizationToken(e,t){dt.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),dt.Contracts.throwIfNullOrWhitespace(t,"region");let r=new Nr;return r.properties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromHost(e,t){dt.Contracts.throwIfNull(e,"hostName");let r=new Nr;return r.setProperty(E.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}static fromEndpoint(e,t){dt.Contracts.throwIfNull(e,"endpoint"),dt.Contracts.throwIfNull(t,"subscriptionKey");let r=new Nr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Endpoint,e.href),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}};gi.SpeechTranslationConfig=Ro;var Nr=class extends Ro{constructor(){super(),this.privSpeechProperties=new E.PropertyCollection,this.outputFormat=E.OutputFormat.Simple}set authorizationToken(e){dt.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e)}set speechRecognitionLanguage(e){dt.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get speechRecognitionLanguage(){return this.privSpeechProperties.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_RecoLanguage])}get subscriptionKey(){return this.privSpeechProperties.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_Key])}get outputFormat(){return E.OutputFormat[this.privSpeechProperties.getProperty(Sn.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privSpeechProperties.setProperty(Sn.OutputFormatPropertyName,E.OutputFormat[e])}get endpointId(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_EndpointId,e)}addTargetLanguage(e){dt.Contracts.throwIfNullOrWhitespace(e,"value");let t=this.targetLanguages;t.includes(e)||(t.push(e),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))}get targetLanguages(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","):[]}get voiceName(){return this.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_TranslationVoice])}set voiceName(e){dt.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_TranslationVoice,e)}get region(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_Region)}setProxy(e,t,r,n){this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyPassword],n)}getProperty(e,t){return this.privSpeechProperties.getProperty(e,t)}setProperty(e,t){this.privSpeechProperties.setProperty(e,t)}get properties(){return this.privSpeechProperties}close(){}setServiceProperty(e,t){let r=JSON.parse(this.privSpeechProperties.getProperty(Sn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privSpeechProperties.setProperty(Sn.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceResponse_ProfanityOption,E.ProfanityOption[e])}enableAudioLogging(){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privSpeechProperties.setProperty(Sn.ForceDictationPropertyName,"true")}get speechSynthesisLanguage(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return E.SpeechSynthesisOutputFormat[this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthOutputFormat,E.SpeechSynthesisOutputFormat[e])}};gi.SpeechTranslationConfigImpl=Nr});var Lh=p(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.PropertyCollection=void 0;var PS=f(),jh=class i{constructor(){this.privKeys=[],this.privValues=[]}getProperty(e,t){let r;typeof e=="string"?r=e:r=PS.PropertyId[e];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r)return this.privValues[n];if(t!==void 0)return String(t)}setProperty(e,t){let r;typeof e=="string"?r=e:r=PS.PropertyId[e];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r){this.privValues[n]=t;return}this.privKeys.push(r),this.privValues.push(t)}clone(){let e=new i;for(let t=0;t<this.privKeys.length;t++)e.privKeys.push(this.privKeys[t]),e.privValues.push(this.privValues[t]);return e}mergeTo(e){this.privKeys.forEach(t=>{if(e.getProperty(t,void 0)===void 0){let r=this.getProperty(t);e.setProperty(t,r)}})}get keys(){return this.privKeys}};Eo.PropertyCollection=jh});var Io=p(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.PropertyId=void 0;var Ow;(function(i){i[i.SpeechServiceConnection_Key=0]="SpeechServiceConnection_Key",i[i.SpeechServiceConnection_Endpoint=1]="SpeechServiceConnection_Endpoint",i[i.SpeechServiceConnection_Region=2]="SpeechServiceConnection_Region",i[i.SpeechServiceAuthorization_Token=3]="SpeechServiceAuthorization_Token",i[i.SpeechServiceAuthorization_Type=4]="SpeechServiceAuthorization_Type",i[i.SpeechServiceConnection_EndpointId=5]="SpeechServiceConnection_EndpointId",i[i.SpeechServiceConnection_TranslationToLanguages=6]="SpeechServiceConnection_TranslationToLanguages",i[i.SpeechServiceConnection_TranslationVoice=7]="SpeechServiceConnection_TranslationVoice",i[i.SpeechServiceConnection_TranslationFeatures=8]="SpeechServiceConnection_TranslationFeatures",i[i.SpeechServiceConnection_IntentRegion=9]="SpeechServiceConnection_IntentRegion",i[i.SpeechServiceConnection_ProxyHostName=10]="SpeechServiceConnection_ProxyHostName",i[i.SpeechServiceConnection_ProxyPort=11]="SpeechServiceConnection_ProxyPort",i[i.SpeechServiceConnection_ProxyUserName=12]="SpeechServiceConnection_ProxyUserName",i[i.SpeechServiceConnection_ProxyPassword=13]="SpeechServiceConnection_ProxyPassword",i[i.SpeechServiceConnection_RecoMode=14]="SpeechServiceConnection_RecoMode",i[i.SpeechServiceConnection_RecoLanguage=15]="SpeechServiceConnection_RecoLanguage",i[i.Speech_SessionId=16]="Speech_SessionId",i[i.SpeechServiceConnection_SynthLanguage=17]="SpeechServiceConnection_SynthLanguage",i[i.SpeechServiceConnection_SynthVoice=18]="SpeechServiceConnection_SynthVoice",i[i.SpeechServiceConnection_SynthOutputFormat=19]="SpeechServiceConnection_SynthOutputFormat",i[i.SpeechServiceConnection_AutoDetectSourceLanguages=20]="SpeechServiceConnection_AutoDetectSourceLanguages",i[i.SpeechServiceResponse_RequestDetailedResultTrueFalse=21]="SpeechServiceResponse_RequestDetailedResultTrueFalse",i[i.SpeechServiceResponse_RequestProfanityFilterTrueFalse=22]="SpeechServiceResponse_RequestProfanityFilterTrueFalse",i[i.SpeechServiceResponse_JsonResult=23]="SpeechServiceResponse_JsonResult",i[i.SpeechServiceResponse_JsonErrorDetails=24]="SpeechServiceResponse_JsonErrorDetails",i[i.CancellationDetails_Reason=25]="CancellationDetails_Reason",i[i.CancellationDetails_ReasonText=26]="CancellationDetails_ReasonText",i[i.CancellationDetails_ReasonDetailedText=27]="CancellationDetails_ReasonDetailedText",i[i.LanguageUnderstandingServiceResponse_JsonResult=28]="LanguageUnderstandingServiceResponse_JsonResult",i[i.SpeechServiceConnection_Url=29]="SpeechServiceConnection_Url",i[i.SpeechServiceConnection_InitialSilenceTimeoutMs=30]="SpeechServiceConnection_InitialSilenceTimeoutMs",i[i.SpeechServiceConnection_EndSilenceTimeoutMs=31]="SpeechServiceConnection_EndSilenceTimeoutMs",i[i.Speech_SegmentationSilenceTimeoutMs=32]="Speech_SegmentationSilenceTimeoutMs",i[i.SpeechServiceConnection_EnableAudioLogging=33]="SpeechServiceConnection_EnableAudioLogging",i[i.SpeechServiceConnection_LanguageIdMode=34]="SpeechServiceConnection_LanguageIdMode",i[i.SpeechServiceConnection_RecognitionEndpointVersion=35]="SpeechServiceConnection_RecognitionEndpointVersion",i[i.SpeechServiceConnection_SpeakerIdMode=36]="SpeechServiceConnection_SpeakerIdMode",i[i.SpeechServiceResponse_ProfanityOption=37]="SpeechServiceResponse_ProfanityOption",i[i.SpeechServiceResponse_PostProcessingOption=38]="SpeechServiceResponse_PostProcessingOption",i[i.SpeechServiceResponse_RequestWordLevelTimestamps=39]="SpeechServiceResponse_RequestWordLevelTimestamps",i[i.SpeechServiceResponse_StablePartialResultThreshold=40]="SpeechServiceResponse_StablePartialResultThreshold",i[i.SpeechServiceResponse_OutputFormatOption=41]="SpeechServiceResponse_OutputFormatOption",i[i.SpeechServiceResponse_TranslationRequestStablePartialResult=42]="SpeechServiceResponse_TranslationRequestStablePartialResult",i[i.SpeechServiceResponse_RequestWordBoundary=43]="SpeechServiceResponse_RequestWordBoundary",i[i.SpeechServiceResponse_RequestPunctuationBoundary=44]="SpeechServiceResponse_RequestPunctuationBoundary",i[i.SpeechServiceResponse_RequestSentenceBoundary=45]="SpeechServiceResponse_RequestSentenceBoundary",i[i.Conversation_ApplicationId=46]="Conversation_ApplicationId",i[i.Conversation_DialogType=47]="Conversation_DialogType",i[i.Conversation_Initial_Silence_Timeout=48]="Conversation_Initial_Silence_Timeout",i[i.Conversation_From_Id=49]="Conversation_From_Id",i[i.Conversation_Conversation_Id=50]="Conversation_Conversation_Id",i[i.Conversation_Custom_Voice_Deployment_Ids=51]="Conversation_Custom_Voice_Deployment_Ids",i[i.Conversation_Speech_Activity_Template=52]="Conversation_Speech_Activity_Template",i[i.Conversation_Request_Bot_Status_Messages=53]="Conversation_Request_Bot_Status_Messages",i[i.Conversation_Agent_Connection_Id=54]="Conversation_Agent_Connection_Id",i[i.SpeechServiceConnection_Host=55]="SpeechServiceConnection_Host",i[i.ConversationTranslator_Host=56]="ConversationTranslator_Host",i[i.ConversationTranslator_Name=57]="ConversationTranslator_Name",i[i.ConversationTranslator_CorrelationId=58]="ConversationTranslator_CorrelationId",i[i.ConversationTranslator_Token=59]="ConversationTranslator_Token",i[i.PronunciationAssessment_ReferenceText=60]="PronunciationAssessment_ReferenceText",i[i.PronunciationAssessment_GradingSystem=61]="PronunciationAssessment_GradingSystem",i[i.PronunciationAssessment_Granularity=62]="PronunciationAssessment_Granularity",i[i.PronunciationAssessment_EnableMiscue=63]="PronunciationAssessment_EnableMiscue",i[i.PronunciationAssessment_Json=64]="PronunciationAssessment_Json",i[i.PronunciationAssessment_Params=65]="PronunciationAssessment_Params",i[i.SpeakerRecognition_Api_Version=66]="SpeakerRecognition_Api_Version",i[i.WebWorkerLoadType=67]="WebWorkerLoadType",i[i.TalkingAvatarService_WebRTC_SDP=68]="TalkingAvatarService_WebRTC_SDP"})(Ow=yn.PropertyId||(yn.PropertyId={}))});var ES=p(To=>{"use strict";Object.defineProperty(To,"__esModule",{value:!0});To.Recognizer=void 0;var qr=C(),RS=P(),wo=I(),_o=f(),Bh=class i{constructor(e,t,r){this.audioConfig=e!==void 0?e:_o.AudioConfig.fromDefaultMicrophoneInput(),this.privDisposed=!1,this.privProperties=t.clone(),this.privConnectionFactory=r,this.implCommonRecognizerSetup()}close(e,t){wo.Contracts.throwIfDisposed(this.privDisposed),RS.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privReco}async dispose(e){this.privDisposed||(this.privDisposed=!0,e&&this.privReco&&(await this.privReco.audioSource.turnOff(),await this.privReco.dispose()))}static get telemetryEnabled(){return qr.ServiceRecognizerBase.telemetryDataEnabled}static enableTelemetry(e){qr.ServiceRecognizerBase.telemetryDataEnabled=e}implCommonRecognizerSetup(){let e=typeof window<"u"?"Browser":"Node",t="unknown",r="unknown";typeof navigator<"u"&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);let n=this.createRecognizerConfig(new qr.SpeechServiceConfig(new qr.Context(new qr.OS(e,t,r))));this.privReco=this.createServiceRecognizer(i.getAuthFromProperties(this.privProperties),this.privConnectionFactory,this.audioConfig,n)}async recognizeOnceAsyncImpl(e){wo.Contracts.throwIfDisposed(this.privDisposed);let t=new RS.Deferred;await this.implRecognizerStop(),await this.privReco.recognize(e,t.resolve,t.reject);let r=await t.promise;return await this.implRecognizerStop(),r}async startContinuousRecognitionAsyncImpl(e){wo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop(),await this.privReco.recognize(e,void 0,void 0)}async stopContinuousRecognitionAsyncImpl(){wo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop()}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}static getAuthFromProperties(e){let t=e.getProperty(_o.PropertyId.SpeechServiceConnection_Key,void 0);return t&&t!==""?new qr.CognitiveSubscriptionKeyAuthentication(t):new qr.CognitiveTokenAuthentication(()=>{let n=e.getProperty(_o.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)},()=>{let n=e.getProperty(_o.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)})}};To.Recognizer=Bh});var IS=p(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.SpeechRecognizer=void 0;var mi=C(),Ao=P(),ar=I(),ze=f(),Fh=class i extends ze.Recognizer{constructor(e,t){let r=e;ar.Contracts.throwIfNull(r,"speechConfig"),ar.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(ze.PropertyId.SpeechServiceConnection_RecoLanguage),ze.PropertyId[ze.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new mi.SpeechConnectionFactory),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get endpointId(){return ar.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ze.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(ze.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){ar.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(ze.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return ar.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ze.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return ar.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(mi.OutputFormatPropertyName,ze.OutputFormat[ze.OutputFormat.Simple])===ze.OutputFormat[ze.OutputFormat.Simple]?ze.OutputFormat.Simple:ze.OutputFormat.Detailed}get properties(){return this.privProperties}recognizeOnceAsync(e,t){Ao.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(mi.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){Ao.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(mi.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){Ao.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){ar.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e){e&&e()}close(e,t){ar.Contracts.throwIfDisposed(this.privDisposedRecognizer),Ao.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new mi.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new mi.SpeechServiceRecognizer(e,t,s,n,this)}};bo.SpeechRecognizer=Fh});var wS=p(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.IntentRecognizer=void 0;var xr=C(),Oo=P(),_e=I(),Ft=f(),Vh=class extends Ft.Recognizer{constructor(e,t){_e.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;_e.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new xr.IntentConnectionFactory),this.privAddedIntents=[],this.privAddedLmIntents={},this.privDisposedIntentRecognizer=!1,this.privProperties=r.properties,_e.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(Ft.PropertyId.SpeechServiceConnection_RecoLanguage),Ft.PropertyId[Ft.PropertyId.SpeechServiceConnection_RecoLanguage])}get speechRecognitionLanguage(){return _e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.properties.getProperty(Ft.PropertyId.SpeechServiceConnection_RecoLanguage)}get authorizationToken(){return this.properties.getProperty(Ft.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(Ft.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}recognizeOnceAsync(e,t){if(_e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){let r=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",r.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(r.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}Oo.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(xr.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){if(Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){let r=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",r.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(r.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}Oo.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(xr.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){Oo.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){_e.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e,t){if(e)try{e()}catch(r){t&&t(r)}}addIntent(e,t){_e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),_e.Contracts.throwIfNullOrWhitespace(t,"intentId"),_e.Contracts.throwIfNullOrWhitespace(e,"simplePhrase"),this.privAddedIntents.push([t,e])}addIntentWithLanguageModel(e,t,r){_e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),_e.Contracts.throwIfNullOrWhitespace(e,"intentId"),_e.Contracts.throwIfNull(t,"model");let n=t;_e.Contracts.throwIfNullOrWhitespace(n.appId,"model.appId"),this.privAddedLmIntents[e]=new xr.AddedLmIntent(n,r)}addAllIntents(e,t){_e.Contracts.throwIfNull(e,"model");let r=e;_e.Contracts.throwIfNullOrWhitespace(r.appId,"model.appId"),this.privUmbrellaIntent=new xr.AddedLmIntent(r,t)}close(e,t){_e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Oo.marshalPromiseToCallbacks(this.dispose(!0),e,t)}createRecognizerConfig(e){return new xr.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new xr.IntentServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedIntentRecognizer||e&&(this.privDisposedIntentRecognizer=!0,await super.dispose(e))}buildSpeechContext(){let e,t,r,n=[];this.privUmbrellaIntent!==void 0&&(e=this.privUmbrellaIntent.modelImpl.appId,t=this.privUmbrellaIntent.modelImpl.region,r=this.privUmbrellaIntent.modelImpl.subscriptionKey);for(let s of Object.keys(this.privAddedLmIntents)){let o=this.privAddedLmIntents[s];if(e===void 0)e=o.modelImpl.appId;else if(e!==o.modelImpl.appId)throw new Error("Intents must all be from the same LUIS model");if(t===void 0)t=o.modelImpl.region;else if(t!==o.modelImpl.region)throw new Error("Intents must all be from the same LUIS model in a single region");if(r===void 0)r=o.modelImpl.subscriptionKey;else if(r!==o.modelImpl.subscriptionKey)throw new Error("Intents must all use the same subscription key");let a="luis/"+e+"-PRODUCTION#"+s;n.push(a)}return{Intent:{id:e,key:r===void 0?this.privProperties.getProperty(Ft.PropertyId[Ft.PropertyId.SpeechServiceConnection_Key]):r,provider:"LUIS"},ReferenceGrammars:this.privUmbrellaIntent===void 0?n:["luis/"+e+"-PRODUCTION"]}}};Mo.IntentRecognizer=Vh});var _S=p(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.VoiceProfileType=void 0;var Mw;(function(i){i[i.TextIndependentIdentification=0]="TextIndependentIdentification",i[i.TextDependentVerification=1]="TextDependentVerification",i[i.TextIndependentVerification=2]="TextIndependentVerification"})(Mw=Cn.VoiceProfileType||(Cn.VoiceProfileType={}))});var Hh=p(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.ConnectionMessageImpl=Si.ConnectionMessage=void 0;var TS=we(),AS=P(),Dw=Lh(),kw=Io(),Uh=class{};Si.ConnectionMessage=Uh;var Wh=class{constructor(e){this.privConnectionMessage=e,this.privProperties=new Dw.PropertyCollection,this.privConnectionMessage.headers[TS.HeaderNames.ConnectionId]&&this.privProperties.setProperty(kw.PropertyId.Speech_SessionId,this.privConnectionMessage.headers[TS.HeaderNames.ConnectionId]),Object.keys(this.privConnectionMessage.headers).forEach(t=>{this.privProperties.setProperty(t,this.privConnectionMessage.headers[t])})}get path(){return this.privConnectionMessage.headers[Object.keys(this.privConnectionMessage.headers).find(e=>e.toLowerCase()==="path".toLowerCase())]}get isTextMessage(){return this.privConnectionMessage.messageType===AS.MessageType.Text}get isBinaryMessage(){return this.privConnectionMessage.messageType===AS.MessageType.Binary}get TextMessage(){return this.privConnectionMessage.textBody}get binaryMessage(){return this.privConnectionMessage.binaryBody}get properties(){return this.privProperties}toString(){return""}};Si.ConnectionMessageImpl=Wh});var $h=p(Do=>{"use strict";Object.defineProperty(Do,"__esModule",{value:!0});Do.Connection=void 0;var Kh=C(),Jh=P(),bS=Hh(),Nw=I(),Pn=f(),Gh=class i{static fromRecognizer(e){let t=e.internalData,r=new i;return r.privInternalData=t,r.setupEvents(),r}static fromSynthesizer(e){let t=e.internalData,r=new i;return r.privInternalData=t,r.setupEvents(),r}openConnection(e,t){Jh.marshalPromiseToCallbacks(this.privInternalData.connect(),e,t)}closeConnection(e,t){if(this.privInternalData instanceof Kh.SynthesisAdapterBase)throw new Error("Disconnecting a synthesizer's connection is currently not supported");Jh.marshalPromiseToCallbacks(this.privInternalData.disconnect(),e,t)}setMessageProperty(e,t,r){if(Nw.Contracts.throwIfNullOrWhitespace(t,"propertyName"),this.privInternalData instanceof Kh.ServiceRecognizerBase){if(e.toLowerCase()!=="speech.context")throw new Error("Only speech.context message property sets are currently supported for recognizer");this.privInternalData.speechContext.setSection(t,r)}else if(this.privInternalData instanceof Kh.SynthesisAdapterBase){if(e.toLowerCase()!=="synthesis.context")throw new Error("Only synthesis.context message property sets are currently supported for synthesizer");this.privInternalData.synthesisContext.setSection(t,r)}}sendMessageAsync(e,t,r,n){Jh.marshalPromiseToCallbacks(this.privInternalData.sendNetworkMessage(e,t),r,n)}close(){}setupEvents(){this.privEventListener=this.privInternalData.connectionEvents.attach(e=>{e.name==="ConnectionEstablishedEvent"?this.connected&&this.connected(new Pn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionClosedEvent"?this.disconnected&&this.disconnected(new Pn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionMessageSentEvent"?this.messageSent&&this.messageSent(new Pn.ConnectionMessageEventArgs(new bS.ConnectionMessageImpl(e.message))):e.name==="ConnectionMessageReceivedEvent"&&this.messageReceived&&this.messageReceived(new Pn.ConnectionMessageEventArgs(new bS.ConnectionMessageImpl(e.message)))}),this.privServiceEventListener=this.privInternalData.serviceEvents.attach(e=>{this.receivedServiceMessage&&this.receivedServiceMessage(new Pn.ServiceEventArgs(e.jsonString,e.name))})}};Do.Connection=Gh});var OS=p(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.TranslationRecognizer=void 0;var Rn=C(),ko=P(),qw=$h(),lt=I(),J=f(),Qh=class i extends J.Recognizer{constructor(e,t,r){let n=e;lt.Contracts.throwIfNull(n,"speechConfig"),super(t,n.properties,r||new Rn.TranslationConnectionFactory),this.privDisposedTranslationRecognizer=!1,this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)!==void 0&&lt.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationVoice),J.PropertyId[J.PropertyId.SpeechServiceConnection_TranslationVoice]),lt.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages),J.PropertyId[J.PropertyId.SpeechServiceConnection_TranslationToLanguages]),lt.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(J.PropertyId.SpeechServiceConnection_RecoLanguage),J.PropertyId[J.PropertyId.SpeechServiceConnection_RecoLanguage])}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get speechRecognitionLanguage(){return lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_RecoLanguage)}get targetLanguages(){return lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",")}get voiceName(){return lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(J.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(J.PropertyId.SpeechServiceAuthorization_Token,e)}recognizeOnceAsync(e,t){lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),ko.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Rn.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){ko.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Rn.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){ko.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}removeTargetLanguage(e){if(lt.Contracts.throwIfNullOrUndefined(e,"language to be removed"),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0){let t=this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),r=t.indexOf(e);r>-1&&(t.splice(r,1),this.properties.setProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")),this.updateLanguages(t))}}addTargetLanguage(e){lt.Contracts.throwIfNullOrUndefined(e,"language to be added");let t=[];this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?(t=this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),t.includes(e)||(t.push(e),this.properties.setProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))):(this.properties.setProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,e),t=[e]),this.updateLanguages(t)}close(e,t){lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),ko.marshalPromiseToCallbacks(this.dispose(!0),e,t)}onConnection(){}async dispose(e){this.privDisposedTranslationRecognizer||(this.privDisposedTranslationRecognizer=!0,e&&(await this.implRecognizerStop(),await super.dispose(e)))}createRecognizerConfig(e){return new Rn.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Rn.TranslationServiceRecognizer(e,t,s,n,this)}updateLanguages(e){let t=qw.Connection.fromRecognizer(this);t&&(t.setMessageProperty("speech.context","translationcontext",{to:e}),t.sendMessageAsync("event",JSON.stringify({id:"translation",name:"updateLanguage",to:e})))}};No.TranslationRecognizer=Qh});var MS=p(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});qo.Translations=void 0;var xw=f(),Yh=class{constructor(){this.privMap=new xw.PropertyCollection}get languages(){return this.privMap.keys}get(e,t){return this.privMap.getProperty(e,t)}set(e,t){this.privMap.setProperty(e,t)}};qo.Translations=Yh});var DS=p(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.NoMatchReason=void 0;var zw;(function(i){i[i.NotRecognized=0]="NotRecognized",i[i.InitialSilenceTimeout=1]="InitialSilenceTimeout",i[i.InitialBabbleTimeout=2]="InitialBabbleTimeout"})(zw=En.NoMatchReason||(En.NoMatchReason={}))});var kS=p(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.NoMatchDetails=void 0;var Xh=C(),xo=f(),Zh=class i{constructor(e){this.privReason=e}static fromResult(e){let t=Xh.SimpleSpeechPhrase.fromJSON(e.json),r=xo.NoMatchReason.NotRecognized;switch(t.RecognitionStatus){case Xh.RecognitionStatus.BabbleTimeout:r=xo.NoMatchReason.InitialBabbleTimeout;break;case Xh.RecognitionStatus.InitialSilenceTimeout:r=xo.NoMatchReason.InitialSilenceTimeout;break;default:r=xo.NoMatchReason.NotRecognized;break}return new i(r)}get reason(){return this.privReason}};zo.NoMatchDetails=Zh});var NS=p(jo=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});jo.TranslationRecognitionCanceledEventArgs=void 0;var ed=class{constructor(e,t,r,n,s){this.privCancelReason=t,this.privErrorDetails=r,this.privResult=s,this.privSessionId=e,this.privErrorCode=n}get result(){return this.privResult}get sessionId(){return this.privSessionId}get reason(){return this.privCancelReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};jo.TranslationRecognitionCanceledEventArgs=ed});var qS=p(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.IntentRecognitionCanceledEventArgs=void 0;var jw=f(),td=class extends jw.IntentRecognitionEventArgs{constructor(e,t,r,n,s,o){super(n,s,o),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};Lo.IntentRecognitionCanceledEventArgs=td});var id=p(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.CancellationDetailsBase=void 0;var rd=class{constructor(e,t,r){this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get ErrorCode(){return this.privErrorCode}};Bo.CancellationDetailsBase=rd});var xS=p(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.CancellationDetails=void 0;var Fo=C(),Lw=id(),yi=f(),nd=class i extends Lw.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=yi.CancellationReason.Error,r=yi.CancellationErrorCode.NoError;if(e instanceof yi.RecognitionResult&&e.json){let n=Fo.SimpleSpeechPhrase.fromJSON(e.json);t=Fo.EnumTranslation.implTranslateCancelResult(n.RecognitionStatus)}return e.properties&&(r=yi.CancellationErrorCode[e.properties.getProperty(Fo.CancellationErrorCodePropertyName,yi.CancellationErrorCode[yi.CancellationErrorCode.NoError])]),new i(t,e.errorDetails||Fo.EnumTranslation.implTranslateErrorDetails(r),r)}};Vo.CancellationDetails=nd});var zS=p(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.CancellationErrorCode=void 0;var Bw;(function(i){i[i.NoError=0]="NoError",i[i.AuthenticationFailure=1]="AuthenticationFailure",i[i.BadRequestParameters=2]="BadRequestParameters",i[i.TooManyRequests=3]="TooManyRequests",i[i.ConnectionFailure=4]="ConnectionFailure",i[i.ServiceTimeout=5]="ServiceTimeout",i[i.ServiceError=6]="ServiceError",i[i.RuntimeError=7]="RuntimeError",i[i.Forbidden=8]="Forbidden"})(Bw=In.CancellationErrorCode||(In.CancellationErrorCode={}))});var jS=p(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.ConnectionEventArgs=void 0;var Fw=f(),sd=class extends Fw.SessionEventArgs{};Uo.ConnectionEventArgs=sd});var LS=p(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.ServiceEventArgs=void 0;var Vw=f(),od=class extends Vw.SessionEventArgs{constructor(e,t,r){super(r),this.privJsonResult=e,this.privEventName=t}get jsonString(){return this.privJsonResult}get eventName(){return this.privEventName}};Wo.ServiceEventArgs=od});var BS=p(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});Ho.PhraseListGrammar=void 0;var ad=class i{constructor(e){this.privGrammerBuilder=e.dynamicGrammar}static fromRecognizer(e){let t=e.internalData;return new i(t)}addPhrase(e){this.privGrammerBuilder.addPhrase(e)}addPhrases(e){this.privGrammerBuilder.addPhrase(e)}clear(){this.privGrammerBuilder.clearPhrases()}};Ho.PhraseListGrammar=ad});var Jo=p(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});Ci.DialogServiceConfigImpl=Ci.DialogServiceConfig=void 0;var Uw=I(),wn=f(),Ko=class{constructor(){}set applicationId(e){}static get DialogTypes(){return{BotFramework:"bot_framework",CustomCommands:"custom_commands"}}};Ci.DialogServiceConfig=Ko;var cd=class extends Ko{constructor(){super(),this.privSpeechConfig=new wn.SpeechConfigImpl}get properties(){return this.privSpeechConfig.properties}get speechRecognitionLanguage(){return this.privSpeechConfig.speechRecognitionLanguage}set speechRecognitionLanguage(e){Uw.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechConfig.speechRecognitionLanguage=e}get outputFormat(){return this.privSpeechConfig.outputFormat}set outputFormat(e){this.privSpeechConfig.outputFormat=e}setProperty(e,t){this.privSpeechConfig.setProperty(e,t)}getProperty(e,t){return this.privSpeechConfig.getProperty(e)}setProxy(e,t,r,n){this.setProperty(wn.PropertyId.SpeechServiceConnection_ProxyHostName,e),this.setProperty(wn.PropertyId.SpeechServiceConnection_ProxyPort,`${t}`),r&&this.setProperty(wn.PropertyId.SpeechServiceConnection_ProxyUserName,r),n&&this.setProperty(wn.PropertyId.SpeechServiceConnection_ProxyPassword,n)}setServiceProperty(e,t,r){this.privSpeechConfig.setServiceProperty(e,t)}close(){}};Ci.DialogServiceConfigImpl=cd});var FS=p(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.BotFrameworkConfig=void 0;var zr=I(),Vt=Jo(),je=f(),pd=class extends Vt.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){zr.Contracts.throwIfNullOrWhitespace(e,"subscription"),zr.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Vt.DialogServiceConfigImpl;return n.setProperty(je.PropertyId.Conversation_DialogType,Vt.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(je.PropertyId.SpeechServiceConnection_Key,e),n.setProperty(je.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(je.PropertyId.Conversation_ApplicationId,r),n}static fromAuthorizationToken(e,t,r){zr.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),zr.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Vt.DialogServiceConfigImpl;return n.setProperty(je.PropertyId.Conversation_DialogType,Vt.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(je.PropertyId.SpeechServiceAuthorization_Token,e),n.setProperty(je.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(je.PropertyId.Conversation_ApplicationId,r),n}static fromHost(e,t,r){zr.Contracts.throwIfNullOrUndefined(e,"host");let n=e instanceof URL?e:new URL(`wss://${e}.convai.speech.azure.us`);zr.Contracts.throwIfNullOrUndefined(n,"resolvedHost");let s=new Vt.DialogServiceConfigImpl;return s.setProperty(je.PropertyId.Conversation_DialogType,Vt.DialogServiceConfig.DialogTypes.BotFramework),s.setProperty(je.PropertyId.SpeechServiceConnection_Host,n.toString()),t!==void 0&&s.setProperty(je.PropertyId.SpeechServiceConnection_Key,t),s}static fromEndpoint(e,t){zr.Contracts.throwIfNull(e,"endpoint");let r=new Vt.DialogServiceConfigImpl;return r.setProperty(je.PropertyId.Conversation_DialogType,Vt.DialogServiceConfig.DialogTypes.BotFramework),r.setProperty(je.PropertyId.SpeechServiceConnection_Endpoint,e.toString()),t!==void 0&&r.setProperty(je.PropertyId.SpeechServiceConnection_Key,t),r}};Go.BotFrameworkConfig=pd});var VS=p($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.CustomCommandsConfig=void 0;var jr=I(),_n=Jo(),It=f(),ud=class extends _n.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){jr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),jr.Contracts.throwIfNullOrWhitespace(t,"subscription"),jr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new _n.DialogServiceConfigImpl;return n.setProperty(It.PropertyId.Conversation_DialogType,_n.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(It.PropertyId.Conversation_ApplicationId,e),n.setProperty(It.PropertyId.SpeechServiceConnection_Key,t),n.setProperty(It.PropertyId.SpeechServiceConnection_Region,r),n}static fromAuthorizationToken(e,t,r){jr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),jr.Contracts.throwIfNullOrWhitespace(t,"authorizationToken"),jr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new _n.DialogServiceConfigImpl;return n.setProperty(It.PropertyId.Conversation_DialogType,_n.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(It.PropertyId.Conversation_ApplicationId,e),n.setProperty(It.PropertyId.SpeechServiceAuthorization_Token,t),n.setProperty(It.PropertyId.SpeechServiceConnection_Region,r),n}set applicationId(e){jr.Contracts.throwIfNullOrWhitespace(e,"value"),this.setProperty(It.PropertyId.Conversation_ApplicationId,e)}get applicationId(){return this.getProperty(It.PropertyId.Conversation_ApplicationId)}};$o.CustomCommandsConfig=ud});var Ut=p(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.QueryParameterNames=void 0;var W=class{};Qo.QueryParameterNames=W;W.BotId="botid";W.CustomSpeechDeploymentId="cid";W.CustomVoiceDeploymentId="deploymentId";W.EnableAudioLogging="storeAudio";W.EnableLanguageId="lidEnabled";W.EnableWordLevelTimestamps="wordLevelTimestamps";W.EndSilenceTimeoutMs="endSilenceTimeoutMs";W.SegmentationSilenceTimeoutMs="segmentationSilenceTimeoutMs";W.Format="format";W.InitialSilenceTimeoutMs="initialSilenceTimeoutMs";W.Language="language";W.Profanity="profanity";W.RequestBotStatusMessages="enableBotMessageStatus";W.StableIntermediateThreshold="stableIntermediateThreshold";W.StableTranslation="stableTranslation";W.TestHooks="testhooks";W.Postprocessing="postprocessing";W.CtsMeetingId="meetingId";W.CtsDeviceId="deviceId";W.CtsIsParticipant="isParticipant";W.EnableAvatar="enableTalkingAvatar"});var Ye=p(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.ConnectionFactoryBase=void 0;var Ww=C(),cr=f(),pr=Ut(),hd=class{static getHostSuffix(e){if(e){if(e.toLowerCase().startsWith("china"))return".azure.cn";if(e.toLowerCase().startsWith("usgov"))return".azure.us"}return".microsoft.com"}setCommonUrlParams(e,t,r){new Map([[cr.PropertyId.Speech_SegmentationSilenceTimeoutMs,pr.QueryParameterNames.SegmentationSilenceTimeoutMs],[cr.PropertyId.SpeechServiceConnection_EnableAudioLogging,pr.QueryParameterNames.EnableAudioLogging],[cr.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,pr.QueryParameterNames.EndSilenceTimeoutMs],[cr.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,pr.QueryParameterNames.InitialSilenceTimeoutMs],[cr.PropertyId.SpeechServiceResponse_PostProcessingOption,pr.QueryParameterNames.Postprocessing],[cr.PropertyId.SpeechServiceResponse_ProfanityOption,pr.QueryParameterNames.Profanity],[cr.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,pr.QueryParameterNames.EnableWordLevelTimestamps],[cr.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,pr.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(Ww.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}setUrlParameter(e,t,r,n,s){let o=r.parameters.getProperty(e,void 0);o&&(!s||s.search(t)===-1)&&(n[t]=o.toLocaleLowerCase())}};Yo.ConnectionFactoryBase=hd});var KS=p(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.DialogConnectionFactory=void 0;var US=pe(),Hw=C(),Ue=f(),WS=Ye(),Kw=C(),HS=we(),Xo=Ut(),Tn=class i extends WS.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Ue.PropertyId.Conversation_ApplicationId,""),s=e.parameters.getProperty(Ue.PropertyId.Conversation_DialogType),o=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_Region),a=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),c=e.parameters.getProperty(Ue.PropertyId.Conversation_Request_Bot_Status_Messages,"true"),u={};u[HS.HeaderNames.ConnectionId]=r,u[Xo.QueryParameterNames.Format]=e.parameters.getProperty(Hw.OutputFormatPropertyName,Ue.OutputFormat[Ue.OutputFormat.Simple]).toLowerCase(),u[Xo.QueryParameterNames.Language]=a,u[Xo.QueryParameterNames.RequestBotStatusMessages]=c,n&&(u[Xo.QueryParameterNames.BotId]=n,s===Ue.DialogServiceConfig.DialogTypes.CustomCommands&&(u[HS.HeaderNames.CustomCommandsAppId]=n));let h=s===Ue.DialogServiceConfig.DialogTypes.CustomCommands?"commands/":"",d=s===Ue.DialogServiceConfig.DialogTypes.CustomCommands?"v1":s===Ue.DialogServiceConfig.DialogTypes.BotFramework?"v3":"v0",v={};t.token!=null&&t.token!==""&&(v[t.headerName]=t.token);let g=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_Endpoint,"");if(!g){let k=WS.ConnectionFactoryBase.getHostSuffix(o),ae=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_Host,`wss://${o}.${i.BaseUrl}${k}`);g=`${ae.endsWith("/")?ae:ae+"/"}${h}${i.ApiKey}/${d}`}this.setCommonUrlParams(e,u,g);let w=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new US.WebsocketConnection(g,u,v,new Kw.WebsocketMessageFormatter,US.ProxyInfo.fromRecognizerConfig(e),w,r)}};Zo.DialogConnectionFactory=Tn;Tn.ApiKey="api";Tn.BaseUrl="convai.speech"});var JS=p(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.DialogServiceConnector=void 0;var Jw=KS(),dd=C(),Pi=P(),ea=I(),Gw=f(),ur=Io(),ld=class extends Gw.Recognizer{constructor(e,t){let r=e;ea.Contracts.throwIfNull(e,"dialogConfig"),super(t,r.properties,new Jw.DialogConnectionFactory),this.isTurnComplete=!0,this.privIsDisposed=!1,this.privProperties=r.properties.clone();let n=this.buildAgentConfig();this.privReco.agentConfig.set(n)}connect(e,t){Pi.marshalPromiseToCallbacks(this.privReco.connect(),e,t)}disconnect(e,t){Pi.marshalPromiseToCallbacks(this.privReco.disconnect(),e,t)}get authorizationToken(){return this.properties.getProperty(ur.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){ea.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(ur.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get speechActivityTemplate(){return this.properties.getProperty(ur.PropertyId.Conversation_Speech_Activity_Template)}set speechActivityTemplate(e){this.properties.setProperty(ur.PropertyId.Conversation_Speech_Activity_Template,e)}listenOnceAsync(e,t){if(this.isTurnComplete){ea.Contracts.throwIfDisposed(this.privIsDisposed);let n=(async()=>{await this.privReco.connect(),await this.implRecognizerStop(),this.isTurnComplete=!1;let s=new Pi.Deferred;await this.privReco.recognize(dd.RecognitionMode.Conversation,s.resolve,s.reject);let o=await s.promise;return await this.implRecognizerStop(),o})();n.catch(()=>{this.dispose(!0).catch(()=>{})}),Pi.marshalPromiseToCallbacks(n.finally(()=>{this.isTurnComplete=!0}),e,t)}}sendActivityAsync(e,t,r){Pi.marshalPromiseToCallbacks(this.privReco.sendMessage(e),t,r)}close(e,t){ea.Contracts.throwIfDisposed(this.privIsDisposed),Pi.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privIsDisposed||e&&(this.privIsDisposed=!0,await this.implRecognizerStop(),await super.dispose(e))}createRecognizerConfig(e){return new dd.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new dd.DialogServiceAdapter(e,t,s,n,this)}buildAgentConfig(){return{botInfo:{commType:this.properties.getProperty("Conversation_Communication_Type","Default"),commandsCulture:void 0,connectionId:this.properties.getProperty(ur.PropertyId.Conversation_Agent_Connection_Id),conversationId:this.properties.getProperty(ur.PropertyId.Conversation_Conversation_Id,void 0),fromId:this.properties.getProperty(ur.PropertyId.Conversation_From_Id,void 0),ttsAudioFormat:this.properties.getProperty(ur.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)},version:.2}}};ta.DialogServiceConnector=ld});var GS=p(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.ActivityReceivedEventArgs=void 0;var vd=class{constructor(e,t){this.privActivity=e,this.privAudioStream=t}get activity(){return this.privActivity}get audioStream(){return this.privAudioStream}};ra.ActivityReceivedEventArgs=vd});var $S=p(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.TurnStatusResponsePayload=void 0;var fd=class i{constructor(e){this.privMessageStatusResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get interactionId(){return this.privMessageStatusResponse.interactionId}get conversationId(){return this.privMessageStatusResponse.conversationId}get statusCode(){switch(this.privMessageStatusResponse.statusCode){case"Success":return 200;case"Failed":return 400;case"TimedOut":return 429;default:return this.privMessageStatusResponse.statusCode}}};ia.TurnStatusResponsePayload=fd});var QS=p(na=>{"use strict";Object.defineProperty(na,"__esModule",{value:!0});na.TurnStatusReceivedEventArgs=void 0;var $w=$S(),gd=class{constructor(e){this.privTurnStatus=$w.TurnStatusResponsePayload.fromJSON(e)}get interactionId(){return this.privTurnStatus.interactionId}get conversationId(){return this.privTurnStatus.conversationId}get statusCode(){return this.privTurnStatus.statusCode}};na.TurnStatusReceivedEventArgs=gd});var YS=p(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.ServicePropertyChannel=void 0;var Qw;(function(i){i[i.UriQueryParameter=0]="UriQueryParameter"})(Qw=An.ServicePropertyChannel||(An.ServicePropertyChannel={}))});var XS=p(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.ProfanityOption=void 0;var Yw;(function(i){i[i.Masked=0]="Masked",i[i.Removed=1]="Removed",i[i.Raw=2]="Raw"})(Yw=bn.ProfanityOption||(bn.ProfanityOption={}))});var ZS=p(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.BaseAudioPlayer=void 0;var Xw=ht(),Zw=f(),e_=nr(),md=class{constructor(e){this.audioContext=null,this.gainNode=null,this.autoUpdateBufferTimer=0,e===void 0&&(e=Zw.AudioStreamFormat.getDefaultInputFormat()),this.init(e)}playAudioSample(e,t,r){try{this.ensureInitializedContext();let n=this.formatAudioData(e),s=new Float32Array(this.samples.length+n.length);s.set(this.samples,0),s.set(n,this.samples.length),this.samples=s,t&&t()}catch(n){r&&r(n)}}stopAudio(e,t){this.audioContext!==null&&(this.samples=new Float32Array,clearInterval(this.autoUpdateBufferTimer),this.audioContext.close().then(()=>{e&&e()},r=>{t&&t(r)}),this.audioContext=null)}init(e){this.audioFormat=e,this.samples=new Float32Array}ensureInitializedContext(){if(this.audioContext===null){this.createAudioContext();let e=200;this.autoUpdateBufferTimer=setInterval(()=>{this.updateAudioBuffer()},e)}}createAudioContext(){this.audioContext=e_.AudioStreamFormatImpl.getAudioContext(),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.gainNode.connect(this.audioContext.destination),this.startTime=this.audioContext.currentTime}formatAudioData(e){switch(this.audioFormat.bitsPerSample){case 8:return this.formatArrayBuffer(new Int8Array(e),128);case 16:return this.formatArrayBuffer(new Int16Array(e),32768);case 32:return this.formatArrayBuffer(new Int32Array(e),2147483648);default:throw new Xw.InvalidOperationError("Only WAVE_FORMAT_PCM (8/16/32 bps) format supported at this time")}}formatArrayBuffer(e,t){let r=new Float32Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]/t;return r}updateAudioBuffer(){if(this.samples.length===0)return;let e=this.audioFormat.channels,t=this.audioContext.createBufferSource(),r=this.samples.length/e,n=this.audioContext.createBuffer(e,r,this.audioFormat.samplesPerSec);for(let s=0;s<e;s++){let o=s,a=n.getChannelData(s);for(let c=0;c<this.samples.length;c++,o+=e)a[c]=this.samples[o]}this.startTime<this.audioContext.currentTime&&(this.startTime=this.audioContext.currentTime),t.buffer=n,t.connect(this.gainNode),t.start(this.startTime),this.startTime+=n.duration,this.samples=new Float32Array}async playAudio(e){this.audioContext===null&&this.createAudioContext();let t=this.audioContext.createBufferSource(),r=this.audioContext.destination;await this.audioContext.decodeAudioData(e,n=>{t.buffer=n,t.connect(r),t.start(0)})}};sa.BaseAudioPlayer=md});var ey=p(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0});oa.ConnectionMessageEventArgs=void 0;var Sd=class{constructor(e){this.privConnectionMessage=e}get message(){return this.privConnectionMessage}toString(){return"Message: "+this.privConnectionMessage.toString()}};oa.ConnectionMessageEventArgs=Sd});var ty=p(aa=>{"use strict";Object.defineProperty(aa,"__esModule",{value:!0});aa.VoiceProfile=void 0;var yd=class{constructor(e,t){this.privId=e,this.privProfileType=t}get profileId(){return this.privId}get profileType(){return this.privProfileType}};aa.VoiceProfile=yd});var iy=p(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});Ri.VoiceProfileEnrollmentCancellationDetails=Ri.VoiceProfileEnrollmentResult=void 0;var ry=C(),ge=f(),Cd=class i{constructor(e,t,r){this.privReason=e,this.privProperties=new ge.PropertyCollection,this.privReason!==ge.ResultReason.Canceled?t&&(this.privDetails=JSON.parse(t),this.privDetails.enrollmentStatus.toLowerCase()==="enrolling"&&(this.privReason=ge.ResultReason.EnrollingVoiceProfile)):(this.privErrorDetails=r,this.privProperties.setProperty(ry.CancellationErrorCodePropertyName,ge.CancellationErrorCode[ge.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get enrollmentsCount(){return this.privDetails.enrollmentsCount}get enrollmentsLength(){return this.privDetails.enrollmentsLength}get properties(){return this.privProperties}get enrollmentResultDetails(){return this.privDetails}get errorDetails(){return this.privErrorDetails}static FromIdentificationProfileList(e){let t=[];for(let r of e.value){let n=r.enrollmentStatus.toLowerCase()==="enrolling"?ge.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ge.ResultReason.EnrolledVoiceProfile:ge.ResultReason.Canceled,s=new i(n,null,null);s.privDetails=this.getIdentificationDetails(r),t.push(s)}return t}static FromVerificationProfileList(e){let t=[];for(let r of e.value){let n=r.enrollmentStatus.toLowerCase()==="enrolling"?ge.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ge.ResultReason.EnrolledVoiceProfile:ge.ResultReason.Canceled,s=new i(n,null,null);s.privDetails=this.getVerificationDetails(r),t.push(s)}return t}static getIdentificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount||0,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.identificationProfileId,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}static getVerificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.verificationProfileId,remainingEnrollmentsCount:e.remainingEnrollments||e.remainingEnrollmentsCount,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}};Ri.VoiceProfileEnrollmentResult=Cd;var Pd=class i extends ge.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=ge.CancellationReason.Error,r=ge.CancellationErrorCode.NoError;return e.properties&&(r=ge.CancellationErrorCode[e.properties.getProperty(ry.CancellationErrorCodePropertyName,ge.CancellationErrorCode[ge.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ri.VoiceProfileEnrollmentCancellationDetails=Pd});var sy=p(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.VoiceProfileCancellationDetails=Ei.VoiceProfileResult=void 0;var ny=C(),t_=I(),wt=f(),Rd=class{constructor(e,t){this.privReason=e,this.privProperties=new wt.PropertyCollection,e===wt.ResultReason.Canceled&&(t_.Contracts.throwIfNullOrUndefined(t,"statusText"),this.privErrorDetails=t,this.privProperties.setProperty(ny.CancellationErrorCodePropertyName,wt.CancellationErrorCode[wt.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get properties(){return this.privProperties}get errorDetails(){return this.privErrorDetails}};Ei.VoiceProfileResult=Rd;var Ed=class i extends wt.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=wt.CancellationReason.Error,r=wt.CancellationErrorCode.NoError;return e.properties&&(r=wt.CancellationErrorCode[e.properties.getProperty(ny.CancellationErrorCodePropertyName,wt.CancellationErrorCode[wt.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ei.VoiceProfileCancellationDetails=Ed});var oy=p(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.VoiceProfilePhraseResult=void 0;var r_=I(),i_=f(),Id=class extends i_.VoiceProfileResult{constructor(e,t,r,n){super(e,t),this.privPhrases=[],r_.Contracts.throwIfNullOrUndefined(n,"phrase array"),this.privType=r,n&&n[0]&&(this.privPhrases=n)}get phrases(){return this.privPhrases}get type(){return this.privType}};ca.VoiceProfilePhraseResult=Id});var ay=p(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.VoiceProfileClient=void 0;var wd=C(),n_=yh(),pa=I(),Lr=f(),_d=class extends Lr.Recognizer{constructor(e){pa.Contracts.throwIfNullOrUndefined(e,"speechConfig");let t=e;pa.Contracts.throwIfNull(t,"speechConfig"),super(n_.AudioConfig.fromStreamInput(Lr.AudioInputStream.createPushStream()),t.properties,new wd.VoiceProfileConnectionFactory),this.privProperties=t.properties.clone(),this.privVoiceAdapter=this.privReco,this.privDisposedVoiceAdapter=!1}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Lr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){pa.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Lr.PropertyId.SpeechServiceAuthorization_Token,e)}async createProfileAsync(e,t){let r=await this.privVoiceAdapter.createProfile(e,t);return new Lr.VoiceProfile(r[0],e)}async retrieveEnrollmentResultAsync(e){return this.privVoiceAdapter.retrieveEnrollmentResult(e)}async getAllProfilesAsync(e){return this.privVoiceAdapter.getAllProfiles(e)}async getActivationPhrasesAsync(e,t){return this.privVoiceAdapter.getActivationPhrases(e,t)}async enrollProfileAsync(e,t){let r=t;return pa.Contracts.throwIfNullOrUndefined(r,"audioConfig"),this.audioConfig=t,this.privVoiceAdapter.SpeakerAudioSource=r,this.privVoiceAdapter.enrollProfile(e)}async deleteProfileAsync(e){return this.privVoiceAdapter.deleteProfile(e)}async resetProfileAsync(e){return this.privVoiceAdapter.resetProfile(e)}async close(){await this.dispose(!0)}createServiceRecognizer(e,t,r,n){let s=r;return new wd.VoiceServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedVoiceAdapter||(this.privDisposedVoiceAdapter=!0,e&&await super.dispose(e))}createRecognizerConfig(e){return new wd.RecognizerConfig(e,this.properties)}getResult(e,t){return new Lr.VoiceProfileResult(e.ok?t:Lr.ResultReason.Canceled,e.statusText)}};ua.VoiceProfileClient=_d});var cy=p(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.SpeakerRecognizer=void 0;var Td=C(),Br=I(),Ad=f(),bd=class extends Ad.Recognizer{constructor(e,t){Br.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;Br.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new Td.SpeakerRecognitionConnectionFactory),this.privAudioConfigImpl=t,Br.Contracts.throwIfNull(this.privAudioConfigImpl,"audioConfig"),this.privDisposedSpeakerRecognizer=!1,this.privProperties=r.properties}get authorizationToken(){return this.properties.getProperty(Ad.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Br.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Ad.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}async recognizeOnceAsync(e){return Br.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),this.recognizeSpeakerOnceAsyncImpl(e)}async close(){Br.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.dispose(!0)}async recognizeSpeakerOnceAsyncImpl(e){Br.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.implRecognizerStop();let t=await this.privReco.recognizeSpeaker(e);return await this.implRecognizerStop(),t}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}createRecognizerConfig(e){return new Td.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Td.SpeakerServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedSpeakerRecognizer||e&&(this.privDisposedSpeakerRecognizer=!0,await super.dispose(e))}};ha.SpeakerRecognizer=bd});var py=p(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.SpeakerIdentificationModel=void 0;var s_=I(),o_=f(),Od=class i{constructor(e){if(this.privVoiceProfiles=[],this.privProfileIds=[],s_.Contracts.throwIfNullOrUndefined(e,"VoiceProfiles"),e.length===0)throw new Error("Empty Voice Profiles array");for(let t of e){if(t.profileType!==o_.VoiceProfileType.TextIndependentIdentification)throw new Error("Identification model can only be created from Identification profile: "+t.profileId);this.privVoiceProfiles.push(t),this.privProfileIds.push(t.profileId)}}static fromProfiles(e){return new i(e)}get voiceProfileIds(){return this.privProfileIds.join(",")}get profileIds(){return this.privProfileIds}get scenario(){return"TextIndependentIdentification"}};da.SpeakerIdentificationModel=Od});var hy=p(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.SpeakerVerificationModel=void 0;var a_=I(),uy=f(),Md=class i{constructor(e){if(a_.Contracts.throwIfNullOrUndefined(e,"VoiceProfile"),e.profileType===uy.VoiceProfileType.TextIndependentIdentification)throw new Error("Verification model cannot be created from Identification profile");this.privVoiceProfile=e}static fromProfile(e){return new i(e)}get voiceProfile(){return this.privVoiceProfile}get profileIds(){return[this.voiceProfile.profileId]}get scenario(){return this.voiceProfile.profileType===uy.VoiceProfileType.TextDependentVerification?"TextDependentVerification":"TextIndependentVerification"}};la.SpeakerVerificationModel=Md});var Dd=p(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.LanguageIdMode=void 0;var c_;(function(i){i[i.AtStart=0]="AtStart",i[i.Continuous=1]="Continuous"})(c_=On.LanguageIdMode||(On.LanguageIdMode={}))});var ly=p(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});va.AutoDetectSourceLanguageConfig=void 0;var p_=C(),u_=I(),_t=f(),dy=Dd(),kd=class i{constructor(){this.privProperties=new _t.PropertyCollection,this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart"),this.privLanguageIdMode=dy.LanguageIdMode.AtStart}static fromOpenRange(){let e=new i;return e.properties.setProperty(_t.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,p_.AutoDetectSourceLanguagesOpenRangeOptionName),e}static fromLanguages(e){u_.Contracts.throwIfArrayEmptyOrWhitespace(e,"languages");let t=new i;return t.properties.setProperty(_t.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e.join()),t}static fromSourceLanguageConfigs(e){if(e.length<1)throw new Error("Expected non-empty SourceLanguageConfig array.");let t=new i,r=[];return e.forEach(n=>{if(r.push(n.language),n.endpointId!==void 0&&n.endpointId!==""){let s=n.language+_t.PropertyId.SpeechServiceConnection_EndpointId.toString();t.properties.setProperty(s,n.endpointId)}}),t.properties.setProperty(_t.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,r.join()),t}get properties(){return this.privProperties}set mode(e){e===dy.LanguageIdMode.Continuous?(this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_LanguageIdMode,"Continuous")):(this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"1"),this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart")),this.privLanguageIdMode=e}};va.AutoDetectSourceLanguageConfig=kd});var fy=p(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.AutoDetectSourceLanguageResult=void 0;var vy=I(),Nd=class i{constructor(e,t){vy.Contracts.throwIfNullOrUndefined(e,"language"),vy.Contracts.throwIfNullOrUndefined(t,"languageDetectionConfidence"),this.privLanguage=e,this.privLanguageDetectionConfidence=t}static fromResult(e){return new i(e.language,e.languageDetectionConfidence)}static fromConversationTranscriptionResult(e){return new i(e.language,e.languageDetectionConfidence)}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}};fa.AutoDetectSourceLanguageResult=Nd});var gy=p(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.SourceLanguageConfig=void 0;var h_=I(),qd=class i{constructor(e,t){h_.Contracts.throwIfNullOrUndefined(e,"language"),this.privLanguage=e,this.privEndpointId=t}static fromLanguage(e,t){return new i(e,t)}get language(){return this.privLanguage}get endpointId(){return this.privEndpointId}};ga.SourceLanguageConfig=qd});var Sy=p(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.SpeakerRecognitionCancellationDetails=Wt.SpeakerRecognitionResult=Wt.SpeakerRecognitionResultType=void 0;var my=C(),Le=f(),ma;(function(i){i[i.Verify=0]="Verify",i[i.Identify=1]="Identify"})(ma=Wt.SpeakerRecognitionResultType||(Wt.SpeakerRecognitionResultType={}));var xd=class{constructor(e,t=Le.ResultReason.RecognizedSpeaker,r=Le.CancellationErrorCode.NoError,n=""){this.privProperties=new Le.PropertyCollection;let s=e.scenario==="TextIndependentIdentification"?ma.Identify:ma.Verify;this.privReason=t,this.privReason!==Le.ResultReason.Canceled?s===ma.Identify?(this.privProfileId=e.identificationResult.identifiedProfile.profileId,this.privScore=e.identificationResult.identifiedProfile.score,this.privReason=Le.ResultReason.RecognizedSpeakers):(this.privScore=e.verificationResult.score,e.verificationResult.recognitionResult.toLowerCase()!=="accept"&&(this.privReason=Le.ResultReason.NoMatch),e.verificationResult.profileId!==void 0&&e.verificationResult.profileId!==""&&(this.privProfileId=e.verificationResult.profileId)):(this.privErrorDetails=n,this.privProperties.setProperty(my.CancellationErrorCodePropertyName,Le.CancellationErrorCode[r])),this.privProperties.setProperty(Le.PropertyId.SpeechServiceResponse_JsonResult,JSON.stringify(e))}get properties(){return this.privProperties}get reason(){return this.privReason}get profileId(){return this.privProfileId}get errorDetails(){return this.privErrorDetails}get score(){return this.privScore}};Wt.SpeakerRecognitionResult=xd;var zd=class i extends Le.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=Le.CancellationReason.Error,r=Le.CancellationErrorCode.NoError;return e.properties&&(r=Le.CancellationErrorCode[e.properties.getProperty(my.CancellationErrorCodePropertyName,Le.CancellationErrorCode[Le.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Wt.SpeakerRecognitionCancellationDetails=zd});var jd=p(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.ConversationImpl=Ii.Conversation=void 0;var x=C(),Mn=P(),S=I(),q=f(),Sa=class{constructor(){}static createConversationAsync(e,t,r,n){S.Contracts.throwIfNullOrUndefined(e,x.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),S.Contracts.throwIfNullOrUndefined(e.region,x.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),!e.subscriptionKey&&!e.getProperty(q.PropertyId[q.PropertyId.SpeechServiceAuthorization_Token])&&S.Contracts.throwIfNullOrUndefined(e.subscriptionKey,x.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s,o,a;return typeof t=="string"?(s=new Dn(e,t),Mn.marshalPromiseToCallbacks((async()=>{})(),r,n)):(s=new Dn(e),o=t,a=r,s.createConversationAsync(()=>{o&&o()},c=>{a&&a(c)})),s}};Ii.Conversation=Sa;var Dn=class extends Sa{constructor(e,t){if(super(),this.privErrors=x.ConversationConnectionConfig.restErrors,this.onConnected=s=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,s)}catch{}},this.onDisconnected=s=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,s)}catch{}finally{this.close(!1)}},this.onCanceled=(s,o)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,o)}catch{}},this.onParticipantUpdateCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.id);if(a!==void 0){switch(o.key){case x.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case x.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case x.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case x.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case x.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.Updated,[this.toParticipant(a)],o.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(s,o)=>{try{this.privParticipants.participants.forEach(a=>a.isMuted=a.isHost?!1:o.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.Updated,this.toParticipants(!1),o.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(s,o)=>{try{let a=this.privParticipants.addOrUpdateParticipant(o.participant);a!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.JoinedConversation,[this.toParticipant(a)],o.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.participant.id);a!==void 0&&(this.privParticipants.deleteParticipant(o.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case x.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new q.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case x.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new q.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case x.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new q.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break}}catch{}},this.onParticipantsListReceived=(s,o)=>{try{if(o.sessionToken!==void 0&&o.sessionToken!==null&&(this.privRoom.token=o.sessionToken),this.privParticipants.participants=[...o.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(q.PropertyId.ConversationTranslator_Name);a!==void 0&&a.length>0&&a!==this.me.displayName&&this.changeNicknameAsync(a)}}catch{}},this.onConversationExpiration=(s,o)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,o)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new q.PropertyCollection,this.privManager=new x.ConversationManager,e.getProperty(q.PropertyId[q.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(q.PropertyId[q.PropertyId.SpeechServiceConnection_RecoLanguage],x.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(q.PropertyId[q.PropertyId.SpeechServiceConnection_RecoLanguage]),t)this.privConversationId=t;else{e.targetLanguages.length===0&&e.addTargetLanguage(this.privLanguage),e.getProperty(q.PropertyId[q.PropertyId.SpeechServiceResponse_ProfanityOption])||e.setProfanity(q.ProfanityOption.Masked);let o=e.getProperty(q.PropertyId[q.PropertyId.ConversationTranslator_Name]);o==null&&(o="Host"),S.Contracts.throwIfNullOrTooLong(o,"nickname",50),S.Contracts.throwIfNullOrTooShort(o,"nickname",2),e.setProperty(q.PropertyId[q.PropertyId.ConversationTranslator_Name],o)}this.privConfig=e;let n=e;S.Contracts.throwIfNull(n,"speechConfig"),this.privProperties=n.properties.clone(),this.privIsConnected=!1,this.privParticipants=new x.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get conversationId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return this.privParticipants.me?.isHost?!1:this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get conversationInfo(){let e=this.conversationId,t=this.participants.map(s=>({id:s.id,preferredLanguage:s.preferredLanguage,voice:s.voice})),r={};for(let s of x.ConversationConnectionConfig.transcriptionEventKeys){let o=this.properties.getProperty(s,"");o!==""&&(r[s]=o)}return{id:e,participants:t,conversationProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){S.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}set conversationTranslator(e){this.privConversationTranslator=e}onToken(e){this.privConversationTranslator.onToken(e)}createConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}startConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer=x.ConversationRecognizerFactory.fromConfig(this,this.privConfig),this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.disconnected=this.onDisconnected,this.privConversationRecognizer.canceled=this.onCanceled,this.privConversationRecognizer.participantUpdateCommandReceived=this.onParticipantUpdateCommandReceived,this.privConversationRecognizer.lockRoomCommandReceived=this.onLockRoomCommandReceived,this.privConversationRecognizer.muteAllCommandReceived=this.onMuteAllCommandReceived,this.privConversationRecognizer.participantJoinCommandReceived=this.onParticipantJoinCommandReceived,this.privConversationRecognizer.participantLeaveCommandReceived=this.onParticipantLeaveCommandReceived,this.privConversationRecognizer.translationReceived=this.onTranslationReceived,this.privConversationRecognizer.participantsListReceived=this.onParticipantsListReceived,this.privConversationRecognizer.conversationExpiration=this.onConversationExpiration,this.privConversationRecognizer.connect(this.privRoom.token,()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}addParticipantAsync(e,t,r){S.Contracts.throwIfNullOrUndefined(e,"Participant"),Mn.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),t,r)}joinConversationAsync(e,t,r,n,s){try{S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),S.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),S.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,o=>{S.Contracts.throwIfNullOrUndefined(o,this.privErrors.permissionDeniedConnect),this.privRoom=o,this.privConfig.authorizationToken=o.cognitiveSpeechAuthToken,n&&n(o.cognitiveSpeechAuthToken)},o=>{this.handleError(o,s)})}catch(o){this.handleError(o,s)}}deleteConversationAsync(e,t){Mn.marshalPromiseToCallbacks(this.deleteConversationImplAsync(),e,t)}async deleteConversationImplAsync(){S.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),S.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endConversationAsync(e,t){Mn.marshalPromiseToCallbacks(this.endConversationImplAsync(),e,t)}endConversationImplAsync(){return this.close(!0)}lockConversationAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteAllParticipantsAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteParticipantAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}removeParticipantAsync(e,t,r){try{if(S.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))Mn.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),t,r);else{S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let n="";typeof e=="string"?n=e:e.hasOwnProperty("id")?n=e.id:e.hasOwnProperty("userId")&&(n=e.userId),S.Contracts.throwIfNullOrWhitespace(n,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(o=>o.id===n)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(n),()=>{this.handleCallback(t,r)},o=>{this.handleError(o,r)})}}catch(n){this.handleError(n,r)}}unlockConversationAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteAllParticipantsAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteParticipantAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}sendTextMessageAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}setTranslatedLanguagesAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}changeNicknameAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),this.privConfig=void 0,this.privLanguage=void 0,this.privProperties=void 0,this.privRoom=void 0,this.privToken=void 0,this.privManager=void 0,this.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.conversation=this}getKeepAlive(){let e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){let r=this.conversationInfo;return r.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(r,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);let t=this.conversationInfo;return t.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await this.privConversationRecognizer?.close(),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(t){throw t}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){let t=this.privParticipants.participants.map(r=>this.toParticipant(r));return e?t:t.filter(r=>r.isHost===!1)}toParticipant(e){return new q.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"nickname"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),S.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:x.ConversationTranslatorMessageTypes.instantMessage})}};Ii.ConversationImpl=Dn});var yy=p(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.ConversationCommon=void 0;var Ld=class{constructor(e){this.privAudioConfig=e}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}};ya.ConversationCommon=Ld});var Cy=p(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.ConversationExpirationEventArgs=void 0;var d_=f(),Bd=class extends d_.SessionEventArgs{constructor(e,t){super(t),this.privExpirationTime=e}get expirationTime(){return this.privExpirationTime}};Ca.ConversationExpirationEventArgs=Bd});var Py=p(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.ConversationParticipantsChangedEventArgs=void 0;var l_=f(),Fd=class extends l_.SessionEventArgs{constructor(e,t,r){super(r),this.privReason=e,this.privParticipant=t}get reason(){return this.privReason}get participants(){return this.privParticipant}};Pa.ConversationParticipantsChangedEventArgs=Fd});var Ry=p(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.ConversationTranslationCanceledEventArgs=void 0;var v_=vi(),Vd=class extends v_.CancellationEventArgsBase{};Ra.ConversationTranslationCanceledEventArgs=Vd});var Ey=p(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.ConversationTranslationEventArgs=void 0;var f_=f(),Ud=class extends f_.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};Ea.ConversationTranslationEventArgs=Ud});var Iy=p(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.ConversationTranslationResult=void 0;var g_=xh(),Wd=class extends g_.TranslationRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(t,n,s,o,a,c,void 0,void 0,u,h,d),this.privId=e,this.privOrigLang=r}get participantId(){return this.privId}get originalLang(){return this.privOrigLang}};Ia.ConversationTranslationResult=Wd});var Kd=p(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.StringUtils=void 0;var Hd=class{static formatString(e,t){if(!e)return"";if(!t)return e;let r="",n="",s=c=>{r+=c},o=c=>{n+=c},a=s;for(let c=0;c<e.length;c++){let u=e[c],h=c+1<e.length?e[c+1]:"";switch(u){case"{":h==="{"?(a("{"),c++):a=o;break;case"}":h==="}"?(a("}"),c++):(t.hasOwnProperty(n)&&(r+=t[n]),a=s,n="");break;default:a(u);break}}return r}};wa.StringUtils=Hd});var Ty=p(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.ConversationTranslatorConnectionFactory=void 0;var Jd=pe(),wy=Kd(),m_=I(),_a=f(),S_=we(),Xe=Ut(),_y=Ye(),Gd=C(),Ta=class i extends _y.ConnectionFactoryBase{constructor(e){super(),m_.Contracts.throwIfNullOrUndefined(e,"convGetter"),this.privConvGetter=e}create(e,t,r){let n=e.parameters.getProperty("ConversationTranslator_MultiChannelAudio","").toUpperCase()==="TRUE",s=this.privConvGetter().room,o=s.cognitiveSpeechRegion||e.parameters.getProperty(_a.PropertyId.SpeechServiceConnection_Region,""),a={hostSuffix:_y.ConnectionFactoryBase.getHostSuffix(o),path:i.CTS_VIRT_MIC_PATH,region:encodeURIComponent(o)};a[Xe.QueryParameterNames.Language]=encodeURIComponent(e.parameters.getProperty(_a.PropertyId.SpeechServiceConnection_RecoLanguage,"")),a[Xe.QueryParameterNames.CtsMeetingId]=encodeURIComponent(s.roomId),a[Xe.QueryParameterNames.CtsDeviceId]=encodeURIComponent(s.participantId),a[Xe.QueryParameterNames.CtsIsParticipant]=s.isHost?"":"&"+Xe.QueryParameterNames.CtsIsParticipant;let c="",u={},h={};if(n){c=e.parameters.getProperty(_a.PropertyId.SpeechServiceConnection_Endpoint),c||(c="wss://"+e.parameters.getProperty(_a.PropertyId.SpeechServiceConnection_Host,"transcribe.{region}.cts.speech{hostSuffix}")+"{path}"),c=wy.StringUtils.formatString(c,a);let v=new URL(c);v.searchParams.forEach((w,k)=>{u[k]=w}),new Gd.TranscriberConnectionFactory().setQueryParams(u,e,c),u[Xe.QueryParameterNames.CtsMeetingId]=a[Xe.QueryParameterNames.CtsMeetingId],u[Xe.QueryParameterNames.CtsDeviceId]=a[Xe.QueryParameterNames.CtsDeviceId],s.isHost||(u[Xe.QueryParameterNames.CtsIsParticipant]=""),Xe.QueryParameterNames.Format in u||(u[Xe.QueryParameterNames.Format]="simple"),v.searchParams.forEach((w,k)=>{v.searchParams.set(k,u[k]),delete u[k]}),c=v.toString()}else{let v=new Gd.TranslationConnectionFactory;c=v.getEndpointUrl(e,!0),c=wy.StringUtils.formatString(c,a),v.setQueryParams(u,e,c)}h[S_.HeaderNames.ConnectionId]=r,h[Jd.RestConfigBase.configParams.token]=s.token,t.token&&(h[t.headerName]=t.token);let d=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","").toUpperCase()==="TRUE";return new Jd.WebsocketConnection(c,u,h,new Gd.WebsocketMessageFormatter,Jd.ProxyInfo.fromRecognizerConfig(e),d,r)}};Aa.ConversationTranslatorConnectionFactory=Ta;Ta.CTS_VIRT_MIC_PATH="/speech/recognition/dynamicaudio"});var by=p(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.ConversationTranslator=Fr.SpeechState=void 0;var kn=C(),y_=Ty(),ba=P(),vt=I(),V=f(),C_=jd(),Ay=Oa(),ft;(function(i){i[i.Inactive=0]="Inactive",i[i.Connecting=1]="Connecting",i[i.Connected=2]="Connected"})(ft=Fr.SpeechState||(Fr.SpeechState={}));var $d=class extends V.TranslationRecognizer{constructor(e,t,r,n){super(e,t,new y_.ConversationTranslatorConnectionFactory(n)),this.privSpeechState=ft.Inactive,r&&(this.privTranslator=r,this.sessionStarted=()=>{this.privSpeechState=ft.Connected},this.sessionStopped=()=>{this.privSpeechState=ft.Inactive},this.recognizing=(s,o)=>{this.privTranslator.recognizing&&this.privTranslator.recognizing(this.privTranslator,o)},this.recognized=async(s,o)=>{o.result?.errorDetails?(await this.cancelSpeech(),this.fireCancelEvent(o.result.errorDetails)):this.privTranslator.recognized&&this.privTranslator.recognized(this.privTranslator,o)},this.canceled=async()=>{if(this.privSpeechState!==ft.Inactive)try{await this.cancelSpeech()}catch{this.privSpeechState=ft.Inactive}})}get state(){return this.privSpeechState}set state(e){this.privSpeechState=e}set authentication(e){this.privReco.authentication=e}onConnection(){this.privSpeechState=ft.Connected}async onCancelSpeech(){this.privSpeechState=ft.Inactive,await this.cancelSpeech()}fireCancelEvent(e){try{if(this.privTranslator.canceled){let t=new Ay.ConversationTranslationCanceledEventArgs(V.CancellationReason.Error,e,V.CancellationErrorCode.RuntimeError);this.privTranslator.canceled(this.privTranslator,t)}}catch{}}async cancelSpeech(){try{this.stopContinuousRecognitionAsync(),await this.privReco?.disconnect(),this.privSpeechState=ft.Inactive}catch{}}},Qd=class extends Ay.ConversationCommon{constructor(e){super(e),this.privErrors=kn.ConversationConnectionConfig.restErrors,this.privIsDisposed=!1,this.privIsSpeaking=!1,this.privPlaceholderKey="abcdefghijklmnopqrstuvwxyz012345",this.privPlaceholderRegion="westus",this.privProperties=new V.PropertyCollection}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get participants(){return this.privConversation?.participants}get canSpeak(){return!(!this.privConversation.isConnected||!this.privCTRecognizer||this.privIsSpeaking||this.privCTRecognizer.state===ft.Connected||this.privCTRecognizer.state===ft.Connecting||this.privConversation.isMutedByHost)}onToken(e){this.privCTRecognizer.authentication=e}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(kn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(kn.ServicePropertiesPropertyName,JSON.stringify(r))}joinConversationAsync(e,t,r,n,s){try{if(typeof e=="string"){vt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),vt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privConversation&&this.handleError(new Error(this.privErrors.permissionDeniedStart),s);let o=r;(o==null||o==="")&&(o=kn.ConversationConnectionConfig.defaultLanguageCode),this.privSpeechTranslationConfig=V.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey,this.privPlaceholderRegion),this.privSpeechTranslationConfig.setProfanity(V.ProfanityOption.Masked),this.privSpeechTranslationConfig.addTargetLanguage(o),this.privSpeechTranslationConfig.setProperty(V.PropertyId[V.PropertyId.SpeechServiceConnection_RecoLanguage],o),this.privSpeechTranslationConfig.setProperty(V.PropertyId[V.PropertyId.ConversationTranslator_Name],t);let a=[V.PropertyId.SpeechServiceConnection_Host,V.PropertyId.ConversationTranslator_Host,V.PropertyId.SpeechServiceConnection_Endpoint,V.PropertyId.SpeechServiceConnection_ProxyHostName,V.PropertyId.SpeechServiceConnection_ProxyPassword,V.PropertyId.SpeechServiceConnection_ProxyPort,V.PropertyId.SpeechServiceConnection_ProxyUserName,"ConversationTranslator_MultiChannelAudio","ConversationTranslator_Region"];for(let u of a){let h=this.privProperties.getProperty(u);if(h){let d=typeof u=="string"?u:V.PropertyId[u];this.privSpeechTranslationConfig.setProperty(d,h)}}let c=JSON.parse(this.privProperties.getProperty(kn.ServicePropertiesPropertyName,"{}"));for(let u of Object.keys(c))this.privSpeechTranslationConfig.setServiceProperty(u,c[u],V.ServicePropertyChannel.UriQueryParameter);this.privConversation=new C_.ConversationImpl(this.privSpeechTranslationConfig),this.privConversation.conversationTranslator=this,this.privConversation.joinConversationAsync(e,t,o,u=>{u||this.handleError(new Error(this.privErrors.permissionDeniedConnect),s),this.privSpeechTranslationConfig.authorizationToken=u,this.privConversation.room.isHost=!1,this.privConversation.startConversationAsync(()=>{this.handleCallback(n,s)},h=>{this.handleError(h,s)})},u=>{this.handleError(u,s)})}else typeof e=="object"?(vt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),vt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privProperties.setProperty(V.PropertyId.ConversationTranslator_Name,t),this.privConversation=e,this.privConversation.conversationTranslator=this,this.privConversation.room.isHost=!0,vt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedConnect),vt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privSpeechTranslationConfig=e.config,this.handleCallback(r,n)):this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","invalid conversation type")),n)}catch(o){this.handleError(o,typeof r=="string"?s:n)}}leaveConversationAsync(e,t){ba.marshalPromiseToCallbacks((async()=>{await this.cancelSpeech(),await this.privConversation.endConversationImplAsync(),await this.privConversation.deleteConversationImplAsync(),this.dispose()})(),e,t)}sendTextMessageAsync(e,t,r){try{vt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),vt.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}",e)),this.privConversation.sendTextMessageAsync(e,t,r)}catch(n){this.handleError(n,r)}}startTranscribingAsync(e,t){ba.marshalPromiseToCallbacks((async()=>{try{vt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),vt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privCTRecognizer===void 0&&await this.connectTranslatorRecognizer(),vt.Contracts.throwIfNullOrUndefined(this.privCTRecognizer,this.privErrors.permissionDeniedSend),this.canSpeak||this.handleError(new Error(this.privErrors.permissionDeniedSend),t),await this.startContinuousRecognition(),this.privIsSpeaking=!0}catch(r){throw this.privIsSpeaking=!1,await this.cancelSpeech(),r}})(),e,t)}stopTranscribingAsync(e,t){ba.marshalPromiseToCallbacks((async()=>{try{if(!this.privIsSpeaking){await this.cancelSpeech();return}this.privIsSpeaking=!1,await new Promise((r,n)=>{this.privCTRecognizer.stopContinuousRecognitionAsync(r,n)})}catch{await this.cancelSpeech()}})(),e,t)}isDisposed(){return this.privIsDisposed}dispose(e,t,r){ba.marshalPromiseToCallbacks((async()=>{this.isDisposed&&!this.privIsSpeaking||(await this.cancelSpeech(),this.privIsDisposed=!0,this.privSpeechTranslationConfig.close(),this.privSpeechRecognitionLanguage=void 0,this.privProperties=void 0,this.privAudioConfig=void 0,this.privSpeechTranslationConfig=void 0,this.privConversation.dispose(),this.privConversation=void 0)})(),t,r)}async cancelSpeech(){try{this.privIsSpeaking=!1,await this.privCTRecognizer?.onCancelSpeech(),this.privCTRecognizer=void 0}catch{}}async connectTranslatorRecognizer(){try{this.privAudioConfig===void 0&&(this.privAudioConfig=V.AudioConfig.fromDefaultMicrophoneInput()),this.privSpeechTranslationConfig.getProperty(V.PropertyId[V.PropertyId.SpeechServiceConnection_Key])===this.privPlaceholderKey&&this.privSpeechTranslationConfig.setProperty(V.PropertyId[V.PropertyId.SpeechServiceConnection_Key],"");let e=()=>this.privConversation;this.privCTRecognizer=new $d(this.privSpeechTranslationConfig,this.privAudioConfig,this,e)}catch(e){throw await this.cancelSpeech(),e}}startContinuousRecognition(){return new Promise((e,t)=>{this.privCTRecognizer.startContinuousRecognitionAsync(e,t)})}};Fr.ConversationTranslator=Qd});var Oy=p(Ma=>{"use strict";Object.defineProperty(Ma,"__esModule",{value:!0});Ma.ConversationTranscriber=void 0;var Nn=C(),Yd=P(),Vr=I(),ke=f(),Xd=class i extends ke.Recognizer{constructor(e,t){let r=e;Vr.Contracts.throwIfNull(r,"speechConfig"),Vr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(ke.PropertyId.SpeechServiceConnection_RecoLanguage),ke.PropertyId[ke.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Nn.ConversationTranscriberConnectionFactory),this.privProperties.setProperty(ke.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get endpointId(){return Vr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ke.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(ke.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Vr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(ke.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return Vr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ke.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return Vr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Nn.OutputFormatPropertyName,ke.OutputFormat[ke.OutputFormat.Simple])===ke.OutputFormat[ke.OutputFormat.Simple]?ke.OutputFormat.Simple:ke.OutputFormat.Detailed}get properties(){return this.privProperties}startTranscribingAsync(e,t){Yd.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Nn.RecognitionMode.Conversation),e,t)}stopTranscribingAsync(e,t){Yd.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}close(e,t){Vr.Contracts.throwIfDisposed(this.privDisposedRecognizer),Yd.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new Nn.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return n.isSpeakerDiarizationEnabled=!0,new Nn.ConversationTranscriptionServiceRecognizer(e,t,s,n,this)}};Ma.ConversationTranscriber=Xd});var My=p(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.Participant=wi.User=void 0;var P_=f(),Zd=class{constructor(e){this.privUserId=e}get userId(){return this.privUserId}};wi.User=Zd;var el=class i{constructor(e,t,r,n,s,o,a,c){this.privId=e,this.privAvatar=t,this.privDisplayName=r,this.privIsHost=n,this.privIsMuted=s,this.privIsUsingTts=o,this.privPreferredLanguage=a,this.privVoice=c,this.privProperties=new P_.PropertyCollection}get avatar(){return this.privAvatar}get displayName(){return this.privDisplayName}get id(){return this.privId}get preferredLanguage(){return this.privPreferredLanguage}get isHost(){return this.privIsHost}get isMuted(){return this.privIsMuted}get isUsingTts(){return this.privIsUsingTts}get voice(){return this.privVoice}get properties(){return this.privProperties}static From(e,t,r){return new i(e,"",e,!1,!1,!1,t,r)}};wi.Participant=el});var Dy=p(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.ParticipantChangedReason=void 0;var R_;(function(i){i[i.JoinedConversation=0]="JoinedConversation",i[i.LeftConversation=1]="LeftConversation",i[i.Updated=2]="Updated"})(R_=qn.ParticipantChangedReason||(qn.ParticipantChangedReason={}))});var ky=p(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.MeetingImpl=_i.Meeting=void 0;var j=C(),xn=P(),y=I(),H=f(),Da=class{constructor(){}static createMeetingAsync(e,t,r,n){if(y.Contracts.throwIfNullOrUndefined(e,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),y.Contracts.throwIfNullOrUndefined(e.region,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),y.Contracts.throwIfNull(t,"meetingId"),t.length===0)throw new Error("meetingId cannot be empty");!e.subscriptionKey&&!e.getProperty(H.PropertyId[H.PropertyId.SpeechServiceAuthorization_Token])&&y.Contracts.throwIfNullOrUndefined(e.subscriptionKey,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s=new ka(e,t);return xn.marshalPromiseToCallbacks((async()=>{})(),r,n),s}};_i.Meeting=Da;var ka=class extends Da{constructor(e,t){super(),this.privErrors=j.ConversationConnectionConfig.restErrors,this.onConnected=s=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,s)}catch{}},this.onDisconnected=s=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,s)}catch{}finally{this.close(!1)}},this.onCanceled=(s,o)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,o)}catch{}},this.onParticipantUpdateCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.id);if(a!==void 0){switch(o.key){case j.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case j.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case j.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case j.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case j.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.Updated,[this.toParticipant(a)],o.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(s,o)=>{try{this.privParticipants.participants.forEach(a=>a.isMuted=a.isHost?!1:o.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.Updated,this.toParticipants(!1),o.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(s,o)=>{try{let a=this.privParticipants.addOrUpdateParticipant(o.participant);a!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.JoinedConversation,[this.toParticipant(a)],o.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.participant.id);a!==void 0&&(this.privParticipants.deleteParticipant(o.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case j.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new H.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new H.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new H.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break}}catch{}},this.onParticipantsListReceived=(s,o)=>{try{if(o.sessionToken!==void 0&&o.sessionToken!==null&&(this.privRoom.token=o.sessionToken),this.privParticipants.participants=[...o.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(H.PropertyId.ConversationTranslator_Name);a!==void 0&&a.length>0&&a!==this.me.displayName&&this.changeNicknameAsync(a)}}catch{}},this.onConversationExpiration=(s,o)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,o)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new H.PropertyCollection,this.privManager=new j.ConversationManager,e.getProperty(H.PropertyId[H.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(H.PropertyId[H.PropertyId.SpeechServiceConnection_RecoLanguage],j.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(H.PropertyId[H.PropertyId.SpeechServiceConnection_RecoLanguage]),this.privConversationId=t,this.privConfig=e;let n=e;y.Contracts.throwIfNull(n,"speechConfig"),this.privProperties=n.properties.clone(),this.privIsConnected=!1,this.privParticipants=new j.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get meetingId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return this.privParticipants.me?.isHost?!1:this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get meetingInfo(){let e=this.meetingId,t=this.participants.map(s=>({id:s.id,preferredLanguage:s.preferredLanguage,voice:s.voice})),r={};for(let s of j.ConversationConnectionConfig.transcriptionEventKeys){let o=this.properties.getProperty(s,"");o!==""&&(r[s]=o)}return{id:e,participants:t,meetingProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){y.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}createMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}startMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.disconnected=this.onDisconnected,this.privConversationRecognizer.canceled=this.onCanceled,this.privConversationRecognizer.participantUpdateCommandReceived=this.onParticipantUpdateCommandReceived,this.privConversationRecognizer.lockRoomCommandReceived=this.onLockRoomCommandReceived,this.privConversationRecognizer.muteAllCommandReceived=this.onMuteAllCommandReceived,this.privConversationRecognizer.participantJoinCommandReceived=this.onParticipantJoinCommandReceived,this.privConversationRecognizer.participantLeaveCommandReceived=this.onParticipantLeaveCommandReceived,this.privConversationRecognizer.translationReceived=this.onTranslationReceived,this.privConversationRecognizer.participantsListReceived=this.onParticipantsListReceived,this.privConversationRecognizer.conversationExpiration=this.onConversationExpiration,this.privConversationRecognizer.connect(this.privRoom.token,()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}addParticipantAsync(e,t,r){y.Contracts.throwIfNullOrUndefined(e,"Participant"),xn.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),t,r)}joinMeetingAsync(e,t,r,n,s){try{y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),y.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),y.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,o=>{y.Contracts.throwIfNullOrUndefined(o,this.privErrors.permissionDeniedConnect),this.privRoom=o,this.privConfig.authorizationToken=o.cognitiveSpeechAuthToken,n&&n(o.cognitiveSpeechAuthToken)},o=>{this.handleError(o,s)})}catch(o){this.handleError(o,s)}}deleteMeetingAsync(e,t){xn.marshalPromiseToCallbacks(this.deleteMeetingImplAsync(),e,t)}async deleteMeetingImplAsync(){y.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),y.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endMeetingAsync(e,t){xn.marshalPromiseToCallbacks(this.endMeetingImplAsync(),e,t)}endMeetingImplAsync(){return this.close(!0)}lockMeetingAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteAllParticipantsAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteParticipantAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}removeParticipantAsync(e,t,r){try{if(y.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))xn.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),t,r);else{y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let n="";typeof e=="string"?n=e:e.hasOwnProperty("id")?n=e.id:e.hasOwnProperty("userId")&&(n=e.userId),y.Contracts.throwIfNullOrWhitespace(n,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(o=>o.id===n)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(n),()=>{this.handleCallback(t,r)},o=>{this.handleError(o,r)})}}catch(n){this.handleError(n,r)}}unlockMeetingAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteAllParticipantsAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteParticipantAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}sendTextMessageAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}setTranslatedLanguagesAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}changeNicknameAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),this.privConfig=void 0,this.privLanguage=void 0,this.privProperties=void 0,this.privRoom=void 0,this.privToken=void 0,this.privManager=void 0,this.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.meeting=this}getKeepAlive(){let e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){let r=this.meetingInfo;return r.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(r,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);let t=this.meetingInfo;return t.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await this.privConversationRecognizer?.close(),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(t){throw t}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){let t=this.privParticipants.participants.map(r=>this.toParticipant(r));return e?t:t.filter(r=>r.isHost===!1)}toParticipant(e){return new H.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingd"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(e,"nickname"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),y.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:j.ConversationTranslatorMessageTypes.instantMessage})}};_i.MeetingImpl=ka});var Ny=p(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.MeetingTranscriptionCanceledEventArgs=void 0;var E_=vi(),tl=class extends E_.CancellationEventArgsBase{};Na.MeetingTranscriptionCanceledEventArgs=tl});var qy=p(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.MeetingTranscriber=void 0;var I_=C(),rl=P(),zn=I(),jn=f(),w_=Oa(),il=class{constructor(e){this.privAudioConfig=e,this.privProperties=new jn.PropertyCollection,this.privRecognizer=void 0,this.privDisposedRecognizer=!1}get speechRecognitionLanguage(){return zn.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(jn.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get internalData(){return this.privRecognizer.internalData}get connection(){return jn.Connection.fromRecognizer(this.privRecognizer)}get authorizationToken(){return this.properties.getProperty(jn.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){zn.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(jn.PropertyId.SpeechServiceAuthorization_Token,e)}joinMeetingAsync(e,t,r){let n=e;zn.Contracts.throwIfNullOrUndefined(w_.MeetingImpl,"Meeting"),this.privRecognizer=new I_.TranscriberRecognizer(e.config,this.privAudioConfig),zn.Contracts.throwIfNullOrUndefined(this.privRecognizer,"Recognizer"),this.privRecognizer.connectMeetingCallbacks(this),rl.marshalPromiseToCallbacks(n.connectTranscriberRecognizer(this.privRecognizer),t,r)}startTranscribingAsync(e,t){this.privRecognizer.startContinuousRecognitionAsync(e,t)}stopTranscribingAsync(e,t){this.privRecognizer.stopContinuousRecognitionAsync(e,t)}leaveMeetingAsync(e,t){this.privRecognizer.disconnectCallbacks(),rl.marshalPromiseToCallbacks((async()=>{})(),e,t)}close(e,t){zn.Contracts.throwIfDisposed(this.privDisposedRecognizer),rl.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(this.privRecognizer&&(await this.privRecognizer.close(),this.privRecognizer=void 0),e&&(this.privDisposedRecognizer=!0))}};qa.MeetingTranscriber=il});var xy=p(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});xa.ConversationTranscriptionResult=void 0;var __=f(),nl=class extends __.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(e,t,r,n,s,o,a,u,h,d),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};xa.ConversationTranscriptionResult=nl});var Oa=p(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});var zy=jd();Object.defineProperty(ne,"Conversation",{enumerable:!0,get:function(){return zy.Conversation}});Object.defineProperty(ne,"ConversationImpl",{enumerable:!0,get:function(){return zy.ConversationImpl}});var T_=yy();Object.defineProperty(ne,"ConversationCommon",{enumerable:!0,get:function(){return T_.ConversationCommon}});var A_=Cy();Object.defineProperty(ne,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return A_.ConversationExpirationEventArgs}});var b_=Py();Object.defineProperty(ne,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return b_.ConversationParticipantsChangedEventArgs}});var O_=Ry();Object.defineProperty(ne,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return O_.ConversationTranslationCanceledEventArgs}});var M_=Ey();Object.defineProperty(ne,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return M_.ConversationTranslationEventArgs}});var D_=Iy();Object.defineProperty(ne,"ConversationTranslationResult",{enumerable:!0,get:function(){return D_.ConversationTranslationResult}});var k_=by();Object.defineProperty(ne,"ConversationTranslator",{enumerable:!0,get:function(){return k_.ConversationTranslator}});var N_=Oy();Object.defineProperty(ne,"ConversationTranscriber",{enumerable:!0,get:function(){return N_.ConversationTranscriber}});var jy=My();Object.defineProperty(ne,"Participant",{enumerable:!0,get:function(){return jy.Participant}});Object.defineProperty(ne,"User",{enumerable:!0,get:function(){return jy.User}});var q_=Dy();Object.defineProperty(ne,"ParticipantChangedReason",{enumerable:!0,get:function(){return q_.ParticipantChangedReason}});var Ly=ky();Object.defineProperty(ne,"Meeting",{enumerable:!0,get:function(){return Ly.Meeting}});Object.defineProperty(ne,"MeetingImpl",{enumerable:!0,get:function(){return Ly.MeetingImpl}});var x_=Ny();Object.defineProperty(ne,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return x_.MeetingTranscriptionCanceledEventArgs}});var z_=qy();Object.defineProperty(ne,"MeetingTranscriber",{enumerable:!0,get:function(){return z_.MeetingTranscriber}});var j_=xy();Object.defineProperty(ne,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return j_.ConversationTranscriptionResult}})});var za=p(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});Ti.SynthesisRequest=Ti.Synthesizer=void 0;var Ur=C(),L_=P(),By=I(),hr=f(),sl=class i{constructor(e){let t=e;By.Contracts.throwIfNull(t,"speechConfig"),this.privProperties=t.properties.clone(),this.privDisposed=!1,this.privSynthesizing=!1,this.synthesisRequestQueue=new L_.Queue}get authorizationToken(){return this.properties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){By.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(hr.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get autoDetectSourceLanguage(){return this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)===Ur.AutoDetectSourceLanguagesOpenRangeOptionName}buildSsml(e){let t={"af-ZA":"af-ZA-AdriNeural","am-ET":"am-ET-AmehaNeural","ar-AE":"ar-AE-FatimaNeural","ar-BH":"ar-BH-AliNeural","ar-DZ":"ar-DZ-AminaNeural","ar-EG":"ar-EG-SalmaNeural","ar-IQ":"ar-IQ-BasselNeural","ar-JO":"ar-JO-SanaNeural","ar-KW":"ar-KW-FahedNeural","ar-LY":"ar-LY-ImanNeural","ar-MA":"ar-MA-JamalNeural","ar-QA":"ar-QA-AmalNeural","ar-SA":"ar-SA-HamedNeural","ar-SY":"ar-SY-AmanyNeural","ar-TN":"ar-TN-HediNeural","ar-YE":"ar-YE-MaryamNeural","bg-BG":"bg-BG-BorislavNeural","bn-BD":"bn-BD-NabanitaNeural","bn-IN":"bn-IN-BashkarNeural","ca-ES":"ca-ES-JoanaNeural","cs-CZ":"cs-CZ-AntoninNeural","cy-GB":"cy-GB-AledNeural","da-DK":"da-DK-ChristelNeural","de-AT":"de-AT-IngridNeural","de-CH":"de-CH-JanNeural","de-DE":"de-DE-KatjaNeural","el-GR":"el-GR-AthinaNeural","en-AU":"en-AU-NatashaNeural","en-CA":"en-CA-ClaraNeural","en-GB":"en-GB-LibbyNeural","en-HK":"en-HK-SamNeural","en-IE":"en-IE-ConnorNeural","en-IN":"en-IN-NeerjaNeural","en-KE":"en-KE-AsiliaNeural","en-NG":"en-NG-AbeoNeural","en-NZ":"en-NZ-MitchellNeural","en-PH":"en-PH-JamesNeural","en-SG":"en-SG-LunaNeural","en-TZ":"en-TZ-ElimuNeural","en-US":"en-US-JennyNeural","en-ZA":"en-ZA-LeahNeural","es-AR":"es-AR-ElenaNeural","es-BO":"es-BO-MarceloNeural","es-CL":"es-CL-CatalinaNeural","es-CO":"es-CO-GonzaloNeural","es-CR":"es-CR-JuanNeural","es-CU":"es-CU-BelkysNeural","es-DO":"es-DO-EmilioNeural","es-EC":"es-EC-AndreaNeural","es-ES":"es-ES-AlvaroNeural","es-GQ":"es-GQ-JavierNeural","es-GT":"es-GT-AndresNeural","es-HN":"es-HN-CarlosNeural","es-MX":"es-MX-DaliaNeural","es-NI":"es-NI-FedericoNeural","es-PA":"es-PA-MargaritaNeural","es-PE":"es-PE-AlexNeural","es-PR":"es-PR-KarinaNeural","es-PY":"es-PY-MarioNeural","es-SV":"es-SV-LorenaNeural","es-US":"es-US-AlonsoNeural","es-UY":"es-UY-MateoNeural","es-VE":"es-VE-PaolaNeural","et-EE":"et-EE-AnuNeural","fa-IR":"fa-IR-DilaraNeural","fi-FI":"fi-FI-SelmaNeural","fil-PH":"fil-PH-AngeloNeural","fr-BE":"fr-BE-CharlineNeural","fr-CA":"fr-CA-SylvieNeural","fr-CH":"fr-CH-ArianeNeural","fr-FR":"fr-FR-DeniseNeural","ga-IE":"ga-IE-ColmNeural","gl-ES":"gl-ES-RoiNeural","gu-IN":"gu-IN-DhwaniNeural","he-IL":"he-IL-AvriNeural","hi-IN":"hi-IN-MadhurNeural","hr-HR":"hr-HR-GabrijelaNeural","hu-HU":"hu-HU-NoemiNeural","id-ID":"id-ID-ArdiNeural","is-IS":"is-IS-GudrunNeural","it-IT":"it-IT-IsabellaNeural","ja-JP":"ja-JP-NanamiNeural","jv-ID":"jv-ID-DimasNeural","kk-KZ":"kk-KZ-AigulNeural","km-KH":"km-KH-PisethNeural","kn-IN":"kn-IN-GaganNeural","ko-KR":"ko-KR-SunHiNeural","lo-LA":"lo-LA-ChanthavongNeural","lt-LT":"lt-LT-LeonasNeural","lv-LV":"lv-LV-EveritaNeural","mk-MK":"mk-MK-AleksandarNeural","ml-IN":"ml-IN-MidhunNeural","mr-IN":"mr-IN-AarohiNeural","ms-MY":"ms-MY-OsmanNeural","mt-MT":"mt-MT-GraceNeural","my-MM":"my-MM-NilarNeural","nb-NO":"nb-NO-PernilleNeural","nl-BE":"nl-BE-ArnaudNeural","nl-NL":"nl-NL-ColetteNeural","pl-PL":"pl-PL-AgnieszkaNeural","ps-AF":"ps-AF-GulNawazNeural","pt-BR":"pt-BR-FranciscaNeural","pt-PT":"pt-PT-DuarteNeural","ro-RO":"ro-RO-AlinaNeural","ru-RU":"ru-RU-SvetlanaNeural","si-LK":"si-LK-SameeraNeural","sk-SK":"sk-SK-LukasNeural","sl-SI":"sl-SI-PetraNeural","so-SO":"so-SO-MuuseNeural","sr-RS":"sr-RS-NicholasNeural","su-ID":"su-ID-JajangNeural","sv-SE":"sv-SE-SofieNeural","sw-KE":"sw-KE-RafikiNeural","sw-TZ":"sw-TZ-DaudiNeural","ta-IN":"ta-IN-PallaviNeural","ta-LK":"ta-LK-KumarNeural","ta-SG":"ta-SG-AnbuNeural","te-IN":"te-IN-MohanNeural","th-TH":"th-TH-PremwadeeNeural","tr-TR":"tr-TR-AhmetNeural","uk-UA":"uk-UA-OstapNeural","ur-IN":"ur-IN-GulNeural","ur-PK":"ur-PK-AsadNeural","uz-UZ":"uz-UZ-MadinaNeural","vi-VN":"vi-VN-HoaiMyNeural","zh-CN":"zh-CN-XiaoxiaoNeural","zh-HK":"zh-HK-HiuMaanNeural","zh-TW":"zh-TW-HsiaoChenNeural","zu-ZA":"zu-ZA-ThandoNeural"},r=this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_SynthLanguage,"en-US"),n=this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_SynthVoice,""),s=i.XMLEncode(e);return this.autoDetectSourceLanguage?r="en-US":n=n||t[r],n&&(s=`<voice name='${n}'>${s}</voice>`),s=`<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts' xmlns:emo='http://www.w3.org/2009/10/emotionml' xml:lang='${r}'>${s}</speak>`,s}async dispose(e){this.privDisposed||(e&&this.privAdapter&&await this.privAdapter.dispose(),this.privDisposed=!0)}async adapterSpeak(){if(!this.privDisposed&&!this.privSynthesizing){this.privSynthesizing=!0;let e=await this.synthesisRequestQueue.dequeue();return this.privAdapter.Speak(e.text,e.isSSML,e.requestId,e.cb,e.err,e.dataStream)}}createSynthesizerConfig(e){return new Ur.SynthesizerConfig(e,this.privProperties)}implCommonSynthesizeSetup(){let e=typeof window<"u"?"Browser":"Node",t="unknown",r="unknown";typeof navigator<"u"&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);let n=this.createSynthesizerConfig(new Ur.SpeechServiceConfig(new Ur.Context(new Ur.OS(e,t,r)))),s=this.privProperties.getProperty(hr.PropertyId.SpeechServiceConnection_Key,void 0),o=s&&s!==""?new Ur.CognitiveSubscriptionKeyAuthentication(s):new Ur.CognitiveTokenAuthentication(()=>{let a=this.privProperties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(a)},()=>{let a=this.privProperties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(a)});this.privAdapter=this.createSynthesisAdapter(o,this.privConnectionFactory,n),this.privRestAdapter=this.createRestSynthesisAdapter(o,n)}static XMLEncode(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}};Ti.Synthesizer=sl;var ol=class{constructor(e,t,r,n,s,o){this.requestId=e,this.text=t,this.isSSML=r,this.cb=n,this.err=s,this.dataStream=o}};Ti.SynthesisRequest=ol});var Vy=p(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});ja.SpeechSynthesizer=void 0;var al=C(),cl=P(),B_=fh(),F_=ui(),V_=br(),Fy=I(),dr=f(),U_=za(),pl=class i extends dr.Synthesizer{constructor(e,t){super(e),t!==null&&(t===void 0?this.audioConfig=typeof window>"u"?void 0:dr.AudioConfig.fromDefaultSpeakerOutput():this.audioConfig=t),this.privConnectionFactory=new al.SpeechSynthesisConnectionFactory,this.implCommonSynthesizeSetup()}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}speakTextAsync(e,t,r,n){this.speakImpl(e,!1,t,r,n)}speakSsmlAsync(e,t,r,n){this.speakImpl(e,!0,t,r,n)}async getVoicesAsync(e=""){return this.getVoices(e)}close(e,t){Fy.Contracts.throwIfDisposed(this.privDisposed),cl.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privAdapter}createSynthesisAdapter(e,t,r){return new al.SpeechSynthesisAdapter(e,t,r,this,this.audioConfig)}createRestSynthesisAdapter(e,t){return new al.SynthesisRestAdapter(t,e)}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=F_.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(dr.SpeechSynthesisOutputFormat[this.properties.getProperty(dr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)])}speakImpl(e,t,r,n,s){try{Fy.Contracts.throwIfDisposed(this.privDisposed);let o=cl.createNoDashGuid(),a;s instanceof dr.PushAudioOutputStreamCallback?a=new V_.PushAudioOutputStreamImpl(s):s instanceof dr.PullAudioOutputStream?a=s:s!==void 0?a=new B_.AudioFileWriter(s):a=void 0,this.synthesisRequestQueue.enqueue(new U_.SynthesisRequest(o,e,t,c=>{if(this.privSynthesizing=!1,r)try{r(c)}catch(u){n&&n(u)}r=void 0,this.adapterSpeak().catch(()=>{})},c=>{n&&n(c)},a)),this.adapterSpeak().catch(()=>{})}catch(o){if(n)if(o instanceof Error){let a=o;n(a.name+": "+a.message)}else n(o);this.dispose(!0).catch(()=>{})}}async getVoices(e){let t=cl.createNoDashGuid(),r=await this.privRestAdapter.getVoicesList(t);if(r.ok&&Array.isArray(r.json)){let n=r.json;return e&&e.length>0&&(n=n.filter(s=>!!s.Locale&&s.Locale.toLowerCase()===e.toLowerCase())),new dr.SynthesisVoicesResult(t,n,void 0)}else return new dr.SynthesisVoicesResult(t,void 0,`Error: ${r.status}: ${r.statusText}`)}};ja.SpeechSynthesizer=pl});var Uy=p(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.SynthesisResult=void 0;var ul=class{constructor(e,t,r,n){this.privResultId=e,this.privReason=t,this.privErrorDetails=r,this.privProperties=n}get resultId(){return this.privResultId}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get properties(){return this.privProperties}};La.SynthesisResult=ul});var Wy=p(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.SpeechSynthesisResult=void 0;var W_=f(),hl=class extends W_.SynthesisResult{constructor(e,t,r,n,s,o){super(e,t,n,s),this.privAudioData=r,this.privAudioDuration=o}get audioData(){return this.privAudioData}get audioDuration(){return this.privAudioDuration}};Ba.SpeechSynthesisResult=hl});var Hy=p(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});Fa.SpeechSynthesisEventArgs=void 0;var dl=class{constructor(e){this.privResult=e}get result(){return this.privResult}};Fa.SpeechSynthesisEventArgs=dl});var Ky=p(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.SpeechSynthesisWordBoundaryEventArgs=void 0;var ll=class{constructor(e,t,r,n,s,o){this.privAudioOffset=e,this.privDuration=t,this.privText=r,this.privWordLength=n,this.privTextOffset=s,this.privBoundaryType=o}get audioOffset(){return this.privAudioOffset}get duration(){return this.privDuration}get text(){return this.privText}get wordLength(){return this.privWordLength}get textOffset(){return this.privTextOffset}get boundaryType(){return this.privBoundaryType}};Va.SpeechSynthesisWordBoundaryEventArgs=ll});var Jy=p(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.SpeechSynthesisBookmarkEventArgs=void 0;var vl=class{constructor(e,t){this.privAudioOffset=e,this.privText=t}get audioOffset(){return this.privAudioOffset}get text(){return this.privText}};Ua.SpeechSynthesisBookmarkEventArgs=vl});var Gy=p(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.SpeechSynthesisVisemeEventArgs=void 0;var fl=class{constructor(e,t,r){this.privAudioOffset=e,this.privVisemeId=t,this.privAnimation=r}get audioOffset(){return this.privAudioOffset}get visemeId(){return this.privVisemeId}get animation(){return this.privAnimation}};Wa.SpeechSynthesisVisemeEventArgs=fl});var $y=p(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.SpeechSynthesisBoundaryType=void 0;var H_;(function(i){i.Word="WordBoundary",i.Punctuation="PunctuationBoundary",i.Sentence="SentenceBoundary"})(H_=Ln.SpeechSynthesisBoundaryType||(Ln.SpeechSynthesisBoundaryType={}))});var Qy=p(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.SynthesisVoicesResult=void 0;var Ai=f(),gl=class extends Ai.SynthesisResult{constructor(e,t,r){if(Array.isArray(t)){super(e,Ai.ResultReason.VoicesListRetrieved,void 0,new Ai.PropertyCollection),this.privVoices=[];for(let n of t)this.privVoices.push(new Ai.VoiceInfo(n))}else super(e,Ai.ResultReason.Canceled,r||"Error information unavailable",new Ai.PropertyCollection)}get voices(){return this.privVoices}};Ha.SynthesisVoicesResult=gl});var Yy=p(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.VoiceInfo=Tt.SynthesisVoiceType=Tt.SynthesisVoiceGender=void 0;var gt;(function(i){i[i.Unknown=0]="Unknown",i[i.Female=1]="Female",i[i.Male=2]="Male",i[i.Neutral=3]="Neutral"})(gt=Tt.SynthesisVoiceGender||(Tt.SynthesisVoiceGender={}));var ml;(function(i){i[i.OnlineNeural=1]="OnlineNeural",i[i.OnlineStandard=2]="OnlineStandard",i[i.OfflineNeural=3]="OfflineNeural",i[i.OfflineStandard=4]="OfflineStandard"})(ml=Tt.SynthesisVoiceType||(Tt.SynthesisVoiceType={}));var K_={[gt[gt.Neutral]]:gt.Neutral,[gt[gt.Male]]:gt.Male,[gt[gt.Female]]:gt.Female},Sl=class{constructor(e){if(this.privStyleList=[],e){if(this.privName=e.Name,this.privLocale=e.Locale,this.privShortName=e.ShortName,this.privLocaleName=e.LocaleName,this.privDisplayName=e.DisplayName,this.privLocalName=e.LocalName,this.privVoiceType=e.VoiceType.endsWith("Standard")?ml.OnlineStandard:ml.OnlineNeural,this.privGender=K_[e.Gender]||gt.Unknown,e.StyleList&&Array.isArray(e.StyleList))for(let t of e.StyleList)this.privStyleList.push(t);this.privSampleRateHertz=e.SampleRateHertz,this.privStatus=e.Status,e.ExtendedPropertyMap&&(this.privExtendedPropertyMap=e.ExtendedPropertyMap),this.privWordsPerMinute=e.WordsPerMinute,Array.isArray(e.SecondaryLocaleList)&&(this.privSecondaryLocaleList=[...e.SecondaryLocaleList]),Array.isArray(e.RolePlayList)&&(this.privRolePlayList=[...e.RolePlayList])}}get name(){return this.privName}get locale(){return this.privLocale}get shortName(){return this.privShortName}get displayName(){return this.privDisplayName}get localName(){return this.privLocalName}get localeName(){return this.privLocaleName}get gender(){return this.privGender}get voiceType(){return this.privVoiceType}get styleList(){return this.privStyleList}get sampleRateHertz(){return this.privSampleRateHertz}get status(){return this.privStatus}get extendedPropertyMap(){return this.privExtendedPropertyMap}get wordsPerMinute(){return this.privWordsPerMinute}get secondaryLocaleList(){return this.privSecondaryLocaleList}get rolePlayList(){return this.privRolePlayList}};Tt.VoiceInfo=Sl});var Zy=p(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.SpeakerAudioDestination=void 0;var Wr=P(),J_=br(),Ze=nr(),G_=60*30,Xy={[Ze.AudioFormatTag.PCM]:"audio/wav",[Ze.AudioFormatTag.MuLaw]:"audio/x-wav",[Ze.AudioFormatTag.MP3]:"audio/mpeg",[Ze.AudioFormatTag.OGG_OPUS]:"audio/ogg",[Ze.AudioFormatTag.WEBM_OPUS]:"audio/webm; codecs=opus",[Ze.AudioFormatTag.ALaw]:"audio/x-wav",[Ze.AudioFormatTag.FLAC]:"audio/flac"},yl=class{constructor(e){this.privPlaybackStarted=!1,this.privAppendingToBuffer=!1,this.privMediaSourceOpened=!1,this.privBytesReceived=0,this.privId=e||Wr.createNoDashGuid(),this.privIsPaused=!1,this.privIsClosed=!1}id(){return this.privId}write(e,t,r){this.privAudioBuffer!==void 0?(this.privAudioBuffer.push(e),this.updateSourceBuffer().then(()=>{t&&t()},n=>{r&&r(n)})):this.privAudioOutputStream!==void 0&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength)}close(e,t){if(this.privIsClosed=!0,this.privSourceBuffer!==void 0)this.handleSourceBufferUpdateEnd().then(()=>{e&&e()},r=>{t&&t(r)});else if(this.privAudioOutputStream!==void 0&&typeof window<"u")if((this.privFormat.formatTag===Ze.AudioFormatTag.PCM||this.privFormat.formatTag===Ze.AudioFormatTag.MuLaw||this.privFormat.formatTag===Ze.AudioFormatTag.ALaw)&&this.privFormat.hasHeader===!1)console.warn("Play back is not supported for raw PCM, mulaw or alaw format without header."),this.onAudioEnd&&this.onAudioEnd(this);else{let r=new ArrayBuffer(this.privBytesReceived);this.privAudioOutputStream.read(r).then(()=>{r=this.privFormat.addHeader(r);let n=new Blob([r],{type:Xy[this.privFormat.formatTag]});this.privAudio.src=window.URL.createObjectURL(n),this.notifyPlayback().then(()=>{e&&e()},s=>{t&&t(s)})},n=>{t&&t(n)})}else this.onAudioEnd&&this.onAudioEnd(this)}set format(e){if(typeof AudioContext<"u"||typeof window<"u"&&typeof window.webkitAudioContext<"u"){this.privFormat=e;let t=Xy[this.privFormat.formatTag];t===void 0?console.warn(`Unknown mimeType for format ${Ze.AudioFormatTag[this.privFormat.formatTag]}; playback is not supported.`):typeof MediaSource<"u"&&MediaSource.isTypeSupported(t)?(this.privAudio=new Audio,this.privAudioBuffer=[],this.privMediaSource=new MediaSource,this.privAudio.src=URL.createObjectURL(this.privMediaSource),this.privAudio.load(),this.privMediaSource.onsourceopen=()=>{this.privMediaSourceOpened=!0,this.privMediaSource.duration=G_,this.privSourceBuffer=this.privMediaSource.addSourceBuffer(t),this.privSourceBuffer.onupdate=()=>{this.updateSourceBuffer().catch(r=>{Wr.Events.instance.onEvent(new Wr.BackgroundEvent(r))})},this.privSourceBuffer.onupdateend=()=>{this.handleSourceBufferUpdateEnd().catch(r=>{Wr.Events.instance.onEvent(new Wr.BackgroundEvent(r))})},this.privSourceBuffer.onupdatestart=()=>{this.privAppendingToBuffer=!1}},this.updateSourceBuffer().catch(r=>{Wr.Events.instance.onEvent(new Wr.BackgroundEvent(r))})):(console.warn(`Format ${Ze.AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`),this.privAudioOutputStream=new J_.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privFormat,this.privAudio=new Audio)}}get volume(){return this.privAudio?.volume??-1}set volume(e){this.privAudio&&(this.privAudio.volume=e)}mute(){this.privAudio&&(this.privAudio.muted=!0)}unmute(){this.privAudio&&(this.privAudio.muted=!1)}get isClosed(){return this.privIsClosed}get currentTime(){return this.privAudio!==void 0?this.privAudio.currentTime:-1}pause(){!this.privIsPaused&&this.privAudio!==void 0&&(this.privAudio.pause(),this.privIsPaused=!0)}resume(e,t){this.privIsPaused&&this.privAudio!==void 0&&(this.privAudio.play().then(()=>{e&&e()},r=>{t&&t(r)}),this.privIsPaused=!1)}get internalAudio(){return this.privAudio}async updateSourceBuffer(){if(this.privAudioBuffer!==void 0&&this.privAudioBuffer.length>0&&this.sourceBufferAvailable()){this.privAppendingToBuffer=!0;let e=this.privAudioBuffer.shift();try{this.privSourceBuffer.appendBuffer(e)}catch{this.privAudioBuffer.unshift(e),console.log("buffer filled, pausing addition of binaries until space is made");return}await this.notifyPlayback()}else this.canEndStream()&&await this.handleSourceBufferUpdateEnd()}async handleSourceBufferUpdateEnd(){this.canEndStream()&&this.sourceBufferAvailable()&&(this.privMediaSource.endOfStream(),await this.notifyPlayback())}async notifyPlayback(){!this.privPlaybackStarted&&this.privAudio!==void 0&&(this.privPlaybackStarted=!0,this.onAudioStart&&this.onAudioStart(this),this.privAudio.onended=()=>{this.onAudioEnd&&this.onAudioEnd(this)},this.privIsPaused||await this.privAudio.play())}canEndStream(){return this.isClosed&&this.privSourceBuffer!==void 0&&this.privAudioBuffer.length===0&&this.privMediaSourceOpened&&!this.privAppendingToBuffer&&this.privMediaSource.readyState==="open"}sourceBufferAvailable(){return this.privSourceBuffer!==void 0&&!this.privSourceBuffer.updating}};Ka.SpeakerAudioDestination=yl});var eC=p(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.ConversationTranscriptionCanceledEventArgs=void 0;var $_=vi(),Cl=class extends $_.CancellationEventArgsBase{};Ja.ConversationTranscriptionCanceledEventArgs=Cl});var tC=p(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.MeetingTranscriptionCanceledEventArgs=void 0;var Q_=vi(),Pl=class extends Q_.CancellationEventArgsBase{};Ga.MeetingTranscriptionCanceledEventArgs=Pl});var rC=p(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.PronunciationAssessmentGradingSystem=void 0;var Y_;(function(i){i[i.FivePoint=1]="FivePoint",i[i.HundredMark=2]="HundredMark"})(Y_=Bn.PronunciationAssessmentGradingSystem||(Bn.PronunciationAssessmentGradingSystem={}))});var iC=p(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.PronunciationAssessmentGranularity=void 0;var X_;(function(i){i[i.Phoneme=1]="Phoneme",i[i.Word=2]="Word",i[i.FullText=3]="FullText"})(X_=Fn.PronunciationAssessmentGranularity||(Fn.PronunciationAssessmentGranularity={}))});var nC=p(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.PronunciationAssessmentConfig=void 0;var $a=I(),G=f(),Rl=class i{constructor(e,t=G.PronunciationAssessmentGradingSystem.FivePoint,r=G.PronunciationAssessmentGranularity.Phoneme,n=!1){$a.Contracts.throwIfNullOrUndefined(e,"referenceText"),this.privProperties=new G.PropertyCollection,this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_ReferenceText,e),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_GradingSystem,G.PronunciationAssessmentGradingSystem[t]),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_Granularity,G.PronunciationAssessmentGranularity[r]),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_EnableMiscue,String(n))}static fromJSON(e){$a.Contracts.throwIfNullOrUndefined(e,"json");let t=new i("");return t.privProperties=new G.PropertyCollection,t.properties.setProperty(G.PropertyId.PronunciationAssessment_Json,e),t}toJSON(){return this.updateJson(),this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_Params)}applyTo(e){this.updateJson();let t=e.internalData;t.expectContentAssessmentResponse=!!this.privContentAssessmentTopic,t.speechContext.setPronunciationAssessmentParams(this.properties.getProperty(G.PropertyId.PronunciationAssessment_Params),this.privContentAssessmentTopic,t.isSpeakerDiarizationEnabled)}get referenceText(){return this.properties.getProperty(G.PropertyId.PronunciationAssessment_ReferenceText)}set referenceText(e){$a.Contracts.throwIfNullOrWhitespace(e,"referenceText"),this.properties.setProperty(G.PropertyId.PronunciationAssessment_ReferenceText,e)}set phonemeAlphabet(e){$a.Contracts.throwIfNullOrWhitespace(e,"phonemeAlphabet"),this.privPhonemeAlphabet=e}set enableMiscue(e){let t=e?"true":"false";this.properties.setProperty(G.PropertyId.PronunciationAssessment_EnableMiscue,t)}get enableMiscue(){return this.properties.getProperty(G.PropertyId.PronunciationAssessment_EnableMiscue,"false").toLowerCase()==="true"}set nbestPhonemeCount(e){this.privNBestPhonemeCount=e}set enableProsodyAssessment(e){this.privEnableProsodyAssessment=e}enableContentAssessmentWithTopic(e){this.privContentAssessmentTopic=e}get properties(){return this.privProperties}updateJson(){let e=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_Json,"{}"),t=JSON.parse(e),r=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_ReferenceText);r&&(t.referenceText=r);let n=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_GradingSystem);n&&(t.gradingSystem=n);let s=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_Granularity);s&&(t.granularity=s),this.privPhonemeAlphabet&&(t.phonemeAlphabet=this.privPhonemeAlphabet),this.privNBestPhonemeCount&&(t.nbestPhonemeCount=this.privNBestPhonemeCount),t.enableProsodyAssessment=this.privEnableProsodyAssessment,t.dimension="Comprehensive",this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_EnableMiscue)&&(t.enableMiscue=this.enableMiscue),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_Params,JSON.stringify(t))}};Qa.PronunciationAssessmentConfig=Rl});var sC=p(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.PronunciationAssessmentResult=bi.ContentAssessmentResult=void 0;var El=I(),Z_=f(),Ya=class{constructor(e){this.privPronJson=e}get grammarScore(){return this.privPronJson.ContentAssessment.GrammarScore}get vocabularyScore(){return this.privPronJson.ContentAssessment.VocabularyScore}get topicScore(){return this.privPronJson.ContentAssessment.TopicScore}};bi.ContentAssessmentResult=Ya;var Il=class i{constructor(e){let t=JSON.parse(e);El.Contracts.throwIfNullOrUndefined(t.NBest[0],"NBest"),this.privPronJson=t.NBest[0]}static fromResult(e){El.Contracts.throwIfNullOrUndefined(e,"result");let t=e.properties.getProperty(Z_.PropertyId.SpeechServiceResponse_JsonResult);return El.Contracts.throwIfNullOrUndefined(t,"json"),new i(t)}get detailResult(){return this.privPronJson}get accuracyScore(){return this.detailResult.PronunciationAssessment?.AccuracyScore}get pronunciationScore(){return this.detailResult.PronunciationAssessment?.PronScore}get completenessScore(){return this.detailResult.PronunciationAssessment?.CompletenessScore}get fluencyScore(){return this.detailResult.PronunciationAssessment?.FluencyScore}get prosodyScore(){return this.detailResult.PronunciationAssessment?.ProsodyScore}get contentAssessmentResult(){if(this.detailResult.ContentAssessment!==void 0)return new Ya(this.detailResult)}};bi.PronunciationAssessmentResult=Il});var oC=p(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.AvatarConfig=void 0;var eT=I(),tT=f(),wl=class{constructor(e,t,r){this.privCustomized=!1,eT.Contracts.throwIfNullOrWhitespace(e,"character"),this.character=e,this.style=t,r===void 0&&(r=new tT.AvatarVideoFormat),this.videoFormat=r}get customized(){return this.privCustomized}set customized(e){this.privCustomized=e}get backgroundColor(){return this.privBackgroundColor}set backgroundColor(e){this.privBackgroundColor=e}};Xa.AvatarConfig=wl});var aC=p(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0});Hr.AvatarEventArgs=Hr.AvatarEventTypes=void 0;var rT;(function(i){i.SwitchedToSpeaking="SwitchedToSpeaking",i.SwitchedToIdle="SwitchedToIdle",i.SessionClosed="SessionClosed"})(rT=Hr.AvatarEventTypes||(Hr.AvatarEventTypes={}));var _l=class{constructor(e,t){this.privOffset=e,this.privDescription=t}get type(){return this.privType}get offset(){return this.privOffset}get description(){return this.privDescription}};Hr.AvatarEventArgs=_l});var Al=p(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.SpeechSynthesisConnectionFactory=void 0;var cC=pe(),Vn=f(),iT=Ye(),nT=C(),sT=we(),Za=Ut(),Tl=class{constructor(){this.synthesisUri="/cognitiveservices/websocket/v1"}create(e,t,r){let n=e.parameters.getProperty(Vn.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Vn.PropertyId.SpeechServiceConnection_Region,void 0),o=iT.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(Vn.PropertyId.SpeechServiceConnection_EndpointId,void 0),c=a===void 0?"tts":"voice",u=e.parameters.getProperty(Vn.PropertyId.SpeechServiceConnection_Host,"wss://"+s+"."+c+".speech"+o),h={},d={};t.token!==void 0&&t.token!==""&&(d[t.headerName]=t.token),d[sT.HeaderNames.ConnectionId]=r,a!==void 0&&a!==""&&(!n||n.search(Za.QueryParameterNames.CustomVoiceDeploymentId)===-1)&&(h[Za.QueryParameterNames.CustomVoiceDeploymentId]=a),e.avatarEnabled&&(!n||n.search(Za.QueryParameterNames.EnableAvatar)===-1)&&(h[Za.QueryParameterNames.EnableAvatar]="true"),n||(n=u+this.synthesisUri),e.parameters.setProperty(Vn.PropertyId.SpeechServiceConnection_Url,n);let v=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new cC.WebsocketConnection(n,h,d,new nT.WebsocketMessageFormatter,cC.ProxyInfo.fromParameters(e.parameters),v,r)}};ec.SpeechSynthesisConnectionFactory=Tl});var pC=p(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.AvatarSynthesizer=void 0;var oT=Al(),aT=C(),ee=P(),cT=ui(),Ht=f(),tc=I(),pT=za(),bl=class extends Ht.Synthesizer{constructor(e,t){super(e),tc.Contracts.throwIfNullOrUndefined(t,"avatarConfig"),this.privConnectionFactory=new oT.SpeechSynthesisConnectionFactory,this.privAvatarConfig=t,this.implCommonSynthesizeSetup()}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=cT.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(Ht.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm)}async startAvatarAsync(e){tc.Contracts.throwIfNullOrUndefined(e,"peerConnection"),this.privIceServers=e.getConfiguration().iceServers,tc.Contracts.throwIfNullOrUndefined(this.privIceServers,"Ice servers must be set.");let t=new ee.Deferred;e.onicegatheringstatechange=()=>{ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice gathering state: "+e.iceGatheringState,ee.EventType.Debug)),e.iceGatheringState==="complete"&&(ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice gathering complete.",ee.EventType.Info)),t.resolve())},e.onicecandidate=a=>{a.candidate?ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice candidate: "+a.candidate.candidate,ee.EventType.Debug)):(ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice candidate: complete",ee.EventType.Debug)),t.resolve())},setTimeout(()=>{e.iceGatheringState!=="complete"&&(ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice gathering timeout.",ee.EventType.Warning)),t.resolve())},2e3);let r=await e.createOffer();await e.setLocalDescription(r),await t.promise,ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: got local SDP.",ee.EventType.Info)),this.privProperties.setProperty(Ht.PropertyId.TalkingAvatarService_WebRTC_SDP,JSON.stringify(e.localDescription));let n=await this.speak("",!1);if(n.reason!==Ht.ResultReason.SynthesizingAudioCompleted)return new Ht.SynthesisResult(n.resultId,n.reason,n.errorDetails,n.properties);let s=atob(n.properties.getProperty(Ht.PropertyId.TalkingAvatarService_WebRTC_SDP)),o=new RTCSessionDescription(JSON.parse(s));return await e.setRemoteDescription(o),new Ht.SynthesisResult(n.resultId,n.reason,void 0,n.properties)}async speakTextAsync(e){let t=await this.speak(e,!1);return new Ht.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async speakSsmlAsync(e){let t=await this.speak(e,!0);return new Ht.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async stopSpeakingAsync(){for(;this.synthesisRequestQueue.length()>0;)(await this.synthesisRequestQueue.dequeue()).err("Synthesis is canceled by user.");return this.privAdapter.stopSpeaking()}async stopAvatarAsync(){return tc.Contracts.throwIfDisposed(this.privDisposed),this.dispose(!0)}async close(){if(!this.privDisposed)return this.dispose(!0)}get iceServers(){return this.privIceServers}createSynthesisAdapter(e,t,r){return new aT.AvatarSynthesisAdapter(e,t,r,this,this.privAvatarConfig)}createRestSynthesisAdapter(e,t){}createSynthesizerConfig(e){let t=super.createSynthesizerConfig(e);return t.avatarEnabled=!0,t}async speak(e,t){let r=ee.createNoDashGuid(),n=new ee.Deferred;return this.synthesisRequestQueue.enqueue(new pT.SynthesisRequest(r,e,t,s=>{n.resolve(s),this.privSynthesizing=!1,this.adapterSpeak()},s=>{n.reject(s),this.privSynthesizing=!1})),this.adapterSpeak(),n.promise}};rc.AvatarSynthesizer=bl});var uC=p(Oi=>{"use strict";Object.defineProperty(Oi,"__esModule",{value:!0});Oi.AvatarVideoFormat=Oi.Coordinate=void 0;var Ol=class{constructor(e,t){this.x=e,this.y=t}};Oi.Coordinate=Ol;var Ml=class{constructor(e="H264",t=2e6,r=1920,n=1080){this.codec=e,this.bitrate=t,this.width=r,this.height=n}setCropRange(e,t){this.cropRange={bottomRight:t,topLeft:e}}};Oi.AvatarVideoFormat=Ml});var hC=p(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.AvatarWebRTCConnectionResult=void 0;var uT=f(),Dl=class extends uT.SynthesisResult{constructor(e,t,r,n,s){super(t,r,n,s),this.privSDPAnswer=e}get SDPAnswer(){return this.privSDPAnswer}};ic.AvatarWebRTCConnectionResult=Dl});var dC=p(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.Diagnostics=void 0;var hT=pe(),dT=P(),nc=class{static SetLoggingLevel(e){this.privListener=new hT.ConsoleLoggingListener(e),dT.Events.instance.attachConsoleListener(this.privListener)}static StartConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!0)}static StopConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!1)}static SetLogOutputPath(e){if(typeof window>"u")this.privListener&&(this.privListener.logPath=e);else throw new Error("File system logging not available in browser.")}static set onLogOutput(e){this.privListener&&(this.privListener.logCallback=e)}};sc.Diagnostics=nc;nc.privListener=void 0});var f=p(l=>{"use strict";Object.defineProperty(l,"__esModule",{value:!0});var lT=yh();Object.defineProperty(l,"AudioConfig",{enumerable:!0,get:function(){return lT.AudioConfig}});var lC=nr();Object.defineProperty(l,"AudioStreamFormat",{enumerable:!0,get:function(){return lC.AudioStreamFormat}});Object.defineProperty(l,"AudioFormatTag",{enumerable:!0,get:function(){return lC.AudioFormatTag}});var kl=gh();Object.defineProperty(l,"AudioInputStream",{enumerable:!0,get:function(){return kl.AudioInputStream}});Object.defineProperty(l,"PullAudioInputStream",{enumerable:!0,get:function(){return kl.PullAudioInputStream}});Object.defineProperty(l,"PushAudioInputStream",{enumerable:!0,get:function(){return kl.PushAudioInputStream}});var Nl=br();Object.defineProperty(l,"AudioOutputStream",{enumerable:!0,get:function(){return Nl.AudioOutputStream}});Object.defineProperty(l,"PullAudioOutputStream",{enumerable:!0,get:function(){return Nl.PullAudioOutputStream}});Object.defineProperty(l,"PushAudioOutputStream",{enumerable:!0,get:function(){return Nl.PushAudioOutputStream}});var vT=Zm();Object.defineProperty(l,"CancellationReason",{enumerable:!0,get:function(){return vT.CancellationReason}});var fT=eS();Object.defineProperty(l,"PullAudioInputStreamCallback",{enumerable:!0,get:function(){return fT.PullAudioInputStreamCallback}});var gT=tS();Object.defineProperty(l,"PushAudioOutputStreamCallback",{enumerable:!0,get:function(){return gT.PushAudioOutputStreamCallback}});var mT=iS();Object.defineProperty(l,"KeywordRecognitionModel",{enumerable:!0,get:function(){return mT.KeywordRecognitionModel}});var ST=nS();Object.defineProperty(l,"SessionEventArgs",{enumerable:!0,get:function(){return ST.SessionEventArgs}});var yT=sS();Object.defineProperty(l,"RecognitionEventArgs",{enumerable:!0,get:function(){return yT.RecognitionEventArgs}});var CT=oS();Object.defineProperty(l,"OutputFormat",{enumerable:!0,get:function(){return CT.OutputFormat}});var PT=aS();Object.defineProperty(l,"IntentRecognitionEventArgs",{enumerable:!0,get:function(){return PT.IntentRecognitionEventArgs}});var RT=cS();Object.defineProperty(l,"RecognitionResult",{enumerable:!0,get:function(){return RT.RecognitionResult}});var ET=pS();Object.defineProperty(l,"SpeechRecognitionResult",{enumerable:!0,get:function(){return ET.SpeechRecognitionResult}});var IT=uS();Object.defineProperty(l,"IntentRecognitionResult",{enumerable:!0,get:function(){return IT.IntentRecognitionResult}});var wT=hS();Object.defineProperty(l,"LanguageUnderstandingModel",{enumerable:!0,get:function(){return wT.LanguageUnderstandingModel}});var ql=lS();Object.defineProperty(l,"SpeechRecognitionEventArgs",{enumerable:!0,get:function(){return ql.SpeechRecognitionEventArgs}});Object.defineProperty(l,"ConversationTranscriptionEventArgs",{enumerable:!0,get:function(){return ql.ConversationTranscriptionEventArgs}});Object.defineProperty(l,"MeetingTranscriptionEventArgs",{enumerable:!0,get:function(){return ql.MeetingTranscriptionEventArgs}});var _T=vS();Object.defineProperty(l,"SpeechRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return _T.SpeechRecognitionCanceledEventArgs}});var TT=fS();Object.defineProperty(l,"TranslationRecognitionEventArgs",{enumerable:!0,get:function(){return TT.TranslationRecognitionEventArgs}});var AT=gS();Object.defineProperty(l,"TranslationSynthesisEventArgs",{enumerable:!0,get:function(){return AT.TranslationSynthesisEventArgs}});var bT=xh();Object.defineProperty(l,"TranslationRecognitionResult",{enumerable:!0,get:function(){return bT.TranslationRecognitionResult}});var OT=mS();Object.defineProperty(l,"TranslationSynthesisResult",{enumerable:!0,get:function(){return OT.TranslationSynthesisResult}});var MT=SS();Object.defineProperty(l,"ResultReason",{enumerable:!0,get:function(){return MT.ResultReason}});var vC=yS();Object.defineProperty(l,"SpeechConfig",{enumerable:!0,get:function(){return vC.SpeechConfig}});Object.defineProperty(l,"SpeechConfigImpl",{enumerable:!0,get:function(){return vC.SpeechConfigImpl}});var fC=CS();Object.defineProperty(l,"SpeechTranslationConfig",{enumerable:!0,get:function(){return fC.SpeechTranslationConfig}});Object.defineProperty(l,"SpeechTranslationConfigImpl",{enumerable:!0,get:function(){return fC.SpeechTranslationConfigImpl}});var DT=Lh();Object.defineProperty(l,"PropertyCollection",{enumerable:!0,get:function(){return DT.PropertyCollection}});var kT=Io();Object.defineProperty(l,"PropertyId",{enumerable:!0,get:function(){return kT.PropertyId}});var NT=ES();Object.defineProperty(l,"Recognizer",{enumerable:!0,get:function(){return NT.Recognizer}});var qT=IS();Object.defineProperty(l,"SpeechRecognizer",{enumerable:!0,get:function(){return qT.SpeechRecognizer}});var xT=wS();Object.defineProperty(l,"IntentRecognizer",{enumerable:!0,get:function(){return xT.IntentRecognizer}});var zT=_S();Object.defineProperty(l,"VoiceProfileType",{enumerable:!0,get:function(){return zT.VoiceProfileType}});var jT=OS();Object.defineProperty(l,"TranslationRecognizer",{enumerable:!0,get:function(){return jT.TranslationRecognizer}});var LT=MS();Object.defineProperty(l,"Translations",{enumerable:!0,get:function(){return LT.Translations}});var BT=DS();Object.defineProperty(l,"NoMatchReason",{enumerable:!0,get:function(){return BT.NoMatchReason}});var FT=kS();Object.defineProperty(l,"NoMatchDetails",{enumerable:!0,get:function(){return FT.NoMatchDetails}});var VT=NS();Object.defineProperty(l,"TranslationRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return VT.TranslationRecognitionCanceledEventArgs}});var UT=qS();Object.defineProperty(l,"IntentRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return UT.IntentRecognitionCanceledEventArgs}});var WT=id();Object.defineProperty(l,"CancellationDetailsBase",{enumerable:!0,get:function(){return WT.CancellationDetailsBase}});var HT=xS();Object.defineProperty(l,"CancellationDetails",{enumerable:!0,get:function(){return HT.CancellationDetails}});var KT=zS();Object.defineProperty(l,"CancellationErrorCode",{enumerable:!0,get:function(){return KT.CancellationErrorCode}});var JT=jS();Object.defineProperty(l,"ConnectionEventArgs",{enumerable:!0,get:function(){return JT.ConnectionEventArgs}});var GT=LS();Object.defineProperty(l,"ServiceEventArgs",{enumerable:!0,get:function(){return GT.ServiceEventArgs}});var $T=$h();Object.defineProperty(l,"Connection",{enumerable:!0,get:function(){return $T.Connection}});var QT=BS();Object.defineProperty(l,"PhraseListGrammar",{enumerable:!0,get:function(){return QT.PhraseListGrammar}});var YT=Jo();Object.defineProperty(l,"DialogServiceConfig",{enumerable:!0,get:function(){return YT.DialogServiceConfig}});var XT=FS();Object.defineProperty(l,"BotFrameworkConfig",{enumerable:!0,get:function(){return XT.BotFrameworkConfig}});var ZT=VS();Object.defineProperty(l,"CustomCommandsConfig",{enumerable:!0,get:function(){return ZT.CustomCommandsConfig}});var eA=JS();Object.defineProperty(l,"DialogServiceConnector",{enumerable:!0,get:function(){return eA.DialogServiceConnector}});var tA=GS();Object.defineProperty(l,"ActivityReceivedEventArgs",{enumerable:!0,get:function(){return tA.ActivityReceivedEventArgs}});var rA=QS();Object.defineProperty(l,"TurnStatusReceivedEventArgs",{enumerable:!0,get:function(){return rA.TurnStatusReceivedEventArgs}});var iA=YS();Object.defineProperty(l,"ServicePropertyChannel",{enumerable:!0,get:function(){return iA.ServicePropertyChannel}});var nA=XS();Object.defineProperty(l,"ProfanityOption",{enumerable:!0,get:function(){return nA.ProfanityOption}});var sA=ZS();Object.defineProperty(l,"BaseAudioPlayer",{enumerable:!0,get:function(){return sA.BaseAudioPlayer}});var oA=ey();Object.defineProperty(l,"ConnectionMessageEventArgs",{enumerable:!0,get:function(){return oA.ConnectionMessageEventArgs}});var aA=Hh();Object.defineProperty(l,"ConnectionMessage",{enumerable:!0,get:function(){return aA.ConnectionMessage}});var cA=ty();Object.defineProperty(l,"VoiceProfile",{enumerable:!0,get:function(){return cA.VoiceProfile}});var gC=iy();Object.defineProperty(l,"VoiceProfileEnrollmentResult",{enumerable:!0,get:function(){return gC.VoiceProfileEnrollmentResult}});Object.defineProperty(l,"VoiceProfileEnrollmentCancellationDetails",{enumerable:!0,get:function(){return gC.VoiceProfileEnrollmentCancellationDetails}});var mC=sy();Object.defineProperty(l,"VoiceProfileResult",{enumerable:!0,get:function(){return mC.VoiceProfileResult}});Object.defineProperty(l,"VoiceProfileCancellationDetails",{enumerable:!0,get:function(){return mC.VoiceProfileCancellationDetails}});var pA=oy();Object.defineProperty(l,"VoiceProfilePhraseResult",{enumerable:!0,get:function(){return pA.VoiceProfilePhraseResult}});var uA=ay();Object.defineProperty(l,"VoiceProfileClient",{enumerable:!0,get:function(){return uA.VoiceProfileClient}});var hA=cy();Object.defineProperty(l,"SpeakerRecognizer",{enumerable:!0,get:function(){return hA.SpeakerRecognizer}});var dA=py();Object.defineProperty(l,"SpeakerIdentificationModel",{enumerable:!0,get:function(){return dA.SpeakerIdentificationModel}});var lA=hy();Object.defineProperty(l,"SpeakerVerificationModel",{enumerable:!0,get:function(){return lA.SpeakerVerificationModel}});var vA=ly();Object.defineProperty(l,"AutoDetectSourceLanguageConfig",{enumerable:!0,get:function(){return vA.AutoDetectSourceLanguageConfig}});var fA=fy();Object.defineProperty(l,"AutoDetectSourceLanguageResult",{enumerable:!0,get:function(){return fA.AutoDetectSourceLanguageResult}});var gA=gy();Object.defineProperty(l,"SourceLanguageConfig",{enumerable:!0,get:function(){return gA.SourceLanguageConfig}});var xl=Sy();Object.defineProperty(l,"SpeakerRecognitionResult",{enumerable:!0,get:function(){return xl.SpeakerRecognitionResult}});Object.defineProperty(l,"SpeakerRecognitionResultType",{enumerable:!0,get:function(){return xl.SpeakerRecognitionResultType}});Object.defineProperty(l,"SpeakerRecognitionCancellationDetails",{enumerable:!0,get:function(){return xl.SpeakerRecognitionCancellationDetails}});var Be=Oa();Object.defineProperty(l,"Conversation",{enumerable:!0,get:function(){return Be.Conversation}});Object.defineProperty(l,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return Be.ConversationExpirationEventArgs}});Object.defineProperty(l,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return Be.ConversationParticipantsChangedEventArgs}});Object.defineProperty(l,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return Be.ConversationTranslationCanceledEventArgs}});Object.defineProperty(l,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return Be.ConversationTranslationEventArgs}});Object.defineProperty(l,"ConversationTranslationResult",{enumerable:!0,get:function(){return Be.ConversationTranslationResult}});Object.defineProperty(l,"ConversationTranslator",{enumerable:!0,get:function(){return Be.ConversationTranslator}});Object.defineProperty(l,"ConversationTranscriber",{enumerable:!0,get:function(){return Be.ConversationTranscriber}});Object.defineProperty(l,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return Be.ConversationTranscriptionResult}});Object.defineProperty(l,"Meeting",{enumerable:!0,get:function(){return Be.Meeting}});Object.defineProperty(l,"MeetingTranscriber",{enumerable:!0,get:function(){return Be.MeetingTranscriber}});Object.defineProperty(l,"Participant",{enumerable:!0,get:function(){return Be.Participant}});Object.defineProperty(l,"ParticipantChangedReason",{enumerable:!0,get:function(){return Be.ParticipantChangedReason}});Object.defineProperty(l,"User",{enumerable:!0,get:function(){return Be.User}});var mA=za();Object.defineProperty(l,"Synthesizer",{enumerable:!0,get:function(){return mA.Synthesizer}});var SA=mh();Object.defineProperty(l,"SpeechSynthesisOutputFormat",{enumerable:!0,get:function(){return SA.SpeechSynthesisOutputFormat}});var yA=Vy();Object.defineProperty(l,"SpeechSynthesizer",{enumerable:!0,get:function(){return yA.SpeechSynthesizer}});var CA=Uy();Object.defineProperty(l,"SynthesisResult",{enumerable:!0,get:function(){return CA.SynthesisResult}});var PA=Wy();Object.defineProperty(l,"SpeechSynthesisResult",{enumerable:!0,get:function(){return PA.SpeechSynthesisResult}});var RA=Hy();Object.defineProperty(l,"SpeechSynthesisEventArgs",{enumerable:!0,get:function(){return RA.SpeechSynthesisEventArgs}});var EA=Ky();Object.defineProperty(l,"SpeechSynthesisWordBoundaryEventArgs",{enumerable:!0,get:function(){return EA.SpeechSynthesisWordBoundaryEventArgs}});var IA=Jy();Object.defineProperty(l,"SpeechSynthesisBookmarkEventArgs",{enumerable:!0,get:function(){return IA.SpeechSynthesisBookmarkEventArgs}});var wA=Gy();Object.defineProperty(l,"SpeechSynthesisVisemeEventArgs",{enumerable:!0,get:function(){return wA.SpeechSynthesisVisemeEventArgs}});var _A=$y();Object.defineProperty(l,"SpeechSynthesisBoundaryType",{enumerable:!0,get:function(){return _A.SpeechSynthesisBoundaryType}});var TA=Qy();Object.defineProperty(l,"SynthesisVoicesResult",{enumerable:!0,get:function(){return TA.SynthesisVoicesResult}});var AA=Yy();Object.defineProperty(l,"VoiceInfo",{enumerable:!0,get:function(){return AA.VoiceInfo}});var bA=Zy();Object.defineProperty(l,"SpeakerAudioDestination",{enumerable:!0,get:function(){return bA.SpeakerAudioDestination}});var OA=eC();Object.defineProperty(l,"ConversationTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return OA.ConversationTranscriptionCanceledEventArgs}});var MA=tC();Object.defineProperty(l,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return MA.MeetingTranscriptionCanceledEventArgs}});var DA=rC();Object.defineProperty(l,"PronunciationAssessmentGradingSystem",{enumerable:!0,get:function(){return DA.PronunciationAssessmentGradingSystem}});var kA=iC();Object.defineProperty(l,"PronunciationAssessmentGranularity",{enumerable:!0,get:function(){return kA.PronunciationAssessmentGranularity}});var NA=nC();Object.defineProperty(l,"PronunciationAssessmentConfig",{enumerable:!0,get:function(){return NA.PronunciationAssessmentConfig}});var qA=sC();Object.defineProperty(l,"PronunciationAssessmentResult",{enumerable:!0,get:function(){return qA.PronunciationAssessmentResult}});var xA=Dd();Object.defineProperty(l,"LanguageIdMode",{enumerable:!0,get:function(){return xA.LanguageIdMode}});var zA=oC();Object.defineProperty(l,"AvatarConfig",{enumerable:!0,get:function(){return zA.AvatarConfig}});var jA=aC();Object.defineProperty(l,"AvatarEventArgs",{enumerable:!0,get:function(){return jA.AvatarEventArgs}});var LA=pC();Object.defineProperty(l,"AvatarSynthesizer",{enumerable:!0,get:function(){return LA.AvatarSynthesizer}});var SC=uC();Object.defineProperty(l,"AvatarVideoFormat",{enumerable:!0,get:function(){return SC.AvatarVideoFormat}});Object.defineProperty(l,"Coordinate",{enumerable:!0,get:function(){return SC.Coordinate}});var BA=hC();Object.defineProperty(l,"AvatarWebRTCConnectionResult",{enumerable:!0,get:function(){return BA.AvatarWebRTCConnectionResult}});var FA=dC();Object.defineProperty(l,"Diagnostics",{enumerable:!0,get:function(){return FA.Diagnostics}});var VA=rh();Object.defineProperty(l,"LogLevel",{enumerable:!0,get:function(){return VA.LogLevel}})});var yC=p(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});ac.ProxyInfo=void 0;var oc=f(),zl=class i{constructor(e,t,r,n){this.privProxyHostName=e,this.privProxyPort=t,this.privProxyUserName=r,this.privProxyPassword=n}static fromParameters(e){return new i(e.getProperty(oc.PropertyId.SpeechServiceConnection_ProxyHostName),parseInt(e.getProperty(oc.PropertyId.SpeechServiceConnection_ProxyPort),10),e.getProperty(oc.PropertyId.SpeechServiceConnection_ProxyUserName),e.getProperty(oc.PropertyId.SpeechServiceConnection_ProxyPassword))}static fromRecognizerConfig(e){return this.fromParameters(e.parameters)}get HostName(){return this.privProxyHostName}get Port(){return this.privProxyPort}get UserName(){return this.privProxyUserName}get Password(){return this.privProxyPassword}};ac.ProxyInfo=zl});var PC=p((_1,CC)=>{"use strict";var UA=new Set(["json","buffer","string"]);CC.exports=i=>(...e)=>{let t=new Set,r,n,s,o="";return e.forEach(a=>{if(typeof a=="string")if(a.toUpperCase()===a)if(r){let c=`Can't set method to ${a}, already set to ${r}.`;throw new Error(c)}else r=a;else if(a.startsWith("http:")||a.startsWith("https:"))o=a;else if(UA.has(a))n=a;else throw new Error(`Unknown encoding, ${a}`);else if(typeof a=="number")t.add(a);else if(typeof a=="object")if(Array.isArray(a)||a instanceof Set)a.forEach(c=>t.add(c));else{if(s)throw new Error("Cannot set headers twice.");s=a}else throw new Error(`Unknown type: ${typeof a}`)}),r||(r="GET"),t.size===0&&t.add(200),i(t,r,n,s,o)}});var EC=p((T1,RC)=>{"use strict";var WA=PC(),jl=class i extends Error{constructor(e,...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="StatusError",this.message=e.statusMessage,this.statusCode=e.status,this.res=e,this.json=e.json.bind(e),this.text=e.text.bind(e),this.arrayBuffer=e.arrayBuffer.bind(e);let r;Object.defineProperty(this,"responseBody",{get:()=>(r||(r=this.arrayBuffer()),r)}),this.headers={};for(let[s,o]of e.headers.entries())this.headers[s.toLowerCase()]=o}},HA=(i,e,t,r,n)=>async(s,o,a={})=>{s=n+(s||"");let c=new URL(s);if(r||(r={}),c.username&&(r.Authorization="Basic "+btoa(c.username+":"+c.password),c=new URL(c.protocol+"//"+c.host+c.pathname+c.search)),c.protocol!=="https:"&&c.protocol!=="http:")throw new Error(`Unknown protocol, ${c.protocol}`);if(o&&!(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||typeof o=="string"))if(typeof o=="object")o=JSON.stringify(o),r["Content-Type"]="application/json";else throw new Error("Unknown body type.");a=new Headers({...r||{},...a});let u=await fetch(c,{method:e,headers:a,body:o});if(u.statusCode=u.status,!i.has(u.status))throw new jl(u);return t==="json"?u.json():t==="buffer"?u.arrayBuffer():t==="string"?u.text():u};RC.exports=WA(HA)});var wC=p(Kt=>{"use strict";var KA=Kt&&Kt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Kt,"__esModule",{value:!0});Kt.RestMessageAdapter=Kt.RestRequestType=void 0;var JA=KA(EC()),IC=P(),cc;(function(i){i.Get="GET",i.Post="POST",i.Delete="DELETE",i.File="file"})(cc=Kt.RestRequestType||(Kt.RestRequestType={}));var Ll=class{constructor(e){if(!e)throw new IC.ArgumentNullError("configParams");this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}static extractHeaderValue(e,t){let r="";try{let n=t.trim().split(/[\r\n]+/),s={};n.forEach(o=>{let a=o.split(": "),c=a.shift().toLowerCase(),u=a.join(": ");s[c]=u}),r=s[e.toLowerCase()]}catch{}return r}set options(e){this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}setHeaders(e,t){this.privHeaders[e]=t}request(e,t,r={},n=null){let s=new IC.Deferred,o=e===cc.File?"POST":e,a=(u,h={})=>{let d=u;return{data:JSON.stringify(h),headers:JSON.stringify(u.headers),json:h,ok:u.statusCode>=200&&u.statusCode<300,status:u.statusCode,statusText:h.error?h.error.message:d.statusText?d.statusText:d.statusMessage}},c=u=>{let h=JA.default(t,o,this.privHeaders,200,201,202,204,400,401,402,403,404),d=this.queryParams(r)===""?"":`?${this.queryParams(r)}`;h(d,u).then(async v=>{if(e===cc.Delete||v.statusCode===204)s.resolve(a(v));else try{let g=await v.json();s.resolve(a(v,g))}catch{s.resolve(a(v))}}).catch(v=>{s.reject(v)})};return this.privIgnoreCache&&(this.privHeaders["Cache-Control"]="no-cache"),e===cc.Post&&n&&(this.privHeaders["content-type"]="application/json",this.privHeaders["Content-Type"]="application/json"),c(n),s.promise}queryParams(e={}){return Object.keys(e).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(e[t])).join("&")}};Kt.RestMessageAdapter=Ll});var Bl=p(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});pc.RestConfigBase=void 0;var Mi=class i{static get requestOptions(){return i.privDefaultRequestOptions}static get configParams(){return i.privDefaultParams}static get restErrors(){return i.privRestErrors}};pc.RestConfigBase=Mi;Mi.privDefaultRequestOptions={headers:{Accept:"application/json"},ignoreCache:!1,timeout:1e4};Mi.privRestErrors={authInvalidSubscriptionKey:"You must specify either an authentication token to use, or a Cognitive Speech subscription key.",authInvalidSubscriptionRegion:"You must specify the Cognitive Speech region to use.",invalidArgs:"Required input not found: {arg}.",invalidCreateJoinConversationResponse:"Creating/Joining conversation failed with HTTP {status}.",invalidParticipantRequest:"The requested participant was not found.",permissionDeniedConnect:"Required credentials not found.",permissionDeniedConversation:"Invalid operation: only the host can {command} the conversation.",permissionDeniedParticipant:"Invalid operation: only the host can {command} a participant.",permissionDeniedSend:"Invalid operation: the conversation is not in a connected state.",permissionDeniedStart:"Invalid operation: there is already an active conversation."};Mi.privDefaultParams={apiVersion:"api-version",authorization:"Authorization",clientAppId:"X-ClientAppId",contentTypeKey:"Content-Type",correlationId:"X-CorrelationId",languageCode:"language",nickname:"nickname",profanity:"profanity",requestId:"X-RequestId",roomId:"roomid",sessionToken:"token",subscriptionKey:"Ocp-Apim-Subscription-Key",subscriptionRegion:"Ocp-Apim-Subscription-Region",token:"X-CapitoToken"}});var pe=p(me=>{"use strict";var GA=me&&me.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),mt=me&&me.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&GA(e,i,t)};Object.defineProperty(me,"__esModule",{value:!0});mt(qm(),me);mt(zm(),me);mt(Bm(),me);mt(Vm(),me);mt(Um(),me);mt(Qm(),me);mt(ch(),me);mt(Ym(),me);mt(yC(),me);mt(wC(),me);mt(Bl(),me)});var AC=p(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.IntentConnectionFactory=void 0;var _C=pe(),Un=f(),TC=Ye(),$A=C(),QA=we(),Fl=class extends TC.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Un.PropertyId.SpeechServiceConnection_Endpoint);if(!n){let c=e.parameters.getProperty(Un.PropertyId.SpeechServiceConnection_IntentRegion),u=TC.ConnectionFactoryBase.getHostSuffix(c);n=e.parameters.getProperty(Un.PropertyId.SpeechServiceConnection_Host,"wss://"+c+".sr.speech"+u)+"/speech/recognition/interactive/cognitiveservices/v1"}let s={format:"simple",language:e.parameters.getProperty(Un.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,s,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[QA.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Un.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new _C.WebsocketConnection(n,s,o,new $A.WebsocketMessageFormatter,_C.ProxyInfo.fromRecognizerConfig(e),a,r)}getSpeechRegionFromIntentRegion(e){switch(e){case"West US":case"US West":case"westus":return"uswest";case"West US 2":case"US West 2":case"westus2":return"uswest2";case"South Central US":case"US South Central":case"southcentralus":return"ussouthcentral";case"West Central US":case"US West Central":case"westcentralus":return"uswestcentral";case"East US":case"US East":case"eastus":return"useast";case"East US 2":case"US East 2":case"eastus2":return"useast2";case"West Europe":case"Europe West":case"westeurope":return"europewest";case"North Europe":case"Europe North":case"northeurope":return"europenorth";case"Brazil South":case"South Brazil":case"southbrazil":return"brazilsouth";case"Australia East":case"East Australia":case"eastaustralia":return"australiaeast";case"Southeast Asia":case"Asia Southeast":case"southeastasia":return"asiasoutheast";case"East Asia":case"Asia East":case"eastasia":return"asiaeast";default:return e}}};uc.IntentConnectionFactory=Fl});var DC=p(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.VoiceProfileConnectionFactory=Di.SpeakerRecognitionConnectionFactory=void 0;var bC=pe(),Kr=f(),OC=Ye(),YA=C(),MC=we(),hc=class extends OC.ConnectionFactoryBase{create(e,t,r,n){let s=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_Endpoint);if(!s){let u=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_Region),h=OC.ConnectionFactoryBase.getHostSuffix(u),d=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_Host,`wss://${u}.spr-frontend.speech${h}`),v=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_SpeakerIdMode,"TextIndependentIdentification");s=`${d}/speaker/ws/${this.scenarioToPath(v)}/${r}`}let o={format:"simple",language:e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,o,s);let a={};t.token!==void 0&&t.token!==""&&(a[t.headerName]=t.token),a[MC.HeaderNames.ConnectionId]=n,a[MC.HeaderNames.SpIDAuthKey]=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_Key),e.parameters.setProperty(Kr.PropertyId.SpeechServiceConnection_Url,s);let c=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new bC.WebsocketConnection(s,o,a,new YA.WebsocketMessageFormatter,bC.ProxyInfo.fromRecognizerConfig(e),c,n)}scenarioToPath(e){switch(e){case"TextIndependentVerification":case"2":return"verification/text-independent";case"TextDependentVerification":case"1":return"verification/text-dependent";default:return"identification/text-independent"}}},Vl=class extends hc{create(e,t,r){return super.create(e,t,"recognition",r)}};Di.SpeakerRecognitionConnectionFactory=Vl;var Ul=class extends hc{create(e,t,r){return super.create(e,t,"profile",r)}};Di.VoiceProfileConnectionFactory=Ul});var lc=p(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.RecognitionEndedEvent=Se.RecognitionCompletionStatus=Se.RecognitionStartedEvent=Se.ConnectingToServiceEvent=Se.ListeningStartedEvent=Se.RecognitionTriggeredEvent=Se.SpeechRecognitionEvent=void 0;var dc=P(),lr=class extends dc.PlatformEvent{constructor(e,t,r,n=dc.EventType.Info){super(e,n),this.privRequestId=t,this.privSessionId=r}get requestId(){return this.privRequestId}get sessionId(){return this.privSessionId}};Se.SpeechRecognitionEvent=lr;var Wl=class extends lr{constructor(e,t,r,n){super("RecognitionTriggeredEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};Se.RecognitionTriggeredEvent=Wl;var Hl=class extends lr{constructor(e,t,r,n){super("ListeningStartedEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};Se.ListeningStartedEvent=Hl;var Kl=class extends lr{constructor(e,t,r){super("ConnectingToServiceEvent",e,r),this.privAuthFetchEventid=t}get authFetchEventid(){return this.privAuthFetchEventid}};Se.ConnectingToServiceEvent=Kl;var Jl=class extends lr{constructor(e,t,r,n,s){super("RecognitionStartedEvent",e,s),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}};Se.RecognitionStartedEvent=Jl;var kC;(function(i){i[i.Success=0]="Success",i[i.AudioSourceError=1]="AudioSourceError",i[i.AudioSourceTimeout=2]="AudioSourceTimeout",i[i.AuthTokenFetchError=3]="AuthTokenFetchError",i[i.AuthTokenFetchTimeout=4]="AuthTokenFetchTimeout",i[i.UnAuthorized=5]="UnAuthorized",i[i.ConnectTimeout=6]="ConnectTimeout",i[i.ConnectError=7]="ConnectError",i[i.ClientRecognitionActivityTimeout=8]="ClientRecognitionActivityTimeout",i[i.UnknownError=9]="UnknownError"})(kC=Se.RecognitionCompletionStatus||(Se.RecognitionCompletionStatus={}));var Gl=class extends lr{constructor(e,t,r,n,s,o,a,c){super("RecognitionEndedEvent",e,s,a===kC.Success?dc.EventType.Info:dc.EventType.Error),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=n,this.privStatus=a,this.privError=c,this.privServiceTag=o}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}get serviceTag(){return this.privServiceTag}get status(){return this.privStatus}get error(){return this.privError}};Se.RecognitionEndedEvent=Gl});var Jr=p(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});vc.SpeechConnectionMessage=void 0;var $l=P(),Jt=we(),Ql=class i extends $l.ConnectionMessage{constructor(e,t,r,n,s,o,a,c){if(!t)throw new $l.ArgumentNullError("path");if(!r)throw new $l.ArgumentNullError("requestId");let u={};if(u[Jt.HeaderNames.Path]=t,u[Jt.HeaderNames.RequestId]=r,u[Jt.HeaderNames.RequestTimestamp]=new Date().toISOString(),n&&(u[Jt.HeaderNames.ContentType]=n),o&&(u[Jt.HeaderNames.RequestStreamId]=o),a)for(let h in a)h&&(u[h]=a[h]);c?super(e,s,u,c):super(e,s,u),this.privPath=t,this.privRequestId=r,this.privContentType=n,this.privStreamId=o,this.privAdditionalHeaders=a}get path(){return this.privPath}get requestId(){return this.privRequestId}get contentType(){return this.privContentType}get streamId(){return this.privStreamId}get additionalHeaders(){return this.privAdditionalHeaders}static fromConnectionMessage(e){let t=null,r=null,n=null,s=null,o={};if(e.headers)for(let a in e.headers)a&&(a.toLowerCase()===Jt.HeaderNames.Path.toLowerCase()?t=e.headers[a]:a.toLowerCase()===Jt.HeaderNames.RequestId.toLowerCase()?r=e.headers[a]:a.toLowerCase()===Jt.HeaderNames.ContentType.toLowerCase()?n=e.headers[a]:a.toLowerCase()===Jt.HeaderNames.RequestStreamId.toLowerCase()?s=e.headers[a]:o[a]=e.headers[a]);return new i(e.messageType,t,r,n,e.body,s,o,e.id)}};vc.SpeechConnectionMessage=Ql});var NC=p(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.ServiceRecognizerBase=void 0;var XA=pe(),te=P(),B=f(),At=C(),vr=Jr(),fc=class i{constructor(e,t,r,n,s){if(this.privConnectionConfigurationPromise=void 0,this.privConnectionPromise=void 0,this.privSetTimeout=setTimeout,this.privIsLiveAudio=!1,this.privAverageBytesPerMs=0,this.privEnableSpeakerId=!1,this.privExpectContentAssessmentResponse=!1,this.recognizeOverride=void 0,this.recognizeSpeaker=void 0,this.disconnectOverride=void 0,this.receiveMessageOverride=void 0,this.sendPrePayloadJSONOverride=void 0,this.postConnectImplOverride=void 0,this.configConnectionOverride=void 0,this.handleSpeechPhraseMessage=void 0,this.handleSpeechHypothesisMessage=void 0,!e)throw new te.ArgumentNullError("authentication");if(!t)throw new te.ArgumentNullError("connectionFactory");if(!r)throw new te.ArgumentNullError("audioSource");if(!n)throw new te.ArgumentNullError("recognizerConfig");this.privEnableSpeakerId=n.isSpeakerDiarizationEnabled,this.privMustReportEndOfStream=!1,this.privAuthentication=e,this.privConnectionFactory=t,this.privAudioSource=r,this.privRecognizerConfig=n,this.privIsDisposed=!1,this.privRecognizer=s,this.privRequestSession=new At.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new te.EventSource,this.privServiceEvents=new te.EventSource,this.privDynamicGrammar=new At.DynamicGrammarBuilder,this.privSpeechContext=new At.SpeechContext(this.privDynamicGrammar),this.privAgentConfig=new At.AgentConfig,this.privRecognizerConfig.parameters.getProperty(B.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?this.privSetTimeout=te.Timeout.setTimeout:typeof window<"u"&&(this.privSetTimeout=window.setTimeout.bind(window)),this.connectionEvents.attach(a=>{if(a.name==="ConnectionClosedEvent"){let c=a;(c.statusCode===1003||c.statusCode===1007||c.statusCode===1002||c.statusCode===4e3||this.privRequestSession.numConnectionAttempts>this.privRecognizerConfig.maxRetryCount)&&this.cancelRecognitionLocal(B.CancellationReason.Error,c.statusCode===1007?B.CancellationErrorCode.BadRequestParameters:B.CancellationErrorCode.ConnectionFailure,`${c.reason} websocket error code: ${c.statusCode}`)}}),this.privEnableSpeakerId&&(this.privDiarizationSessionId=te.createNoDashGuid()),this.setLanguageIdJson(),this.setOutputDetailLevelJson()}setTranslationJson(){let e=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0);if(e!==void 0){let t=e.split(","),r=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationVoice,void 0),n=r!==void 0?"Synthesize":"None";if(this.privSpeechContext.setSection("translation",{onSuccess:{action:n},output:{interimResults:{mode:"Always"}},targetLanguages:t}),r!==void 0){let s={};for(let o of t)s[o]=r;this.privSpeechContext.setSection("synthesis",{defaultVoices:s})}}}setSpeechSegmentationTimeoutJson(){let e=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.Speech_SegmentationSilenceTimeoutMs,void 0);if(e!==void 0){let t=this.recognitionMode===At.RecognitionMode.Conversation?"CONVERSATION":this.recognitionMode===At.RecognitionMode.Dictation?"DICTATION":"INTERACTIVE",r=parseInt(e,10),n=this.privSpeechContext.getSection("phraseDetection");n.mode=t,n[t]={segmentation:{mode:"Custom",segmentationSilenceTimeoutMs:r}},this.privSpeechContext.setSection("phraseDetection",n)}}setLanguageIdJson(){let e=this.privSpeechContext.getSection("phraseDetection");if(this.privRecognizerConfig.autoDetectSourceLanguages!==void 0){let r=this.privRecognizerConfig.autoDetectSourceLanguages.split(","),n;this.privRecognizerConfig.languageIdMode==="Continuous"?n="DetectContinuous":n="DetectAtAudioStart",this.privSpeechContext.setSection("languageId",{Priority:"PrioritizeLatency",languages:r,mode:n,onSuccess:{action:"Recognize"},onUnknown:{action:"None"}}),this.privSpeechContext.setSection("phraseOutput",{interimResults:{resultType:"Auto"},phraseResults:{resultType:"Always"}});let s=this.privRecognizerConfig.sourceLanguageModels;s!==void 0&&(e.customModels=s,e.onInterim={action:"None"},e.onSuccess={action:"None"})}this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0&&(e.onInterim={action:"Translate"},e.onSuccess={action:"Translate"},this.privSpeechContext.setSection("phraseOutput",{interimResults:{resultType:"None"},phraseResults:{resultType:"None"}})),this.privSpeechContext.setSection("phraseDetection",e)}setOutputDetailLevelJson(){this.privEnableSpeakerId&&(this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true"?this.privSpeechContext.setWordLevelTimings():this.privRecognizerConfig.parameters.getProperty(At.OutputFormatPropertyName,B.OutputFormat[B.OutputFormat.Simple]).toLowerCase()===B.OutputFormat[B.OutputFormat.Detailed].toLocaleLowerCase()&&this.privSpeechContext.setDetailedOutputFormat())}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}get audioSource(){return this.privAudioSource}get speechContext(){return this.privSpeechContext}get dynamicGrammar(){return this.privDynamicGrammar}get agentConfig(){return this.privAgentConfig}set conversationTranslatorToken(e){this.privRecognizerConfig.parameters.setProperty(B.PropertyId.ConversationTranslator_Token,e)}set voiceProfileType(e){this.privRecognizerConfig.parameters.setProperty(B.PropertyId.SpeechServiceConnection_SpeakerIdMode,e)}set authentication(e){this.privAuthentication=e}isDisposed(){return this.privIsDisposed}async dispose(e){if(this.privIsDisposed=!0,this.privConnectionConfigurationPromise!==void 0)try{await(await this.privConnectionConfigurationPromise).dispose(e)}catch{return}}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}get recognitionMode(){return this.privRecognizerConfig.recognitionMode}async recognize(e,t,r){if(this.recognizeOverride!==void 0){await this.recognizeOverride(e,t,r);return}this.privConnectionConfigurationPromise=void 0,this.privRecognizerConfig.recognitionMode=e,this.setSpeechSegmentationTimeoutJson(),this.setTranslationJson(),this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events);let n=this.connectImpl(),s;try{let c=await this.audioSource.attach(this.privRequestSession.audioNodeId),u=await this.audioSource.format,h=await this.audioSource.deviceInfo;this.privIsLiveAudio=h.type&&h.type===At.type.Microphones,s=new XA.ReplayableAudioNode(c,u.avgBytesPerSec),await this.privRequestSession.onAudioSourceAttachCompleted(s,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:h}}catch(c){throw await this.privRequestSession.onStopRecognizing(),c}try{await n}catch(c){await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.ConnectionFailure,c);return}let o=new B.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,o),this.receiveMessage(),this.sendAudio(s).catch(async c=>{await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.RuntimeError,c)})}async stopRecognizing(){if(this.privRequestSession.isRecognizing)try{await this.audioSource.turnOff(),await this.sendFinalAudio(),await this.privRequestSession.onStopRecognizing(),await this.privRequestSession.turnCompletionPromise}finally{await this.privRequestSession.dispose()}}async connect(){return await this.connectImpl(),Promise.resolve()}connectAsync(e,t){this.connectImpl().then(()=>{try{e&&e()}catch(r){t&&t(r)}},r=>{try{t&&t(r)}catch{}})}async disconnect(){if(await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.NoError,"Disconnecting"),this.disconnectOverride!==void 0&&await this.disconnectOverride(),this.privConnectionPromise!==void 0)try{await(await this.privConnectionPromise).dispose()}catch{}this.privConnectionPromise=void 0}sendMessage(e){}async sendNetworkMessage(e,t){let r=typeof t=="string"?te.MessageType.Text:te.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new vr.SpeechConnectionMessage(r,e,this.privRequestSession.requestId,n,t))}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set expectContentAssessmentResponse(e){this.privExpectContentAssessmentResponse=e}async sendTelemetryData(){let e=this.privRequestSession.getTelemetry();if(i.telemetryDataEnabled!==!0||this.privIsDisposed||e===null)return;if(i.telemetryData)try{i.telemetryData(e)}catch{}await(await this.fetchConnection()).send(new vr.SpeechConnectionMessage(te.MessageType.Text,"telemetry",this.privRequestSession.requestId,"application/json",e))}async cancelRecognitionLocal(e,t,r){this.privRequestSession.isRecognizing&&(await this.privRequestSession.onStopRecognizing(),this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,e,t,r))}async receiveMessage(){try{if(this.privIsDisposed)return;let e=await this.fetchConnection(),t=await e.read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(!t)return this.receiveMessage();this.privServiceHasSentMessage=!0;let r=vr.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privRequestSession.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privMustReportEndOfStream=!0,this.privRequestSession.onServiceTurnStartResponse();break;case"speech.startdetected":let n=At.SpeechDetected.fromJSON(r.textBody),s=new B.RecognitionEventArgs(n.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,s);break;case"speech.enddetected":let o;r.textBody.length>0?o=r.textBody:o="{ Offset: 0 }";let a=At.SpeechDetected.fromJSON(o),c=new B.RecognitionEventArgs(a.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,c);break;case"turn.end":await this.sendTelemetryData(),this.privRequestSession.isSpeechEnded&&this.privMustReportEndOfStream&&(this.privMustReportEndOfStream=!1,await this.cancelRecognitionLocal(B.CancellationReason.EndOfStream,B.CancellationErrorCode.NoError,void 0));let u=new B.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition),!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing){this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,u);return}else e=await this.fetchConnection(),await this.sendPrePayloadJSON(e);break;default:await this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new te.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch{return null}}updateSpeakerDiarizationAudioOffset(){let t=this.privRequestSession.recognitionBytesSent/this.privAverageBytesPerMs;this.privSpeechContext.setSpeakerDiarizationAudioOffsetMs(t)}sendSpeechContext(e,t){this.privEnableSpeakerId&&this.updateSpeakerDiarizationAudioOffset();let r=this.speechContext.toJSON();if(t&&this.privRequestSession.onSpeechContext(),r)return e.send(new vr.SpeechConnectionMessage(te.MessageType.Text,"speech.context",this.privRequestSession.requestId,"application/json",r))}noOp(){}async sendPrePayloadJSON(e,t=!0){if(this.sendPrePayloadJSONOverride!==void 0)return this.sendPrePayloadJSONOverride(e);await this.sendSpeechContext(e,t),await this.sendWaveHeader(e)}async sendWaveHeader(e){let t=await this.audioSource.format;return e.send(new vr.SpeechConnectionMessage(te.MessageType.Binary,"audio",this.privRequestSession.requestId,"audio/x-wav",t.header))}connectImpl(){return this.privConnectionPromise!==void 0?this.privConnectionPromise.then(e=>e.state()===te.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl())):(this.privConnectionPromise=this.retryableConnect(),this.privConnectionPromise.catch(()=>{}),this.postConnectImplOverride!==void 0?this.postConnectImplOverride(this.privConnectionPromise):this.privConnectionPromise)}sendSpeechServiceConfig(e,t,r){if(t.onSpeechContext(),i.telemetryDataEnabled!==!0){let s={context:{system:JSON.parse(r).context.system}};r=JSON.stringify(s)}if(this.privRecognizerConfig.parameters.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()==="true"){let n=JSON.parse(r);n.context.DisableReferenceChannel="True",n.context.MicSpec="1_0_0",r=JSON.stringify(n)}if(r)return e.send(new vr.SpeechConnectionMessage(te.MessageType.Text,"speech.config",t.requestId,"application/json",r))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===te.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async sendAudio(e){let t=await this.audioSource.format;this.privAverageBytesPerMs=t.avgBytesPerSec/1e3;let r=Date.now(),n=this.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs","5000"),s=t.avgBytesPerSec/1e3*parseInt(n,10),o=this.privRequestSession.recogNumber,a=async()=>{if(!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o){let c=await this.fetchConnection(),u=await e.read();if(this.privRequestSession.isSpeechEnded)return;let h,d;if(!u||u.isEnd?(h=null,d=0):(h=u.buffer,this.privRequestSession.onAudioSent(h.byteLength),s>=this.privRequestSession.bytesSent?d=0:d=Math.max(0,r-Date.now())),d!==0&&await this.delay(d),h!==null&&(r=Date.now()+h.byteLength*1e3/(t.avgBytesPerSec*2)),!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o)if(c.send(new vr.SpeechConnectionMessage(te.MessageType.Binary,"audio",this.privRequestSession.requestId,null,h)).catch(()=>{this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition).catch(()=>{})}),u?.isEnd)this.privIsLiveAudio||this.privRequestSession.onSpeechEnded();else return a()}};return a()}async retryableConnect(){let e=!1;this.privAuthFetchEventId=te.createNoDashGuid();let t=this.privRequestSession.sessionId;this.privConnectionId=t!==void 0?t:te.createNoDashGuid(),this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId,this.privConnectionId);let r=0,n="";for(;this.privRequestSession.numConnectionAttempts<=this.privRecognizerConfig.maxRetryCount;){let o=await(e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId));await this.privRequestSession.onAuthCompleted(!1);let a=this.privConnectionFactory.create(this.privRecognizerConfig,o,this.privConnectionId);this.privRequestSession.listenForServiceTelemetry(a.events),a.events.attach(u=>{this.connectionEvents.onEvent(u)});let c=await a.open();if(c.statusCode===200)return await this.privRequestSession.onConnectionEstablishCompleted(c.statusCode),Promise.resolve(a);c.statusCode===1006&&(e=!0),r=c.statusCode,n=c.reason,this.privRequestSession.onRetryConnection()}return await this.privRequestSession.onConnectionEstablishCompleted(r,n),Promise.reject(`Unable to contact server. StatusCode: ${r}, ${this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${n}`)}delay(e){return new Promise(t=>this.privSetTimeout(t,e))}writeBufferToConsole(e){let t="Buffer Size: ";if(e===null)t+="null";else{let r=new Uint8Array(e);t+=`${e.byteLength}\r
19
- `;for(let n=0;n<e.byteLength;n++)t+=r[n].toString(16).padStart(2,"0")+" ",(n+1)%16===0&&(console.info(t),t="")}console.info(t)}async sendFinalAudio(){await(await this.fetchConnection()).send(new vr.SpeechConnectionMessage(te.MessageType.Binary,"audio",this.privRequestSession.requestId,null,null))}async configureConnection(){let e=await this.connectImpl();return this.configConnectionOverride!==void 0?this.configConnectionOverride(e):(await this.sendSpeechServiceConfig(e,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendPrePayloadJSON(e,!1),e)}};gc.ServiceRecognizerBase=fc;fc.telemetryDataEnabled=!0});var qC=p(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});mc.ConversationServiceRecognizer=void 0;var et=f(),bt=C(),Yl=class extends bt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.handleSpeechPhraseMessage=async o=>this.handleSpeechPhrase(o),this.handleSpeechHypothesisMessage=o=>this.handleSpeechHypothesis(o)}processTypeSpecificMessages(e){}handleRecognizedCallback(e,t,r){}handleRecognizingCallback(e,t,r){}async processSpeechMessages(e){let t=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":this.handleSpeechHypothesisMessage&&this.handleSpeechHypothesisMessage(e.textBody),t=!0;break;case"speech.phrase":this.handleSpeechPhraseMessage&&await this.handleSpeechPhraseMessage(e.textBody),t=!0;break;default:break}return t}cancelRecognition(e,t,r,n,s){}async handleSpeechPhrase(e){let t=bt.SimpleSpeechPhrase.fromJSON(e),r=bt.EnumTranslation.implTranslateRecognitionResult(t.RecognitionStatus),n,s=new et.PropertyCollection;s.setProperty(et.PropertyId.SpeechServiceResponse_JsonResult,e);let o=t.Offset+this.privRequestSession.currentTurnAudioOffset,a=o;if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+t.Offset+t.Duration),et.ResultReason.Canceled===r){let c=bt.EnumTranslation.implTranslateCancelResult(t.RecognitionStatus),u=bt.EnumTranslation.implTranslateCancelErrorCode(t.RecognitionStatus);await this.cancelRecognitionLocal(c,u,bt.EnumTranslation.implTranslateErrorDetails(u))}else if(!(this.privRequestSession.isSpeechEnded&&r===et.ResultReason.NoMatch&&t.RecognitionStatus!==bt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(bt.OutputFormatPropertyName)===et.OutputFormat[et.OutputFormat.Simple])n=new et.SpeechRecognitionResult(this.privRequestSession.requestId,r,t.DisplayText,t.Duration,o,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,e,s);else{let c=bt.DetailedSpeechPhrase.fromJSON(e),u=c.Offset+this.privRequestSession.currentTurnAudioOffset,h=c.getJsonWithCorrectedOffsets(u);n=new et.SpeechRecognitionResult(this.privRequestSession.requestId,r,c.Text,c.Duration,u,c.Language,c.LanguageDetectionConfidence,c.SpeakerId,void 0,h,s),a=n.offset}this.handleRecognizedCallback(n,a,this.privRequestSession.sessionId)}}handleSpeechHypothesis(e){let t=bt.SpeechHypothesis.fromJSON(e),r=t.Offset+this.privRequestSession.currentTurnAudioOffset,n=new et.PropertyCollection;n.setProperty(et.PropertyId.SpeechServiceResponse_JsonResult,e);let s=new et.SpeechRecognitionResult(this.privRequestSession.requestId,et.ResultReason.RecognizingSpeech,t.Text,t.Duration,r,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,e,n);this.privRequestSession.onHypothesis(r),this.handleRecognizingCallback(s,t.Duration,this.privRequestSession.sessionId)}};mc.ConversationServiceRecognizer=Yl});var zC=p(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.RecognizerConfig=Ot.SpeechResultFormat=Ot.RecognitionMode=void 0;var Sc=f(),xC=C(),yc;(function(i){i[i.Interactive=0]="Interactive",i[i.Conversation=1]="Conversation",i[i.Dictation=2]="Dictation"})(yc=Ot.RecognitionMode||(Ot.RecognitionMode={}));var ZA;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(ZA=Ot.SpeechResultFormat||(Ot.SpeechResultFormat={}));var Xl=class{constructor(e,t){this.privSpeechServiceConfig=e||new xC.SpeechServiceConfig(new xC.Context(null)),this.privParameters=t,this.privMaxRetryCount=parseInt(t.getProperty("SPEECH-Error-MaxRetryCount","4"),10),this.privLanguageIdMode=t.getProperty(Sc.PropertyId.SpeechServiceConnection_LanguageIdMode,void 0),this.privEnableSpeakerId=!1}get parameters(){return this.privParameters}get recognitionMode(){return this.privRecognitionMode}set recognitionMode(e){this.privRecognitionMode=e,this.privRecognitionActivityTimeout=e===yc.Interactive?8e3:25e3,this.privSpeechServiceConfig.Recognition=yc[e]}get SpeechServiceConfig(){return this.privSpeechServiceConfig}get recognitionActivityTimeout(){return this.privRecognitionActivityTimeout}get isContinuousRecognition(){return this.privRecognitionMode!==yc.Interactive}get languageIdMode(){return this.privLanguageIdMode}get autoDetectSourceLanguages(){return this.parameters.getProperty(Sc.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,void 0)}get recognitionEndpointVersion(){return this.parameters.getProperty(Sc.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,void 0)}get sourceLanguageModels(){let e=[],t=!1;if(this.autoDetectSourceLanguages!==void 0)for(let r of this.autoDetectSourceLanguages.split(",")){let n=r+Sc.PropertyId.SpeechServiceConnection_EndpointId.toString(),s=this.parameters.getProperty(n,void 0);s!==void 0?(e.push({language:r,endpoint:s}),t=!0):e.push({language:r,endpoint:""})}return t?e:void 0}get maxRetryCount(){return this.privMaxRetryCount}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}set isSpeakerDiarizationEnabled(e){this.privEnableSpeakerId=e}};Ot.RecognizerConfig=Xl});var LC=p(jC=>{"use strict";Object.defineProperty(jC,"__esModule",{value:!0})});var FC=p(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});Cc.WebsocketMessageFormatter=void 0;var tt=P(),BC=`\r
20
- `,Zl=class{toConnectionMessage(e){let t=new tt.Deferred;try{if(e.messageType===tt.MessageType.Text){let r=e.textContent,n={},s=null;if(r){let o=r.split(`\r
17
+ registerProcessor('speech-processor', SP);`,h=new Blob([u],{type:"application/javascript; charset=utf-8"});this.privSpeechProcessorScript=URL.createObjectURL(h)}e.audioWorklet.addModule(this.privSpeechProcessorScript).then(()=>{let u=new AudioWorkletNode(e,"speech-processor");u.port.onmessage=h=>{let d=h.data;if(r&&!r.isClosed){let v=s.encode(d);v&&r.writeStreamChunk({buffer:v,isEnd:!1,timeReceived:Date.now()})}},o.connect(u),u.connect(e.destination),this.privMediaResources={scriptProcessorNode:u,source:o,stream:t}}).catch(()=>{a()})}else try{a()}catch(u){throw new Error(`Unable to start audio worklet node for PCMRecorder: ${u}`)}}releaseMediaResources(e){this.privMediaResources&&(this.privMediaResources.scriptProcessorNode&&(this.privMediaResources.scriptProcessorNode.disconnect(e.destination),this.privMediaResources.scriptProcessorNode=null),this.privMediaResources.source&&(this.privMediaResources.source.disconnect(),this.privStopInputOnRelease&&this.privMediaResources.stream.getTracks().forEach(t=>t.stop()),this.privMediaResources.source=null))}setWorkletUrl(e){this.privSpeechProcessorScript=e}};Ws.PcmRecorder=nh});var Vm=p(()=>{});var Um=p(()=>{});var Wm=p(()=>{});var Hm=p(()=>{});var Km=p(()=>{});var oh=p(Ge=>{"use strict";var $I=Ge&&Ge.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),QI=Ge&&Ge.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Jm=Ge&&Ge.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&$I(e,i,t);return QI(e,i),e},sh=Ge&&Ge.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.WebsocketMessageAdapter=void 0;var YI=Jm(Vm()),XI=Jm(Um()),ZI=sh(Wm()),ew=sh(Hm()),tw=sh(Km()),rw=we(),T=P(),Hs=class i{constructor(e,t,r,n,s,o){if(!e)throw new T.ArgumentNullError("uri");if(!r)throw new T.ArgumentNullError("messageFormatter");this.proxyInfo=n,this.privConnectionEvents=new T.EventSource,this.privConnectionId=t,this.privMessageFormatter=r,this.privConnectionState=T.ConnectionState.None,this.privUri=e,this.privHeaders=s,this.privEnableCompression=o,this.privHeaders[rw.HeaderNames.ConnectionId]=this.privConnectionId,this.privLastErrorReceived=""}get state(){return this.privConnectionState}open(){if(this.privConnectionState===T.ConnectionState.Disconnected)return Promise.reject(`Cannot open a connection that is in ${this.privConnectionState} state`);if(this.privConnectionEstablishDeferral)return this.privConnectionEstablishDeferral.promise;this.privConnectionEstablishDeferral=new T.Deferred,this.privCertificateValidatedDeferral=new T.Deferred,this.privConnectionState=T.ConnectionState.Connecting;try{if(typeof WebSocket<"u"&&!i.forceNpmWebSocket)this.privCertificateValidatedDeferral.resolve(),this.privWebsocketClient=new WebSocket(this.privUri);else{let e={headers:this.privHeaders,perMessageDeflate:this.privEnableCompression};this.privCertificateValidatedDeferral.resolve(),e.agent=this.getAgent();let r=new URL(this.privUri).protocol;r?.toLocaleLowerCase()==="wss:"?r="https:":r?.toLocaleLowerCase()==="ws:"&&(r="http:"),e.agent.protocol=r,this.privWebsocketClient=new tw.default(this.privUri,e)}this.privWebsocketClient.binaryType="arraybuffer",this.privReceivingMessageQueue=new T.Queue,this.privDisconnectDeferral=new T.Deferred,this.privSendMessageQueue=new T.Queue,this.processSendQueue().catch(e=>{T.Events.instance.onEvent(new T.BackgroundEvent(e))})}catch(e){return this.privConnectionEstablishDeferral.resolve(new T.ConnectionOpenResponse(500,e)),this.privConnectionEstablishDeferral.promise}return this.onEvent(new T.ConnectionStartEvent(this.privConnectionId,this.privUri)),this.privWebsocketClient.onopen=()=>{this.privCertificateValidatedDeferral.promise.then(()=>{this.privConnectionState=T.ConnectionState.Connected,this.onEvent(new T.ConnectionEstablishedEvent(this.privConnectionId)),this.privConnectionEstablishDeferral.resolve(new T.ConnectionOpenResponse(200,""))},e=>{this.privConnectionEstablishDeferral.reject(e)})},this.privWebsocketClient.onerror=e=>{this.onEvent(new T.ConnectionErrorEvent(this.privConnectionId,e.message,e.type)),this.privLastErrorReceived=e.message},this.privWebsocketClient.onclose=e=>{this.privConnectionState===T.ConnectionState.Connecting?(this.privConnectionState=T.ConnectionState.Disconnected,this.privConnectionEstablishDeferral.resolve(new T.ConnectionOpenResponse(e.code,e.reason+" "+this.privLastErrorReceived))):(this.privConnectionState=T.ConnectionState.Disconnected,this.privWebsocketClient=null,this.onEvent(new T.ConnectionClosedEvent(this.privConnectionId,e.code,e.reason))),this.onClose(e.code,e.reason).catch(t=>{T.Events.instance.onEvent(new T.BackgroundEvent(t))})},this.privWebsocketClient.onmessage=e=>{let t=new Date().toISOString();if(this.privConnectionState===T.ConnectionState.Connected){let r=new T.Deferred;if(this.privReceivingMessageQueue.enqueueFromPromise(r.promise),e.data instanceof ArrayBuffer){let n=new T.RawWebsocketMessage(T.MessageType.Binary,e.data);this.privMessageFormatter.toConnectionMessage(n).then(s=>{this.onEvent(new T.ConnectionMessageReceivedEvent(this.privConnectionId,t,s)),r.resolve(s)},s=>{r.reject(`Invalid binary message format. Error: ${s}`)})}else{let n=new T.RawWebsocketMessage(T.MessageType.Text,e.data);this.privMessageFormatter.toConnectionMessage(n).then(s=>{this.onEvent(new T.ConnectionMessageReceivedEvent(this.privConnectionId,t,s)),r.resolve(s)},s=>{r.reject(`Invalid text message format. Error: ${s}`)})}}},this.privConnectionEstablishDeferral.promise}send(e){if(this.privConnectionState!==T.ConnectionState.Connected)return Promise.reject(`Cannot send on connection that is in ${T.ConnectionState[this.privConnectionState]} state`);let t=new T.Deferred,r=new T.Deferred;return this.privSendMessageQueue.enqueueFromPromise(r.promise),this.privMessageFormatter.fromConnectionMessage(e).then(n=>{r.resolve({Message:e,RawWebsocketMessage:n,sendStatusDeferral:t})},n=>{r.reject(`Error formatting the message. ${n}`)}),t.promise}read(){return this.privConnectionState!==T.ConnectionState.Connected?Promise.reject(`Cannot read on connection that is in ${this.privConnectionState} state`):this.privReceivingMessageQueue.dequeue()}close(e){if(this.privWebsocketClient)this.privConnectionState!==T.ConnectionState.Disconnected&&this.privWebsocketClient.close(1e3,e||"Normal closure by client");else return Promise.resolve();return this.privDisconnectDeferral.promise}get events(){return this.privConnectionEvents}sendRawMessage(e){try{if(!e)return Promise.resolve();if(this.onEvent(new T.ConnectionMessageSentEvent(this.privConnectionId,new Date().toISOString(),e.Message)),this.isWebsocketOpen)this.privWebsocketClient.send(e.RawWebsocketMessage.payload);else return Promise.reject("websocket send error: Websocket not ready "+this.privConnectionId+" "+e.Message.id+" "+new Error().stack);return Promise.resolve()}catch(t){return Promise.reject(`websocket send error: ${t}`)}}async onClose(e,t){let r=`Connection closed. ${e}: ${t}`;this.privConnectionState=T.ConnectionState.Disconnected,this.privDisconnectDeferral.resolve(),await this.privReceivingMessageQueue.drainAndDispose(()=>{},r),await this.privSendMessageQueue.drainAndDispose(n=>{n.sendStatusDeferral.reject(r)},r)}async processSendQueue(){for(;;){let t=await this.privSendMessageQueue.dequeue();if(!t)return;try{await this.sendRawMessage(t),t.sendStatusDeferral.resolve()}catch(r){t.sendStatusDeferral.reject(r)}}}onEvent(e){this.privConnectionEvents.onEvent(e),T.Events.instance.onEvent(e)}getAgent(){let e=new ZI.default.Agent(this.createConnection);return this.proxyInfo!==void 0&&this.proxyInfo.HostName!==void 0&&this.proxyInfo.Port>0&&(e.proxyInfo=this.proxyInfo),e}static GetProxyAgent(e){let t={host:e.HostName,port:e.Port};return e.UserName?t.headers={"Proxy-Authentication":"Basic "+new Buffer(`${e.UserName}:${e.Password===void 0?"":e.Password}`).toString("base64")}:t.headers={},t.headers.requestOCSP="true",new ew.default(t)}createConnection(e,t){let r;if(t={...t,requestOCSP:!0,servername:t.host},this.proxyInfo){let s=i.GetProxyAgent(this.proxyInfo);r=new Promise((o,a)=>{s.callback(e,t,(c,u)=>{c?a(c):o(u)})})}else t.secureEndpoint?r=Promise.resolve(XI.connect(t)):r=Promise.resolve(YI.connect(t));return r}get isWebsocketOpen(){return this.privWebsocketClient&&this.privWebsocketClient.readyState===this.privWebsocketClient.OPEN}};Ge.WebsocketMessageAdapter=Hs;Hs.forceNpmWebSocket=!1});var Gm=p(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.WebsocketConnection=void 0;var ah=P(),iw=oh(),ch=class{constructor(e,t,r,n,s,o=!1,a){if(this.privIsDisposed=!1,!e)throw new ah.ArgumentNullError("uri");if(!n)throw new ah.ArgumentNullError("messageFormatter");this.privMessageFormatter=n;let c="",u=0;if(t){for(let h in t)if(h){c+=u===0&&e.indexOf("?")===-1?"?":"&";let d=encodeURIComponent(h);c+=d;let v=t[h];v&&(v=encodeURIComponent(v),c+=`=${v}`),u++}}if(r){for(let h in r)if(h){c+=u===0&&e.indexOf("?")===-1?"?":"&";let d=encodeURIComponent(r[h]);c+=`${h}=${d}`,u++}}this.privUri=e+c,this.privId=a||ah.createNoDashGuid(),this.privConnectionMessageAdapter=new iw.WebsocketMessageAdapter(this.privUri,this.id,this.privMessageFormatter,s,r,o)}async dispose(){this.privIsDisposed=!0,this.privConnectionMessageAdapter&&await this.privConnectionMessageAdapter.close()}isDisposed(){return this.privIsDisposed}get id(){return this.privId}get uri(){return this.privUri}state(){return this.privConnectionMessageAdapter.state}open(){return this.privConnectionMessageAdapter.open()}send(e){return this.privConnectionMessageAdapter.send(e)}read(){return this.privConnectionMessageAdapter.read()}get events(){return this.privConnectionMessageAdapter.events}};Ks.WebsocketConnection=ch});var $m=p(Js=>{"use strict";Object.defineProperty(Js,"__esModule",{value:!0});Js.ReplayableAudioNode=void 0;var ph=class{constructor(e,t){this.privBuffers=[],this.privReplayOffset=0,this.privLastShrinkOffset=0,this.privBufferStartOffset=0,this.privBufferSerial=0,this.privBufferedBytes=0,this.privReplay=!1,this.privLastChunkAcquiredTime=0,this.privAudioNode=e,this.privBytesPerSecond=t}id(){return this.privAudioNode.id()}read(){if(this.privReplay&&this.privBuffers.length!==0){let e=this.privReplayOffset-this.privBufferStartOffset,t=Math.round(e*this.privBytesPerSecond*1e-7);t%2!==0&&t++;let r=0;for(;r<this.privBuffers.length&&t>=this.privBuffers[r].chunk.buffer.byteLength;)t-=this.privBuffers[r++].chunk.buffer.byteLength;if(r<this.privBuffers.length){let n=this.privBuffers[r].chunk.buffer.slice(t);return this.privReplayOffset+=n.byteLength/this.privBytesPerSecond*1e7,r===this.privBuffers.length-1&&(this.privReplay=!1),Promise.resolve({buffer:n,isEnd:!1,timeReceived:this.privBuffers[r].chunk.timeReceived})}}return this.privAudioNode.read().then(e=>(e&&e.buffer&&(this.privBuffers.push(new uh(e,this.privBufferSerial++,this.privBufferedBytes)),this.privBufferedBytes+=e.buffer.byteLength),e))}detach(){return this.privBuffers=void 0,this.privAudioNode.detach()}replay(){this.privBuffers&&this.privBuffers.length!==0&&(this.privReplay=!0,this.privReplayOffset=this.privLastShrinkOffset)}shrinkBuffers(e){if(this.privBuffers===void 0||this.privBuffers.length===0)return;this.privLastShrinkOffset=e;let t=e-this.privBufferStartOffset,r=Math.round(t*this.privBytesPerSecond*1e-7),n=0;for(;n<this.privBuffers.length&&r>=this.privBuffers[n].chunk.buffer.byteLength;)r-=this.privBuffers[n++].chunk.buffer.byteLength;this.privBufferStartOffset=Math.round(e-r/this.privBytesPerSecond*1e7),this.privBuffers=this.privBuffers.slice(n)}findTimeAtOffset(e){if(e<this.privBufferStartOffset||this.privBuffers===void 0)return 0;for(let t of this.privBuffers){let r=t.byteOffset/this.privBytesPerSecond*1e7,n=r+t.chunk.buffer.byteLength/this.privBytesPerSecond*1e7;if(e>=r&&e<=n)return t.chunk.timeReceived}return 0}};Js.ReplayableAudioNode=ph;var uh=class{constructor(e,t,r){this.chunk=e,this.serial=t,this.byteOffset=r}}});var lh=p(Et=>{"use strict";var nw=Et&&Et.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),sw=Et&&Et.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),ow=Et&&Et.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&nw(e,i,t);return sw(e,i),e};Object.defineProperty(Et,"__esModule",{value:!0});Et.AudioFileWriter=void 0;var on=ow(Zu()),hh=I(),dh=class{constructor(e){hh.Contracts.throwIfNullOrUndefined(on.openSync,`
18
+ File System access not available, please use Push or PullAudioOutputStream`),this.privFd=on.openSync(e,"w")}set format(e){hh.Contracts.throwIfNotUndefined(this.privAudioFormat,"format is already set"),this.privAudioFormat=e;let t=0;this.privAudioFormat.hasHeader&&(t=this.privAudioFormat.header.byteLength),this.privFd!==void 0&&(this.privWriteStream=on.createWriteStream("",{fd:this.privFd,start:t,autoClose:!1}))}write(e){hh.Contracts.throwIfNullOrUndefined(this.privAudioFormat,"must set format before writing."),this.privWriteStream!==void 0&&this.privWriteStream.write(new Uint8Array(e.slice(0)))}close(){this.privFd!==void 0&&(this.privWriteStream.on("finish",()=>{this.privAudioFormat.hasHeader&&(this.privAudioFormat.updateHeader(this.privWriteStream.bytesWritten),on.writeSync(this.privFd,new Int8Array(this.privAudioFormat.header),0,this.privAudioFormat.header.byteLength,0)),on.closeSync(this.privFd),this.privFd=void 0}),this.privWriteStream.end())}id(){return this.privId}};Et.AudioFileWriter=dh});var vh=p($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.PullAudioInputStreamImpl=$e.PullAudioInputStream=$e.PushAudioInputStreamImpl=$e.PushAudioInputStream=$e.AudioInputStream=void 0;var Gs=C(),fe=P(),Qm=tr(),aw=f(),cw=nr(),an=class{constructor(){}static createPushStream(e){return cn.create(e)}static createPullStream(e,t){return pn.create(e,t)}};$e.AudioInputStream=an;var cn=class extends an{static create(e){return new $s(e)}};$e.PushAudioInputStream=cn;var $s=class extends cn{constructor(e){super(),e===void 0?this.privFormat=cw.AudioStreamFormatImpl.getDefaultInputFormat():this.privFormat=e,this.privEvents=new fe.EventSource,this.privId=Qm.createNoDashGuid(),this.privStream=new fe.ChunkedArrayBufferStream(this.privFormat.avgBytesPerSec/10)}get format(){return Promise.resolve(this.privFormat)}write(e){this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}id(){return this.privId}turnOn(){this.onEvent(new fe.AudioSourceInitializingEvent(this.privId)),this.onEvent(new fe.AudioSourceReadyEvent(this.privId))}async attach(e){this.onEvent(new fe.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn();let t=this.privStream;return this.onEvent(new fe.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(this.onEvent(new fe.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}}detach(e){this.onEvent(new fe.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:Gs.connectivity.Unknown,manufacturer:"Speech SDK",model:"PushStream",samplerate:this.privFormat.samplesPerSec,type:Gs.type.Stream})}onEvent(e){this.privEvents.onEvent(e),fe.Events.instance.onEvent(e)}toBuffer(e){let t=Buffer.alloc(e.byteLength),r=new Uint8Array(e);for(let n=0;n<t.length;++n)t[n]=r[n];return t}};$e.PushAudioInputStreamImpl=$s;var pn=class extends an{constructor(){super()}static create(e,t){return new Qs(e,t)}};$e.PullAudioInputStream=pn;var Qs=class extends pn{constructor(e,t){super(),t===void 0?this.privFormat=aw.AudioStreamFormat.getDefaultInputFormat():this.privFormat=t,this.privEvents=new fe.EventSource,this.privId=Qm.createNoDashGuid(),this.privCallback=e,this.privIsClosed=!1,this.privBufferSize=this.privFormat.avgBytesPerSec/10}get format(){return Promise.resolve(this.privFormat)}close(){this.privIsClosed=!0,this.privCallback.close()}id(){return this.privId}turnOn(){this.onEvent(new fe.AudioSourceInitializingEvent(this.privId)),this.onEvent(new fe.AudioSourceReadyEvent(this.privId))}async attach(e){return this.onEvent(new fe.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn(),this.onEvent(new fe.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:()=>(this.privCallback.close(),this.onEvent(new fe.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>{let t=0,r;for(;t<this.privBufferSize;){let n=new ArrayBuffer(this.privBufferSize-t),s=this.privCallback.read(n);if(r===void 0?r=n:new Int8Array(r).set(new Int8Array(n),t),s===0)break;t+=s}return Promise.resolve({buffer:r.slice(0,t),isEnd:this.privIsClosed||t===0,timeReceived:Date.now()})}}}detach(e){this.onEvent(new fe.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:Gs.connectivity.Unknown,manufacturer:"Speech SDK",model:"PullStream",samplerate:this.privFormat.samplesPerSec,type:Gs.type.Stream})}onEvent(e){this.privEvents.onEvent(e),fe.Events.instance.onEvent(e)}};$e.PullAudioInputStreamImpl=Qs});var fh=p(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.SpeechSynthesisOutputFormat=void 0;var pw;(function(i){i[i.Raw8Khz8BitMonoMULaw=0]="Raw8Khz8BitMonoMULaw",i[i.Riff16Khz16KbpsMonoSiren=1]="Riff16Khz16KbpsMonoSiren",i[i.Audio16Khz16KbpsMonoSiren=2]="Audio16Khz16KbpsMonoSiren",i[i.Audio16Khz32KBitRateMonoMp3=3]="Audio16Khz32KBitRateMonoMp3",i[i.Audio16Khz128KBitRateMonoMp3=4]="Audio16Khz128KBitRateMonoMp3",i[i.Audio16Khz64KBitRateMonoMp3=5]="Audio16Khz64KBitRateMonoMp3",i[i.Audio24Khz48KBitRateMonoMp3=6]="Audio24Khz48KBitRateMonoMp3",i[i.Audio24Khz96KBitRateMonoMp3=7]="Audio24Khz96KBitRateMonoMp3",i[i.Audio24Khz160KBitRateMonoMp3=8]="Audio24Khz160KBitRateMonoMp3",i[i.Raw16Khz16BitMonoTrueSilk=9]="Raw16Khz16BitMonoTrueSilk",i[i.Riff16Khz16BitMonoPcm=10]="Riff16Khz16BitMonoPcm",i[i.Riff8Khz16BitMonoPcm=11]="Riff8Khz16BitMonoPcm",i[i.Riff24Khz16BitMonoPcm=12]="Riff24Khz16BitMonoPcm",i[i.Riff8Khz8BitMonoMULaw=13]="Riff8Khz8BitMonoMULaw",i[i.Raw16Khz16BitMonoPcm=14]="Raw16Khz16BitMonoPcm",i[i.Raw24Khz16BitMonoPcm=15]="Raw24Khz16BitMonoPcm",i[i.Raw8Khz16BitMonoPcm=16]="Raw8Khz16BitMonoPcm",i[i.Ogg16Khz16BitMonoOpus=17]="Ogg16Khz16BitMonoOpus",i[i.Ogg24Khz16BitMonoOpus=18]="Ogg24Khz16BitMonoOpus",i[i.Raw48Khz16BitMonoPcm=19]="Raw48Khz16BitMonoPcm",i[i.Riff48Khz16BitMonoPcm=20]="Riff48Khz16BitMonoPcm",i[i.Audio48Khz96KBitRateMonoMp3=21]="Audio48Khz96KBitRateMonoMp3",i[i.Audio48Khz192KBitRateMonoMp3=22]="Audio48Khz192KBitRateMonoMp3",i[i.Ogg48Khz16BitMonoOpus=23]="Ogg48Khz16BitMonoOpus",i[i.Webm16Khz16BitMonoOpus=24]="Webm16Khz16BitMonoOpus",i[i.Webm24Khz16BitMonoOpus=25]="Webm24Khz16BitMonoOpus",i[i.Raw24Khz16BitMonoTrueSilk=26]="Raw24Khz16BitMonoTrueSilk",i[i.Raw8Khz8BitMonoALaw=27]="Raw8Khz8BitMonoALaw",i[i.Riff8Khz8BitMonoALaw=28]="Riff8Khz8BitMonoALaw",i[i.Webm24Khz16Bit24KbpsMonoOpus=29]="Webm24Khz16Bit24KbpsMonoOpus",i[i.Audio16Khz16Bit32KbpsMonoOpus=30]="Audio16Khz16Bit32KbpsMonoOpus",i[i.Audio24Khz16Bit48KbpsMonoOpus=31]="Audio24Khz16Bit48KbpsMonoOpus",i[i.Audio24Khz16Bit24KbpsMonoOpus=32]="Audio24Khz16Bit24KbpsMonoOpus",i[i.Raw22050Hz16BitMonoPcm=33]="Raw22050Hz16BitMonoPcm",i[i.Riff22050Hz16BitMonoPcm=34]="Riff22050Hz16BitMonoPcm",i[i.Raw44100Hz16BitMonoPcm=35]="Raw44100Hz16BitMonoPcm",i[i.Riff44100Hz16BitMonoPcm=36]="Riff44100Hz16BitMonoPcm"})(pw=un.SpeechSynthesisOutputFormat||(un.SpeechSynthesisOutputFormat={}))});var ui=p(Xs=>{"use strict";Object.defineProperty(Xs,"__esModule",{value:!0});Xs.AudioOutputFormatImpl=void 0;var O=fh(),A=nr(),Ys=class i extends A.AudioStreamFormatImpl{constructor(e,t,r,n,s,o,a,c,u){super(r,o,t,e),this.formatTag=e,this.avgBytesPerSec=n,this.blockAlign=s,this.priAudioFormatString=a,this.priRequestAudioFormatString=c,this.priHasHeader=u}static fromSpeechSynthesisOutputFormat(e){return e===void 0?i.getDefaultOutputFormat():i.fromSpeechSynthesisOutputFormatString(i.SpeechSynthesisOutputFormatToString[e])}static fromSpeechSynthesisOutputFormatString(e){switch(e){case"raw-8khz-8bit-mono-mulaw":return new i(A.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,e,!1);case"riff-16khz-16kbps-mono-siren":return new i(A.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,"audio-16khz-16kbps-mono-siren",!0);case"audio-16khz-16kbps-mono-siren":return new i(A.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,e,!1);case"audio-16khz-32kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,16e3,4096,2,16,e,e,!1);case"audio-16khz-128kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,16e3,16384,2,16,e,e,!1);case"audio-16khz-64kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,16e3,8192,2,16,e,e,!1);case"audio-24khz-48kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,24e3,6144,2,16,e,e,!1);case"audio-24khz-96kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,24e3,12288,2,16,e,e,!1);case"audio-24khz-160kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,24e3,20480,2,16,e,e,!1);case"raw-16khz-16bit-mono-truesilk":return new i(A.AudioFormatTag.SILKSkype,1,16e3,32e3,2,16,e,e,!1);case"riff-8khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!0);case"riff-24khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!0);case"riff-8khz-8bit-mono-mulaw":return new i(A.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-mulaw",!0);case"raw-16khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,16e3,32e3,2,16,e,"raw-16khz-16bit-mono-pcm",!1);case"raw-24khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!1);case"raw-8khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!1);case"ogg-16khz-16bit-mono-opus":return new i(A.AudioFormatTag.OGG_OPUS,1,16e3,8192,2,16,e,e,!1);case"ogg-24khz-16bit-mono-opus":return new i(A.AudioFormatTag.OGG_OPUS,1,24e3,8192,2,16,e,e,!1);case"raw-48khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!1);case"riff-48khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!0);case"audio-48khz-96kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,48e3,12288,2,16,e,e,!1);case"audio-48khz-192kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,48e3,24576,2,16,e,e,!1);case"ogg-48khz-16bit-mono-opus":return new i(A.AudioFormatTag.OGG_OPUS,1,48e3,12e3,2,16,e,e,!1);case"webm-16khz-16bit-mono-opus":return new i(A.AudioFormatTag.WEBM_OPUS,1,16e3,4e3,2,16,e,e,!1);case"webm-24khz-16bit-mono-opus":return new i(A.AudioFormatTag.WEBM_OPUS,1,24e3,6e3,2,16,e,e,!1);case"webm-24khz-16bit-24kbps-mono-opus":return new i(A.AudioFormatTag.WEBM_OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-16khz-16bit-32kbps-mono-opus":return new i(A.AudioFormatTag.OPUS,1,16e3,4e3,2,16,e,e,!1);case"audio-24khz-16bit-48kbps-mono-opus":return new i(A.AudioFormatTag.OPUS,1,24e3,6e3,2,16,e,e,!1);case"audio-24khz-16bit-24kbps-mono-opus":return new i(A.AudioFormatTag.OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-24khz-16bit-mono-flac":return new i(A.AudioFormatTag.FLAC,1,24e3,24e3,2,16,e,e,!1);case"audio-48khz-16bit-mono-flac":return new i(A.AudioFormatTag.FLAC,1,48e3,3e4,2,16,e,e,!1);case"raw-24khz-16bit-mono-truesilk":return new i(A.AudioFormatTag.SILKSkype,1,24e3,48e3,2,16,e,e,!1);case"raw-8khz-8bit-mono-alaw":return new i(A.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,e,!1);case"riff-8khz-8bit-mono-alaw":return new i(A.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-alaw",!0);case"raw-22050hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,22050,44100,2,16,e,e,!1);case"riff-22050hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,22050,44100,2,16,e,"raw-22050hz-16bit-mono-pcm",!0);case"raw-44100hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,44100,88200,2,16,e,e,!1);case"riff-44100hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,44100,88200,2,16,e,"raw-44100hz-16bit-mono-pcm",!0);case"riff-16khz-16bit-mono-pcm":default:return new i(A.AudioFormatTag.PCM,1,16e3,32e3,2,16,"riff-16khz-16bit-mono-pcm","raw-16khz-16bit-mono-pcm",!0)}}static getDefaultOutputFormat(){return i.fromSpeechSynthesisOutputFormatString(typeof window<"u"?"audio-24khz-48kbitrate-mono-mp3":"riff-16khz-16bit-mono-pcm")}get hasHeader(){return this.priHasHeader}get header(){if(this.hasHeader)return this.privHeader}updateHeader(e){if(this.priHasHeader){let t=new DataView(this.privHeader);t.setUint32(4,e+this.privHeader.byteLength-8,!0),t.setUint32(40,e,!0)}}get requestAudioFormatString(){return this.priRequestAudioFormatString}addHeader(e){if(!this.hasHeader)return e;this.updateHeader(e.byteLength);let t=new Uint8Array(e.byteLength+this.header.byteLength);return t.set(new Uint8Array(this.header),0),t.set(new Uint8Array(e),this.header.byteLength),t.buffer}};Xs.AudioOutputFormatImpl=Ys;Ys.SpeechSynthesisOutputFormatToString={[O.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]:"raw-8khz-8bit-mono-mulaw",[O.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]:"riff-16khz-16kbps-mono-siren",[O.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]:"audio-16khz-16kbps-mono-siren",[O.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]:"audio-16khz-32kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]:"audio-16khz-128kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]:"audio-16khz-64kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]:"audio-24khz-48kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]:"audio-24khz-96kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]:"audio-24khz-160kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]:"raw-16khz-16bit-mono-truesilk",[O.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]:"riff-16khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]:"riff-8khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]:"riff-24khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]:"riff-8khz-8bit-mono-mulaw",[O.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]:"raw-16khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]:"raw-24khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]:"raw-8khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus]:"ogg-16khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus]:"ogg-24khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm]:"raw-48khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm]:"riff-48khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3]:"audio-48khz-96kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3]:"audio-48khz-192kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus]:"ogg-48khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus]:"webm-16khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus]:"webm-24khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus]:"webm-24khz-16bit-24kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk]:"raw-24khz-16bit-mono-truesilk",[O.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw]:"raw-8khz-8bit-mono-alaw",[O.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw]:"riff-8khz-8bit-mono-alaw",[O.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus]:"audio-16khz-16bit-32kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus]:"audio-24khz-16bit-48kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus]:"audio-24khz-16bit-24kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm]:"raw-22050hz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]:"riff-22050hz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]:"raw-44100hz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]:"riff-44100hz-16bit-mono-pcm"}});var br=p(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.PushAudioOutputStreamImpl=Qe.PushAudioOutputStream=Qe.PullAudioOutputStreamImpl=Qe.PullAudioOutputStream=Qe.AudioOutputStream=void 0;var gh=P(),uw=I(),hw=ui(),hn=class{constructor(){}static createPullStream(){return dn.create()}};Qe.AudioOutputStream=hn;var dn=class extends hn{static create(){return new Zs}};Qe.PullAudioOutputStream=dn;var Zs=class extends dn{constructor(){super(),this.privId=gh.createNoDashGuid(),this.privStream=new gh.Stream}set format(e){e==null&&(this.privFormat=hw.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privFormat=e}get format(){return this.privFormat}get isClosed(){return this.privStream.isClosed}id(){return this.privId}async read(e){let t=new Int8Array(e),r=0;if(this.privLastChunkView!==void 0){if(this.privLastChunkView.length>e.byteLength)return t.set(this.privLastChunkView.slice(0,e.byteLength)),this.privLastChunkView=this.privLastChunkView.slice(e.byteLength),Promise.resolve(e.byteLength);t.set(this.privLastChunkView),r=this.privLastChunkView.length,this.privLastChunkView=void 0}for(;r<e.byteLength&&!this.privStream.isReadEnded;){let n=await this.privStream.read();if(n!==void 0&&!n.isEnd){let s;n.buffer.byteLength>e.byteLength-r?(s=n.buffer.slice(0,e.byteLength-r),this.privLastChunkView=new Int8Array(n.buffer.slice(e.byteLength-r))):s=n.buffer,t.set(new Int8Array(s),r),r+=s.byteLength}else this.privStream.readEnded()}return r}write(e){uw.Contracts.throwIfNullOrUndefined(this.privStream,"must set format before writing"),this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}};Qe.PullAudioOutputStreamImpl=Zs;var eo=class extends hn{constructor(){super()}static create(e){return new to(e)}};Qe.PushAudioOutputStream=eo;var to=class extends eo{constructor(e){super(),this.privId=gh.createNoDashGuid(),this.privCallback=e}set format(e){}write(e){this.privCallback.write&&this.privCallback.write(e)}close(){this.privCallback.close&&this.privCallback.close()}id(){return this.privId}};Qe.PushAudioOutputStreamImpl=to});var mh=p(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.AudioOutputConfigImpl=sr.AudioConfigImpl=sr.AudioConfig=void 0;var Or=pe(),dw=I(),Mr=f(),lw=lh(),vw=vh(),fw=br(),ln=class i{static fromDefaultMicrophoneInput(){let e=new Or.PcmRecorder(!0);return new Lt(new Or.MicAudioSource(e))}static fromMicrophoneInput(e){let t=new Or.PcmRecorder(!0);return new Lt(new Or.MicAudioSource(t,e))}static fromWavFileInput(e,t="unnamedBuffer.wav"){return new Lt(new Or.FileAudioSource(e,t))}static fromStreamInput(e){if(e instanceof Mr.PullAudioInputStreamCallback)return new Lt(new vw.PullAudioInputStreamImpl(e));if(e instanceof Mr.AudioInputStream)return new Lt(e);if(typeof MediaStream<"u"&&e instanceof MediaStream){let t=new Or.PcmRecorder(!1);return new Lt(new Or.MicAudioSource(t,null,null,e))}throw new Error("Not Supported Type")}static fromDefaultSpeakerOutput(){return new Bt(new Mr.SpeakerAudioDestination)}static fromSpeakerOutput(e){if(e===void 0)return i.fromDefaultSpeakerOutput();if(e instanceof Mr.SpeakerAudioDestination)return new Bt(e);throw new Error("Not Supported Type")}static fromAudioFileOutput(e){return new Bt(new lw.AudioFileWriter(e))}static fromStreamOutput(e){if(e instanceof Mr.PushAudioOutputStreamCallback)return new Bt(new fw.PushAudioOutputStreamImpl(e));if(e instanceof Mr.PushAudioOutputStream)return new Bt(e);if(e instanceof Mr.PullAudioOutputStream)return new Bt(e);throw new Error("Not Supported Type")}};sr.AudioConfig=ln;var Lt=class extends ln{constructor(e){super(),this.privSource=e}get format(){return this.privSource.format}close(e,t){this.privSource.turnOff().then(()=>{e&&e()},r=>{t&&t(r)})}id(){return this.privSource.id()}turnOn(){return this.privSource.turnOn()}attach(e){return this.privSource.attach(e)}detach(e){return this.privSource.detach(e)}turnOff(){return this.privSource.turnOff()}get events(){return this.privSource.events}setProperty(e,t){if(dw.Contracts.throwIfNull(t,"value"),this.privSource.setProperty!==void 0)this.privSource.setProperty(e,t);else throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(e,t){if(this.privSource.getProperty!==void 0)return this.privSource.getProperty(e,t);throw new Error("This AudioConfig instance does not support getting properties.")}get deviceInfo(){return this.privSource.deviceInfo}};sr.AudioConfigImpl=Lt;var Bt=class extends ln{constructor(e){super(),this.privDestination=e}set format(e){this.privDestination.format=e}write(e){this.privDestination.write(e)}close(){this.privDestination.close()}id(){return this.privDestination.id()}setProperty(){throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(){throw new Error("This AudioConfig instance does not support getting properties.")}};sr.AudioOutputConfigImpl=Bt});var Ym=p(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.CancellationReason=void 0;var gw;(function(i){i[i.Error=0]="Error",i[i.EndOfStream=1]="EndOfStream"})(gw=vn.CancellationReason||(vn.CancellationReason={}))});var Xm=p(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.PullAudioInputStreamCallback=void 0;var Sh=class{};ro.PullAudioInputStreamCallback=Sh});var Zm=p(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.PushAudioOutputStreamCallback=void 0;var yh=class{};io.PushAudioOutputStreamCallback=yh});var tS=p(no=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});no.KeywordRecognitionModel=void 0;var eS=I(),Ch=class{constructor(){this.privDisposed=!1}static fromFile(e){throw eS.Contracts.throwIfFileDoesNotExist(e,"fileName"),new Error("Not yet implemented.")}static fromStream(e){throw eS.Contracts.throwIfNull(e,"file"),new Error("Not yet implemented.")}close(){this.privDisposed||(this.privDisposed=!0)}};no.KeywordRecognitionModel=Ch});var rS=p(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.SessionEventArgs=void 0;var Ph=class{constructor(e){this.privSessionId=e}get sessionId(){return this.privSessionId}};so.SessionEventArgs=Ph});var iS=p(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.RecognitionEventArgs=void 0;var mw=f(),Rh=class extends mw.SessionEventArgs{constructor(e,t){super(t),this.privOffset=e}get offset(){return this.privOffset}};oo.RecognitionEventArgs=Rh});var nS=p(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.OutputFormat=void 0;var Sw;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(Sw=fn.OutputFormat||(fn.OutputFormat={}))});var sS=p(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.IntentRecognitionEventArgs=void 0;var yw=f(),Eh=class extends yw.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};ao.IntentRecognitionEventArgs=Eh});var oS=p(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.RecognitionResult=void 0;var Ih=class{constructor(e,t,r,n,s,o,a,c,u,h){this.privResultId=e,this.privReason=t,this.privText=r,this.privDuration=n,this.privOffset=s,this.privLanguage=o,this.privLanguageDetectionConfidence=a,this.privErrorDetails=c,this.privJson=u,this.privProperties=h}get resultId(){return this.privResultId}get reason(){return this.privReason}get text(){return this.privText}get duration(){return this.privDuration}get offset(){return this.privOffset}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}get errorDetails(){return this.privErrorDetails}get json(){return this.privJson}get properties(){return this.privProperties}};co.RecognitionResult=Ih});var aS=p(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.SpeechRecognitionResult=void 0;var Cw=f(),wh=class extends Cw.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(e,t,r,n,s,o,a,u,h,d),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};po.SpeechRecognitionResult=wh});var cS=p(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.IntentRecognitionResult=void 0;var Pw=f(),_h=class extends Pw.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(t,r,n,s,o,a,c,void 0,u,h,d),this.privIntentId=e}get intentId(){return this.privIntentId}};uo.IntentRecognitionResult=_h});var pS=p(li=>{"use strict";Object.defineProperty(li,"__esModule",{value:!0});li.LanguageUnderstandingModelImpl=li.LanguageUnderstandingModel=void 0;var hi=I(),ho=class{constructor(){}static fromEndpoint(e){hi.Contracts.throwIfNull(e,"uri"),hi.Contracts.throwIfNullOrWhitespace(e.hostname,"uri");let t=new di,r=e.host.indexOf(".");if(r===-1)throw new Error("Could not determine region from endpoint");t.region=e.host.substr(0,r);let n=e.pathname.lastIndexOf("/")+1;if(n===-1)throw new Error("Could not determine appId from endpoint");if(t.appId=e.pathname.substr(n),t.subscriptionKey=e.searchParams.get("subscription-key"),t.subscriptionKey===void 0)throw new Error("Could not determine subscription key from endpoint");return t}static fromAppId(e){hi.Contracts.throwIfNullOrWhitespace(e,"appId");let t=new di;return t.appId=e,t}static fromSubscription(e,t,r){hi.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),hi.Contracts.throwIfNullOrWhitespace(t,"appId"),hi.Contracts.throwIfNullOrWhitespace(r,"region");let n=new di;return n.appId=t,n.region=r,n.subscriptionKey=e,n}};li.LanguageUnderstandingModel=ho;var di=class extends ho{};li.LanguageUnderstandingModelImpl=di});var hS=p(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.MeetingTranscriptionEventArgs=or.ConversationTranscriptionEventArgs=or.SpeechRecognitionEventArgs=void 0;var uS=f(),lo=class extends uS.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};or.SpeechRecognitionEventArgs=lo;var Th=class extends uS.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};or.ConversationTranscriptionEventArgs=Th;var Ah=class extends lo{};or.MeetingTranscriptionEventArgs=Ah});var vi=p(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.CancellationEventArgsBase=void 0;var Rw=f(),bh=class extends Rw.RecognitionEventArgs{constructor(e,t,r,n,s){super(n,s),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};vo.CancellationEventArgsBase=bh});var dS=p(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.SpeechRecognitionCanceledEventArgs=void 0;var Ew=vi(),Oh=class extends Ew.CancellationEventArgsBase{};fo.SpeechRecognitionCanceledEventArgs=Oh});var lS=p(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.TranslationRecognitionEventArgs=void 0;var Iw=f(),Mh=class extends Iw.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};go.TranslationRecognitionEventArgs=Mh});var vS=p(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.TranslationSynthesisEventArgs=void 0;var ww=f(),Dh=class extends ww.SessionEventArgs{constructor(e,t){super(t),this.privResult=e}get result(){return this.privResult}};mo.TranslationSynthesisEventArgs=Dh});var Nh=p(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.TranslationRecognitionResult=void 0;var _w=f(),kh=class i extends _w.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(t,r,n,s,o,a,c,void 0,u,h,d),this.privTranslations=e}static fromSpeechRecognitionResult(e){return new i(void 0,e.resultId,e.reason,e.text,e.duration,e.offset,e.language,e.languageDetectionConfidence,e.errorDetails,e.json,e.properties)}get translations(){return this.privTranslations}};So.TranslationRecognitionResult=kh});var fS=p(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.TranslationSynthesisResult=void 0;var qh=class{constructor(e,t){this.privReason=e,this.privAudio=t}get audio(){return this.privAudio}get reason(){return this.privReason}};yo.TranslationSynthesisResult=qh});var gS=p(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.ResultReason=void 0;var Tw;(function(i){i[i.NoMatch=0]="NoMatch",i[i.Canceled=1]="Canceled",i[i.RecognizingSpeech=2]="RecognizingSpeech",i[i.RecognizedSpeech=3]="RecognizedSpeech",i[i.RecognizedKeyword=4]="RecognizedKeyword",i[i.RecognizingIntent=5]="RecognizingIntent",i[i.RecognizedIntent=6]="RecognizedIntent",i[i.TranslatingSpeech=7]="TranslatingSpeech",i[i.TranslatedSpeech=8]="TranslatedSpeech",i[i.SynthesizingAudio=9]="SynthesizingAudio",i[i.SynthesizingAudioCompleted=10]="SynthesizingAudioCompleted",i[i.SynthesizingAudioStarted=11]="SynthesizingAudioStarted",i[i.EnrollingVoiceProfile=12]="EnrollingVoiceProfile",i[i.EnrolledVoiceProfile=13]="EnrolledVoiceProfile",i[i.RecognizedSpeakers=14]="RecognizedSpeakers",i[i.RecognizedSpeaker=15]="RecognizedSpeaker",i[i.ResetVoiceProfile=16]="ResetVoiceProfile",i[i.DeletedVoiceProfile=17]="DeletedVoiceProfile",i[i.VoicesListRetrieved=18]="VoicesListRetrieved",i[i.TranslatingParticipantSpeech=19]="TranslatingParticipantSpeech",i[i.TranslatedParticipantSpeech=20]="TranslatedParticipantSpeech",i[i.TranslatedInstantMessage=21]="TranslatedInstantMessage",i[i.TranslatedParticipantInstantMessage=22]="TranslatedParticipantInstantMessage"})(Tw=gn.ResultReason||(gn.ResultReason={}))});var mS=p(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.SpeechConfigImpl=fi.SpeechConfig=void 0;var mn=C(),Dr=I(),_=f(),Co=class{constructor(){}static fromSubscription(e,t){Dr.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),Dr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new kr;return r.setProperty(_.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(_.PropertyId.SpeechServiceConnection_IntentRegion,t),r.setProperty(_.PropertyId.SpeechServiceConnection_Key,e),r}static fromEndpoint(e,t){Dr.Contracts.throwIfNull(e,"endpoint");let r=new kr;return r.setProperty(_.PropertyId.SpeechServiceConnection_Endpoint,e.href),t!==void 0&&r.setProperty(_.PropertyId.SpeechServiceConnection_Key,t),r}static fromHost(e,t){Dr.Contracts.throwIfNull(e,"hostName");let r=new kr;return r.setProperty(_.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(_.PropertyId.SpeechServiceConnection_Key,t),r}static fromAuthorizationToken(e,t){Dr.Contracts.throwIfNull(e,"authorizationToken"),Dr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new kr;return r.setProperty(_.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(_.PropertyId.SpeechServiceConnection_IntentRegion,t),r.authorizationToken=e,r}close(){}};fi.SpeechConfig=Co;var kr=class i extends Co{constructor(){super(),this.privProperties=new _.PropertyCollection,this.speechRecognitionLanguage="en-US",this.outputFormat=_.OutputFormat.Simple}get properties(){return this.privProperties}get endPoint(){return new URL(this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_Endpoint))}get subscriptionKey(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_Key)}get region(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_Region)}get authorizationToken(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_RecoLanguage)}set speechRecognitionLanguage(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get autoDetectSourceLanguages(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)}set autoDetectSourceLanguages(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e)}get outputFormat(){return _.OutputFormat[this.privProperties.getProperty(mn.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privProperties.setProperty(mn.OutputFormatPropertyName,_.OutputFormat[e])}get endpointId(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_EndpointId,e)}setProperty(e,t){Dr.Contracts.throwIfNull(t,"value"),this.privProperties.setProperty(e,t)}getProperty(e,t){return this.privProperties.getProperty(e,t)}setProxy(e,t,r,n){this.setProperty(_.PropertyId[_.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(_.PropertyId[_.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(_.PropertyId[_.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(_.PropertyId[_.PropertyId.SpeechServiceConnection_ProxyPassword],n)}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(mn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(mn.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceResponse_ProfanityOption,_.ProfanityOption[e])}enableAudioLogging(){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privProperties.setProperty(_.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privProperties.setProperty(mn.ForceDictationPropertyName,"true")}clone(){let e=new i;return e.privProperties=this.privProperties.clone(),e}get speechSynthesisLanguage(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return _.SpeechSynthesisOutputFormat[this.privProperties.getProperty(_.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privProperties.setProperty(_.PropertyId.SpeechServiceConnection_SynthOutputFormat,_.SpeechSynthesisOutputFormat[e])}};fi.SpeechConfigImpl=kr});var SS=p(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.SpeechTranslationConfigImpl=gi.SpeechTranslationConfig=void 0;var Sn=C(),dt=I(),E=f(),Po=class extends E.SpeechConfig{constructor(){super()}static fromSubscription(e,t){dt.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),dt.Contracts.throwIfNullOrWhitespace(t,"region");let r=new Nr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromAuthorizationToken(e,t){dt.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),dt.Contracts.throwIfNullOrWhitespace(t,"region");let r=new Nr;return r.properties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromHost(e,t){dt.Contracts.throwIfNull(e,"hostName");let r=new Nr;return r.setProperty(E.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}static fromEndpoint(e,t){dt.Contracts.throwIfNull(e,"endpoint"),dt.Contracts.throwIfNull(t,"subscriptionKey");let r=new Nr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Endpoint,e.href),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}};gi.SpeechTranslationConfig=Po;var Nr=class extends Po{constructor(){super(),this.privSpeechProperties=new E.PropertyCollection,this.outputFormat=E.OutputFormat.Simple}set authorizationToken(e){dt.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e)}set speechRecognitionLanguage(e){dt.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get speechRecognitionLanguage(){return this.privSpeechProperties.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_RecoLanguage])}get subscriptionKey(){return this.privSpeechProperties.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_Key])}get outputFormat(){return E.OutputFormat[this.privSpeechProperties.getProperty(Sn.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privSpeechProperties.setProperty(Sn.OutputFormatPropertyName,E.OutputFormat[e])}get endpointId(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_EndpointId,e)}addTargetLanguage(e){dt.Contracts.throwIfNullOrWhitespace(e,"value");let t=this.targetLanguages;t.includes(e)||(t.push(e),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))}get targetLanguages(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","):[]}get voiceName(){return this.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_TranslationVoice])}set voiceName(e){dt.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_TranslationVoice,e)}get region(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_Region)}setProxy(e,t,r,n){this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyPassword],n)}getProperty(e,t){return this.privSpeechProperties.getProperty(e,t)}setProperty(e,t){this.privSpeechProperties.setProperty(e,t)}get properties(){return this.privSpeechProperties}close(){}setServiceProperty(e,t){let r=JSON.parse(this.privSpeechProperties.getProperty(Sn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privSpeechProperties.setProperty(Sn.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceResponse_ProfanityOption,E.ProfanityOption[e])}enableAudioLogging(){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privSpeechProperties.setProperty(Sn.ForceDictationPropertyName,"true")}get speechSynthesisLanguage(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return E.SpeechSynthesisOutputFormat[this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthOutputFormat,E.SpeechSynthesisOutputFormat[e])}};gi.SpeechTranslationConfigImpl=Nr});var zh=p(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});Ro.PropertyCollection=void 0;var yS=f(),xh=class i{constructor(){this.privKeys=[],this.privValues=[]}getProperty(e,t){let r;typeof e=="string"?r=e:r=yS.PropertyId[e];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r)return this.privValues[n];if(t!==void 0)return String(t)}setProperty(e,t){let r;typeof e=="string"?r=e:r=yS.PropertyId[e];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r){this.privValues[n]=t;return}this.privKeys.push(r),this.privValues.push(t)}clone(){let e=new i;for(let t=0;t<this.privKeys.length;t++)e.privKeys.push(this.privKeys[t]),e.privValues.push(this.privValues[t]);return e}mergeTo(e){this.privKeys.forEach(t=>{if(e.getProperty(t,void 0)===void 0){let r=this.getProperty(t);e.setProperty(t,r)}})}get keys(){return this.privKeys}};Ro.PropertyCollection=xh});var Eo=p(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.PropertyId=void 0;var Aw;(function(i){i[i.SpeechServiceConnection_Key=0]="SpeechServiceConnection_Key",i[i.SpeechServiceConnection_Endpoint=1]="SpeechServiceConnection_Endpoint",i[i.SpeechServiceConnection_Region=2]="SpeechServiceConnection_Region",i[i.SpeechServiceAuthorization_Token=3]="SpeechServiceAuthorization_Token",i[i.SpeechServiceAuthorization_Type=4]="SpeechServiceAuthorization_Type",i[i.SpeechServiceConnection_EndpointId=5]="SpeechServiceConnection_EndpointId",i[i.SpeechServiceConnection_TranslationToLanguages=6]="SpeechServiceConnection_TranslationToLanguages",i[i.SpeechServiceConnection_TranslationVoice=7]="SpeechServiceConnection_TranslationVoice",i[i.SpeechServiceConnection_TranslationFeatures=8]="SpeechServiceConnection_TranslationFeatures",i[i.SpeechServiceConnection_IntentRegion=9]="SpeechServiceConnection_IntentRegion",i[i.SpeechServiceConnection_ProxyHostName=10]="SpeechServiceConnection_ProxyHostName",i[i.SpeechServiceConnection_ProxyPort=11]="SpeechServiceConnection_ProxyPort",i[i.SpeechServiceConnection_ProxyUserName=12]="SpeechServiceConnection_ProxyUserName",i[i.SpeechServiceConnection_ProxyPassword=13]="SpeechServiceConnection_ProxyPassword",i[i.SpeechServiceConnection_RecoMode=14]="SpeechServiceConnection_RecoMode",i[i.SpeechServiceConnection_RecoLanguage=15]="SpeechServiceConnection_RecoLanguage",i[i.Speech_SessionId=16]="Speech_SessionId",i[i.SpeechServiceConnection_SynthLanguage=17]="SpeechServiceConnection_SynthLanguage",i[i.SpeechServiceConnection_SynthVoice=18]="SpeechServiceConnection_SynthVoice",i[i.SpeechServiceConnection_SynthOutputFormat=19]="SpeechServiceConnection_SynthOutputFormat",i[i.SpeechServiceConnection_AutoDetectSourceLanguages=20]="SpeechServiceConnection_AutoDetectSourceLanguages",i[i.SpeechServiceResponse_RequestDetailedResultTrueFalse=21]="SpeechServiceResponse_RequestDetailedResultTrueFalse",i[i.SpeechServiceResponse_RequestProfanityFilterTrueFalse=22]="SpeechServiceResponse_RequestProfanityFilterTrueFalse",i[i.SpeechServiceResponse_JsonResult=23]="SpeechServiceResponse_JsonResult",i[i.SpeechServiceResponse_JsonErrorDetails=24]="SpeechServiceResponse_JsonErrorDetails",i[i.CancellationDetails_Reason=25]="CancellationDetails_Reason",i[i.CancellationDetails_ReasonText=26]="CancellationDetails_ReasonText",i[i.CancellationDetails_ReasonDetailedText=27]="CancellationDetails_ReasonDetailedText",i[i.LanguageUnderstandingServiceResponse_JsonResult=28]="LanguageUnderstandingServiceResponse_JsonResult",i[i.SpeechServiceConnection_Url=29]="SpeechServiceConnection_Url",i[i.SpeechServiceConnection_InitialSilenceTimeoutMs=30]="SpeechServiceConnection_InitialSilenceTimeoutMs",i[i.SpeechServiceConnection_EndSilenceTimeoutMs=31]="SpeechServiceConnection_EndSilenceTimeoutMs",i[i.Speech_SegmentationSilenceTimeoutMs=32]="Speech_SegmentationSilenceTimeoutMs",i[i.SpeechServiceConnection_EnableAudioLogging=33]="SpeechServiceConnection_EnableAudioLogging",i[i.SpeechServiceConnection_LanguageIdMode=34]="SpeechServiceConnection_LanguageIdMode",i[i.SpeechServiceConnection_RecognitionEndpointVersion=35]="SpeechServiceConnection_RecognitionEndpointVersion",i[i.SpeechServiceConnection_SpeakerIdMode=36]="SpeechServiceConnection_SpeakerIdMode",i[i.SpeechServiceResponse_ProfanityOption=37]="SpeechServiceResponse_ProfanityOption",i[i.SpeechServiceResponse_PostProcessingOption=38]="SpeechServiceResponse_PostProcessingOption",i[i.SpeechServiceResponse_RequestWordLevelTimestamps=39]="SpeechServiceResponse_RequestWordLevelTimestamps",i[i.SpeechServiceResponse_StablePartialResultThreshold=40]="SpeechServiceResponse_StablePartialResultThreshold",i[i.SpeechServiceResponse_OutputFormatOption=41]="SpeechServiceResponse_OutputFormatOption",i[i.SpeechServiceResponse_TranslationRequestStablePartialResult=42]="SpeechServiceResponse_TranslationRequestStablePartialResult",i[i.SpeechServiceResponse_RequestWordBoundary=43]="SpeechServiceResponse_RequestWordBoundary",i[i.SpeechServiceResponse_RequestPunctuationBoundary=44]="SpeechServiceResponse_RequestPunctuationBoundary",i[i.SpeechServiceResponse_RequestSentenceBoundary=45]="SpeechServiceResponse_RequestSentenceBoundary",i[i.Conversation_ApplicationId=46]="Conversation_ApplicationId",i[i.Conversation_DialogType=47]="Conversation_DialogType",i[i.Conversation_Initial_Silence_Timeout=48]="Conversation_Initial_Silence_Timeout",i[i.Conversation_From_Id=49]="Conversation_From_Id",i[i.Conversation_Conversation_Id=50]="Conversation_Conversation_Id",i[i.Conversation_Custom_Voice_Deployment_Ids=51]="Conversation_Custom_Voice_Deployment_Ids",i[i.Conversation_Speech_Activity_Template=52]="Conversation_Speech_Activity_Template",i[i.Conversation_Request_Bot_Status_Messages=53]="Conversation_Request_Bot_Status_Messages",i[i.Conversation_Agent_Connection_Id=54]="Conversation_Agent_Connection_Id",i[i.SpeechServiceConnection_Host=55]="SpeechServiceConnection_Host",i[i.ConversationTranslator_Host=56]="ConversationTranslator_Host",i[i.ConversationTranslator_Name=57]="ConversationTranslator_Name",i[i.ConversationTranslator_CorrelationId=58]="ConversationTranslator_CorrelationId",i[i.ConversationTranslator_Token=59]="ConversationTranslator_Token",i[i.PronunciationAssessment_ReferenceText=60]="PronunciationAssessment_ReferenceText",i[i.PronunciationAssessment_GradingSystem=61]="PronunciationAssessment_GradingSystem",i[i.PronunciationAssessment_Granularity=62]="PronunciationAssessment_Granularity",i[i.PronunciationAssessment_EnableMiscue=63]="PronunciationAssessment_EnableMiscue",i[i.PronunciationAssessment_Json=64]="PronunciationAssessment_Json",i[i.PronunciationAssessment_Params=65]="PronunciationAssessment_Params",i[i.SpeakerRecognition_Api_Version=66]="SpeakerRecognition_Api_Version",i[i.WebWorkerLoadType=67]="WebWorkerLoadType",i[i.TalkingAvatarService_WebRTC_SDP=68]="TalkingAvatarService_WebRTC_SDP"})(Aw=yn.PropertyId||(yn.PropertyId={}))});var PS=p(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.Recognizer=void 0;var qr=C(),CS=P(),Io=I(),wo=f(),jh=class i{constructor(e,t,r){this.audioConfig=e!==void 0?e:wo.AudioConfig.fromDefaultMicrophoneInput(),this.privDisposed=!1,this.privProperties=t.clone(),this.privConnectionFactory=r,this.implCommonRecognizerSetup()}close(e,t){Io.Contracts.throwIfDisposed(this.privDisposed),CS.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privReco}async dispose(e){this.privDisposed||(this.privDisposed=!0,e&&this.privReco&&(await this.privReco.audioSource.turnOff(),await this.privReco.dispose()))}static get telemetryEnabled(){return qr.ServiceRecognizerBase.telemetryDataEnabled}static enableTelemetry(e){qr.ServiceRecognizerBase.telemetryDataEnabled=e}implCommonRecognizerSetup(){let e=typeof window<"u"?"Browser":"Node",t="unknown",r="unknown";typeof navigator<"u"&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);let n=this.createRecognizerConfig(new qr.SpeechServiceConfig(new qr.Context(new qr.OS(e,t,r))));this.privReco=this.createServiceRecognizer(i.getAuthFromProperties(this.privProperties),this.privConnectionFactory,this.audioConfig,n)}async recognizeOnceAsyncImpl(e){Io.Contracts.throwIfDisposed(this.privDisposed);let t=new CS.Deferred;await this.implRecognizerStop(),await this.privReco.recognize(e,t.resolve,t.reject);let r=await t.promise;return await this.implRecognizerStop(),r}async startContinuousRecognitionAsyncImpl(e){Io.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop(),await this.privReco.recognize(e,void 0,void 0)}async stopContinuousRecognitionAsyncImpl(){Io.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop()}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}static getAuthFromProperties(e){let t=e.getProperty(wo.PropertyId.SpeechServiceConnection_Key,void 0);return t&&t!==""?new qr.CognitiveSubscriptionKeyAuthentication(t):new qr.CognitiveTokenAuthentication(()=>{let n=e.getProperty(wo.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)},()=>{let n=e.getProperty(wo.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)})}};_o.Recognizer=jh});var RS=p(Ao=>{"use strict";Object.defineProperty(Ao,"__esModule",{value:!0});Ao.SpeechRecognizer=void 0;var mi=C(),To=P(),ar=I(),ze=f(),Lh=class i extends ze.Recognizer{constructor(e,t){let r=e;ar.Contracts.throwIfNull(r,"speechConfig"),ar.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(ze.PropertyId.SpeechServiceConnection_RecoLanguage),ze.PropertyId[ze.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new mi.SpeechConnectionFactory),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get endpointId(){return ar.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ze.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(ze.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){ar.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(ze.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return ar.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ze.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return ar.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(mi.OutputFormatPropertyName,ze.OutputFormat[ze.OutputFormat.Simple])===ze.OutputFormat[ze.OutputFormat.Simple]?ze.OutputFormat.Simple:ze.OutputFormat.Detailed}get properties(){return this.privProperties}recognizeOnceAsync(e,t){To.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(mi.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){To.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(mi.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){To.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){ar.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e){e&&e()}close(e,t){ar.Contracts.throwIfDisposed(this.privDisposedRecognizer),To.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new mi.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new mi.SpeechServiceRecognizer(e,t,s,n,this)}};Ao.SpeechRecognizer=Lh});var ES=p(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});Oo.IntentRecognizer=void 0;var xr=C(),bo=P(),_e=I(),Ft=f(),Bh=class extends Ft.Recognizer{constructor(e,t){_e.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;_e.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new xr.IntentConnectionFactory),this.privAddedIntents=[],this.privAddedLmIntents={},this.privDisposedIntentRecognizer=!1,this.privProperties=r.properties,_e.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(Ft.PropertyId.SpeechServiceConnection_RecoLanguage),Ft.PropertyId[Ft.PropertyId.SpeechServiceConnection_RecoLanguage])}get speechRecognitionLanguage(){return _e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.properties.getProperty(Ft.PropertyId.SpeechServiceConnection_RecoLanguage)}get authorizationToken(){return this.properties.getProperty(Ft.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(Ft.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}recognizeOnceAsync(e,t){if(_e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){let r=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",r.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(r.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}bo.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(xr.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){if(Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){let r=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",r.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(r.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}bo.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(xr.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){bo.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){_e.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e,t){if(e)try{e()}catch(r){t&&t(r)}}addIntent(e,t){_e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),_e.Contracts.throwIfNullOrWhitespace(t,"intentId"),_e.Contracts.throwIfNullOrWhitespace(e,"simplePhrase"),this.privAddedIntents.push([t,e])}addIntentWithLanguageModel(e,t,r){_e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),_e.Contracts.throwIfNullOrWhitespace(e,"intentId"),_e.Contracts.throwIfNull(t,"model");let n=t;_e.Contracts.throwIfNullOrWhitespace(n.appId,"model.appId"),this.privAddedLmIntents[e]=new xr.AddedLmIntent(n,r)}addAllIntents(e,t){_e.Contracts.throwIfNull(e,"model");let r=e;_e.Contracts.throwIfNullOrWhitespace(r.appId,"model.appId"),this.privUmbrellaIntent=new xr.AddedLmIntent(r,t)}close(e,t){_e.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),bo.marshalPromiseToCallbacks(this.dispose(!0),e,t)}createRecognizerConfig(e){return new xr.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new xr.IntentServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedIntentRecognizer||e&&(this.privDisposedIntentRecognizer=!0,await super.dispose(e))}buildSpeechContext(){let e,t,r,n=[];this.privUmbrellaIntent!==void 0&&(e=this.privUmbrellaIntent.modelImpl.appId,t=this.privUmbrellaIntent.modelImpl.region,r=this.privUmbrellaIntent.modelImpl.subscriptionKey);for(let s of Object.keys(this.privAddedLmIntents)){let o=this.privAddedLmIntents[s];if(e===void 0)e=o.modelImpl.appId;else if(e!==o.modelImpl.appId)throw new Error("Intents must all be from the same LUIS model");if(t===void 0)t=o.modelImpl.region;else if(t!==o.modelImpl.region)throw new Error("Intents must all be from the same LUIS model in a single region");if(r===void 0)r=o.modelImpl.subscriptionKey;else if(r!==o.modelImpl.subscriptionKey)throw new Error("Intents must all use the same subscription key");let a="luis/"+e+"-PRODUCTION#"+s;n.push(a)}return{Intent:{id:e,key:r===void 0?this.privProperties.getProperty(Ft.PropertyId[Ft.PropertyId.SpeechServiceConnection_Key]):r,provider:"LUIS"},ReferenceGrammars:this.privUmbrellaIntent===void 0?n:["luis/"+e+"-PRODUCTION"]}}};Oo.IntentRecognizer=Bh});var IS=p(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.VoiceProfileType=void 0;var bw;(function(i){i[i.TextIndependentIdentification=0]="TextIndependentIdentification",i[i.TextDependentVerification=1]="TextDependentVerification",i[i.TextIndependentVerification=2]="TextIndependentVerification"})(bw=Cn.VoiceProfileType||(Cn.VoiceProfileType={}))});var Uh=p(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.ConnectionMessageImpl=Si.ConnectionMessage=void 0;var wS=we(),_S=P(),Ow=zh(),Mw=Eo(),Fh=class{};Si.ConnectionMessage=Fh;var Vh=class{constructor(e){this.privConnectionMessage=e,this.privProperties=new Ow.PropertyCollection,this.privConnectionMessage.headers[wS.HeaderNames.ConnectionId]&&this.privProperties.setProperty(Mw.PropertyId.Speech_SessionId,this.privConnectionMessage.headers[wS.HeaderNames.ConnectionId]),Object.keys(this.privConnectionMessage.headers).forEach(t=>{this.privProperties.setProperty(t,this.privConnectionMessage.headers[t])})}get path(){return this.privConnectionMessage.headers[Object.keys(this.privConnectionMessage.headers).find(e=>e.toLowerCase()==="path".toLowerCase())]}get isTextMessage(){return this.privConnectionMessage.messageType===_S.MessageType.Text}get isBinaryMessage(){return this.privConnectionMessage.messageType===_S.MessageType.Binary}get TextMessage(){return this.privConnectionMessage.textBody}get binaryMessage(){return this.privConnectionMessage.binaryBody}get properties(){return this.privProperties}toString(){return""}};Si.ConnectionMessageImpl=Vh});var Jh=p(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.Connection=void 0;var Wh=C(),Hh=P(),TS=Uh(),Dw=I(),Pn=f(),Kh=class i{static fromRecognizer(e){let t=e.internalData,r=new i;return r.privInternalData=t,r.setupEvents(),r}static fromSynthesizer(e){let t=e.internalData,r=new i;return r.privInternalData=t,r.setupEvents(),r}openConnection(e,t){Hh.marshalPromiseToCallbacks(this.privInternalData.connect(),e,t)}closeConnection(e,t){if(this.privInternalData instanceof Wh.SynthesisAdapterBase)throw new Error("Disconnecting a synthesizer's connection is currently not supported");Hh.marshalPromiseToCallbacks(this.privInternalData.disconnect(),e,t)}setMessageProperty(e,t,r){if(Dw.Contracts.throwIfNullOrWhitespace(t,"propertyName"),this.privInternalData instanceof Wh.ServiceRecognizerBase){if(e.toLowerCase()!=="speech.context")throw new Error("Only speech.context message property sets are currently supported for recognizer");this.privInternalData.speechContext.setSection(t,r)}else if(this.privInternalData instanceof Wh.SynthesisAdapterBase){if(e.toLowerCase()!=="synthesis.context")throw new Error("Only synthesis.context message property sets are currently supported for synthesizer");this.privInternalData.synthesisContext.setSection(t,r)}}sendMessageAsync(e,t,r,n){Hh.marshalPromiseToCallbacks(this.privInternalData.sendNetworkMessage(e,t),r,n)}close(){}setupEvents(){this.privEventListener=this.privInternalData.connectionEvents.attach(e=>{e.name==="ConnectionEstablishedEvent"?this.connected&&this.connected(new Pn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionClosedEvent"?this.disconnected&&this.disconnected(new Pn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionMessageSentEvent"?this.messageSent&&this.messageSent(new Pn.ConnectionMessageEventArgs(new TS.ConnectionMessageImpl(e.message))):e.name==="ConnectionMessageReceivedEvent"&&this.messageReceived&&this.messageReceived(new Pn.ConnectionMessageEventArgs(new TS.ConnectionMessageImpl(e.message)))}),this.privServiceEventListener=this.privInternalData.serviceEvents.attach(e=>{this.receivedServiceMessage&&this.receivedServiceMessage(new Pn.ServiceEventArgs(e.jsonString,e.name))})}};Mo.Connection=Kh});var AS=p(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.TranslationRecognizer=void 0;var Rn=C(),Do=P(),kw=Jh(),lt=I(),J=f(),Gh=class i extends J.Recognizer{constructor(e,t,r){let n=e;lt.Contracts.throwIfNull(n,"speechConfig"),super(t,n.properties,r||new Rn.TranslationConnectionFactory),this.privDisposedTranslationRecognizer=!1,this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)!==void 0&&lt.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationVoice),J.PropertyId[J.PropertyId.SpeechServiceConnection_TranslationVoice]),lt.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages),J.PropertyId[J.PropertyId.SpeechServiceConnection_TranslationToLanguages]),lt.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(J.PropertyId.SpeechServiceConnection_RecoLanguage),J.PropertyId[J.PropertyId.SpeechServiceConnection_RecoLanguage])}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get speechRecognitionLanguage(){return lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_RecoLanguage)}get targetLanguages(){return lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",")}get voiceName(){return lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(J.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(J.PropertyId.SpeechServiceAuthorization_Token,e)}recognizeOnceAsync(e,t){lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),Do.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Rn.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){Do.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Rn.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){Do.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}removeTargetLanguage(e){if(lt.Contracts.throwIfNullOrUndefined(e,"language to be removed"),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0){let t=this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),r=t.indexOf(e);r>-1&&(t.splice(r,1),this.properties.setProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")),this.updateLanguages(t))}}addTargetLanguage(e){lt.Contracts.throwIfNullOrUndefined(e,"language to be added");let t=[];this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?(t=this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),t.includes(e)||(t.push(e),this.properties.setProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))):(this.properties.setProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,e),t=[e]),this.updateLanguages(t)}close(e,t){lt.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),Do.marshalPromiseToCallbacks(this.dispose(!0),e,t)}onConnection(){}async dispose(e){this.privDisposedTranslationRecognizer||(this.privDisposedTranslationRecognizer=!0,e&&(await this.implRecognizerStop(),await super.dispose(e)))}createRecognizerConfig(e){return new Rn.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Rn.TranslationServiceRecognizer(e,t,s,n,this)}updateLanguages(e){let t=kw.Connection.fromRecognizer(this);t&&(t.setMessageProperty("speech.context","translationcontext",{to:e}),t.sendMessageAsync("event",JSON.stringify({id:"translation",name:"updateLanguage",to:e})))}};ko.TranslationRecognizer=Gh});var bS=p(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.Translations=void 0;var Nw=f(),$h=class{constructor(){this.privMap=new Nw.PropertyCollection}get languages(){return this.privMap.keys}get(e,t){return this.privMap.getProperty(e,t)}set(e,t){this.privMap.setProperty(e,t)}};No.Translations=$h});var OS=p(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.NoMatchReason=void 0;var qw;(function(i){i[i.NotRecognized=0]="NotRecognized",i[i.InitialSilenceTimeout=1]="InitialSilenceTimeout",i[i.InitialBabbleTimeout=2]="InitialBabbleTimeout"})(qw=En.NoMatchReason||(En.NoMatchReason={}))});var MS=p(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.NoMatchDetails=void 0;var Qh=C(),qo=f(),Yh=class i{constructor(e){this.privReason=e}static fromResult(e){let t=Qh.SimpleSpeechPhrase.fromJSON(e.json),r=qo.NoMatchReason.NotRecognized;switch(t.RecognitionStatus){case Qh.RecognitionStatus.BabbleTimeout:r=qo.NoMatchReason.InitialBabbleTimeout;break;case Qh.RecognitionStatus.InitialSilenceTimeout:r=qo.NoMatchReason.InitialSilenceTimeout;break;default:r=qo.NoMatchReason.NotRecognized;break}return new i(r)}get reason(){return this.privReason}};xo.NoMatchDetails=Yh});var DS=p(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.TranslationRecognitionCanceledEventArgs=void 0;var Xh=class{constructor(e,t,r,n,s){this.privCancelReason=t,this.privErrorDetails=r,this.privResult=s,this.privSessionId=e,this.privErrorCode=n}get result(){return this.privResult}get sessionId(){return this.privSessionId}get reason(){return this.privCancelReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};zo.TranslationRecognitionCanceledEventArgs=Xh});var kS=p(jo=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});jo.IntentRecognitionCanceledEventArgs=void 0;var xw=f(),Zh=class extends xw.IntentRecognitionEventArgs{constructor(e,t,r,n,s,o){super(n,s,o),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};jo.IntentRecognitionCanceledEventArgs=Zh});var td=p(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.CancellationDetailsBase=void 0;var ed=class{constructor(e,t,r){this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get ErrorCode(){return this.privErrorCode}};Lo.CancellationDetailsBase=ed});var NS=p(Fo=>{"use strict";Object.defineProperty(Fo,"__esModule",{value:!0});Fo.CancellationDetails=void 0;var Bo=C(),zw=td(),yi=f(),rd=class i extends zw.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=yi.CancellationReason.Error,r=yi.CancellationErrorCode.NoError;if(e instanceof yi.RecognitionResult&&e.json){let n=Bo.SimpleSpeechPhrase.fromJSON(e.json);t=Bo.EnumTranslation.implTranslateCancelResult(n.RecognitionStatus)}return e.properties&&(r=yi.CancellationErrorCode[e.properties.getProperty(Bo.CancellationErrorCodePropertyName,yi.CancellationErrorCode[yi.CancellationErrorCode.NoError])]),new i(t,e.errorDetails||Bo.EnumTranslation.implTranslateErrorDetails(r),r)}};Fo.CancellationDetails=rd});var qS=p(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.CancellationErrorCode=void 0;var jw;(function(i){i[i.NoError=0]="NoError",i[i.AuthenticationFailure=1]="AuthenticationFailure",i[i.BadRequestParameters=2]="BadRequestParameters",i[i.TooManyRequests=3]="TooManyRequests",i[i.ConnectionFailure=4]="ConnectionFailure",i[i.ServiceTimeout=5]="ServiceTimeout",i[i.ServiceError=6]="ServiceError",i[i.RuntimeError=7]="RuntimeError",i[i.Forbidden=8]="Forbidden"})(jw=In.CancellationErrorCode||(In.CancellationErrorCode={}))});var xS=p(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.ConnectionEventArgs=void 0;var Lw=f(),id=class extends Lw.SessionEventArgs{};Vo.ConnectionEventArgs=id});var zS=p(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.ServiceEventArgs=void 0;var Bw=f(),nd=class extends Bw.SessionEventArgs{constructor(e,t,r){super(r),this.privJsonResult=e,this.privEventName=t}get jsonString(){return this.privJsonResult}get eventName(){return this.privEventName}};Uo.ServiceEventArgs=nd});var jS=p(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.PhraseListGrammar=void 0;var sd=class i{constructor(e){this.privGrammerBuilder=e.dynamicGrammar}static fromRecognizer(e){let t=e.internalData;return new i(t)}addPhrase(e){this.privGrammerBuilder.addPhrase(e)}addPhrases(e){this.privGrammerBuilder.addPhrase(e)}clear(){this.privGrammerBuilder.clearPhrases()}};Wo.PhraseListGrammar=sd});var Ko=p(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});Ci.DialogServiceConfigImpl=Ci.DialogServiceConfig=void 0;var Fw=I(),wn=f(),Ho=class{constructor(){}set applicationId(e){}static get DialogTypes(){return{BotFramework:"bot_framework",CustomCommands:"custom_commands"}}};Ci.DialogServiceConfig=Ho;var od=class extends Ho{constructor(){super(),this.privSpeechConfig=new wn.SpeechConfigImpl}get properties(){return this.privSpeechConfig.properties}get speechRecognitionLanguage(){return this.privSpeechConfig.speechRecognitionLanguage}set speechRecognitionLanguage(e){Fw.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechConfig.speechRecognitionLanguage=e}get outputFormat(){return this.privSpeechConfig.outputFormat}set outputFormat(e){this.privSpeechConfig.outputFormat=e}setProperty(e,t){this.privSpeechConfig.setProperty(e,t)}getProperty(e,t){return this.privSpeechConfig.getProperty(e)}setProxy(e,t,r,n){this.setProperty(wn.PropertyId.SpeechServiceConnection_ProxyHostName,e),this.setProperty(wn.PropertyId.SpeechServiceConnection_ProxyPort,`${t}`),r&&this.setProperty(wn.PropertyId.SpeechServiceConnection_ProxyUserName,r),n&&this.setProperty(wn.PropertyId.SpeechServiceConnection_ProxyPassword,n)}setServiceProperty(e,t,r){this.privSpeechConfig.setServiceProperty(e,t)}close(){}};Ci.DialogServiceConfigImpl=od});var LS=p(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.BotFrameworkConfig=void 0;var zr=I(),Vt=Ko(),je=f(),ad=class extends Vt.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){zr.Contracts.throwIfNullOrWhitespace(e,"subscription"),zr.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Vt.DialogServiceConfigImpl;return n.setProperty(je.PropertyId.Conversation_DialogType,Vt.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(je.PropertyId.SpeechServiceConnection_Key,e),n.setProperty(je.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(je.PropertyId.Conversation_ApplicationId,r),n}static fromAuthorizationToken(e,t,r){zr.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),zr.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Vt.DialogServiceConfigImpl;return n.setProperty(je.PropertyId.Conversation_DialogType,Vt.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(je.PropertyId.SpeechServiceAuthorization_Token,e),n.setProperty(je.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(je.PropertyId.Conversation_ApplicationId,r),n}static fromHost(e,t,r){zr.Contracts.throwIfNullOrUndefined(e,"host");let n=e instanceof URL?e:new URL(`wss://${e}.convai.speech.azure.us`);zr.Contracts.throwIfNullOrUndefined(n,"resolvedHost");let s=new Vt.DialogServiceConfigImpl;return s.setProperty(je.PropertyId.Conversation_DialogType,Vt.DialogServiceConfig.DialogTypes.BotFramework),s.setProperty(je.PropertyId.SpeechServiceConnection_Host,n.toString()),t!==void 0&&s.setProperty(je.PropertyId.SpeechServiceConnection_Key,t),s}static fromEndpoint(e,t){zr.Contracts.throwIfNull(e,"endpoint");let r=new Vt.DialogServiceConfigImpl;return r.setProperty(je.PropertyId.Conversation_DialogType,Vt.DialogServiceConfig.DialogTypes.BotFramework),r.setProperty(je.PropertyId.SpeechServiceConnection_Endpoint,e.toString()),t!==void 0&&r.setProperty(je.PropertyId.SpeechServiceConnection_Key,t),r}};Jo.BotFrameworkConfig=ad});var BS=p(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.CustomCommandsConfig=void 0;var jr=I(),_n=Ko(),It=f(),cd=class extends _n.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){jr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),jr.Contracts.throwIfNullOrWhitespace(t,"subscription"),jr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new _n.DialogServiceConfigImpl;return n.setProperty(It.PropertyId.Conversation_DialogType,_n.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(It.PropertyId.Conversation_ApplicationId,e),n.setProperty(It.PropertyId.SpeechServiceConnection_Key,t),n.setProperty(It.PropertyId.SpeechServiceConnection_Region,r),n}static fromAuthorizationToken(e,t,r){jr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),jr.Contracts.throwIfNullOrWhitespace(t,"authorizationToken"),jr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new _n.DialogServiceConfigImpl;return n.setProperty(It.PropertyId.Conversation_DialogType,_n.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(It.PropertyId.Conversation_ApplicationId,e),n.setProperty(It.PropertyId.SpeechServiceAuthorization_Token,t),n.setProperty(It.PropertyId.SpeechServiceConnection_Region,r),n}set applicationId(e){jr.Contracts.throwIfNullOrWhitespace(e,"value"),this.setProperty(It.PropertyId.Conversation_ApplicationId,e)}get applicationId(){return this.getProperty(It.PropertyId.Conversation_ApplicationId)}};Go.CustomCommandsConfig=cd});var Ut=p($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.QueryParameterNames=void 0;var W=class{};$o.QueryParameterNames=W;W.BotId="botid";W.CustomSpeechDeploymentId="cid";W.CustomVoiceDeploymentId="deploymentId";W.EnableAudioLogging="storeAudio";W.EnableLanguageId="lidEnabled";W.EnableWordLevelTimestamps="wordLevelTimestamps";W.EndSilenceTimeoutMs="endSilenceTimeoutMs";W.SegmentationSilenceTimeoutMs="segmentationSilenceTimeoutMs";W.Format="format";W.InitialSilenceTimeoutMs="initialSilenceTimeoutMs";W.Language="language";W.Profanity="profanity";W.RequestBotStatusMessages="enableBotMessageStatus";W.StableIntermediateThreshold="stableIntermediateThreshold";W.StableTranslation="stableTranslation";W.TestHooks="testhooks";W.Postprocessing="postprocessing";W.CtsMeetingId="meetingId";W.CtsDeviceId="deviceId";W.CtsIsParticipant="isParticipant";W.EnableAvatar="enableTalkingAvatar"});var Ye=p(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.ConnectionFactoryBase=void 0;var Vw=C(),cr=f(),pr=Ut(),pd=class{static getHostSuffix(e){if(e){if(e.toLowerCase().startsWith("china"))return".azure.cn";if(e.toLowerCase().startsWith("usgov"))return".azure.us"}return".microsoft.com"}setCommonUrlParams(e,t,r){new Map([[cr.PropertyId.Speech_SegmentationSilenceTimeoutMs,pr.QueryParameterNames.SegmentationSilenceTimeoutMs],[cr.PropertyId.SpeechServiceConnection_EnableAudioLogging,pr.QueryParameterNames.EnableAudioLogging],[cr.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,pr.QueryParameterNames.EndSilenceTimeoutMs],[cr.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,pr.QueryParameterNames.InitialSilenceTimeoutMs],[cr.PropertyId.SpeechServiceResponse_PostProcessingOption,pr.QueryParameterNames.Postprocessing],[cr.PropertyId.SpeechServiceResponse_ProfanityOption,pr.QueryParameterNames.Profanity],[cr.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,pr.QueryParameterNames.EnableWordLevelTimestamps],[cr.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,pr.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(Vw.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}setUrlParameter(e,t,r,n,s){let o=r.parameters.getProperty(e,void 0);o&&(!s||s.search(t)===-1)&&(n[t]=o.toLocaleLowerCase())}};Qo.ConnectionFactoryBase=pd});var WS=p(Xo=>{"use strict";Object.defineProperty(Xo,"__esModule",{value:!0});Xo.DialogConnectionFactory=void 0;var FS=pe(),Uw=C(),Ue=f(),VS=Ye(),Ww=C(),US=we(),Yo=Ut(),Tn=class i extends VS.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Ue.PropertyId.Conversation_ApplicationId,""),s=e.parameters.getProperty(Ue.PropertyId.Conversation_DialogType),o=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_Region),a=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),c=e.parameters.getProperty(Ue.PropertyId.Conversation_Request_Bot_Status_Messages,"true"),u={};u[US.HeaderNames.ConnectionId]=r,u[Yo.QueryParameterNames.Format]=e.parameters.getProperty(Uw.OutputFormatPropertyName,Ue.OutputFormat[Ue.OutputFormat.Simple]).toLowerCase(),u[Yo.QueryParameterNames.Language]=a,u[Yo.QueryParameterNames.RequestBotStatusMessages]=c,n&&(u[Yo.QueryParameterNames.BotId]=n,s===Ue.DialogServiceConfig.DialogTypes.CustomCommands&&(u[US.HeaderNames.CustomCommandsAppId]=n));let h=s===Ue.DialogServiceConfig.DialogTypes.CustomCommands?"commands/":"",d=s===Ue.DialogServiceConfig.DialogTypes.CustomCommands?"v1":s===Ue.DialogServiceConfig.DialogTypes.BotFramework?"v3":"v0",v={};t.token!=null&&t.token!==""&&(v[t.headerName]=t.token);let g=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_Endpoint,"");if(!g){let k=VS.ConnectionFactoryBase.getHostSuffix(o),ae=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_Host,`wss://${o}.${i.BaseUrl}${k}`);g=`${ae.endsWith("/")?ae:ae+"/"}${h}${i.ApiKey}/${d}`}this.setCommonUrlParams(e,u,g);let w=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new FS.WebsocketConnection(g,u,v,new Ww.WebsocketMessageFormatter,FS.ProxyInfo.fromRecognizerConfig(e),w,r)}};Xo.DialogConnectionFactory=Tn;Tn.ApiKey="api";Tn.BaseUrl="convai.speech"});var HS=p(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});ea.DialogServiceConnector=void 0;var Hw=WS(),ud=C(),Pi=P(),Zo=I(),Kw=f(),ur=Eo(),hd=class extends Kw.Recognizer{constructor(e,t){let r=e;Zo.Contracts.throwIfNull(e,"dialogConfig"),super(t,r.properties,new Hw.DialogConnectionFactory),this.isTurnComplete=!0,this.privIsDisposed=!1,this.privProperties=r.properties.clone();let n=this.buildAgentConfig();this.privReco.agentConfig.set(n)}connect(e,t){Pi.marshalPromiseToCallbacks(this.privReco.connect(),e,t)}disconnect(e,t){Pi.marshalPromiseToCallbacks(this.privReco.disconnect(),e,t)}get authorizationToken(){return this.properties.getProperty(ur.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Zo.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(ur.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get speechActivityTemplate(){return this.properties.getProperty(ur.PropertyId.Conversation_Speech_Activity_Template)}set speechActivityTemplate(e){this.properties.setProperty(ur.PropertyId.Conversation_Speech_Activity_Template,e)}listenOnceAsync(e,t){if(this.isTurnComplete){Zo.Contracts.throwIfDisposed(this.privIsDisposed);let n=(async()=>{await this.privReco.connect(),await this.implRecognizerStop(),this.isTurnComplete=!1;let s=new Pi.Deferred;await this.privReco.recognize(ud.RecognitionMode.Conversation,s.resolve,s.reject);let o=await s.promise;return await this.implRecognizerStop(),o})();n.catch(()=>{this.dispose(!0).catch(()=>{})}),Pi.marshalPromiseToCallbacks(n.finally(()=>{this.isTurnComplete=!0}),e,t)}}sendActivityAsync(e,t,r){Pi.marshalPromiseToCallbacks(this.privReco.sendMessage(e),t,r)}close(e,t){Zo.Contracts.throwIfDisposed(this.privIsDisposed),Pi.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privIsDisposed||e&&(this.privIsDisposed=!0,await this.implRecognizerStop(),await super.dispose(e))}createRecognizerConfig(e){return new ud.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new ud.DialogServiceAdapter(e,t,s,n,this)}buildAgentConfig(){return{botInfo:{commType:this.properties.getProperty("Conversation_Communication_Type","Default"),commandsCulture:void 0,connectionId:this.properties.getProperty(ur.PropertyId.Conversation_Agent_Connection_Id),conversationId:this.properties.getProperty(ur.PropertyId.Conversation_Conversation_Id,void 0),fromId:this.properties.getProperty(ur.PropertyId.Conversation_From_Id,void 0),ttsAudioFormat:this.properties.getProperty(ur.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)},version:.2}}};ea.DialogServiceConnector=hd});var KS=p(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.ActivityReceivedEventArgs=void 0;var dd=class{constructor(e,t){this.privActivity=e,this.privAudioStream=t}get activity(){return this.privActivity}get audioStream(){return this.privAudioStream}};ta.ActivityReceivedEventArgs=dd});var JS=p(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.TurnStatusResponsePayload=void 0;var ld=class i{constructor(e){this.privMessageStatusResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get interactionId(){return this.privMessageStatusResponse.interactionId}get conversationId(){return this.privMessageStatusResponse.conversationId}get statusCode(){switch(this.privMessageStatusResponse.statusCode){case"Success":return 200;case"Failed":return 400;case"TimedOut":return 429;default:return this.privMessageStatusResponse.statusCode}}};ra.TurnStatusResponsePayload=ld});var GS=p(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.TurnStatusReceivedEventArgs=void 0;var Jw=JS(),vd=class{constructor(e){this.privTurnStatus=Jw.TurnStatusResponsePayload.fromJSON(e)}get interactionId(){return this.privTurnStatus.interactionId}get conversationId(){return this.privTurnStatus.conversationId}get statusCode(){return this.privTurnStatus.statusCode}};ia.TurnStatusReceivedEventArgs=vd});var $S=p(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.ServicePropertyChannel=void 0;var Gw;(function(i){i[i.UriQueryParameter=0]="UriQueryParameter"})(Gw=An.ServicePropertyChannel||(An.ServicePropertyChannel={}))});var QS=p(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.ProfanityOption=void 0;var $w;(function(i){i[i.Masked=0]="Masked",i[i.Removed=1]="Removed",i[i.Raw=2]="Raw"})($w=bn.ProfanityOption||(bn.ProfanityOption={}))});var YS=p(na=>{"use strict";Object.defineProperty(na,"__esModule",{value:!0});na.BaseAudioPlayer=void 0;var Qw=ht(),Yw=f(),Xw=nr(),fd=class{constructor(e){this.audioContext=null,this.gainNode=null,this.autoUpdateBufferTimer=0,e===void 0&&(e=Yw.AudioStreamFormat.getDefaultInputFormat()),this.init(e)}playAudioSample(e,t,r){try{this.ensureInitializedContext();let n=this.formatAudioData(e),s=new Float32Array(this.samples.length+n.length);s.set(this.samples,0),s.set(n,this.samples.length),this.samples=s,t&&t()}catch(n){r&&r(n)}}stopAudio(e,t){this.audioContext!==null&&(this.samples=new Float32Array,clearInterval(this.autoUpdateBufferTimer),this.audioContext.close().then(()=>{e&&e()},r=>{t&&t(r)}),this.audioContext=null)}init(e){this.audioFormat=e,this.samples=new Float32Array}ensureInitializedContext(){if(this.audioContext===null){this.createAudioContext();let e=200;this.autoUpdateBufferTimer=setInterval(()=>{this.updateAudioBuffer()},e)}}createAudioContext(){this.audioContext=Xw.AudioStreamFormatImpl.getAudioContext(),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.gainNode.connect(this.audioContext.destination),this.startTime=this.audioContext.currentTime}formatAudioData(e){switch(this.audioFormat.bitsPerSample){case 8:return this.formatArrayBuffer(new Int8Array(e),128);case 16:return this.formatArrayBuffer(new Int16Array(e),32768);case 32:return this.formatArrayBuffer(new Int32Array(e),2147483648);default:throw new Qw.InvalidOperationError("Only WAVE_FORMAT_PCM (8/16/32 bps) format supported at this time")}}formatArrayBuffer(e,t){let r=new Float32Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]/t;return r}updateAudioBuffer(){if(this.samples.length===0)return;let e=this.audioFormat.channels,t=this.audioContext.createBufferSource(),r=this.samples.length/e,n=this.audioContext.createBuffer(e,r,this.audioFormat.samplesPerSec);for(let s=0;s<e;s++){let o=s,a=n.getChannelData(s);for(let c=0;c<this.samples.length;c++,o+=e)a[c]=this.samples[o]}this.startTime<this.audioContext.currentTime&&(this.startTime=this.audioContext.currentTime),t.buffer=n,t.connect(this.gainNode),t.start(this.startTime),this.startTime+=n.duration,this.samples=new Float32Array}async playAudio(e){this.audioContext===null&&this.createAudioContext();let t=this.audioContext.createBufferSource(),r=this.audioContext.destination;await this.audioContext.decodeAudioData(e,n=>{t.buffer=n,t.connect(r),t.start(0)})}};na.BaseAudioPlayer=fd});var XS=p(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.ConnectionMessageEventArgs=void 0;var gd=class{constructor(e){this.privConnectionMessage=e}get message(){return this.privConnectionMessage}toString(){return"Message: "+this.privConnectionMessage.toString()}};sa.ConnectionMessageEventArgs=gd});var ZS=p(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0});oa.VoiceProfile=void 0;var md=class{constructor(e,t){this.privId=e,this.privProfileType=t}get profileId(){return this.privId}get profileType(){return this.privProfileType}};oa.VoiceProfile=md});var ty=p(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});Ri.VoiceProfileEnrollmentCancellationDetails=Ri.VoiceProfileEnrollmentResult=void 0;var ey=C(),ge=f(),Sd=class i{constructor(e,t,r){this.privReason=e,this.privProperties=new ge.PropertyCollection,this.privReason!==ge.ResultReason.Canceled?t&&(this.privDetails=JSON.parse(t),this.privDetails.enrollmentStatus.toLowerCase()==="enrolling"&&(this.privReason=ge.ResultReason.EnrollingVoiceProfile)):(this.privErrorDetails=r,this.privProperties.setProperty(ey.CancellationErrorCodePropertyName,ge.CancellationErrorCode[ge.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get enrollmentsCount(){return this.privDetails.enrollmentsCount}get enrollmentsLength(){return this.privDetails.enrollmentsLength}get properties(){return this.privProperties}get enrollmentResultDetails(){return this.privDetails}get errorDetails(){return this.privErrorDetails}static FromIdentificationProfileList(e){let t=[];for(let r of e.value){let n=r.enrollmentStatus.toLowerCase()==="enrolling"?ge.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ge.ResultReason.EnrolledVoiceProfile:ge.ResultReason.Canceled,s=new i(n,null,null);s.privDetails=this.getIdentificationDetails(r),t.push(s)}return t}static FromVerificationProfileList(e){let t=[];for(let r of e.value){let n=r.enrollmentStatus.toLowerCase()==="enrolling"?ge.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ge.ResultReason.EnrolledVoiceProfile:ge.ResultReason.Canceled,s=new i(n,null,null);s.privDetails=this.getVerificationDetails(r),t.push(s)}return t}static getIdentificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount||0,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.identificationProfileId,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}static getVerificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.verificationProfileId,remainingEnrollmentsCount:e.remainingEnrollments||e.remainingEnrollmentsCount,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}};Ri.VoiceProfileEnrollmentResult=Sd;var yd=class i extends ge.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=ge.CancellationReason.Error,r=ge.CancellationErrorCode.NoError;return e.properties&&(r=ge.CancellationErrorCode[e.properties.getProperty(ey.CancellationErrorCodePropertyName,ge.CancellationErrorCode[ge.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ri.VoiceProfileEnrollmentCancellationDetails=yd});var iy=p(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.VoiceProfileCancellationDetails=Ei.VoiceProfileResult=void 0;var ry=C(),Zw=I(),wt=f(),Cd=class{constructor(e,t){this.privReason=e,this.privProperties=new wt.PropertyCollection,e===wt.ResultReason.Canceled&&(Zw.Contracts.throwIfNullOrUndefined(t,"statusText"),this.privErrorDetails=t,this.privProperties.setProperty(ry.CancellationErrorCodePropertyName,wt.CancellationErrorCode[wt.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get properties(){return this.privProperties}get errorDetails(){return this.privErrorDetails}};Ei.VoiceProfileResult=Cd;var Pd=class i extends wt.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=wt.CancellationReason.Error,r=wt.CancellationErrorCode.NoError;return e.properties&&(r=wt.CancellationErrorCode[e.properties.getProperty(ry.CancellationErrorCodePropertyName,wt.CancellationErrorCode[wt.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ei.VoiceProfileCancellationDetails=Pd});var ny=p(aa=>{"use strict";Object.defineProperty(aa,"__esModule",{value:!0});aa.VoiceProfilePhraseResult=void 0;var e_=I(),t_=f(),Rd=class extends t_.VoiceProfileResult{constructor(e,t,r,n){super(e,t),this.privPhrases=[],e_.Contracts.throwIfNullOrUndefined(n,"phrase array"),this.privType=r,n&&n[0]&&(this.privPhrases=n)}get phrases(){return this.privPhrases}get type(){return this.privType}};aa.VoiceProfilePhraseResult=Rd});var sy=p(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.VoiceProfileClient=void 0;var Ed=C(),r_=mh(),ca=I(),Lr=f(),Id=class extends Lr.Recognizer{constructor(e){ca.Contracts.throwIfNullOrUndefined(e,"speechConfig");let t=e;ca.Contracts.throwIfNull(t,"speechConfig"),super(r_.AudioConfig.fromStreamInput(Lr.AudioInputStream.createPushStream()),t.properties,new Ed.VoiceProfileConnectionFactory),this.privProperties=t.properties.clone(),this.privVoiceAdapter=this.privReco,this.privDisposedVoiceAdapter=!1}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Lr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){ca.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Lr.PropertyId.SpeechServiceAuthorization_Token,e)}async createProfileAsync(e,t){let r=await this.privVoiceAdapter.createProfile(e,t);return new Lr.VoiceProfile(r[0],e)}async retrieveEnrollmentResultAsync(e){return this.privVoiceAdapter.retrieveEnrollmentResult(e)}async getAllProfilesAsync(e){return this.privVoiceAdapter.getAllProfiles(e)}async getActivationPhrasesAsync(e,t){return this.privVoiceAdapter.getActivationPhrases(e,t)}async enrollProfileAsync(e,t){let r=t;return ca.Contracts.throwIfNullOrUndefined(r,"audioConfig"),this.audioConfig=t,this.privVoiceAdapter.SpeakerAudioSource=r,this.privVoiceAdapter.enrollProfile(e)}async deleteProfileAsync(e){return this.privVoiceAdapter.deleteProfile(e)}async resetProfileAsync(e){return this.privVoiceAdapter.resetProfile(e)}async close(){await this.dispose(!0)}createServiceRecognizer(e,t,r,n){let s=r;return new Ed.VoiceServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedVoiceAdapter||(this.privDisposedVoiceAdapter=!0,e&&await super.dispose(e))}createRecognizerConfig(e){return new Ed.RecognizerConfig(e,this.properties)}getResult(e,t){return new Lr.VoiceProfileResult(e.ok?t:Lr.ResultReason.Canceled,e.statusText)}};pa.VoiceProfileClient=Id});var oy=p(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.SpeakerRecognizer=void 0;var wd=C(),Br=I(),_d=f(),Td=class extends _d.Recognizer{constructor(e,t){Br.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;Br.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new wd.SpeakerRecognitionConnectionFactory),this.privAudioConfigImpl=t,Br.Contracts.throwIfNull(this.privAudioConfigImpl,"audioConfig"),this.privDisposedSpeakerRecognizer=!1,this.privProperties=r.properties}get authorizationToken(){return this.properties.getProperty(_d.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Br.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(_d.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}async recognizeOnceAsync(e){return Br.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),this.recognizeSpeakerOnceAsyncImpl(e)}async close(){Br.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.dispose(!0)}async recognizeSpeakerOnceAsyncImpl(e){Br.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.implRecognizerStop();let t=await this.privReco.recognizeSpeaker(e);return await this.implRecognizerStop(),t}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}createRecognizerConfig(e){return new wd.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new wd.SpeakerServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedSpeakerRecognizer||e&&(this.privDisposedSpeakerRecognizer=!0,await super.dispose(e))}};ua.SpeakerRecognizer=Td});var ay=p(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.SpeakerIdentificationModel=void 0;var i_=I(),n_=f(),Ad=class i{constructor(e){if(this.privVoiceProfiles=[],this.privProfileIds=[],i_.Contracts.throwIfNullOrUndefined(e,"VoiceProfiles"),e.length===0)throw new Error("Empty Voice Profiles array");for(let t of e){if(t.profileType!==n_.VoiceProfileType.TextIndependentIdentification)throw new Error("Identification model can only be created from Identification profile: "+t.profileId);this.privVoiceProfiles.push(t),this.privProfileIds.push(t.profileId)}}static fromProfiles(e){return new i(e)}get voiceProfileIds(){return this.privProfileIds.join(",")}get profileIds(){return this.privProfileIds}get scenario(){return"TextIndependentIdentification"}};ha.SpeakerIdentificationModel=Ad});var py=p(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.SpeakerVerificationModel=void 0;var s_=I(),cy=f(),bd=class i{constructor(e){if(s_.Contracts.throwIfNullOrUndefined(e,"VoiceProfile"),e.profileType===cy.VoiceProfileType.TextIndependentIdentification)throw new Error("Verification model cannot be created from Identification profile");this.privVoiceProfile=e}static fromProfile(e){return new i(e)}get voiceProfile(){return this.privVoiceProfile}get profileIds(){return[this.voiceProfile.profileId]}get scenario(){return this.voiceProfile.profileType===cy.VoiceProfileType.TextDependentVerification?"TextDependentVerification":"TextIndependentVerification"}};da.SpeakerVerificationModel=bd});var Od=p(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.LanguageIdMode=void 0;var o_;(function(i){i[i.AtStart=0]="AtStart",i[i.Continuous=1]="Continuous"})(o_=On.LanguageIdMode||(On.LanguageIdMode={}))});var hy=p(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.AutoDetectSourceLanguageConfig=void 0;var a_=C(),c_=I(),_t=f(),uy=Od(),Md=class i{constructor(){this.privProperties=new _t.PropertyCollection,this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart"),this.privLanguageIdMode=uy.LanguageIdMode.AtStart}static fromOpenRange(){let e=new i;return e.properties.setProperty(_t.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,a_.AutoDetectSourceLanguagesOpenRangeOptionName),e}static fromLanguages(e){c_.Contracts.throwIfArrayEmptyOrWhitespace(e,"languages");let t=new i;return t.properties.setProperty(_t.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e.join()),t}static fromSourceLanguageConfigs(e){if(e.length<1)throw new Error("Expected non-empty SourceLanguageConfig array.");let t=new i,r=[];return e.forEach(n=>{if(r.push(n.language),n.endpointId!==void 0&&n.endpointId!==""){let s=n.language+_t.PropertyId.SpeechServiceConnection_EndpointId.toString();t.properties.setProperty(s,n.endpointId)}}),t.properties.setProperty(_t.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,r.join()),t}get properties(){return this.privProperties}set mode(e){e===uy.LanguageIdMode.Continuous?(this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_LanguageIdMode,"Continuous")):(this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"1"),this.privProperties.setProperty(_t.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart")),this.privLanguageIdMode=e}};la.AutoDetectSourceLanguageConfig=Md});var ly=p(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});va.AutoDetectSourceLanguageResult=void 0;var dy=I(),Dd=class i{constructor(e,t){dy.Contracts.throwIfNullOrUndefined(e,"language"),dy.Contracts.throwIfNullOrUndefined(t,"languageDetectionConfidence"),this.privLanguage=e,this.privLanguageDetectionConfidence=t}static fromResult(e){return new i(e.language,e.languageDetectionConfidence)}static fromConversationTranscriptionResult(e){return new i(e.language,e.languageDetectionConfidence)}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}};va.AutoDetectSourceLanguageResult=Dd});var vy=p(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.SourceLanguageConfig=void 0;var p_=I(),kd=class i{constructor(e,t){p_.Contracts.throwIfNullOrUndefined(e,"language"),this.privLanguage=e,this.privEndpointId=t}static fromLanguage(e,t){return new i(e,t)}get language(){return this.privLanguage}get endpointId(){return this.privEndpointId}};fa.SourceLanguageConfig=kd});var gy=p(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.SpeakerRecognitionCancellationDetails=Wt.SpeakerRecognitionResult=Wt.SpeakerRecognitionResultType=void 0;var fy=C(),Le=f(),ga;(function(i){i[i.Verify=0]="Verify",i[i.Identify=1]="Identify"})(ga=Wt.SpeakerRecognitionResultType||(Wt.SpeakerRecognitionResultType={}));var Nd=class{constructor(e,t=Le.ResultReason.RecognizedSpeaker,r=Le.CancellationErrorCode.NoError,n=""){this.privProperties=new Le.PropertyCollection;let s=e.scenario==="TextIndependentIdentification"?ga.Identify:ga.Verify;this.privReason=t,this.privReason!==Le.ResultReason.Canceled?s===ga.Identify?(this.privProfileId=e.identificationResult.identifiedProfile.profileId,this.privScore=e.identificationResult.identifiedProfile.score,this.privReason=Le.ResultReason.RecognizedSpeakers):(this.privScore=e.verificationResult.score,e.verificationResult.recognitionResult.toLowerCase()!=="accept"&&(this.privReason=Le.ResultReason.NoMatch),e.verificationResult.profileId!==void 0&&e.verificationResult.profileId!==""&&(this.privProfileId=e.verificationResult.profileId)):(this.privErrorDetails=n,this.privProperties.setProperty(fy.CancellationErrorCodePropertyName,Le.CancellationErrorCode[r])),this.privProperties.setProperty(Le.PropertyId.SpeechServiceResponse_JsonResult,JSON.stringify(e))}get properties(){return this.privProperties}get reason(){return this.privReason}get profileId(){return this.privProfileId}get errorDetails(){return this.privErrorDetails}get score(){return this.privScore}};Wt.SpeakerRecognitionResult=Nd;var qd=class i extends Le.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=Le.CancellationReason.Error,r=Le.CancellationErrorCode.NoError;return e.properties&&(r=Le.CancellationErrorCode[e.properties.getProperty(fy.CancellationErrorCodePropertyName,Le.CancellationErrorCode[Le.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Wt.SpeakerRecognitionCancellationDetails=qd});var xd=p(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.ConversationImpl=Ii.Conversation=void 0;var x=C(),Mn=P(),S=I(),q=f(),ma=class{constructor(){}static createConversationAsync(e,t,r,n){S.Contracts.throwIfNullOrUndefined(e,x.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),S.Contracts.throwIfNullOrUndefined(e.region,x.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),!e.subscriptionKey&&!e.getProperty(q.PropertyId[q.PropertyId.SpeechServiceAuthorization_Token])&&S.Contracts.throwIfNullOrUndefined(e.subscriptionKey,x.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s,o,a;return typeof t=="string"?(s=new Dn(e,t),Mn.marshalPromiseToCallbacks((async()=>{})(),r,n)):(s=new Dn(e),o=t,a=r,s.createConversationAsync(()=>{o&&o()},c=>{a&&a(c)})),s}};Ii.Conversation=ma;var Dn=class extends ma{constructor(e,t){if(super(),this.privErrors=x.ConversationConnectionConfig.restErrors,this.onConnected=s=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,s)}catch{}},this.onDisconnected=s=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,s)}catch{}finally{this.close(!1)}},this.onCanceled=(s,o)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,o)}catch{}},this.onParticipantUpdateCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.id);if(a!==void 0){switch(o.key){case x.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case x.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case x.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case x.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case x.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.Updated,[this.toParticipant(a)],o.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(s,o)=>{try{this.privParticipants.participants.forEach(a=>a.isMuted=a.isHost?!1:o.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.Updated,this.toParticipants(!1),o.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(s,o)=>{try{let a=this.privParticipants.addOrUpdateParticipant(o.participant);a!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.JoinedConversation,[this.toParticipant(a)],o.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.participant.id);a!==void 0&&(this.privParticipants.deleteParticipant(o.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case x.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new q.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case x.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new q.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case x.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new q.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break}}catch{}},this.onParticipantsListReceived=(s,o)=>{try{if(o.sessionToken!==void 0&&o.sessionToken!==null&&(this.privRoom.token=o.sessionToken),this.privParticipants.participants=[...o.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new q.ConversationParticipantsChangedEventArgs(q.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(q.PropertyId.ConversationTranslator_Name);a!==void 0&&a.length>0&&a!==this.me.displayName&&this.changeNicknameAsync(a)}}catch{}},this.onConversationExpiration=(s,o)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,o)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new q.PropertyCollection,this.privManager=new x.ConversationManager,e.getProperty(q.PropertyId[q.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(q.PropertyId[q.PropertyId.SpeechServiceConnection_RecoLanguage],x.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(q.PropertyId[q.PropertyId.SpeechServiceConnection_RecoLanguage]),t)this.privConversationId=t;else{e.targetLanguages.length===0&&e.addTargetLanguage(this.privLanguage),e.getProperty(q.PropertyId[q.PropertyId.SpeechServiceResponse_ProfanityOption])||e.setProfanity(q.ProfanityOption.Masked);let o=e.getProperty(q.PropertyId[q.PropertyId.ConversationTranslator_Name]);o==null&&(o="Host"),S.Contracts.throwIfNullOrTooLong(o,"nickname",50),S.Contracts.throwIfNullOrTooShort(o,"nickname",2),e.setProperty(q.PropertyId[q.PropertyId.ConversationTranslator_Name],o)}this.privConfig=e;let n=e;S.Contracts.throwIfNull(n,"speechConfig"),this.privProperties=n.properties.clone(),this.privIsConnected=!1,this.privParticipants=new x.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get conversationId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return this.privParticipants.me?.isHost?!1:this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get conversationInfo(){let e=this.conversationId,t=this.participants.map(s=>({id:s.id,preferredLanguage:s.preferredLanguage,voice:s.voice})),r={};for(let s of x.ConversationConnectionConfig.transcriptionEventKeys){let o=this.properties.getProperty(s,"");o!==""&&(r[s]=o)}return{id:e,participants:t,conversationProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){S.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}set conversationTranslator(e){this.privConversationTranslator=e}onToken(e){this.privConversationTranslator.onToken(e)}createConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}startConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer=x.ConversationRecognizerFactory.fromConfig(this,this.privConfig),this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.disconnected=this.onDisconnected,this.privConversationRecognizer.canceled=this.onCanceled,this.privConversationRecognizer.participantUpdateCommandReceived=this.onParticipantUpdateCommandReceived,this.privConversationRecognizer.lockRoomCommandReceived=this.onLockRoomCommandReceived,this.privConversationRecognizer.muteAllCommandReceived=this.onMuteAllCommandReceived,this.privConversationRecognizer.participantJoinCommandReceived=this.onParticipantJoinCommandReceived,this.privConversationRecognizer.participantLeaveCommandReceived=this.onParticipantLeaveCommandReceived,this.privConversationRecognizer.translationReceived=this.onTranslationReceived,this.privConversationRecognizer.participantsListReceived=this.onParticipantsListReceived,this.privConversationRecognizer.conversationExpiration=this.onConversationExpiration,this.privConversationRecognizer.connect(this.privRoom.token,()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}addParticipantAsync(e,t,r){S.Contracts.throwIfNullOrUndefined(e,"Participant"),Mn.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),t,r)}joinConversationAsync(e,t,r,n,s){try{S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),S.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),S.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,o=>{S.Contracts.throwIfNullOrUndefined(o,this.privErrors.permissionDeniedConnect),this.privRoom=o,this.privConfig.authorizationToken=o.cognitiveSpeechAuthToken,n&&n(o.cognitiveSpeechAuthToken)},o=>{this.handleError(o,s)})}catch(o){this.handleError(o,s)}}deleteConversationAsync(e,t){Mn.marshalPromiseToCallbacks(this.deleteConversationImplAsync(),e,t)}async deleteConversationImplAsync(){S.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),S.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endConversationAsync(e,t){Mn.marshalPromiseToCallbacks(this.endConversationImplAsync(),e,t)}endConversationImplAsync(){return this.close(!0)}lockConversationAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteAllParticipantsAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteParticipantAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}removeParticipantAsync(e,t,r){try{if(S.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))Mn.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),t,r);else{S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let n="";typeof e=="string"?n=e:e.hasOwnProperty("id")?n=e.id:e.hasOwnProperty("userId")&&(n=e.userId),S.Contracts.throwIfNullOrWhitespace(n,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(o=>o.id===n)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(n),()=>{this.handleCallback(t,r)},o=>{this.handleError(o,r)})}}catch(n){this.handleError(n,r)}}unlockConversationAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteAllParticipantsAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteParticipantAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}sendTextMessageAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}setTranslatedLanguagesAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}changeNicknameAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),this.privConfig=void 0,this.privLanguage=void 0,this.privProperties=void 0,this.privRoom=void 0,this.privToken=void 0,this.privManager=void 0,this.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.conversation=this}getKeepAlive(){let e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){let r=this.conversationInfo;return r.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(r,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);let t=this.conversationInfo;return t.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await this.privConversationRecognizer?.close(),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(t){throw t}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){let t=this.privParticipants.participants.map(r=>this.toParticipant(r));return e?t:t.filter(r=>r.isHost===!1)}toParticipant(e){return new q.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"nickname"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:x.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:x.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),S.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:x.ConversationTranslatorMessageTypes.instantMessage})}};Ii.ConversationImpl=Dn});var my=p(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.ConversationCommon=void 0;var zd=class{constructor(e){this.privAudioConfig=e}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}};Sa.ConversationCommon=zd});var Sy=p(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.ConversationExpirationEventArgs=void 0;var u_=f(),jd=class extends u_.SessionEventArgs{constructor(e,t){super(t),this.privExpirationTime=e}get expirationTime(){return this.privExpirationTime}};ya.ConversationExpirationEventArgs=jd});var yy=p(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.ConversationParticipantsChangedEventArgs=void 0;var h_=f(),Ld=class extends h_.SessionEventArgs{constructor(e,t,r){super(r),this.privReason=e,this.privParticipant=t}get reason(){return this.privReason}get participants(){return this.privParticipant}};Ca.ConversationParticipantsChangedEventArgs=Ld});var Cy=p(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.ConversationTranslationCanceledEventArgs=void 0;var d_=vi(),Bd=class extends d_.CancellationEventArgsBase{};Pa.ConversationTranslationCanceledEventArgs=Bd});var Py=p(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.ConversationTranslationEventArgs=void 0;var l_=f(),Fd=class extends l_.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};Ra.ConversationTranslationEventArgs=Fd});var Ry=p(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.ConversationTranslationResult=void 0;var v_=Nh(),Vd=class extends v_.TranslationRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(t,n,s,o,a,c,void 0,void 0,u,h,d),this.privId=e,this.privOrigLang=r}get participantId(){return this.privId}get originalLang(){return this.privOrigLang}};Ea.ConversationTranslationResult=Vd});var Wd=p(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.StringUtils=void 0;var Ud=class{static formatString(e,t){if(!e)return"";if(!t)return e;let r="",n="",s=c=>{r+=c},o=c=>{n+=c},a=s;for(let c=0;c<e.length;c++){let u=e[c],h=c+1<e.length?e[c+1]:"";switch(u){case"{":h==="{"?(a("{"),c++):a=o;break;case"}":h==="}"?(a("}"),c++):(t.hasOwnProperty(n)&&(r+=t[n]),a=s,n="");break;default:a(u);break}}return r}};Ia.StringUtils=Ud});var wy=p(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.ConversationTranslatorConnectionFactory=void 0;var Hd=pe(),Ey=Wd(),f_=I(),wa=f(),g_=we(),Xe=Ut(),Iy=Ye(),Kd=C(),_a=class i extends Iy.ConnectionFactoryBase{constructor(e){super(),f_.Contracts.throwIfNullOrUndefined(e,"convGetter"),this.privConvGetter=e}create(e,t,r){let n=e.parameters.getProperty("ConversationTranslator_MultiChannelAudio","").toUpperCase()==="TRUE",s=this.privConvGetter().room,o=s.cognitiveSpeechRegion||e.parameters.getProperty(wa.PropertyId.SpeechServiceConnection_Region,""),a={hostSuffix:Iy.ConnectionFactoryBase.getHostSuffix(o),path:i.CTS_VIRT_MIC_PATH,region:encodeURIComponent(o)};a[Xe.QueryParameterNames.Language]=encodeURIComponent(e.parameters.getProperty(wa.PropertyId.SpeechServiceConnection_RecoLanguage,"")),a[Xe.QueryParameterNames.CtsMeetingId]=encodeURIComponent(s.roomId),a[Xe.QueryParameterNames.CtsDeviceId]=encodeURIComponent(s.participantId),a[Xe.QueryParameterNames.CtsIsParticipant]=s.isHost?"":"&"+Xe.QueryParameterNames.CtsIsParticipant;let c="",u={},h={};if(n){c=e.parameters.getProperty(wa.PropertyId.SpeechServiceConnection_Endpoint),c||(c="wss://"+e.parameters.getProperty(wa.PropertyId.SpeechServiceConnection_Host,"transcribe.{region}.cts.speech{hostSuffix}")+"{path}"),c=Ey.StringUtils.formatString(c,a);let v=new URL(c);v.searchParams.forEach((w,k)=>{u[k]=w}),new Kd.TranscriberConnectionFactory().setQueryParams(u,e,c),u[Xe.QueryParameterNames.CtsMeetingId]=a[Xe.QueryParameterNames.CtsMeetingId],u[Xe.QueryParameterNames.CtsDeviceId]=a[Xe.QueryParameterNames.CtsDeviceId],s.isHost||(u[Xe.QueryParameterNames.CtsIsParticipant]=""),Xe.QueryParameterNames.Format in u||(u[Xe.QueryParameterNames.Format]="simple"),v.searchParams.forEach((w,k)=>{v.searchParams.set(k,u[k]),delete u[k]}),c=v.toString()}else{let v=new Kd.TranslationConnectionFactory;c=v.getEndpointUrl(e,!0),c=Ey.StringUtils.formatString(c,a),v.setQueryParams(u,e,c)}h[g_.HeaderNames.ConnectionId]=r,h[Hd.RestConfigBase.configParams.token]=s.token,t.token&&(h[t.headerName]=t.token);let d=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","").toUpperCase()==="TRUE";return new Hd.WebsocketConnection(c,u,h,new Kd.WebsocketMessageFormatter,Hd.ProxyInfo.fromRecognizerConfig(e),d,r)}};Ta.ConversationTranslatorConnectionFactory=_a;_a.CTS_VIRT_MIC_PATH="/speech/recognition/dynamicaudio"});var Ty=p(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.ConversationTranslator=Fr.SpeechState=void 0;var kn=C(),m_=wy(),Aa=P(),vt=I(),V=f(),S_=xd(),_y=ba(),ft;(function(i){i[i.Inactive=0]="Inactive",i[i.Connecting=1]="Connecting",i[i.Connected=2]="Connected"})(ft=Fr.SpeechState||(Fr.SpeechState={}));var Jd=class extends V.TranslationRecognizer{constructor(e,t,r,n){super(e,t,new m_.ConversationTranslatorConnectionFactory(n)),this.privSpeechState=ft.Inactive,r&&(this.privTranslator=r,this.sessionStarted=()=>{this.privSpeechState=ft.Connected},this.sessionStopped=()=>{this.privSpeechState=ft.Inactive},this.recognizing=(s,o)=>{this.privTranslator.recognizing&&this.privTranslator.recognizing(this.privTranslator,o)},this.recognized=async(s,o)=>{o.result?.errorDetails?(await this.cancelSpeech(),this.fireCancelEvent(o.result.errorDetails)):this.privTranslator.recognized&&this.privTranslator.recognized(this.privTranslator,o)},this.canceled=async()=>{if(this.privSpeechState!==ft.Inactive)try{await this.cancelSpeech()}catch{this.privSpeechState=ft.Inactive}})}get state(){return this.privSpeechState}set state(e){this.privSpeechState=e}set authentication(e){this.privReco.authentication=e}onConnection(){this.privSpeechState=ft.Connected}async onCancelSpeech(){this.privSpeechState=ft.Inactive,await this.cancelSpeech()}fireCancelEvent(e){try{if(this.privTranslator.canceled){let t=new _y.ConversationTranslationCanceledEventArgs(V.CancellationReason.Error,e,V.CancellationErrorCode.RuntimeError);this.privTranslator.canceled(this.privTranslator,t)}}catch{}}async cancelSpeech(){try{this.stopContinuousRecognitionAsync(),await this.privReco?.disconnect(),this.privSpeechState=ft.Inactive}catch{}}},Gd=class extends _y.ConversationCommon{constructor(e){super(e),this.privErrors=kn.ConversationConnectionConfig.restErrors,this.privIsDisposed=!1,this.privIsSpeaking=!1,this.privPlaceholderKey="abcdefghijklmnopqrstuvwxyz012345",this.privPlaceholderRegion="westus",this.privProperties=new V.PropertyCollection}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get participants(){return this.privConversation?.participants}get canSpeak(){return!(!this.privConversation.isConnected||!this.privCTRecognizer||this.privIsSpeaking||this.privCTRecognizer.state===ft.Connected||this.privCTRecognizer.state===ft.Connecting||this.privConversation.isMutedByHost)}onToken(e){this.privCTRecognizer.authentication=e}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(kn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(kn.ServicePropertiesPropertyName,JSON.stringify(r))}joinConversationAsync(e,t,r,n,s){try{if(typeof e=="string"){vt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),vt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privConversation&&this.handleError(new Error(this.privErrors.permissionDeniedStart),s);let o=r;(o==null||o==="")&&(o=kn.ConversationConnectionConfig.defaultLanguageCode),this.privSpeechTranslationConfig=V.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey,this.privPlaceholderRegion),this.privSpeechTranslationConfig.setProfanity(V.ProfanityOption.Masked),this.privSpeechTranslationConfig.addTargetLanguage(o),this.privSpeechTranslationConfig.setProperty(V.PropertyId[V.PropertyId.SpeechServiceConnection_RecoLanguage],o),this.privSpeechTranslationConfig.setProperty(V.PropertyId[V.PropertyId.ConversationTranslator_Name],t);let a=[V.PropertyId.SpeechServiceConnection_Host,V.PropertyId.ConversationTranslator_Host,V.PropertyId.SpeechServiceConnection_Endpoint,V.PropertyId.SpeechServiceConnection_ProxyHostName,V.PropertyId.SpeechServiceConnection_ProxyPassword,V.PropertyId.SpeechServiceConnection_ProxyPort,V.PropertyId.SpeechServiceConnection_ProxyUserName,"ConversationTranslator_MultiChannelAudio","ConversationTranslator_Region"];for(let u of a){let h=this.privProperties.getProperty(u);if(h){let d=typeof u=="string"?u:V.PropertyId[u];this.privSpeechTranslationConfig.setProperty(d,h)}}let c=JSON.parse(this.privProperties.getProperty(kn.ServicePropertiesPropertyName,"{}"));for(let u of Object.keys(c))this.privSpeechTranslationConfig.setServiceProperty(u,c[u],V.ServicePropertyChannel.UriQueryParameter);this.privConversation=new S_.ConversationImpl(this.privSpeechTranslationConfig),this.privConversation.conversationTranslator=this,this.privConversation.joinConversationAsync(e,t,o,u=>{u||this.handleError(new Error(this.privErrors.permissionDeniedConnect),s),this.privSpeechTranslationConfig.authorizationToken=u,this.privConversation.room.isHost=!1,this.privConversation.startConversationAsync(()=>{this.handleCallback(n,s)},h=>{this.handleError(h,s)})},u=>{this.handleError(u,s)})}else typeof e=="object"?(vt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),vt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privProperties.setProperty(V.PropertyId.ConversationTranslator_Name,t),this.privConversation=e,this.privConversation.conversationTranslator=this,this.privConversation.room.isHost=!0,vt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedConnect),vt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privSpeechTranslationConfig=e.config,this.handleCallback(r,n)):this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","invalid conversation type")),n)}catch(o){this.handleError(o,typeof r=="string"?s:n)}}leaveConversationAsync(e,t){Aa.marshalPromiseToCallbacks((async()=>{await this.cancelSpeech(),await this.privConversation.endConversationImplAsync(),await this.privConversation.deleteConversationImplAsync(),this.dispose()})(),e,t)}sendTextMessageAsync(e,t,r){try{vt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),vt.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}",e)),this.privConversation.sendTextMessageAsync(e,t,r)}catch(n){this.handleError(n,r)}}startTranscribingAsync(e,t){Aa.marshalPromiseToCallbacks((async()=>{try{vt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),vt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privCTRecognizer===void 0&&await this.connectTranslatorRecognizer(),vt.Contracts.throwIfNullOrUndefined(this.privCTRecognizer,this.privErrors.permissionDeniedSend),this.canSpeak||this.handleError(new Error(this.privErrors.permissionDeniedSend),t),await this.startContinuousRecognition(),this.privIsSpeaking=!0}catch(r){throw this.privIsSpeaking=!1,await this.cancelSpeech(),r}})(),e,t)}stopTranscribingAsync(e,t){Aa.marshalPromiseToCallbacks((async()=>{try{if(!this.privIsSpeaking){await this.cancelSpeech();return}this.privIsSpeaking=!1,await new Promise((r,n)=>{this.privCTRecognizer.stopContinuousRecognitionAsync(r,n)})}catch{await this.cancelSpeech()}})(),e,t)}isDisposed(){return this.privIsDisposed}dispose(e,t,r){Aa.marshalPromiseToCallbacks((async()=>{this.isDisposed&&!this.privIsSpeaking||(await this.cancelSpeech(),this.privIsDisposed=!0,this.privSpeechTranslationConfig.close(),this.privSpeechRecognitionLanguage=void 0,this.privProperties=void 0,this.privAudioConfig=void 0,this.privSpeechTranslationConfig=void 0,this.privConversation.dispose(),this.privConversation=void 0)})(),t,r)}async cancelSpeech(){try{this.privIsSpeaking=!1,await this.privCTRecognizer?.onCancelSpeech(),this.privCTRecognizer=void 0}catch{}}async connectTranslatorRecognizer(){try{this.privAudioConfig===void 0&&(this.privAudioConfig=V.AudioConfig.fromDefaultMicrophoneInput()),this.privSpeechTranslationConfig.getProperty(V.PropertyId[V.PropertyId.SpeechServiceConnection_Key])===this.privPlaceholderKey&&this.privSpeechTranslationConfig.setProperty(V.PropertyId[V.PropertyId.SpeechServiceConnection_Key],"");let e=()=>this.privConversation;this.privCTRecognizer=new Jd(this.privSpeechTranslationConfig,this.privAudioConfig,this,e)}catch(e){throw await this.cancelSpeech(),e}}startContinuousRecognition(){return new Promise((e,t)=>{this.privCTRecognizer.startContinuousRecognitionAsync(e,t)})}};Fr.ConversationTranslator=Gd});var Ay=p(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});Oa.ConversationTranscriber=void 0;var Nn=C(),$d=P(),Vr=I(),ke=f(),Qd=class i extends ke.Recognizer{constructor(e,t){let r=e;Vr.Contracts.throwIfNull(r,"speechConfig"),Vr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(ke.PropertyId.SpeechServiceConnection_RecoLanguage),ke.PropertyId[ke.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Nn.ConversationTranscriberConnectionFactory),this.privProperties.setProperty(ke.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get endpointId(){return Vr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ke.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(ke.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Vr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(ke.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return Vr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ke.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return Vr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Nn.OutputFormatPropertyName,ke.OutputFormat[ke.OutputFormat.Simple])===ke.OutputFormat[ke.OutputFormat.Simple]?ke.OutputFormat.Simple:ke.OutputFormat.Detailed}get properties(){return this.privProperties}startTranscribingAsync(e,t){$d.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Nn.RecognitionMode.Conversation),e,t)}stopTranscribingAsync(e,t){$d.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}close(e,t){Vr.Contracts.throwIfDisposed(this.privDisposedRecognizer),$d.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new Nn.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return n.isSpeakerDiarizationEnabled=!0,new Nn.ConversationTranscriptionServiceRecognizer(e,t,s,n,this)}};Oa.ConversationTranscriber=Qd});var by=p(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.Participant=wi.User=void 0;var y_=f(),Yd=class{constructor(e){this.privUserId=e}get userId(){return this.privUserId}};wi.User=Yd;var Xd=class i{constructor(e,t,r,n,s,o,a,c){this.privId=e,this.privAvatar=t,this.privDisplayName=r,this.privIsHost=n,this.privIsMuted=s,this.privIsUsingTts=o,this.privPreferredLanguage=a,this.privVoice=c,this.privProperties=new y_.PropertyCollection}get avatar(){return this.privAvatar}get displayName(){return this.privDisplayName}get id(){return this.privId}get preferredLanguage(){return this.privPreferredLanguage}get isHost(){return this.privIsHost}get isMuted(){return this.privIsMuted}get isUsingTts(){return this.privIsUsingTts}get voice(){return this.privVoice}get properties(){return this.privProperties}static From(e,t,r){return new i(e,"",e,!1,!1,!1,t,r)}};wi.Participant=Xd});var Oy=p(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.ParticipantChangedReason=void 0;var C_;(function(i){i[i.JoinedConversation=0]="JoinedConversation",i[i.LeftConversation=1]="LeftConversation",i[i.Updated=2]="Updated"})(C_=qn.ParticipantChangedReason||(qn.ParticipantChangedReason={}))});var My=p(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.MeetingImpl=_i.Meeting=void 0;var j=C(),xn=P(),y=I(),H=f(),Ma=class{constructor(){}static createMeetingAsync(e,t,r,n){if(y.Contracts.throwIfNullOrUndefined(e,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),y.Contracts.throwIfNullOrUndefined(e.region,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),y.Contracts.throwIfNull(t,"meetingId"),t.length===0)throw new Error("meetingId cannot be empty");!e.subscriptionKey&&!e.getProperty(H.PropertyId[H.PropertyId.SpeechServiceAuthorization_Token])&&y.Contracts.throwIfNullOrUndefined(e.subscriptionKey,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s=new Da(e,t);return xn.marshalPromiseToCallbacks((async()=>{})(),r,n),s}};_i.Meeting=Ma;var Da=class extends Ma{constructor(e,t){super(),this.privErrors=j.ConversationConnectionConfig.restErrors,this.onConnected=s=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,s)}catch{}},this.onDisconnected=s=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,s)}catch{}finally{this.close(!1)}},this.onCanceled=(s,o)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,o)}catch{}},this.onParticipantUpdateCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.id);if(a!==void 0){switch(o.key){case j.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case j.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case j.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case j.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case j.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.Updated,[this.toParticipant(a)],o.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(s,o)=>{try{this.privParticipants.participants.forEach(a=>a.isMuted=a.isHost?!1:o.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.Updated,this.toParticipants(!1),o.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(s,o)=>{try{let a=this.privParticipants.addOrUpdateParticipant(o.participant);a!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.JoinedConversation,[this.toParticipant(a)],o.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.participant.id);a!==void 0&&(this.privParticipants.deleteParticipant(o.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case j.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new H.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new H.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new H.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break}}catch{}},this.onParticipantsListReceived=(s,o)=>{try{if(o.sessionToken!==void 0&&o.sessionToken!==null&&(this.privRoom.token=o.sessionToken),this.privParticipants.participants=[...o.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(H.PropertyId.ConversationTranslator_Name);a!==void 0&&a.length>0&&a!==this.me.displayName&&this.changeNicknameAsync(a)}}catch{}},this.onConversationExpiration=(s,o)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,o)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new H.PropertyCollection,this.privManager=new j.ConversationManager,e.getProperty(H.PropertyId[H.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(H.PropertyId[H.PropertyId.SpeechServiceConnection_RecoLanguage],j.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(H.PropertyId[H.PropertyId.SpeechServiceConnection_RecoLanguage]),this.privConversationId=t,this.privConfig=e;let n=e;y.Contracts.throwIfNull(n,"speechConfig"),this.privProperties=n.properties.clone(),this.privIsConnected=!1,this.privParticipants=new j.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get meetingId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return this.privParticipants.me?.isHost?!1:this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get meetingInfo(){let e=this.meetingId,t=this.participants.map(s=>({id:s.id,preferredLanguage:s.preferredLanguage,voice:s.voice})),r={};for(let s of j.ConversationConnectionConfig.transcriptionEventKeys){let o=this.properties.getProperty(s,"");o!==""&&(r[s]=o)}return{id:e,participants:t,meetingProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){y.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}createMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}startMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.disconnected=this.onDisconnected,this.privConversationRecognizer.canceled=this.onCanceled,this.privConversationRecognizer.participantUpdateCommandReceived=this.onParticipantUpdateCommandReceived,this.privConversationRecognizer.lockRoomCommandReceived=this.onLockRoomCommandReceived,this.privConversationRecognizer.muteAllCommandReceived=this.onMuteAllCommandReceived,this.privConversationRecognizer.participantJoinCommandReceived=this.onParticipantJoinCommandReceived,this.privConversationRecognizer.participantLeaveCommandReceived=this.onParticipantLeaveCommandReceived,this.privConversationRecognizer.translationReceived=this.onTranslationReceived,this.privConversationRecognizer.participantsListReceived=this.onParticipantsListReceived,this.privConversationRecognizer.conversationExpiration=this.onConversationExpiration,this.privConversationRecognizer.connect(this.privRoom.token,()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}addParticipantAsync(e,t,r){y.Contracts.throwIfNullOrUndefined(e,"Participant"),xn.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),t,r)}joinMeetingAsync(e,t,r,n,s){try{y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),y.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),y.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,o=>{y.Contracts.throwIfNullOrUndefined(o,this.privErrors.permissionDeniedConnect),this.privRoom=o,this.privConfig.authorizationToken=o.cognitiveSpeechAuthToken,n&&n(o.cognitiveSpeechAuthToken)},o=>{this.handleError(o,s)})}catch(o){this.handleError(o,s)}}deleteMeetingAsync(e,t){xn.marshalPromiseToCallbacks(this.deleteMeetingImplAsync(),e,t)}async deleteMeetingImplAsync(){y.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),y.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endMeetingAsync(e,t){xn.marshalPromiseToCallbacks(this.endMeetingImplAsync(),e,t)}endMeetingImplAsync(){return this.close(!0)}lockMeetingAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteAllParticipantsAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteParticipantAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}removeParticipantAsync(e,t,r){try{if(y.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))xn.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),t,r);else{y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let n="";typeof e=="string"?n=e:e.hasOwnProperty("id")?n=e.id:e.hasOwnProperty("userId")&&(n=e.userId),y.Contracts.throwIfNullOrWhitespace(n,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(o=>o.id===n)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(n),()=>{this.handleCallback(t,r)},o=>{this.handleError(o,r)})}}catch(n){this.handleError(n,r)}}unlockMeetingAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteAllParticipantsAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteParticipantAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}sendTextMessageAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}setTranslatedLanguagesAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}changeNicknameAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),this.privConfig=void 0,this.privLanguage=void 0,this.privProperties=void 0,this.privRoom=void 0,this.privToken=void 0,this.privManager=void 0,this.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.meeting=this}getKeepAlive(){let e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){let r=this.meetingInfo;return r.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(r,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);let t=this.meetingInfo;return t.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await this.privConversationRecognizer?.close(),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(t){throw t}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){let t=this.privParticipants.participants.map(r=>this.toParticipant(r));return e?t:t.filter(r=>r.isHost===!1)}toParticipant(e){return new H.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingd"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(e,"nickname"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),y.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:j.ConversationTranslatorMessageTypes.instantMessage})}};_i.MeetingImpl=Da});var Dy=p(ka=>{"use strict";Object.defineProperty(ka,"__esModule",{value:!0});ka.MeetingTranscriptionCanceledEventArgs=void 0;var P_=vi(),Zd=class extends P_.CancellationEventArgsBase{};ka.MeetingTranscriptionCanceledEventArgs=Zd});var ky=p(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.MeetingTranscriber=void 0;var R_=C(),el=P(),zn=I(),jn=f(),E_=ba(),tl=class{constructor(e){this.privAudioConfig=e,this.privProperties=new jn.PropertyCollection,this.privRecognizer=void 0,this.privDisposedRecognizer=!1}get speechRecognitionLanguage(){return zn.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(jn.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get internalData(){return this.privRecognizer.internalData}get connection(){return jn.Connection.fromRecognizer(this.privRecognizer)}get authorizationToken(){return this.properties.getProperty(jn.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){zn.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(jn.PropertyId.SpeechServiceAuthorization_Token,e)}joinMeetingAsync(e,t,r){let n=e;zn.Contracts.throwIfNullOrUndefined(E_.MeetingImpl,"Meeting"),this.privRecognizer=new R_.TranscriberRecognizer(e.config,this.privAudioConfig),zn.Contracts.throwIfNullOrUndefined(this.privRecognizer,"Recognizer"),this.privRecognizer.connectMeetingCallbacks(this),el.marshalPromiseToCallbacks(n.connectTranscriberRecognizer(this.privRecognizer),t,r)}startTranscribingAsync(e,t){this.privRecognizer.startContinuousRecognitionAsync(e,t)}stopTranscribingAsync(e,t){this.privRecognizer.stopContinuousRecognitionAsync(e,t)}leaveMeetingAsync(e,t){this.privRecognizer.disconnectCallbacks(),el.marshalPromiseToCallbacks((async()=>{})(),e,t)}close(e,t){zn.Contracts.throwIfDisposed(this.privDisposedRecognizer),el.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(this.privRecognizer&&(await this.privRecognizer.close(),this.privRecognizer=void 0),e&&(this.privDisposedRecognizer=!0))}};Na.MeetingTranscriber=tl});var Ny=p(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.ConversationTranscriptionResult=void 0;var I_=f(),rl=class extends I_.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,h,d){super(e,t,r,n,s,o,a,u,h,d),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};qa.ConversationTranscriptionResult=rl});var ba=p(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});var qy=xd();Object.defineProperty(ne,"Conversation",{enumerable:!0,get:function(){return qy.Conversation}});Object.defineProperty(ne,"ConversationImpl",{enumerable:!0,get:function(){return qy.ConversationImpl}});var w_=my();Object.defineProperty(ne,"ConversationCommon",{enumerable:!0,get:function(){return w_.ConversationCommon}});var __=Sy();Object.defineProperty(ne,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return __.ConversationExpirationEventArgs}});var T_=yy();Object.defineProperty(ne,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return T_.ConversationParticipantsChangedEventArgs}});var A_=Cy();Object.defineProperty(ne,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return A_.ConversationTranslationCanceledEventArgs}});var b_=Py();Object.defineProperty(ne,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return b_.ConversationTranslationEventArgs}});var O_=Ry();Object.defineProperty(ne,"ConversationTranslationResult",{enumerable:!0,get:function(){return O_.ConversationTranslationResult}});var M_=Ty();Object.defineProperty(ne,"ConversationTranslator",{enumerable:!0,get:function(){return M_.ConversationTranslator}});var D_=Ay();Object.defineProperty(ne,"ConversationTranscriber",{enumerable:!0,get:function(){return D_.ConversationTranscriber}});var xy=by();Object.defineProperty(ne,"Participant",{enumerable:!0,get:function(){return xy.Participant}});Object.defineProperty(ne,"User",{enumerable:!0,get:function(){return xy.User}});var k_=Oy();Object.defineProperty(ne,"ParticipantChangedReason",{enumerable:!0,get:function(){return k_.ParticipantChangedReason}});var zy=My();Object.defineProperty(ne,"Meeting",{enumerable:!0,get:function(){return zy.Meeting}});Object.defineProperty(ne,"MeetingImpl",{enumerable:!0,get:function(){return zy.MeetingImpl}});var N_=Dy();Object.defineProperty(ne,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return N_.MeetingTranscriptionCanceledEventArgs}});var q_=ky();Object.defineProperty(ne,"MeetingTranscriber",{enumerable:!0,get:function(){return q_.MeetingTranscriber}});var x_=Ny();Object.defineProperty(ne,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return x_.ConversationTranscriptionResult}})});var xa=p(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});Ti.SynthesisRequest=Ti.Synthesizer=void 0;var Ur=C(),z_=P(),jy=I(),hr=f(),il=class i{constructor(e){let t=e;jy.Contracts.throwIfNull(t,"speechConfig"),this.privProperties=t.properties.clone(),this.privDisposed=!1,this.privSynthesizing=!1,this.synthesisRequestQueue=new z_.Queue}get authorizationToken(){return this.properties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){jy.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(hr.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get autoDetectSourceLanguage(){return this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)===Ur.AutoDetectSourceLanguagesOpenRangeOptionName}buildSsml(e){let t={"af-ZA":"af-ZA-AdriNeural","am-ET":"am-ET-AmehaNeural","ar-AE":"ar-AE-FatimaNeural","ar-BH":"ar-BH-AliNeural","ar-DZ":"ar-DZ-AminaNeural","ar-EG":"ar-EG-SalmaNeural","ar-IQ":"ar-IQ-BasselNeural","ar-JO":"ar-JO-SanaNeural","ar-KW":"ar-KW-FahedNeural","ar-LY":"ar-LY-ImanNeural","ar-MA":"ar-MA-JamalNeural","ar-QA":"ar-QA-AmalNeural","ar-SA":"ar-SA-HamedNeural","ar-SY":"ar-SY-AmanyNeural","ar-TN":"ar-TN-HediNeural","ar-YE":"ar-YE-MaryamNeural","bg-BG":"bg-BG-BorislavNeural","bn-BD":"bn-BD-NabanitaNeural","bn-IN":"bn-IN-BashkarNeural","ca-ES":"ca-ES-JoanaNeural","cs-CZ":"cs-CZ-AntoninNeural","cy-GB":"cy-GB-AledNeural","da-DK":"da-DK-ChristelNeural","de-AT":"de-AT-IngridNeural","de-CH":"de-CH-JanNeural","de-DE":"de-DE-KatjaNeural","el-GR":"el-GR-AthinaNeural","en-AU":"en-AU-NatashaNeural","en-CA":"en-CA-ClaraNeural","en-GB":"en-GB-LibbyNeural","en-HK":"en-HK-SamNeural","en-IE":"en-IE-ConnorNeural","en-IN":"en-IN-NeerjaNeural","en-KE":"en-KE-AsiliaNeural","en-NG":"en-NG-AbeoNeural","en-NZ":"en-NZ-MitchellNeural","en-PH":"en-PH-JamesNeural","en-SG":"en-SG-LunaNeural","en-TZ":"en-TZ-ElimuNeural","en-US":"en-US-JennyNeural","en-ZA":"en-ZA-LeahNeural","es-AR":"es-AR-ElenaNeural","es-BO":"es-BO-MarceloNeural","es-CL":"es-CL-CatalinaNeural","es-CO":"es-CO-GonzaloNeural","es-CR":"es-CR-JuanNeural","es-CU":"es-CU-BelkysNeural","es-DO":"es-DO-EmilioNeural","es-EC":"es-EC-AndreaNeural","es-ES":"es-ES-AlvaroNeural","es-GQ":"es-GQ-JavierNeural","es-GT":"es-GT-AndresNeural","es-HN":"es-HN-CarlosNeural","es-MX":"es-MX-DaliaNeural","es-NI":"es-NI-FedericoNeural","es-PA":"es-PA-MargaritaNeural","es-PE":"es-PE-AlexNeural","es-PR":"es-PR-KarinaNeural","es-PY":"es-PY-MarioNeural","es-SV":"es-SV-LorenaNeural","es-US":"es-US-AlonsoNeural","es-UY":"es-UY-MateoNeural","es-VE":"es-VE-PaolaNeural","et-EE":"et-EE-AnuNeural","fa-IR":"fa-IR-DilaraNeural","fi-FI":"fi-FI-SelmaNeural","fil-PH":"fil-PH-AngeloNeural","fr-BE":"fr-BE-CharlineNeural","fr-CA":"fr-CA-SylvieNeural","fr-CH":"fr-CH-ArianeNeural","fr-FR":"fr-FR-DeniseNeural","ga-IE":"ga-IE-ColmNeural","gl-ES":"gl-ES-RoiNeural","gu-IN":"gu-IN-DhwaniNeural","he-IL":"he-IL-AvriNeural","hi-IN":"hi-IN-MadhurNeural","hr-HR":"hr-HR-GabrijelaNeural","hu-HU":"hu-HU-NoemiNeural","id-ID":"id-ID-ArdiNeural","is-IS":"is-IS-GudrunNeural","it-IT":"it-IT-IsabellaNeural","ja-JP":"ja-JP-NanamiNeural","jv-ID":"jv-ID-DimasNeural","kk-KZ":"kk-KZ-AigulNeural","km-KH":"km-KH-PisethNeural","kn-IN":"kn-IN-GaganNeural","ko-KR":"ko-KR-SunHiNeural","lo-LA":"lo-LA-ChanthavongNeural","lt-LT":"lt-LT-LeonasNeural","lv-LV":"lv-LV-EveritaNeural","mk-MK":"mk-MK-AleksandarNeural","ml-IN":"ml-IN-MidhunNeural","mr-IN":"mr-IN-AarohiNeural","ms-MY":"ms-MY-OsmanNeural","mt-MT":"mt-MT-GraceNeural","my-MM":"my-MM-NilarNeural","nb-NO":"nb-NO-PernilleNeural","nl-BE":"nl-BE-ArnaudNeural","nl-NL":"nl-NL-ColetteNeural","pl-PL":"pl-PL-AgnieszkaNeural","ps-AF":"ps-AF-GulNawazNeural","pt-BR":"pt-BR-FranciscaNeural","pt-PT":"pt-PT-DuarteNeural","ro-RO":"ro-RO-AlinaNeural","ru-RU":"ru-RU-SvetlanaNeural","si-LK":"si-LK-SameeraNeural","sk-SK":"sk-SK-LukasNeural","sl-SI":"sl-SI-PetraNeural","so-SO":"so-SO-MuuseNeural","sr-RS":"sr-RS-NicholasNeural","su-ID":"su-ID-JajangNeural","sv-SE":"sv-SE-SofieNeural","sw-KE":"sw-KE-RafikiNeural","sw-TZ":"sw-TZ-DaudiNeural","ta-IN":"ta-IN-PallaviNeural","ta-LK":"ta-LK-KumarNeural","ta-SG":"ta-SG-AnbuNeural","te-IN":"te-IN-MohanNeural","th-TH":"th-TH-PremwadeeNeural","tr-TR":"tr-TR-AhmetNeural","uk-UA":"uk-UA-OstapNeural","ur-IN":"ur-IN-GulNeural","ur-PK":"ur-PK-AsadNeural","uz-UZ":"uz-UZ-MadinaNeural","vi-VN":"vi-VN-HoaiMyNeural","zh-CN":"zh-CN-XiaoxiaoNeural","zh-HK":"zh-HK-HiuMaanNeural","zh-TW":"zh-TW-HsiaoChenNeural","zu-ZA":"zu-ZA-ThandoNeural"},r=this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_SynthLanguage,"en-US"),n=this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_SynthVoice,""),s=i.XMLEncode(e);return this.autoDetectSourceLanguage?r="en-US":n=n||t[r],n&&(s=`<voice name='${n}'>${s}</voice>`),s=`<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts' xmlns:emo='http://www.w3.org/2009/10/emotionml' xml:lang='${r}'>${s}</speak>`,s}async dispose(e){this.privDisposed||(e&&this.privAdapter&&await this.privAdapter.dispose(),this.privDisposed=!0)}async adapterSpeak(){if(!this.privDisposed&&!this.privSynthesizing){this.privSynthesizing=!0;let e=await this.synthesisRequestQueue.dequeue();return this.privAdapter.Speak(e.text,e.isSSML,e.requestId,e.cb,e.err,e.dataStream)}}createSynthesizerConfig(e){return new Ur.SynthesizerConfig(e,this.privProperties)}implCommonSynthesizeSetup(){let e=typeof window<"u"?"Browser":"Node",t="unknown",r="unknown";typeof navigator<"u"&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);let n=this.createSynthesizerConfig(new Ur.SpeechServiceConfig(new Ur.Context(new Ur.OS(e,t,r)))),s=this.privProperties.getProperty(hr.PropertyId.SpeechServiceConnection_Key,void 0),o=s&&s!==""?new Ur.CognitiveSubscriptionKeyAuthentication(s):new Ur.CognitiveTokenAuthentication(()=>{let a=this.privProperties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(a)},()=>{let a=this.privProperties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(a)});this.privAdapter=this.createSynthesisAdapter(o,this.privConnectionFactory,n),this.privRestAdapter=this.createRestSynthesisAdapter(o,n)}static XMLEncode(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}};Ti.Synthesizer=il;var nl=class{constructor(e,t,r,n,s,o){this.requestId=e,this.text=t,this.isSSML=r,this.cb=n,this.err=s,this.dataStream=o}};Ti.SynthesisRequest=nl});var By=p(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.SpeechSynthesizer=void 0;var sl=C(),ol=P(),j_=lh(),L_=ui(),B_=br(),Ly=I(),dr=f(),F_=xa(),al=class i extends dr.Synthesizer{constructor(e,t){super(e),t!==null&&(t===void 0?this.audioConfig=typeof window>"u"?void 0:dr.AudioConfig.fromDefaultSpeakerOutput():this.audioConfig=t),this.privConnectionFactory=new sl.SpeechSynthesisConnectionFactory,this.implCommonSynthesizeSetup()}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}speakTextAsync(e,t,r,n){this.speakImpl(e,!1,t,r,n)}speakSsmlAsync(e,t,r,n){this.speakImpl(e,!0,t,r,n)}async getVoicesAsync(e=""){return this.getVoices(e)}close(e,t){Ly.Contracts.throwIfDisposed(this.privDisposed),ol.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privAdapter}createSynthesisAdapter(e,t,r){return new sl.SpeechSynthesisAdapter(e,t,r,this,this.audioConfig)}createRestSynthesisAdapter(e,t){return new sl.SynthesisRestAdapter(t,e)}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=L_.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(dr.SpeechSynthesisOutputFormat[this.properties.getProperty(dr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)])}speakImpl(e,t,r,n,s){try{Ly.Contracts.throwIfDisposed(this.privDisposed);let o=ol.createNoDashGuid(),a;s instanceof dr.PushAudioOutputStreamCallback?a=new B_.PushAudioOutputStreamImpl(s):s instanceof dr.PullAudioOutputStream?a=s:s!==void 0?a=new j_.AudioFileWriter(s):a=void 0,this.synthesisRequestQueue.enqueue(new F_.SynthesisRequest(o,e,t,c=>{if(this.privSynthesizing=!1,r)try{r(c)}catch(u){n&&n(u)}r=void 0,this.adapterSpeak().catch(()=>{})},c=>{n&&n(c)},a)),this.adapterSpeak().catch(()=>{})}catch(o){if(n)if(o instanceof Error){let a=o;n(a.name+": "+a.message)}else n(o);this.dispose(!0).catch(()=>{})}}async getVoices(e){let t=ol.createNoDashGuid(),r=await this.privRestAdapter.getVoicesList(t);if(r.ok&&Array.isArray(r.json)){let n=r.json;return e&&e.length>0&&(n=n.filter(s=>!!s.Locale&&s.Locale.toLowerCase()===e.toLowerCase())),new dr.SynthesisVoicesResult(t,n,void 0)}else return new dr.SynthesisVoicesResult(t,void 0,`Error: ${r.status}: ${r.statusText}`)}};za.SpeechSynthesizer=al});var Fy=p(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});ja.SynthesisResult=void 0;var cl=class{constructor(e,t,r,n){this.privResultId=e,this.privReason=t,this.privErrorDetails=r,this.privProperties=n}get resultId(){return this.privResultId}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get properties(){return this.privProperties}};ja.SynthesisResult=cl});var Vy=p(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.SpeechSynthesisResult=void 0;var V_=f(),pl=class extends V_.SynthesisResult{constructor(e,t,r,n,s,o){super(e,t,n,s),this.privAudioData=r,this.privAudioDuration=o}get audioData(){return this.privAudioData}get audioDuration(){return this.privAudioDuration}};La.SpeechSynthesisResult=pl});var Uy=p(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.SpeechSynthesisEventArgs=void 0;var ul=class{constructor(e){this.privResult=e}get result(){return this.privResult}};Ba.SpeechSynthesisEventArgs=ul});var Wy=p(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});Fa.SpeechSynthesisWordBoundaryEventArgs=void 0;var hl=class{constructor(e,t,r,n,s,o){this.privAudioOffset=e,this.privDuration=t,this.privText=r,this.privWordLength=n,this.privTextOffset=s,this.privBoundaryType=o}get audioOffset(){return this.privAudioOffset}get duration(){return this.privDuration}get text(){return this.privText}get wordLength(){return this.privWordLength}get textOffset(){return this.privTextOffset}get boundaryType(){return this.privBoundaryType}};Fa.SpeechSynthesisWordBoundaryEventArgs=hl});var Hy=p(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.SpeechSynthesisBookmarkEventArgs=void 0;var dl=class{constructor(e,t){this.privAudioOffset=e,this.privText=t}get audioOffset(){return this.privAudioOffset}get text(){return this.privText}};Va.SpeechSynthesisBookmarkEventArgs=dl});var Ky=p(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.SpeechSynthesisVisemeEventArgs=void 0;var ll=class{constructor(e,t,r){this.privAudioOffset=e,this.privVisemeId=t,this.privAnimation=r}get audioOffset(){return this.privAudioOffset}get visemeId(){return this.privVisemeId}get animation(){return this.privAnimation}};Ua.SpeechSynthesisVisemeEventArgs=ll});var Jy=p(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.SpeechSynthesisBoundaryType=void 0;var U_;(function(i){i.Word="WordBoundary",i.Punctuation="PunctuationBoundary",i.Sentence="SentenceBoundary"})(U_=Ln.SpeechSynthesisBoundaryType||(Ln.SpeechSynthesisBoundaryType={}))});var Gy=p(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.SynthesisVoicesResult=void 0;var Ai=f(),vl=class extends Ai.SynthesisResult{constructor(e,t,r){if(Array.isArray(t)){super(e,Ai.ResultReason.VoicesListRetrieved,void 0,new Ai.PropertyCollection),this.privVoices=[];for(let n of t)this.privVoices.push(new Ai.VoiceInfo(n))}else super(e,Ai.ResultReason.Canceled,r||"Error information unavailable",new Ai.PropertyCollection)}get voices(){return this.privVoices}};Wa.SynthesisVoicesResult=vl});var $y=p(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.VoiceInfo=Tt.SynthesisVoiceType=Tt.SynthesisVoiceGender=void 0;var gt;(function(i){i[i.Unknown=0]="Unknown",i[i.Female=1]="Female",i[i.Male=2]="Male",i[i.Neutral=3]="Neutral"})(gt=Tt.SynthesisVoiceGender||(Tt.SynthesisVoiceGender={}));var fl;(function(i){i[i.OnlineNeural=1]="OnlineNeural",i[i.OnlineStandard=2]="OnlineStandard",i[i.OfflineNeural=3]="OfflineNeural",i[i.OfflineStandard=4]="OfflineStandard"})(fl=Tt.SynthesisVoiceType||(Tt.SynthesisVoiceType={}));var W_={[gt[gt.Neutral]]:gt.Neutral,[gt[gt.Male]]:gt.Male,[gt[gt.Female]]:gt.Female},gl=class{constructor(e){if(this.privStyleList=[],e){if(this.privName=e.Name,this.privLocale=e.Locale,this.privShortName=e.ShortName,this.privLocaleName=e.LocaleName,this.privDisplayName=e.DisplayName,this.privLocalName=e.LocalName,this.privVoiceType=e.VoiceType.endsWith("Standard")?fl.OnlineStandard:fl.OnlineNeural,this.privGender=W_[e.Gender]||gt.Unknown,e.StyleList&&Array.isArray(e.StyleList))for(let t of e.StyleList)this.privStyleList.push(t);this.privSampleRateHertz=e.SampleRateHertz,this.privStatus=e.Status,e.ExtendedPropertyMap&&(this.privExtendedPropertyMap=e.ExtendedPropertyMap),this.privWordsPerMinute=e.WordsPerMinute,Array.isArray(e.SecondaryLocaleList)&&(this.privSecondaryLocaleList=[...e.SecondaryLocaleList]),Array.isArray(e.RolePlayList)&&(this.privRolePlayList=[...e.RolePlayList])}}get name(){return this.privName}get locale(){return this.privLocale}get shortName(){return this.privShortName}get displayName(){return this.privDisplayName}get localName(){return this.privLocalName}get localeName(){return this.privLocaleName}get gender(){return this.privGender}get voiceType(){return this.privVoiceType}get styleList(){return this.privStyleList}get sampleRateHertz(){return this.privSampleRateHertz}get status(){return this.privStatus}get extendedPropertyMap(){return this.privExtendedPropertyMap}get wordsPerMinute(){return this.privWordsPerMinute}get secondaryLocaleList(){return this.privSecondaryLocaleList}get rolePlayList(){return this.privRolePlayList}};Tt.VoiceInfo=gl});var Yy=p(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.SpeakerAudioDestination=void 0;var Wr=P(),H_=br(),Ze=nr(),K_=60*30,Qy={[Ze.AudioFormatTag.PCM]:"audio/wav",[Ze.AudioFormatTag.MuLaw]:"audio/x-wav",[Ze.AudioFormatTag.MP3]:"audio/mpeg",[Ze.AudioFormatTag.OGG_OPUS]:"audio/ogg",[Ze.AudioFormatTag.WEBM_OPUS]:"audio/webm; codecs=opus",[Ze.AudioFormatTag.ALaw]:"audio/x-wav",[Ze.AudioFormatTag.FLAC]:"audio/flac"},ml=class{constructor(e){this.privPlaybackStarted=!1,this.privAppendingToBuffer=!1,this.privMediaSourceOpened=!1,this.privBytesReceived=0,this.privId=e||Wr.createNoDashGuid(),this.privIsPaused=!1,this.privIsClosed=!1}id(){return this.privId}write(e,t,r){this.privAudioBuffer!==void 0?(this.privAudioBuffer.push(e),this.updateSourceBuffer().then(()=>{t&&t()},n=>{r&&r(n)})):this.privAudioOutputStream!==void 0&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength)}close(e,t){if(this.privIsClosed=!0,this.privSourceBuffer!==void 0)this.handleSourceBufferUpdateEnd().then(()=>{e&&e()},r=>{t&&t(r)});else if(this.privAudioOutputStream!==void 0&&typeof window<"u")if((this.privFormat.formatTag===Ze.AudioFormatTag.PCM||this.privFormat.formatTag===Ze.AudioFormatTag.MuLaw||this.privFormat.formatTag===Ze.AudioFormatTag.ALaw)&&this.privFormat.hasHeader===!1)console.warn("Play back is not supported for raw PCM, mulaw or alaw format without header."),this.onAudioEnd&&this.onAudioEnd(this);else{let r=new ArrayBuffer(this.privBytesReceived);this.privAudioOutputStream.read(r).then(()=>{r=this.privFormat.addHeader(r);let n=new Blob([r],{type:Qy[this.privFormat.formatTag]});this.privAudio.src=window.URL.createObjectURL(n),this.notifyPlayback().then(()=>{e&&e()},s=>{t&&t(s)})},n=>{t&&t(n)})}else this.onAudioEnd&&this.onAudioEnd(this)}set format(e){if(typeof AudioContext<"u"||typeof window<"u"&&typeof window.webkitAudioContext<"u"){this.privFormat=e;let t=Qy[this.privFormat.formatTag];t===void 0?console.warn(`Unknown mimeType for format ${Ze.AudioFormatTag[this.privFormat.formatTag]}; playback is not supported.`):typeof MediaSource<"u"&&MediaSource.isTypeSupported(t)?(this.privAudio=new Audio,this.privAudioBuffer=[],this.privMediaSource=new MediaSource,this.privAudio.src=URL.createObjectURL(this.privMediaSource),this.privAudio.load(),this.privMediaSource.onsourceopen=()=>{this.privMediaSourceOpened=!0,this.privMediaSource.duration=K_,this.privSourceBuffer=this.privMediaSource.addSourceBuffer(t),this.privSourceBuffer.onupdate=()=>{this.updateSourceBuffer().catch(r=>{Wr.Events.instance.onEvent(new Wr.BackgroundEvent(r))})},this.privSourceBuffer.onupdateend=()=>{this.handleSourceBufferUpdateEnd().catch(r=>{Wr.Events.instance.onEvent(new Wr.BackgroundEvent(r))})},this.privSourceBuffer.onupdatestart=()=>{this.privAppendingToBuffer=!1}},this.updateSourceBuffer().catch(r=>{Wr.Events.instance.onEvent(new Wr.BackgroundEvent(r))})):(console.warn(`Format ${Ze.AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`),this.privAudioOutputStream=new H_.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privFormat,this.privAudio=new Audio)}}get volume(){return this.privAudio?.volume??-1}set volume(e){this.privAudio&&(this.privAudio.volume=e)}mute(){this.privAudio&&(this.privAudio.muted=!0)}unmute(){this.privAudio&&(this.privAudio.muted=!1)}get isClosed(){return this.privIsClosed}get currentTime(){return this.privAudio!==void 0?this.privAudio.currentTime:-1}pause(){!this.privIsPaused&&this.privAudio!==void 0&&(this.privAudio.pause(),this.privIsPaused=!0)}resume(e,t){this.privIsPaused&&this.privAudio!==void 0&&(this.privAudio.play().then(()=>{e&&e()},r=>{t&&t(r)}),this.privIsPaused=!1)}get internalAudio(){return this.privAudio}async updateSourceBuffer(){if(this.privAudioBuffer!==void 0&&this.privAudioBuffer.length>0&&this.sourceBufferAvailable()){this.privAppendingToBuffer=!0;let e=this.privAudioBuffer.shift();try{this.privSourceBuffer.appendBuffer(e)}catch{this.privAudioBuffer.unshift(e),console.log("buffer filled, pausing addition of binaries until space is made");return}await this.notifyPlayback()}else this.canEndStream()&&await this.handleSourceBufferUpdateEnd()}async handleSourceBufferUpdateEnd(){this.canEndStream()&&this.sourceBufferAvailable()&&(this.privMediaSource.endOfStream(),await this.notifyPlayback())}async notifyPlayback(){!this.privPlaybackStarted&&this.privAudio!==void 0&&(this.privPlaybackStarted=!0,this.onAudioStart&&this.onAudioStart(this),this.privAudio.onended=()=>{this.onAudioEnd&&this.onAudioEnd(this)},this.privIsPaused||await this.privAudio.play())}canEndStream(){return this.isClosed&&this.privSourceBuffer!==void 0&&this.privAudioBuffer.length===0&&this.privMediaSourceOpened&&!this.privAppendingToBuffer&&this.privMediaSource.readyState==="open"}sourceBufferAvailable(){return this.privSourceBuffer!==void 0&&!this.privSourceBuffer.updating}};Ha.SpeakerAudioDestination=ml});var Xy=p(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.ConversationTranscriptionCanceledEventArgs=void 0;var J_=vi(),Sl=class extends J_.CancellationEventArgsBase{};Ka.ConversationTranscriptionCanceledEventArgs=Sl});var Zy=p(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.MeetingTranscriptionCanceledEventArgs=void 0;var G_=vi(),yl=class extends G_.CancellationEventArgsBase{};Ja.MeetingTranscriptionCanceledEventArgs=yl});var eC=p(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.PronunciationAssessmentGradingSystem=void 0;var $_;(function(i){i[i.FivePoint=1]="FivePoint",i[i.HundredMark=2]="HundredMark"})($_=Bn.PronunciationAssessmentGradingSystem||(Bn.PronunciationAssessmentGradingSystem={}))});var tC=p(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.PronunciationAssessmentGranularity=void 0;var Q_;(function(i){i[i.Phoneme=1]="Phoneme",i[i.Word=2]="Word",i[i.FullText=3]="FullText"})(Q_=Fn.PronunciationAssessmentGranularity||(Fn.PronunciationAssessmentGranularity={}))});var rC=p($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.PronunciationAssessmentConfig=void 0;var Ga=I(),G=f(),Cl=class i{constructor(e,t=G.PronunciationAssessmentGradingSystem.FivePoint,r=G.PronunciationAssessmentGranularity.Phoneme,n=!1){Ga.Contracts.throwIfNullOrUndefined(e,"referenceText"),this.privProperties=new G.PropertyCollection,this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_ReferenceText,e),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_GradingSystem,G.PronunciationAssessmentGradingSystem[t]),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_Granularity,G.PronunciationAssessmentGranularity[r]),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_EnableMiscue,String(n))}static fromJSON(e){Ga.Contracts.throwIfNullOrUndefined(e,"json");let t=new i("");return t.privProperties=new G.PropertyCollection,t.properties.setProperty(G.PropertyId.PronunciationAssessment_Json,e),t}toJSON(){return this.updateJson(),this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_Params)}applyTo(e){this.updateJson();let t=e.internalData;t.expectContentAssessmentResponse=!!this.privContentAssessmentTopic,t.speechContext.setPronunciationAssessmentParams(this.properties.getProperty(G.PropertyId.PronunciationAssessment_Params),this.privContentAssessmentTopic,t.isSpeakerDiarizationEnabled)}get referenceText(){return this.properties.getProperty(G.PropertyId.PronunciationAssessment_ReferenceText)}set referenceText(e){Ga.Contracts.throwIfNullOrWhitespace(e,"referenceText"),this.properties.setProperty(G.PropertyId.PronunciationAssessment_ReferenceText,e)}set phonemeAlphabet(e){Ga.Contracts.throwIfNullOrWhitespace(e,"phonemeAlphabet"),this.privPhonemeAlphabet=e}set enableMiscue(e){let t=e?"true":"false";this.properties.setProperty(G.PropertyId.PronunciationAssessment_EnableMiscue,t)}get enableMiscue(){return this.properties.getProperty(G.PropertyId.PronunciationAssessment_EnableMiscue,"false").toLowerCase()==="true"}set nbestPhonemeCount(e){this.privNBestPhonemeCount=e}set enableProsodyAssessment(e){this.privEnableProsodyAssessment=e}enableContentAssessmentWithTopic(e){this.privContentAssessmentTopic=e}get properties(){return this.privProperties}updateJson(){let e=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_Json,"{}"),t=JSON.parse(e),r=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_ReferenceText);r&&(t.referenceText=r);let n=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_GradingSystem);n&&(t.gradingSystem=n);let s=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_Granularity);s&&(t.granularity=s),this.privPhonemeAlphabet&&(t.phonemeAlphabet=this.privPhonemeAlphabet),this.privNBestPhonemeCount&&(t.nbestPhonemeCount=this.privNBestPhonemeCount),t.enableProsodyAssessment=this.privEnableProsodyAssessment,t.dimension="Comprehensive",this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_EnableMiscue)&&(t.enableMiscue=this.enableMiscue),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_Params,JSON.stringify(t))}};$a.PronunciationAssessmentConfig=Cl});var iC=p(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.PronunciationAssessmentResult=bi.ContentAssessmentResult=void 0;var Pl=I(),Y_=f(),Qa=class{constructor(e){this.privPronJson=e}get grammarScore(){return this.privPronJson.ContentAssessment.GrammarScore}get vocabularyScore(){return this.privPronJson.ContentAssessment.VocabularyScore}get topicScore(){return this.privPronJson.ContentAssessment.TopicScore}};bi.ContentAssessmentResult=Qa;var Rl=class i{constructor(e){let t=JSON.parse(e);Pl.Contracts.throwIfNullOrUndefined(t.NBest[0],"NBest"),this.privPronJson=t.NBest[0]}static fromResult(e){Pl.Contracts.throwIfNullOrUndefined(e,"result");let t=e.properties.getProperty(Y_.PropertyId.SpeechServiceResponse_JsonResult);return Pl.Contracts.throwIfNullOrUndefined(t,"json"),new i(t)}get detailResult(){return this.privPronJson}get accuracyScore(){return this.detailResult.PronunciationAssessment?.AccuracyScore}get pronunciationScore(){return this.detailResult.PronunciationAssessment?.PronScore}get completenessScore(){return this.detailResult.PronunciationAssessment?.CompletenessScore}get fluencyScore(){return this.detailResult.PronunciationAssessment?.FluencyScore}get prosodyScore(){return this.detailResult.PronunciationAssessment?.ProsodyScore}get contentAssessmentResult(){if(this.detailResult.ContentAssessment!==void 0)return new Qa(this.detailResult)}};bi.PronunciationAssessmentResult=Rl});var nC=p(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.AvatarConfig=void 0;var X_=I(),Z_=f(),El=class{constructor(e,t,r){this.privCustomized=!1,X_.Contracts.throwIfNullOrWhitespace(e,"character"),this.character=e,this.style=t,r===void 0&&(r=new Z_.AvatarVideoFormat),this.videoFormat=r}get customized(){return this.privCustomized}set customized(e){this.privCustomized=e}get backgroundColor(){return this.privBackgroundColor}set backgroundColor(e){this.privBackgroundColor=e}};Ya.AvatarConfig=El});var sC=p(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0});Hr.AvatarEventArgs=Hr.AvatarEventTypes=void 0;var eT;(function(i){i.SwitchedToSpeaking="SwitchedToSpeaking",i.SwitchedToIdle="SwitchedToIdle",i.SessionClosed="SessionClosed"})(eT=Hr.AvatarEventTypes||(Hr.AvatarEventTypes={}));var Il=class{constructor(e,t){this.privOffset=e,this.privDescription=t}get type(){return this.privType}get offset(){return this.privOffset}get description(){return this.privDescription}};Hr.AvatarEventArgs=Il});var _l=p(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});Za.SpeechSynthesisConnectionFactory=void 0;var oC=pe(),Vn=f(),tT=Ye(),rT=C(),iT=we(),Xa=Ut(),wl=class{constructor(){this.synthesisUri="/cognitiveservices/websocket/v1"}create(e,t,r){let n=e.parameters.getProperty(Vn.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Vn.PropertyId.SpeechServiceConnection_Region,void 0),o=tT.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(Vn.PropertyId.SpeechServiceConnection_EndpointId,void 0),c=a===void 0?"tts":"voice",u=e.parameters.getProperty(Vn.PropertyId.SpeechServiceConnection_Host,"wss://"+s+"."+c+".speech"+o),h={},d={};t.token!==void 0&&t.token!==""&&(d[t.headerName]=t.token),d[iT.HeaderNames.ConnectionId]=r,a!==void 0&&a!==""&&(!n||n.search(Xa.QueryParameterNames.CustomVoiceDeploymentId)===-1)&&(h[Xa.QueryParameterNames.CustomVoiceDeploymentId]=a),e.avatarEnabled&&(!n||n.search(Xa.QueryParameterNames.EnableAvatar)===-1)&&(h[Xa.QueryParameterNames.EnableAvatar]="true"),n||(n=u+this.synthesisUri),e.parameters.setProperty(Vn.PropertyId.SpeechServiceConnection_Url,n);let v=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new oC.WebsocketConnection(n,h,d,new rT.WebsocketMessageFormatter,oC.ProxyInfo.fromParameters(e.parameters),v,r)}};Za.SpeechSynthesisConnectionFactory=wl});var aC=p(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});tc.AvatarSynthesizer=void 0;var nT=_l(),sT=C(),ee=P(),oT=ui(),Ht=f(),ec=I(),aT=xa(),Tl=class extends Ht.Synthesizer{constructor(e,t){super(e),ec.Contracts.throwIfNullOrUndefined(t,"avatarConfig"),this.privConnectionFactory=new nT.SpeechSynthesisConnectionFactory,this.privAvatarConfig=t,this.implCommonSynthesizeSetup()}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=oT.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(Ht.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm)}async startAvatarAsync(e){ec.Contracts.throwIfNullOrUndefined(e,"peerConnection"),this.privIceServers=e.getConfiguration().iceServers,ec.Contracts.throwIfNullOrUndefined(this.privIceServers,"Ice servers must be set.");let t=new ee.Deferred;e.onicegatheringstatechange=()=>{ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice gathering state: "+e.iceGatheringState,ee.EventType.Debug)),e.iceGatheringState==="complete"&&(ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice gathering complete.",ee.EventType.Info)),t.resolve())},e.onicecandidate=a=>{a.candidate?ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice candidate: "+a.candidate.candidate,ee.EventType.Debug)):(ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice candidate: complete",ee.EventType.Debug)),t.resolve())},setTimeout(()=>{e.iceGatheringState!=="complete"&&(ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: ice gathering timeout.",ee.EventType.Warning)),t.resolve())},2e3);let r=await e.createOffer();await e.setLocalDescription(r),await t.promise,ee.Events.instance.onEvent(new ee.PlatformEvent("peer connection: got local SDP.",ee.EventType.Info)),this.privProperties.setProperty(Ht.PropertyId.TalkingAvatarService_WebRTC_SDP,JSON.stringify(e.localDescription));let n=await this.speak("",!1);if(n.reason!==Ht.ResultReason.SynthesizingAudioCompleted)return new Ht.SynthesisResult(n.resultId,n.reason,n.errorDetails,n.properties);let s=atob(n.properties.getProperty(Ht.PropertyId.TalkingAvatarService_WebRTC_SDP)),o=new RTCSessionDescription(JSON.parse(s));return await e.setRemoteDescription(o),new Ht.SynthesisResult(n.resultId,n.reason,void 0,n.properties)}async speakTextAsync(e){let t=await this.speak(e,!1);return new Ht.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async speakSsmlAsync(e){let t=await this.speak(e,!0);return new Ht.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async stopSpeakingAsync(){for(;this.synthesisRequestQueue.length()>0;)(await this.synthesisRequestQueue.dequeue()).err("Synthesis is canceled by user.");return this.privAdapter.stopSpeaking()}async stopAvatarAsync(){return ec.Contracts.throwIfDisposed(this.privDisposed),this.dispose(!0)}async close(){if(!this.privDisposed)return this.dispose(!0)}get iceServers(){return this.privIceServers}createSynthesisAdapter(e,t,r){return new sT.AvatarSynthesisAdapter(e,t,r,this,this.privAvatarConfig)}createRestSynthesisAdapter(e,t){}createSynthesizerConfig(e){let t=super.createSynthesizerConfig(e);return t.avatarEnabled=!0,t}async speak(e,t){let r=ee.createNoDashGuid(),n=new ee.Deferred;return this.synthesisRequestQueue.enqueue(new aT.SynthesisRequest(r,e,t,s=>{n.resolve(s),this.privSynthesizing=!1,this.adapterSpeak()},s=>{n.reject(s),this.privSynthesizing=!1})),this.adapterSpeak(),n.promise}};tc.AvatarSynthesizer=Tl});var cC=p(Oi=>{"use strict";Object.defineProperty(Oi,"__esModule",{value:!0});Oi.AvatarVideoFormat=Oi.Coordinate=void 0;var Al=class{constructor(e,t){this.x=e,this.y=t}};Oi.Coordinate=Al;var bl=class{constructor(e="H264",t=2e6,r=1920,n=1080){this.codec=e,this.bitrate=t,this.width=r,this.height=n}setCropRange(e,t){this.cropRange={bottomRight:t,topLeft:e}}};Oi.AvatarVideoFormat=bl});var pC=p(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.AvatarWebRTCConnectionResult=void 0;var cT=f(),Ol=class extends cT.SynthesisResult{constructor(e,t,r,n,s){super(t,r,n,s),this.privSDPAnswer=e}get SDPAnswer(){return this.privSDPAnswer}};rc.AvatarWebRTCConnectionResult=Ol});var uC=p(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.Diagnostics=void 0;var pT=pe(),uT=P(),ic=class{static SetLoggingLevel(e){this.privListener=new pT.ConsoleLoggingListener(e),uT.Events.instance.attachConsoleListener(this.privListener)}static StartConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!0)}static StopConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!1)}static SetLogOutputPath(e){if(typeof window>"u")this.privListener&&(this.privListener.logPath=e);else throw new Error("File system logging not available in browser.")}static set onLogOutput(e){this.privListener&&(this.privListener.logCallback=e)}};nc.Diagnostics=ic;ic.privListener=void 0});var f=p(l=>{"use strict";Object.defineProperty(l,"__esModule",{value:!0});var hT=mh();Object.defineProperty(l,"AudioConfig",{enumerable:!0,get:function(){return hT.AudioConfig}});var hC=nr();Object.defineProperty(l,"AudioStreamFormat",{enumerable:!0,get:function(){return hC.AudioStreamFormat}});Object.defineProperty(l,"AudioFormatTag",{enumerable:!0,get:function(){return hC.AudioFormatTag}});var Ml=vh();Object.defineProperty(l,"AudioInputStream",{enumerable:!0,get:function(){return Ml.AudioInputStream}});Object.defineProperty(l,"PullAudioInputStream",{enumerable:!0,get:function(){return Ml.PullAudioInputStream}});Object.defineProperty(l,"PushAudioInputStream",{enumerable:!0,get:function(){return Ml.PushAudioInputStream}});var Dl=br();Object.defineProperty(l,"AudioOutputStream",{enumerable:!0,get:function(){return Dl.AudioOutputStream}});Object.defineProperty(l,"PullAudioOutputStream",{enumerable:!0,get:function(){return Dl.PullAudioOutputStream}});Object.defineProperty(l,"PushAudioOutputStream",{enumerable:!0,get:function(){return Dl.PushAudioOutputStream}});var dT=Ym();Object.defineProperty(l,"CancellationReason",{enumerable:!0,get:function(){return dT.CancellationReason}});var lT=Xm();Object.defineProperty(l,"PullAudioInputStreamCallback",{enumerable:!0,get:function(){return lT.PullAudioInputStreamCallback}});var vT=Zm();Object.defineProperty(l,"PushAudioOutputStreamCallback",{enumerable:!0,get:function(){return vT.PushAudioOutputStreamCallback}});var fT=tS();Object.defineProperty(l,"KeywordRecognitionModel",{enumerable:!0,get:function(){return fT.KeywordRecognitionModel}});var gT=rS();Object.defineProperty(l,"SessionEventArgs",{enumerable:!0,get:function(){return gT.SessionEventArgs}});var mT=iS();Object.defineProperty(l,"RecognitionEventArgs",{enumerable:!0,get:function(){return mT.RecognitionEventArgs}});var ST=nS();Object.defineProperty(l,"OutputFormat",{enumerable:!0,get:function(){return ST.OutputFormat}});var yT=sS();Object.defineProperty(l,"IntentRecognitionEventArgs",{enumerable:!0,get:function(){return yT.IntentRecognitionEventArgs}});var CT=oS();Object.defineProperty(l,"RecognitionResult",{enumerable:!0,get:function(){return CT.RecognitionResult}});var PT=aS();Object.defineProperty(l,"SpeechRecognitionResult",{enumerable:!0,get:function(){return PT.SpeechRecognitionResult}});var RT=cS();Object.defineProperty(l,"IntentRecognitionResult",{enumerable:!0,get:function(){return RT.IntentRecognitionResult}});var ET=pS();Object.defineProperty(l,"LanguageUnderstandingModel",{enumerable:!0,get:function(){return ET.LanguageUnderstandingModel}});var kl=hS();Object.defineProperty(l,"SpeechRecognitionEventArgs",{enumerable:!0,get:function(){return kl.SpeechRecognitionEventArgs}});Object.defineProperty(l,"ConversationTranscriptionEventArgs",{enumerable:!0,get:function(){return kl.ConversationTranscriptionEventArgs}});Object.defineProperty(l,"MeetingTranscriptionEventArgs",{enumerable:!0,get:function(){return kl.MeetingTranscriptionEventArgs}});var IT=dS();Object.defineProperty(l,"SpeechRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return IT.SpeechRecognitionCanceledEventArgs}});var wT=lS();Object.defineProperty(l,"TranslationRecognitionEventArgs",{enumerable:!0,get:function(){return wT.TranslationRecognitionEventArgs}});var _T=vS();Object.defineProperty(l,"TranslationSynthesisEventArgs",{enumerable:!0,get:function(){return _T.TranslationSynthesisEventArgs}});var TT=Nh();Object.defineProperty(l,"TranslationRecognitionResult",{enumerable:!0,get:function(){return TT.TranslationRecognitionResult}});var AT=fS();Object.defineProperty(l,"TranslationSynthesisResult",{enumerable:!0,get:function(){return AT.TranslationSynthesisResult}});var bT=gS();Object.defineProperty(l,"ResultReason",{enumerable:!0,get:function(){return bT.ResultReason}});var dC=mS();Object.defineProperty(l,"SpeechConfig",{enumerable:!0,get:function(){return dC.SpeechConfig}});Object.defineProperty(l,"SpeechConfigImpl",{enumerable:!0,get:function(){return dC.SpeechConfigImpl}});var lC=SS();Object.defineProperty(l,"SpeechTranslationConfig",{enumerable:!0,get:function(){return lC.SpeechTranslationConfig}});Object.defineProperty(l,"SpeechTranslationConfigImpl",{enumerable:!0,get:function(){return lC.SpeechTranslationConfigImpl}});var OT=zh();Object.defineProperty(l,"PropertyCollection",{enumerable:!0,get:function(){return OT.PropertyCollection}});var MT=Eo();Object.defineProperty(l,"PropertyId",{enumerable:!0,get:function(){return MT.PropertyId}});var DT=PS();Object.defineProperty(l,"Recognizer",{enumerable:!0,get:function(){return DT.Recognizer}});var kT=RS();Object.defineProperty(l,"SpeechRecognizer",{enumerable:!0,get:function(){return kT.SpeechRecognizer}});var NT=ES();Object.defineProperty(l,"IntentRecognizer",{enumerable:!0,get:function(){return NT.IntentRecognizer}});var qT=IS();Object.defineProperty(l,"VoiceProfileType",{enumerable:!0,get:function(){return qT.VoiceProfileType}});var xT=AS();Object.defineProperty(l,"TranslationRecognizer",{enumerable:!0,get:function(){return xT.TranslationRecognizer}});var zT=bS();Object.defineProperty(l,"Translations",{enumerable:!0,get:function(){return zT.Translations}});var jT=OS();Object.defineProperty(l,"NoMatchReason",{enumerable:!0,get:function(){return jT.NoMatchReason}});var LT=MS();Object.defineProperty(l,"NoMatchDetails",{enumerable:!0,get:function(){return LT.NoMatchDetails}});var BT=DS();Object.defineProperty(l,"TranslationRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return BT.TranslationRecognitionCanceledEventArgs}});var FT=kS();Object.defineProperty(l,"IntentRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return FT.IntentRecognitionCanceledEventArgs}});var VT=td();Object.defineProperty(l,"CancellationDetailsBase",{enumerable:!0,get:function(){return VT.CancellationDetailsBase}});var UT=NS();Object.defineProperty(l,"CancellationDetails",{enumerable:!0,get:function(){return UT.CancellationDetails}});var WT=qS();Object.defineProperty(l,"CancellationErrorCode",{enumerable:!0,get:function(){return WT.CancellationErrorCode}});var HT=xS();Object.defineProperty(l,"ConnectionEventArgs",{enumerable:!0,get:function(){return HT.ConnectionEventArgs}});var KT=zS();Object.defineProperty(l,"ServiceEventArgs",{enumerable:!0,get:function(){return KT.ServiceEventArgs}});var JT=Jh();Object.defineProperty(l,"Connection",{enumerable:!0,get:function(){return JT.Connection}});var GT=jS();Object.defineProperty(l,"PhraseListGrammar",{enumerable:!0,get:function(){return GT.PhraseListGrammar}});var $T=Ko();Object.defineProperty(l,"DialogServiceConfig",{enumerable:!0,get:function(){return $T.DialogServiceConfig}});var QT=LS();Object.defineProperty(l,"BotFrameworkConfig",{enumerable:!0,get:function(){return QT.BotFrameworkConfig}});var YT=BS();Object.defineProperty(l,"CustomCommandsConfig",{enumerable:!0,get:function(){return YT.CustomCommandsConfig}});var XT=HS();Object.defineProperty(l,"DialogServiceConnector",{enumerable:!0,get:function(){return XT.DialogServiceConnector}});var ZT=KS();Object.defineProperty(l,"ActivityReceivedEventArgs",{enumerable:!0,get:function(){return ZT.ActivityReceivedEventArgs}});var eA=GS();Object.defineProperty(l,"TurnStatusReceivedEventArgs",{enumerable:!0,get:function(){return eA.TurnStatusReceivedEventArgs}});var tA=$S();Object.defineProperty(l,"ServicePropertyChannel",{enumerable:!0,get:function(){return tA.ServicePropertyChannel}});var rA=QS();Object.defineProperty(l,"ProfanityOption",{enumerable:!0,get:function(){return rA.ProfanityOption}});var iA=YS();Object.defineProperty(l,"BaseAudioPlayer",{enumerable:!0,get:function(){return iA.BaseAudioPlayer}});var nA=XS();Object.defineProperty(l,"ConnectionMessageEventArgs",{enumerable:!0,get:function(){return nA.ConnectionMessageEventArgs}});var sA=Uh();Object.defineProperty(l,"ConnectionMessage",{enumerable:!0,get:function(){return sA.ConnectionMessage}});var oA=ZS();Object.defineProperty(l,"VoiceProfile",{enumerable:!0,get:function(){return oA.VoiceProfile}});var vC=ty();Object.defineProperty(l,"VoiceProfileEnrollmentResult",{enumerable:!0,get:function(){return vC.VoiceProfileEnrollmentResult}});Object.defineProperty(l,"VoiceProfileEnrollmentCancellationDetails",{enumerable:!0,get:function(){return vC.VoiceProfileEnrollmentCancellationDetails}});var fC=iy();Object.defineProperty(l,"VoiceProfileResult",{enumerable:!0,get:function(){return fC.VoiceProfileResult}});Object.defineProperty(l,"VoiceProfileCancellationDetails",{enumerable:!0,get:function(){return fC.VoiceProfileCancellationDetails}});var aA=ny();Object.defineProperty(l,"VoiceProfilePhraseResult",{enumerable:!0,get:function(){return aA.VoiceProfilePhraseResult}});var cA=sy();Object.defineProperty(l,"VoiceProfileClient",{enumerable:!0,get:function(){return cA.VoiceProfileClient}});var pA=oy();Object.defineProperty(l,"SpeakerRecognizer",{enumerable:!0,get:function(){return pA.SpeakerRecognizer}});var uA=ay();Object.defineProperty(l,"SpeakerIdentificationModel",{enumerable:!0,get:function(){return uA.SpeakerIdentificationModel}});var hA=py();Object.defineProperty(l,"SpeakerVerificationModel",{enumerable:!0,get:function(){return hA.SpeakerVerificationModel}});var dA=hy();Object.defineProperty(l,"AutoDetectSourceLanguageConfig",{enumerable:!0,get:function(){return dA.AutoDetectSourceLanguageConfig}});var lA=ly();Object.defineProperty(l,"AutoDetectSourceLanguageResult",{enumerable:!0,get:function(){return lA.AutoDetectSourceLanguageResult}});var vA=vy();Object.defineProperty(l,"SourceLanguageConfig",{enumerable:!0,get:function(){return vA.SourceLanguageConfig}});var Nl=gy();Object.defineProperty(l,"SpeakerRecognitionResult",{enumerable:!0,get:function(){return Nl.SpeakerRecognitionResult}});Object.defineProperty(l,"SpeakerRecognitionResultType",{enumerable:!0,get:function(){return Nl.SpeakerRecognitionResultType}});Object.defineProperty(l,"SpeakerRecognitionCancellationDetails",{enumerable:!0,get:function(){return Nl.SpeakerRecognitionCancellationDetails}});var Be=ba();Object.defineProperty(l,"Conversation",{enumerable:!0,get:function(){return Be.Conversation}});Object.defineProperty(l,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return Be.ConversationExpirationEventArgs}});Object.defineProperty(l,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return Be.ConversationParticipantsChangedEventArgs}});Object.defineProperty(l,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return Be.ConversationTranslationCanceledEventArgs}});Object.defineProperty(l,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return Be.ConversationTranslationEventArgs}});Object.defineProperty(l,"ConversationTranslationResult",{enumerable:!0,get:function(){return Be.ConversationTranslationResult}});Object.defineProperty(l,"ConversationTranslator",{enumerable:!0,get:function(){return Be.ConversationTranslator}});Object.defineProperty(l,"ConversationTranscriber",{enumerable:!0,get:function(){return Be.ConversationTranscriber}});Object.defineProperty(l,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return Be.ConversationTranscriptionResult}});Object.defineProperty(l,"Meeting",{enumerable:!0,get:function(){return Be.Meeting}});Object.defineProperty(l,"MeetingTranscriber",{enumerable:!0,get:function(){return Be.MeetingTranscriber}});Object.defineProperty(l,"Participant",{enumerable:!0,get:function(){return Be.Participant}});Object.defineProperty(l,"ParticipantChangedReason",{enumerable:!0,get:function(){return Be.ParticipantChangedReason}});Object.defineProperty(l,"User",{enumerable:!0,get:function(){return Be.User}});var fA=xa();Object.defineProperty(l,"Synthesizer",{enumerable:!0,get:function(){return fA.Synthesizer}});var gA=fh();Object.defineProperty(l,"SpeechSynthesisOutputFormat",{enumerable:!0,get:function(){return gA.SpeechSynthesisOutputFormat}});var mA=By();Object.defineProperty(l,"SpeechSynthesizer",{enumerable:!0,get:function(){return mA.SpeechSynthesizer}});var SA=Fy();Object.defineProperty(l,"SynthesisResult",{enumerable:!0,get:function(){return SA.SynthesisResult}});var yA=Vy();Object.defineProperty(l,"SpeechSynthesisResult",{enumerable:!0,get:function(){return yA.SpeechSynthesisResult}});var CA=Uy();Object.defineProperty(l,"SpeechSynthesisEventArgs",{enumerable:!0,get:function(){return CA.SpeechSynthesisEventArgs}});var PA=Wy();Object.defineProperty(l,"SpeechSynthesisWordBoundaryEventArgs",{enumerable:!0,get:function(){return PA.SpeechSynthesisWordBoundaryEventArgs}});var RA=Hy();Object.defineProperty(l,"SpeechSynthesisBookmarkEventArgs",{enumerable:!0,get:function(){return RA.SpeechSynthesisBookmarkEventArgs}});var EA=Ky();Object.defineProperty(l,"SpeechSynthesisVisemeEventArgs",{enumerable:!0,get:function(){return EA.SpeechSynthesisVisemeEventArgs}});var IA=Jy();Object.defineProperty(l,"SpeechSynthesisBoundaryType",{enumerable:!0,get:function(){return IA.SpeechSynthesisBoundaryType}});var wA=Gy();Object.defineProperty(l,"SynthesisVoicesResult",{enumerable:!0,get:function(){return wA.SynthesisVoicesResult}});var _A=$y();Object.defineProperty(l,"VoiceInfo",{enumerable:!0,get:function(){return _A.VoiceInfo}});var TA=Yy();Object.defineProperty(l,"SpeakerAudioDestination",{enumerable:!0,get:function(){return TA.SpeakerAudioDestination}});var AA=Xy();Object.defineProperty(l,"ConversationTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return AA.ConversationTranscriptionCanceledEventArgs}});var bA=Zy();Object.defineProperty(l,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return bA.MeetingTranscriptionCanceledEventArgs}});var OA=eC();Object.defineProperty(l,"PronunciationAssessmentGradingSystem",{enumerable:!0,get:function(){return OA.PronunciationAssessmentGradingSystem}});var MA=tC();Object.defineProperty(l,"PronunciationAssessmentGranularity",{enumerable:!0,get:function(){return MA.PronunciationAssessmentGranularity}});var DA=rC();Object.defineProperty(l,"PronunciationAssessmentConfig",{enumerable:!0,get:function(){return DA.PronunciationAssessmentConfig}});var kA=iC();Object.defineProperty(l,"PronunciationAssessmentResult",{enumerable:!0,get:function(){return kA.PronunciationAssessmentResult}});var NA=Od();Object.defineProperty(l,"LanguageIdMode",{enumerable:!0,get:function(){return NA.LanguageIdMode}});var qA=nC();Object.defineProperty(l,"AvatarConfig",{enumerable:!0,get:function(){return qA.AvatarConfig}});var xA=sC();Object.defineProperty(l,"AvatarEventArgs",{enumerable:!0,get:function(){return xA.AvatarEventArgs}});var zA=aC();Object.defineProperty(l,"AvatarSynthesizer",{enumerable:!0,get:function(){return zA.AvatarSynthesizer}});var gC=cC();Object.defineProperty(l,"AvatarVideoFormat",{enumerable:!0,get:function(){return gC.AvatarVideoFormat}});Object.defineProperty(l,"Coordinate",{enumerable:!0,get:function(){return gC.Coordinate}});var jA=pC();Object.defineProperty(l,"AvatarWebRTCConnectionResult",{enumerable:!0,get:function(){return jA.AvatarWebRTCConnectionResult}});var LA=uC();Object.defineProperty(l,"Diagnostics",{enumerable:!0,get:function(){return LA.Diagnostics}});var BA=eh();Object.defineProperty(l,"LogLevel",{enumerable:!0,get:function(){return BA.LogLevel}})});var mC=p(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.ProxyInfo=void 0;var sc=f(),ql=class i{constructor(e,t,r,n){this.privProxyHostName=e,this.privProxyPort=t,this.privProxyUserName=r,this.privProxyPassword=n}static fromParameters(e){return new i(e.getProperty(sc.PropertyId.SpeechServiceConnection_ProxyHostName),parseInt(e.getProperty(sc.PropertyId.SpeechServiceConnection_ProxyPort),10),e.getProperty(sc.PropertyId.SpeechServiceConnection_ProxyUserName),e.getProperty(sc.PropertyId.SpeechServiceConnection_ProxyPassword))}static fromRecognizerConfig(e){return this.fromParameters(e.parameters)}get HostName(){return this.privProxyHostName}get Port(){return this.privProxyPort}get UserName(){return this.privProxyUserName}get Password(){return this.privProxyPassword}};oc.ProxyInfo=ql});var yC=p((E1,SC)=>{"use strict";var FA=new Set(["json","buffer","string"]);SC.exports=i=>(...e)=>{let t=new Set,r,n,s,o="";return e.forEach(a=>{if(typeof a=="string")if(a.toUpperCase()===a)if(r){let c=`Can't set method to ${a}, already set to ${r}.`;throw new Error(c)}else r=a;else if(a.startsWith("http:")||a.startsWith("https:"))o=a;else if(FA.has(a))n=a;else throw new Error(`Unknown encoding, ${a}`);else if(typeof a=="number")t.add(a);else if(typeof a=="object")if(Array.isArray(a)||a instanceof Set)a.forEach(c=>t.add(c));else{if(s)throw new Error("Cannot set headers twice.");s=a}else throw new Error(`Unknown type: ${typeof a}`)}),r||(r="GET"),t.size===0&&t.add(200),i(t,r,n,s,o)}});var PC=p((I1,CC)=>{"use strict";var VA=yC(),xl=class i extends Error{constructor(e,...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="StatusError",this.message=e.statusMessage,this.statusCode=e.status,this.res=e,this.json=e.json.bind(e),this.text=e.text.bind(e),this.arrayBuffer=e.arrayBuffer.bind(e);let r;Object.defineProperty(this,"responseBody",{get:()=>(r||(r=this.arrayBuffer()),r)}),this.headers={};for(let[s,o]of e.headers.entries())this.headers[s.toLowerCase()]=o}},UA=(i,e,t,r,n)=>async(s,o,a={})=>{s=n+(s||"");let c=new URL(s);if(r||(r={}),c.username&&(r.Authorization="Basic "+btoa(c.username+":"+c.password),c=new URL(c.protocol+"//"+c.host+c.pathname+c.search)),c.protocol!=="https:"&&c.protocol!=="http:")throw new Error(`Unknown protocol, ${c.protocol}`);if(o&&!(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||typeof o=="string"))if(typeof o=="object")o=JSON.stringify(o),r["Content-Type"]="application/json";else throw new Error("Unknown body type.");a=new Headers({...r||{},...a});let u=await fetch(c,{method:e,headers:a,body:o});if(u.statusCode=u.status,!i.has(u.status))throw new xl(u);return t==="json"?u.json():t==="buffer"?u.arrayBuffer():t==="string"?u.text():u};CC.exports=VA(UA)});var EC=p(Kt=>{"use strict";var WA=Kt&&Kt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Kt,"__esModule",{value:!0});Kt.RestMessageAdapter=Kt.RestRequestType=void 0;var HA=WA(PC()),RC=P(),ac;(function(i){i.Get="GET",i.Post="POST",i.Delete="DELETE",i.File="file"})(ac=Kt.RestRequestType||(Kt.RestRequestType={}));var zl=class{constructor(e){if(!e)throw new RC.ArgumentNullError("configParams");this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}static extractHeaderValue(e,t){let r="";try{let n=t.trim().split(/[\r\n]+/),s={};n.forEach(o=>{let a=o.split(": "),c=a.shift().toLowerCase(),u=a.join(": ");s[c]=u}),r=s[e.toLowerCase()]}catch{}return r}set options(e){this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}setHeaders(e,t){this.privHeaders[e]=t}request(e,t,r={},n=null){let s=new RC.Deferred,o=e===ac.File?"POST":e,a=(u,h={})=>{let d=u;return{data:JSON.stringify(h),headers:JSON.stringify(u.headers),json:h,ok:u.statusCode>=200&&u.statusCode<300,status:u.statusCode,statusText:h.error?h.error.message:d.statusText?d.statusText:d.statusMessage}},c=u=>{let h=HA.default(t,o,this.privHeaders,200,201,202,204,400,401,402,403,404),d=this.queryParams(r)===""?"":`?${this.queryParams(r)}`;h(d,u).then(async v=>{if(e===ac.Delete||v.statusCode===204)s.resolve(a(v));else try{let g=await v.json();s.resolve(a(v,g))}catch{s.resolve(a(v))}}).catch(v=>{s.reject(v)})};return this.privIgnoreCache&&(this.privHeaders["Cache-Control"]="no-cache"),e===ac.Post&&n&&(this.privHeaders["content-type"]="application/json",this.privHeaders["Content-Type"]="application/json"),c(n),s.promise}queryParams(e={}){return Object.keys(e).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(e[t])).join("&")}};Kt.RestMessageAdapter=zl});var jl=p(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});cc.RestConfigBase=void 0;var Mi=class i{static get requestOptions(){return i.privDefaultRequestOptions}static get configParams(){return i.privDefaultParams}static get restErrors(){return i.privRestErrors}};cc.RestConfigBase=Mi;Mi.privDefaultRequestOptions={headers:{Accept:"application/json"},ignoreCache:!1,timeout:1e4};Mi.privRestErrors={authInvalidSubscriptionKey:"You must specify either an authentication token to use, or a Cognitive Speech subscription key.",authInvalidSubscriptionRegion:"You must specify the Cognitive Speech region to use.",invalidArgs:"Required input not found: {arg}.",invalidCreateJoinConversationResponse:"Creating/Joining conversation failed with HTTP {status}.",invalidParticipantRequest:"The requested participant was not found.",permissionDeniedConnect:"Required credentials not found.",permissionDeniedConversation:"Invalid operation: only the host can {command} the conversation.",permissionDeniedParticipant:"Invalid operation: only the host can {command} a participant.",permissionDeniedSend:"Invalid operation: the conversation is not in a connected state.",permissionDeniedStart:"Invalid operation: there is already an active conversation."};Mi.privDefaultParams={apiVersion:"api-version",authorization:"Authorization",clientAppId:"X-ClientAppId",contentTypeKey:"Content-Type",correlationId:"X-CorrelationId",languageCode:"language",nickname:"nickname",profanity:"profanity",requestId:"X-RequestId",roomId:"roomid",sessionToken:"token",subscriptionKey:"Ocp-Apim-Subscription-Key",subscriptionRegion:"Ocp-Apim-Subscription-Region",token:"X-CapitoToken"}});var pe=p(me=>{"use strict";var KA=me&&me.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),mt=me&&me.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&KA(e,i,t)};Object.defineProperty(me,"__esModule",{value:!0});mt(km(),me);mt(qm(),me);mt(jm(),me);mt(Bm(),me);mt(Fm(),me);mt(Gm(),me);mt(oh(),me);mt($m(),me);mt(mC(),me);mt(EC(),me);mt(jl(),me)});var _C=p(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});pc.IntentConnectionFactory=void 0;var IC=pe(),Un=f(),wC=Ye(),JA=C(),GA=we(),Ll=class extends wC.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Un.PropertyId.SpeechServiceConnection_Endpoint);if(!n){let c=e.parameters.getProperty(Un.PropertyId.SpeechServiceConnection_IntentRegion),u=wC.ConnectionFactoryBase.getHostSuffix(c);n=e.parameters.getProperty(Un.PropertyId.SpeechServiceConnection_Host,"wss://"+c+".sr.speech"+u)+"/speech/recognition/interactive/cognitiveservices/v1"}let s={format:"simple",language:e.parameters.getProperty(Un.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,s,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[GA.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Un.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new IC.WebsocketConnection(n,s,o,new JA.WebsocketMessageFormatter,IC.ProxyInfo.fromRecognizerConfig(e),a,r)}getSpeechRegionFromIntentRegion(e){switch(e){case"West US":case"US West":case"westus":return"uswest";case"West US 2":case"US West 2":case"westus2":return"uswest2";case"South Central US":case"US South Central":case"southcentralus":return"ussouthcentral";case"West Central US":case"US West Central":case"westcentralus":return"uswestcentral";case"East US":case"US East":case"eastus":return"useast";case"East US 2":case"US East 2":case"eastus2":return"useast2";case"West Europe":case"Europe West":case"westeurope":return"europewest";case"North Europe":case"Europe North":case"northeurope":return"europenorth";case"Brazil South":case"South Brazil":case"southbrazil":return"brazilsouth";case"Australia East":case"East Australia":case"eastaustralia":return"australiaeast";case"Southeast Asia":case"Asia Southeast":case"southeastasia":return"asiasoutheast";case"East Asia":case"Asia East":case"eastasia":return"asiaeast";default:return e}}};pc.IntentConnectionFactory=Ll});var OC=p(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.VoiceProfileConnectionFactory=Di.SpeakerRecognitionConnectionFactory=void 0;var TC=pe(),Kr=f(),AC=Ye(),$A=C(),bC=we(),uc=class extends AC.ConnectionFactoryBase{create(e,t,r,n){let s=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_Endpoint);if(!s){let u=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_Region),h=AC.ConnectionFactoryBase.getHostSuffix(u),d=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_Host,`wss://${u}.spr-frontend.speech${h}`),v=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_SpeakerIdMode,"TextIndependentIdentification");s=`${d}/speaker/ws/${this.scenarioToPath(v)}/${r}`}let o={format:"simple",language:e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,o,s);let a={};t.token!==void 0&&t.token!==""&&(a[t.headerName]=t.token),a[bC.HeaderNames.ConnectionId]=n,a[bC.HeaderNames.SpIDAuthKey]=e.parameters.getProperty(Kr.PropertyId.SpeechServiceConnection_Key),e.parameters.setProperty(Kr.PropertyId.SpeechServiceConnection_Url,s);let c=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new TC.WebsocketConnection(s,o,a,new $A.WebsocketMessageFormatter,TC.ProxyInfo.fromRecognizerConfig(e),c,n)}scenarioToPath(e){switch(e){case"TextIndependentVerification":case"2":return"verification/text-independent";case"TextDependentVerification":case"1":return"verification/text-dependent";default:return"identification/text-independent"}}},Bl=class extends uc{create(e,t,r){return super.create(e,t,"recognition",r)}};Di.SpeakerRecognitionConnectionFactory=Bl;var Fl=class extends uc{create(e,t,r){return super.create(e,t,"profile",r)}};Di.VoiceProfileConnectionFactory=Fl});var dc=p(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.RecognitionEndedEvent=Se.RecognitionCompletionStatus=Se.RecognitionStartedEvent=Se.ConnectingToServiceEvent=Se.ListeningStartedEvent=Se.RecognitionTriggeredEvent=Se.SpeechRecognitionEvent=void 0;var hc=P(),lr=class extends hc.PlatformEvent{constructor(e,t,r,n=hc.EventType.Info){super(e,n),this.privRequestId=t,this.privSessionId=r}get requestId(){return this.privRequestId}get sessionId(){return this.privSessionId}};Se.SpeechRecognitionEvent=lr;var Vl=class extends lr{constructor(e,t,r,n){super("RecognitionTriggeredEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};Se.RecognitionTriggeredEvent=Vl;var Ul=class extends lr{constructor(e,t,r,n){super("ListeningStartedEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};Se.ListeningStartedEvent=Ul;var Wl=class extends lr{constructor(e,t,r){super("ConnectingToServiceEvent",e,r),this.privAuthFetchEventid=t}get authFetchEventid(){return this.privAuthFetchEventid}};Se.ConnectingToServiceEvent=Wl;var Hl=class extends lr{constructor(e,t,r,n,s){super("RecognitionStartedEvent",e,s),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}};Se.RecognitionStartedEvent=Hl;var MC;(function(i){i[i.Success=0]="Success",i[i.AudioSourceError=1]="AudioSourceError",i[i.AudioSourceTimeout=2]="AudioSourceTimeout",i[i.AuthTokenFetchError=3]="AuthTokenFetchError",i[i.AuthTokenFetchTimeout=4]="AuthTokenFetchTimeout",i[i.UnAuthorized=5]="UnAuthorized",i[i.ConnectTimeout=6]="ConnectTimeout",i[i.ConnectError=7]="ConnectError",i[i.ClientRecognitionActivityTimeout=8]="ClientRecognitionActivityTimeout",i[i.UnknownError=9]="UnknownError"})(MC=Se.RecognitionCompletionStatus||(Se.RecognitionCompletionStatus={}));var Kl=class extends lr{constructor(e,t,r,n,s,o,a,c){super("RecognitionEndedEvent",e,s,a===MC.Success?hc.EventType.Info:hc.EventType.Error),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=n,this.privStatus=a,this.privError=c,this.privServiceTag=o}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}get serviceTag(){return this.privServiceTag}get status(){return this.privStatus}get error(){return this.privError}};Se.RecognitionEndedEvent=Kl});var Jr=p(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});lc.SpeechConnectionMessage=void 0;var Jl=P(),Jt=we(),Gl=class i extends Jl.ConnectionMessage{constructor(e,t,r,n,s,o,a,c){if(!t)throw new Jl.ArgumentNullError("path");if(!r)throw new Jl.ArgumentNullError("requestId");let u={};if(u[Jt.HeaderNames.Path]=t,u[Jt.HeaderNames.RequestId]=r,u[Jt.HeaderNames.RequestTimestamp]=new Date().toISOString(),n&&(u[Jt.HeaderNames.ContentType]=n),o&&(u[Jt.HeaderNames.RequestStreamId]=o),a)for(let h in a)h&&(u[h]=a[h]);c?super(e,s,u,c):super(e,s,u),this.privPath=t,this.privRequestId=r,this.privContentType=n,this.privStreamId=o,this.privAdditionalHeaders=a}get path(){return this.privPath}get requestId(){return this.privRequestId}get contentType(){return this.privContentType}get streamId(){return this.privStreamId}get additionalHeaders(){return this.privAdditionalHeaders}static fromConnectionMessage(e){let t=null,r=null,n=null,s=null,o={};if(e.headers)for(let a in e.headers)a&&(a.toLowerCase()===Jt.HeaderNames.Path.toLowerCase()?t=e.headers[a]:a.toLowerCase()===Jt.HeaderNames.RequestId.toLowerCase()?r=e.headers[a]:a.toLowerCase()===Jt.HeaderNames.ContentType.toLowerCase()?n=e.headers[a]:a.toLowerCase()===Jt.HeaderNames.RequestStreamId.toLowerCase()?s=e.headers[a]:o[a]=e.headers[a]);return new i(e.messageType,t,r,n,e.body,s,o,e.id)}};lc.SpeechConnectionMessage=Gl});var DC=p(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});fc.ServiceRecognizerBase=void 0;var QA=pe(),te=P(),B=f(),At=C(),vr=Jr(),vc=class i{constructor(e,t,r,n,s){if(this.privConnectionConfigurationPromise=void 0,this.privConnectionPromise=void 0,this.privSetTimeout=setTimeout,this.privIsLiveAudio=!1,this.privAverageBytesPerMs=0,this.privEnableSpeakerId=!1,this.privExpectContentAssessmentResponse=!1,this.recognizeOverride=void 0,this.recognizeSpeaker=void 0,this.disconnectOverride=void 0,this.receiveMessageOverride=void 0,this.sendPrePayloadJSONOverride=void 0,this.postConnectImplOverride=void 0,this.configConnectionOverride=void 0,this.handleSpeechPhraseMessage=void 0,this.handleSpeechHypothesisMessage=void 0,!e)throw new te.ArgumentNullError("authentication");if(!t)throw new te.ArgumentNullError("connectionFactory");if(!r)throw new te.ArgumentNullError("audioSource");if(!n)throw new te.ArgumentNullError("recognizerConfig");this.privEnableSpeakerId=n.isSpeakerDiarizationEnabled,this.privMustReportEndOfStream=!1,this.privAuthentication=e,this.privConnectionFactory=t,this.privAudioSource=r,this.privRecognizerConfig=n,this.privIsDisposed=!1,this.privRecognizer=s,this.privRequestSession=new At.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new te.EventSource,this.privServiceEvents=new te.EventSource,this.privDynamicGrammar=new At.DynamicGrammarBuilder,this.privSpeechContext=new At.SpeechContext(this.privDynamicGrammar),this.privAgentConfig=new At.AgentConfig,this.privRecognizerConfig.parameters.getProperty(B.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?this.privSetTimeout=te.Timeout.setTimeout:typeof window<"u"&&(this.privSetTimeout=window.setTimeout.bind(window)),this.connectionEvents.attach(a=>{if(a.name==="ConnectionClosedEvent"){let c=a;(c.statusCode===1003||c.statusCode===1007||c.statusCode===1002||c.statusCode===4e3||this.privRequestSession.numConnectionAttempts>this.privRecognizerConfig.maxRetryCount)&&this.cancelRecognitionLocal(B.CancellationReason.Error,c.statusCode===1007?B.CancellationErrorCode.BadRequestParameters:B.CancellationErrorCode.ConnectionFailure,`${c.reason} websocket error code: ${c.statusCode}`)}}),this.privEnableSpeakerId&&(this.privDiarizationSessionId=te.createNoDashGuid()),this.setLanguageIdJson(),this.setOutputDetailLevelJson()}setTranslationJson(){let e=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0);if(e!==void 0){let t=e.split(","),r=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationVoice,void 0),n=r!==void 0?"Synthesize":"None";if(this.privSpeechContext.setSection("translation",{onSuccess:{action:n},output:{interimResults:{mode:"Always"}},targetLanguages:t}),r!==void 0){let s={};for(let o of t)s[o]=r;this.privSpeechContext.setSection("synthesis",{defaultVoices:s})}}}setSpeechSegmentationTimeoutJson(){let e=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.Speech_SegmentationSilenceTimeoutMs,void 0);if(e!==void 0){let t=this.recognitionMode===At.RecognitionMode.Conversation?"CONVERSATION":this.recognitionMode===At.RecognitionMode.Dictation?"DICTATION":"INTERACTIVE",r=parseInt(e,10),n=this.privSpeechContext.getSection("phraseDetection");n.mode=t,n[t]={segmentation:{mode:"Custom",segmentationSilenceTimeoutMs:r}},this.privSpeechContext.setSection("phraseDetection",n)}}setLanguageIdJson(){let e=this.privSpeechContext.getSection("phraseDetection");if(this.privRecognizerConfig.autoDetectSourceLanguages!==void 0){let r=this.privRecognizerConfig.autoDetectSourceLanguages.split(","),n;this.privRecognizerConfig.languageIdMode==="Continuous"?n="DetectContinuous":n="DetectAtAudioStart",this.privSpeechContext.setSection("languageId",{Priority:"PrioritizeLatency",languages:r,mode:n,onSuccess:{action:"Recognize"},onUnknown:{action:"None"}}),this.privSpeechContext.setSection("phraseOutput",{interimResults:{resultType:"Auto"},phraseResults:{resultType:"Always"}});let s=this.privRecognizerConfig.sourceLanguageModels;s!==void 0&&(e.customModels=s,e.onInterim={action:"None"},e.onSuccess={action:"None"})}this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0&&(e.onInterim={action:"Translate"},e.onSuccess={action:"Translate"},this.privSpeechContext.setSection("phraseOutput",{interimResults:{resultType:"None"},phraseResults:{resultType:"None"}})),this.privSpeechContext.setSection("phraseDetection",e)}setOutputDetailLevelJson(){this.privEnableSpeakerId&&(this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true"?this.privSpeechContext.setWordLevelTimings():this.privRecognizerConfig.parameters.getProperty(At.OutputFormatPropertyName,B.OutputFormat[B.OutputFormat.Simple]).toLowerCase()===B.OutputFormat[B.OutputFormat.Detailed].toLocaleLowerCase()&&this.privSpeechContext.setDetailedOutputFormat())}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}get audioSource(){return this.privAudioSource}get speechContext(){return this.privSpeechContext}get dynamicGrammar(){return this.privDynamicGrammar}get agentConfig(){return this.privAgentConfig}set conversationTranslatorToken(e){this.privRecognizerConfig.parameters.setProperty(B.PropertyId.ConversationTranslator_Token,e)}set voiceProfileType(e){this.privRecognizerConfig.parameters.setProperty(B.PropertyId.SpeechServiceConnection_SpeakerIdMode,e)}set authentication(e){this.privAuthentication=e}isDisposed(){return this.privIsDisposed}async dispose(e){if(this.privIsDisposed=!0,this.privConnectionConfigurationPromise!==void 0)try{await(await this.privConnectionConfigurationPromise).dispose(e)}catch{return}}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}get recognitionMode(){return this.privRecognizerConfig.recognitionMode}async recognize(e,t,r){if(this.recognizeOverride!==void 0){await this.recognizeOverride(e,t,r);return}this.privConnectionConfigurationPromise=void 0,this.privRecognizerConfig.recognitionMode=e,this.setSpeechSegmentationTimeoutJson(),this.setTranslationJson(),this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events);let n=this.connectImpl(),s;try{let c=await this.audioSource.attach(this.privRequestSession.audioNodeId),u=await this.audioSource.format,h=await this.audioSource.deviceInfo;this.privIsLiveAudio=h.type&&h.type===At.type.Microphones,s=new QA.ReplayableAudioNode(c,u.avgBytesPerSec),await this.privRequestSession.onAudioSourceAttachCompleted(s,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:h}}catch(c){throw await this.privRequestSession.onStopRecognizing(),c}try{await n}catch(c){await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.ConnectionFailure,c);return}let o=new B.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,o),this.receiveMessage(),this.sendAudio(s).catch(async c=>{await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.RuntimeError,c)})}async stopRecognizing(){if(this.privRequestSession.isRecognizing)try{await this.audioSource.turnOff(),await this.sendFinalAudio(),await this.privRequestSession.onStopRecognizing(),await this.privRequestSession.turnCompletionPromise}finally{await this.privRequestSession.dispose()}}async connect(){return await this.connectImpl(),Promise.resolve()}connectAsync(e,t){this.connectImpl().then(()=>{try{e&&e()}catch(r){t&&t(r)}},r=>{try{t&&t(r)}catch{}})}async disconnect(){if(await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.NoError,"Disconnecting"),this.disconnectOverride!==void 0&&await this.disconnectOverride(),this.privConnectionPromise!==void 0)try{await(await this.privConnectionPromise).dispose()}catch{}this.privConnectionPromise=void 0}sendMessage(e){}async sendNetworkMessage(e,t){let r=typeof t=="string"?te.MessageType.Text:te.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new vr.SpeechConnectionMessage(r,e,this.privRequestSession.requestId,n,t))}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set expectContentAssessmentResponse(e){this.privExpectContentAssessmentResponse=e}async sendTelemetryData(){let e=this.privRequestSession.getTelemetry();if(i.telemetryDataEnabled!==!0||this.privIsDisposed||e===null)return;if(i.telemetryData)try{i.telemetryData(e)}catch{}await(await this.fetchConnection()).send(new vr.SpeechConnectionMessage(te.MessageType.Text,"telemetry",this.privRequestSession.requestId,"application/json",e))}async cancelRecognitionLocal(e,t,r){this.privRequestSession.isRecognizing&&(await this.privRequestSession.onStopRecognizing(),this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,e,t,r))}async receiveMessage(){try{if(this.privIsDisposed)return;let e=await this.fetchConnection(),t=await e.read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(!t)return this.receiveMessage();this.privServiceHasSentMessage=!0;let r=vr.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privRequestSession.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privMustReportEndOfStream=!0,this.privRequestSession.onServiceTurnStartResponse();break;case"speech.startdetected":let n=At.SpeechDetected.fromJSON(r.textBody),s=new B.RecognitionEventArgs(n.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,s);break;case"speech.enddetected":let o;r.textBody.length>0?o=r.textBody:o="{ Offset: 0 }";let a=At.SpeechDetected.fromJSON(o),c=new B.RecognitionEventArgs(a.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,c);break;case"turn.end":await this.sendTelemetryData(),this.privRequestSession.isSpeechEnded&&this.privMustReportEndOfStream&&(this.privMustReportEndOfStream=!1,await this.cancelRecognitionLocal(B.CancellationReason.EndOfStream,B.CancellationErrorCode.NoError,void 0));let u=new B.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition),!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing){this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,u);return}else e=await this.fetchConnection(),await this.sendPrePayloadJSON(e);break;default:await this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new te.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch{return null}}updateSpeakerDiarizationAudioOffset(){let t=this.privRequestSession.recognitionBytesSent/this.privAverageBytesPerMs;this.privSpeechContext.setSpeakerDiarizationAudioOffsetMs(t)}sendSpeechContext(e,t){this.privEnableSpeakerId&&this.updateSpeakerDiarizationAudioOffset();let r=this.speechContext.toJSON();if(t&&this.privRequestSession.onSpeechContext(),r)return e.send(new vr.SpeechConnectionMessage(te.MessageType.Text,"speech.context",this.privRequestSession.requestId,"application/json",r))}noOp(){}async sendPrePayloadJSON(e,t=!0){if(this.sendPrePayloadJSONOverride!==void 0)return this.sendPrePayloadJSONOverride(e);await this.sendSpeechContext(e,t),await this.sendWaveHeader(e)}async sendWaveHeader(e){let t=await this.audioSource.format;return e.send(new vr.SpeechConnectionMessage(te.MessageType.Binary,"audio",this.privRequestSession.requestId,"audio/x-wav",t.header))}connectImpl(){return this.privConnectionPromise!==void 0?this.privConnectionPromise.then(e=>e.state()===te.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl())):(this.privConnectionPromise=this.retryableConnect(),this.privConnectionPromise.catch(()=>{}),this.postConnectImplOverride!==void 0?this.postConnectImplOverride(this.privConnectionPromise):this.privConnectionPromise)}sendSpeechServiceConfig(e,t,r){if(t.onSpeechContext(),i.telemetryDataEnabled!==!0){let s={context:{system:JSON.parse(r).context.system}};r=JSON.stringify(s)}if(this.privRecognizerConfig.parameters.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()==="true"){let n=JSON.parse(r);n.context.DisableReferenceChannel="True",n.context.MicSpec="1_0_0",r=JSON.stringify(n)}if(r)return e.send(new vr.SpeechConnectionMessage(te.MessageType.Text,"speech.config",t.requestId,"application/json",r))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===te.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async sendAudio(e){let t=await this.audioSource.format;this.privAverageBytesPerMs=t.avgBytesPerSec/1e3;let r=Date.now(),n=this.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs","5000"),s=t.avgBytesPerSec/1e3*parseInt(n,10),o=this.privRequestSession.recogNumber,a=async()=>{if(!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o){let c=await this.fetchConnection(),u=await e.read();if(this.privRequestSession.isSpeechEnded)return;let h,d;if(!u||u.isEnd?(h=null,d=0):(h=u.buffer,this.privRequestSession.onAudioSent(h.byteLength),s>=this.privRequestSession.bytesSent?d=0:d=Math.max(0,r-Date.now())),d!==0&&await this.delay(d),h!==null&&(r=Date.now()+h.byteLength*1e3/(t.avgBytesPerSec*2)),!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o)if(c.send(new vr.SpeechConnectionMessage(te.MessageType.Binary,"audio",this.privRequestSession.requestId,null,h)).catch(()=>{this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition).catch(()=>{})}),u?.isEnd)this.privIsLiveAudio||this.privRequestSession.onSpeechEnded();else return a()}};return a()}async retryableConnect(){let e=!1;this.privAuthFetchEventId=te.createNoDashGuid();let t=this.privRequestSession.sessionId;this.privConnectionId=t!==void 0?t:te.createNoDashGuid(),this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId,this.privConnectionId);let r=0,n="";for(;this.privRequestSession.numConnectionAttempts<=this.privRecognizerConfig.maxRetryCount;){let o=await(e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId));await this.privRequestSession.onAuthCompleted(!1);let a=this.privConnectionFactory.create(this.privRecognizerConfig,o,this.privConnectionId);this.privRequestSession.listenForServiceTelemetry(a.events),a.events.attach(u=>{this.connectionEvents.onEvent(u)});let c=await a.open();if(c.statusCode===200)return await this.privRequestSession.onConnectionEstablishCompleted(c.statusCode),Promise.resolve(a);c.statusCode===1006&&(e=!0),r=c.statusCode,n=c.reason,this.privRequestSession.onRetryConnection()}return await this.privRequestSession.onConnectionEstablishCompleted(r,n),Promise.reject(`Unable to contact server. StatusCode: ${r}, ${this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${n}`)}delay(e){return new Promise(t=>this.privSetTimeout(t,e))}writeBufferToConsole(e){let t="Buffer Size: ";if(e===null)t+="null";else{let r=new Uint8Array(e);t+=`${e.byteLength}\r
19
+ `;for(let n=0;n<e.byteLength;n++)t+=r[n].toString(16).padStart(2,"0")+" ",(n+1)%16===0&&(console.info(t),t="")}console.info(t)}async sendFinalAudio(){await(await this.fetchConnection()).send(new vr.SpeechConnectionMessage(te.MessageType.Binary,"audio",this.privRequestSession.requestId,null,null))}async configureConnection(){let e=await this.connectImpl();return this.configConnectionOverride!==void 0?this.configConnectionOverride(e):(await this.sendSpeechServiceConfig(e,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendPrePayloadJSON(e,!1),e)}};fc.ServiceRecognizerBase=vc;vc.telemetryDataEnabled=!0});var kC=p(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.ConversationServiceRecognizer=void 0;var et=f(),bt=C(),$l=class extends bt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.handleSpeechPhraseMessage=async o=>this.handleSpeechPhrase(o),this.handleSpeechHypothesisMessage=o=>this.handleSpeechHypothesis(o)}processTypeSpecificMessages(e){}handleRecognizedCallback(e,t,r){}handleRecognizingCallback(e,t,r){}async processSpeechMessages(e){let t=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":this.handleSpeechHypothesisMessage&&this.handleSpeechHypothesisMessage(e.textBody),t=!0;break;case"speech.phrase":this.handleSpeechPhraseMessage&&await this.handleSpeechPhraseMessage(e.textBody),t=!0;break;default:break}return t}cancelRecognition(e,t,r,n,s){}async handleSpeechPhrase(e){let t=bt.SimpleSpeechPhrase.fromJSON(e),r=bt.EnumTranslation.implTranslateRecognitionResult(t.RecognitionStatus),n,s=new et.PropertyCollection;s.setProperty(et.PropertyId.SpeechServiceResponse_JsonResult,e);let o=t.Offset+this.privRequestSession.currentTurnAudioOffset,a=o;if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+t.Offset+t.Duration),et.ResultReason.Canceled===r){let c=bt.EnumTranslation.implTranslateCancelResult(t.RecognitionStatus),u=bt.EnumTranslation.implTranslateCancelErrorCode(t.RecognitionStatus);await this.cancelRecognitionLocal(c,u,bt.EnumTranslation.implTranslateErrorDetails(u))}else if(!(this.privRequestSession.isSpeechEnded&&r===et.ResultReason.NoMatch&&t.RecognitionStatus!==bt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(bt.OutputFormatPropertyName)===et.OutputFormat[et.OutputFormat.Simple])n=new et.SpeechRecognitionResult(this.privRequestSession.requestId,r,t.DisplayText,t.Duration,o,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,e,s);else{let c=bt.DetailedSpeechPhrase.fromJSON(e),u=c.Offset+this.privRequestSession.currentTurnAudioOffset,h=c.getJsonWithCorrectedOffsets(u);n=new et.SpeechRecognitionResult(this.privRequestSession.requestId,r,c.Text,c.Duration,u,c.Language,c.LanguageDetectionConfidence,c.SpeakerId,void 0,h,s),a=n.offset}this.handleRecognizedCallback(n,a,this.privRequestSession.sessionId)}}handleSpeechHypothesis(e){let t=bt.SpeechHypothesis.fromJSON(e),r=t.Offset+this.privRequestSession.currentTurnAudioOffset,n=new et.PropertyCollection;n.setProperty(et.PropertyId.SpeechServiceResponse_JsonResult,e);let s=new et.SpeechRecognitionResult(this.privRequestSession.requestId,et.ResultReason.RecognizingSpeech,t.Text,t.Duration,r,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,e,n);this.privRequestSession.onHypothesis(r),this.handleRecognizingCallback(s,t.Duration,this.privRequestSession.sessionId)}};gc.ConversationServiceRecognizer=$l});var qC=p(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.RecognizerConfig=Ot.SpeechResultFormat=Ot.RecognitionMode=void 0;var mc=f(),NC=C(),Sc;(function(i){i[i.Interactive=0]="Interactive",i[i.Conversation=1]="Conversation",i[i.Dictation=2]="Dictation"})(Sc=Ot.RecognitionMode||(Ot.RecognitionMode={}));var YA;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(YA=Ot.SpeechResultFormat||(Ot.SpeechResultFormat={}));var Ql=class{constructor(e,t){this.privSpeechServiceConfig=e||new NC.SpeechServiceConfig(new NC.Context(null)),this.privParameters=t,this.privMaxRetryCount=parseInt(t.getProperty("SPEECH-Error-MaxRetryCount","4"),10),this.privLanguageIdMode=t.getProperty(mc.PropertyId.SpeechServiceConnection_LanguageIdMode,void 0),this.privEnableSpeakerId=!1}get parameters(){return this.privParameters}get recognitionMode(){return this.privRecognitionMode}set recognitionMode(e){this.privRecognitionMode=e,this.privRecognitionActivityTimeout=e===Sc.Interactive?8e3:25e3,this.privSpeechServiceConfig.Recognition=Sc[e]}get SpeechServiceConfig(){return this.privSpeechServiceConfig}get recognitionActivityTimeout(){return this.privRecognitionActivityTimeout}get isContinuousRecognition(){return this.privRecognitionMode!==Sc.Interactive}get languageIdMode(){return this.privLanguageIdMode}get autoDetectSourceLanguages(){return this.parameters.getProperty(mc.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,void 0)}get recognitionEndpointVersion(){return this.parameters.getProperty(mc.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,void 0)}get sourceLanguageModels(){let e=[],t=!1;if(this.autoDetectSourceLanguages!==void 0)for(let r of this.autoDetectSourceLanguages.split(",")){let n=r+mc.PropertyId.SpeechServiceConnection_EndpointId.toString(),s=this.parameters.getProperty(n,void 0);s!==void 0?(e.push({language:r,endpoint:s}),t=!0):e.push({language:r,endpoint:""})}return t?e:void 0}get maxRetryCount(){return this.privMaxRetryCount}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}set isSpeakerDiarizationEnabled(e){this.privEnableSpeakerId=e}};Ot.RecognizerConfig=Ql});var zC=p(xC=>{"use strict";Object.defineProperty(xC,"__esModule",{value:!0})});var LC=p(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});yc.WebsocketMessageFormatter=void 0;var tt=P(),jC=`\r
20
+ `,Yl=class{toConnectionMessage(e){let t=new tt.Deferred;try{if(e.messageType===tt.MessageType.Text){let r=e.textContent,n={},s=null;if(r){let o=r.split(`\r
21
21
  \r
22
- `);o&&o.length>0&&(n=this.parseHeaders(o[0]),o.length>1&&(s=o[1]))}t.resolve(new tt.ConnectionMessage(e.messageType,s,n,e.id))}else if(e.messageType===tt.MessageType.Binary){let r=e.binaryContent,n={},s=null;if(!r||r.byteLength<2)throw new Error("Invalid binary message format. Header length missing.");let o=new DataView(r),a=o.getInt16(0);if(r.byteLength<a+2)throw new Error("Invalid binary message format. Header content missing.");let c="";for(let u=0;u<a;u++)c+=String.fromCharCode(o.getInt8(u+2));n=this.parseHeaders(c),r.byteLength>a+2&&(s=r.slice(2+a)),t.resolve(new tt.ConnectionMessage(e.messageType,s,n,e.id))}}catch(r){t.reject(`Error formatting the message. Error: ${r}`)}return t.promise}fromConnectionMessage(e){let t=new tt.Deferred;try{if(e.messageType===tt.MessageType.Text){let r=`${this.makeHeaders(e)}${BC}${e.textBody?e.textBody:""}`;t.resolve(new tt.RawWebsocketMessage(tt.MessageType.Text,r,e.id))}else if(e.messageType===tt.MessageType.Binary){let r=this.makeHeaders(e),n=e.binaryBody,s=this.stringToArrayBuffer(r),o=new Int8Array(s),a=o.byteLength,c=new Int8Array(2+a+(n?n.byteLength:0));if(c[0]=a>>8&255,c[1]=a&255,c.set(o,2),n){let h=new Int8Array(n);c.set(h,2+a)}let u=c.buffer;t.resolve(new tt.RawWebsocketMessage(tt.MessageType.Binary,u,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}makeHeaders(e){let t="";if(e.headers)for(let r in e.headers)r&&(t+=`${r}: ${e.headers[r]}${BC}`);return t}parseHeaders(e){let t={};if(e){let r=e.match(/[^\r\n]+/g);if(t){for(let n of r)if(n){let s=n.indexOf(":"),o=s>0?n.substr(0,s).trim().toLowerCase():n,a=s>0&&n.length>s+1?n.substr(s+1).trim():"";t[o]=a}}}return t}stringToArrayBuffer(e){let t=new ArrayBuffer(e.length),r=new DataView(t);for(let n=0;n<e.length;n++)r.setUint8(n,e.charCodeAt(n));return t}};Cc.WebsocketMessageFormatter=Zl});var HC=p(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});Pc.SpeechConnectionFactory=void 0;var VC=pe(),UC=C(),fr=f(),WC=Ye(),ev=C(),eb=we(),Gr=Ut(),tv=class extends WC.ConnectionFactoryBase{constructor(){super(...arguments),this.interactiveRelativeUri="/speech/recognition/interactive/cognitiveservices/v1",this.conversationRelativeUri="/speech/recognition/conversation/cognitiveservices/v1",this.dictationRelativeUri="/speech/recognition/dictation/cognitiveservices/v1",this.universalUri="/speech/universal/v"}create(e,t,r){let n=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_Region,void 0),o=WC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_EndpointId,void 0),h=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(u?(!n||n.search(Gr.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[Gr.QueryParameterNames.CustomSpeechDeploymentId]=u):h&&(!n||n.search(Gr.QueryParameterNames.Language)===-1)&&(c[Gr.QueryParameterNames.Language]=h),(!n||n.search(Gr.QueryParameterNames.Format)===-1)&&(c[Gr.QueryParameterNames.Format]=e.parameters.getProperty(UC.OutputFormatPropertyName,fr.OutputFormat[fr.OutputFormat.Simple]).toLowerCase()),e.autoDetectSourceLanguages!==void 0&&(c[Gr.QueryParameterNames.EnableLanguageId]="true"),this.setCommonUrlParams(e,c,n),!n)switch(e.recognitionMode){case ev.RecognitionMode.Conversation:e.parameters.getProperty(UC.ForceDictationPropertyName,"false")==="true"?n=a+this.dictationRelativeUri:e.recognitionEndpointVersion!==void 0&&parseInt(e.recognitionEndpointVersion,10)>1?n=`${a}${this.universalUri}${e.recognitionEndpointVersion}`:n=a+this.conversationRelativeUri;break;case ev.RecognitionMode.Dictation:n=a+this.dictationRelativeUri;break;default:e.recognitionEndpointVersion!==void 0&&parseInt(e.recognitionEndpointVersion,10)>1?n=`${a}${this.universalUri}${e.recognitionEndpointVersion}`:n=a+this.interactiveRelativeUri;break}let d={};t.token!==void 0&&t.token!==""&&(d[t.headerName]=t.token),d[eb.HeaderNames.ConnectionId]=r;let v=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new VC.WebsocketConnection(n,c,d,new ev.WebsocketMessageFormatter,VC.ProxyInfo.fromRecognizerConfig(e),v,r),w=g.uri;return e.parameters.setProperty(fr.PropertyId.SpeechServiceConnection_Url,w),g}};Pc.SpeechConnectionFactory=tv});var GC=p(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});Rc.ConversationTranscriberConnectionFactory=void 0;var KC=pe(),We=f(),tb=C(),JC=Ye(),rb=C(),ib=we(),rt=Ut(),rv=class extends JC.ConnectionFactoryBase{constructor(){super(...arguments),this.universalUri="/speech/universal/v2"}create(e,t,r){let n=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Region,void 0),o=JC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_EndpointId,void 0),h=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);u?(!n||n.search(rt.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[rt.QueryParameterNames.CustomSpeechDeploymentId]=u):h&&(!n||n.search(rt.QueryParameterNames.Language)===-1)&&(c[rt.QueryParameterNames.Language]=h),e.autoDetectSourceLanguages!==void 0&&(c[rt.QueryParameterNames.EnableLanguageId]="true"),this.setV2UrlParams(e,c,n),n||(n=`${a}${this.universalUri}`);let d={};t.token!==void 0&&t.token!==""&&(d[t.headerName]=t.token),d[ib.HeaderNames.ConnectionId]=r;let v=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new KC.WebsocketConnection(n,c,d,new rb.WebsocketMessageFormatter,KC.ProxyInfo.fromRecognizerConfig(e),v,r),w=g.uri;return e.parameters.setProperty(We.PropertyId.SpeechServiceConnection_Url,w),g}setV2UrlParams(e,t,r){new Map([[We.PropertyId.Speech_SegmentationSilenceTimeoutMs,rt.QueryParameterNames.SegmentationSilenceTimeoutMs],[We.PropertyId.SpeechServiceConnection_EnableAudioLogging,rt.QueryParameterNames.EnableAudioLogging],[We.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,rt.QueryParameterNames.EndSilenceTimeoutMs],[We.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,rt.QueryParameterNames.InitialSilenceTimeoutMs],[We.PropertyId.SpeechServiceResponse_PostProcessingOption,rt.QueryParameterNames.Postprocessing],[We.PropertyId.SpeechServiceResponse_ProfanityOption,rt.QueryParameterNames.Profanity],[We.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,rt.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(tb.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}};Rc.ConversationTranscriberConnectionFactory=rv});var XC=p(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});Ec.TranscriberConnectionFactory=void 0;var $C=pe(),He=f(),QC=Ye(),YC=C(),nb=we(),Wn=Ut(),iv=class extends QC.ConnectionFactoryBase{constructor(){super(...arguments),this.multiaudioRelativeUri="/speech/recognition/multiaudio"}create(e,t,r){let n=e.parameters.getProperty(He.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(He.PropertyId.SpeechServiceConnection_Region,"centralus"),o=QC.ConnectionFactoryBase.getHostSuffix(s),a="wss://transcribe."+s+".cts.speech"+o+this.multiaudioRelativeUri,c=e.parameters.getProperty(He.PropertyId.SpeechServiceConnection_Host,a),u={};this.setQueryParams(u,e,n),n||(n=c);let h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[nb.HeaderNames.ConnectionId]=r,e.parameters.setProperty(He.PropertyId.SpeechServiceConnection_Url,n);let d=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new $C.WebsocketConnection(n,u,h,new YC.WebsocketMessageFormatter,$C.ProxyInfo.fromRecognizerConfig(e),d,r)}setQueryParams(e,t,r){let n=t.parameters.getProperty(He.PropertyId.SpeechServiceConnection_EndpointId,void 0),s=t.parameters.getProperty(He.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);n&&!(Wn.QueryParameterNames.CustomSpeechDeploymentId in e)&&(e[Wn.QueryParameterNames.CustomSpeechDeploymentId]=n),s&&!(Wn.QueryParameterNames.Language in e)&&(e[Wn.QueryParameterNames.Language]=s);let o=t.parameters.getProperty(He.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true",a=t.parameters.getProperty(YC.OutputFormatPropertyName,He.OutputFormat[He.OutputFormat.Simple])!==He.OutputFormat[He.OutputFormat.Simple];(o||a)&&(e[Wn.QueryParameterNames.Format]=He.OutputFormat[He.OutputFormat.Detailed].toLowerCase()),this.setCommonUrlParams(t,e,r)}};Ec.TranscriberConnectionFactory=iv});var rP=p(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});Ic.TranslationConnectionFactory=void 0;var ZC=pe(),sb=Kd(),Gt=f(),eP=Ye(),nv=C(),ob=we(),tP=Ut(),sv=class extends eP.ConnectionFactoryBase{create(e,t,r){let n=this.getEndpointUrl(e),s={};e.autoDetectSourceLanguages!==void 0&&(s[tP.QueryParameterNames.EnableLanguageId]="true"),this.setQueryParams(s,e,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[ob.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Gt.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new ZC.WebsocketConnection(n,s,o,new nv.WebsocketMessageFormatter,ZC.ProxyInfo.fromRecognizerConfig(e),a,r)}getEndpointUrl(e,t){let r=e.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_Region),n=eP.ConnectionFactoryBase.getHostSuffix(r),s=e.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_Endpoint,void 0);return s||(e.autoDetectSourceLanguages!==void 0?s=e.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_Host,"wss://{region}.stt.speech"+n)+"/speech/universal/v2":s=e.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_Host,"wss://{region}.s2s.speech"+n)+"/speech/translation/cognitiveservices/v1"),t===!0?s:sb.StringUtils.formatString(s,{region:r})}setQueryParams(e,t,r){e.from=t.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_RecoLanguage),e.to=t.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_TranslationToLanguages),e.scenario=t.recognitionMode===nv.RecognitionMode.Interactive?"interactive":t.recognitionMode===nv.RecognitionMode.Conversation?"conversation":"",this.setCommonUrlParams(t,e,r),this.setUrlParameter(Gt.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,tP.QueryParameterNames.StableTranslation,t,e,r);let n=t.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_TranslationVoice,void 0);n!==void 0&&(e.voice=n,e.features="texttospeech")}};Ic.TranslationConnectionFactory=sv});var iP=p(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.EnumTranslation=void 0;var ue=f(),se=C(),ov=class{static implTranslateRecognitionResult(e,t=!1){let r=ue.ResultReason.Canceled;switch(e){case se.RecognitionStatus.Success:r=ue.ResultReason.RecognizedSpeech;break;case se.RecognitionStatus.EndOfDictation:r=t?ue.ResultReason.RecognizedSpeech:ue.ResultReason.NoMatch;break;case se.RecognitionStatus.NoMatch:case se.RecognitionStatus.InitialSilenceTimeout:case se.RecognitionStatus.BabbleTimeout:r=ue.ResultReason.NoMatch;break;case se.RecognitionStatus.Error:case se.RecognitionStatus.BadRequest:case se.RecognitionStatus.Forbidden:default:r=ue.ResultReason.Canceled;break}return r}static implTranslateCancelResult(e){let t=ue.CancellationReason.EndOfStream;switch(e){case se.RecognitionStatus.Success:case se.RecognitionStatus.EndOfDictation:case se.RecognitionStatus.NoMatch:t=ue.CancellationReason.EndOfStream;break;case se.RecognitionStatus.InitialSilenceTimeout:case se.RecognitionStatus.BabbleTimeout:case se.RecognitionStatus.Error:case se.RecognitionStatus.BadRequest:case se.RecognitionStatus.Forbidden:default:t=ue.CancellationReason.Error;break}return t}static implTranslateCancelErrorCode(e){let t=ue.CancellationErrorCode.NoError;switch(e){case se.RecognitionStatus.Error:t=ue.CancellationErrorCode.ServiceError;break;case se.RecognitionStatus.TooManyRequests:t=ue.CancellationErrorCode.TooManyRequests;break;case se.RecognitionStatus.BadRequest:t=ue.CancellationErrorCode.BadRequestParameters;break;case se.RecognitionStatus.Forbidden:t=ue.CancellationErrorCode.Forbidden;break;default:t=ue.CancellationErrorCode.NoError;break}return t}static implTranslateErrorDetails(e){let t="The speech service encountered an internal error and could not continue.";switch(e){case ue.CancellationErrorCode.Forbidden:t="The recognizer is using a free subscription that ran out of quota.";break;case ue.CancellationErrorCode.BadRequestParameters:t="Invalid parameter or unsupported audio format in the request.";break;case ue.CancellationErrorCode.TooManyRequests:t="The number of parallel requests exceeded the number of allowed concurrent transcriptions.";break;default:break}return t}};wc.EnumTranslation=ov});var nP=p(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});gr.RecognitionStatus=gr.SynthesisStatus=void 0;var ab;(function(i){i[i.Success=0]="Success",i[i.SynthesisEnd=1]="SynthesisEnd",i[i.Error=2]="Error"})(ab=gr.SynthesisStatus||(gr.SynthesisStatus={}));var cb;(function(i){i[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",i[i.TooManyRequests=6]="TooManyRequests",i[i.BadRequest=7]="BadRequest",i[i.Forbidden=8]="Forbidden"})(cb=gr.RecognitionStatus||(gr.RecognitionStatus={}))});var oP=p(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});_c.TranslationSynthesisEnd=void 0;var sP=C(),av=class i{constructor(e){this.privSynthesisEnd=JSON.parse(e),this.privSynthesisEnd.SynthesisStatus&&(this.privSynthesisEnd.SynthesisStatus=sP.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]),this.privSynthesisEnd.Status&&(this.privSynthesisEnd.SynthesisStatus=sP.SynthesisStatus[this.privSynthesisEnd.Status])}static fromJSON(e){return new i(e)}get SynthesisStatus(){return this.privSynthesisEnd.SynthesisStatus}get FailureReason(){return this.privSynthesisEnd.FailureReason}};_c.TranslationSynthesisEnd=av});var aP=p(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});Tc.TranslationHypothesis=void 0;var pb=I(),ub=Os(),cv=class i{constructor(e){this.privTranslationHypothesis=e,this.privTranslationHypothesis.Translation.TranslationStatus=ub.TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus]}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){pb.Contracts.throwIfNullOrUndefined(e,"translationHypothesis");let t=e.SpeechHypothesis;return e.SpeechHypothesis=void 0,t.Translation=e,new i(t)}get Duration(){return this.privTranslationHypothesis.Duration}get Offset(){return this.privTranslationHypothesis.Offset}get Text(){return this.privTranslationHypothesis.Text}get Translation(){return this.privTranslationHypothesis.Translation}get Language(){return this.privTranslationHypothesis.PrimaryLanguage?.Language}};Tc.TranslationHypothesis=cv});var cP=p(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});Ac.TranslationPhrase=void 0;var hb=I(),db=C(),lb=Os(),pv=class i{constructor(e){this.privTranslationPhrase=e,this.privTranslationPhrase.RecognitionStatus=db.RecognitionStatus[this.privTranslationPhrase.RecognitionStatus],this.privTranslationPhrase.Translation!==void 0&&(this.privTranslationPhrase.Translation.TranslationStatus=lb.TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus])}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){hb.Contracts.throwIfNullOrUndefined(e,"translationResponse");let t=e.SpeechPhrase;return e.SpeechPhrase=void 0,t.Translation=e,t.Text=t.DisplayText,new i(t)}get RecognitionStatus(){return this.privTranslationPhrase.RecognitionStatus}get Offset(){return this.privTranslationPhrase.Offset}get Duration(){return this.privTranslationPhrase.Duration}get Text(){return this.privTranslationPhrase.Text}get Language(){return this.privTranslationPhrase.PrimaryLanguage?.Language}get Confidence(){return this.privTranslationPhrase.PrimaryLanguage?.Confidence}get Translation(){return this.privTranslationPhrase.Translation}};Ac.TranslationPhrase=pv});var uP=p(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.TranslationServiceRecognizer=void 0;var pP=P(),z=f(),Te=C(),uv=class extends Te.ConversationServiceRecognizer{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privTranslationRecognizer=s,this.connectionEvents.attach(o=>{o.name==="ConnectionEstablishedEvent"&&this.privTranslationRecognizer.onConnection()})}async processTypeSpecificMessages(e){let t=new z.PropertyCollection,r=await this.processSpeechMessages(e);if(r)return!0;let n=async o=>{if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus===Te.RecognitionStatus.Success){let a=this.fireEventForResult(o,t);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,a)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(a.result)}catch(c){this.privErrorCallback&&this.privErrorCallback(c)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}else{let a=Te.EnumTranslation.implTranslateRecognitionResult(o.RecognitionStatus),c=new z.TranslationRecognitionResult(void 0,this.privRequestSession.requestId,a,o.Text,o.Duration,this.privRequestSession.currentTurnAudioOffset+o.Offset,o.Language,o.Confidence,void 0,e.textBody,t);if(a===z.ResultReason.Canceled){let u=Te.EnumTranslation.implTranslateCancelResult(o.RecognitionStatus),h=Te.EnumTranslation.implTranslateCancelErrorCode(o.RecognitionStatus);await this.cancelRecognitionLocal(u,h,Te.EnumTranslation.implTranslateErrorDetails(h))}else{if(!(this.privRequestSession.isSpeechEnded&&a===z.ResultReason.NoMatch&&o.RecognitionStatus!==Te.RecognitionStatus.InitialSilenceTimeout)){let u=new z.TranslationRecognitionEventArgs(c,c.offset,this.privRequestSession.sessionId);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,u)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(c)}catch(u){this.privErrorCallback&&this.privErrorCallback(u)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}r=!0}},s=(o,a)=>{let c=this.fireEventForResult(o,a);if(this.privRequestSession.onHypothesis(this.privRequestSession.currentTurnAudioOffset+c.offset),this.privTranslationRecognizer.recognizing)try{this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,c)}catch{}r=!0};switch(e.messageType===pP.MessageType.Text&&t.setProperty(z.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"translation.hypothesis":s(Te.TranslationHypothesis.fromJSON(e.textBody),t);break;case"translation.response":let o=JSON.parse(e.textBody);if(o.SpeechPhrase)await n(Te.TranslationPhrase.fromTranslationResponse(o));else{let c=JSON.parse(e.textBody);c.SpeechHypothesis&&s(Te.TranslationHypothesis.fromTranslationResponse(c),t)}break;case"translation.phrase":await n(Te.TranslationPhrase.fromJSON(e.textBody));break;case"translation.synthesis":this.sendSynthesisAudio(e.binaryBody,this.privRequestSession.sessionId),r=!0;break;case"audio.end":case"translation.synthesis.end":let a=Te.TranslationSynthesisEnd.fromJSON(e.textBody);switch(a.SynthesisStatus){case Te.SynthesisStatus.Error:if(this.privTranslationRecognizer.synthesizing){let c=new z.TranslationSynthesisResult(z.ResultReason.Canceled,void 0),u=new z.TranslationSynthesisEventArgs(c,this.privRequestSession.sessionId);try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,u)}catch{}}if(this.privTranslationRecognizer.canceled){let c=new z.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId,z.CancellationReason.Error,a.FailureReason,z.CancellationErrorCode.ServiceError,null);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,c)}catch{}}break;case Te.SynthesisStatus.Success:this.sendSynthesisAudio(void 0,this.privRequestSession.sessionId);break;default:break}r=!0;break;default:break}return r}cancelRecognition(e,t,r,n,s){let o=new z.PropertyCollection;if(o.setProperty(Te.CancellationErrorCodePropertyName,z.CancellationErrorCode[n]),this.privTranslationRecognizer.canceled){let a=new z.TranslationRecognitionCanceledEventArgs(e,r,s,n,void 0);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new z.TranslationRecognitionResult(void 0,t,z.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}handleRecognizingCallback(e,t,r){try{let n=new z.TranslationRecognitionEventArgs(z.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,n)}catch{}}handleRecognizedCallback(e,t,r){try{let n=new z.TranslationRecognitionEventArgs(z.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,n)}catch{}}fireEventForResult(e,t){let r;if(e.Translation.Translations!==void 0){r=new z.Translations;for(let h of e.Translation.Translations)r.set(h.Language,h.Text||h.DisplayText)}let n,s;e instanceof Te.TranslationPhrase?(e.Translation&&e.Translation.TranslationStatus===pP.TranslationStatus.Success?n=z.ResultReason.TranslatedSpeech:n=z.ResultReason.RecognizedSpeech,s=e.Confidence):n=z.ResultReason.TranslatingSpeech;let o=e.Language,a=e.Offset+this.privRequestSession.currentTurnAudioOffset,c=new z.TranslationRecognitionResult(r,this.privRequestSession.requestId,n,e.Text,e.Duration,a,o,s,e.Translation.FailureReason,JSON.stringify(e),t);return new z.TranslationRecognitionEventArgs(c,a,this.privRequestSession.sessionId)}sendSynthesisAudio(e,t){let r=e===void 0?z.ResultReason.SynthesizingAudioCompleted:z.ResultReason.SynthesizingAudio,n=new z.TranslationSynthesisResult(r,e),s=new z.TranslationSynthesisEventArgs(n,t);if(this.privTranslationRecognizer.synthesizing)try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,s)}catch{}}};bc.TranslationServiceRecognizer=uv});var hP=p(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.SpeechDetected=void 0;var hv=class i{constructor(e){this.privSpeechStartDetected=JSON.parse(e)}static fromJSON(e){return new i(e)}get Offset(){return this.privSpeechStartDetected.Offset}};Oc.SpeechDetected=hv});var dP=p(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.SpeechHypothesis=void 0;var dv=class i{constructor(e){this.privSpeechHypothesis=JSON.parse(e)}static fromJSON(e){return new i(e)}get Text(){return this.privSpeechHypothesis.Text}get Offset(){return this.privSpeechHypothesis.Offset}get Duration(){return this.privSpeechHypothesis.Duration}get Language(){return this.privSpeechHypothesis.PrimaryLanguage===void 0?void 0:this.privSpeechHypothesis.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privSpeechHypothesis.PrimaryLanguage===void 0?void 0:this.privSpeechHypothesis.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSpeechHypothesis.SpeakerId}};Mc.SpeechHypothesis=dv});var lP=p(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});Dc.SpeechKeyword=void 0;var lv=class i{constructor(e){this.privSpeechKeyword=JSON.parse(e)}static fromJSON(e){return new i(e)}get Status(){return this.privSpeechKeyword.Status}get Text(){return this.privSpeechKeyword.Text}get Offset(){return this.privSpeechKeyword.Offset}get Duration(){return this.privSpeechKeyword.Duration}};Dc.SpeechKeyword=lv});var vP=p(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.SpeechServiceRecognizer=void 0;var ye=f(),it=C(),vv=class extends it.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeechRecognizer=s}async processTypeSpecificMessages(e){let t,r=new ye.PropertyCollection;r.setProperty(ye.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=it.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new ye.SpeechRecognitionResult(this.privRequestSession.requestId,ye.ResultReason.RecognizingSpeech,s.Text,s.Duration,o,s.Language,s.LanguageDetectionConfidence,void 0,void 0,e.textBody,r),this.privRequestSession.onHypothesis(o);let a=new ye.SpeechRecognitionEventArgs(t,s.Duration,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognizing)try{this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer,a)}catch{}n=!0;break;case"speech.phrase":let c=it.SimpleSpeechPhrase.fromJSON(e.textBody),u=it.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus,this.privExpectContentAssessmentResponse);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),ye.ResultReason.Canceled===u){let h=it.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),d=it.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(h,d,it.EnumTranslation.implTranslateErrorDetails(d))}else{if(!(this.privRequestSession.isSpeechEnded&&u===ye.ResultReason.NoMatch&&c.RecognitionStatus!==it.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(it.OutputFormatPropertyName)===ye.OutputFormat[ye.OutputFormat.Simple])t=new ye.SpeechRecognitionResult(this.privRequestSession.requestId,u,c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,void 0,e.textBody,r);else{let d=it.DetailedSpeechPhrase.fromJSON(e.textBody),v=d.Offset+this.privRequestSession.currentTurnAudioOffset,g=d.getJsonWithCorrectedOffsets(v);t=new ye.SpeechRecognitionResult(this.privRequestSession.requestId,u,d.RecognitionStatus===it.RecognitionStatus.Success?d.NBest[0].Display:void 0,d.Duration,v,d.Language,d.LanguageDetectionConfidence,void 0,void 0,g,r)}let h=new ye.SpeechRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognized)try{this.privSpeechRecognizer.recognized(this.privSpeechRecognizer,h)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){let o=new ye.PropertyCollection;if(o.setProperty(it.CancellationErrorCodePropertyName,ye.CancellationErrorCode[n]),this.privSpeechRecognizer.canceled){let a=new ye.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new ye.SpeechRecognitionResult(t,ye.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}};kc.SpeechServiceRecognizer=vv});var fP=p(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});Nc.ConversationTranscriptionServiceRecognizer=void 0;var Ne=f(),nt=C(),fv=class extends nt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privConversationTranscriber=s,this.setSpeakerDiarizationJson()}setSpeakerDiarizationJson(){if(this.privEnableSpeakerId){let e=this.privSpeechContext.getSection("phraseDetection");e.mode="Conversation";let t={};t.mode="Anonymous",t.audioSessionId=this.privDiarizationSessionId,t.audioOffsetMs=0,e.speakerDiarization=t,this.privSpeechContext.setSection("phraseDetection",e)}}async processTypeSpecificMessages(e){let t,r=new Ne.PropertyCollection;r.setProperty(Ne.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=nt.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new Ne.ConversationTranscriptionResult(this.privRequestSession.requestId,Ne.ResultReason.RecognizingSpeech,s.Text,s.Duration,o,s.Language,s.LanguageDetectionConfidence,void 0,void 0,e.textBody,r),this.privRequestSession.onHypothesis(o);let a=new Ne.ConversationTranscriptionEventArgs(t,s.Duration,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribing)try{this.privConversationTranscriber.transcribing(this.privConversationTranscriber,a)}catch{}n=!0;break;case"speech.phrase":let c=nt.SimpleSpeechPhrase.fromJSON(e.textBody),u=nt.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),Ne.ResultReason.Canceled===u){let h=nt.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),d=nt.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(h,d,nt.EnumTranslation.implTranslateErrorDetails(d))}else if(!(this.privRequestSession.isSpeechEnded&&u===Ne.ResultReason.NoMatch&&c.RecognitionStatus!==nt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(nt.OutputFormatPropertyName)===Ne.OutputFormat[Ne.OutputFormat.Simple])t=new Ne.ConversationTranscriptionResult(this.privRequestSession.requestId,u,c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,c.SpeakerId,void 0,e.textBody,r);else{let d=nt.DetailedSpeechPhrase.fromJSON(e.textBody),v=d.Offset+this.privRequestSession.currentTurnAudioOffset,g=d.getJsonWithCorrectedOffsets(v);t=new Ne.ConversationTranscriptionResult(this.privRequestSession.requestId,u,d.RecognitionStatus===nt.RecognitionStatus.Success?d.NBest[0].Display:void 0,d.Duration,v,d.Language,d.LanguageDetectionConfidence,c.SpeakerId,void 0,g,r)}let h=new Ne.ConversationTranscriptionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribed)try{this.privConversationTranscriber.transcribed(this.privConversationTranscriber,h)}catch{}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){if(new Ne.PropertyCollection().setProperty(nt.CancellationErrorCodePropertyName,Ne.CancellationErrorCode[n]),this.privConversationTranscriber.canceled){let a=new Ne.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationTranscriber.canceled(this.privConversationTranscriber,a)}catch{}}}};Nc.ConversationTranscriptionServiceRecognizer=fv});var mP=p(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});qc.TranscriptionServiceRecognizer=void 0;var vb=P(),$t=f(),gP=C(),fb=Jr(),gv=class extends gP.ConversationServiceRecognizer{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privTranscriberRecognizer=s,this.sendPrePayloadJSONOverride=o=>this.sendTranscriptionStartJSON(o),this.privRecognizerConfig.parameters.getProperty($t.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps)==="true"&&this.privSpeechContext.setWordLevelTimings()}async sendSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){let r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createSpeechEventPayload(e,t))}}async sendMeetingSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){let r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createMeetingSpeechEventPayload(e,t))}}processTypeSpecificMessages(e){return this.processSpeechMessages(e)}handleRecognizedCallback(e,t,r){try{let n=new $t.SpeechRecognitionEventArgs(e,t,r);if(this.privTranscriberRecognizer.recognized(this.privTranscriberRecognizer,n),this.privSuccessCallback){try{this.privSuccessCallback(e)}catch(s){this.privErrorCallback&&this.privErrorCallback(s)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}catch{}}handleRecognizingCallback(e,t,r){try{let n=new $t.SpeechRecognitionEventArgs(e,t,r);this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer,n)}catch{}}cancelRecognition(e,t,r,n,s){let o=new $t.PropertyCollection;if(o.setProperty(gP.CancellationErrorCodePropertyName,$t.CancellationErrorCode[n]),this.privTranscriberRecognizer.IsMeetingRecognizer()){if(this.privTranscriberRecognizer.canceled){let a=new $t.MeetingTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}}else if(this.privTranscriberRecognizer.canceled){let a=new $t.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new $t.SpeechRecognitionResult(t,$t.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}async sendTranscriptionStartJSON(e){if(await this.sendSpeechContext(e,!0),this.privTranscriberRecognizer.IsMeetingRecognizer()){let t=this.privTranscriberRecognizer.getMeetingInfo(),r=this.createMeetingSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}else{let t=this.privTranscriberRecognizer.getConversationInfo(),r=this.createSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}await this.sendWaveHeader(e)}sendSpeechEvent(e,t){let r=JSON.stringify(t);if(r)return e.send(new fb.SpeechConnectionMessage(vb.MessageType.Text,"speech.event",this.privRequestSession.requestId,"application/json",r))}createSpeechEventPayload(e,t){let r={id:"meeting",name:t,meeting:e.conversationProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}createMeetingSpeechEventPayload(e,t){let r={id:"meeting",name:t,meeting:e.meetingProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}};qc.TranscriptionServiceRecognizer=gv});var SP=p(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.DetailedSpeechPhrase=void 0;var gb=C(),mv=class i{constructor(e){this.privDetailedSpeechPhrase=JSON.parse(e),this.privDetailedSpeechPhrase.RecognitionStatus=gb.RecognitionStatus[this.privDetailedSpeechPhrase.RecognitionStatus]}static fromJSON(e){return new i(e)}getJsonWithCorrectedOffsets(e){if(this.privDetailedSpeechPhrase.NBest){let t;for(let r of this.privDetailedSpeechPhrase.NBest)if(r.Words&&r.Words[0]){t=r.Words[0].Offset;break}if(t&&t<e){let r=e-t;for(let n of this.privDetailedSpeechPhrase.NBest){if(n.Words)for(let s of n.Words)s.Offset+=r;if(n.DisplayWords)for(let s of n.DisplayWords)s.Offset+=r}}}return JSON.stringify(this.privDetailedSpeechPhrase)}get RecognitionStatus(){return this.privDetailedSpeechPhrase.RecognitionStatus}get NBest(){return this.privDetailedSpeechPhrase.NBest}get Duration(){return this.privDetailedSpeechPhrase.Duration}get Offset(){return this.privDetailedSpeechPhrase.Offset}get Language(){return this.privDetailedSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privDetailedSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Confidence}get Text(){return this.privDetailedSpeechPhrase.NBest&&this.privDetailedSpeechPhrase.NBest[0]?this.privDetailedSpeechPhrase.NBest[0].Display||this.privDetailedSpeechPhrase.NBest[0].DisplayText:this.privDetailedSpeechPhrase.DisplayText}get SpeakerId(){return this.privDetailedSpeechPhrase.SpeakerId}};xc.DetailedSpeechPhrase=mv});var yP=p(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.SimpleSpeechPhrase=void 0;var mb=C(),Sv=class i{constructor(e){this.privSimpleSpeechPhrase=JSON.parse(e),this.privSimpleSpeechPhrase.RecognitionStatus=mb.RecognitionStatus[this.privSimpleSpeechPhrase.RecognitionStatus]}static fromJSON(e){return new i(e)}get RecognitionStatus(){return this.privSimpleSpeechPhrase.RecognitionStatus}get DisplayText(){return this.privSimpleSpeechPhrase.DisplayText}get Offset(){return this.privSimpleSpeechPhrase.Offset}get Duration(){return this.privSimpleSpeechPhrase.Duration}get Language(){return this.privSimpleSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privSimpleSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSimpleSpeechPhrase.SpeakerId}};zc.SimpleSpeechPhrase=Sv});var CP=p(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.AddedLmIntent=void 0;var yv=class{constructor(e,t){this.modelImpl=e,this.intentName=t}};jc.AddedLmIntent=yv});var RP=p(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});Lc.IntentServiceRecognizer=void 0;var PP=P(),oe=f(),ki=C(),Cv=class extends ki.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privIntentRecognizer=s,this.privIntentDataSent=!1}setIntents(e,t){this.privAddedLmIntents=e,this.privUmbrellaIntent=t,this.privIntentDataSent=!0}processTypeSpecificMessages(e){let t,r,n=!1,s=new oe.PropertyCollection;switch(e.messageType===PP.MessageType.Text&&s.setProperty(oe.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.hypothesis":let a=ki.SpeechHypothesis.fromJSON(e.textBody);if(t=new oe.IntentRecognitionResult(void 0,this.privRequestSession.requestId,oe.ResultReason.RecognizingIntent,a.Text,a.Duration,a.Offset+this.privRequestSession.currentTurnAudioOffset,a.Language,a.LanguageDetectionConfidence,void 0,e.textBody,s),this.privRequestSession.onHypothesis(t.offset),r=new oe.IntentRecognitionEventArgs(t,a.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId),this.privIntentRecognizer.recognizing)try{this.privIntentRecognizer.recognizing(this.privIntentRecognizer,r)}catch{}n=!0;break;case"speech.phrase":let c=ki.SimpleSpeechPhrase.fromJSON(e.textBody);t=new oe.IntentRecognitionResult(void 0,this.privRequestSession.requestId,ki.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus),c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,e.textBody,s),r=new oe.IntentRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);let u=()=>{if(this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(d){this.privErrorCallback&&this.privErrorCallback(d)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}};this.privIntentDataSent===!1||oe.ResultReason.NoMatch===r.result.reason?(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),u()):this.privPendingIntentArgs=r,n=!0;break;case"response":if(r=this.privPendingIntentArgs,this.privPendingIntentArgs=void 0,r===void 0){if(e.textBody==="")return;r=new oe.IntentRecognitionEventArgs(new oe.IntentRecognitionResult,0,this.privRequestSession.sessionId)}let h=ki.IntentResponse.fromJSON(e.textBody);if(h!==null&&h.topScoringIntent&&h.topScoringIntent.intent){let d=this.privAddedLmIntents[h.topScoringIntent.intent];if(this.privUmbrellaIntent!==void 0&&(d=this.privUmbrellaIntent),d){let v=d===void 0||d.intentName===void 0?h.topScoringIntent.intent:d.intentName,g=r.result.reason;v!==void 0&&(g=oe.ResultReason.RecognizedIntent);let w=r.result.properties!==void 0?r.result.properties:new oe.PropertyCollection;w.setProperty(oe.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,e.textBody),r=new oe.IntentRecognitionEventArgs(new oe.IntentRecognitionResult(v,r.result.resultId,g,r.result.text,r.result.duration,r.result.offset,void 0,void 0,r.result.errorDetails,r.result.json,w),r.offset,r.sessionId)}}if(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(r.result)}catch(d){this.privErrorCallback&&this.privErrorCallback(d)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}n=!0;break;default:break}let o=new PP.Deferred;return o.resolve(n),o.promise}cancelRecognition(e,t,r,n,s){let o=new oe.PropertyCollection;if(o.setProperty(ki.CancellationErrorCodePropertyName,oe.CancellationErrorCode[n]),this.privIntentRecognizer.canceled){let a=new oe.IntentRecognitionCanceledEventArgs(r,s,n,void 0,void 0,e);try{this.privIntentRecognizer.canceled(this.privIntentRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new oe.IntentRecognitionResult(void 0,t,oe.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}};Lc.IntentServiceRecognizer=Cv});var EP=p(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});Bc.IntentResponse=void 0;var Pv=class i{constructor(e){e===""?this.privIntentResponse={}:this.privIntentResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get query(){return this.privIntentResponse.query}get topScoringIntent(){return this.privIntentResponse.topScoringIntent}get entities(){return this.privIntentResponse.entities}};Bc.IntentResponse=Pv});var wP=p(IP=>{"use strict";Object.defineProperty(IP,"__esModule",{value:!0})});var TP=p(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});Fc.ServiceTelemetryListener=void 0;var Qt=P(),_P=lc(),Rv=class{constructor(e,t,r){this.privIsDisposed=!1,this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privRequestId=e,this.privAudioSourceId=t,this.privAudioNodeId=r,this.privReceivedMessages={},this.privPhraseLatencies=[],this.privHypothesisLatencies=[]}phraseReceived(e){e>0&&this.privPhraseLatencies.push(Date.now()-e)}hypothesisReceived(e){e>0&&this.privHypothesisLatencies.push(Date.now()-e)}onEvent(e){this.privIsDisposed||(e instanceof _P.RecognitionTriggeredEvent&&e.requestId===this.privRequestId&&(this.privListeningTriggerMetric={End:e.eventTime,Name:"ListeningTrigger",Start:e.eventTime}),e instanceof Qt.AudioStreamNodeAttachingEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Qt.AudioStreamNodeAttachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Qt.AudioSourceErrorEvent&&e.audioSourceId===this.privAudioSourceId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof Qt.AudioStreamNodeErrorEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof Qt.AudioStreamNodeDetachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Name:"Microphone",Start:this.privMicStartTime})),e instanceof _P.ConnectingToServiceEvent&&e.requestId===this.privRequestId&&(this.privConnectionId=e.sessionId),e instanceof Qt.ConnectionStartEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionStartTime=e.eventTime),e instanceof Qt.ConnectionEstablishedEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof Qt.ConnectionEstablishErrorEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Error:this.getConnectionError(e.statusCode),Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof Qt.ConnectionMessageReceivedEvent&&e.connectionId===this.privConnectionId&&e.message&&e.message.headers&&e.message.headers.path&&(this.privReceivedMessages[e.message.headers.path]||(this.privReceivedMessages[e.message.headers.path]=new Array),this.privReceivedMessages[e.message.headers.path].length<50&&this.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime)))}getTelemetry(){let e=new Array;this.privListeningTriggerMetric&&e.push(this.privListeningTriggerMetric),this.privMicMetric&&e.push(this.privMicMetric),this.privConnectionEstablishMetric&&e.push(this.privConnectionEstablishMetric),this.privPhraseLatencies.length>0&&e.push({PhraseLatencyMs:this.privPhraseLatencies}),this.privHypothesisLatencies.length>0&&e.push({FirstHypothesisLatencyMs:this.privHypothesisLatencies});let t={Metrics:e,ReceivedMessages:this.privReceivedMessages},r=JSON.stringify(t);return this.privReceivedMessages={},this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privPhraseLatencies=[],this.privHypothesisLatencies=[],r}get hasTelemetry(){return Object.keys(this.privReceivedMessages).length!==0||this.privListeningTriggerMetric!==null||this.privMicMetric!==null||this.privConnectionEstablishMetric!==null||this.privPhraseLatencies.length!==0||this.privHypothesisLatencies.length!==0}dispose(){this.privIsDisposed=!0}getConnectionError(e){switch(e){case 400:case 1002:case 1003:case 1005:case 1007:case 1008:case 1009:return"BadRequest";case 401:return"Unauthorized";case 403:return"Forbidden";case 503:case 1001:return"ServerUnavailable";case 500:case 1011:return"ServerError";case 408:case 504:return"Timeout";default:return"statuscode:"+e.toString()}}};Fc.ServiceTelemetryListener=Rv});var AP=p(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.RequestSession=void 0;var Ni=P(),Vc=lc(),Sb=TP(),Ev=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privIsAudioNodeDetached=!1,this.privIsRecognizing=!1,this.privIsSpeechEnded=!1,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privHypothesisReceived=!1,this.privBytesSent=0,this.privRecognitionBytesSent=0,this.privRecogNumber=0,this.privInTurn=!1,this.privConnectionAttempts=0,this.privAudioSourceId=e,this.privRequestId=Ni.createNoDashGuid(),this.privAudioNodeId=Ni.createNoDashGuid(),this.privTurnDeferral=new Ni.Deferred,this.privTurnDeferral.resolve()}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get audioNodeId(){return this.privAudioNodeId}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSpeechEnded(){return this.privIsSpeechEnded}get isRecognizing(){return this.privIsRecognizing}get currentTurnAudioOffset(){return this.privTurnStartAudioOffset}get recogNumber(){return this.privRecogNumber}get numConnectionAttempts(){return this.privConnectionAttempts}get bytesSent(){return this.privBytesSent}get recognitionBytesSent(){return this.privRecognitionBytesSent}listenForServiceTelemetry(e){this.privServiceTelemetryListener&&this.privDetachables.push(e.attachListener(this.privServiceTelemetryListener))}startNewRecognition(){this.privRecognitionBytesSent=0,this.privIsSpeechEnded=!1,this.privIsRecognizing=!0,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privRecogNumber++,this.privServiceTelemetryListener=new Sb.ServiceTelemetryListener(this.privRequestId,this.privAudioSourceId,this.privAudioNodeId),this.onEvent(new Vc.RecognitionTriggeredEvent(this.requestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}async onAudioSourceAttachCompleted(e,t){this.privAudioNode=e,this.privIsAudioNodeDetached=!1,t?await this.onComplete():this.onEvent(new Vc.ListeningStartedEvent(this.privRequestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}onPreConnectionStart(e,t){this.privAuthFetchEventId=e,this.privSessionId=t,this.onEvent(new Vc.ConnectingToServiceEvent(this.privRequestId,this.privAuthFetchEventId,this.privSessionId))}async onAuthCompleted(e){e&&await this.onComplete()}async onConnectionEstablishCompleted(e,t){if(e===200){this.onEvent(new Vc.RecognitionStartedEvent(this.requestId,this.privAudioSourceId,this.privAudioNodeId,this.privAuthFetchEventId,this.privSessionId)),this.privAudioNode&&this.privAudioNode.replay(),this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privBytesSent=0;return}else e===403&&await this.onComplete()}async onServiceTurnEndResponse(e){this.privTurnDeferral.resolve(),!e||this.isSpeechEnded?(await this.onComplete(),this.privInTurn=!1):(this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privAudioNode.replay())}onSpeechContext(){this.privRequestId=Ni.createNoDashGuid()}onServiceTurnStartResponse(){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch(()=>{})),this.privInTurn=!0,this.privTurnDeferral=new Ni.Deferred}onHypothesis(e){this.privHypothesisReceived||(this.privHypothesisReceived=!0,this.privServiceTelemetryListener.hypothesisReceived(this.privAudioNode.findTimeAtOffset(e)))}onPhraseRecognized(e){this.privServiceTelemetryListener.phraseReceived(this.privAudioNode.findTimeAtOffset(e)),this.onServiceRecognized(e)}onServiceRecognized(e){this.privLastRecoOffset=e,this.privHypothesisReceived=!1,this.privAudioNode.shrinkBuffers(e),this.privConnectionAttempts=0}onAudioSent(e){this.privBytesSent+=e,this.privRecognitionBytesSent+=e}onRetryConnection(){this.privConnectionAttempts++}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach();this.privServiceTelemetryListener&&this.privServiceTelemetryListener.dispose(),this.privIsRecognizing=!1}}getTelemetry(){return this.privServiceTelemetryListener.hasTelemetry?this.privServiceTelemetryListener.getTelemetry():null}async onStopRecognizing(){await this.onComplete()}onSpeechEnded(){this.privIsSpeechEnded=!0}onEvent(e){this.privServiceTelemetryListener&&this.privServiceTelemetryListener.onEvent(e),Ni.Events.instance.onEvent(e)}async onComplete(){this.privIsRecognizing&&(this.privIsRecognizing=!1,await this.detachAudioNode())}async detachAudioNode(){this.privIsAudioNodeDetached||(this.privIsAudioNodeDetached=!0,this.privAudioNode&&await this.privAudioNode.detach())}};Uc.RequestSession=Ev});var bP=p(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});Wc.SpeechContext=void 0;var Iv=class{constructor(e){this.privContext={},this.privDynamicGrammar=e}getSection(e){return this.privContext[e]||{}}setSection(e,t){this.privContext[e]=t}setPronunciationAssessmentParams(e,t,r=!1){this.privContext.phraseDetection===void 0&&(this.privContext.phraseDetection={enrichment:{pronunciationAssessment:{}}}),this.privContext.phraseDetection.enrichment===void 0&&(this.privContext.phraseDetection.enrichment={pronunciationAssessment:{}}),this.privContext.phraseDetection.enrichment.pronunciationAssessment=JSON.parse(e),r&&(this.privContext.phraseDetection.mode="Conversation"),this.setWordLevelTimings(),this.privContext.phraseOutput.detailed.options.push("PronunciationAssessment"),this.privContext.phraseOutput.detailed.options.indexOf("SNR")===-1&&this.privContext.phraseOutput.detailed.options.push("SNR"),t&&(this.privContext.phraseDetection.enrichment.contentAssessment={topic:t},this.privContext.phraseOutput.detailed.options.push("ContentAssessment"))}setDetailedOutputFormat(){this.privContext.phraseOutput===void 0&&(this.privContext.phraseOutput={detailed:{options:[]},format:{}}),this.privContext.phraseOutput.detailed===void 0&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format="Detailed"}setWordLevelTimings(){this.privContext.phraseOutput===void 0&&(this.privContext.phraseOutput={detailed:{options:[]},format:{}}),this.privContext.phraseOutput.detailed===void 0&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format="Detailed",this.privContext.phraseOutput.detailed.options.indexOf("WordTimings")===-1&&this.privContext.phraseOutput.detailed.options.push("WordTimings")}setSpeakerDiarizationAudioOffsetMs(e){this.privContext.phraseDetection.speakerDiarization.audioOffsetMs=e}toJSON(){let e=this.privDynamicGrammar.generateGrammarObject();return this.setSection("dgi",e),JSON.stringify(this.privContext)}};Wc.SpeechContext=Iv});var OP=p(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});Hc.DynamicGrammarBuilder=void 0;var wv=class{addPhrase(e){this.privPhrases||(this.privPhrases=[]),e instanceof Array?this.privPhrases=this.privPhrases.concat(e):this.privPhrases.push(e)}clearPhrases(){this.privPhrases=void 0}addReferenceGrammar(e){this.privGrammars||(this.privGrammars=[]),e instanceof Array?this.privGrammars=this.privGrammars.concat(e):this.privGrammars.push(e)}clearGrammars(){this.privGrammars=void 0}generateGrammarObject(){if(this.privGrammars===void 0&&this.privPhrases===void 0)return;let e={};if(e.ReferenceGrammars=this.privGrammars,this.privPhrases!==void 0&&this.privPhrases.length!==0){let t=[];this.privPhrases.forEach(r=>{t.push({Text:r})}),e.Groups=[{Type:"Generic",Items:t}]}return e}};Hc.DynamicGrammarBuilder=wv});var DP=p(MP=>{"use strict";Object.defineProperty(MP,"__esModule",{value:!0})});var Tv=p($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0});$r.MessageDataStreamType=$r.ActivityPayloadResponse=void 0;var _v=class i{constructor(e){this.privActivityResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get conversationId(){return this.privActivityResponse.conversationId}get messageDataStreamType(){return this.privActivityResponse.messageDataStreamType}get messagePayload(){return this.privActivityResponse.messagePayload}get version(){return this.privActivityResponse.version}};$r.ActivityPayloadResponse=_v;var yb;(function(i){i[i.None=0]="None",i[i.TextToSpeechAudio=1]="TextToSpeechAudio"})(yb=$r.MessageDataStreamType||($r.MessageDataStreamType={}))});var kP=p(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.DialogServiceTurnState=void 0;var Cb=ui(),Pb=br(),Rb=Tv(),Av=class{constructor(e,t){this.privRequestId=t,this.privIsCompleted=!1,this.privAudioStream=null,this.privTurnManager=e,this.resetTurnEndTimeout()}get audioStream(){return this.resetTurnEndTimeout(),this.privAudioStream}processActivityPayload(e,t){return e.messageDataStreamType===Rb.MessageDataStreamType.TextToSpeechAudio&&(this.privAudioStream=Pb.AudioOutputStream.createPullStream(),this.privAudioStream.format=t!==void 0?t:Cb.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privAudioStream}endAudioStream(){this.privAudioStream!==null&&!this.privAudioStream.isClosed&&this.privAudioStream.close()}complete(){this.privTimeoutToken!==void 0&&clearTimeout(this.privTimeoutToken),this.endAudioStream()}resetTurnEndTimeout(){this.privTimeoutToken!==void 0&&clearTimeout(this.privTimeoutToken),this.privTimeoutToken=setTimeout(()=>{this.privTurnManager.CompleteTurn(this.privRequestId)},2e3)}};Kc.DialogServiceTurnState=Av});var qP=p(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});Jc.DialogServiceTurnStateManager=void 0;var NP=ht(),Eb=kP(),bv=class{constructor(){this.privTurnMap=new Map}StartTurn(e){if(this.privTurnMap.has(e))throw new NP.InvalidOperationError("Service error: There is already a turn with id:"+e);let t=new Eb.DialogServiceTurnState(this,e);return this.privTurnMap.set(e,t),this.privTurnMap.get(e)}GetTurn(e){return this.privTurnMap.get(e)}CompleteTurn(e){if(!this.privTurnMap.has(e))throw new NP.InvalidOperationError("Service error: Received turn end for an unknown turn id:"+e);let t=this.privTurnMap.get(e);return t.complete(),this.privTurnMap.delete(e),t}};Jc.DialogServiceTurnStateManager=bv});var xP=p($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.DialogServiceAdapter=void 0;var Ib=pe(),wb=Cu(),Ae=P(),_b=ui(),D=f(),Tb=qP(),Mt=C(),Ab=Tv(),Gc=Jr(),Ov=class extends Mt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privEvents=new Ae.EventSource,this.privDialogServiceConnector=s,this.receiveMessageOverride=()=>this.receiveDialogMessageOverride(),this.privTurnStateManager=new Tb.DialogServiceTurnStateManager,this.recognizeOverride=(o,a,c)=>this.listenOnce(o,a,c),this.postConnectImplOverride=o=>this.dialogConnectImpl(o),this.configConnectionOverride=o=>this.configConnection(o),this.disconnectOverride=()=>this.privDisconnect(),this.privDialogAudioSource=r,this.agentConfigSent=!1,this.privLastResult=null,this.connectionEvents.attach(o=>{o.name==="ConnectionClosedEvent"&&(this.terminateMessageLoop=!0)})}async sendMessage(e){let t=Ae.createGuid(),r=Ae.createNoDashGuid(),n={context:{interactionId:t},messagePayload:JSON.parse(e),version:.5},s=JSON.stringify(n);await(await this.fetchConnection()).send(new Gc.SpeechConnectionMessage(Ae.MessageType.Text,"agent",r,"application/json",s))}async privDisconnect(){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,D.CancellationReason.Error,D.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.agentConfigSent=!1}processTypeSpecificMessages(e){let t=new D.PropertyCollection;e.messageType===Ae.MessageType.Text&&t.setProperty(D.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let r,n;switch(e.path.toLowerCase()){case"speech.phrase":let o=Mt.SimpleSpeechPhrase.fromJSON(e.textBody);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus!==Mt.RecognitionStatus.TooManyRequests&&o.RecognitionStatus!==Mt.RecognitionStatus.Error){let v=this.fireEventForResult(o,t);if(this.privLastResult=v.result,this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,v)}catch{}}n=!0;break;case"speech.hypothesis":let a=Mt.SpeechHypothesis.fromJSON(e.textBody),c=a.Offset+this.privRequestSession.currentTurnAudioOffset;r=new D.SpeechRecognitionResult(this.privRequestSession.requestId,D.ResultReason.RecognizingSpeech,a.Text,a.Duration,c,a.Language,a.LanguageDetectionConfidence,void 0,void 0,e.textBody,t),this.privRequestSession.onHypothesis(c);let u=new D.SpeechRecognitionEventArgs(r,a.Duration,this.privRequestSession.sessionId);if(this.privDialogServiceConnector.recognizing)try{this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector,u)}catch{}n=!0;break;case"speech.keyword":let h=Mt.SpeechKeyword.fromJSON(e.textBody);r=new D.SpeechRecognitionResult(this.privRequestSession.requestId,h.Status==="Accepted"?D.ResultReason.RecognizedKeyword:D.ResultReason.NoMatch,h.Text,h.Duration,h.Offset,void 0,void 0,void 0,void 0,e.textBody,t),h.Status!=="Accepted"&&(this.privLastResult=r);let d=new D.SpeechRecognitionEventArgs(r,r.duration,r.resultId);if(this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,d)}catch{}n=!0;break;case"audio":{let v=e.requestId.toUpperCase(),g=this.privTurnStateManager.GetTurn(v);try{e.binaryBody?g.audioStream.write(e.binaryBody):g.endAudioStream()}catch{}}n=!0;break;case"response":this.handleResponseMessage(e),n=!0;break;default:break}let s=new Ae.Deferred;return s.resolve(n),s.promise}async cancelRecognition(e,t,r,n,s){if(this.terminateMessageLoop=!0,this.privRequestSession.isRecognizing&&await this.privRequestSession.onStopRecognizing(),this.privDialogServiceConnector.canceled){let o=new D.PropertyCollection;o.setProperty(Mt.CancellationErrorCodePropertyName,D.CancellationErrorCode[n]);let a=new D.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privDialogServiceConnector.canceled(this.privDialogServiceConnector,a)}catch{}if(this.privSuccessCallback){let c=new D.SpeechRecognitionResult(void 0,D.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(c),this.privSuccessCallback=void 0}catch{}}}}async listenOnce(e,t,r){this.privRecognizerConfig.recognitionMode=e,this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privDialogAudioSource.events),this.privRecognizerConfig.parameters.setProperty(D.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let n=this.connectImpl(),s=this.sendPreAudioMessages(),o=await this.privDialogAudioSource.attach(this.privRequestSession.audioNodeId),a=await this.privDialogAudioSource.format,c=await this.privDialogAudioSource.deviceInfo,u=new Ib.ReplayableAudioNode(o,a.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(u,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:c};try{await n,await s}catch(v){return await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,D.CancellationReason.Error,D.CancellationErrorCode.ConnectionFailure,v),Promise.resolve()}let h=new D.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,h),this.sendAudio(u).then(()=>{},async v=>{await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,D.CancellationReason.Error,D.CancellationErrorCode.RuntimeError,v)})}dialogConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}receiveDialogMessageOverride(){let e=new Ae.Deferred,t=async()=>{try{let r=this.isDisposed(),n=!this.isDisposed()&&this.terminateMessageLoop;if(r||n){e.resolve(void 0);return}let o=await(await this.fetchConnection()).read();if(!o)return t();let a=Gc.SpeechConnectionMessage.fromConnectionMessage(o);switch(a.path.toLowerCase()){case"turn.start":{let w=a.requestId.toUpperCase(),k=this.privRequestSession.requestId.toUpperCase();w!==k?this.privTurnStateManager.StartTurn(w):this.privRequestSession.onServiceTurnStartResponse()}break;case"speech.startdetected":let u=Mt.SpeechDetected.fromJSON(a.textBody),h=new D.RecognitionEventArgs(u.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,h);break;case"speech.enddetected":let d;a.textBody.length>0?d=a.textBody:d="{ Offset: 0 }";let v=Mt.SpeechDetected.fromJSON(d);this.privRequestSession.onServiceRecognized(v.Offset+this.privRequestSession.currentTurnAudioOffset);let g=new D.RecognitionEventArgs(v.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,g);break;case"turn.end":{let w=a.requestId.toUpperCase(),k=this.privRequestSession.requestId.toUpperCase();if(w!==k)this.privTurnStateManager.CompleteTurn(w);else{let ae=new D.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(!1),(!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing)&&this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,ae),this.privSuccessCallback&&this.privLastResult){try{this.privSuccessCallback(this.privLastResult),this.privLastResult=null}catch(Z){this.privErrorCallback&&this.privErrorCallback(Z)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}}break;default:try{await this.processTypeSpecificMessages(a)||this.serviceEvents&&this.serviceEvents.onEvent(new Ae.ServiceEvent(a.path.toLowerCase(),a.textBody))}catch{}}return t()}catch{this.terminateMessageLoop=!0,e.resolve()}};return t().catch(r=>{Ae.Events.instance.onEvent(new Ae.BackgroundEvent(r))}),e.promise}async startMessageLoop(){this.terminateMessageLoop=!1;try{await this.receiveDialogMessageOverride()}catch(e){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,D.CancellationReason.Error,D.CancellationErrorCode.RuntimeError,e)}return Promise.resolve()}async configConnection(e){return this.terminateMessageLoop?(this.terminateMessageLoop=!1,Promise.reject("Connection to service terminated.")):(await this.sendSpeechServiceConfig(e,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendAgentConfig(e),e)}async sendPreAudioMessages(){let e=await this.fetchConnection();this.addKeywordContextData(),await this.sendSpeechContext(e,!0),await this.sendAgentContext(e),await this.sendWaveHeader(e)}sendAgentConfig(e){if(this.agentConfig&&!this.agentConfigSent){if(this.privRecognizerConfig.parameters.getProperty(D.PropertyId.Conversation_DialogType)===D.DialogServiceConfig.DialogTypes.CustomCommands){let r=this.agentConfig.get();r.botInfo.commandsCulture=this.privRecognizerConfig.parameters.getProperty(D.PropertyId.SpeechServiceConnection_RecoLanguage,"en-us"),this.agentConfig.set(r)}this.onEvent(new wb.SendingAgentContextMessageEvent(this.agentConfig));let t=this.agentConfig.toJsonString();return this.agentConfigSent=!0,e.send(new Gc.SpeechConnectionMessage(Ae.MessageType.Text,"agent.config",this.privRequestSession.requestId,"application/json",t))}}sendAgentContext(e){let t=Ae.createGuid(),r=this.privDialogServiceConnector.properties.getProperty(D.PropertyId.Conversation_Speech_Activity_Template),s=JSON.stringify({channelData:"",context:{interactionId:t},messagePayload:typeof r===void 0?void 0:r,version:.5});return e.send(new Gc.SpeechConnectionMessage(Ae.MessageType.Text,"speech.agent.context",this.privRequestSession.requestId,"application/json",s))}fireEventForResult(e,t){let r=Mt.EnumTranslation.implTranslateRecognitionResult(e.RecognitionStatus),n=e.Offset+this.privRequestSession.currentTurnAudioOffset,s=new D.SpeechRecognitionResult(this.privRequestSession.requestId,r,e.DisplayText,e.Duration,n,e.Language,e.LanguageDetectionConfidence,void 0,void 0,JSON.stringify(e),t);return new D.SpeechRecognitionEventArgs(s,n,this.privRequestSession.sessionId)}handleResponseMessage(e){let t=JSON.parse(e.textBody);switch(t.messageType.toLowerCase()){case"message":let r=e.requestId.toUpperCase(),n=Ab.ActivityPayloadResponse.fromJSON(e.textBody),s=this.privTurnStateManager.GetTurn(r);if(n.conversationId){let c=this.agentConfig.get();c.botInfo.conversationId=n.conversationId,this.agentConfig.set(c)}let o=s.processActivityPayload(n,_b.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(D.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0))),a=new D.ActivityReceivedEventArgs(n.messagePayload,o);if(this.privDialogServiceConnector.activityReceived)try{this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector,a)}catch{}break;case"messagestatus":if(this.privDialogServiceConnector.turnStatusReceived)try{this.privDialogServiceConnector.turnStatusReceived(this.privDialogServiceConnector,new D.TurnStatusReceivedEventArgs(e.textBody))}catch{}break;default:Ae.Events.instance.onEvent(new Ae.BackgroundEvent(`Unexpected response of type ${t.messageType}. Ignoring.`));break}}onEvent(e){this.privEvents.onEvent(e),Ae.Events.instance.onEvent(e)}addKeywordContextData(){let e=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect");if(e===void 0)return;let t=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Offsets"),r=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Durations"),n=e.split(";"),s=t===void 0?[]:t.split(";"),o=r===void 0?[]:r.split(";"),a=[];for(let c=0;c<n.length;c++){let u={};u.text=n[c],c<s.length&&(u.offset=Number(s[c])),c<o.length&&(u.duration=Number(o[c])),a.push(u)}this.speechContext.setSection("invocationSource","VoiceActivationWithKeyword"),this.speechContext.setSection("keywordDetection",[{clientDetectedKeywords:a,onReject:{action:"EndOfTurn"},type:"startTrigger"}])}};$c.DialogServiceAdapter=Ov});var zP=p(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});Qc.AgentConfig=void 0;var Mv=class{toJsonString(){return JSON.stringify(this.iPrivConfig)}get(){return this.iPrivConfig}set(e){this.iPrivConfig=e}};Qc.AgentConfig=Mv});var Xc=p(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});Yc.ConversationConnectionConfig=void 0;var bb=Bl(),Dt=class i extends bb.RestConfigBase{static get host(){return i.privHost}static get apiVersion(){return i.privApiVersion}static get clientAppId(){return i.privClientAppId}static get defaultLanguageCode(){return i.privDefaultLanguageCode}static get restPath(){return i.privRestPath}static get webSocketPath(){return i.privWebSocketPath}static get transcriptionEventKeys(){return i.privTranscriptionEventKeys}};Yc.ConversationConnectionConfig=Dt;Dt.privHost="dev.microsofttranslator.com";Dt.privRestPath="/capito/room";Dt.privApiVersion="2.0";Dt.privDefaultLanguageCode="en-US";Dt.privClientAppId="FC539C22-1767-4F1F-84BC-B4D811114F15";Dt.privWebSocketPath="/capito/translate";Dt.privTranscriptionEventKeys=["iCalUid","callId","organizer","FLAC","MTUri","DifferentiateGuestSpeakers","audiorecording","Threadid","OrganizerMri","OrganizerTenantId","UserToken"]});var jP=p(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});ep.ConversationManager=void 0;var Zc=pe(),mr=I(),Yt=f(),Qr=Xc(),Dv=class{constructor(){this.privRequestParams=Qr.ConversationConnectionConfig.configParams,this.privErrors=Qr.ConversationConnectionConfig.restErrors,this.privHost=Qr.ConversationConnectionConfig.host,this.privApiVersion=Qr.ConversationConnectionConfig.apiVersion,this.privRestPath=Qr.ConversationConnectionConfig.restPath,this.privRestAdapter=new Zc.RestMessageAdapter({})}createOrJoin(e,t,r,n){try{mr.Contracts.throwIfNullOrUndefined(e,"args");let s=e.getProperty(Yt.PropertyId.SpeechServiceConnection_RecoLanguage,Qr.ConversationConnectionConfig.defaultLanguageCode),o=e.getProperty(Yt.PropertyId.ConversationTranslator_Name,"conversation_host"),a=e.getProperty(Yt.PropertyId.ConversationTranslator_Host,this.privHost),c=e.getProperty(Yt.PropertyId.ConversationTranslator_CorrelationId),u=e.getProperty(Yt.PropertyId.SpeechServiceConnection_Key),h=e.getProperty(Yt.PropertyId.SpeechServiceConnection_Region),d=e.getProperty(Yt.PropertyId.SpeechServiceAuthorization_Token);mr.Contracts.throwIfNullOrWhitespace(s,"languageCode"),mr.Contracts.throwIfNullOrWhitespace(o,"nickname"),mr.Contracts.throwIfNullOrWhitespace(a,"endpointHost");let v={};v[this.privRequestParams.apiVersion]=this.privApiVersion,v[this.privRequestParams.languageCode]=s,v[this.privRequestParams.nickname]=o;let g={};c&&(g[this.privRequestParams.correlationId]=c),g[this.privRequestParams.clientAppId]=Qr.ConversationConnectionConfig.clientAppId,t!==void 0?v[this.privRequestParams.roomId]=t:(mr.Contracts.throwIfNullOrUndefined(h,this.privErrors.authInvalidSubscriptionRegion),g[this.privRequestParams.subscriptionRegion]=h,u?g[this.privRequestParams.subscriptionKey]=u:d?g[this.privRequestParams.authorization]=`Bearer ${d}`:mr.Contracts.throwIfNullOrUndefined(u,this.privErrors.authInvalidSubscriptionKey));let w={};w.headers=g,this.privRestAdapter.options=w;let k=`https://${a}${this.privRestPath}`;this.privRestAdapter.request(Zc.RestRequestType.Post,k,v,null).then(ae=>{let Z=Zc.RestMessageAdapter.extractHeaderValue(this.privRequestParams.requestId,ae.headers);if(!ae.ok){if(n){let Oe=this.privErrors.invalidCreateJoinConversationResponse.replace("{status}",ae.status.toString()),F;try{F=JSON.parse(ae.data),Oe+=` [${F.error.code}: ${F.error.message}]`}catch{Oe+=` [${ae.data}]`}Z&&(Oe+=` ${Z}`),n(Oe)}return}let U=JSON.parse(ae.data);if(U&&(U.requestId=Z),r){try{r(U)}catch(Oe){n&&n(Oe)}r=void 0}}).catch(()=>{})}catch(s){if(n)if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}}leave(e,t){return new Promise((r,n)=>{try{mr.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","config")),mr.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","token"));let s=e.getProperty(Yt.PropertyId.ConversationTranslator_Host,this.privHost),o=e.getProperty(Yt.PropertyId.ConversationTranslator_CorrelationId),a={};a[this.privRequestParams.apiVersion]=this.privApiVersion,a[this.privRequestParams.sessionToken]=t;let c={};o&&(c[this.privRequestParams.correlationId]=o);let u={};u.headers=c,this.privRestAdapter.options=u;let h=`https://${s}${this.privRestPath}`;this.privRestAdapter.request(Zc.RestRequestType.Delete,h,a,null).then(d=>{d.ok,r()}).catch(()=>{})}catch(s){if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}})}};ep.ConversationManager=Dv});var Nv=p(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});tp.ConversationConnectionMessage=void 0;var Ob=P(),kv=class extends Ob.ConnectionMessage{constructor(e,t,r,n){super(e,t,r,n);let s=JSON.parse(this.textBody);s.type!==void 0&&(this.privConversationMessageType=s.type)}get conversationMessageType(){return this.privConversationMessageType}};tp.ConversationConnectionMessage=kv});var BP=p(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.ConversationWebsocketMessageFormatter=void 0;var Yr=P(),LP=Nv(),qv=class{toConnectionMessage(e){let t=new Yr.Deferred;try{if(e.messageType===Yr.MessageType.Text){let r=new LP.ConversationConnectionMessage(e.messageType,e.textContent,{},e.id);t.resolve(r)}else e.messageType===Yr.MessageType.Binary&&t.resolve(new LP.ConversationConnectionMessage(e.messageType,e.binaryContent,void 0,e.id))}catch(r){t.reject(`Error formatting the message. Error: ${r}`)}return t.promise}fromConnectionMessage(e){let t=new Yr.Deferred;try{if(e.messageType===Yr.MessageType.Text){let r=`${e.textBody?e.textBody:""}`;t.resolve(new Yr.RawWebsocketMessage(Yr.MessageType.Text,r,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}};rp.ConversationWebsocketMessageFormatter=qv});var VP=p(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});ip.ConversationConnectionFactory=void 0;var FP=pe(),Mb=P(),Db=I(),xv=f(),kb=Ye(),qi=Xc(),Nb=BP(),zv=class extends kb.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(xv.PropertyId.ConversationTranslator_Host,qi.ConversationConnectionConfig.host),s=e.parameters.getProperty(xv.PropertyId.ConversationTranslator_CorrelationId,Mb.createGuid()),o=`wss://${n}${qi.ConversationConnectionConfig.webSocketPath}`,a=e.parameters.getProperty(xv.PropertyId.ConversationTranslator_Token,void 0);Db.Contracts.throwIfNullOrUndefined(a,"token");let c={};c[qi.ConversationConnectionConfig.configParams.apiVersion]=qi.ConversationConnectionConfig.apiVersion,c[qi.ConversationConnectionConfig.configParams.token]=a,c[qi.ConversationConnectionConfig.configParams.correlationId]=s;let u=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new FP.WebsocketConnection(o,c,{},new Nb.ConversationWebsocketMessageFormatter,FP.ProxyInfo.fromRecognizerConfig(e),u,r)}};ip.ConversationConnectionFactory=zv});var UP=p(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});np.ConversationRequestSession=void 0;var jv=P(),Lv=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privSessionId=e,this.privRequestId=jv.createNoDashGuid(),this.privRequestCompletionDeferral=new jv.Deferred}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get completionPromise(){return this.privRequestCompletionDeferral.promise}onPreConnectionStart(e,t){this.privSessionId=t}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){e!==200&&e===403&&this.onComplete()}onServiceTurnEndResponse(e){e?this.privRequestId=jv.createNoDashGuid():this.onComplete()}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach()}}onComplete(){}};np.ConversationRequestSession=Lv});var Kv=p(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.ConversationReceivedTranslationEventArgs=Fe.ParticipantsListEventArgs=Fe.ParticipantAttributeEventArgs=Fe.ParticipantEventArgs=Fe.LockRoomEventArgs=Fe.MuteAllEventArgs=void 0;var Hn=f(),Bv=class extends Hn.SessionEventArgs{constructor(e,t){super(t),this.privIsMuted=e}get isMuted(){return this.privIsMuted}};Fe.MuteAllEventArgs=Bv;var Fv=class extends Hn.SessionEventArgs{constructor(e,t){super(t),this.privIsLocked=e}get isMuted(){return this.privIsLocked}};Fe.LockRoomEventArgs=Fv;var Vv=class extends Hn.SessionEventArgs{constructor(e,t){super(t),this.privParticipant=e}get participant(){return this.privParticipant}};Fe.ParticipantEventArgs=Vv;var Uv=class extends Hn.SessionEventArgs{constructor(e,t,r,n){super(n),this.privKey=t,this.privValue=r,this.privParticipantId=e}get value(){return this.privValue}get key(){return this.privKey}get id(){return this.privParticipantId}};Fe.ParticipantAttributeEventArgs=Uv;var Wv=class extends Hn.SessionEventArgs{constructor(e,t,r,n,s,o,a,c,u){super(u),this.privRoomId=e,this.privSessionToken=t,this.privTranslateTo=r,this.privProfanityFilter=n,this.privRoomProfanityFilter=s,this.privIsRoomLocked=o,this.privIsRoomLocked=a,this.privParticipants=c}get sessionToken(){return this.privSessionToken}get conversationId(){return this.privRoomId}get translateTo(){return this.privTranslateTo}get profanityFilter(){return this.privProfanityFilter}get roomProfanityFilter(){return this.privRoomProfanityFilter}get isRoomLocked(){return this.privIsRoomLocked}get isMuteAll(){return this.privIsMuteAll}get participants(){return this.privParticipants}};Fe.ParticipantsListEventArgs=Wv;var Hv=class{constructor(e,t,r){this.privPayload=t,this.privCommand=e,this.privSessionId=r}get payload(){return this.privPayload}get command(){return this.privCommand}get sessionId(){return this.privSessionId}};Fe.ConversationReceivedTranslationEventArgs=Hv});var Gv=p(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.ConversationTranslatorCommandTypes=Sr.ConversationTranslatorMessageTypes=Sr.InternalParticipants=void 0;var Jv=class{constructor(e=[],t){this.participants=e,this.meId=t}addOrUpdateParticipant(e){if(e===void 0)return;let t=this.getParticipantIndex(e.id);return t>-1?this.participants.splice(t,1,e):this.participants.push(e),this.getParticipant(e.id)}getParticipantIndex(e){return this.participants.findIndex(t=>t.id===e)}getParticipant(e){return this.participants.find(t=>t.id===e)}deleteParticipant(e){this.participants=this.participants.filter(t=>t.id!==e)}get host(){return this.participants.find(e=>e.isHost===!0)}get me(){return this.getParticipant(this.meId)}};Sr.InternalParticipants=Jv;Sr.ConversationTranslatorMessageTypes={command:"command",final:"final",info:"info",instantMessage:"instant_message",keepAlive:"keep_alive",partial:"partial",participantCommand:"participant_command",translatedMessage:"translated_message"};Sr.ConversationTranslatorCommandTypes={changeNickname:"ChangeNickname",disconnectSession:"DisconnectSession",ejectParticipant:"EjectParticipant",instant_message:"instant_message",joinSession:"JoinSession",leaveSession:"LeaveSession",participantList:"ParticipantList",roomExpirationWarning:"RoomExpirationWarning",setLockState:"SetLockState",setMute:"SetMute",setMuteAll:"SetMuteAll",setProfanityFiltering:"SetProfanityFiltering",setTranslateToLanguages:"SetTranslateToLanguages",setUseTTS:"SetUseTTS"}});var WP=p(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});sp.CommandResponsePayload=void 0;var qb=i=>JSON.parse(i),$v=class i{constructor(e){this.privCommandResponse=qb(e)}get type(){return this.privCommandResponse.type}get command(){return this.privCommandResponse.command}get id(){return this.privCommandResponse.id}get nickname(){return this.privCommandResponse.nickname}get participantId(){return this.privCommandResponse.participantId}get roomid(){return this.privCommandResponse.roomid}get value(){return this.privCommandResponse.value}get token(){return this.privCommandResponse.token}static fromJSON(e){return new i(e)}};sp.CommandResponsePayload=$v});var HP=p(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.ParticipantPayloadResponse=xi.ParticipantsListPayloadResponse=void 0;var xb=i=>JSON.parse(i),zb=i=>JSON.parse(i),Qv=class i{constructor(e){this.privParticipantsPayloadResponse=xb(e)}get roomid(){return this.privParticipantsPayloadResponse.roomid}get id(){return this.privParticipantsPayloadResponse.id}get command(){return this.privParticipantsPayloadResponse.command}get participants(){return this.privParticipantsPayloadResponse.participants}get token(){return this.privParticipantsPayloadResponse.token}get translateTo(){return this.privParticipantsPayloadResponse.translateTo}get profanityFilter(){return this.privParticipantsPayloadResponse.profanityFilter}get roomProfanityFilter(){return this.privParticipantsPayloadResponse.roomProfanityFilter}get roomLocked(){return this.privParticipantsPayloadResponse.roomLocked}get muteAll(){return this.privParticipantsPayloadResponse.muteAll}get type(){return this.privParticipantsPayloadResponse.type}static fromJSON(e){return new i(e)}};xi.ParticipantsListPayloadResponse=Qv;var Yv=class i{constructor(e){this.privParticipantPayloadResponse=zb(e)}get nickname(){return this.privParticipantPayloadResponse.nickname}get locale(){return this.privParticipantPayloadResponse.locale}get usetts(){return this.privParticipantPayloadResponse.usetts}get ismuted(){return this.privParticipantPayloadResponse.ismuted}get ishost(){return this.privParticipantPayloadResponse.ishost}get participantId(){return this.privParticipantPayloadResponse.participantId}get avatar(){return this.privParticipantPayloadResponse.avatar}static fromJSON(e){return new i(e)}};xi.ParticipantPayloadResponse=Yv});var KP=p(zi=>{"use strict";Object.defineProperty(zi,"__esModule",{value:!0});zi.TextResponsePayload=zi.SpeechResponsePayload=void 0;var jb=i=>JSON.parse(i),Lb=i=>JSON.parse(i),Xv=class i{constructor(e){this.privSpeechResponse=jb(e)}get recognition(){return this.privSpeechResponse.recognition}get translations(){return this.privSpeechResponse.translations}get id(){return this.privSpeechResponse.id}get language(){return this.privSpeechResponse.language}get nickname(){return this.privSpeechResponse.nickname}get participantId(){return this.privSpeechResponse.participantId}get roomid(){return this.privSpeechResponse.roomid}get timestamp(){return this.privSpeechResponse.timestamp}get type(){return this.privSpeechResponse.type}get isFinal(){return this.privSpeechResponse.type==="final"}static fromJSON(e){return new i(e)}};zi.SpeechResponsePayload=Xv;var Zv=class i{constructor(e){this.privTextResponse=Lb(e)}get originalText(){return this.privTextResponse.originalText}get translations(){return this.privTextResponse.translations}get id(){return this.privTextResponse.id}get language(){return this.privTextResponse.language}get nickname(){return this.privTextResponse.nickname}get participantId(){return this.privTextResponse.participantId}get roomid(){return this.privTextResponse.roomid}get timestamp(){return this.privTextResponse.timestamp}get type(){return this.privTextResponse.type}static fromJSON(e){return new i(e)}};zi.TextResponsePayload=Zv});var $P=p(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});var Bb=WP();Object.defineProperty(Xr,"CommandResponsePayload",{enumerable:!0,get:function(){return Bb.CommandResponsePayload}});var JP=HP();Object.defineProperty(Xr,"ParticipantsListPayloadResponse",{enumerable:!0,get:function(){return JP.ParticipantsListPayloadResponse}});Object.defineProperty(Xr,"ParticipantPayloadResponse",{enumerable:!0,get:function(){return JP.ParticipantPayloadResponse}});var GP=KP();Object.defineProperty(Xr,"SpeechResponsePayload",{enumerable:!0,get:function(){return GP.SpeechResponsePayload}});Object.defineProperty(Xr,"TextResponsePayload",{enumerable:!0,get:function(){return GP.TextResponsePayload}})});var XP=p(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});op.ConversationServiceAdapter=void 0;var Kn=P(),St=f(),QP=C(),YP=Nv(),Fb=UP(),Ke=Kv(),yr=Gv(),Jn=$P(),ef=class extends QP.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privConnectionConfigPromise=void 0,this.privLastPartialUtteranceId="",this.privConversationServiceConnector=s,this.privConversationAuthentication=e,this.receiveMessageOverride=()=>this.receiveConversationMessageOverride(),this.recognizeOverride=()=>this.noOp(),this.postConnectImplOverride=o=>this.conversationConnectImpl(o),this.configConnectionOverride=()=>this.configConnection(),this.disconnectOverride=()=>this.privDisconnect(),this.privConversationRequestSession=new Fb.ConversationRequestSession(Kn.createNoDashGuid()),this.privConversationConnectionFactory=t,this.privConversationIsDisposed=!1}isDisposed(){return super.isDisposed()||this.privConversationIsDisposed}async dispose(e){this.privConversationIsDisposed=!0,this.privConnectionConfigPromise!==void 0&&await(await this.privConnectionConfigPromise).dispose(e),await super.dispose(e)}async sendMessage(e){return(await this.fetchConnection()).send(new YP.ConversationConnectionMessage(Kn.MessageType.Text,e))}async sendMessageAsync(e){await(await this.fetchConnection()).send(new YP.ConversationConnectionMessage(Kn.MessageType.Text,e))}privDisconnect(){if(!this.terminateMessageLoop)return this.cancelRecognition(this.privConversationRequestSession.sessionId,this.privConversationRequestSession.requestId,St.CancellationReason.Error,St.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,Promise.resolve()}async processTypeSpecificMessages(){return!0}cancelRecognition(e,t,r,n,s){this.terminateMessageLoop=!0;let o=new St.ConversationTranslationCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationServiceConnector.canceled&&this.privConversationServiceConnector.canceled(this.privConversationServiceConnector,o)}catch{}}async conversationConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}async receiveConversationMessageOverride(){if(this.isDisposed()||this.terminateMessageLoop)return Promise.resolve();let e=new Kn.Deferred;try{let r=await(await this.fetchConnection()).read();if(this.isDisposed()||this.terminateMessageLoop)return e.resolve(),Promise.resolve();if(!r)return this.receiveConversationMessageOverride();let n=this.privConversationRequestSession.sessionId,s=r.conversationMessageType.toLowerCase(),o=!1;try{switch(s){case"info":case"participant_command":case"command":let a=Jn.CommandResponsePayload.fromJSON(r.textBody);switch(a.command.toLowerCase()){case"participantlist":let g=Jn.ParticipantsListPayloadResponse.fromJSON(r.textBody),w=g.participants.map(F=>({avatar:F.avatar,displayName:F.nickname,id:F.participantId,isHost:F.ishost,isMuted:F.ismuted,isUsingTts:F.usetts,preferredLanguage:F.locale}));this.privConversationServiceConnector.participantsListReceived&&this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector,new Ke.ParticipantsListEventArgs(g.roomid,g.token,g.translateTo,g.profanityFilter,g.roomProfanityFilter,g.roomLocked,g.muteAll,w,n));break;case"settranslatetolanguages":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.setTranslateToLanguages,a.value,n));break;case"setprofanityfiltering":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.setProfanityFiltering,a.value,n));break;case"setmute":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.setMute,a.value,n));break;case"setmuteall":this.privConversationServiceConnector.muteAllCommandReceived&&this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector,new Ke.MuteAllEventArgs(a.value,n));break;case"roomexpirationwarning":this.privConversationServiceConnector.conversationExpiration&&this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector,new St.ConversationExpirationEventArgs(a.value,this.privConversationRequestSession.sessionId));break;case"setusetts":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.setUseTTS,a.value,n));break;case"setlockstate":this.privConversationServiceConnector.lockRoomCommandReceived&&this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector,new Ke.LockRoomEventArgs(a.value,n));break;case"changenickname":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.changeNickname,a.value,n));break;case"joinsession":let k=Jn.ParticipantPayloadResponse.fromJSON(r.textBody),ae={avatar:k.avatar,displayName:k.nickname,id:k.participantId,isHost:k.ishost,isMuted:k.ismuted,isUsingTts:k.usetts,preferredLanguage:k.locale};this.privConversationServiceConnector.participantJoinCommandReceived&&this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantEventArgs(ae,n));break;case"leavesession":let Z={id:a.participantId};this.privConversationServiceConnector.participantLeaveCommandReceived&&this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantEventArgs(Z,n));break;case"disconnectsession":let U={id:a.participantId};break;case"token":let Oe=new QP.CognitiveTokenAuthentication(()=>{let F=a.token;return Promise.resolve(F)},()=>{let F=a.token;return Promise.resolve(F)});this.authentication=Oe,this.privConversationServiceConnector.onToken(Oe);break;default:break}break;case"partial":case"final":let c=Jn.SpeechResponsePayload.fromJSON(r.textBody),u=s==="final"?St.ResultReason.TranslatedParticipantSpeech:St.ResultReason.TranslatingParticipantSpeech,h=new St.ConversationTranslationResult(c.participantId,this.getTranslations(c.translations),c.language,c.id,u,c.recognition,void 0,void 0,r.textBody,void 0);c.isFinal?((h.text!==void 0&&h.text.length>0||c.id===this.privLastPartialUtteranceId)&&(o=!0),o&&this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ke.ConversationReceivedTranslationEventArgs(yr.ConversationTranslatorMessageTypes.final,h,n))):h.text!==void 0&&(this.privLastPartialUtteranceId=c.id,this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ke.ConversationReceivedTranslationEventArgs(yr.ConversationTranslatorMessageTypes.partial,h,n)));break;case"translated_message":let d=Jn.TextResponsePayload.fromJSON(r.textBody),v=new St.ConversationTranslationResult(d.participantId,this.getTranslations(d.translations),d.language,void 0,void 0,d.originalText,void 0,void 0,void 0,r.textBody,void 0);this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ke.ConversationReceivedTranslationEventArgs(yr.ConversationTranslatorMessageTypes.instantMessage,v,n));break;default:break}}catch{}return this.receiveConversationMessageOverride()}catch{this.terminateMessageLoop=!0}return e.promise}async startMessageLoop(){if(this.isDisposed())return Promise.resolve();this.terminateMessageLoop=!1;let e=this.receiveConversationMessageOverride();try{return await e}catch(t){return this.cancelRecognition(this.privRequestSession?this.privRequestSession.sessionId:"",this.privRequestSession?this.privRequestSession.requestId:"",St.CancellationReason.Error,St.CancellationErrorCode.RuntimeError,t),null}}configConnection(){return this.isDisposed()?Promise.resolve(void 0):this.privConnectionConfigPromise!==void 0?this.privConnectionConfigPromise.then(e=>e.state()===Kn.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection()):this.privConnectionConfigPromise,()=>(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection())):this.terminateMessageLoop?Promise.resolve(void 0):(this.privConnectionConfigPromise=this.connectImpl().then(e=>e),this.privConnectionConfigPromise)}getTranslations(e){let t;if(e!==void 0){t=new St.Translations;for(let r of e)t.set(r.lang,r.translation)}return t}};op.ConversationServiceAdapter=ef});var ZP=p(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.ConversationTranslatorRecognizer=Bi.ConversationRecognizerFactory=void 0;var Vb=C(),ji=P(),Li=I(),tf=f(),Ub=VP(),Wb=XP(),rf=class{static fromConfig(e,t,r){return new ap(e,t,r)}};Bi.ConversationRecognizerFactory=rf;var ap=class extends tf.Recognizer{constructor(e,t,r){let n=t;Li.Contracts.throwIfNull(n,"speechConfig");let s=e;Li.Contracts.throwIfNull(s,"conversationImpl"),super(r,n.properties,new Ub.ConversationConnectionFactory),this.privConversation=s,this.privIsDisposed=!1,this.privProperties=n.properties.clone(),this.privConnection=tf.Connection.fromRecognizer(this),this.privProperties.getProperty(tf.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?(this.privSetTimeout=ji.Timeout.setTimeout,this.privClearTimeout=ji.Timeout.clearTimeout):typeof window<"u"?(this.privSetTimeout=window.setTimeout.bind(window),this.privClearTimeout=window.clearTimeout.bind(window)):(this.privSetTimeout=setTimeout,this.privClearTimeout=clearTimeout)}set connected(e){this.privConnection.connected=e}set disconnected(e){this.privConnection.disconnected=e}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get properties(){return this.privProperties}isDisposed(){return this.privIsDisposed}connect(e,t,r){try{Li.Contracts.throwIfDisposed(this.privIsDisposed),Li.Contracts.throwIfNullOrWhitespace(e,"token"),this.privReco.conversationTranslatorToken=e,this.resetConversationTimeout(),this.privReco.connectAsync(t,r)}catch(n){if(r)if(n instanceof Error){let s=n;r(s.name+": "+s.message)}else r(n)}}disconnect(e,t){try{Li.Contracts.throwIfDisposed(this.privIsDisposed),this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privReco.disconnect().then(()=>{e&&e()},r=>{t&&t(r)})}catch(r){if(t)if(r instanceof Error){let n=r;t(n.name+": "+n.message)}else t(r);this.dispose(!0).catch(n=>{ji.Events.instance.onEvent(new ji.BackgroundEvent(n))})}}sendRequest(e,t,r){try{Li.Contracts.throwIfDisposed(this.privIsDisposed),this.sendMessage(e,t,r)}catch(n){if(r)if(n instanceof Error){let s=n;r(s.name+": "+s.message)}else r(n);this.dispose(!0).catch(s=>{ji.Events.instance.onEvent(new ji.BackgroundEvent(s))})}}onToken(e){this.privConversation.onToken(e)}async close(){this.privIsDisposed||(this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close()),this.privConnection=void 0,await this.dispose(!0))}async dispose(e){this.privIsDisposed||e&&(this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privIsDisposed=!0,this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close(),this.privConnection=void 0),await super.dispose(e))}createRecognizerConfig(e){return new Vb.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Wb.ConversationServiceAdapter(e,t,s,n,this)}sendMessage(e,t,r){let n=this.privReco;((o,a,c)=>{o!==void 0?o.then(()=>{try{a&&a()}catch(u){c&&c(`'Unhandled error on promise callback: ${u}'`)}},u=>{try{c&&c(u)}catch{}}):c&&c("Null promise")})(n.sendMessageAsync(e),t,r),this.resetConversationTimeout()}resetConversationTimeout(){this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privTimeoutToken=this.privSetTimeout(()=>{this.sendRequest(this.privConversation.getKeepAlive())},6e4)}};Bi.ConversationTranslatorRecognizer=ap});var tR=p(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});pp.TranscriberRecognizer=void 0;var eR=P(),yt=I(),Fi=f(),cp=C(),nf=class extends Fi.Recognizer{constructor(e,t){let r=e;yt.Contracts.throwIfNull(r,"speechTranslationConfig");let n=t;yt.Contracts.throwIfNull(n,"audioConfigImpl"),yt.Contracts.throwIfNullOrWhitespace(r.speechRecognitionLanguage,Fi.PropertyId[Fi.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new cp.TranscriberConnectionFactory),this.privDisposedRecognizer=!1,this.isMeetingRecognizer=!1}get speechRecognitionLanguage(){return yt.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Fi.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Fi.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){yt.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Fi.PropertyId.SpeechServiceAuthorization_Token,e)}set conversation(e){yt.Contracts.throwIfNullOrUndefined(e,"Conversation"),this.isMeetingRecognizer=!1,this.privConversation=e}getConversationInfo(){return yt.Contracts.throwIfNullOrUndefined(this.privConversation,"Conversation"),this.privConversation.conversationInfo}set meeting(e){yt.Contracts.throwIfNullOrUndefined(e,"Meeting"),this.isMeetingRecognizer=!0,this.privMeeting=e}getMeetingInfo(){return yt.Contracts.throwIfNullOrUndefined(this.privMeeting,"Meeting"),this.privMeeting.meetingInfo}IsMeetingRecognizer(){return this.isMeetingRecognizer}startContinuousRecognitionAsync(e,t){eR.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(cp.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){eR.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}async close(){this.privDisposedRecognizer||await this.dispose(!0)}async pushConversationEvent(e,t){let r=this.privReco;yt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendSpeechEventAsync(e,t)}async pushMeetingEvent(e,t){let r=this.privReco;yt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendMeetingSpeechEventAsync(e,t)}async enforceAudioGating(){let r=(await this.audioConfig.format).channels;if(r===1){if(this.properties.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()!=="true")throw new Error("Single channel audio configuration for MeetingTranscriber is currently under private preview, please contact diarizationrequest@microsoft.com for more details")}else if(r!==8)throw new Error(`Unsupported audio configuration: Detected ${r}-channel audio`)}connectMeetingCallbacks(e){this.isMeetingRecognizer=!0,this.canceled=(t,r)=>{e.canceled&&e.canceled(e,r)},this.recognizing=(t,r)=>{e.transcribing&&e.transcribing(e,r)},this.recognized=(t,r)=>{e.transcribed&&e.transcribed(e,r)},this.sessionStarted=(t,r)=>{e.sessionStarted&&e.sessionStarted(e,r)},this.sessionStopped=(t,r)=>{e.sessionStopped&&e.sessionStopped(e,r)}}disconnectCallbacks(){this.canceled=void 0,this.recognizing=void 0,this.recognized=void 0,this.sessionStarted=void 0,this.sessionStopped=void 0}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new cp.RecognizerConfig(e,this.properties)}createServiceRecognizer(e,t,r,n){let s=r;return new cp.TranscriptionServiceRecognizer(e,t,s,n,this)}};pp.TranscriberRecognizer=nf});var rR=p(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});var Hb=jP();Object.defineProperty(qe,"ConversationManager",{enumerable:!0,get:function(){return Hb.ConversationManager}});var Kb=Xc();Object.defineProperty(qe,"ConversationConnectionConfig",{enumerable:!0,get:function(){return Kb.ConversationConnectionConfig}});var Jb=ZP();Object.defineProperty(qe,"ConversationRecognizerFactory",{enumerable:!0,get:function(){return Jb.ConversationRecognizerFactory}});var Gb=tR();Object.defineProperty(qe,"TranscriberRecognizer",{enumerable:!0,get:function(){return Gb.TranscriberRecognizer}});var Vi=Kv();Object.defineProperty(qe,"ConversationReceivedTranslationEventArgs",{enumerable:!0,get:function(){return Vi.ConversationReceivedTranslationEventArgs}});Object.defineProperty(qe,"LockRoomEventArgs",{enumerable:!0,get:function(){return Vi.LockRoomEventArgs}});Object.defineProperty(qe,"MuteAllEventArgs",{enumerable:!0,get:function(){return Vi.MuteAllEventArgs}});Object.defineProperty(qe,"ParticipantAttributeEventArgs",{enumerable:!0,get:function(){return Vi.ParticipantAttributeEventArgs}});Object.defineProperty(qe,"ParticipantEventArgs",{enumerable:!0,get:function(){return Vi.ParticipantEventArgs}});Object.defineProperty(qe,"ParticipantsListEventArgs",{enumerable:!0,get:function(){return Vi.ParticipantsListEventArgs}});var sf=Gv();Object.defineProperty(qe,"ConversationTranslatorCommandTypes",{enumerable:!0,get:function(){return sf.ConversationTranslatorCommandTypes}});Object.defineProperty(qe,"ConversationTranslatorMessageTypes",{enumerable:!0,get:function(){return sf.ConversationTranslatorMessageTypes}});Object.defineProperty(qe,"InternalParticipants",{enumerable:!0,get:function(){return sf.InternalParticipants}})});var af=p(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.SynthesisAudioMetadata=Zr.MetadataType=void 0;var $b;(function(i){i.WordBoundary="WordBoundary",i.Bookmark="Bookmark",i.Viseme="Viseme",i.SentenceBoundary="SentenceBoundary",i.SessionEnd="SessionEnd",i.AvatarSignal="TalkingAvatarSignal"})($b=Zr.MetadataType||(Zr.MetadataType={}));var of=class i{constructor(e){this.privSynthesisAudioMetadata=JSON.parse(e)}static fromJSON(e){return new i(e)}get Metadata(){return this.privSynthesisAudioMetadata.Metadata}};Zr.SynthesisAudioMetadata=of});var nR=p(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.SynthesisStartedEvent=kt.ConnectingToSynthesisServiceEvent=kt.SynthesisTriggeredEvent=kt.SpeechSynthesisEvent=void 0;var iR=P(),Ui=class extends iR.PlatformEvent{constructor(e,t,r=iR.EventType.Info){super(e,r),this.privRequestId=t}get requestId(){return this.privRequestId}};kt.SpeechSynthesisEvent=Ui;var cf=class extends Ui{constructor(e,t,r){super("SynthesisTriggeredEvent",e),this.privSessionAudioDestinationId=t,this.privTurnAudioDestinationId=r}get audioSessionDestinationId(){return this.privSessionAudioDestinationId}get audioTurnDestinationId(){return this.privTurnAudioDestinationId}};kt.SynthesisTriggeredEvent=cf;var pf=class extends Ui{constructor(e,t){super("ConnectingToSynthesisServiceEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};kt.ConnectingToSynthesisServiceEvent=pf;var uf=class extends Ui{constructor(e,t){super("SynthesisStartedEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};kt.SynthesisStartedEvent=uf});var sR=p(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});dp.SynthesisTurn=void 0;var up=P(),Qb=br(),hp=f(),Yb=af(),hf=nR(),df=class i{constructor(){this.privIsDisposed=!1,this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!1,this.privBytesReceived=0,this.privInTurn=!1,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privRequestId=up.createNoDashGuid(),this.privTurnDeferral=new up.Deferred,this.privTurnDeferral.resolve()}get requestId(){return this.privRequestId}get streamId(){return this.privStreamId}set streamId(e){this.privStreamId=e}get audioOutputFormat(){return this.privAudioOutputFormat}set audioOutputFormat(e){this.privAudioOutputFormat=e}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSynthesisEnded(){return this.privIsSynthesisEnded}get isSynthesizing(){return this.privIsSynthesizing}get currentTextOffset(){return this.privTextOffset}get currentSentenceOffset(){return this.privSentenceOffset}get bytesReceived(){return this.privBytesReceived}get audioDuration(){return this.privAudioDuration}get extraProperties(){if(this.privWebRTCSDP){let e=new hp.PropertyCollection;return e.setProperty(hp.PropertyId.TalkingAvatarService_WebRTC_SDP,this.privWebRTCSDP),e}}async getAllReceivedAudio(){return this.privReceivedAudio?Promise.resolve(this.privReceivedAudio):this.privIsSynthesisEnded?(await this.readAllAudioFromStream(),Promise.resolve(this.privReceivedAudio)):null}async getAllReceivedAudioWithHeader(){if(this.privReceivedAudioWithHeader)return this.privReceivedAudioWithHeader;if(!this.privIsSynthesisEnded)return null;if(this.audioOutputFormat.hasHeader){let e=await this.getAllReceivedAudio();return this.privReceivedAudioWithHeader=this.audioOutputFormat.addHeader(e),this.privReceivedAudioWithHeader}else return this.getAllReceivedAudio()}startNewSynthesis(e,t,r,n){this.privIsSynthesisEnded=!1,this.privIsSynthesizing=!0,this.privRequestId=e,this.privRawText=t,this.privIsSSML=r,this.privAudioOutputStream=new Qb.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privAudioOutputFormat,this.privReceivedAudio=null,this.privReceivedAudioWithHeader=null,this.privBytesReceived=0,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privPartialVisemeAnimation="",this.privWebRTCSDP="",n!==void 0&&(this.privTurnAudioDestination=n,this.privTurnAudioDestination.format=this.privAudioOutputFormat),this.onEvent(new hf.SynthesisTriggeredEvent(this.requestId,void 0,n===void 0?void 0:n.id()))}onPreConnectionStart(e){this.privAuthFetchEventId=e,this.onEvent(new hf.ConnectingToSynthesisServiceEvent(this.privRequestId,this.privAuthFetchEventId))}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){if(e===200){this.onEvent(new hf.SynthesisStartedEvent(this.requestId,this.privAuthFetchEventId)),this.privBytesReceived=0;return}else e===403&&this.onComplete()}onServiceResponseMessage(e){let t=JSON.parse(e);this.streamId=t.audio.streamId}onServiceTurnEndResponse(){this.privInTurn=!1,this.privTurnDeferral.resolve(),this.onComplete()}onServiceTurnStartResponse(e){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch(()=>{})),this.privInTurn=!0,this.privTurnDeferral=new up.Deferred;let t=JSON.parse(e);t.webrtc&&(this.privWebRTCSDP=t.webrtc.connectionString)}onAudioChunkReceived(e){this.isSynthesizing&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength,this.privTurnAudioDestination!==void 0&&this.privTurnAudioDestination.write(e))}onTextBoundaryEvent(e){this.updateTextOffset(e.Data.text.Text,e.Type)}onVisemeMetadataReceived(e){e.Data.AnimationChunk!==void 0&&(this.privPartialVisemeAnimation+=e.Data.AnimationChunk)}onSessionEnd(e){this.privAudioDuration=e.Data.Offset}async constructSynthesisResult(){let e=await this.getAllReceivedAudioWithHeader();return new hp.SpeechSynthesisResult(this.requestId,hp.ResultReason.SynthesizingAudioCompleted,e,void 0,this.extraProperties,this.audioDuration)}dispose(){this.privIsDisposed||(this.privIsDisposed=!0)}onStopSynthesizing(){this.onComplete()}getAndClearVisemeAnimation(){let e=this.privPartialVisemeAnimation;return this.privPartialVisemeAnimation="",e}onEvent(e){up.Events.instance.onEvent(e)}static isXmlTag(e){return e.length>=2&&e[0]==="<"&&e[e.length-1]===">"}updateTextOffset(e,t){t===Yb.MetadataType.WordBoundary?(this.privTextOffset=this.privRawText.indexOf(e,this.privNextSearchTextIndex),this.privTextOffset>=0&&(this.privNextSearchTextIndex=this.privTextOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privTextOffset)&&!i.isXmlTag(e)&&this.updateTextOffset(e,t))):(this.privSentenceOffset=this.privRawText.indexOf(e,this.privNextSearchSentenceIndex),this.privSentenceOffset>=0&&(this.privNextSearchSentenceIndex=this.privSentenceOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privSentenceOffset)&&!i.isXmlTag(e)&&this.updateTextOffset(e,t)))}onComplete(){this.privIsSynthesizing&&(this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!0,this.privAudioOutputStream.close(),this.privInTurn=!1,this.privTurnAudioDestination!==void 0&&(this.privTurnAudioDestination.close(),this.privTurnAudioDestination=void 0))}async readAllAudioFromStream(){if(this.privIsSynthesisEnded){this.privReceivedAudio=new ArrayBuffer(this.bytesReceived);try{await this.privAudioOutputStream.read(this.privReceivedAudio)}catch{this.privReceivedAudio=new ArrayBuffer(0)}}}withinXmlTag(e){return this.privRawText.indexOf("<",e+1)>this.privRawText.indexOf(">",e+1)}};dp.SynthesisTurn=df});var oR=p(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});vp.SynthesisAdapterBase=void 0;var be=P(),Je=f(),st=C(),Wi=Jr(),lp=class{constructor(e,t,r,n){if(this.speakOverride=void 0,this.receiveMessageOverride=void 0,this.connectImplOverride=void 0,this.configConnectionOverride=void 0,this.privConnectionConfigurationPromise=void 0,!e)throw new be.ArgumentNullError("authentication");if(!t)throw new be.ArgumentNullError("connectionFactory");if(!r)throw new be.ArgumentNullError("synthesizerConfig");this.privAuthentication=e,this.privConnectionFactory=t,this.privSynthesizerConfig=r,this.privIsDisposed=!1,this.privSessionAudioDestination=n,this.privSynthesisTurn=new st.SynthesisTurn,this.privConnectionEvents=new be.EventSource,this.privServiceEvents=new be.EventSource,this.privSynthesisContext=new st.SynthesisContext,this.privAgentConfig=new st.AgentConfig,this.connectionEvents.attach(s=>{if(s.name==="ConnectionClosedEvent"){let o=s;o.statusCode!==1e3&&this.cancelSynthesisLocal(Je.CancellationReason.Error,o.statusCode===1007?Je.CancellationErrorCode.BadRequestParameters:Je.CancellationErrorCode.ConnectionFailure,`${o.reason} websocket error code: ${o.statusCode}`)}})}get synthesisContext(){return this.privSynthesisContext}get agentConfig(){return this.privAgentConfig}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set audioOutputFormat(e){this.privAudioOutputFormat=e,this.privSynthesisTurn.audioOutputFormat=e,this.privSessionAudioDestination!==void 0&&(this.privSessionAudioDestination.format=e),this.synthesisContext!==void 0&&(this.synthesisContext.audioOutputFormat=e)}isDisposed(){return this.privIsDisposed}async dispose(e){this.privIsDisposed=!0,this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.close(),this.privConnectionConfigurationPromise!==void 0&&await(await this.privConnectionConfigurationPromise).dispose(e)}async connect(){await this.connectImpl()}async sendNetworkMessage(e,t){let r=typeof t=="string"?be.MessageType.Text:be.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new Wi.SpeechConnectionMessage(r,e,this.privSynthesisTurn.requestId,n,t))}async Speak(e,t,r,n,s,o){let a;if(t?a=e:a=this.privSynthesizer.buildSsml(e),this.speakOverride!==void 0)return this.speakOverride(a,r,n,s);this.privSuccessCallback=n,this.privErrorCallback=s,this.privSynthesisTurn.startNewSynthesis(r,e,t,o);try{await this.connectImpl();let c=await this.fetchConnection();await this.sendSynthesisContext(c),await this.sendSsmlMessage(c,a,r),this.onSynthesisStarted(r),this.receiveMessage()}catch(c){return this.cancelSynthesisLocal(Je.CancellationReason.Error,Je.CancellationErrorCode.ConnectionFailure,c),Promise.reject(c)}}async stopSpeaking(){return await this.connectImpl(),(await this.fetchConnection()).send(new Wi.SpeechConnectionMessage(be.MessageType.Text,"synthesis.control",this.privSynthesisTurn.requestId,"application/json",JSON.stringify({action:"stop"})))}cancelSynthesis(e,t,r,n){let s=new Je.PropertyCollection;s.setProperty(st.CancellationErrorCodePropertyName,Je.CancellationErrorCode[r]);let o=new Je.SpeechSynthesisResult(e,Je.ResultReason.Canceled,void 0,n,s);if(this.onSynthesisCancelled(o),this.privSuccessCallback)try{this.privSuccessCallback(o)}catch{}}cancelSynthesisLocal(e,t,r){this.privSynthesisTurn.isSynthesizing&&(this.privSynthesisTurn.onStopSynthesizing(),this.cancelSynthesis(this.privSynthesisTurn.requestId,e,t,r))}processTypeSpecificMessages(e){return!0}async receiveMessage(){try{let t=await(await this.fetchConnection()).read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(this.privIsDisposed)return;if(!t)return this.privSynthesisTurn.isSynthesizing?this.receiveMessage():void 0;let r=Wi.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privSynthesisTurn.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privSynthesisTurn.onServiceTurnStartResponse(r.textBody);break;case"response":this.privSynthesisTurn.onServiceResponseMessage(r.textBody);break;case"audio":this.privSynthesisTurn.streamId.toLowerCase()===r.streamId.toLowerCase()&&r.binaryBody&&(this.privSynthesisTurn.onAudioChunkReceived(r.binaryBody),this.onSynthesizing(r.binaryBody),this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.write(r.binaryBody));break;case"audio.metadata":let n=st.SynthesisAudioMetadata.fromJSON(r.textBody).Metadata;for(let o of n)switch(o.Type){case st.MetadataType.WordBoundary:case st.MetadataType.SentenceBoundary:this.privSynthesisTurn.onTextBoundaryEvent(o);let a=new Je.SpeechSynthesisWordBoundaryEventArgs(o.Data.Offset,o.Data.Duration,o.Data.text.Text,o.Data.text.Length,o.Type===st.MetadataType.WordBoundary?this.privSynthesisTurn.currentTextOffset:this.privSynthesisTurn.currentSentenceOffset,o.Data.text.BoundaryType);this.onWordBoundary(a);break;case st.MetadataType.Bookmark:let c=new Je.SpeechSynthesisBookmarkEventArgs(o.Data.Offset,o.Data.Bookmark);this.onBookmarkReached(c);break;case st.MetadataType.Viseme:if(this.privSynthesisTurn.onVisemeMetadataReceived(o),o.Data.IsLastAnimation){let u=new Je.SpeechSynthesisVisemeEventArgs(o.Data.Offset,o.Data.VisemeId,this.privSynthesisTurn.getAndClearVisemeAnimation());this.onVisemeReceived(u)}break;case st.MetadataType.AvatarSignal:this.onAvatarEvent(o);break;case st.MetadataType.SessionEnd:this.privSynthesisTurn.onSessionEnd(o);break}break;case"turn.end":this.privSynthesisTurn.onServiceTurnEndResponse();let s;try{s=await this.privSynthesisTurn.constructSynthesisResult(),this.privSuccessCallback&&this.privSuccessCallback(s)}catch(o){this.privErrorCallback&&this.privErrorCallback(o)}this.onSynthesisCompleted(s);break;default:this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new be.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch{}}sendSynthesisContext(e){this.setSynthesisContextSynthesisSection();let t=this.synthesisContext.toJSON();if(t)return e.send(new Wi.SpeechConnectionMessage(be.MessageType.Text,"synthesis.context",this.privSynthesisTurn.requestId,"application/json",t))}setSpeechConfigSynthesisSection(){}connectImpl(e=!1){if(this.privConnectionPromise!=null)return this.privConnectionPromise.then(r=>r.state()===be.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()));this.privAuthFetchEventId=be.createNoDashGuid(),this.privConnectionId=be.createNoDashGuid(),this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId);let t=e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId);return this.privConnectionPromise=t.then(async r=>{this.privSynthesisTurn.onAuthCompleted(!1);let n=this.privConnectionFactory.create(this.privSynthesizerConfig,r,this.privConnectionId);n.events.attach(o=>{this.connectionEvents.onEvent(o)});let s=await n.open();return s.statusCode===200?(this.privSynthesisTurn.onConnectionEstablishCompleted(s.statusCode),Promise.resolve(n)):s.statusCode===403&&!e?this.connectImpl(!0):(this.privSynthesisTurn.onConnectionEstablishCompleted(s.statusCode),Promise.reject(`Unable to contact server. StatusCode: ${s.statusCode},
23
- ${this.privSynthesizerConfig.parameters.getProperty(Je.PropertyId.SpeechServiceConnection_Url)} Reason: ${s.reason}`))},r=>{throw this.privSynthesisTurn.onAuthCompleted(!0),new Error(r)}),this.privConnectionPromise.catch(()=>{}),this.privConnectionPromise}sendSpeechServiceConfig(e,t){if(t)return e.send(new Wi.SpeechConnectionMessage(be.MessageType.Text,"speech.config",this.privSynthesisTurn.requestId,"application/json",t))}sendSsmlMessage(e,t,r){return e.send(new Wi.SpeechConnectionMessage(be.MessageType.Text,"ssml",r,"application/ssml+xml",t))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===be.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async configureConnection(){let e=await this.connectImpl();return this.configConnectionOverride!==void 0?this.configConnectionOverride(e):(this.setSpeechConfigSynthesisSection(),await this.sendSpeechServiceConfig(e,this.privSynthesizerConfig.SpeechServiceConfig.serialize()),e)}onAvatarEvent(e){}onSynthesisStarted(e){}onSynthesizing(e){}onSynthesisCancelled(e){}onSynthesisCompleted(e){}onWordBoundary(e){}onVisemeReceived(e){}onBookmarkReached(e){}};vp.SynthesisAdapterBase=lp;lp.telemetryDataEnabled=!0});var cR=p(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});fp.AvatarSynthesisAdapter=void 0;var aR=f(),Xb=C(),lf=class extends Xb.SynthesisAdapterBase{constructor(e,t,r,n,s){super(e,t,r,void 0),this.privAvatarSynthesizer=n,this.privSynthesizer=n,this.privAvatarConfig=s}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(void 0)}setSpeechConfigSynthesisSection(){this.privSynthesizerConfig.synthesisVideoSection={format:{bitrate:this.privAvatarConfig.videoFormat?.bitrate,codec:this.privAvatarConfig.videoFormat?.codec,crop:{bottomRight:{x:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.y},topLeft:{x:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.y}},resolution:{height:this.privAvatarConfig.videoFormat?.height,width:this.privAvatarConfig.videoFormat?.width}},protocol:{name:"WebRTC",webrtcConfig:{clientDescription:btoa(this.privSynthesizerConfig.parameters.getProperty(aR.PropertyId.TalkingAvatarService_WebRTC_SDP)),iceServers:this.privAvatarSynthesizer.iceServers}},talkingAvatar:{background:{color:this.privAvatarConfig.backgroundColor},character:this.privAvatarConfig.character,customized:this.privAvatarConfig.customized,style:this.privAvatarConfig.style}}}onAvatarEvent(e){if(this.privAvatarSynthesizer.avatarEventReceived){let t=new aR.AvatarEventArgs(e.Data.Offset,e.Data.Name);try{this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer,t)}catch{}}}};fp.AvatarSynthesisAdapter=lf});var pR=p(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0});gp.SpeechSynthesisAdapter=void 0;var Cr=f(),Zb=C(),vf=class extends Zb.SynthesisAdapterBase{constructor(e,t,r,n,s){super(e,t,r,s),this.privSpeechSynthesizer=n,this.privSynthesizer=n}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(this.privSpeechSynthesizer)}onSynthesisStarted(e){let t=new Cr.SpeechSynthesisEventArgs(new Cr.SpeechSynthesisResult(e,Cr.ResultReason.SynthesizingAudioStarted));this.privSpeechSynthesizer.synthesisStarted&&this.privSpeechSynthesizer.synthesisStarted(this.privSpeechSynthesizer,t)}onSynthesizing(e){if(this.privSpeechSynthesizer.synthesizing)try{let t=this.privSynthesisTurn.audioOutputFormat.addHeader(e),r=new Cr.SpeechSynthesisEventArgs(new Cr.SpeechSynthesisResult(this.privSynthesisTurn.requestId,Cr.ResultReason.SynthesizingAudio,t));this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer,r)}catch{}}onSynthesisCancelled(e){if(this.privSpeechSynthesizer.SynthesisCanceled){let t=new Cr.SpeechSynthesisEventArgs(e);try{this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer,t)}catch{}}}onSynthesisCompleted(e){if(this.privSpeechSynthesizer.synthesisCompleted)try{this.privSpeechSynthesizer.synthesisCompleted(this.privSpeechSynthesizer,new Cr.SpeechSynthesisEventArgs(e))}catch{}}onWordBoundary(e){if(this.privSpeechSynthesizer.wordBoundary)try{this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer,e)}catch{}}onVisemeReceived(e){if(this.privSpeechSynthesizer.visemeReceived)try{this.privSpeechSynthesizer.visemeReceived(this.privSpeechSynthesizer,e)}catch{}}onBookmarkReached(e){if(this.privSpeechSynthesizer.bookmarkReached)try{this.privSpeechSynthesizer.bookmarkReached(this.privSpeechSynthesizer,e)}catch{}}};gp.SpeechSynthesisAdapter=vf});var uR=p(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});mp.SynthesisRestAdapter=void 0;var ff=pe(),gf=f(),eO=Ye(),tO=we(),mf=class{constructor(e,t){let r=e.parameters.getProperty(gf.PropertyId.SpeechServiceConnection_Endpoint,void 0);if(!r){let s=e.parameters.getProperty(gf.PropertyId.SpeechServiceConnection_Region,"westus"),o=eO.ConnectionFactoryBase.getHostSuffix(s);r=e.parameters.getProperty(gf.PropertyId.SpeechServiceConnection_Host,`https://${s}.tts.speech${o}`)}this.privUri=`${r}/cognitiveservices/voices/list`;let n=ff.RestConfigBase.requestOptions;this.privRestAdapter=new ff.RestMessageAdapter(n),this.privAuthentication=t}getVoicesList(e){return this.privRestAdapter.setHeaders(tO.HeaderNames.ConnectionId,e),this.privAuthentication.fetch(e).then(t=>(this.privRestAdapter.setHeaders(t.headerName,t.token),this.privRestAdapter.request(ff.RestRequestType.Get,this.privUri)))}};mp.SynthesisRestAdapter=mf});var lR=p(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.SynthesizerConfig=ei.SynthesisServiceType=void 0;var hR=C(),dR;(function(i){i[i.Standard=0]="Standard",i[i.Custom=1]="Custom"})(dR=ei.SynthesisServiceType||(ei.SynthesisServiceType={}));var Sf=class{constructor(e,t){this.privSynthesisServiceType=dR.Standard,this.avatarEnabled=!1,this.privSpeechServiceConfig=e||new hR.SpeechServiceConfig(new hR.Context(null)),this.privParameters=t}get parameters(){return this.privParameters}get synthesisServiceType(){return this.privSynthesisServiceType}set synthesisServiceType(e){this.privSynthesisServiceType=e}set synthesisVideoSection(e){this.privSpeechServiceConfig.Context.synthesis={video:e}}get SpeechServiceConfig(){return this.privSpeechServiceConfig}};ei.SynthesizerConfig=Sf});var vR=p(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});Sp.SynthesisContext=void 0;var yf=f(),Cf=class{constructor(){this.privContext={}}setSection(e,t){this.privContext[e]=t}set audioOutputFormat(e){this.privAudioOutputFormat=e}toJSON(){return JSON.stringify(this.privContext)}setSynthesisSection(e){let t=this.buildSynthesisContext(e);this.setSection("synthesis",t)}buildSynthesisContext(e){return{audio:{metadataOptions:{bookmarkEnabled:!!e?.bookmarkReached,punctuationBoundaryEnabled:e?.properties.getProperty(yf.PropertyId.SpeechServiceResponse_RequestPunctuationBoundary,!!e?.wordBoundary),sentenceBoundaryEnabled:e?.properties.getProperty(yf.PropertyId.SpeechServiceResponse_RequestSentenceBoundary,!1),sessionEndEnabled:!0,visemeEnabled:!!e?.visemeReceived,wordBoundaryEnabled:e?.properties.getProperty(yf.PropertyId.SpeechServiceResponse_RequestWordBoundary,!!e?.wordBoundary)},outputFormat:this.privAudioOutputFormat.requestAudioFormatString},language:{autoDetection:e?.autoDetectSourceLanguage}}}};Sp.SynthesisContext=Cf});var fR=p(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});yp.SpeakerRecognitionConfig=void 0;var rO=C(),Pf=class{constructor(e,t){this.privContext=e||new rO.Context(null),this.privParameters=t}get parameters(){return this.privParameters}get Context(){return this.privContext}};yp.SpeakerRecognitionConfig=Pf});var mR=p(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});Pp.SpeakerServiceRecognizer=void 0;var iO=pe(),Cp=P(),Ce=f(),gR=C(),nO=Jr(),Rf=class extends gR.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeakerRecognizer=s,this.privSpeakerAudioSource=r,this.recognizeSpeaker=o=>this.recognizeSpeakerOnce(o),this.sendPrePayloadJSONOverride=()=>this.noOp()}processTypeSpecificMessages(e){let t=!1,r=new Ce.PropertyCollection;switch(e.messageType===Cp.MessageType.Text&&r.setProperty(Ce.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.response":let s=JSON.parse(e.textBody),o;s.status.statusCode.toLowerCase()!=="success"?o=new Ce.SpeakerRecognitionResult(s,Ce.ResultReason.Canceled,Ce.CancellationErrorCode.ServiceError,s.status.reason):o=new Ce.SpeakerRecognitionResult(s,Ce.ResultReason.RecognizedSpeaker),this.privResultDeferral&&this.privResultDeferral.resolve(o),t=!0;break;default:break}let n=new Cp.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){if(new Ce.PropertyCollection().setProperty(gR.CancellationErrorCodePropertyName,Ce.CancellationErrorCode[n]),this.privResultDeferral){let a=new Ce.SpeakerRecognitionResult({scenario:this.privSpeakerModel.scenario,status:{statusCode:s,reason:s}},Ce.ResultReason.Canceled,n,s);try{this.privResultDeferral.resolve(a)}catch(c){this.privResultDeferral.reject(c)}}}async recognizeSpeakerOnce(e){this.privSpeakerModel=e,this.voiceProfileType=e.scenario,this.privResultDeferral||(this.privResultDeferral=new Cp.Deferred),this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(Ce.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let t=this.connectImpl(),r=this.sendPreAudioMessages(this.extractSpeakerContext(e)),n=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),s=await this.privSpeakerAudioSource.format,o=await this.privSpeakerAudioSource.deviceInfo,a=new iO.ReplayableAudioNode(n,s.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(a,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:o};try{await t,await r}catch(h){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Ce.CancellationReason.Error,Ce.CancellationErrorCode.ConnectionFailure,h)}let c=new Ce.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,c),this.receiveMessage(),this.sendAudio(a).then(()=>{},h=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Ce.CancellationReason.Error,Ce.CancellationErrorCode.RuntimeError,h)}),this.privResultDeferral.promise}async sendPreAudioMessages(e){let t=await this.fetchConnection();await this.sendSpeakerRecognition(t,e)}async sendSpeakerRecognition(e,t){let r=JSON.stringify(t);return e.send(new nO.SpeechConnectionMessage(Cp.MessageType.Text,"speaker.context",this.privRequestSession.requestId,"application/json; charset=utf-8",r))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}};Pp.SpeakerServiceRecognizer=Rf});var yR=p(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});Rp.VoiceServiceRecognizer=void 0;var sO=pe(),Nt=P(),L=f(),SR=C(),Ef=Jr(),If=class extends SR.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privDeferralMap=new Nt.DeferralMap,this.privSpeakerAudioSource=r,this.sendPrePayloadJSONOverride=()=>this.noOp()}set SpeakerAudioSource(e){this.privSpeakerAudioSource=e}processTypeSpecificMessages(e){let t=!1,r=new L.PropertyCollection;switch(e.messageType===Nt.MessageType.Text&&r.setProperty(L.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.profiles":let s=JSON.parse(e.textBody);switch(s.operation.toLowerCase()){case"create":this.handleCreateResponse(s,e.requestId);break;case"delete":case"reset":this.handleResultResponse(s,e.requestId);break;case"fetch":let u=JSON.parse(e.textBody);this.handleFetchResponse(u,e.requestId);break;default:break}t=!0;break;case"speaker.phrases":let o=JSON.parse(e.textBody);this.handlePhrasesResponse(o,e.requestId),t=!0;break;case"speaker.profile.enrollment":let a=JSON.parse(e.textBody),c=new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(a.enrollment?a.enrollment.enrollmentStatus:a.status.statusCode),a.enrollment?JSON.stringify(a.enrollment):void 0,a.status.reason);this.privDeferralMap.getId(e.requestId)&&this.privDeferralMap.complete(e.requestId,c),this.privRequestSession.onSpeechEnded(),t=!0;break;default:break}let n=new Nt.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){new L.PropertyCollection().setProperty(SR.CancellationErrorCodePropertyName,L.CancellationErrorCode[n]);let a=new L.VoiceProfileEnrollmentResult(L.ResultReason.Canceled,s,s);this.privDeferralMap.getId(t)&&this.privDeferralMap.complete(t,a)}async createProfile(e,t){this.voiceProfileType=e.toString();let r=this.connectImpl();try{let n=new Nt.Deferred;return await r,await this.sendCreateProfile(n,e,t),this.receiveMessage(),n.promise}catch(n){throw n}}async resetProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("reset",e.profileType,e)}async deleteProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("delete",e.profileType,e)}async retrieveEnrollmentResult(e){return this.voiceProfileType=e.profileType.toString(),this.privExpectedProfileId=e.profileId,this.sendCommonRequest("fetch",e.profileType,e)}async getAllProfiles(e){return this.voiceProfileType=e.toString(),this.sendCommonRequest("fetch",e)}async getActivationPhrases(e,t){this.voiceProfileType=e.toString();let r=this.connectImpl();try{let n=new Nt.Deferred;return await r,await this.sendPhrasesRequest(n,e,t),this.receiveMessage(),n.promise}catch(n){throw n}}async enrollProfile(e){this.voiceProfileType=e.profileType.toString();let t=new Nt.Deferred;this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(L.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let r=this.connectImpl(),n=this.sendPreAudioMessages(e,t),s=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),o=await this.privSpeakerAudioSource.format,a=await this.privSpeakerAudioSource.deviceInfo,c=new sO.ReplayableAudioNode(s,o.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(c,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:a};try{await r,await n}catch(d){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.ConnectionFailure,d)}let u=new L.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,u),this.receiveMessage(),this.sendAudio(c).then(()=>{},d=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.RuntimeError,d)}),t.promise}async sendPreAudioMessages(e,t){let r=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,t),await this.sendBaseRequest(r,"enroll",this.scenarioFrom(e.profileType),e)}async sendPhrasesRequest(e,t,r){let n=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);let s=this.scenarioFrom(t),o={locale:r,scenario:s};return n.send(new Ef.SpeechConnectionMessage(Nt.MessageType.Text,"speaker.profile.phrases",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(o)))}async sendCreateProfile(e,t,r){let n=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);let s=t===L.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":t===L.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification",o={locale:r,number:"1",scenario:s};return n.send(new Ef.SpeechConnectionMessage(Nt.MessageType.Text,"speaker.profile.create",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(o)))}async sendCommonRequest(e,t,r=void 0){let n=this.connectImpl();try{let s=new Nt.Deferred;this.privRequestSession.onSpeechContext(),await n;let o=await this.fetchConnection();return this.privDeferralMap.add(this.privRequestSession.requestId,s),await this.sendBaseRequest(o,e,this.scenarioFrom(t),r),this.receiveMessage(),s.promise}catch(s){throw s}}async sendBaseRequest(e,t,r,n){let s={scenario:r};return n?s.profileIds=[n.profileId]:s.maxPageSize=-1,e.send(new Ef.SpeechConnectionMessage(Nt.MessageType.Text,`speaker.profile.${t}`,this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(s)))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}handlePhrasesResponse(e,t){if(this.privDeferralMap.getId(t))if(e.status.statusCode.toLowerCase()!=="success"){let r=L.ResultReason.Canceled,n=new L.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,[]);this.privDeferralMap.complete(t,n)}else if(e.phrases&&e.phrases.length>0){let r=L.ResultReason.EnrollingVoiceProfile,n=new L.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,e.phrases);this.privDeferralMap.complete(t,n)}else throw new Error("Voice Profile get activation phrases failed, no phrases received");else throw new Error(`Voice Profile get activation phrases request for requestID ${t} not found`)}handleCreateResponse(e,t){if(e.profiles&&e.profiles.length>0)if(this.privDeferralMap.getId(t)){let r=e.profiles.map(n=>n.profileId);this.privDeferralMap.complete(t,r)}else throw new Error(`Voice Profile create request for requestID ${t} not found`);else throw new Error("Voice Profile create failed, no profile id received")}handleResultResponse(e,t){if(this.privDeferralMap.getId(t)){let r=e.operation.toLowerCase()==="delete"?L.ResultReason.DeletedVoiceProfile:L.ResultReason.ResetVoiceProfile,n=e.status.statusCode.toLowerCase()==="success"?r:L.ResultReason.Canceled,s=new L.VoiceProfileResult(n,`statusCode: ${e.status.statusCode}, errorDetails: ${e.status.reason}`);this.privDeferralMap.complete(t,s)}else throw new Error(`Voice Profile create request for requestID ${t} not found`)}handleFetchResponse(e,t){if(this.privDeferralMap.getId(t)&&e.profiles[0]){if(this.privExpectedProfileId&&e.profiles.length===1&&e.profiles[0].profileId===this.privExpectedProfileId){this.privExpectedProfileId=void 0;let r=e.profiles[0],n=new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(r.enrollmentStatus),JSON.stringify(r),e.status.reason);this.privDeferralMap.complete(t,n)}else if(e.profiles.length>0){let r=e.profiles,n=[];for(let s of r)n.push(new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(s.enrollmentStatus),JSON.stringify(s),e.status.reason));this.privDeferralMap.complete(t,n)}}else throw new Error(`Voice Profile fetch request for requestID ${t} not found`)}enrollmentReasonFrom(e){switch(e.toLowerCase()){case"enrolled":return L.ResultReason.EnrolledVoiceProfile;case"invalidlocale":case"invalidphrase":case"invalidaudioformat":case"invalidscenario":case"invalidprofilecount":case"invalidoperation":case"audiotooshort":case"audiotoolong":case"toomanyenrollments":case"storageconflict":case"profilenotfound":case"incompatibleprofiles":case"incompleteenrollment":return L.ResultReason.Canceled;default:return L.ResultReason.EnrollingVoiceProfile}}scenarioFrom(e){return e===L.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":e===L.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification"}};Rp.VoiceServiceRecognizer=If});var CR=p(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.type=he.connectivity=he.Device=he.OS=he.System=he.Context=he.SpeechServiceConfig=void 0;var wf=class{constructor(e){this.context=e}serialize(){return JSON.stringify(this,(e,t)=>{if(t&&typeof t=="object"&&!Array.isArray(t)){let r={};for(let n in t)Object.hasOwnProperty.call(t,n)&&(r[n&&n.charAt(0).toLowerCase()+n.substring(1)]=t[n]);return r}return t})}get Context(){return this.context}get Recognition(){return this.recognition}set Recognition(e){this.recognition=e.toLowerCase()}};he.SpeechServiceConfig=wf;var _f=class{constructor(e){this.system=new Ep,this.os=e}};he.Context=_f;var Ep=class{constructor(){let e="1.36.0";this.name="SpeechSDK",this.version=e,this.build="JavaScript",this.lang="JavaScript"}};he.System=Ep;var Tf=class{constructor(e,t,r){this.platform=e,this.name=t,this.version=r}};he.OS=Tf;var Af=class{constructor(e,t,r){this.manufacturer=e,this.model=t,this.version=r}};he.Device=Af;var oO;(function(i){i.Bluetooth="Bluetooth",i.Wired="Wired",i.WiFi="WiFi",i.Cellular="Cellular",i.InBuilt="InBuilt",i.Unknown="Unknown"})(oO=he.connectivity||(he.connectivity={}));var aO;(function(i){i.Phone="Phone",i.Speaker="Speaker",i.Car="Car",i.Headset="Headset",i.Thermostat="Thermostat",i.Microphones="Microphones",i.Deskphone="Deskphone",i.RemoteControl="RemoteControl",i.Unknown="Unknown",i.File="File",i.Stream="Stream"})(aO=he.type||(he.type={}))});var C=p(m=>{"use strict";var cO=m&&m.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),R=m&&m.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&cO(e,i,t)};Object.defineProperty(m,"__esModule",{value:!0});m.AutoDetectSourceLanguagesOpenRangeOptionName=m.ForceDictationPropertyName=m.ServicePropertiesPropertyName=m.CancellationErrorCodePropertyName=m.OutputFormatPropertyName=void 0;R(wm(),m);R(bm(),m);R(xs(),m);R(Mm(),m);R(km(),m);R(AC(),m);R(DC(),m);R(lc(),m);R(NC(),m);R(qC(),m);R(zC(),m);R(LC(),m);R(FC(),m);R(HC(),m);R(GC(),m);R(XC(),m);R(rP(),m);R(Al(),m);R(iP(),m);R(nP(),m);R(oP(),m);R(aP(),m);R(cP(),m);R(uP(),m);R(hP(),m);R(dP(),m);R(lP(),m);R(vP(),m);R(fP(),m);R(mP(),m);R(SP(),m);R(yP(),m);R(CP(),m);R(RP(),m);R(EP(),m);R(wP(),m);R(AP(),m);R(bP(),m);R(OP(),m);R(DP(),m);R(xP(),m);R(zP(),m);R(rR(),m);R(af(),m);R(sR(),m);R(oR(),m);var pO=cR();Object.defineProperty(m,"AvatarSynthesisAdapter",{enumerable:!0,get:function(){return pO.AvatarSynthesisAdapter}});var uO=pR();Object.defineProperty(m,"SpeechSynthesisAdapter",{enumerable:!0,get:function(){return uO.SpeechSynthesisAdapter}});R(uR(),m);R(lR(),m);R(vR(),m);R(fR(),m);R(mR(),m);R(yR(),m);R(CR(),m);m.OutputFormatPropertyName="OutputFormat";m.CancellationErrorCodePropertyName="CancellationErrorCode";m.ServicePropertiesPropertyName="ServiceProperties";m.ForceDictationPropertyName="ForceDictation";m.AutoDetectSourceLanguagesOpenRangeOptionName="OpenRange"});var PR=p(ti=>{"use strict";var hO=ti&&ti.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),dO=ti&&ti.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&hO(e,i,t)};Object.defineProperty(ti,"__esModule",{value:!0});var lO=C();new lO.AgentConfig;dO(f(),ti)});var TR=p((Yn,kf)=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.default=PO;function PO(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;try{var t=i.call(e);return typeof t.then=="function"?new Promise(function(r){t.then(r,function(){return r()})}):t}catch{}}kf.exports=Yn.default;kf.exports.default=Yn.default});var DR=p((MN,MR)=>{"use strict";MR.exports=function(){var i={};return i.promise=new Promise(function(e,t){i.resolve=e,i.reject=t}),i}});var qR=p((Gi,qf)=>{"use strict";Object.defineProperty(Gi,"__esModule",{value:!0});Gi.default=void 0;var kR=wO(DR());function wO(i){return i&&i.__esModule?i:{default:i}}function _O(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function NR(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function TO(i,e,t){return e&&NR(i.prototype,e),t&&NR(i,t),i}var AO=function(){function i(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_O(this,i),this.defers=[],this.upcomingDeferred=null,this.eventListener=this.eventListener.bind(this),this.options=t,this.one=this.one.bind(this),this.upcoming=this.upcoming.bind(this),this[Symbol.iterator]=function(){return{next:function(){return{done:!1,value:e.upcoming()}}}}}return TO(i,[{key:"eventListener",value:function(t){var r=this.defers.shift(),n=this.options.array?[].slice.call(arguments):t;r&&r.resolve(n),this.upcomingDeferred&&(this.upcomingDeferred.resolve(n),this.upcomingDeferred=null)}},{key:"one",value:function(){var t=(0,kR.default)();return this.defers.push(t),t.promise}},{key:"upcoming",value:function(){return this.upcomingDeferred||(this.upcomingDeferred=(0,kR.default)()),this.upcomingDeferred.promise}}]),i}();Gi.default=AO;qf.exports=Gi.default;qf.exports.default=Gi.default});function jp(i,e,...t){if(!i)throw new TypeError(ng(e,t))}function ng(i,e){let t=0;return i.replace(/%[os]/gu,()=>sg(e[t++]))}function sg(i){return typeof i!="object"||i===null?String(i):Object.prototype.toString.call(i)}var Gf;function GR(i){try{let e=i instanceof Error?i:new Error(sg(i));if(Gf){Gf(e);return}if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}));else if(typeof process<"u"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)}catch{}}var at=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,$f;var ct=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{if($f){$f({...this,args:e});return}let r=((t=new Error().stack)!==null&&t!==void 0?t:"").replace(/^(?:.+?\n){2}/gu,`
24
- `);console.warn(this.message,...e,r)}catch{}}},$R=new ct("W01","Unable to initialize event under dispatching."),QR=new ct("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),YR=new ct("W03","Assigning any truthy value to 'returnValue' property has no effect."),XR=new ct("W04","Unable to preventDefault on non-cancelable events."),ZR=new ct("W05","Unable to preventDefault inside passive event listener invocation."),eE=new ct("W06","An event listener wasn't added because it has been added already: %o, %o"),Np=new ct("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),Qf=new ct("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),tE=new ct("W09","Event attribute handler must be a function: %o"),Me=class{static get NONE(){return Yf}static get CAPTURING_PHASE(){return Xf}static get AT_TARGET(){return Zf}static get BUBBLING_PHASE(){return eg}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let r=t??{};zp.set(this,{type:String(e),bubbles:!!r.bubbles,cancelable:!!r.cancelable,composed:!!r.composed,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return re(this).type}get target(){return re(this).target}get srcElement(){return re(this).target}get currentTarget(){return re(this).currentTarget}composedPath(){let e=re(this).currentTarget;return e?[e]:[]}get NONE(){return Yf}get CAPTURING_PHASE(){return Xf}get AT_TARGET(){return Zf}get BUBBLING_PHASE(){return eg}get eventPhase(){return re(this).dispatchFlag?2:0}stopPropagation(){re(this).stopPropagationFlag=!0}get cancelBubble(){return re(this).stopPropagationFlag}set cancelBubble(e){e?re(this).stopPropagationFlag=!0:QR.warn()}stopImmediatePropagation(){let e=re(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return re(this).bubbles}get cancelable(){return re(this).cancelable}get returnValue(){return!re(this).canceledFlag}set returnValue(e){e?YR.warn():tg(re(this))}preventDefault(){tg(re(this))}get defaultPrevented(){return re(this).canceledFlag}get composed(){return re(this).composed}get isTrusted(){return!1}get timeStamp(){return re(this).timeStamp}initEvent(e,t=!1,r=!1){let n=re(this);if(n.dispatchFlag){$R.warn();return}zp.set(this,{...n,type:String(e),bubbles:!!t,cancelable:!!r,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},Yf=0,Xf=1,Zf=2,eg=3,zp=new WeakMap;function re(i,e="this"){let t=zp.get(i);return jp(t!=null,"'%s' must be an object that Event constructor created, but got another one: %o",e,i),t}function tg(i){if(i.inPassiveListenerFlag){ZR.warn();return}if(!i.cancelable){XR.warn();return}i.canceledFlag=!0}Object.defineProperty(Me,"NONE",{enumerable:!0});Object.defineProperty(Me,"CAPTURING_PHASE",{enumerable:!0});Object.defineProperty(Me,"AT_TARGET",{enumerable:!0});Object.defineProperty(Me,"BUBBLING_PHASE",{enumerable:!0});var qp=Object.getOwnPropertyNames(Me.prototype);for(let i=0;i<qp.length;++i)qp[i]!=="constructor"&&Object.defineProperty(Me.prototype,qp[i],{enumerable:!0});typeof at<"u"&&typeof at.Event<"u"&&Object.setPrototypeOf(Me.prototype,at.Event.prototype);function rE(i){return at.DOMException?new at.DOMException(i,"InvalidStateError"):(ii==null&&(ii=class og extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,og)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(ii.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),ig(ii),ig(ii.prototype)),new ii(i))}var ii,rg={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function ig(i){let e=Object.keys(rg);for(let t=0;t<e.length;++t){let r=e[t],n=rg[r];Object.defineProperty(i,r,{get(){return n},configurable:!0,enumerable:!0})}}var si=class extends Me{static wrap(e){return new(cg(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),ag.set(this,{original:e});let t=Object.keys(e);for(let r=0;r<t.length;++r){let n=t[r];n in this||Object.defineProperty(this,n,pg(e,n))}}stopPropagation(){super.stopPropagation();let{original:e}=Zt(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;let{original:t}=Zt(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:e}=Zt(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;let{original:t}=Zt(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();let{original:e}=Zt(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){let{original:e}=Zt(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},ag=new WeakMap;function Zt(i){let e=ag.get(i);return jp(e!=null,"'this' is expected an Event object, but got",i),e}var es=new WeakMap;es.set(Object.prototype,si);typeof at<"u"&&typeof at.Event<"u"&&es.set(at.Event.prototype,si);function cg(i){let e=Object.getPrototypeOf(i);if(e==null)return si;let t=es.get(e);return t==null&&(t=iE(cg(e),e),es.set(e,t)),t}function iE(i,e){class t extends i{}let r=Object.keys(e);for(let n=0;n<r.length;++n)Object.defineProperty(t.prototype,r[n],pg(e,r[n]));return t}function pg(i,e){let t=Object.getOwnPropertyDescriptor(i,e);return{get(){let r=Zt(this).original,n=r[e];return typeof n=="function"?n.bind(r):n},set(r){let n=Zt(this).original;n[e]=r},configurable:t.configurable,enumerable:t.enumerable}}function nE(i,e,t,r,n,s){return{callback:i,flags:(e?1:0)|(t?2:0)|(r?4:0),signal:n,signalListener:s}}function sE(i){i.flags|=8}function ug(i){return(i.flags&1)===1}function hg(i){return(i.flags&2)===2}function dg(i){return(i.flags&4)===4}function oE(i){return(i.flags&8)===8}function aE({callback:i},e,t){try{typeof i=="function"?i.call(e,t):typeof i.handleEvent=="function"&&i.handleEvent(t)}catch(r){GR(r)}}function lg({listeners:i},e,t){for(let r=0;r<i.length;++r)if(i[r].callback===e&&ug(i[r])===t)return r;return-1}function vg(i,e,t,r,n,s){let o;s&&(o=Lp.bind(null,i,e,t),s.addEventListener("abort",o));let a=nE(e,t,r,n,s,o);return i.cow?(i.cow=!1,i.listeners=[...i.listeners,a]):i.listeners.push(a),a}function Lp(i,e,t){let r=lg(i,e,t);return r!==-1?fg(i,r):!1}function fg(i,e,t=!1){let r=i.listeners[e];return sE(r),r.signal&&r.signal.removeEventListener("abort",r.signalListener),i.cow&&!t?(i.cow=!1,i.listeners=i.listeners.filter((n,s)=>s!==e),!1):(i.listeners.splice(e,1),!0)}function cE(){return Object.create(null)}function gg(i,e){var t;return(t=i[e])!==null&&t!==void 0?t:i[e]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}var pt=class{constructor(){mg.set(this,cE())}addEventListener(e,t,r){let n=ni(this),{callback:s,capture:o,once:a,passive:c,signal:u,type:h}=pE(e,t,r);if(s==null||u?.aborted)return;let d=gg(n,h),v=lg(d,s,o);if(v!==-1){hE(d.listeners[v],c,a,u);return}vg(d,s,o,c,a,u)}removeEventListener(e,t,r){let n=ni(this),{callback:s,capture:o,type:a}=uE(e,t,r),c=n[a];s!=null&&c&&Lp(c,s,o)}dispatchEvent(e){let t=ni(this)[String(e.type)];if(t==null)return!0;let r=e instanceof Me?e:si.wrap(e),n=re(r,"event");if(n.dispatchFlag)throw rE("This event has been in dispatching.");if(n.dispatchFlag=!0,n.target=n.currentTarget=this,!n.stopPropagationFlag){let{cow:s,listeners:o}=t;t.cow=!0;for(let a=0;a<o.length;++a){let c=o[a];if(!oE(c)&&(dg(c)&&fg(t,a,!s)&&(a-=1),n.inPassiveListenerFlag=hg(c),aE(c,this,r),n.inPassiveListenerFlag=!1,n.stopImmediatePropagationFlag))break}s||(t.cow=!1)}return n.target=null,n.currentTarget=null,n.stopImmediatePropagationFlag=!1,n.stopPropagationFlag=!1,n.dispatchFlag=!1,!n.canceledFlag}},mg=new WeakMap;function ni(i,e="this"){let t=mg.get(i);return jp(t!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",e,i),t}function pE(i,e,t){var r;return Sg(e),typeof t=="object"&&t!==null?{type:String(i),callback:e??void 0,capture:!!t.capture,passive:!!t.passive,once:!!t.once,signal:(r=t.signal)!==null&&r!==void 0?r:void 0}:{type:String(i),callback:e??void 0,capture:!!t,passive:!1,once:!1,signal:void 0}}function uE(i,e,t){return Sg(e),typeof t=="object"&&t!==null?{type:String(i),callback:e??void 0,capture:!!t.capture}:{type:String(i),callback:e??void 0,capture:!!t}}function Sg(i){if(!(typeof i=="function"||typeof i=="object"&&i!==null&&typeof i.handleEvent=="function")){if(i==null||typeof i=="object"){Qf.warn(i);return}throw new TypeError(ng(Qf.message,[i]))}}function hE(i,e,t,r){eE.warn(ug(i)?"capture":"bubble",i.callback),hg(i)!==e&&Np.warn("passive"),dg(i)!==t&&Np.warn("once"),i.signal!==r&&Np.warn("signal")}var xp=Object.getOwnPropertyNames(pt.prototype);for(let i=0;i<xp.length;++i)xp[i]!=="constructor"&&Object.defineProperty(pt.prototype,xp[i],{enumerable:!0});typeof at<"u"&&typeof at.EventTarget<"u"&&Object.setPrototypeOf(pt.prototype,at.EventTarget.prototype);function Q(i,e){var t,r;return(r=(t=ni(i,"target")[e])===null||t===void 0?void 0:t.attrCallback)!==null&&r!==void 0?r:null}function Y(i,e,t){t!=null&&typeof t!="function"&&tE.warn(t),typeof t=="function"||typeof t=="object"&&t!==null?dE(i,e,t):lE(i,e)}function dE(i,e,t){let r=gg(ni(i,"target"),String(e));r.attrCallback=t,r.attrListener==null&&(r.attrListener=vg(r,vE(r),!1,!1,!1,void 0))}function lE(i,e){let r=ni(i,"target")[String(e)];r&&r.attrListener&&(Lp(r,r.attrListener.callback,!1),r.attrCallback=r.attrListener=void 0)}function vE(i){return function(e){let t=i.attrCallback;typeof t=="function"&&t.call(this,e)}}function yg(i,e){let t={...[].reduce.call(i,(r,n,s)=>(r[s]=n,r),{}),...e,length:i.length,[Symbol.iterator]:()=>[].slice.call(t)[Symbol.iterator]()};return t}var qt=kp(PR()),Ip={AudioConfig:qt.AudioConfig,OutputFormat:qt.OutputFormat,ResultReason:qt.ResultReason,SpeechConfig:qt.SpeechConfig,SpeechRecognizer:qt.SpeechRecognizer};var{ResultReason:{RecognizingSpeech:vO,RecognizedSpeech:bf}}=Ip;function Of(i,{maxAlternatives:e=1/0,textNormalization:t="display"}={}){if(i.reason===vO||i.reason===bf&&!i.json.NBest){let r=[{confidence:.5,transcript:i.text}];return i.reason===bf&&(r.isFinal=!0),r}else if(i.reason===bf)return yg((i.json.NBest||[]).slice(0,e).map(({Confidence:n,Display:s,ITN:o,Lexical:a,MaskedITN:c})=>({confidence:n,transcript:t==="itn"?o:t==="lexical"?a:t==="maskeditn"?c:s})),{isFinal:!0});return[]}function Gn(){let i={};return i.promise=new Promise((e,t)=>{i.resolve=e,i.reject=t}),i}function RR(){let i,e=[];return{push:n=>{if(i){let{resolve:s}=i;i=null,s(n)}else e.push(n)},shift:()=>e.length?Promise.resolve(e.shift()):(i||(i=Gn())).promise}}function fO(i){return typeof i=="function"}function $n(i){return fO(i)?i():i}var ER=!0;function Qn({authorizationToken:i,credentials:e,looseEvent:t,looseEvents:r,region:n="westus",subscriptionKey:s,...o}={}){if(typeof t<"u"&&(console.warn('web-speech-cognitive-services: The option "looseEvent" should be named as "looseEvents".'),r=t),!e){if(!i&&!s)throw new Error("web-speech-cognitive-services: Credentials must be specified.");console.warn("web-speech-cognitive-services: We are deprecating authorizationToken, region, and subscriptionKey. Please use credentials instead. The deprecated option will be removed on or after 2020-11-14."),e=async()=>i?{authorizationToken:await $n(i),region:n}:{region:n,subscriptionKey:await $n(s)}}return{...o,fetchCredentials:async()=>{let{authorizationToken:a,customVoiceHostname:c,region:u,speechRecognitionHostname:h,speechSynthesisHostname:d,subscriptionKey:v}=await $n(e);if(!a&&!v||a&&v)throw new Error('web-speech-cognitive-services: Either "authorizationToken" or "subscriptionKey" must be provided.');if(!u&&!(h&&d))throw new Error('web-speech-cognitive-services: Either "region" or "speechRecognitionHostname" and "speechSynthesisHostname" must be set.');if(u&&(c||h||d))throw new Error('web-speech-cognitive-services: Only either "region" or "customVoiceHostname", "speechRecognitionHostname" and "speechSynthesisHostname" can be set.');if(a){if(typeof a!="string")throw new Error('web-speech-cognitive-services: "authorizationToken" must be a string.')}else if(typeof v!="string")throw new Error('web-speech-cognitive-services: "subscriptionKey" must be a string.');ER&&v&&(console.warn("web-speech-cognitive-services: In production environment, subscription key should not be used, authorization token should be used instead."),ER=!1);let g=a?{authorizationToken:a}:{subscriptionKey:v};return u?g.region=u:(g.customVoiceHostname=c,g.speechRecognitionHostname=h,g.speechSynthesisHostname=d),g},looseEvents:r}}var Hi=class{constructor(){this._phrases=[]}addFromString(){throw new Error("JSGF is not supported")}get phrases(){return this._phrases}set phrases(i){if(Array.isArray(i))this._phrases=i;else if(typeof i=="string")this._phrases=[i];else throw new Error("The provided value is not an array or of type 'string'")}};var{AudioConfig:gO,OutputFormat:mO,ResultReason:SO,SpeechConfig:wp,SpeechRecognizer:wR}=Ip;function IR({duration:i,errorDetails:e,json:t,offset:r,properties:n,reason:s,resultId:o,text:a}){return{duration:i,errorDetails:e,json:JSON.parse(t),offset:r,properties:n,reason:s,resultId:o,text:a}}function yO(i){let e=new Int16Array(i);return[].reduce.call(e,(t,r)=>t+Math.abs(r),0)/e.length}function Mf(i){return(...e)=>new Promise((t,r)=>i(...e,t,r))}var $=class extends Me{constructor(e,{data:t,emma:r,interpretation:n,resultIndex:s,results:o}={}){super(e),this.data=t,this.emma=r,this.interpretation=n,this.resultIndex=s,this.results=o}};function CO(i){let e=i.attach,t=i.attach.bind(i),r,n;return i.attach=async()=>{let s=await t();return{...s,read:async()=>{let o=await s.read();return!r&&yO(o.buffer)>150&&(i.events.onEvent({name:"FirstAudibleChunk"}),r=!0),n?{buffer:new ArrayBuffer(0),isEnd:!0,timeReceived:Date.now()}:o}}},{audioConfig:i,pause:()=>{n=!0},unprepare:()=>{i.attach=e}}}function Ki({createRecognizer:i,enableTelemetry:e,looseEvents:t,referenceGrammars:r,textNormalization:n}){wR.enableTelemetry(e!==!1);class s extends pt{constructor(){super(),this._continuous=!1,this._interimResults=!1,this._lang=typeof window<"u"?window.document.documentElement.getAttribute("lang")||window.navigator.language:"en-US",this._grammars=new Hi,this._maxAlternatives=1}emitCognitiveServices(a,c){this.dispatchEvent(new $("cognitiveservices",{data:{...c,type:a}}))}get continuous(){return this._continuous}set continuous(a){this._continuous=a}get grammars(){return this._grammars}set grammars(a){if(a instanceof Hi)this._grammars=a;else throw new Error("The provided value is not of type 'SpeechGrammarList'")}get interimResults(){return this._interimResults}set interimResults(a){this._interimResults=a}get maxAlternatives(){return this._maxAlternatives}set maxAlternatives(a){this._maxAlternatives=a}get lang(){return this._lang}set lang(a){this._lang=a}get onaudioend(){return Q(this,"audioend")}set onaudioend(a){Y(this,"audioend",a)}get onaudiostart(){return Q(this,"audiostart")}set onaudiostart(a){Y(this,"audiostart",a)}get oncognitiveservices(){return Q(this,"cognitiveservices")}set oncognitiveservices(a){Y(this,"cognitiveservices",a)}get onend(){return Q(this,"end")}set onend(a){Y(this,"end",a)}get onerror(){return Q(this,"error")}set onerror(a){Y(this,"error",a)}get onresult(){return Q(this,"result")}set onresult(a){Y(this,"result",a)}get onsoundend(){return Q(this,"soundend")}set onsoundend(a){Y(this,"soundend",a)}get onsoundstart(){return Q(this,"soundstart")}set onsoundstart(a){Y(this,"soundstart",a)}get onspeechend(){return Q(this,"speechend")}set onspeechend(a){Y(this,"speechend",a)}get onspeechstart(){return Q(this,"speechstart")}set onspeechstart(a){Y(this,"speechstart",a)}get onstart(){return Q(this,"start")}set onstart(a){Y(this,"start",a)}start(){this._startOnce().catch(a=>{this.dispatchEvent(new ErrorEvent("error",{error:a,message:a&&(a.stack||a.message)}))})}async _startOnce(){let a=await i(this.lang),{pause:c,unprepare:u}=CO(a.audioConfig);try{let h=RR(),d,v,g,{detach:w}=a.audioConfig.events.attach(F=>{let{name:K}=F;K==="AudioSourceReadyEvent"?h.push({audioSourceReady:{}}):K==="AudioSourceOffEvent"?h.push({audioSourceOff:{}}):K==="FirstAudibleChunk"&&h.push({firstAudibleChunk:{}})});a.canceled=(F,{errorDetails:K,offset:ot,reason:Pr,sessionId:bp})=>{h.push({canceled:{errorDetails:K,offset:ot,reason:Pr,sessionId:bp}})},a.recognized=(F,{offset:K,result:ot,sessionId:Pr})=>{h.push({recognized:{offset:K,result:IR(ot),sessionId:Pr}})},a.recognizing=(F,{offset:K,result:ot,sessionId:Pr})=>{h.push({recognizing:{offset:K,result:IR(ot),sessionId:Pr}})},a.sessionStarted=(F,{sessionId:K})=>{h.push({sessionStarted:{sessionId:K}})},a.sessionStopped=(F,{sessionId:K})=>{h.push({sessionStopped:{sessionId:K}})},a.speechStartDetected=(F,{offset:K,sessionId:ot})=>{h.push({speechStartDetected:{offset:K,sessionId:ot}})},a.speechEndDetected=(F,{sessionId:K})=>{h.push({speechEndDetected:{sessionId:K}})};let{phrases:k}=this.grammars,{dynamicGrammar:ae}=a.privReco;r&&r.length&&ae.addReferenceGrammar(r),k&&k.length&&ae.addPhrase(k),await Mf(a.startContinuousRecognitionAsync.bind(a))(),a.stopContinuousRecognitionAsync?(this.abort=()=>h.push({abort:{}}),this.stop=()=>h.push({stop:{}})):this.abort=this.stop=void 0;let Z,U,Oe=[];for(let F=0;!g||Z;F++){let K=await h.shift(),{abort:ot,audioSourceOff:Pr,audioSourceReady:bp,canceled:Kf,firstAudibleChunk:BR,recognized:ri,recognizing:Op,stop:FR}=K;Object.keys(K).forEach($i=>this.emitCognitiveServices($i,K[$i]));let Mp=Kf&&Kf.errorDetails;if(/Permission\sdenied/u.test(Mp||"")){U={error:"not-allowed",type:"error"};break}if(F||this.dispatchEvent(new $("start")),Mp){/1006/u.test(Mp)?(Z||(this.dispatchEvent(new $("audiostart")),this.dispatchEvent(new $("audioend"))),U={error:"network",type:"error"}):U={error:"unknown",type:"error"};break}else if(ot||FR)ot?(U={error:"aborted",type:"error"},g="abort"):(c(),g="stop"),ot&&a.stopContinuousRecognitionAsync&&await Mf(a.stopContinuousRecognitionAsync.bind(a))();else if(bp)this.dispatchEvent(new $("audiostart")),Z=!0;else if(BR)this.dispatchEvent(new $("soundstart")),d=!0;else if(Pr){v&&this.dispatchEvent(new $("speechend")),d&&this.dispatchEvent(new $("soundend")),Z&&this.dispatchEvent(new $("audioend")),Z=d=v=!1;break}else if(g!=="abort"){if(ri&&ri.result&&ri.result.reason===SO.NoMatch)U={error:"no-speech",type:"error"};else if(ri||Op)if(Z||(this.dispatchEvent(new $("audiostart")),Z=!0),d||(this.dispatchEvent(new $("soundstart")),d=!0),v||(this.dispatchEvent(new $("speechstart")),v=!0),ri){let $i=Of(ri.result,{maxAlternatives:this.maxAlternatives,textNormalization:n}),Dp=!!$i[0].transcript;Dp&&(Oe=[...Oe,$i],this.continuous&&this.dispatchEvent(new $("result",{results:Oe}))),this.continuous&&Dp?U=null:U={results:Oe,type:"result"},!this.continuous&&a.stopContinuousRecognitionAsync&&await Mf(a.stopContinuousRecognitionAsync.bind(a))(),t&&U&&Dp&&(this.dispatchEvent(new $(U.type,U)),U=null)}else Op&&this.interimResults&&this.dispatchEvent(new $("result",{results:[...Oe,Of(Op.result,{maxAlternatives:this.maxAlternatives,textNormalization:n})]}))}}v&&this.dispatchEvent(new $("speechend")),d&&this.dispatchEvent(new $("soundend")),Z&&this.dispatchEvent(new $("audioend")),U&&(U.type==="result"&&!U.results.length&&(U={error:"no-speech",type:"error"}),U.type==="error"?this.dispatchEvent(new ErrorEvent("error",U)):this.dispatchEvent(new $(U.type,U))),this.dispatchEvent(new $("end")),w()}catch(h){throw console.error(h),h}finally{u(),a.dispose()}}}return{SpeechGrammarList:Hi,SpeechRecognition:s,SpeechRecognitionEvent:$}}var _R=i=>{let{audioConfig:e=gO.fromDefaultMicrophoneInput(),enableTelemetry:t=!0,fetchCredentials:r,looseEvents:n,referenceGrammars:s,speechRecognitionEndpointId:o,textNormalization:a="display"}=Qn(i);return!e&&(!window.navigator.mediaDevices||!window.navigator.mediaDevices.getUserMedia)?(console.warn("web-speech-cognitive-services: This browser does not support WebRTC and it will not work with Cognitive Services Speech Services."),{}):Ki({audioConfig:e,createRecognizer:async u=>{let{authorizationToken:h,region:d,speechRecognitionHostname:v,subscriptionKey:g}=await r(),w;if(v){let k={hostname:v,port:443,protocol:"wss:"};h?(w=wp.fromHost(k),w.authorizationToken=h):w=wp.fromHost(k,g)}else w=h?wp.fromAuthorizationToken(h,d):wp.fromSubscription(g,d);return o&&(w.endpointId=o),w.outputFormat=mO.Detailed,w.speechRecognitionLanguage=u||"en-US",new wR(w,e)},enableTelemetry:t,looseEvents:n,referenceGrammars:s,textNormalization:a})};var Df=_R;var Uf=kp(TR());var AR=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function RO(i,e){return!!(i===e||AR(i)&&AR(e))}function EO(i,e){if(i.length!==e.length)return!1;for(var t=0;t<i.length;t++)if(!RO(i[t],e[t]))return!1;return!0}function bR(i,e){e===void 0&&(e=EO);var t=null;function r(){for(var n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];if(t&&t.lastThis===this&&e(n,t.lastArgs))return t.lastResult;var o=i.apply(this,n);return t={lastResult:o,lastArgs:n,lastThis:this},o}return r.clear=function(){t=null},r}var _p=class{constructor(i){this.audioContext=i}pause(){this.audioContext&&this.audioContext.suspend(),this.playingUtterance&&this.playingUtterance.dispatchEvent(new CustomEvent("pause"))}resume(){this.audioContext&&this.audioContext.resume(),this.playingUtterance&&this.playingUtterance.dispatchEvent(new CustomEvent("resume"))}async start(i){let e;for(;e=i.shift();)this.playingUtterance=e,await e.play(this.audioContext),this.playingUtterance=null}stop(){this.playingUtterance&&this.playingUtterance.stop(),this.audioContext.state==="suspended"&&this.audioContext.resume()}};var Tp=class{constructor({audioContext:i,ponyfill:e}){this.consumer=null,this.paused=!1,this.queue=[],this.getAudioContext=bR(()=>i||new e.AudioContext)}pause(){this.paused=!0,this.consumer&&this.consumer.pause()}push(i){this.queue.push(i),this.startConsumer()}resume(){this.paused=!1,this.consumer?this.consumer.resume():this.startConsumer()}get speaking(){return!!this.consumer}async startConsumer(){for(;!this.paused&&this.queue.length&&!this.consumer;)this.consumer=new _p(this.getAudioContext()),await this.consumer.start(this.queue),this.consumer=null}stop(){this.queue.splice(0),this.consumer&&this.consumer.stop()}};var Ji=class{constructor({gender:i,lang:e,voiceURI:t}){this._default=!1,this._gender=i,this._lang=e,this._localService=!1,this._name=t,this._voiceURI=t}get default(){return this._default}get gender(){return this._gender}get lang(){return this._lang}get localService(){return this._localService}get name(){return this._name}get voiceURI(){return this._voiceURI}};async function IO({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r}){let n=i||`${t}.customvoice.api.speech.microsoft.com`,s=await fetch(`https://${encodeURI(n)}/api/texttospeech/v2.0/endpoints/${encodeURIComponent(e)}`,{headers:{accept:"application/json","ocp-apim-subscription-key":r}});if(!s.ok)throw new Error("Failed to fetch custom voices");return s.json()}async function OR({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r}){let{models:n}=await IO({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r});return n.map(({properties:{Gender:s},locale:o,name:a})=>new Ji({gender:s,lang:o,voiceURI:a})).sort(({name:s},{name:o})=>s>o?1:s<o?-1:0)}async function Nf({authorizationToken:i,region:e,speechSynthesisHostname:t,subscriptionKey:r}){let n=t||`${encodeURI(e)}.tts.speech.microsoft.com`,s=await fetch(`https://${n}/cognitiveservices/voices/list`,{headers:{"content-type":"application/json",...i?{authorization:`Bearer ${i}`}:{"Ocp-Apim-Subscription-Key":r}}});if(!s.ok)throw new Error("Failed to fetch voices");return(await s.json()).map(({Gender:a,Locale:c,Name:u})=>new Ji({gender:a,lang:c,voiceURI:u})).sort(({name:a},{name:c})=>a>c?1:a<c?-1:0)}var Xt=class extends Me{constructor(e){super(e)}};var Bf=kp(qR());var xR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zn=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(Xn=0;Xn<xR.length;Xn++)Zn[xR.charCodeAt(Xn)]=Xn;var Xn;var zR=function(i){var e=i.length*.75,t=i.length,r,n=0,s,o,a,c;i[i.length-1]==="="&&(e--,i[i.length-2]==="="&&e--);var u=new ArrayBuffer(e),h=new Uint8Array(u);for(r=0;r<t;r+=4)s=Zn[i.charCodeAt(r)],o=Zn[i.charCodeAt(r+1)],a=Zn[i.charCodeAt(r+2)],c=Zn[i.charCodeAt(r+3)],h[n++]=s<<2|o>>4,h[n++]=(o&15)<<4|a>>2,h[n++]=(a&3)<<6|c&63;return u};function xf(i){let e=Math.round((i-1)*100);return e>=0&&(e="+"+e),e+"%"}function zf({lang:i,pitch:e=1,rate:t=1,text:r,voice:n,volume:s}){return`<speak version="1.0" xml:lang="${i}">
22
+ `);o&&o.length>0&&(n=this.parseHeaders(o[0]),o.length>1&&(s=o[1]))}t.resolve(new tt.ConnectionMessage(e.messageType,s,n,e.id))}else if(e.messageType===tt.MessageType.Binary){let r=e.binaryContent,n={},s=null;if(!r||r.byteLength<2)throw new Error("Invalid binary message format. Header length missing.");let o=new DataView(r),a=o.getInt16(0);if(r.byteLength<a+2)throw new Error("Invalid binary message format. Header content missing.");let c="";for(let u=0;u<a;u++)c+=String.fromCharCode(o.getInt8(u+2));n=this.parseHeaders(c),r.byteLength>a+2&&(s=r.slice(2+a)),t.resolve(new tt.ConnectionMessage(e.messageType,s,n,e.id))}}catch(r){t.reject(`Error formatting the message. Error: ${r}`)}return t.promise}fromConnectionMessage(e){let t=new tt.Deferred;try{if(e.messageType===tt.MessageType.Text){let r=`${this.makeHeaders(e)}${jC}${e.textBody?e.textBody:""}`;t.resolve(new tt.RawWebsocketMessage(tt.MessageType.Text,r,e.id))}else if(e.messageType===tt.MessageType.Binary){let r=this.makeHeaders(e),n=e.binaryBody,s=this.stringToArrayBuffer(r),o=new Int8Array(s),a=o.byteLength,c=new Int8Array(2+a+(n?n.byteLength:0));if(c[0]=a>>8&255,c[1]=a&255,c.set(o,2),n){let h=new Int8Array(n);c.set(h,2+a)}let u=c.buffer;t.resolve(new tt.RawWebsocketMessage(tt.MessageType.Binary,u,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}makeHeaders(e){let t="";if(e.headers)for(let r in e.headers)r&&(t+=`${r}: ${e.headers[r]}${jC}`);return t}parseHeaders(e){let t={};if(e){let r=e.match(/[^\r\n]+/g);if(t){for(let n of r)if(n){let s=n.indexOf(":"),o=s>0?n.substr(0,s).trim().toLowerCase():n,a=s>0&&n.length>s+1?n.substr(s+1).trim():"";t[o]=a}}}return t}stringToArrayBuffer(e){let t=new ArrayBuffer(e.length),r=new DataView(t);for(let n=0;n<e.length;n++)r.setUint8(n,e.charCodeAt(n));return t}};yc.WebsocketMessageFormatter=Yl});var UC=p(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});Cc.SpeechConnectionFactory=void 0;var BC=pe(),FC=C(),fr=f(),VC=Ye(),Xl=C(),XA=we(),Gr=Ut(),Zl=class extends VC.ConnectionFactoryBase{constructor(){super(...arguments),this.interactiveRelativeUri="/speech/recognition/interactive/cognitiveservices/v1",this.conversationRelativeUri="/speech/recognition/conversation/cognitiveservices/v1",this.dictationRelativeUri="/speech/recognition/dictation/cognitiveservices/v1",this.universalUri="/speech/universal/v"}create(e,t,r){let n=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_Region,void 0),o=VC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_EndpointId,void 0),h=e.parameters.getProperty(fr.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(u?(!n||n.search(Gr.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[Gr.QueryParameterNames.CustomSpeechDeploymentId]=u):h&&(!n||n.search(Gr.QueryParameterNames.Language)===-1)&&(c[Gr.QueryParameterNames.Language]=h),(!n||n.search(Gr.QueryParameterNames.Format)===-1)&&(c[Gr.QueryParameterNames.Format]=e.parameters.getProperty(FC.OutputFormatPropertyName,fr.OutputFormat[fr.OutputFormat.Simple]).toLowerCase()),e.autoDetectSourceLanguages!==void 0&&(c[Gr.QueryParameterNames.EnableLanguageId]="true"),this.setCommonUrlParams(e,c,n),!n)switch(e.recognitionMode){case Xl.RecognitionMode.Conversation:e.parameters.getProperty(FC.ForceDictationPropertyName,"false")==="true"?n=a+this.dictationRelativeUri:e.recognitionEndpointVersion!==void 0&&parseInt(e.recognitionEndpointVersion,10)>1?n=`${a}${this.universalUri}${e.recognitionEndpointVersion}`:n=a+this.conversationRelativeUri;break;case Xl.RecognitionMode.Dictation:n=a+this.dictationRelativeUri;break;default:e.recognitionEndpointVersion!==void 0&&parseInt(e.recognitionEndpointVersion,10)>1?n=`${a}${this.universalUri}${e.recognitionEndpointVersion}`:n=a+this.interactiveRelativeUri;break}let d={};t.token!==void 0&&t.token!==""&&(d[t.headerName]=t.token),d[XA.HeaderNames.ConnectionId]=r;let v=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new BC.WebsocketConnection(n,c,d,new Xl.WebsocketMessageFormatter,BC.ProxyInfo.fromRecognizerConfig(e),v,r),w=g.uri;return e.parameters.setProperty(fr.PropertyId.SpeechServiceConnection_Url,w),g}};Cc.SpeechConnectionFactory=Zl});var KC=p(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});Pc.ConversationTranscriberConnectionFactory=void 0;var WC=pe(),We=f(),ZA=C(),HC=Ye(),eb=C(),tb=we(),rt=Ut(),ev=class extends HC.ConnectionFactoryBase{constructor(){super(...arguments),this.universalUri="/speech/universal/v2"}create(e,t,r){let n=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Region,void 0),o=HC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_EndpointId,void 0),h=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);u?(!n||n.search(rt.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[rt.QueryParameterNames.CustomSpeechDeploymentId]=u):h&&(!n||n.search(rt.QueryParameterNames.Language)===-1)&&(c[rt.QueryParameterNames.Language]=h),e.autoDetectSourceLanguages!==void 0&&(c[rt.QueryParameterNames.EnableLanguageId]="true"),this.setV2UrlParams(e,c,n),n||(n=`${a}${this.universalUri}`);let d={};t.token!==void 0&&t.token!==""&&(d[t.headerName]=t.token),d[tb.HeaderNames.ConnectionId]=r;let v=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new WC.WebsocketConnection(n,c,d,new eb.WebsocketMessageFormatter,WC.ProxyInfo.fromRecognizerConfig(e),v,r),w=g.uri;return e.parameters.setProperty(We.PropertyId.SpeechServiceConnection_Url,w),g}setV2UrlParams(e,t,r){new Map([[We.PropertyId.Speech_SegmentationSilenceTimeoutMs,rt.QueryParameterNames.SegmentationSilenceTimeoutMs],[We.PropertyId.SpeechServiceConnection_EnableAudioLogging,rt.QueryParameterNames.EnableAudioLogging],[We.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,rt.QueryParameterNames.EndSilenceTimeoutMs],[We.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,rt.QueryParameterNames.InitialSilenceTimeoutMs],[We.PropertyId.SpeechServiceResponse_PostProcessingOption,rt.QueryParameterNames.Postprocessing],[We.PropertyId.SpeechServiceResponse_ProfanityOption,rt.QueryParameterNames.Profanity],[We.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,rt.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(ZA.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}};Pc.ConversationTranscriberConnectionFactory=ev});var QC=p(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});Rc.TranscriberConnectionFactory=void 0;var JC=pe(),He=f(),GC=Ye(),$C=C(),rb=we(),Wn=Ut(),tv=class extends GC.ConnectionFactoryBase{constructor(){super(...arguments),this.multiaudioRelativeUri="/speech/recognition/multiaudio"}create(e,t,r){let n=e.parameters.getProperty(He.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(He.PropertyId.SpeechServiceConnection_Region,"centralus"),o=GC.ConnectionFactoryBase.getHostSuffix(s),a="wss://transcribe."+s+".cts.speech"+o+this.multiaudioRelativeUri,c=e.parameters.getProperty(He.PropertyId.SpeechServiceConnection_Host,a),u={};this.setQueryParams(u,e,n),n||(n=c);let h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[rb.HeaderNames.ConnectionId]=r,e.parameters.setProperty(He.PropertyId.SpeechServiceConnection_Url,n);let d=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new JC.WebsocketConnection(n,u,h,new $C.WebsocketMessageFormatter,JC.ProxyInfo.fromRecognizerConfig(e),d,r)}setQueryParams(e,t,r){let n=t.parameters.getProperty(He.PropertyId.SpeechServiceConnection_EndpointId,void 0),s=t.parameters.getProperty(He.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);n&&!(Wn.QueryParameterNames.CustomSpeechDeploymentId in e)&&(e[Wn.QueryParameterNames.CustomSpeechDeploymentId]=n),s&&!(Wn.QueryParameterNames.Language in e)&&(e[Wn.QueryParameterNames.Language]=s);let o=t.parameters.getProperty(He.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true",a=t.parameters.getProperty($C.OutputFormatPropertyName,He.OutputFormat[He.OutputFormat.Simple])!==He.OutputFormat[He.OutputFormat.Simple];(o||a)&&(e[Wn.QueryParameterNames.Format]=He.OutputFormat[He.OutputFormat.Detailed].toLowerCase()),this.setCommonUrlParams(t,e,r)}};Rc.TranscriberConnectionFactory=tv});var eP=p(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});Ec.TranslationConnectionFactory=void 0;var YC=pe(),ib=Wd(),Gt=f(),XC=Ye(),rv=C(),nb=we(),ZC=Ut(),iv=class extends XC.ConnectionFactoryBase{create(e,t,r){let n=this.getEndpointUrl(e),s={};e.autoDetectSourceLanguages!==void 0&&(s[ZC.QueryParameterNames.EnableLanguageId]="true"),this.setQueryParams(s,e,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[nb.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Gt.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new YC.WebsocketConnection(n,s,o,new rv.WebsocketMessageFormatter,YC.ProxyInfo.fromRecognizerConfig(e),a,r)}getEndpointUrl(e,t){let r=e.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_Region),n=XC.ConnectionFactoryBase.getHostSuffix(r),s=e.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_Endpoint,void 0);return s||(e.autoDetectSourceLanguages!==void 0?s=e.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_Host,"wss://{region}.stt.speech"+n)+"/speech/universal/v2":s=e.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_Host,"wss://{region}.s2s.speech"+n)+"/speech/translation/cognitiveservices/v1"),t===!0?s:ib.StringUtils.formatString(s,{region:r})}setQueryParams(e,t,r){e.from=t.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_RecoLanguage),e.to=t.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_TranslationToLanguages),e.scenario=t.recognitionMode===rv.RecognitionMode.Interactive?"interactive":t.recognitionMode===rv.RecognitionMode.Conversation?"conversation":"",this.setCommonUrlParams(t,e,r),this.setUrlParameter(Gt.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,ZC.QueryParameterNames.StableTranslation,t,e,r);let n=t.parameters.getProperty(Gt.PropertyId.SpeechServiceConnection_TranslationVoice,void 0);n!==void 0&&(e.voice=n,e.features="texttospeech")}};Ec.TranslationConnectionFactory=iv});var tP=p(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});Ic.EnumTranslation=void 0;var ue=f(),se=C(),nv=class{static implTranslateRecognitionResult(e,t=!1){let r=ue.ResultReason.Canceled;switch(e){case se.RecognitionStatus.Success:r=ue.ResultReason.RecognizedSpeech;break;case se.RecognitionStatus.EndOfDictation:r=t?ue.ResultReason.RecognizedSpeech:ue.ResultReason.NoMatch;break;case se.RecognitionStatus.NoMatch:case se.RecognitionStatus.InitialSilenceTimeout:case se.RecognitionStatus.BabbleTimeout:r=ue.ResultReason.NoMatch;break;case se.RecognitionStatus.Error:case se.RecognitionStatus.BadRequest:case se.RecognitionStatus.Forbidden:default:r=ue.ResultReason.Canceled;break}return r}static implTranslateCancelResult(e){let t=ue.CancellationReason.EndOfStream;switch(e){case se.RecognitionStatus.Success:case se.RecognitionStatus.EndOfDictation:case se.RecognitionStatus.NoMatch:t=ue.CancellationReason.EndOfStream;break;case se.RecognitionStatus.InitialSilenceTimeout:case se.RecognitionStatus.BabbleTimeout:case se.RecognitionStatus.Error:case se.RecognitionStatus.BadRequest:case se.RecognitionStatus.Forbidden:default:t=ue.CancellationReason.Error;break}return t}static implTranslateCancelErrorCode(e){let t=ue.CancellationErrorCode.NoError;switch(e){case se.RecognitionStatus.Error:t=ue.CancellationErrorCode.ServiceError;break;case se.RecognitionStatus.TooManyRequests:t=ue.CancellationErrorCode.TooManyRequests;break;case se.RecognitionStatus.BadRequest:t=ue.CancellationErrorCode.BadRequestParameters;break;case se.RecognitionStatus.Forbidden:t=ue.CancellationErrorCode.Forbidden;break;default:t=ue.CancellationErrorCode.NoError;break}return t}static implTranslateErrorDetails(e){let t="The speech service encountered an internal error and could not continue.";switch(e){case ue.CancellationErrorCode.Forbidden:t="The recognizer is using a free subscription that ran out of quota.";break;case ue.CancellationErrorCode.BadRequestParameters:t="Invalid parameter or unsupported audio format in the request.";break;case ue.CancellationErrorCode.TooManyRequests:t="The number of parallel requests exceeded the number of allowed concurrent transcriptions.";break;default:break}return t}};Ic.EnumTranslation=nv});var rP=p(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});gr.RecognitionStatus=gr.SynthesisStatus=void 0;var sb;(function(i){i[i.Success=0]="Success",i[i.SynthesisEnd=1]="SynthesisEnd",i[i.Error=2]="Error"})(sb=gr.SynthesisStatus||(gr.SynthesisStatus={}));var ob;(function(i){i[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",i[i.TooManyRequests=6]="TooManyRequests",i[i.BadRequest=7]="BadRequest",i[i.Forbidden=8]="Forbidden"})(ob=gr.RecognitionStatus||(gr.RecognitionStatus={}))});var nP=p(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.TranslationSynthesisEnd=void 0;var iP=C(),sv=class i{constructor(e){this.privSynthesisEnd=JSON.parse(e),this.privSynthesisEnd.SynthesisStatus&&(this.privSynthesisEnd.SynthesisStatus=iP.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]),this.privSynthesisEnd.Status&&(this.privSynthesisEnd.SynthesisStatus=iP.SynthesisStatus[this.privSynthesisEnd.Status])}static fromJSON(e){return new i(e)}get SynthesisStatus(){return this.privSynthesisEnd.SynthesisStatus}get FailureReason(){return this.privSynthesisEnd.FailureReason}};wc.TranslationSynthesisEnd=sv});var sP=p(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});_c.TranslationHypothesis=void 0;var ab=I(),cb=bs(),ov=class i{constructor(e){this.privTranslationHypothesis=e,this.privTranslationHypothesis.Translation.TranslationStatus=cb.TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus]}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){ab.Contracts.throwIfNullOrUndefined(e,"translationHypothesis");let t=e.SpeechHypothesis;return e.SpeechHypothesis=void 0,t.Translation=e,new i(t)}get Duration(){return this.privTranslationHypothesis.Duration}get Offset(){return this.privTranslationHypothesis.Offset}get Text(){return this.privTranslationHypothesis.Text}get Translation(){return this.privTranslationHypothesis.Translation}get Language(){return this.privTranslationHypothesis.PrimaryLanguage?.Language}};_c.TranslationHypothesis=ov});var oP=p(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});Tc.TranslationPhrase=void 0;var pb=I(),ub=C(),hb=bs(),av=class i{constructor(e){this.privTranslationPhrase=e,this.privTranslationPhrase.RecognitionStatus=ub.RecognitionStatus[this.privTranslationPhrase.RecognitionStatus],this.privTranslationPhrase.Translation!==void 0&&(this.privTranslationPhrase.Translation.TranslationStatus=hb.TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus])}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){pb.Contracts.throwIfNullOrUndefined(e,"translationResponse");let t=e.SpeechPhrase;return e.SpeechPhrase=void 0,t.Translation=e,t.Text=t.DisplayText,new i(t)}get RecognitionStatus(){return this.privTranslationPhrase.RecognitionStatus}get Offset(){return this.privTranslationPhrase.Offset}get Duration(){return this.privTranslationPhrase.Duration}get Text(){return this.privTranslationPhrase.Text}get Language(){return this.privTranslationPhrase.PrimaryLanguage?.Language}get Confidence(){return this.privTranslationPhrase.PrimaryLanguage?.Confidence}get Translation(){return this.privTranslationPhrase.Translation}};Tc.TranslationPhrase=av});var cP=p(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});Ac.TranslationServiceRecognizer=void 0;var aP=P(),z=f(),Te=C(),cv=class extends Te.ConversationServiceRecognizer{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privTranslationRecognizer=s,this.connectionEvents.attach(o=>{o.name==="ConnectionEstablishedEvent"&&this.privTranslationRecognizer.onConnection()})}async processTypeSpecificMessages(e){let t=new z.PropertyCollection,r=await this.processSpeechMessages(e);if(r)return!0;let n=async o=>{if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus===Te.RecognitionStatus.Success){let a=this.fireEventForResult(o,t);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,a)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(a.result)}catch(c){this.privErrorCallback&&this.privErrorCallback(c)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}else{let a=Te.EnumTranslation.implTranslateRecognitionResult(o.RecognitionStatus),c=new z.TranslationRecognitionResult(void 0,this.privRequestSession.requestId,a,o.Text,o.Duration,this.privRequestSession.currentTurnAudioOffset+o.Offset,o.Language,o.Confidence,void 0,e.textBody,t);if(a===z.ResultReason.Canceled){let u=Te.EnumTranslation.implTranslateCancelResult(o.RecognitionStatus),h=Te.EnumTranslation.implTranslateCancelErrorCode(o.RecognitionStatus);await this.cancelRecognitionLocal(u,h,Te.EnumTranslation.implTranslateErrorDetails(h))}else{if(!(this.privRequestSession.isSpeechEnded&&a===z.ResultReason.NoMatch&&o.RecognitionStatus!==Te.RecognitionStatus.InitialSilenceTimeout)){let u=new z.TranslationRecognitionEventArgs(c,c.offset,this.privRequestSession.sessionId);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,u)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(c)}catch(u){this.privErrorCallback&&this.privErrorCallback(u)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}r=!0}},s=(o,a)=>{let c=this.fireEventForResult(o,a);if(this.privRequestSession.onHypothesis(this.privRequestSession.currentTurnAudioOffset+c.offset),this.privTranslationRecognizer.recognizing)try{this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,c)}catch{}r=!0};switch(e.messageType===aP.MessageType.Text&&t.setProperty(z.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"translation.hypothesis":s(Te.TranslationHypothesis.fromJSON(e.textBody),t);break;case"translation.response":let o=JSON.parse(e.textBody);if(o.SpeechPhrase)await n(Te.TranslationPhrase.fromTranslationResponse(o));else{let c=JSON.parse(e.textBody);c.SpeechHypothesis&&s(Te.TranslationHypothesis.fromTranslationResponse(c),t)}break;case"translation.phrase":await n(Te.TranslationPhrase.fromJSON(e.textBody));break;case"translation.synthesis":this.sendSynthesisAudio(e.binaryBody,this.privRequestSession.sessionId),r=!0;break;case"audio.end":case"translation.synthesis.end":let a=Te.TranslationSynthesisEnd.fromJSON(e.textBody);switch(a.SynthesisStatus){case Te.SynthesisStatus.Error:if(this.privTranslationRecognizer.synthesizing){let c=new z.TranslationSynthesisResult(z.ResultReason.Canceled,void 0),u=new z.TranslationSynthesisEventArgs(c,this.privRequestSession.sessionId);try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,u)}catch{}}if(this.privTranslationRecognizer.canceled){let c=new z.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId,z.CancellationReason.Error,a.FailureReason,z.CancellationErrorCode.ServiceError,null);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,c)}catch{}}break;case Te.SynthesisStatus.Success:this.sendSynthesisAudio(void 0,this.privRequestSession.sessionId);break;default:break}r=!0;break;default:break}return r}cancelRecognition(e,t,r,n,s){let o=new z.PropertyCollection;if(o.setProperty(Te.CancellationErrorCodePropertyName,z.CancellationErrorCode[n]),this.privTranslationRecognizer.canceled){let a=new z.TranslationRecognitionCanceledEventArgs(e,r,s,n,void 0);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new z.TranslationRecognitionResult(void 0,t,z.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}handleRecognizingCallback(e,t,r){try{let n=new z.TranslationRecognitionEventArgs(z.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,n)}catch{}}handleRecognizedCallback(e,t,r){try{let n=new z.TranslationRecognitionEventArgs(z.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,n)}catch{}}fireEventForResult(e,t){let r;if(e.Translation.Translations!==void 0){r=new z.Translations;for(let h of e.Translation.Translations)r.set(h.Language,h.Text||h.DisplayText)}let n,s;e instanceof Te.TranslationPhrase?(e.Translation&&e.Translation.TranslationStatus===aP.TranslationStatus.Success?n=z.ResultReason.TranslatedSpeech:n=z.ResultReason.RecognizedSpeech,s=e.Confidence):n=z.ResultReason.TranslatingSpeech;let o=e.Language,a=e.Offset+this.privRequestSession.currentTurnAudioOffset,c=new z.TranslationRecognitionResult(r,this.privRequestSession.requestId,n,e.Text,e.Duration,a,o,s,e.Translation.FailureReason,JSON.stringify(e),t);return new z.TranslationRecognitionEventArgs(c,a,this.privRequestSession.sessionId)}sendSynthesisAudio(e,t){let r=e===void 0?z.ResultReason.SynthesizingAudioCompleted:z.ResultReason.SynthesizingAudio,n=new z.TranslationSynthesisResult(r,e),s=new z.TranslationSynthesisEventArgs(n,t);if(this.privTranslationRecognizer.synthesizing)try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,s)}catch{}}};Ac.TranslationServiceRecognizer=cv});var pP=p(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.SpeechDetected=void 0;var pv=class i{constructor(e){this.privSpeechStartDetected=JSON.parse(e)}static fromJSON(e){return new i(e)}get Offset(){return this.privSpeechStartDetected.Offset}};bc.SpeechDetected=pv});var uP=p(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.SpeechHypothesis=void 0;var uv=class i{constructor(e){this.privSpeechHypothesis=JSON.parse(e)}static fromJSON(e){return new i(e)}get Text(){return this.privSpeechHypothesis.Text}get Offset(){return this.privSpeechHypothesis.Offset}get Duration(){return this.privSpeechHypothesis.Duration}get Language(){return this.privSpeechHypothesis.PrimaryLanguage===void 0?void 0:this.privSpeechHypothesis.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privSpeechHypothesis.PrimaryLanguage===void 0?void 0:this.privSpeechHypothesis.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSpeechHypothesis.SpeakerId}};Oc.SpeechHypothesis=uv});var hP=p(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.SpeechKeyword=void 0;var hv=class i{constructor(e){this.privSpeechKeyword=JSON.parse(e)}static fromJSON(e){return new i(e)}get Status(){return this.privSpeechKeyword.Status}get Text(){return this.privSpeechKeyword.Text}get Offset(){return this.privSpeechKeyword.Offset}get Duration(){return this.privSpeechKeyword.Duration}};Mc.SpeechKeyword=hv});var dP=p(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});Dc.SpeechServiceRecognizer=void 0;var ye=f(),it=C(),dv=class extends it.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeechRecognizer=s}async processTypeSpecificMessages(e){let t,r=new ye.PropertyCollection;r.setProperty(ye.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=it.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new ye.SpeechRecognitionResult(this.privRequestSession.requestId,ye.ResultReason.RecognizingSpeech,s.Text,s.Duration,o,s.Language,s.LanguageDetectionConfidence,void 0,void 0,e.textBody,r),this.privRequestSession.onHypothesis(o);let a=new ye.SpeechRecognitionEventArgs(t,s.Duration,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognizing)try{this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer,a)}catch{}n=!0;break;case"speech.phrase":let c=it.SimpleSpeechPhrase.fromJSON(e.textBody),u=it.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus,this.privExpectContentAssessmentResponse);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),ye.ResultReason.Canceled===u){let h=it.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),d=it.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(h,d,it.EnumTranslation.implTranslateErrorDetails(d))}else{if(!(this.privRequestSession.isSpeechEnded&&u===ye.ResultReason.NoMatch&&c.RecognitionStatus!==it.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(it.OutputFormatPropertyName)===ye.OutputFormat[ye.OutputFormat.Simple])t=new ye.SpeechRecognitionResult(this.privRequestSession.requestId,u,c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,void 0,e.textBody,r);else{let d=it.DetailedSpeechPhrase.fromJSON(e.textBody),v=d.Offset+this.privRequestSession.currentTurnAudioOffset,g=d.getJsonWithCorrectedOffsets(v);t=new ye.SpeechRecognitionResult(this.privRequestSession.requestId,u,d.RecognitionStatus===it.RecognitionStatus.Success?d.NBest[0].Display:void 0,d.Duration,v,d.Language,d.LanguageDetectionConfidence,void 0,void 0,g,r)}let h=new ye.SpeechRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognized)try{this.privSpeechRecognizer.recognized(this.privSpeechRecognizer,h)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){let o=new ye.PropertyCollection;if(o.setProperty(it.CancellationErrorCodePropertyName,ye.CancellationErrorCode[n]),this.privSpeechRecognizer.canceled){let a=new ye.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new ye.SpeechRecognitionResult(t,ye.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}};Dc.SpeechServiceRecognizer=dv});var lP=p(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.ConversationTranscriptionServiceRecognizer=void 0;var Ne=f(),nt=C(),lv=class extends nt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privConversationTranscriber=s,this.setSpeakerDiarizationJson()}setSpeakerDiarizationJson(){if(this.privEnableSpeakerId){let e=this.privSpeechContext.getSection("phraseDetection");e.mode="Conversation";let t={};t.mode="Anonymous",t.audioSessionId=this.privDiarizationSessionId,t.audioOffsetMs=0,e.speakerDiarization=t,this.privSpeechContext.setSection("phraseDetection",e)}}async processTypeSpecificMessages(e){let t,r=new Ne.PropertyCollection;r.setProperty(Ne.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=nt.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new Ne.ConversationTranscriptionResult(this.privRequestSession.requestId,Ne.ResultReason.RecognizingSpeech,s.Text,s.Duration,o,s.Language,s.LanguageDetectionConfidence,void 0,void 0,e.textBody,r),this.privRequestSession.onHypothesis(o);let a=new Ne.ConversationTranscriptionEventArgs(t,s.Duration,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribing)try{this.privConversationTranscriber.transcribing(this.privConversationTranscriber,a)}catch{}n=!0;break;case"speech.phrase":let c=nt.SimpleSpeechPhrase.fromJSON(e.textBody),u=nt.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),Ne.ResultReason.Canceled===u){let h=nt.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),d=nt.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(h,d,nt.EnumTranslation.implTranslateErrorDetails(d))}else if(!(this.privRequestSession.isSpeechEnded&&u===Ne.ResultReason.NoMatch&&c.RecognitionStatus!==nt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(nt.OutputFormatPropertyName)===Ne.OutputFormat[Ne.OutputFormat.Simple])t=new Ne.ConversationTranscriptionResult(this.privRequestSession.requestId,u,c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,c.SpeakerId,void 0,e.textBody,r);else{let d=nt.DetailedSpeechPhrase.fromJSON(e.textBody),v=d.Offset+this.privRequestSession.currentTurnAudioOffset,g=d.getJsonWithCorrectedOffsets(v);t=new Ne.ConversationTranscriptionResult(this.privRequestSession.requestId,u,d.RecognitionStatus===nt.RecognitionStatus.Success?d.NBest[0].Display:void 0,d.Duration,v,d.Language,d.LanguageDetectionConfidence,c.SpeakerId,void 0,g,r)}let h=new Ne.ConversationTranscriptionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribed)try{this.privConversationTranscriber.transcribed(this.privConversationTranscriber,h)}catch{}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){if(new Ne.PropertyCollection().setProperty(nt.CancellationErrorCodePropertyName,Ne.CancellationErrorCode[n]),this.privConversationTranscriber.canceled){let a=new Ne.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationTranscriber.canceled(this.privConversationTranscriber,a)}catch{}}}};kc.ConversationTranscriptionServiceRecognizer=lv});var fP=p(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});Nc.TranscriptionServiceRecognizer=void 0;var db=P(),$t=f(),vP=C(),lb=Jr(),vv=class extends vP.ConversationServiceRecognizer{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privTranscriberRecognizer=s,this.sendPrePayloadJSONOverride=o=>this.sendTranscriptionStartJSON(o),this.privRecognizerConfig.parameters.getProperty($t.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps)==="true"&&this.privSpeechContext.setWordLevelTimings()}async sendSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){let r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createSpeechEventPayload(e,t))}}async sendMeetingSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){let r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createMeetingSpeechEventPayload(e,t))}}processTypeSpecificMessages(e){return this.processSpeechMessages(e)}handleRecognizedCallback(e,t,r){try{let n=new $t.SpeechRecognitionEventArgs(e,t,r);if(this.privTranscriberRecognizer.recognized(this.privTranscriberRecognizer,n),this.privSuccessCallback){try{this.privSuccessCallback(e)}catch(s){this.privErrorCallback&&this.privErrorCallback(s)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}catch{}}handleRecognizingCallback(e,t,r){try{let n=new $t.SpeechRecognitionEventArgs(e,t,r);this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer,n)}catch{}}cancelRecognition(e,t,r,n,s){let o=new $t.PropertyCollection;if(o.setProperty(vP.CancellationErrorCodePropertyName,$t.CancellationErrorCode[n]),this.privTranscriberRecognizer.IsMeetingRecognizer()){if(this.privTranscriberRecognizer.canceled){let a=new $t.MeetingTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}}else if(this.privTranscriberRecognizer.canceled){let a=new $t.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new $t.SpeechRecognitionResult(t,$t.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}async sendTranscriptionStartJSON(e){if(await this.sendSpeechContext(e,!0),this.privTranscriberRecognizer.IsMeetingRecognizer()){let t=this.privTranscriberRecognizer.getMeetingInfo(),r=this.createMeetingSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}else{let t=this.privTranscriberRecognizer.getConversationInfo(),r=this.createSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}await this.sendWaveHeader(e)}sendSpeechEvent(e,t){let r=JSON.stringify(t);if(r)return e.send(new lb.SpeechConnectionMessage(db.MessageType.Text,"speech.event",this.privRequestSession.requestId,"application/json",r))}createSpeechEventPayload(e,t){let r={id:"meeting",name:t,meeting:e.conversationProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}createMeetingSpeechEventPayload(e,t){let r={id:"meeting",name:t,meeting:e.meetingProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}};Nc.TranscriptionServiceRecognizer=vv});var gP=p(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});qc.DetailedSpeechPhrase=void 0;var vb=C(),fv=class i{constructor(e){this.privDetailedSpeechPhrase=JSON.parse(e),this.privDetailedSpeechPhrase.RecognitionStatus=vb.RecognitionStatus[this.privDetailedSpeechPhrase.RecognitionStatus]}static fromJSON(e){return new i(e)}getJsonWithCorrectedOffsets(e){if(this.privDetailedSpeechPhrase.NBest){let t;for(let r of this.privDetailedSpeechPhrase.NBest)if(r.Words&&r.Words[0]){t=r.Words[0].Offset;break}if(t&&t<e){let r=e-t;for(let n of this.privDetailedSpeechPhrase.NBest){if(n.Words)for(let s of n.Words)s.Offset+=r;if(n.DisplayWords)for(let s of n.DisplayWords)s.Offset+=r}}}return JSON.stringify(this.privDetailedSpeechPhrase)}get RecognitionStatus(){return this.privDetailedSpeechPhrase.RecognitionStatus}get NBest(){return this.privDetailedSpeechPhrase.NBest}get Duration(){return this.privDetailedSpeechPhrase.Duration}get Offset(){return this.privDetailedSpeechPhrase.Offset}get Language(){return this.privDetailedSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privDetailedSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Confidence}get Text(){return this.privDetailedSpeechPhrase.NBest&&this.privDetailedSpeechPhrase.NBest[0]?this.privDetailedSpeechPhrase.NBest[0].Display||this.privDetailedSpeechPhrase.NBest[0].DisplayText:this.privDetailedSpeechPhrase.DisplayText}get SpeakerId(){return this.privDetailedSpeechPhrase.SpeakerId}};qc.DetailedSpeechPhrase=fv});var mP=p(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.SimpleSpeechPhrase=void 0;var fb=C(),gv=class i{constructor(e){this.privSimpleSpeechPhrase=JSON.parse(e),this.privSimpleSpeechPhrase.RecognitionStatus=fb.RecognitionStatus[this.privSimpleSpeechPhrase.RecognitionStatus]}static fromJSON(e){return new i(e)}get RecognitionStatus(){return this.privSimpleSpeechPhrase.RecognitionStatus}get DisplayText(){return this.privSimpleSpeechPhrase.DisplayText}get Offset(){return this.privSimpleSpeechPhrase.Offset}get Duration(){return this.privSimpleSpeechPhrase.Duration}get Language(){return this.privSimpleSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privSimpleSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSimpleSpeechPhrase.SpeakerId}};xc.SimpleSpeechPhrase=gv});var SP=p(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.AddedLmIntent=void 0;var mv=class{constructor(e,t){this.modelImpl=e,this.intentName=t}};zc.AddedLmIntent=mv});var CP=p(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.IntentServiceRecognizer=void 0;var yP=P(),oe=f(),ki=C(),Sv=class extends ki.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privIntentRecognizer=s,this.privIntentDataSent=!1}setIntents(e,t){this.privAddedLmIntents=e,this.privUmbrellaIntent=t,this.privIntentDataSent=!0}processTypeSpecificMessages(e){let t,r,n=!1,s=new oe.PropertyCollection;switch(e.messageType===yP.MessageType.Text&&s.setProperty(oe.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.hypothesis":let a=ki.SpeechHypothesis.fromJSON(e.textBody);if(t=new oe.IntentRecognitionResult(void 0,this.privRequestSession.requestId,oe.ResultReason.RecognizingIntent,a.Text,a.Duration,a.Offset+this.privRequestSession.currentTurnAudioOffset,a.Language,a.LanguageDetectionConfidence,void 0,e.textBody,s),this.privRequestSession.onHypothesis(t.offset),r=new oe.IntentRecognitionEventArgs(t,a.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId),this.privIntentRecognizer.recognizing)try{this.privIntentRecognizer.recognizing(this.privIntentRecognizer,r)}catch{}n=!0;break;case"speech.phrase":let c=ki.SimpleSpeechPhrase.fromJSON(e.textBody);t=new oe.IntentRecognitionResult(void 0,this.privRequestSession.requestId,ki.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus),c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,e.textBody,s),r=new oe.IntentRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);let u=()=>{if(this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(d){this.privErrorCallback&&this.privErrorCallback(d)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}};this.privIntentDataSent===!1||oe.ResultReason.NoMatch===r.result.reason?(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),u()):this.privPendingIntentArgs=r,n=!0;break;case"response":if(r=this.privPendingIntentArgs,this.privPendingIntentArgs=void 0,r===void 0){if(e.textBody==="")return;r=new oe.IntentRecognitionEventArgs(new oe.IntentRecognitionResult,0,this.privRequestSession.sessionId)}let h=ki.IntentResponse.fromJSON(e.textBody);if(h!==null&&h.topScoringIntent&&h.topScoringIntent.intent){let d=this.privAddedLmIntents[h.topScoringIntent.intent];if(this.privUmbrellaIntent!==void 0&&(d=this.privUmbrellaIntent),d){let v=d===void 0||d.intentName===void 0?h.topScoringIntent.intent:d.intentName,g=r.result.reason;v!==void 0&&(g=oe.ResultReason.RecognizedIntent);let w=r.result.properties!==void 0?r.result.properties:new oe.PropertyCollection;w.setProperty(oe.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,e.textBody),r=new oe.IntentRecognitionEventArgs(new oe.IntentRecognitionResult(v,r.result.resultId,g,r.result.text,r.result.duration,r.result.offset,void 0,void 0,r.result.errorDetails,r.result.json,w),r.offset,r.sessionId)}}if(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(r.result)}catch(d){this.privErrorCallback&&this.privErrorCallback(d)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}n=!0;break;default:break}let o=new yP.Deferred;return o.resolve(n),o.promise}cancelRecognition(e,t,r,n,s){let o=new oe.PropertyCollection;if(o.setProperty(ki.CancellationErrorCodePropertyName,oe.CancellationErrorCode[n]),this.privIntentRecognizer.canceled){let a=new oe.IntentRecognitionCanceledEventArgs(r,s,n,void 0,void 0,e);try{this.privIntentRecognizer.canceled(this.privIntentRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new oe.IntentRecognitionResult(void 0,t,oe.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}};jc.IntentServiceRecognizer=Sv});var PP=p(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});Lc.IntentResponse=void 0;var yv=class i{constructor(e){e===""?this.privIntentResponse={}:this.privIntentResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get query(){return this.privIntentResponse.query}get topScoringIntent(){return this.privIntentResponse.topScoringIntent}get entities(){return this.privIntentResponse.entities}};Lc.IntentResponse=yv});var EP=p(RP=>{"use strict";Object.defineProperty(RP,"__esModule",{value:!0})});var wP=p(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});Bc.ServiceTelemetryListener=void 0;var Qt=P(),IP=dc(),Cv=class{constructor(e,t,r){this.privIsDisposed=!1,this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privRequestId=e,this.privAudioSourceId=t,this.privAudioNodeId=r,this.privReceivedMessages={},this.privPhraseLatencies=[],this.privHypothesisLatencies=[]}phraseReceived(e){e>0&&this.privPhraseLatencies.push(Date.now()-e)}hypothesisReceived(e){e>0&&this.privHypothesisLatencies.push(Date.now()-e)}onEvent(e){this.privIsDisposed||(e instanceof IP.RecognitionTriggeredEvent&&e.requestId===this.privRequestId&&(this.privListeningTriggerMetric={End:e.eventTime,Name:"ListeningTrigger",Start:e.eventTime}),e instanceof Qt.AudioStreamNodeAttachingEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Qt.AudioStreamNodeAttachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Qt.AudioSourceErrorEvent&&e.audioSourceId===this.privAudioSourceId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof Qt.AudioStreamNodeErrorEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof Qt.AudioStreamNodeDetachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Name:"Microphone",Start:this.privMicStartTime})),e instanceof IP.ConnectingToServiceEvent&&e.requestId===this.privRequestId&&(this.privConnectionId=e.sessionId),e instanceof Qt.ConnectionStartEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionStartTime=e.eventTime),e instanceof Qt.ConnectionEstablishedEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof Qt.ConnectionEstablishErrorEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Error:this.getConnectionError(e.statusCode),Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof Qt.ConnectionMessageReceivedEvent&&e.connectionId===this.privConnectionId&&e.message&&e.message.headers&&e.message.headers.path&&(this.privReceivedMessages[e.message.headers.path]||(this.privReceivedMessages[e.message.headers.path]=new Array),this.privReceivedMessages[e.message.headers.path].length<50&&this.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime)))}getTelemetry(){let e=new Array;this.privListeningTriggerMetric&&e.push(this.privListeningTriggerMetric),this.privMicMetric&&e.push(this.privMicMetric),this.privConnectionEstablishMetric&&e.push(this.privConnectionEstablishMetric),this.privPhraseLatencies.length>0&&e.push({PhraseLatencyMs:this.privPhraseLatencies}),this.privHypothesisLatencies.length>0&&e.push({FirstHypothesisLatencyMs:this.privHypothesisLatencies});let t={Metrics:e,ReceivedMessages:this.privReceivedMessages},r=JSON.stringify(t);return this.privReceivedMessages={},this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privPhraseLatencies=[],this.privHypothesisLatencies=[],r}get hasTelemetry(){return Object.keys(this.privReceivedMessages).length!==0||this.privListeningTriggerMetric!==null||this.privMicMetric!==null||this.privConnectionEstablishMetric!==null||this.privPhraseLatencies.length!==0||this.privHypothesisLatencies.length!==0}dispose(){this.privIsDisposed=!0}getConnectionError(e){switch(e){case 400:case 1002:case 1003:case 1005:case 1007:case 1008:case 1009:return"BadRequest";case 401:return"Unauthorized";case 403:return"Forbidden";case 503:case 1001:return"ServerUnavailable";case 500:case 1011:return"ServerError";case 408:case 504:return"Timeout";default:return"statuscode:"+e.toString()}}};Bc.ServiceTelemetryListener=Cv});var _P=p(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});Vc.RequestSession=void 0;var Ni=P(),Fc=dc(),gb=wP(),Pv=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privIsAudioNodeDetached=!1,this.privIsRecognizing=!1,this.privIsSpeechEnded=!1,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privHypothesisReceived=!1,this.privBytesSent=0,this.privRecognitionBytesSent=0,this.privRecogNumber=0,this.privInTurn=!1,this.privConnectionAttempts=0,this.privAudioSourceId=e,this.privRequestId=Ni.createNoDashGuid(),this.privAudioNodeId=Ni.createNoDashGuid(),this.privTurnDeferral=new Ni.Deferred,this.privTurnDeferral.resolve()}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get audioNodeId(){return this.privAudioNodeId}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSpeechEnded(){return this.privIsSpeechEnded}get isRecognizing(){return this.privIsRecognizing}get currentTurnAudioOffset(){return this.privTurnStartAudioOffset}get recogNumber(){return this.privRecogNumber}get numConnectionAttempts(){return this.privConnectionAttempts}get bytesSent(){return this.privBytesSent}get recognitionBytesSent(){return this.privRecognitionBytesSent}listenForServiceTelemetry(e){this.privServiceTelemetryListener&&this.privDetachables.push(e.attachListener(this.privServiceTelemetryListener))}startNewRecognition(){this.privRecognitionBytesSent=0,this.privIsSpeechEnded=!1,this.privIsRecognizing=!0,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privRecogNumber++,this.privServiceTelemetryListener=new gb.ServiceTelemetryListener(this.privRequestId,this.privAudioSourceId,this.privAudioNodeId),this.onEvent(new Fc.RecognitionTriggeredEvent(this.requestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}async onAudioSourceAttachCompleted(e,t){this.privAudioNode=e,this.privIsAudioNodeDetached=!1,t?await this.onComplete():this.onEvent(new Fc.ListeningStartedEvent(this.privRequestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}onPreConnectionStart(e,t){this.privAuthFetchEventId=e,this.privSessionId=t,this.onEvent(new Fc.ConnectingToServiceEvent(this.privRequestId,this.privAuthFetchEventId,this.privSessionId))}async onAuthCompleted(e){e&&await this.onComplete()}async onConnectionEstablishCompleted(e,t){if(e===200){this.onEvent(new Fc.RecognitionStartedEvent(this.requestId,this.privAudioSourceId,this.privAudioNodeId,this.privAuthFetchEventId,this.privSessionId)),this.privAudioNode&&this.privAudioNode.replay(),this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privBytesSent=0;return}else e===403&&await this.onComplete()}async onServiceTurnEndResponse(e){this.privTurnDeferral.resolve(),!e||this.isSpeechEnded?(await this.onComplete(),this.privInTurn=!1):(this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privAudioNode.replay())}onSpeechContext(){this.privRequestId=Ni.createNoDashGuid()}onServiceTurnStartResponse(){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch(()=>{})),this.privInTurn=!0,this.privTurnDeferral=new Ni.Deferred}onHypothesis(e){this.privHypothesisReceived||(this.privHypothesisReceived=!0,this.privServiceTelemetryListener.hypothesisReceived(this.privAudioNode.findTimeAtOffset(e)))}onPhraseRecognized(e){this.privServiceTelemetryListener.phraseReceived(this.privAudioNode.findTimeAtOffset(e)),this.onServiceRecognized(e)}onServiceRecognized(e){this.privLastRecoOffset=e,this.privHypothesisReceived=!1,this.privAudioNode.shrinkBuffers(e),this.privConnectionAttempts=0}onAudioSent(e){this.privBytesSent+=e,this.privRecognitionBytesSent+=e}onRetryConnection(){this.privConnectionAttempts++}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach();this.privServiceTelemetryListener&&this.privServiceTelemetryListener.dispose(),this.privIsRecognizing=!1}}getTelemetry(){return this.privServiceTelemetryListener.hasTelemetry?this.privServiceTelemetryListener.getTelemetry():null}async onStopRecognizing(){await this.onComplete()}onSpeechEnded(){this.privIsSpeechEnded=!0}onEvent(e){this.privServiceTelemetryListener&&this.privServiceTelemetryListener.onEvent(e),Ni.Events.instance.onEvent(e)}async onComplete(){this.privIsRecognizing&&(this.privIsRecognizing=!1,await this.detachAudioNode())}async detachAudioNode(){this.privIsAudioNodeDetached||(this.privIsAudioNodeDetached=!0,this.privAudioNode&&await this.privAudioNode.detach())}};Vc.RequestSession=Pv});var TP=p(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.SpeechContext=void 0;var Rv=class{constructor(e){this.privContext={},this.privDynamicGrammar=e}getSection(e){return this.privContext[e]||{}}setSection(e,t){this.privContext[e]=t}setPronunciationAssessmentParams(e,t,r=!1){this.privContext.phraseDetection===void 0&&(this.privContext.phraseDetection={enrichment:{pronunciationAssessment:{}}}),this.privContext.phraseDetection.enrichment===void 0&&(this.privContext.phraseDetection.enrichment={pronunciationAssessment:{}}),this.privContext.phraseDetection.enrichment.pronunciationAssessment=JSON.parse(e),r&&(this.privContext.phraseDetection.mode="Conversation"),this.setWordLevelTimings(),this.privContext.phraseOutput.detailed.options.push("PronunciationAssessment"),this.privContext.phraseOutput.detailed.options.indexOf("SNR")===-1&&this.privContext.phraseOutput.detailed.options.push("SNR"),t&&(this.privContext.phraseDetection.enrichment.contentAssessment={topic:t},this.privContext.phraseOutput.detailed.options.push("ContentAssessment"))}setDetailedOutputFormat(){this.privContext.phraseOutput===void 0&&(this.privContext.phraseOutput={detailed:{options:[]},format:{}}),this.privContext.phraseOutput.detailed===void 0&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format="Detailed"}setWordLevelTimings(){this.privContext.phraseOutput===void 0&&(this.privContext.phraseOutput={detailed:{options:[]},format:{}}),this.privContext.phraseOutput.detailed===void 0&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format="Detailed",this.privContext.phraseOutput.detailed.options.indexOf("WordTimings")===-1&&this.privContext.phraseOutput.detailed.options.push("WordTimings")}setSpeakerDiarizationAudioOffsetMs(e){this.privContext.phraseDetection.speakerDiarization.audioOffsetMs=e}toJSON(){let e=this.privDynamicGrammar.generateGrammarObject();return this.setSection("dgi",e),JSON.stringify(this.privContext)}};Uc.SpeechContext=Rv});var AP=p(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});Wc.DynamicGrammarBuilder=void 0;var Ev=class{addPhrase(e){this.privPhrases||(this.privPhrases=[]),e instanceof Array?this.privPhrases=this.privPhrases.concat(e):this.privPhrases.push(e)}clearPhrases(){this.privPhrases=void 0}addReferenceGrammar(e){this.privGrammars||(this.privGrammars=[]),e instanceof Array?this.privGrammars=this.privGrammars.concat(e):this.privGrammars.push(e)}clearGrammars(){this.privGrammars=void 0}generateGrammarObject(){if(this.privGrammars===void 0&&this.privPhrases===void 0)return;let e={};if(e.ReferenceGrammars=this.privGrammars,this.privPhrases!==void 0&&this.privPhrases.length!==0){let t=[];this.privPhrases.forEach(r=>{t.push({Text:r})}),e.Groups=[{Type:"Generic",Items:t}]}return e}};Wc.DynamicGrammarBuilder=Ev});var OP=p(bP=>{"use strict";Object.defineProperty(bP,"__esModule",{value:!0})});var wv=p($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0});$r.MessageDataStreamType=$r.ActivityPayloadResponse=void 0;var Iv=class i{constructor(e){this.privActivityResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get conversationId(){return this.privActivityResponse.conversationId}get messageDataStreamType(){return this.privActivityResponse.messageDataStreamType}get messagePayload(){return this.privActivityResponse.messagePayload}get version(){return this.privActivityResponse.version}};$r.ActivityPayloadResponse=Iv;var mb;(function(i){i[i.None=0]="None",i[i.TextToSpeechAudio=1]="TextToSpeechAudio"})(mb=$r.MessageDataStreamType||($r.MessageDataStreamType={}))});var MP=p(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});Hc.DialogServiceTurnState=void 0;var Sb=ui(),yb=br(),Cb=wv(),_v=class{constructor(e,t){this.privRequestId=t,this.privIsCompleted=!1,this.privAudioStream=null,this.privTurnManager=e,this.resetTurnEndTimeout()}get audioStream(){return this.resetTurnEndTimeout(),this.privAudioStream}processActivityPayload(e,t){return e.messageDataStreamType===Cb.MessageDataStreamType.TextToSpeechAudio&&(this.privAudioStream=yb.AudioOutputStream.createPullStream(),this.privAudioStream.format=t!==void 0?t:Sb.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privAudioStream}endAudioStream(){this.privAudioStream!==null&&!this.privAudioStream.isClosed&&this.privAudioStream.close()}complete(){this.privTimeoutToken!==void 0&&clearTimeout(this.privTimeoutToken),this.endAudioStream()}resetTurnEndTimeout(){this.privTimeoutToken!==void 0&&clearTimeout(this.privTimeoutToken),this.privTimeoutToken=setTimeout(()=>{this.privTurnManager.CompleteTurn(this.privRequestId)},2e3)}};Hc.DialogServiceTurnState=_v});var kP=p(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.DialogServiceTurnStateManager=void 0;var DP=ht(),Pb=MP(),Tv=class{constructor(){this.privTurnMap=new Map}StartTurn(e){if(this.privTurnMap.has(e))throw new DP.InvalidOperationError("Service error: There is already a turn with id:"+e);let t=new Pb.DialogServiceTurnState(this,e);return this.privTurnMap.set(e,t),this.privTurnMap.get(e)}GetTurn(e){return this.privTurnMap.get(e)}CompleteTurn(e){if(!this.privTurnMap.has(e))throw new DP.InvalidOperationError("Service error: Received turn end for an unknown turn id:"+e);let t=this.privTurnMap.get(e);return t.complete(),this.privTurnMap.delete(e),t}};Kc.DialogServiceTurnStateManager=Tv});var NP=p(Gc=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});Gc.DialogServiceAdapter=void 0;var Rb=pe(),Eb=Su(),Ae=P(),Ib=ui(),D=f(),wb=kP(),Mt=C(),_b=wv(),Jc=Jr(),Av=class extends Mt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privEvents=new Ae.EventSource,this.privDialogServiceConnector=s,this.receiveMessageOverride=()=>this.receiveDialogMessageOverride(),this.privTurnStateManager=new wb.DialogServiceTurnStateManager,this.recognizeOverride=(o,a,c)=>this.listenOnce(o,a,c),this.postConnectImplOverride=o=>this.dialogConnectImpl(o),this.configConnectionOverride=o=>this.configConnection(o),this.disconnectOverride=()=>this.privDisconnect(),this.privDialogAudioSource=r,this.agentConfigSent=!1,this.privLastResult=null,this.connectionEvents.attach(o=>{o.name==="ConnectionClosedEvent"&&(this.terminateMessageLoop=!0)})}async sendMessage(e){let t=Ae.createGuid(),r=Ae.createNoDashGuid(),n={context:{interactionId:t},messagePayload:JSON.parse(e),version:.5},s=JSON.stringify(n);await(await this.fetchConnection()).send(new Jc.SpeechConnectionMessage(Ae.MessageType.Text,"agent",r,"application/json",s))}async privDisconnect(){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,D.CancellationReason.Error,D.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.agentConfigSent=!1}processTypeSpecificMessages(e){let t=new D.PropertyCollection;e.messageType===Ae.MessageType.Text&&t.setProperty(D.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let r,n;switch(e.path.toLowerCase()){case"speech.phrase":let o=Mt.SimpleSpeechPhrase.fromJSON(e.textBody);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus!==Mt.RecognitionStatus.TooManyRequests&&o.RecognitionStatus!==Mt.RecognitionStatus.Error){let v=this.fireEventForResult(o,t);if(this.privLastResult=v.result,this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,v)}catch{}}n=!0;break;case"speech.hypothesis":let a=Mt.SpeechHypothesis.fromJSON(e.textBody),c=a.Offset+this.privRequestSession.currentTurnAudioOffset;r=new D.SpeechRecognitionResult(this.privRequestSession.requestId,D.ResultReason.RecognizingSpeech,a.Text,a.Duration,c,a.Language,a.LanguageDetectionConfidence,void 0,void 0,e.textBody,t),this.privRequestSession.onHypothesis(c);let u=new D.SpeechRecognitionEventArgs(r,a.Duration,this.privRequestSession.sessionId);if(this.privDialogServiceConnector.recognizing)try{this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector,u)}catch{}n=!0;break;case"speech.keyword":let h=Mt.SpeechKeyword.fromJSON(e.textBody);r=new D.SpeechRecognitionResult(this.privRequestSession.requestId,h.Status==="Accepted"?D.ResultReason.RecognizedKeyword:D.ResultReason.NoMatch,h.Text,h.Duration,h.Offset,void 0,void 0,void 0,void 0,e.textBody,t),h.Status!=="Accepted"&&(this.privLastResult=r);let d=new D.SpeechRecognitionEventArgs(r,r.duration,r.resultId);if(this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,d)}catch{}n=!0;break;case"audio":{let v=e.requestId.toUpperCase(),g=this.privTurnStateManager.GetTurn(v);try{e.binaryBody?g.audioStream.write(e.binaryBody):g.endAudioStream()}catch{}}n=!0;break;case"response":this.handleResponseMessage(e),n=!0;break;default:break}let s=new Ae.Deferred;return s.resolve(n),s.promise}async cancelRecognition(e,t,r,n,s){if(this.terminateMessageLoop=!0,this.privRequestSession.isRecognizing&&await this.privRequestSession.onStopRecognizing(),this.privDialogServiceConnector.canceled){let o=new D.PropertyCollection;o.setProperty(Mt.CancellationErrorCodePropertyName,D.CancellationErrorCode[n]);let a=new D.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privDialogServiceConnector.canceled(this.privDialogServiceConnector,a)}catch{}if(this.privSuccessCallback){let c=new D.SpeechRecognitionResult(void 0,D.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(c),this.privSuccessCallback=void 0}catch{}}}}async listenOnce(e,t,r){this.privRecognizerConfig.recognitionMode=e,this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privDialogAudioSource.events),this.privRecognizerConfig.parameters.setProperty(D.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let n=this.connectImpl(),s=this.sendPreAudioMessages(),o=await this.privDialogAudioSource.attach(this.privRequestSession.audioNodeId),a=await this.privDialogAudioSource.format,c=await this.privDialogAudioSource.deviceInfo,u=new Rb.ReplayableAudioNode(o,a.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(u,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:c};try{await n,await s}catch(v){return await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,D.CancellationReason.Error,D.CancellationErrorCode.ConnectionFailure,v),Promise.resolve()}let h=new D.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,h),this.sendAudio(u).then(()=>{},async v=>{await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,D.CancellationReason.Error,D.CancellationErrorCode.RuntimeError,v)})}dialogConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}receiveDialogMessageOverride(){let e=new Ae.Deferred,t=async()=>{try{let r=this.isDisposed(),n=!this.isDisposed()&&this.terminateMessageLoop;if(r||n){e.resolve(void 0);return}let o=await(await this.fetchConnection()).read();if(!o)return t();let a=Jc.SpeechConnectionMessage.fromConnectionMessage(o);switch(a.path.toLowerCase()){case"turn.start":{let w=a.requestId.toUpperCase(),k=this.privRequestSession.requestId.toUpperCase();w!==k?this.privTurnStateManager.StartTurn(w):this.privRequestSession.onServiceTurnStartResponse()}break;case"speech.startdetected":let u=Mt.SpeechDetected.fromJSON(a.textBody),h=new D.RecognitionEventArgs(u.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,h);break;case"speech.enddetected":let d;a.textBody.length>0?d=a.textBody:d="{ Offset: 0 }";let v=Mt.SpeechDetected.fromJSON(d);this.privRequestSession.onServiceRecognized(v.Offset+this.privRequestSession.currentTurnAudioOffset);let g=new D.RecognitionEventArgs(v.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,g);break;case"turn.end":{let w=a.requestId.toUpperCase(),k=this.privRequestSession.requestId.toUpperCase();if(w!==k)this.privTurnStateManager.CompleteTurn(w);else{let ae=new D.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(!1),(!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing)&&this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,ae),this.privSuccessCallback&&this.privLastResult){try{this.privSuccessCallback(this.privLastResult),this.privLastResult=null}catch(Z){this.privErrorCallback&&this.privErrorCallback(Z)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}}break;default:try{await this.processTypeSpecificMessages(a)||this.serviceEvents&&this.serviceEvents.onEvent(new Ae.ServiceEvent(a.path.toLowerCase(),a.textBody))}catch{}}return t()}catch{this.terminateMessageLoop=!0,e.resolve()}};return t().catch(r=>{Ae.Events.instance.onEvent(new Ae.BackgroundEvent(r))}),e.promise}async startMessageLoop(){this.terminateMessageLoop=!1;try{await this.receiveDialogMessageOverride()}catch(e){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,D.CancellationReason.Error,D.CancellationErrorCode.RuntimeError,e)}return Promise.resolve()}async configConnection(e){return this.terminateMessageLoop?(this.terminateMessageLoop=!1,Promise.reject("Connection to service terminated.")):(await this.sendSpeechServiceConfig(e,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendAgentConfig(e),e)}async sendPreAudioMessages(){let e=await this.fetchConnection();this.addKeywordContextData(),await this.sendSpeechContext(e,!0),await this.sendAgentContext(e),await this.sendWaveHeader(e)}sendAgentConfig(e){if(this.agentConfig&&!this.agentConfigSent){if(this.privRecognizerConfig.parameters.getProperty(D.PropertyId.Conversation_DialogType)===D.DialogServiceConfig.DialogTypes.CustomCommands){let r=this.agentConfig.get();r.botInfo.commandsCulture=this.privRecognizerConfig.parameters.getProperty(D.PropertyId.SpeechServiceConnection_RecoLanguage,"en-us"),this.agentConfig.set(r)}this.onEvent(new Eb.SendingAgentContextMessageEvent(this.agentConfig));let t=this.agentConfig.toJsonString();return this.agentConfigSent=!0,e.send(new Jc.SpeechConnectionMessage(Ae.MessageType.Text,"agent.config",this.privRequestSession.requestId,"application/json",t))}}sendAgentContext(e){let t=Ae.createGuid(),r=this.privDialogServiceConnector.properties.getProperty(D.PropertyId.Conversation_Speech_Activity_Template),s=JSON.stringify({channelData:"",context:{interactionId:t},messagePayload:typeof r===void 0?void 0:r,version:.5});return e.send(new Jc.SpeechConnectionMessage(Ae.MessageType.Text,"speech.agent.context",this.privRequestSession.requestId,"application/json",s))}fireEventForResult(e,t){let r=Mt.EnumTranslation.implTranslateRecognitionResult(e.RecognitionStatus),n=e.Offset+this.privRequestSession.currentTurnAudioOffset,s=new D.SpeechRecognitionResult(this.privRequestSession.requestId,r,e.DisplayText,e.Duration,n,e.Language,e.LanguageDetectionConfidence,void 0,void 0,JSON.stringify(e),t);return new D.SpeechRecognitionEventArgs(s,n,this.privRequestSession.sessionId)}handleResponseMessage(e){let t=JSON.parse(e.textBody);switch(t.messageType.toLowerCase()){case"message":let r=e.requestId.toUpperCase(),n=_b.ActivityPayloadResponse.fromJSON(e.textBody),s=this.privTurnStateManager.GetTurn(r);if(n.conversationId){let c=this.agentConfig.get();c.botInfo.conversationId=n.conversationId,this.agentConfig.set(c)}let o=s.processActivityPayload(n,Ib.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(D.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0))),a=new D.ActivityReceivedEventArgs(n.messagePayload,o);if(this.privDialogServiceConnector.activityReceived)try{this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector,a)}catch{}break;case"messagestatus":if(this.privDialogServiceConnector.turnStatusReceived)try{this.privDialogServiceConnector.turnStatusReceived(this.privDialogServiceConnector,new D.TurnStatusReceivedEventArgs(e.textBody))}catch{}break;default:Ae.Events.instance.onEvent(new Ae.BackgroundEvent(`Unexpected response of type ${t.messageType}. Ignoring.`));break}}onEvent(e){this.privEvents.onEvent(e),Ae.Events.instance.onEvent(e)}addKeywordContextData(){let e=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect");if(e===void 0)return;let t=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Offsets"),r=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Durations"),n=e.split(";"),s=t===void 0?[]:t.split(";"),o=r===void 0?[]:r.split(";"),a=[];for(let c=0;c<n.length;c++){let u={};u.text=n[c],c<s.length&&(u.offset=Number(s[c])),c<o.length&&(u.duration=Number(o[c])),a.push(u)}this.speechContext.setSection("invocationSource","VoiceActivationWithKeyword"),this.speechContext.setSection("keywordDetection",[{clientDetectedKeywords:a,onReject:{action:"EndOfTurn"},type:"startTrigger"}])}};Gc.DialogServiceAdapter=Av});var qP=p($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.AgentConfig=void 0;var bv=class{toJsonString(){return JSON.stringify(this.iPrivConfig)}get(){return this.iPrivConfig}set(e){this.iPrivConfig=e}};$c.AgentConfig=bv});var Yc=p(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});Qc.ConversationConnectionConfig=void 0;var Tb=jl(),Dt=class i extends Tb.RestConfigBase{static get host(){return i.privHost}static get apiVersion(){return i.privApiVersion}static get clientAppId(){return i.privClientAppId}static get defaultLanguageCode(){return i.privDefaultLanguageCode}static get restPath(){return i.privRestPath}static get webSocketPath(){return i.privWebSocketPath}static get transcriptionEventKeys(){return i.privTranscriptionEventKeys}};Qc.ConversationConnectionConfig=Dt;Dt.privHost="dev.microsofttranslator.com";Dt.privRestPath="/capito/room";Dt.privApiVersion="2.0";Dt.privDefaultLanguageCode="en-US";Dt.privClientAppId="FC539C22-1767-4F1F-84BC-B4D811114F15";Dt.privWebSocketPath="/capito/translate";Dt.privTranscriptionEventKeys=["iCalUid","callId","organizer","FLAC","MTUri","DifferentiateGuestSpeakers","audiorecording","Threadid","OrganizerMri","OrganizerTenantId","UserToken"]});var xP=p(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.ConversationManager=void 0;var Xc=pe(),mr=I(),Yt=f(),Qr=Yc(),Ov=class{constructor(){this.privRequestParams=Qr.ConversationConnectionConfig.configParams,this.privErrors=Qr.ConversationConnectionConfig.restErrors,this.privHost=Qr.ConversationConnectionConfig.host,this.privApiVersion=Qr.ConversationConnectionConfig.apiVersion,this.privRestPath=Qr.ConversationConnectionConfig.restPath,this.privRestAdapter=new Xc.RestMessageAdapter({})}createOrJoin(e,t,r,n){try{mr.Contracts.throwIfNullOrUndefined(e,"args");let s=e.getProperty(Yt.PropertyId.SpeechServiceConnection_RecoLanguage,Qr.ConversationConnectionConfig.defaultLanguageCode),o=e.getProperty(Yt.PropertyId.ConversationTranslator_Name,"conversation_host"),a=e.getProperty(Yt.PropertyId.ConversationTranslator_Host,this.privHost),c=e.getProperty(Yt.PropertyId.ConversationTranslator_CorrelationId),u=e.getProperty(Yt.PropertyId.SpeechServiceConnection_Key),h=e.getProperty(Yt.PropertyId.SpeechServiceConnection_Region),d=e.getProperty(Yt.PropertyId.SpeechServiceAuthorization_Token);mr.Contracts.throwIfNullOrWhitespace(s,"languageCode"),mr.Contracts.throwIfNullOrWhitespace(o,"nickname"),mr.Contracts.throwIfNullOrWhitespace(a,"endpointHost");let v={};v[this.privRequestParams.apiVersion]=this.privApiVersion,v[this.privRequestParams.languageCode]=s,v[this.privRequestParams.nickname]=o;let g={};c&&(g[this.privRequestParams.correlationId]=c),g[this.privRequestParams.clientAppId]=Qr.ConversationConnectionConfig.clientAppId,t!==void 0?v[this.privRequestParams.roomId]=t:(mr.Contracts.throwIfNullOrUndefined(h,this.privErrors.authInvalidSubscriptionRegion),g[this.privRequestParams.subscriptionRegion]=h,u?g[this.privRequestParams.subscriptionKey]=u:d?g[this.privRequestParams.authorization]=`Bearer ${d}`:mr.Contracts.throwIfNullOrUndefined(u,this.privErrors.authInvalidSubscriptionKey));let w={};w.headers=g,this.privRestAdapter.options=w;let k=`https://${a}${this.privRestPath}`;this.privRestAdapter.request(Xc.RestRequestType.Post,k,v,null).then(ae=>{let Z=Xc.RestMessageAdapter.extractHeaderValue(this.privRequestParams.requestId,ae.headers);if(!ae.ok){if(n){let Oe=this.privErrors.invalidCreateJoinConversationResponse.replace("{status}",ae.status.toString()),F;try{F=JSON.parse(ae.data),Oe+=` [${F.error.code}: ${F.error.message}]`}catch{Oe+=` [${ae.data}]`}Z&&(Oe+=` ${Z}`),n(Oe)}return}let U=JSON.parse(ae.data);if(U&&(U.requestId=Z),r){try{r(U)}catch(Oe){n&&n(Oe)}r=void 0}}).catch(()=>{})}catch(s){if(n)if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}}leave(e,t){return new Promise((r,n)=>{try{mr.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","config")),mr.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","token"));let s=e.getProperty(Yt.PropertyId.ConversationTranslator_Host,this.privHost),o=e.getProperty(Yt.PropertyId.ConversationTranslator_CorrelationId),a={};a[this.privRequestParams.apiVersion]=this.privApiVersion,a[this.privRequestParams.sessionToken]=t;let c={};o&&(c[this.privRequestParams.correlationId]=o);let u={};u.headers=c,this.privRestAdapter.options=u;let h=`https://${s}${this.privRestPath}`;this.privRestAdapter.request(Xc.RestRequestType.Delete,h,a,null).then(d=>{d.ok,r()}).catch(()=>{})}catch(s){if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}})}};Zc.ConversationManager=Ov});var Dv=p(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});ep.ConversationConnectionMessage=void 0;var Ab=P(),Mv=class extends Ab.ConnectionMessage{constructor(e,t,r,n){super(e,t,r,n);let s=JSON.parse(this.textBody);s.type!==void 0&&(this.privConversationMessageType=s.type)}get conversationMessageType(){return this.privConversationMessageType}};ep.ConversationConnectionMessage=Mv});var jP=p(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});tp.ConversationWebsocketMessageFormatter=void 0;var Yr=P(),zP=Dv(),kv=class{toConnectionMessage(e){let t=new Yr.Deferred;try{if(e.messageType===Yr.MessageType.Text){let r=new zP.ConversationConnectionMessage(e.messageType,e.textContent,{},e.id);t.resolve(r)}else e.messageType===Yr.MessageType.Binary&&t.resolve(new zP.ConversationConnectionMessage(e.messageType,e.binaryContent,void 0,e.id))}catch(r){t.reject(`Error formatting the message. Error: ${r}`)}return t.promise}fromConnectionMessage(e){let t=new Yr.Deferred;try{if(e.messageType===Yr.MessageType.Text){let r=`${e.textBody?e.textBody:""}`;t.resolve(new Yr.RawWebsocketMessage(Yr.MessageType.Text,r,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}};tp.ConversationWebsocketMessageFormatter=kv});var BP=p(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.ConversationConnectionFactory=void 0;var LP=pe(),bb=P(),Ob=I(),Nv=f(),Mb=Ye(),qi=Yc(),Db=jP(),qv=class extends Mb.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Nv.PropertyId.ConversationTranslator_Host,qi.ConversationConnectionConfig.host),s=e.parameters.getProperty(Nv.PropertyId.ConversationTranslator_CorrelationId,bb.createGuid()),o=`wss://${n}${qi.ConversationConnectionConfig.webSocketPath}`,a=e.parameters.getProperty(Nv.PropertyId.ConversationTranslator_Token,void 0);Ob.Contracts.throwIfNullOrUndefined(a,"token");let c={};c[qi.ConversationConnectionConfig.configParams.apiVersion]=qi.ConversationConnectionConfig.apiVersion,c[qi.ConversationConnectionConfig.configParams.token]=a,c[qi.ConversationConnectionConfig.configParams.correlationId]=s;let u=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new LP.WebsocketConnection(o,c,{},new Db.ConversationWebsocketMessageFormatter,LP.ProxyInfo.fromRecognizerConfig(e),u,r)}};rp.ConversationConnectionFactory=qv});var FP=p(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});ip.ConversationRequestSession=void 0;var xv=P(),zv=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privSessionId=e,this.privRequestId=xv.createNoDashGuid(),this.privRequestCompletionDeferral=new xv.Deferred}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get completionPromise(){return this.privRequestCompletionDeferral.promise}onPreConnectionStart(e,t){this.privSessionId=t}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){e!==200&&e===403&&this.onComplete()}onServiceTurnEndResponse(e){e?this.privRequestId=xv.createNoDashGuid():this.onComplete()}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach()}}onComplete(){}};ip.ConversationRequestSession=zv});var Wv=p(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.ConversationReceivedTranslationEventArgs=Fe.ParticipantsListEventArgs=Fe.ParticipantAttributeEventArgs=Fe.ParticipantEventArgs=Fe.LockRoomEventArgs=Fe.MuteAllEventArgs=void 0;var Hn=f(),jv=class extends Hn.SessionEventArgs{constructor(e,t){super(t),this.privIsMuted=e}get isMuted(){return this.privIsMuted}};Fe.MuteAllEventArgs=jv;var Lv=class extends Hn.SessionEventArgs{constructor(e,t){super(t),this.privIsLocked=e}get isMuted(){return this.privIsLocked}};Fe.LockRoomEventArgs=Lv;var Bv=class extends Hn.SessionEventArgs{constructor(e,t){super(t),this.privParticipant=e}get participant(){return this.privParticipant}};Fe.ParticipantEventArgs=Bv;var Fv=class extends Hn.SessionEventArgs{constructor(e,t,r,n){super(n),this.privKey=t,this.privValue=r,this.privParticipantId=e}get value(){return this.privValue}get key(){return this.privKey}get id(){return this.privParticipantId}};Fe.ParticipantAttributeEventArgs=Fv;var Vv=class extends Hn.SessionEventArgs{constructor(e,t,r,n,s,o,a,c,u){super(u),this.privRoomId=e,this.privSessionToken=t,this.privTranslateTo=r,this.privProfanityFilter=n,this.privRoomProfanityFilter=s,this.privIsRoomLocked=o,this.privIsRoomLocked=a,this.privParticipants=c}get sessionToken(){return this.privSessionToken}get conversationId(){return this.privRoomId}get translateTo(){return this.privTranslateTo}get profanityFilter(){return this.privProfanityFilter}get roomProfanityFilter(){return this.privRoomProfanityFilter}get isRoomLocked(){return this.privIsRoomLocked}get isMuteAll(){return this.privIsMuteAll}get participants(){return this.privParticipants}};Fe.ParticipantsListEventArgs=Vv;var Uv=class{constructor(e,t,r){this.privPayload=t,this.privCommand=e,this.privSessionId=r}get payload(){return this.privPayload}get command(){return this.privCommand}get sessionId(){return this.privSessionId}};Fe.ConversationReceivedTranslationEventArgs=Uv});var Kv=p(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.ConversationTranslatorCommandTypes=Sr.ConversationTranslatorMessageTypes=Sr.InternalParticipants=void 0;var Hv=class{constructor(e=[],t){this.participants=e,this.meId=t}addOrUpdateParticipant(e){if(e===void 0)return;let t=this.getParticipantIndex(e.id);return t>-1?this.participants.splice(t,1,e):this.participants.push(e),this.getParticipant(e.id)}getParticipantIndex(e){return this.participants.findIndex(t=>t.id===e)}getParticipant(e){return this.participants.find(t=>t.id===e)}deleteParticipant(e){this.participants=this.participants.filter(t=>t.id!==e)}get host(){return this.participants.find(e=>e.isHost===!0)}get me(){return this.getParticipant(this.meId)}};Sr.InternalParticipants=Hv;Sr.ConversationTranslatorMessageTypes={command:"command",final:"final",info:"info",instantMessage:"instant_message",keepAlive:"keep_alive",partial:"partial",participantCommand:"participant_command",translatedMessage:"translated_message"};Sr.ConversationTranslatorCommandTypes={changeNickname:"ChangeNickname",disconnectSession:"DisconnectSession",ejectParticipant:"EjectParticipant",instant_message:"instant_message",joinSession:"JoinSession",leaveSession:"LeaveSession",participantList:"ParticipantList",roomExpirationWarning:"RoomExpirationWarning",setLockState:"SetLockState",setMute:"SetMute",setMuteAll:"SetMuteAll",setProfanityFiltering:"SetProfanityFiltering",setTranslateToLanguages:"SetTranslateToLanguages",setUseTTS:"SetUseTTS"}});var VP=p(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});np.CommandResponsePayload=void 0;var kb=i=>JSON.parse(i),Jv=class i{constructor(e){this.privCommandResponse=kb(e)}get type(){return this.privCommandResponse.type}get command(){return this.privCommandResponse.command}get id(){return this.privCommandResponse.id}get nickname(){return this.privCommandResponse.nickname}get participantId(){return this.privCommandResponse.participantId}get roomid(){return this.privCommandResponse.roomid}get value(){return this.privCommandResponse.value}get token(){return this.privCommandResponse.token}static fromJSON(e){return new i(e)}};np.CommandResponsePayload=Jv});var UP=p(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.ParticipantPayloadResponse=xi.ParticipantsListPayloadResponse=void 0;var Nb=i=>JSON.parse(i),qb=i=>JSON.parse(i),Gv=class i{constructor(e){this.privParticipantsPayloadResponse=Nb(e)}get roomid(){return this.privParticipantsPayloadResponse.roomid}get id(){return this.privParticipantsPayloadResponse.id}get command(){return this.privParticipantsPayloadResponse.command}get participants(){return this.privParticipantsPayloadResponse.participants}get token(){return this.privParticipantsPayloadResponse.token}get translateTo(){return this.privParticipantsPayloadResponse.translateTo}get profanityFilter(){return this.privParticipantsPayloadResponse.profanityFilter}get roomProfanityFilter(){return this.privParticipantsPayloadResponse.roomProfanityFilter}get roomLocked(){return this.privParticipantsPayloadResponse.roomLocked}get muteAll(){return this.privParticipantsPayloadResponse.muteAll}get type(){return this.privParticipantsPayloadResponse.type}static fromJSON(e){return new i(e)}};xi.ParticipantsListPayloadResponse=Gv;var $v=class i{constructor(e){this.privParticipantPayloadResponse=qb(e)}get nickname(){return this.privParticipantPayloadResponse.nickname}get locale(){return this.privParticipantPayloadResponse.locale}get usetts(){return this.privParticipantPayloadResponse.usetts}get ismuted(){return this.privParticipantPayloadResponse.ismuted}get ishost(){return this.privParticipantPayloadResponse.ishost}get participantId(){return this.privParticipantPayloadResponse.participantId}get avatar(){return this.privParticipantPayloadResponse.avatar}static fromJSON(e){return new i(e)}};xi.ParticipantPayloadResponse=$v});var WP=p(zi=>{"use strict";Object.defineProperty(zi,"__esModule",{value:!0});zi.TextResponsePayload=zi.SpeechResponsePayload=void 0;var xb=i=>JSON.parse(i),zb=i=>JSON.parse(i),Qv=class i{constructor(e){this.privSpeechResponse=xb(e)}get recognition(){return this.privSpeechResponse.recognition}get translations(){return this.privSpeechResponse.translations}get id(){return this.privSpeechResponse.id}get language(){return this.privSpeechResponse.language}get nickname(){return this.privSpeechResponse.nickname}get participantId(){return this.privSpeechResponse.participantId}get roomid(){return this.privSpeechResponse.roomid}get timestamp(){return this.privSpeechResponse.timestamp}get type(){return this.privSpeechResponse.type}get isFinal(){return this.privSpeechResponse.type==="final"}static fromJSON(e){return new i(e)}};zi.SpeechResponsePayload=Qv;var Yv=class i{constructor(e){this.privTextResponse=zb(e)}get originalText(){return this.privTextResponse.originalText}get translations(){return this.privTextResponse.translations}get id(){return this.privTextResponse.id}get language(){return this.privTextResponse.language}get nickname(){return this.privTextResponse.nickname}get participantId(){return this.privTextResponse.participantId}get roomid(){return this.privTextResponse.roomid}get timestamp(){return this.privTextResponse.timestamp}get type(){return this.privTextResponse.type}static fromJSON(e){return new i(e)}};zi.TextResponsePayload=Yv});var JP=p(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});var jb=VP();Object.defineProperty(Xr,"CommandResponsePayload",{enumerable:!0,get:function(){return jb.CommandResponsePayload}});var HP=UP();Object.defineProperty(Xr,"ParticipantsListPayloadResponse",{enumerable:!0,get:function(){return HP.ParticipantsListPayloadResponse}});Object.defineProperty(Xr,"ParticipantPayloadResponse",{enumerable:!0,get:function(){return HP.ParticipantPayloadResponse}});var KP=WP();Object.defineProperty(Xr,"SpeechResponsePayload",{enumerable:!0,get:function(){return KP.SpeechResponsePayload}});Object.defineProperty(Xr,"TextResponsePayload",{enumerable:!0,get:function(){return KP.TextResponsePayload}})});var QP=p(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});sp.ConversationServiceAdapter=void 0;var Kn=P(),St=f(),GP=C(),$P=Dv(),Lb=FP(),Ke=Wv(),yr=Kv(),Jn=JP(),Xv=class extends GP.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privConnectionConfigPromise=void 0,this.privLastPartialUtteranceId="",this.privConversationServiceConnector=s,this.privConversationAuthentication=e,this.receiveMessageOverride=()=>this.receiveConversationMessageOverride(),this.recognizeOverride=()=>this.noOp(),this.postConnectImplOverride=o=>this.conversationConnectImpl(o),this.configConnectionOverride=()=>this.configConnection(),this.disconnectOverride=()=>this.privDisconnect(),this.privConversationRequestSession=new Lb.ConversationRequestSession(Kn.createNoDashGuid()),this.privConversationConnectionFactory=t,this.privConversationIsDisposed=!1}isDisposed(){return super.isDisposed()||this.privConversationIsDisposed}async dispose(e){this.privConversationIsDisposed=!0,this.privConnectionConfigPromise!==void 0&&await(await this.privConnectionConfigPromise).dispose(e),await super.dispose(e)}async sendMessage(e){return(await this.fetchConnection()).send(new $P.ConversationConnectionMessage(Kn.MessageType.Text,e))}async sendMessageAsync(e){await(await this.fetchConnection()).send(new $P.ConversationConnectionMessage(Kn.MessageType.Text,e))}privDisconnect(){if(!this.terminateMessageLoop)return this.cancelRecognition(this.privConversationRequestSession.sessionId,this.privConversationRequestSession.requestId,St.CancellationReason.Error,St.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,Promise.resolve()}async processTypeSpecificMessages(){return!0}cancelRecognition(e,t,r,n,s){this.terminateMessageLoop=!0;let o=new St.ConversationTranslationCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationServiceConnector.canceled&&this.privConversationServiceConnector.canceled(this.privConversationServiceConnector,o)}catch{}}async conversationConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}async receiveConversationMessageOverride(){if(this.isDisposed()||this.terminateMessageLoop)return Promise.resolve();let e=new Kn.Deferred;try{let r=await(await this.fetchConnection()).read();if(this.isDisposed()||this.terminateMessageLoop)return e.resolve(),Promise.resolve();if(!r)return this.receiveConversationMessageOverride();let n=this.privConversationRequestSession.sessionId,s=r.conversationMessageType.toLowerCase(),o=!1;try{switch(s){case"info":case"participant_command":case"command":let a=Jn.CommandResponsePayload.fromJSON(r.textBody);switch(a.command.toLowerCase()){case"participantlist":let g=Jn.ParticipantsListPayloadResponse.fromJSON(r.textBody),w=g.participants.map(F=>({avatar:F.avatar,displayName:F.nickname,id:F.participantId,isHost:F.ishost,isMuted:F.ismuted,isUsingTts:F.usetts,preferredLanguage:F.locale}));this.privConversationServiceConnector.participantsListReceived&&this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector,new Ke.ParticipantsListEventArgs(g.roomid,g.token,g.translateTo,g.profanityFilter,g.roomProfanityFilter,g.roomLocked,g.muteAll,w,n));break;case"settranslatetolanguages":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.setTranslateToLanguages,a.value,n));break;case"setprofanityfiltering":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.setProfanityFiltering,a.value,n));break;case"setmute":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.setMute,a.value,n));break;case"setmuteall":this.privConversationServiceConnector.muteAllCommandReceived&&this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector,new Ke.MuteAllEventArgs(a.value,n));break;case"roomexpirationwarning":this.privConversationServiceConnector.conversationExpiration&&this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector,new St.ConversationExpirationEventArgs(a.value,this.privConversationRequestSession.sessionId));break;case"setusetts":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.setUseTTS,a.value,n));break;case"setlockstate":this.privConversationServiceConnector.lockRoomCommandReceived&&this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector,new Ke.LockRoomEventArgs(a.value,n));break;case"changenickname":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,yr.ConversationTranslatorCommandTypes.changeNickname,a.value,n));break;case"joinsession":let k=Jn.ParticipantPayloadResponse.fromJSON(r.textBody),ae={avatar:k.avatar,displayName:k.nickname,id:k.participantId,isHost:k.ishost,isMuted:k.ismuted,isUsingTts:k.usetts,preferredLanguage:k.locale};this.privConversationServiceConnector.participantJoinCommandReceived&&this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantEventArgs(ae,n));break;case"leavesession":let Z={id:a.participantId};this.privConversationServiceConnector.participantLeaveCommandReceived&&this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantEventArgs(Z,n));break;case"disconnectsession":let U={id:a.participantId};break;case"token":let Oe=new GP.CognitiveTokenAuthentication(()=>{let F=a.token;return Promise.resolve(F)},()=>{let F=a.token;return Promise.resolve(F)});this.authentication=Oe,this.privConversationServiceConnector.onToken(Oe);break;default:break}break;case"partial":case"final":let c=Jn.SpeechResponsePayload.fromJSON(r.textBody),u=s==="final"?St.ResultReason.TranslatedParticipantSpeech:St.ResultReason.TranslatingParticipantSpeech,h=new St.ConversationTranslationResult(c.participantId,this.getTranslations(c.translations),c.language,c.id,u,c.recognition,void 0,void 0,r.textBody,void 0);c.isFinal?((h.text!==void 0&&h.text.length>0||c.id===this.privLastPartialUtteranceId)&&(o=!0),o&&this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ke.ConversationReceivedTranslationEventArgs(yr.ConversationTranslatorMessageTypes.final,h,n))):h.text!==void 0&&(this.privLastPartialUtteranceId=c.id,this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ke.ConversationReceivedTranslationEventArgs(yr.ConversationTranslatorMessageTypes.partial,h,n)));break;case"translated_message":let d=Jn.TextResponsePayload.fromJSON(r.textBody),v=new St.ConversationTranslationResult(d.participantId,this.getTranslations(d.translations),d.language,void 0,void 0,d.originalText,void 0,void 0,void 0,r.textBody,void 0);this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ke.ConversationReceivedTranslationEventArgs(yr.ConversationTranslatorMessageTypes.instantMessage,v,n));break;default:break}}catch{}return this.receiveConversationMessageOverride()}catch{this.terminateMessageLoop=!0}return e.promise}async startMessageLoop(){if(this.isDisposed())return Promise.resolve();this.terminateMessageLoop=!1;let e=this.receiveConversationMessageOverride();try{return await e}catch(t){return this.cancelRecognition(this.privRequestSession?this.privRequestSession.sessionId:"",this.privRequestSession?this.privRequestSession.requestId:"",St.CancellationReason.Error,St.CancellationErrorCode.RuntimeError,t),null}}configConnection(){return this.isDisposed()?Promise.resolve(void 0):this.privConnectionConfigPromise!==void 0?this.privConnectionConfigPromise.then(e=>e.state()===Kn.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection()):this.privConnectionConfigPromise,()=>(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection())):this.terminateMessageLoop?Promise.resolve(void 0):(this.privConnectionConfigPromise=this.connectImpl().then(e=>e),this.privConnectionConfigPromise)}getTranslations(e){let t;if(e!==void 0){t=new St.Translations;for(let r of e)t.set(r.lang,r.translation)}return t}};sp.ConversationServiceAdapter=Xv});var YP=p(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.ConversationTranslatorRecognizer=Bi.ConversationRecognizerFactory=void 0;var Bb=C(),ji=P(),Li=I(),Zv=f(),Fb=BP(),Vb=QP(),ef=class{static fromConfig(e,t,r){return new op(e,t,r)}};Bi.ConversationRecognizerFactory=ef;var op=class extends Zv.Recognizer{constructor(e,t,r){let n=t;Li.Contracts.throwIfNull(n,"speechConfig");let s=e;Li.Contracts.throwIfNull(s,"conversationImpl"),super(r,n.properties,new Fb.ConversationConnectionFactory),this.privConversation=s,this.privIsDisposed=!1,this.privProperties=n.properties.clone(),this.privConnection=Zv.Connection.fromRecognizer(this),this.privProperties.getProperty(Zv.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?(this.privSetTimeout=ji.Timeout.setTimeout,this.privClearTimeout=ji.Timeout.clearTimeout):typeof window<"u"?(this.privSetTimeout=window.setTimeout.bind(window),this.privClearTimeout=window.clearTimeout.bind(window)):(this.privSetTimeout=setTimeout,this.privClearTimeout=clearTimeout)}set connected(e){this.privConnection.connected=e}set disconnected(e){this.privConnection.disconnected=e}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get properties(){return this.privProperties}isDisposed(){return this.privIsDisposed}connect(e,t,r){try{Li.Contracts.throwIfDisposed(this.privIsDisposed),Li.Contracts.throwIfNullOrWhitespace(e,"token"),this.privReco.conversationTranslatorToken=e,this.resetConversationTimeout(),this.privReco.connectAsync(t,r)}catch(n){if(r)if(n instanceof Error){let s=n;r(s.name+": "+s.message)}else r(n)}}disconnect(e,t){try{Li.Contracts.throwIfDisposed(this.privIsDisposed),this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privReco.disconnect().then(()=>{e&&e()},r=>{t&&t(r)})}catch(r){if(t)if(r instanceof Error){let n=r;t(n.name+": "+n.message)}else t(r);this.dispose(!0).catch(n=>{ji.Events.instance.onEvent(new ji.BackgroundEvent(n))})}}sendRequest(e,t,r){try{Li.Contracts.throwIfDisposed(this.privIsDisposed),this.sendMessage(e,t,r)}catch(n){if(r)if(n instanceof Error){let s=n;r(s.name+": "+s.message)}else r(n);this.dispose(!0).catch(s=>{ji.Events.instance.onEvent(new ji.BackgroundEvent(s))})}}onToken(e){this.privConversation.onToken(e)}async close(){this.privIsDisposed||(this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close()),this.privConnection=void 0,await this.dispose(!0))}async dispose(e){this.privIsDisposed||e&&(this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privIsDisposed=!0,this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close(),this.privConnection=void 0),await super.dispose(e))}createRecognizerConfig(e){return new Bb.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Vb.ConversationServiceAdapter(e,t,s,n,this)}sendMessage(e,t,r){let n=this.privReco;((o,a,c)=>{o!==void 0?o.then(()=>{try{a&&a()}catch(u){c&&c(`'Unhandled error on promise callback: ${u}'`)}},u=>{try{c&&c(u)}catch{}}):c&&c("Null promise")})(n.sendMessageAsync(e),t,r),this.resetConversationTimeout()}resetConversationTimeout(){this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privTimeoutToken=this.privSetTimeout(()=>{this.sendRequest(this.privConversation.getKeepAlive())},6e4)}};Bi.ConversationTranslatorRecognizer=op});var ZP=p(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});cp.TranscriberRecognizer=void 0;var XP=P(),yt=I(),Fi=f(),ap=C(),tf=class extends Fi.Recognizer{constructor(e,t){let r=e;yt.Contracts.throwIfNull(r,"speechTranslationConfig");let n=t;yt.Contracts.throwIfNull(n,"audioConfigImpl"),yt.Contracts.throwIfNullOrWhitespace(r.speechRecognitionLanguage,Fi.PropertyId[Fi.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new ap.TranscriberConnectionFactory),this.privDisposedRecognizer=!1,this.isMeetingRecognizer=!1}get speechRecognitionLanguage(){return yt.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Fi.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Fi.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){yt.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Fi.PropertyId.SpeechServiceAuthorization_Token,e)}set conversation(e){yt.Contracts.throwIfNullOrUndefined(e,"Conversation"),this.isMeetingRecognizer=!1,this.privConversation=e}getConversationInfo(){return yt.Contracts.throwIfNullOrUndefined(this.privConversation,"Conversation"),this.privConversation.conversationInfo}set meeting(e){yt.Contracts.throwIfNullOrUndefined(e,"Meeting"),this.isMeetingRecognizer=!0,this.privMeeting=e}getMeetingInfo(){return yt.Contracts.throwIfNullOrUndefined(this.privMeeting,"Meeting"),this.privMeeting.meetingInfo}IsMeetingRecognizer(){return this.isMeetingRecognizer}startContinuousRecognitionAsync(e,t){XP.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(ap.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){XP.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}async close(){this.privDisposedRecognizer||await this.dispose(!0)}async pushConversationEvent(e,t){let r=this.privReco;yt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendSpeechEventAsync(e,t)}async pushMeetingEvent(e,t){let r=this.privReco;yt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendMeetingSpeechEventAsync(e,t)}async enforceAudioGating(){let r=(await this.audioConfig.format).channels;if(r===1){if(this.properties.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()!=="true")throw new Error("Single channel audio configuration for MeetingTranscriber is currently under private preview, please contact diarizationrequest@microsoft.com for more details")}else if(r!==8)throw new Error(`Unsupported audio configuration: Detected ${r}-channel audio`)}connectMeetingCallbacks(e){this.isMeetingRecognizer=!0,this.canceled=(t,r)=>{e.canceled&&e.canceled(e,r)},this.recognizing=(t,r)=>{e.transcribing&&e.transcribing(e,r)},this.recognized=(t,r)=>{e.transcribed&&e.transcribed(e,r)},this.sessionStarted=(t,r)=>{e.sessionStarted&&e.sessionStarted(e,r)},this.sessionStopped=(t,r)=>{e.sessionStopped&&e.sessionStopped(e,r)}}disconnectCallbacks(){this.canceled=void 0,this.recognizing=void 0,this.recognized=void 0,this.sessionStarted=void 0,this.sessionStopped=void 0}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new ap.RecognizerConfig(e,this.properties)}createServiceRecognizer(e,t,r,n){let s=r;return new ap.TranscriptionServiceRecognizer(e,t,s,n,this)}};cp.TranscriberRecognizer=tf});var eR=p(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});var Ub=xP();Object.defineProperty(qe,"ConversationManager",{enumerable:!0,get:function(){return Ub.ConversationManager}});var Wb=Yc();Object.defineProperty(qe,"ConversationConnectionConfig",{enumerable:!0,get:function(){return Wb.ConversationConnectionConfig}});var Hb=YP();Object.defineProperty(qe,"ConversationRecognizerFactory",{enumerable:!0,get:function(){return Hb.ConversationRecognizerFactory}});var Kb=ZP();Object.defineProperty(qe,"TranscriberRecognizer",{enumerable:!0,get:function(){return Kb.TranscriberRecognizer}});var Vi=Wv();Object.defineProperty(qe,"ConversationReceivedTranslationEventArgs",{enumerable:!0,get:function(){return Vi.ConversationReceivedTranslationEventArgs}});Object.defineProperty(qe,"LockRoomEventArgs",{enumerable:!0,get:function(){return Vi.LockRoomEventArgs}});Object.defineProperty(qe,"MuteAllEventArgs",{enumerable:!0,get:function(){return Vi.MuteAllEventArgs}});Object.defineProperty(qe,"ParticipantAttributeEventArgs",{enumerable:!0,get:function(){return Vi.ParticipantAttributeEventArgs}});Object.defineProperty(qe,"ParticipantEventArgs",{enumerable:!0,get:function(){return Vi.ParticipantEventArgs}});Object.defineProperty(qe,"ParticipantsListEventArgs",{enumerable:!0,get:function(){return Vi.ParticipantsListEventArgs}});var rf=Kv();Object.defineProperty(qe,"ConversationTranslatorCommandTypes",{enumerable:!0,get:function(){return rf.ConversationTranslatorCommandTypes}});Object.defineProperty(qe,"ConversationTranslatorMessageTypes",{enumerable:!0,get:function(){return rf.ConversationTranslatorMessageTypes}});Object.defineProperty(qe,"InternalParticipants",{enumerable:!0,get:function(){return rf.InternalParticipants}})});var sf=p(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.SynthesisAudioMetadata=Zr.MetadataType=void 0;var Jb;(function(i){i.WordBoundary="WordBoundary",i.Bookmark="Bookmark",i.Viseme="Viseme",i.SentenceBoundary="SentenceBoundary",i.SessionEnd="SessionEnd",i.AvatarSignal="TalkingAvatarSignal"})(Jb=Zr.MetadataType||(Zr.MetadataType={}));var nf=class i{constructor(e){this.privSynthesisAudioMetadata=JSON.parse(e)}static fromJSON(e){return new i(e)}get Metadata(){return this.privSynthesisAudioMetadata.Metadata}};Zr.SynthesisAudioMetadata=nf});var rR=p(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.SynthesisStartedEvent=kt.ConnectingToSynthesisServiceEvent=kt.SynthesisTriggeredEvent=kt.SpeechSynthesisEvent=void 0;var tR=P(),Ui=class extends tR.PlatformEvent{constructor(e,t,r=tR.EventType.Info){super(e,r),this.privRequestId=t}get requestId(){return this.privRequestId}};kt.SpeechSynthesisEvent=Ui;var of=class extends Ui{constructor(e,t,r){super("SynthesisTriggeredEvent",e),this.privSessionAudioDestinationId=t,this.privTurnAudioDestinationId=r}get audioSessionDestinationId(){return this.privSessionAudioDestinationId}get audioTurnDestinationId(){return this.privTurnAudioDestinationId}};kt.SynthesisTriggeredEvent=of;var af=class extends Ui{constructor(e,t){super("ConnectingToSynthesisServiceEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};kt.ConnectingToSynthesisServiceEvent=af;var cf=class extends Ui{constructor(e,t){super("SynthesisStartedEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};kt.SynthesisStartedEvent=cf});var iR=p(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});hp.SynthesisTurn=void 0;var pp=P(),Gb=br(),up=f(),$b=sf(),pf=rR(),uf=class i{constructor(){this.privIsDisposed=!1,this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!1,this.privBytesReceived=0,this.privInTurn=!1,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privRequestId=pp.createNoDashGuid(),this.privTurnDeferral=new pp.Deferred,this.privTurnDeferral.resolve()}get requestId(){return this.privRequestId}get streamId(){return this.privStreamId}set streamId(e){this.privStreamId=e}get audioOutputFormat(){return this.privAudioOutputFormat}set audioOutputFormat(e){this.privAudioOutputFormat=e}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSynthesisEnded(){return this.privIsSynthesisEnded}get isSynthesizing(){return this.privIsSynthesizing}get currentTextOffset(){return this.privTextOffset}get currentSentenceOffset(){return this.privSentenceOffset}get bytesReceived(){return this.privBytesReceived}get audioDuration(){return this.privAudioDuration}get extraProperties(){if(this.privWebRTCSDP){let e=new up.PropertyCollection;return e.setProperty(up.PropertyId.TalkingAvatarService_WebRTC_SDP,this.privWebRTCSDP),e}}async getAllReceivedAudio(){return this.privReceivedAudio?Promise.resolve(this.privReceivedAudio):this.privIsSynthesisEnded?(await this.readAllAudioFromStream(),Promise.resolve(this.privReceivedAudio)):null}async getAllReceivedAudioWithHeader(){if(this.privReceivedAudioWithHeader)return this.privReceivedAudioWithHeader;if(!this.privIsSynthesisEnded)return null;if(this.audioOutputFormat.hasHeader){let e=await this.getAllReceivedAudio();return this.privReceivedAudioWithHeader=this.audioOutputFormat.addHeader(e),this.privReceivedAudioWithHeader}else return this.getAllReceivedAudio()}startNewSynthesis(e,t,r,n){this.privIsSynthesisEnded=!1,this.privIsSynthesizing=!0,this.privRequestId=e,this.privRawText=t,this.privIsSSML=r,this.privAudioOutputStream=new Gb.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privAudioOutputFormat,this.privReceivedAudio=null,this.privReceivedAudioWithHeader=null,this.privBytesReceived=0,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privPartialVisemeAnimation="",this.privWebRTCSDP="",n!==void 0&&(this.privTurnAudioDestination=n,this.privTurnAudioDestination.format=this.privAudioOutputFormat),this.onEvent(new pf.SynthesisTriggeredEvent(this.requestId,void 0,n===void 0?void 0:n.id()))}onPreConnectionStart(e){this.privAuthFetchEventId=e,this.onEvent(new pf.ConnectingToSynthesisServiceEvent(this.privRequestId,this.privAuthFetchEventId))}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){if(e===200){this.onEvent(new pf.SynthesisStartedEvent(this.requestId,this.privAuthFetchEventId)),this.privBytesReceived=0;return}else e===403&&this.onComplete()}onServiceResponseMessage(e){let t=JSON.parse(e);this.streamId=t.audio.streamId}onServiceTurnEndResponse(){this.privInTurn=!1,this.privTurnDeferral.resolve(),this.onComplete()}onServiceTurnStartResponse(e){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch(()=>{})),this.privInTurn=!0,this.privTurnDeferral=new pp.Deferred;let t=JSON.parse(e);t.webrtc&&(this.privWebRTCSDP=t.webrtc.connectionString)}onAudioChunkReceived(e){this.isSynthesizing&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength,this.privTurnAudioDestination!==void 0&&this.privTurnAudioDestination.write(e))}onTextBoundaryEvent(e){this.updateTextOffset(e.Data.text.Text,e.Type)}onVisemeMetadataReceived(e){e.Data.AnimationChunk!==void 0&&(this.privPartialVisemeAnimation+=e.Data.AnimationChunk)}onSessionEnd(e){this.privAudioDuration=e.Data.Offset}async constructSynthesisResult(){let e=await this.getAllReceivedAudioWithHeader();return new up.SpeechSynthesisResult(this.requestId,up.ResultReason.SynthesizingAudioCompleted,e,void 0,this.extraProperties,this.audioDuration)}dispose(){this.privIsDisposed||(this.privIsDisposed=!0)}onStopSynthesizing(){this.onComplete()}getAndClearVisemeAnimation(){let e=this.privPartialVisemeAnimation;return this.privPartialVisemeAnimation="",e}onEvent(e){pp.Events.instance.onEvent(e)}static isXmlTag(e){return e.length>=2&&e[0]==="<"&&e[e.length-1]===">"}updateTextOffset(e,t){t===$b.MetadataType.WordBoundary?(this.privTextOffset=this.privRawText.indexOf(e,this.privNextSearchTextIndex),this.privTextOffset>=0&&(this.privNextSearchTextIndex=this.privTextOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privTextOffset)&&!i.isXmlTag(e)&&this.updateTextOffset(e,t))):(this.privSentenceOffset=this.privRawText.indexOf(e,this.privNextSearchSentenceIndex),this.privSentenceOffset>=0&&(this.privNextSearchSentenceIndex=this.privSentenceOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privSentenceOffset)&&!i.isXmlTag(e)&&this.updateTextOffset(e,t)))}onComplete(){this.privIsSynthesizing&&(this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!0,this.privAudioOutputStream.close(),this.privInTurn=!1,this.privTurnAudioDestination!==void 0&&(this.privTurnAudioDestination.close(),this.privTurnAudioDestination=void 0))}async readAllAudioFromStream(){if(this.privIsSynthesisEnded){this.privReceivedAudio=new ArrayBuffer(this.bytesReceived);try{await this.privAudioOutputStream.read(this.privReceivedAudio)}catch{this.privReceivedAudio=new ArrayBuffer(0)}}}withinXmlTag(e){return this.privRawText.indexOf("<",e+1)>this.privRawText.indexOf(">",e+1)}};hp.SynthesisTurn=uf});var nR=p(lp=>{"use strict";Object.defineProperty(lp,"__esModule",{value:!0});lp.SynthesisAdapterBase=void 0;var be=P(),Je=f(),st=C(),Wi=Jr(),dp=class{constructor(e,t,r,n){if(this.speakOverride=void 0,this.receiveMessageOverride=void 0,this.connectImplOverride=void 0,this.configConnectionOverride=void 0,this.privConnectionConfigurationPromise=void 0,!e)throw new be.ArgumentNullError("authentication");if(!t)throw new be.ArgumentNullError("connectionFactory");if(!r)throw new be.ArgumentNullError("synthesizerConfig");this.privAuthentication=e,this.privConnectionFactory=t,this.privSynthesizerConfig=r,this.privIsDisposed=!1,this.privSessionAudioDestination=n,this.privSynthesisTurn=new st.SynthesisTurn,this.privConnectionEvents=new be.EventSource,this.privServiceEvents=new be.EventSource,this.privSynthesisContext=new st.SynthesisContext,this.privAgentConfig=new st.AgentConfig,this.connectionEvents.attach(s=>{if(s.name==="ConnectionClosedEvent"){let o=s;o.statusCode!==1e3&&this.cancelSynthesisLocal(Je.CancellationReason.Error,o.statusCode===1007?Je.CancellationErrorCode.BadRequestParameters:Je.CancellationErrorCode.ConnectionFailure,`${o.reason} websocket error code: ${o.statusCode}`)}})}get synthesisContext(){return this.privSynthesisContext}get agentConfig(){return this.privAgentConfig}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set audioOutputFormat(e){this.privAudioOutputFormat=e,this.privSynthesisTurn.audioOutputFormat=e,this.privSessionAudioDestination!==void 0&&(this.privSessionAudioDestination.format=e),this.synthesisContext!==void 0&&(this.synthesisContext.audioOutputFormat=e)}isDisposed(){return this.privIsDisposed}async dispose(e){this.privIsDisposed=!0,this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.close(),this.privConnectionConfigurationPromise!==void 0&&await(await this.privConnectionConfigurationPromise).dispose(e)}async connect(){await this.connectImpl()}async sendNetworkMessage(e,t){let r=typeof t=="string"?be.MessageType.Text:be.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new Wi.SpeechConnectionMessage(r,e,this.privSynthesisTurn.requestId,n,t))}async Speak(e,t,r,n,s,o){let a;if(t?a=e:a=this.privSynthesizer.buildSsml(e),this.speakOverride!==void 0)return this.speakOverride(a,r,n,s);this.privSuccessCallback=n,this.privErrorCallback=s,this.privSynthesisTurn.startNewSynthesis(r,e,t,o);try{await this.connectImpl();let c=await this.fetchConnection();await this.sendSynthesisContext(c),await this.sendSsmlMessage(c,a,r),this.onSynthesisStarted(r),this.receiveMessage()}catch(c){return this.cancelSynthesisLocal(Je.CancellationReason.Error,Je.CancellationErrorCode.ConnectionFailure,c),Promise.reject(c)}}async stopSpeaking(){return await this.connectImpl(),(await this.fetchConnection()).send(new Wi.SpeechConnectionMessage(be.MessageType.Text,"synthesis.control",this.privSynthesisTurn.requestId,"application/json",JSON.stringify({action:"stop"})))}cancelSynthesis(e,t,r,n){let s=new Je.PropertyCollection;s.setProperty(st.CancellationErrorCodePropertyName,Je.CancellationErrorCode[r]);let o=new Je.SpeechSynthesisResult(e,Je.ResultReason.Canceled,void 0,n,s);if(this.onSynthesisCancelled(o),this.privSuccessCallback)try{this.privSuccessCallback(o)}catch{}}cancelSynthesisLocal(e,t,r){this.privSynthesisTurn.isSynthesizing&&(this.privSynthesisTurn.onStopSynthesizing(),this.cancelSynthesis(this.privSynthesisTurn.requestId,e,t,r))}processTypeSpecificMessages(e){return!0}async receiveMessage(){try{let t=await(await this.fetchConnection()).read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(this.privIsDisposed)return;if(!t)return this.privSynthesisTurn.isSynthesizing?this.receiveMessage():void 0;let r=Wi.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privSynthesisTurn.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privSynthesisTurn.onServiceTurnStartResponse(r.textBody);break;case"response":this.privSynthesisTurn.onServiceResponseMessage(r.textBody);break;case"audio":this.privSynthesisTurn.streamId.toLowerCase()===r.streamId.toLowerCase()&&r.binaryBody&&(this.privSynthesisTurn.onAudioChunkReceived(r.binaryBody),this.onSynthesizing(r.binaryBody),this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.write(r.binaryBody));break;case"audio.metadata":let n=st.SynthesisAudioMetadata.fromJSON(r.textBody).Metadata;for(let o of n)switch(o.Type){case st.MetadataType.WordBoundary:case st.MetadataType.SentenceBoundary:this.privSynthesisTurn.onTextBoundaryEvent(o);let a=new Je.SpeechSynthesisWordBoundaryEventArgs(o.Data.Offset,o.Data.Duration,o.Data.text.Text,o.Data.text.Length,o.Type===st.MetadataType.WordBoundary?this.privSynthesisTurn.currentTextOffset:this.privSynthesisTurn.currentSentenceOffset,o.Data.text.BoundaryType);this.onWordBoundary(a);break;case st.MetadataType.Bookmark:let c=new Je.SpeechSynthesisBookmarkEventArgs(o.Data.Offset,o.Data.Bookmark);this.onBookmarkReached(c);break;case st.MetadataType.Viseme:if(this.privSynthesisTurn.onVisemeMetadataReceived(o),o.Data.IsLastAnimation){let u=new Je.SpeechSynthesisVisemeEventArgs(o.Data.Offset,o.Data.VisemeId,this.privSynthesisTurn.getAndClearVisemeAnimation());this.onVisemeReceived(u)}break;case st.MetadataType.AvatarSignal:this.onAvatarEvent(o);break;case st.MetadataType.SessionEnd:this.privSynthesisTurn.onSessionEnd(o);break}break;case"turn.end":this.privSynthesisTurn.onServiceTurnEndResponse();let s;try{s=await this.privSynthesisTurn.constructSynthesisResult(),this.privSuccessCallback&&this.privSuccessCallback(s)}catch(o){this.privErrorCallback&&this.privErrorCallback(o)}this.onSynthesisCompleted(s);break;default:this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new be.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch{}}sendSynthesisContext(e){this.setSynthesisContextSynthesisSection();let t=this.synthesisContext.toJSON();if(t)return e.send(new Wi.SpeechConnectionMessage(be.MessageType.Text,"synthesis.context",this.privSynthesisTurn.requestId,"application/json",t))}setSpeechConfigSynthesisSection(){}connectImpl(e=!1){if(this.privConnectionPromise!=null)return this.privConnectionPromise.then(r=>r.state()===be.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()));this.privAuthFetchEventId=be.createNoDashGuid(),this.privConnectionId=be.createNoDashGuid(),this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId);let t=e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId);return this.privConnectionPromise=t.then(async r=>{this.privSynthesisTurn.onAuthCompleted(!1);let n=this.privConnectionFactory.create(this.privSynthesizerConfig,r,this.privConnectionId);n.events.attach(o=>{this.connectionEvents.onEvent(o)});let s=await n.open();return s.statusCode===200?(this.privSynthesisTurn.onConnectionEstablishCompleted(s.statusCode),Promise.resolve(n)):s.statusCode===403&&!e?this.connectImpl(!0):(this.privSynthesisTurn.onConnectionEstablishCompleted(s.statusCode),Promise.reject(`Unable to contact server. StatusCode: ${s.statusCode},
23
+ ${this.privSynthesizerConfig.parameters.getProperty(Je.PropertyId.SpeechServiceConnection_Url)} Reason: ${s.reason}`))},r=>{throw this.privSynthesisTurn.onAuthCompleted(!0),new Error(r)}),this.privConnectionPromise.catch(()=>{}),this.privConnectionPromise}sendSpeechServiceConfig(e,t){if(t)return e.send(new Wi.SpeechConnectionMessage(be.MessageType.Text,"speech.config",this.privSynthesisTurn.requestId,"application/json",t))}sendSsmlMessage(e,t,r){return e.send(new Wi.SpeechConnectionMessage(be.MessageType.Text,"ssml",r,"application/ssml+xml",t))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===be.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async configureConnection(){let e=await this.connectImpl();return this.configConnectionOverride!==void 0?this.configConnectionOverride(e):(this.setSpeechConfigSynthesisSection(),await this.sendSpeechServiceConfig(e,this.privSynthesizerConfig.SpeechServiceConfig.serialize()),e)}onAvatarEvent(e){}onSynthesisStarted(e){}onSynthesizing(e){}onSynthesisCancelled(e){}onSynthesisCompleted(e){}onWordBoundary(e){}onVisemeReceived(e){}onBookmarkReached(e){}};lp.SynthesisAdapterBase=dp;dp.telemetryDataEnabled=!0});var oR=p(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});vp.AvatarSynthesisAdapter=void 0;var sR=f(),Qb=C(),hf=class extends Qb.SynthesisAdapterBase{constructor(e,t,r,n,s){super(e,t,r,void 0),this.privAvatarSynthesizer=n,this.privSynthesizer=n,this.privAvatarConfig=s}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(void 0)}setSpeechConfigSynthesisSection(){this.privSynthesizerConfig.synthesisVideoSection={format:{bitrate:this.privAvatarConfig.videoFormat?.bitrate,codec:this.privAvatarConfig.videoFormat?.codec,crop:{bottomRight:{x:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.y},topLeft:{x:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.y}},resolution:{height:this.privAvatarConfig.videoFormat?.height,width:this.privAvatarConfig.videoFormat?.width}},protocol:{name:"WebRTC",webrtcConfig:{clientDescription:btoa(this.privSynthesizerConfig.parameters.getProperty(sR.PropertyId.TalkingAvatarService_WebRTC_SDP)),iceServers:this.privAvatarSynthesizer.iceServers}},talkingAvatar:{background:{color:this.privAvatarConfig.backgroundColor},character:this.privAvatarConfig.character,customized:this.privAvatarConfig.customized,style:this.privAvatarConfig.style}}}onAvatarEvent(e){if(this.privAvatarSynthesizer.avatarEventReceived){let t=new sR.AvatarEventArgs(e.Data.Offset,e.Data.Name);try{this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer,t)}catch{}}}};vp.AvatarSynthesisAdapter=hf});var aR=p(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});fp.SpeechSynthesisAdapter=void 0;var Cr=f(),Yb=C(),df=class extends Yb.SynthesisAdapterBase{constructor(e,t,r,n,s){super(e,t,r,s),this.privSpeechSynthesizer=n,this.privSynthesizer=n}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(this.privSpeechSynthesizer)}onSynthesisStarted(e){let t=new Cr.SpeechSynthesisEventArgs(new Cr.SpeechSynthesisResult(e,Cr.ResultReason.SynthesizingAudioStarted));this.privSpeechSynthesizer.synthesisStarted&&this.privSpeechSynthesizer.synthesisStarted(this.privSpeechSynthesizer,t)}onSynthesizing(e){if(this.privSpeechSynthesizer.synthesizing)try{let t=this.privSynthesisTurn.audioOutputFormat.addHeader(e),r=new Cr.SpeechSynthesisEventArgs(new Cr.SpeechSynthesisResult(this.privSynthesisTurn.requestId,Cr.ResultReason.SynthesizingAudio,t));this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer,r)}catch{}}onSynthesisCancelled(e){if(this.privSpeechSynthesizer.SynthesisCanceled){let t=new Cr.SpeechSynthesisEventArgs(e);try{this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer,t)}catch{}}}onSynthesisCompleted(e){if(this.privSpeechSynthesizer.synthesisCompleted)try{this.privSpeechSynthesizer.synthesisCompleted(this.privSpeechSynthesizer,new Cr.SpeechSynthesisEventArgs(e))}catch{}}onWordBoundary(e){if(this.privSpeechSynthesizer.wordBoundary)try{this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer,e)}catch{}}onVisemeReceived(e){if(this.privSpeechSynthesizer.visemeReceived)try{this.privSpeechSynthesizer.visemeReceived(this.privSpeechSynthesizer,e)}catch{}}onBookmarkReached(e){if(this.privSpeechSynthesizer.bookmarkReached)try{this.privSpeechSynthesizer.bookmarkReached(this.privSpeechSynthesizer,e)}catch{}}};fp.SpeechSynthesisAdapter=df});var cR=p(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0});gp.SynthesisRestAdapter=void 0;var lf=pe(),vf=f(),Xb=Ye(),Zb=we(),ff=class{constructor(e,t){let r=e.parameters.getProperty(vf.PropertyId.SpeechServiceConnection_Endpoint,void 0);if(!r){let s=e.parameters.getProperty(vf.PropertyId.SpeechServiceConnection_Region,"westus"),o=Xb.ConnectionFactoryBase.getHostSuffix(s);r=e.parameters.getProperty(vf.PropertyId.SpeechServiceConnection_Host,`https://${s}.tts.speech${o}`)}this.privUri=`${r}/cognitiveservices/voices/list`;let n=lf.RestConfigBase.requestOptions;this.privRestAdapter=new lf.RestMessageAdapter(n),this.privAuthentication=t}getVoicesList(e){return this.privRestAdapter.setHeaders(Zb.HeaderNames.ConnectionId,e),this.privAuthentication.fetch(e).then(t=>(this.privRestAdapter.setHeaders(t.headerName,t.token),this.privRestAdapter.request(lf.RestRequestType.Get,this.privUri)))}};gp.SynthesisRestAdapter=ff});var hR=p(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.SynthesizerConfig=ei.SynthesisServiceType=void 0;var pR=C(),uR;(function(i){i[i.Standard=0]="Standard",i[i.Custom=1]="Custom"})(uR=ei.SynthesisServiceType||(ei.SynthesisServiceType={}));var gf=class{constructor(e,t){this.privSynthesisServiceType=uR.Standard,this.avatarEnabled=!1,this.privSpeechServiceConfig=e||new pR.SpeechServiceConfig(new pR.Context(null)),this.privParameters=t}get parameters(){return this.privParameters}get synthesisServiceType(){return this.privSynthesisServiceType}set synthesisServiceType(e){this.privSynthesisServiceType=e}set synthesisVideoSection(e){this.privSpeechServiceConfig.Context.synthesis={video:e}}get SpeechServiceConfig(){return this.privSpeechServiceConfig}};ei.SynthesizerConfig=gf});var dR=p(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});mp.SynthesisContext=void 0;var mf=f(),Sf=class{constructor(){this.privContext={}}setSection(e,t){this.privContext[e]=t}set audioOutputFormat(e){this.privAudioOutputFormat=e}toJSON(){return JSON.stringify(this.privContext)}setSynthesisSection(e){let t=this.buildSynthesisContext(e);this.setSection("synthesis",t)}buildSynthesisContext(e){return{audio:{metadataOptions:{bookmarkEnabled:!!e?.bookmarkReached,punctuationBoundaryEnabled:e?.properties.getProperty(mf.PropertyId.SpeechServiceResponse_RequestPunctuationBoundary,!!e?.wordBoundary),sentenceBoundaryEnabled:e?.properties.getProperty(mf.PropertyId.SpeechServiceResponse_RequestSentenceBoundary,!1),sessionEndEnabled:!0,visemeEnabled:!!e?.visemeReceived,wordBoundaryEnabled:e?.properties.getProperty(mf.PropertyId.SpeechServiceResponse_RequestWordBoundary,!!e?.wordBoundary)},outputFormat:this.privAudioOutputFormat.requestAudioFormatString},language:{autoDetection:e?.autoDetectSourceLanguage}}}};mp.SynthesisContext=Sf});var lR=p(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});Sp.SpeakerRecognitionConfig=void 0;var eO=C(),yf=class{constructor(e,t){this.privContext=e||new eO.Context(null),this.privParameters=t}get parameters(){return this.privParameters}get Context(){return this.privContext}};Sp.SpeakerRecognitionConfig=yf});var fR=p(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});Cp.SpeakerServiceRecognizer=void 0;var tO=pe(),yp=P(),Ce=f(),vR=C(),rO=Jr(),Cf=class extends vR.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeakerRecognizer=s,this.privSpeakerAudioSource=r,this.recognizeSpeaker=o=>this.recognizeSpeakerOnce(o),this.sendPrePayloadJSONOverride=()=>this.noOp()}processTypeSpecificMessages(e){let t=!1,r=new Ce.PropertyCollection;switch(e.messageType===yp.MessageType.Text&&r.setProperty(Ce.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.response":let s=JSON.parse(e.textBody),o;s.status.statusCode.toLowerCase()!=="success"?o=new Ce.SpeakerRecognitionResult(s,Ce.ResultReason.Canceled,Ce.CancellationErrorCode.ServiceError,s.status.reason):o=new Ce.SpeakerRecognitionResult(s,Ce.ResultReason.RecognizedSpeaker),this.privResultDeferral&&this.privResultDeferral.resolve(o),t=!0;break;default:break}let n=new yp.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){if(new Ce.PropertyCollection().setProperty(vR.CancellationErrorCodePropertyName,Ce.CancellationErrorCode[n]),this.privResultDeferral){let a=new Ce.SpeakerRecognitionResult({scenario:this.privSpeakerModel.scenario,status:{statusCode:s,reason:s}},Ce.ResultReason.Canceled,n,s);try{this.privResultDeferral.resolve(a)}catch(c){this.privResultDeferral.reject(c)}}}async recognizeSpeakerOnce(e){this.privSpeakerModel=e,this.voiceProfileType=e.scenario,this.privResultDeferral||(this.privResultDeferral=new yp.Deferred),this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(Ce.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let t=this.connectImpl(),r=this.sendPreAudioMessages(this.extractSpeakerContext(e)),n=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),s=await this.privSpeakerAudioSource.format,o=await this.privSpeakerAudioSource.deviceInfo,a=new tO.ReplayableAudioNode(n,s.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(a,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:o};try{await t,await r}catch(h){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Ce.CancellationReason.Error,Ce.CancellationErrorCode.ConnectionFailure,h)}let c=new Ce.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,c),this.receiveMessage(),this.sendAudio(a).then(()=>{},h=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Ce.CancellationReason.Error,Ce.CancellationErrorCode.RuntimeError,h)}),this.privResultDeferral.promise}async sendPreAudioMessages(e){let t=await this.fetchConnection();await this.sendSpeakerRecognition(t,e)}async sendSpeakerRecognition(e,t){let r=JSON.stringify(t);return e.send(new rO.SpeechConnectionMessage(yp.MessageType.Text,"speaker.context",this.privRequestSession.requestId,"application/json; charset=utf-8",r))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}};Cp.SpeakerServiceRecognizer=Cf});var mR=p(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});Pp.VoiceServiceRecognizer=void 0;var iO=pe(),Nt=P(),L=f(),gR=C(),Pf=Jr(),Rf=class extends gR.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privDeferralMap=new Nt.DeferralMap,this.privSpeakerAudioSource=r,this.sendPrePayloadJSONOverride=()=>this.noOp()}set SpeakerAudioSource(e){this.privSpeakerAudioSource=e}processTypeSpecificMessages(e){let t=!1,r=new L.PropertyCollection;switch(e.messageType===Nt.MessageType.Text&&r.setProperty(L.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.profiles":let s=JSON.parse(e.textBody);switch(s.operation.toLowerCase()){case"create":this.handleCreateResponse(s,e.requestId);break;case"delete":case"reset":this.handleResultResponse(s,e.requestId);break;case"fetch":let u=JSON.parse(e.textBody);this.handleFetchResponse(u,e.requestId);break;default:break}t=!0;break;case"speaker.phrases":let o=JSON.parse(e.textBody);this.handlePhrasesResponse(o,e.requestId),t=!0;break;case"speaker.profile.enrollment":let a=JSON.parse(e.textBody),c=new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(a.enrollment?a.enrollment.enrollmentStatus:a.status.statusCode),a.enrollment?JSON.stringify(a.enrollment):void 0,a.status.reason);this.privDeferralMap.getId(e.requestId)&&this.privDeferralMap.complete(e.requestId,c),this.privRequestSession.onSpeechEnded(),t=!0;break;default:break}let n=new Nt.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){new L.PropertyCollection().setProperty(gR.CancellationErrorCodePropertyName,L.CancellationErrorCode[n]);let a=new L.VoiceProfileEnrollmentResult(L.ResultReason.Canceled,s,s);this.privDeferralMap.getId(t)&&this.privDeferralMap.complete(t,a)}async createProfile(e,t){this.voiceProfileType=e.toString();let r=this.connectImpl();try{let n=new Nt.Deferred;return await r,await this.sendCreateProfile(n,e,t),this.receiveMessage(),n.promise}catch(n){throw n}}async resetProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("reset",e.profileType,e)}async deleteProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("delete",e.profileType,e)}async retrieveEnrollmentResult(e){return this.voiceProfileType=e.profileType.toString(),this.privExpectedProfileId=e.profileId,this.sendCommonRequest("fetch",e.profileType,e)}async getAllProfiles(e){return this.voiceProfileType=e.toString(),this.sendCommonRequest("fetch",e)}async getActivationPhrases(e,t){this.voiceProfileType=e.toString();let r=this.connectImpl();try{let n=new Nt.Deferred;return await r,await this.sendPhrasesRequest(n,e,t),this.receiveMessage(),n.promise}catch(n){throw n}}async enrollProfile(e){this.voiceProfileType=e.profileType.toString();let t=new Nt.Deferred;this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(L.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let r=this.connectImpl(),n=this.sendPreAudioMessages(e,t),s=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),o=await this.privSpeakerAudioSource.format,a=await this.privSpeakerAudioSource.deviceInfo,c=new iO.ReplayableAudioNode(s,o.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(c,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:a};try{await r,await n}catch(d){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.ConnectionFailure,d)}let u=new L.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,u),this.receiveMessage(),this.sendAudio(c).then(()=>{},d=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.RuntimeError,d)}),t.promise}async sendPreAudioMessages(e,t){let r=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,t),await this.sendBaseRequest(r,"enroll",this.scenarioFrom(e.profileType),e)}async sendPhrasesRequest(e,t,r){let n=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);let s=this.scenarioFrom(t),o={locale:r,scenario:s};return n.send(new Pf.SpeechConnectionMessage(Nt.MessageType.Text,"speaker.profile.phrases",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(o)))}async sendCreateProfile(e,t,r){let n=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);let s=t===L.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":t===L.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification",o={locale:r,number:"1",scenario:s};return n.send(new Pf.SpeechConnectionMessage(Nt.MessageType.Text,"speaker.profile.create",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(o)))}async sendCommonRequest(e,t,r=void 0){let n=this.connectImpl();try{let s=new Nt.Deferred;this.privRequestSession.onSpeechContext(),await n;let o=await this.fetchConnection();return this.privDeferralMap.add(this.privRequestSession.requestId,s),await this.sendBaseRequest(o,e,this.scenarioFrom(t),r),this.receiveMessage(),s.promise}catch(s){throw s}}async sendBaseRequest(e,t,r,n){let s={scenario:r};return n?s.profileIds=[n.profileId]:s.maxPageSize=-1,e.send(new Pf.SpeechConnectionMessage(Nt.MessageType.Text,`speaker.profile.${t}`,this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(s)))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}handlePhrasesResponse(e,t){if(this.privDeferralMap.getId(t))if(e.status.statusCode.toLowerCase()!=="success"){let r=L.ResultReason.Canceled,n=new L.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,[]);this.privDeferralMap.complete(t,n)}else if(e.phrases&&e.phrases.length>0){let r=L.ResultReason.EnrollingVoiceProfile,n=new L.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,e.phrases);this.privDeferralMap.complete(t,n)}else throw new Error("Voice Profile get activation phrases failed, no phrases received");else throw new Error(`Voice Profile get activation phrases request for requestID ${t} not found`)}handleCreateResponse(e,t){if(e.profiles&&e.profiles.length>0)if(this.privDeferralMap.getId(t)){let r=e.profiles.map(n=>n.profileId);this.privDeferralMap.complete(t,r)}else throw new Error(`Voice Profile create request for requestID ${t} not found`);else throw new Error("Voice Profile create failed, no profile id received")}handleResultResponse(e,t){if(this.privDeferralMap.getId(t)){let r=e.operation.toLowerCase()==="delete"?L.ResultReason.DeletedVoiceProfile:L.ResultReason.ResetVoiceProfile,n=e.status.statusCode.toLowerCase()==="success"?r:L.ResultReason.Canceled,s=new L.VoiceProfileResult(n,`statusCode: ${e.status.statusCode}, errorDetails: ${e.status.reason}`);this.privDeferralMap.complete(t,s)}else throw new Error(`Voice Profile create request for requestID ${t} not found`)}handleFetchResponse(e,t){if(this.privDeferralMap.getId(t)&&e.profiles[0]){if(this.privExpectedProfileId&&e.profiles.length===1&&e.profiles[0].profileId===this.privExpectedProfileId){this.privExpectedProfileId=void 0;let r=e.profiles[0],n=new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(r.enrollmentStatus),JSON.stringify(r),e.status.reason);this.privDeferralMap.complete(t,n)}else if(e.profiles.length>0){let r=e.profiles,n=[];for(let s of r)n.push(new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(s.enrollmentStatus),JSON.stringify(s),e.status.reason));this.privDeferralMap.complete(t,n)}}else throw new Error(`Voice Profile fetch request for requestID ${t} not found`)}enrollmentReasonFrom(e){switch(e.toLowerCase()){case"enrolled":return L.ResultReason.EnrolledVoiceProfile;case"invalidlocale":case"invalidphrase":case"invalidaudioformat":case"invalidscenario":case"invalidprofilecount":case"invalidoperation":case"audiotooshort":case"audiotoolong":case"toomanyenrollments":case"storageconflict":case"profilenotfound":case"incompatibleprofiles":case"incompleteenrollment":return L.ResultReason.Canceled;default:return L.ResultReason.EnrollingVoiceProfile}}scenarioFrom(e){return e===L.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":e===L.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification"}};Pp.VoiceServiceRecognizer=Rf});var SR=p(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.type=he.connectivity=he.Device=he.OS=he.System=he.Context=he.SpeechServiceConfig=void 0;var Ef=class{constructor(e){this.context=e}serialize(){return JSON.stringify(this,(e,t)=>{if(t&&typeof t=="object"&&!Array.isArray(t)){let r={};for(let n in t)Object.hasOwnProperty.call(t,n)&&(r[n&&n.charAt(0).toLowerCase()+n.substring(1)]=t[n]);return r}return t})}get Context(){return this.context}get Recognition(){return this.recognition}set Recognition(e){this.recognition=e.toLowerCase()}};he.SpeechServiceConfig=Ef;var If=class{constructor(e){this.system=new Rp,this.os=e}};he.Context=If;var Rp=class{constructor(){let e="1.36.0";this.name="SpeechSDK",this.version=e,this.build="JavaScript",this.lang="JavaScript"}};he.System=Rp;var wf=class{constructor(e,t,r){this.platform=e,this.name=t,this.version=r}};he.OS=wf;var _f=class{constructor(e,t,r){this.manufacturer=e,this.model=t,this.version=r}};he.Device=_f;var nO;(function(i){i.Bluetooth="Bluetooth",i.Wired="Wired",i.WiFi="WiFi",i.Cellular="Cellular",i.InBuilt="InBuilt",i.Unknown="Unknown"})(nO=he.connectivity||(he.connectivity={}));var sO;(function(i){i.Phone="Phone",i.Speaker="Speaker",i.Car="Car",i.Headset="Headset",i.Thermostat="Thermostat",i.Microphones="Microphones",i.Deskphone="Deskphone",i.RemoteControl="RemoteControl",i.Unknown="Unknown",i.File="File",i.Stream="Stream"})(sO=he.type||(he.type={}))});var C=p(m=>{"use strict";var oO=m&&m.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),R=m&&m.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&oO(e,i,t)};Object.defineProperty(m,"__esModule",{value:!0});m.AutoDetectSourceLanguagesOpenRangeOptionName=m.ForceDictationPropertyName=m.ServicePropertiesPropertyName=m.CancellationErrorCodePropertyName=m.OutputFormatPropertyName=void 0;R(Em(),m);R(Tm(),m);R(qs(),m);R(bm(),m);R(Mm(),m);R(_C(),m);R(OC(),m);R(dc(),m);R(DC(),m);R(kC(),m);R(qC(),m);R(zC(),m);R(LC(),m);R(UC(),m);R(KC(),m);R(QC(),m);R(eP(),m);R(_l(),m);R(tP(),m);R(rP(),m);R(nP(),m);R(sP(),m);R(oP(),m);R(cP(),m);R(pP(),m);R(uP(),m);R(hP(),m);R(dP(),m);R(lP(),m);R(fP(),m);R(gP(),m);R(mP(),m);R(SP(),m);R(CP(),m);R(PP(),m);R(EP(),m);R(_P(),m);R(TP(),m);R(AP(),m);R(OP(),m);R(NP(),m);R(qP(),m);R(eR(),m);R(sf(),m);R(iR(),m);R(nR(),m);var aO=oR();Object.defineProperty(m,"AvatarSynthesisAdapter",{enumerable:!0,get:function(){return aO.AvatarSynthesisAdapter}});var cO=aR();Object.defineProperty(m,"SpeechSynthesisAdapter",{enumerable:!0,get:function(){return cO.SpeechSynthesisAdapter}});R(cR(),m);R(hR(),m);R(dR(),m);R(lR(),m);R(fR(),m);R(mR(),m);R(SR(),m);m.OutputFormatPropertyName="OutputFormat";m.CancellationErrorCodePropertyName="CancellationErrorCode";m.ServicePropertiesPropertyName="ServiceProperties";m.ForceDictationPropertyName="ForceDictation";m.AutoDetectSourceLanguagesOpenRangeOptionName="OpenRange"});var yR=p(ti=>{"use strict";var pO=ti&&ti.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),uO=ti&&ti.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&pO(e,i,t)};Object.defineProperty(ti,"__esModule",{value:!0});var hO=C();new hO.AgentConfig;uO(f(),ti)});var bR=p((wN,AR)=>{"use strict";AR.exports=function(){var i={};return i.promise=new Promise(function(e,t){i.resolve=e,i.reject=t}),i}});var DR=p((Ji,Df)=>{"use strict";Object.defineProperty(Ji,"__esModule",{value:!0});Ji.default=void 0;var OR=PO(bR());function PO(i){return i&&i.__esModule?i:{default:i}}function RO(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function MR(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function EO(i,e,t){return e&&MR(i.prototype,e),t&&MR(i,t),i}var IO=function(){function i(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};RO(this,i),this.defers=[],this.upcomingDeferred=null,this.eventListener=this.eventListener.bind(this),this.options=t,this.one=this.one.bind(this),this.upcoming=this.upcoming.bind(this),this[Symbol.iterator]=function(){return{next:function(){return{done:!1,value:e.upcoming()}}}}}return EO(i,[{key:"eventListener",value:function(t){var r=this.defers.shift(),n=this.options.array?[].slice.call(arguments):t;r&&r.resolve(n),this.upcomingDeferred&&(this.upcomingDeferred.resolve(n),this.upcomingDeferred=null)}},{key:"one",value:function(){var t=(0,OR.default)();return this.defers.push(t),t.promise}},{key:"upcoming",value:function(){return this.upcomingDeferred||(this.upcomingDeferred=(0,OR.default)()),this.upcomingDeferred.promise}}]),i}();Ji.default=IO;Df.exports=Ji.default;Df.exports.default=Ji.default});function xp(i,e,...t){if(!i)throw new TypeError(rg(e,t))}function rg(i,e){let t=0;return i.replace(/%[os]/gu,()=>ig(e[t++]))}function ig(i){return typeof i!="object"||i===null?String(i):Object.prototype.toString.call(i)}var Kf;function KR(i){try{let e=i instanceof Error?i:new Error(ig(i));if(Kf){Kf(e);return}if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}));else if(typeof process<"u"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)}catch{}}var at=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,Jf;var ct=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{if(Jf){Jf({...this,args:e});return}let r=((t=new Error().stack)!==null&&t!==void 0?t:"").replace(/^(?:.+?\n){2}/gu,`
24
+ `);console.warn(this.message,...e,r)}catch{}}},JR=new ct("W01","Unable to initialize event under dispatching."),GR=new ct("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),$R=new ct("W03","Assigning any truthy value to 'returnValue' property has no effect."),QR=new ct("W04","Unable to preventDefault on non-cancelable events."),YR=new ct("W05","Unable to preventDefault inside passive event listener invocation."),XR=new ct("W06","An event listener wasn't added because it has been added already: %o, %o"),Dp=new ct("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),Gf=new ct("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),ZR=new ct("W09","Event attribute handler must be a function: %o"),Me=class{static get NONE(){return $f}static get CAPTURING_PHASE(){return Qf}static get AT_TARGET(){return Yf}static get BUBBLING_PHASE(){return Xf}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let r=t??{};qp.set(this,{type:String(e),bubbles:!!r.bubbles,cancelable:!!r.cancelable,composed:!!r.composed,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return re(this).type}get target(){return re(this).target}get srcElement(){return re(this).target}get currentTarget(){return re(this).currentTarget}composedPath(){let e=re(this).currentTarget;return e?[e]:[]}get NONE(){return $f}get CAPTURING_PHASE(){return Qf}get AT_TARGET(){return Yf}get BUBBLING_PHASE(){return Xf}get eventPhase(){return re(this).dispatchFlag?2:0}stopPropagation(){re(this).stopPropagationFlag=!0}get cancelBubble(){return re(this).stopPropagationFlag}set cancelBubble(e){e?re(this).stopPropagationFlag=!0:GR.warn()}stopImmediatePropagation(){let e=re(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return re(this).bubbles}get cancelable(){return re(this).cancelable}get returnValue(){return!re(this).canceledFlag}set returnValue(e){e?$R.warn():Zf(re(this))}preventDefault(){Zf(re(this))}get defaultPrevented(){return re(this).canceledFlag}get composed(){return re(this).composed}get isTrusted(){return!1}get timeStamp(){return re(this).timeStamp}initEvent(e,t=!1,r=!1){let n=re(this);if(n.dispatchFlag){JR.warn();return}qp.set(this,{...n,type:String(e),bubbles:!!t,cancelable:!!r,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},$f=0,Qf=1,Yf=2,Xf=3,qp=new WeakMap;function re(i,e="this"){let t=qp.get(i);return xp(t!=null,"'%s' must be an object that Event constructor created, but got another one: %o",e,i),t}function Zf(i){if(i.inPassiveListenerFlag){YR.warn();return}if(!i.cancelable){QR.warn();return}i.canceledFlag=!0}Object.defineProperty(Me,"NONE",{enumerable:!0});Object.defineProperty(Me,"CAPTURING_PHASE",{enumerable:!0});Object.defineProperty(Me,"AT_TARGET",{enumerable:!0});Object.defineProperty(Me,"BUBBLING_PHASE",{enumerable:!0});var kp=Object.getOwnPropertyNames(Me.prototype);for(let i=0;i<kp.length;++i)kp[i]!=="constructor"&&Object.defineProperty(Me.prototype,kp[i],{enumerable:!0});typeof at<"u"&&typeof at.Event<"u"&&Object.setPrototypeOf(Me.prototype,at.Event.prototype);function eE(i){return at.DOMException?new at.DOMException(i,"InvalidStateError"):(ii==null&&(ii=class ng extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,ng)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(ii.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),tg(ii),tg(ii.prototype)),new ii(i))}var ii,eg={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function tg(i){let e=Object.keys(eg);for(let t=0;t<e.length;++t){let r=e[t],n=eg[r];Object.defineProperty(i,r,{get(){return n},configurable:!0,enumerable:!0})}}var si=class extends Me{static wrap(e){return new(og(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),sg.set(this,{original:e});let t=Object.keys(e);for(let r=0;r<t.length;++r){let n=t[r];n in this||Object.defineProperty(this,n,ag(e,n))}}stopPropagation(){super.stopPropagation();let{original:e}=Zt(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;let{original:t}=Zt(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:e}=Zt(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;let{original:t}=Zt(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();let{original:e}=Zt(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){let{original:e}=Zt(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},sg=new WeakMap;function Zt(i){let e=sg.get(i);return xp(e!=null,"'this' is expected an Event object, but got",i),e}var Zn=new WeakMap;Zn.set(Object.prototype,si);typeof at<"u"&&typeof at.Event<"u"&&Zn.set(at.Event.prototype,si);function og(i){let e=Object.getPrototypeOf(i);if(e==null)return si;let t=Zn.get(e);return t==null&&(t=tE(og(e),e),Zn.set(e,t)),t}function tE(i,e){class t extends i{}let r=Object.keys(e);for(let n=0;n<r.length;++n)Object.defineProperty(t.prototype,r[n],ag(e,r[n]));return t}function ag(i,e){let t=Object.getOwnPropertyDescriptor(i,e);return{get(){let r=Zt(this).original,n=r[e];return typeof n=="function"?n.bind(r):n},set(r){let n=Zt(this).original;n[e]=r},configurable:t.configurable,enumerable:t.enumerable}}function rE(i,e,t,r,n,s){return{callback:i,flags:(e?1:0)|(t?2:0)|(r?4:0),signal:n,signalListener:s}}function iE(i){i.flags|=8}function cg(i){return(i.flags&1)===1}function pg(i){return(i.flags&2)===2}function ug(i){return(i.flags&4)===4}function nE(i){return(i.flags&8)===8}function sE({callback:i},e,t){try{typeof i=="function"?i.call(e,t):typeof i.handleEvent=="function"&&i.handleEvent(t)}catch(r){KR(r)}}function hg({listeners:i},e,t){for(let r=0;r<i.length;++r)if(i[r].callback===e&&cg(i[r])===t)return r;return-1}function dg(i,e,t,r,n,s){let o;s&&(o=zp.bind(null,i,e,t),s.addEventListener("abort",o));let a=rE(e,t,r,n,s,o);return i.cow?(i.cow=!1,i.listeners=[...i.listeners,a]):i.listeners.push(a),a}function zp(i,e,t){let r=hg(i,e,t);return r!==-1?lg(i,r):!1}function lg(i,e,t=!1){let r=i.listeners[e];return iE(r),r.signal&&r.signal.removeEventListener("abort",r.signalListener),i.cow&&!t?(i.cow=!1,i.listeners=i.listeners.filter((n,s)=>s!==e),!1):(i.listeners.splice(e,1),!0)}function oE(){return Object.create(null)}function vg(i,e){var t;return(t=i[e])!==null&&t!==void 0?t:i[e]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}var pt=class{constructor(){fg.set(this,oE())}addEventListener(e,t,r){let n=ni(this),{callback:s,capture:o,once:a,passive:c,signal:u,type:h}=aE(e,t,r);if(s==null||u?.aborted)return;let d=vg(n,h),v=hg(d,s,o);if(v!==-1){pE(d.listeners[v],c,a,u);return}dg(d,s,o,c,a,u)}removeEventListener(e,t,r){let n=ni(this),{callback:s,capture:o,type:a}=cE(e,t,r),c=n[a];s!=null&&c&&zp(c,s,o)}dispatchEvent(e){let t=ni(this)[String(e.type)];if(t==null)return!0;let r=e instanceof Me?e:si.wrap(e),n=re(r,"event");if(n.dispatchFlag)throw eE("This event has been in dispatching.");if(n.dispatchFlag=!0,n.target=n.currentTarget=this,!n.stopPropagationFlag){let{cow:s,listeners:o}=t;t.cow=!0;for(let a=0;a<o.length;++a){let c=o[a];if(!nE(c)&&(ug(c)&&lg(t,a,!s)&&(a-=1),n.inPassiveListenerFlag=pg(c),sE(c,this,r),n.inPassiveListenerFlag=!1,n.stopImmediatePropagationFlag))break}s||(t.cow=!1)}return n.target=null,n.currentTarget=null,n.stopImmediatePropagationFlag=!1,n.stopPropagationFlag=!1,n.dispatchFlag=!1,!n.canceledFlag}},fg=new WeakMap;function ni(i,e="this"){let t=fg.get(i);return xp(t!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",e,i),t}function aE(i,e,t){var r;return gg(e),typeof t=="object"&&t!==null?{type:String(i),callback:e??void 0,capture:!!t.capture,passive:!!t.passive,once:!!t.once,signal:(r=t.signal)!==null&&r!==void 0?r:void 0}:{type:String(i),callback:e??void 0,capture:!!t,passive:!1,once:!1,signal:void 0}}function cE(i,e,t){return gg(e),typeof t=="object"&&t!==null?{type:String(i),callback:e??void 0,capture:!!t.capture}:{type:String(i),callback:e??void 0,capture:!!t}}function gg(i){if(!(typeof i=="function"||typeof i=="object"&&i!==null&&typeof i.handleEvent=="function")){if(i==null||typeof i=="object"){Gf.warn(i);return}throw new TypeError(rg(Gf.message,[i]))}}function pE(i,e,t,r){XR.warn(cg(i)?"capture":"bubble",i.callback),pg(i)!==e&&Dp.warn("passive"),ug(i)!==t&&Dp.warn("once"),i.signal!==r&&Dp.warn("signal")}var Np=Object.getOwnPropertyNames(pt.prototype);for(let i=0;i<Np.length;++i)Np[i]!=="constructor"&&Object.defineProperty(pt.prototype,Np[i],{enumerable:!0});typeof at<"u"&&typeof at.EventTarget<"u"&&Object.setPrototypeOf(pt.prototype,at.EventTarget.prototype);function Q(i,e){var t,r;return(r=(t=ni(i,"target")[e])===null||t===void 0?void 0:t.attrCallback)!==null&&r!==void 0?r:null}function Y(i,e,t){t!=null&&typeof t!="function"&&ZR.warn(t),typeof t=="function"||typeof t=="object"&&t!==null?uE(i,e,t):hE(i,e)}function uE(i,e,t){let r=vg(ni(i,"target"),String(e));r.attrCallback=t,r.attrListener==null&&(r.attrListener=dg(r,dE(r),!1,!1,!1,void 0))}function hE(i,e){let r=ni(i,"target")[String(e)];r&&r.attrListener&&(zp(r,r.attrListener.callback,!1),r.attrCallback=r.attrListener=void 0)}function dE(i){return function(e){let t=i.attrCallback;typeof t=="function"&&t.call(this,e)}}function mg(i,e){let t={...[].reduce.call(i,(r,n,s)=>(r[s]=n,r),{}),...e,length:i.length,[Symbol.iterator]:()=>[].slice.call(t)[Symbol.iterator]()};return t}var qt=Hf(yR()),Ep={AudioConfig:qt.AudioConfig,OutputFormat:qt.OutputFormat,ResultReason:qt.ResultReason,SpeechConfig:qt.SpeechConfig,SpeechRecognizer:qt.SpeechRecognizer};var{ResultReason:{RecognizingSpeech:dO,RecognizedSpeech:Tf}}=Ep;function Af(i,{maxAlternatives:e=1/0,textNormalization:t="display"}={}){if(i.reason===dO||i.reason===Tf&&!i.json.NBest){let r=[{confidence:.5,transcript:i.text}];return i.reason===Tf&&(r.isFinal=!0),r}else if(i.reason===Tf)return mg((i.json.NBest||[]).slice(0,e).map(({Confidence:n,Display:s,ITN:o,Lexical:a,MaskedITN:c})=>({confidence:n,transcript:t==="itn"?o:t==="lexical"?a:t==="maskeditn"?c:s})),{isFinal:!0});return[]}function Gn(){let i={};return i.promise=new Promise((e,t)=>{i.resolve=e,i.reject=t}),i}function CR(){let i,e=[];return{push:n=>{if(i){let{resolve:s}=i;i=null,s(n)}else e.push(n)},shift:()=>e.length?Promise.resolve(e.shift()):(i||(i=Gn())).promise}}function lO(i){return typeof i=="function"}function $n(i){return lO(i)?i():i}var PR=!0;function Qn({authorizationToken:i,credentials:e,looseEvent:t,looseEvents:r,region:n="westus",subscriptionKey:s,...o}={}){if(typeof t<"u"&&(console.warn('web-speech-cognitive-services: The option "looseEvent" should be named as "looseEvents".'),r=t),!e){if(!i&&!s)throw new Error("web-speech-cognitive-services: Credentials must be specified.");console.warn("web-speech-cognitive-services: We are deprecating authorizationToken, region, and subscriptionKey. Please use credentials instead. The deprecated option will be removed on or after 2020-11-14."),e=async()=>i?{authorizationToken:await $n(i),region:n}:{region:n,subscriptionKey:await $n(s)}}return{...o,fetchCredentials:async()=>{let{authorizationToken:a,customVoiceHostname:c,region:u,speechRecognitionHostname:h,speechSynthesisHostname:d,subscriptionKey:v}=await $n(e);if(!a&&!v||a&&v)throw new Error('web-speech-cognitive-services: Either "authorizationToken" or "subscriptionKey" must be provided.');if(!u&&!(h&&d))throw new Error('web-speech-cognitive-services: Either "region" or "speechRecognitionHostname" and "speechSynthesisHostname" must be set.');if(u&&(c||h||d))throw new Error('web-speech-cognitive-services: Only either "region" or "customVoiceHostname", "speechRecognitionHostname" and "speechSynthesisHostname" can be set.');if(a){if(typeof a!="string")throw new Error('web-speech-cognitive-services: "authorizationToken" must be a string.')}else if(typeof v!="string")throw new Error('web-speech-cognitive-services: "subscriptionKey" must be a string.');PR&&v&&(console.warn("web-speech-cognitive-services: In production environment, subscription key should not be used, authorization token should be used instead."),PR=!1);let g=a?{authorizationToken:a}:{subscriptionKey:v};return u?g.region=u:(g.customVoiceHostname=c,g.speechRecognitionHostname=h,g.speechSynthesisHostname=d),g},looseEvents:r}}var Hi=class{constructor(){this._phrases=[]}addFromString(){throw new Error("JSGF is not supported")}get phrases(){return this._phrases}set phrases(i){if(Array.isArray(i))this._phrases=i;else if(typeof i=="string")this._phrases=[i];else throw new Error("The provided value is not an array or of type 'string'")}};var{AudioConfig:vO,OutputFormat:fO,ResultReason:gO,SpeechConfig:Ip,SpeechRecognizer:ER}=Ep;function RR({duration:i,errorDetails:e,json:t,offset:r,properties:n,reason:s,resultId:o,text:a}){return{duration:i,errorDetails:e,json:JSON.parse(t),offset:r,properties:n,reason:s,resultId:o,text:a}}function mO(i){let e=new Int16Array(i);return[].reduce.call(e,(t,r)=>t+Math.abs(r),0)/e.length}function bf(i){return(...e)=>new Promise((t,r)=>i(...e,t,r))}var $=class extends Me{constructor(e,{data:t,emma:r,interpretation:n,resultIndex:s,results:o}={}){super(e),this.data=t,this.emma=r,this.interpretation=n,this.resultIndex=s,this.results=o}};function SO(i){let e=i.attach,t=i.attach.bind(i),r,n;return i.attach=async()=>{let s=await t();return{...s,read:async()=>{let o=await s.read();return!r&&mO(o.buffer)>150&&(i.events.onEvent({name:"FirstAudibleChunk"}),r=!0),n?{buffer:new ArrayBuffer(0),isEnd:!0,timeReceived:Date.now()}:o}}},{audioConfig:i,pause:()=>{n=!0},unprepare:()=>{i.attach=e}}}function Ki({createRecognizer:i,enableTelemetry:e,looseEvents:t,referenceGrammars:r,textNormalization:n}){ER.enableTelemetry(e!==!1);class s extends pt{constructor(){super(),this._continuous=!1,this._interimResults=!1,this._lang=typeof window<"u"?window.document.documentElement.getAttribute("lang")||window.navigator.language:"en-US",this._grammars=new Hi,this._maxAlternatives=1}emitCognitiveServices(a,c){this.dispatchEvent(new $("cognitiveservices",{data:{...c,type:a}}))}get continuous(){return this._continuous}set continuous(a){this._continuous=a}get grammars(){return this._grammars}set grammars(a){if(a instanceof Hi)this._grammars=a;else throw new Error("The provided value is not of type 'SpeechGrammarList'")}get interimResults(){return this._interimResults}set interimResults(a){this._interimResults=a}get maxAlternatives(){return this._maxAlternatives}set maxAlternatives(a){this._maxAlternatives=a}get lang(){return this._lang}set lang(a){this._lang=a}get onaudioend(){return Q(this,"audioend")}set onaudioend(a){Y(this,"audioend",a)}get onaudiostart(){return Q(this,"audiostart")}set onaudiostart(a){Y(this,"audiostart",a)}get oncognitiveservices(){return Q(this,"cognitiveservices")}set oncognitiveservices(a){Y(this,"cognitiveservices",a)}get onend(){return Q(this,"end")}set onend(a){Y(this,"end",a)}get onerror(){return Q(this,"error")}set onerror(a){Y(this,"error",a)}get onresult(){return Q(this,"result")}set onresult(a){Y(this,"result",a)}get onsoundend(){return Q(this,"soundend")}set onsoundend(a){Y(this,"soundend",a)}get onsoundstart(){return Q(this,"soundstart")}set onsoundstart(a){Y(this,"soundstart",a)}get onspeechend(){return Q(this,"speechend")}set onspeechend(a){Y(this,"speechend",a)}get onspeechstart(){return Q(this,"speechstart")}set onspeechstart(a){Y(this,"speechstart",a)}get onstart(){return Q(this,"start")}set onstart(a){Y(this,"start",a)}start(){this._startOnce().catch(a=>{this.dispatchEvent(new ErrorEvent("error",{error:a,message:a&&(a.stack||a.message)}))})}async _startOnce(){let a=await i(this.lang),{pause:c,unprepare:u}=SO(a.audioConfig);try{let h=CR(),d,v,g,{detach:w}=a.audioConfig.events.attach(F=>{let{name:K}=F;K==="AudioSourceReadyEvent"?h.push({audioSourceReady:{}}):K==="AudioSourceOffEvent"?h.push({audioSourceOff:{}}):K==="FirstAudibleChunk"&&h.push({firstAudibleChunk:{}})});a.canceled=(F,{errorDetails:K,offset:ot,reason:Pr,sessionId:Ap})=>{h.push({canceled:{errorDetails:K,offset:ot,reason:Pr,sessionId:Ap}})},a.recognized=(F,{offset:K,result:ot,sessionId:Pr})=>{h.push({recognized:{offset:K,result:RR(ot),sessionId:Pr}})},a.recognizing=(F,{offset:K,result:ot,sessionId:Pr})=>{h.push({recognizing:{offset:K,result:RR(ot),sessionId:Pr}})},a.sessionStarted=(F,{sessionId:K})=>{h.push({sessionStarted:{sessionId:K}})},a.sessionStopped=(F,{sessionId:K})=>{h.push({sessionStopped:{sessionId:K}})},a.speechStartDetected=(F,{offset:K,sessionId:ot})=>{h.push({speechStartDetected:{offset:K,sessionId:ot}})},a.speechEndDetected=(F,{sessionId:K})=>{h.push({speechEndDetected:{sessionId:K}})};let{phrases:k}=this.grammars,{dynamicGrammar:ae}=a.privReco;r&&r.length&&ae.addReferenceGrammar(r),k&&k.length&&ae.addPhrase(k),await bf(a.startContinuousRecognitionAsync.bind(a))(),a.stopContinuousRecognitionAsync?(this.abort=()=>h.push({abort:{}}),this.stop=()=>h.push({stop:{}})):this.abort=this.stop=void 0;let Z,U,Oe=[];for(let F=0;!g||Z;F++){let K=await h.shift(),{abort:ot,audioSourceOff:Pr,audioSourceReady:Ap,canceled:Uf,firstAudibleChunk:jR,recognized:ri,recognizing:bp,stop:LR}=K;Object.keys(K).forEach($i=>this.emitCognitiveServices($i,K[$i]));let Op=Uf&&Uf.errorDetails;if(/Permission\sdenied/u.test(Op||"")){U={error:"not-allowed",type:"error"};break}if(F||this.dispatchEvent(new $("start")),Op){/1006/u.test(Op)?(Z||(this.dispatchEvent(new $("audiostart")),this.dispatchEvent(new $("audioend"))),U={error:"network",type:"error"}):U={error:"unknown",type:"error"};break}else if(ot||LR)ot?(U={error:"aborted",type:"error"},g="abort"):(c(),g="stop"),ot&&a.stopContinuousRecognitionAsync&&await bf(a.stopContinuousRecognitionAsync.bind(a))();else if(Ap)this.dispatchEvent(new $("audiostart")),Z=!0;else if(jR)this.dispatchEvent(new $("soundstart")),d=!0;else if(Pr){v&&this.dispatchEvent(new $("speechend")),d&&this.dispatchEvent(new $("soundend")),Z&&this.dispatchEvent(new $("audioend")),Z=d=v=!1;break}else if(g!=="abort"){if(ri&&ri.result&&ri.result.reason===gO.NoMatch)U={error:"no-speech",type:"error"};else if(ri||bp)if(Z||(this.dispatchEvent(new $("audiostart")),Z=!0),d||(this.dispatchEvent(new $("soundstart")),d=!0),v||(this.dispatchEvent(new $("speechstart")),v=!0),ri){let $i=Af(ri.result,{maxAlternatives:this.maxAlternatives,textNormalization:n}),Mp=!!$i[0].transcript;Mp&&(Oe=[...Oe,$i],this.continuous&&this.dispatchEvent(new $("result",{results:Oe}))),this.continuous&&Mp?U=null:U={results:Oe,type:"result"},!this.continuous&&a.stopContinuousRecognitionAsync&&await bf(a.stopContinuousRecognitionAsync.bind(a))(),t&&U&&Mp&&(this.dispatchEvent(new $(U.type,U)),U=null)}else bp&&this.interimResults&&this.dispatchEvent(new $("result",{results:[...Oe,Af(bp.result,{maxAlternatives:this.maxAlternatives,textNormalization:n})]}))}}v&&this.dispatchEvent(new $("speechend")),d&&this.dispatchEvent(new $("soundend")),Z&&this.dispatchEvent(new $("audioend")),U&&(U.type==="result"&&!U.results.length&&(U={error:"no-speech",type:"error"}),U.type==="error"?this.dispatchEvent(new ErrorEvent("error",U)):this.dispatchEvent(new $(U.type,U))),this.dispatchEvent(new $("end")),w()}catch(h){throw console.error(h),h}finally{u(),a.dispose()}}}return{SpeechGrammarList:Hi,SpeechRecognition:s,SpeechRecognitionEvent:$}}var IR=i=>{let{audioConfig:e=vO.fromDefaultMicrophoneInput(),enableTelemetry:t=!0,fetchCredentials:r,looseEvents:n,referenceGrammars:s,speechRecognitionEndpointId:o,textNormalization:a="display"}=Qn(i);return!e&&(!window.navigator.mediaDevices||!window.navigator.mediaDevices.getUserMedia)?(console.warn("web-speech-cognitive-services: This browser does not support WebRTC and it will not work with Cognitive Services Speech Services."),{}):Ki({audioConfig:e,createRecognizer:async u=>{let{authorizationToken:h,region:d,speechRecognitionHostname:v,subscriptionKey:g}=await r(),w;if(v){let k={hostname:v,port:443,protocol:"wss:"};h?(w=Ip.fromHost(k),w.authorizationToken=h):w=Ip.fromHost(k,g)}else w=h?Ip.fromAuthorizationToken(h,d):Ip.fromSubscription(g,d);return o&&(w.endpointId=o),w.outputFormat=fO.Detailed,w.speechRecognitionLanguage=u||"en-US",new ER(w,e)},enableTelemetry:t,looseEvents:n,referenceGrammars:s,textNormalization:a})};var Of=IR;function wR(i){return!!((typeof i=="function"||typeof i=="object")&&i&&"then"in i&&typeof i.then=="function")}function Mf(i,e){return new Promise(t=>{try{let r=i.call(e);wR(r)?r.then(t,()=>t(void 0)):t(r)}catch{t(void 0)}})}var _R=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function yO(i,e){return!!(i===e||_R(i)&&_R(e))}function CO(i,e){if(i.length!==e.length)return!1;for(var t=0;t<i.length;t++)if(!yO(i[t],e[t]))return!1;return!0}function TR(i,e){e===void 0&&(e=CO);var t=null;function r(){for(var n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];if(t&&t.lastThis===this&&e(n,t.lastArgs))return t.lastResult;var o=i.apply(this,n);return t={lastResult:o,lastArgs:n,lastThis:this},o}return r.clear=function(){t=null},r}var wp=class{constructor(i){this.audioContext=i}pause(){this.audioContext&&this.audioContext.suspend(),this.playingUtterance&&this.playingUtterance.dispatchEvent(new CustomEvent("pause"))}resume(){this.audioContext&&this.audioContext.resume(),this.playingUtterance&&this.playingUtterance.dispatchEvent(new CustomEvent("resume"))}async start(i){let e;for(;e=i.shift();)this.playingUtterance=e,await e.play(this.audioContext),this.playingUtterance=null}stop(){this.playingUtterance&&this.playingUtterance.stop(),this.audioContext.state==="suspended"&&this.audioContext.resume()}};var _p=class{constructor({audioContext:i,ponyfill:e}){this.consumer=null,this.paused=!1,this.queue=[],this.getAudioContext=TR(()=>i||new e.AudioContext)}pause(){this.paused=!0,this.consumer&&this.consumer.pause()}push(i){this.queue.push(i),this.startConsumer()}resume(){this.paused=!1,this.consumer?this.consumer.resume():this.startConsumer()}get speaking(){return!!this.consumer}async startConsumer(){for(;!this.paused&&this.queue.length&&!this.consumer;)this.consumer=new wp(this.getAudioContext()),await this.consumer.start(this.queue),this.consumer=null}stop(){this.queue.splice(0),this.consumer&&this.consumer.stop()}};var Xt=class extends Me{constructor(e){super(e)}};var zf=Hf(DR());var kR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Xn=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(Yn=0;Yn<kR.length;Yn++)Xn[kR.charCodeAt(Yn)]=Yn;var Yn;var NR=function(i){var e=i.length*.75,t=i.length,r,n=0,s,o,a,c;i[i.length-1]==="="&&(e--,i[i.length-2]==="="&&e--);var u=new ArrayBuffer(e),h=new Uint8Array(u);for(r=0;r<t;r+=4)s=Xn[i.charCodeAt(r)],o=Xn[i.charCodeAt(r+1)],a=Xn[i.charCodeAt(r+2)],c=Xn[i.charCodeAt(r+3)],h[n++]=s<<2|o>>4,h[n++]=(o&15)<<4|a>>2,h[n++]=(a&3)<<6|c&63;return u};function kf(i){let e=Math.round((i-1)*100);return e>=0&&(e="+"+e),e+"%"}function Nf({lang:i,pitch:e=1,rate:t=1,text:r,voice:n,volume:s}){return`<speak version="1.0" xml:lang="${i}">
25
25
  <voice xml:lang="${i}" name="${n}">
26
- <prosody pitch="${xf(e)}" rate="${xf(t)}" volume="${xf(s)}">
26
+ <prosody pitch="${kf(e)}" rate="${kf(t)}" volume="${kf(s)}">
27
27
  ${r}
28
28
  </prosody>
29
29
  </voice>
30
- </speak>`}var bO=/^\s*<speak(\s|\/?>)/u,OO=/^\s*<\?xml\s/u;function jf(i){return bO.test(i)||OO.test(i)}var MO="en-US",DO="riff-16khz-16bit-mono-pcm",kO="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)",NO="SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU3LjU2LjEwMQAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU3LjY0AAAAAAAAAAAAAAAAJAUHAAAAAAAAAYYoRBqpAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy45OS41VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMQpg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";async function jR({deploymentId:i,fetchCredentials:e,lang:t=MO,outputFormat:r=DO,pitch:n,rate:s,text:o,voice:a=kO,volume:c}){if(!o)return zR(NO);let{authorizationToken:u,region:h,speechSynthesisHostname:d,subscriptionKey:v}=await e();if(u&&v||!u&&!v)throw new Error('Only "authorizationToken" or "subscriptionKey" should be set.');if(h&&d||!h&&!d)throw new Error('Only "region" or "speechSynthesisHostnamename" should be set.');let g=jf(o)?o:zf({lang:t,pitch:n,rate:s,text:o,voice:a,volume:c}),w=d||(i?`${encodeURI(h)}.voice.speech.microsoft.com`:`${encodeURI(h)}.tts.speech.microsoft.com`),k=i?`?deploymentId=${encodeURI(i)}`:"",ae=`https://${w}/cognitiveservices/v1${k}`,Z=await fetch(ae,{headers:{"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":r,...u?{Authorization:`Bearer ${u}`}:{"Ocp-Apim-Subscription-Key":v}},method:"POST",body:g});if(!Z.ok)throw new Error(`web-speech-cognitive-services: Failed to syntheis speech, server returned ${Z.status}`);return Z.arrayBuffer()}function Lf(i,e,t){return i.addEventListener(e,t),()=>i.removeEventListener(e,t)}function qO(i,e){return new Promise((t,r)=>{let n=i.decodeAudioData(e,t,r);n&&typeof n.then=="function"&&t(n)})}function xO(i,e,t){return new Promise((r,n)=>{let s=new Bf.default,o=new Bf.default,a=Lf(i,"statechange",({target:{state:c}})=>c==="closed"&&s.eventListener());try{t.buffer=e,t.onended=o.eventListener,t.connect(i.destination),t.start(0),Promise.race([s.upcoming(),o.upcoming()]).then(r)}catch(c){n(c)}finally{a()}})}var Ff=class extends pt{constructor(e){super(),this._lang=null,this._pitch=1,this._rate=1,this._voice=null,this._volume=1,this.text=e,this.onboundary=null,this.onend=null,this.onerror=null,this.onmark=null,this.onpause=null,this.onresume=null,this.onstart=null}get lang(){return this._lang}set lang(e){this._lang=e}get onboundary(){return Q(this,"boundary")}set onboundary(e){Y(this,"boundary",e)}get onend(){return Q(this,"end")}set onend(e){Y(this,"end",e)}get onerror(){return Q(this,"error")}set onerror(e){Y(this,"error",e)}get onmark(){return Q(this,"mark")}set onmark(e){Y(this,"mark",e)}get onpause(){return Q(this,"pause")}set onpause(e){Y(this,"pause",e)}get onresume(){return Q(this,"resume")}set onresume(e){Y(this,"resume",e)}get onstart(){return Q(this,"start")}set onstart(e){Y(this,"start",e)}get pitch(){return this._pitch}set pitch(e){this._pitch=e}get rate(){return this._rate}set rate(e){this._rate=e}get voice(){return this._voice}set voice(e){this._voice=e}get volume(){return this._volume}set volume(e){this._volume=e}preload({deploymentId:e,fetchCredentials:t,outputFormat:r}){this.arrayBufferPromise=jR({fetchCredentials:t,deploymentId:e,lang:this.lang||window.navigator.language,outputFormat:r,pitch:this.pitch,rate:this.rate,text:this.text,voice:this.voice&&this.voice.voiceURI,volume:this.volume}),this.arrayBufferPromise.catch()}async play(e){try{this.dispatchEvent(new Xt("start"));let t=e.createBufferSource(),r=await qO(e,await this.arrayBufferPromise);this._playingSource=t,await xO(e,r,t),this._playingSource=null,this.dispatchEvent(new Xt("end"))}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:"synthesis-failed",message:t.stack}))}}stop(){this._playingSource&&this._playingSource.stop()}},Vf=Ff;var zO="audio-24khz-160kbitrate-mono-mp3",jO=[],LR=i=>{let{audioContext:e,fetchCredentials:t,ponyfill:r={AudioContext:window.AudioContext||window.webkitAudioContext},speechSynthesisDeploymentId:n,speechSynthesisOutputFormat:s=zO}=Qn(i);if(!e&&!r.AudioContext)return console.warn("web-speech-cognitive-services: This browser does not support Web Audio and it will not work with Cognitive Services Speech Services."),{};class o extends pt{constructor(){super(),this.queue=new Tp({audioContext:e,ponyfill:r}),this.updateVoices()}cancel(){this.queue.stop()}getVoices(){return jO}get onvoiceschanged(){return Q(this,"voiceschanged")}set onvoiceschanged(c){Y(this,"voiceschanged",c)}pause(){this.queue.pause()}resume(){this.queue.resume()}speak(c){if(!(c instanceof Vf))throw new Error("invalid utterance");let{reject:u,resolve:h,promise:d}=Gn(),v=({error:g,message:w})=>{let k=new Error(g);k.stack=w,u(k)};return c.addEventListener("end",h),c.addEventListener("error",v),c.preload({deploymentId:n,fetchCredentials:t,outputFormat:s}),this.queue.push(c),d.finally(()=>{c.removeEventListener("end",h),c.removeEventListener("error",v)})}get speaking(){return this.queue.speaking}async updateVoices(){let{customVoiceHostname:c,region:u,speechSynthesisHostname:h,subscriptionKey:d}=await t();n?d&&(console.warn("web-speech-cognitive-services: Listing of custom voice models are only available when using subscription key."),await(0,Uf.default)(async()=>{let v=await OR({customVoiceHostname:c,deploymentId:n,region:u,speechSynthesisHostname:h,subscriptionKey:d});this.getVoices=()=>v})):await(0,Uf.default)(async()=>{let v=await Nf(await t());this.getVoices=()=>v}),this.dispatchEvent(new Xt("voiceschanged"))}}return{speechSynthesis:new o,SpeechSynthesisEvent:Xt,SpeechSynthesisUtterance:Vf}};var Wf=LR;function Ap(i={},...e){return{...Df(i,...e),...Wf(i,...e)}}var Hf=document.createElement("meta");Hf.setAttribute("name","web-speech-cognitive-services");Hf.setAttribute("content","version=8.0.0-main.478b2e9");document.head.appendChild(Hf);globalThis.WebSpeechCognitiveServices={create:Ap,createSpeechRecognitionPonyfillFromRecognizer:Ki};})();
30
+ </speak>`}var wO=/^\s*<speak(\s|\/?>)/u,_O=/^\s*<\?xml\s/u;function qf(i){return wO.test(i)||_O.test(i)}var TO="en-US",AO="riff-16khz-16bit-mono-pcm",bO="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)",OO="SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU3LjU2LjEwMQAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU3LjY0AAAAAAAAAAAAAAAAJAUHAAAAAAAAAYYoRBqpAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy45OS41VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMQpg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";async function qR({deploymentId:i,fetchCredentials:e,lang:t=TO,outputFormat:r=AO,pitch:n,rate:s,text:o,voice:a=bO,volume:c}){if(!o)return NR(OO);let{authorizationToken:u,region:h,speechSynthesisHostname:d,subscriptionKey:v}=await e();if(u&&v||!u&&!v)throw new Error('Only "authorizationToken" or "subscriptionKey" should be set.');if(h&&d||!h&&!d)throw new Error('Only "region" or "speechSynthesisHostnamename" should be set.');let g=qf(o)?o:Nf({lang:t,pitch:n,rate:s,text:o,voice:a,volume:c}),w=d||(i?`${encodeURI(h)}.voice.speech.microsoft.com`:`${encodeURI(h)}.tts.speech.microsoft.com`),k=i?`?deploymentId=${encodeURI(i)}`:"",ae=`https://${w}/cognitiveservices/v1${k}`,Z=await fetch(ae,{headers:{"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":r,...u?{Authorization:`Bearer ${u}`}:{"Ocp-Apim-Subscription-Key":v}},method:"POST",body:g});if(!Z.ok)throw new Error(`web-speech-cognitive-services: Failed to syntheis speech, server returned ${Z.status}`);return Z.arrayBuffer()}function xf(i,e,t){return i.addEventListener(e,t),()=>i.removeEventListener(e,t)}function MO(i,e){return new Promise((t,r)=>{let n=i.decodeAudioData(e,t,r);n&&typeof n.then=="function"&&t(n)})}function DO(i,e,t){return new Promise((r,n)=>{let s=new zf.default,o=new zf.default,a=xf(i,"statechange",({target:{state:c}})=>c==="closed"&&s.eventListener());try{t.buffer=e,t.onended=o.eventListener,t.connect(i.destination),t.start(0),Promise.race([s.upcoming(),o.upcoming()]).then(r)}catch(c){n(c)}finally{a()}})}var jf=class extends pt{constructor(e){super(),this._lang=null,this._pitch=1,this._rate=1,this._voice=null,this._volume=1,this.text=e,this.onboundary=null,this.onend=null,this.onerror=null,this.onmark=null,this.onpause=null,this.onresume=null,this.onstart=null}get lang(){return this._lang}set lang(e){this._lang=e}get onboundary(){return Q(this,"boundary")}set onboundary(e){Y(this,"boundary",e)}get onend(){return Q(this,"end")}set onend(e){Y(this,"end",e)}get onerror(){return Q(this,"error")}set onerror(e){Y(this,"error",e)}get onmark(){return Q(this,"mark")}set onmark(e){Y(this,"mark",e)}get onpause(){return Q(this,"pause")}set onpause(e){Y(this,"pause",e)}get onresume(){return Q(this,"resume")}set onresume(e){Y(this,"resume",e)}get onstart(){return Q(this,"start")}set onstart(e){Y(this,"start",e)}get pitch(){return this._pitch}set pitch(e){this._pitch=e}get rate(){return this._rate}set rate(e){this._rate=e}get voice(){return this._voice}set voice(e){this._voice=e}get volume(){return this._volume}set volume(e){this._volume=e}preload({deploymentId:e,fetchCredentials:t,outputFormat:r}){this.arrayBufferPromise=qR({fetchCredentials:t,deploymentId:e,lang:this.lang||window.navigator.language,outputFormat:r,pitch:this.pitch,rate:this.rate,text:this.text,voice:this.voice&&this.voice.voiceURI,volume:this.volume}),this.arrayBufferPromise.catch()}async play(e){try{this.dispatchEvent(new Xt("start"));let t=e.createBufferSource(),r=await MO(e,await this.arrayBufferPromise);this._playingSource=t,await DO(e,r,t),this._playingSource=null,this.dispatchEvent(new Xt("end"))}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:"synthesis-failed",message:t.stack}))}}stop(){this._playingSource&&this._playingSource.stop()}},Lf=jf;var Gi=class{constructor({gender:i,lang:e,voiceURI:t}){this._default=!1,this._gender=i,this._lang=e,this._localService=!1,this._name=t,this._voiceURI=t}get default(){return this._default}get gender(){return this._gender}get lang(){return this._lang}get localService(){return this._localService}get name(){return this._name}get voiceURI(){return this._voiceURI}};async function kO({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r}){let n=i||`${t}.customvoice.api.speech.microsoft.com`,s=await fetch(`https://${encodeURI(n)}/api/texttospeech/v2.0/endpoints/${encodeURIComponent(e)}`,{headers:{accept:"application/json","ocp-apim-subscription-key":r}});if(!s.ok)throw new Error("Failed to fetch custom voices");return s.json()}async function xR({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r}){let{models:n}=await kO({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r});return n.map(({properties:{Gender:s},locale:o,name:a})=>new Gi({gender:s,lang:o,voiceURI:a})).sort(({name:s},{name:o})=>s>o?1:s<o?-1:0)}async function Bf({authorizationToken:i,region:e,speechSynthesisHostname:t,subscriptionKey:r}){let n=t||`${encodeURI(e)}.tts.speech.microsoft.com`,s=await fetch(`https://${n}/cognitiveservices/voices/list`,{headers:{"content-type":"application/json",...i?{authorization:`Bearer ${i}`}:{"Ocp-Apim-Subscription-Key":r}}});if(!s.ok)throw new Error("Failed to fetch voices");return(await s.json()).map(({Gender:a,Locale:c,Name:u})=>new Gi({gender:a,lang:c,voiceURI:u})).sort(({name:a},{name:c})=>a>c?1:a<c?-1:0)}var NO="audio-24khz-160kbitrate-mono-mp3",qO=[],zR=i=>{let{audioContext:e,fetchCredentials:t,ponyfill:r={AudioContext:window.AudioContext||window.webkitAudioContext},speechSynthesisDeploymentId:n,speechSynthesisOutputFormat:s=NO}=Qn(i);if(!e&&!r.AudioContext)return console.warn("web-speech-cognitive-services: This browser does not support Web Audio and it will not work with Cognitive Services Speech Services."),{};class o extends pt{constructor(){super(),this.queue=new _p({audioContext:e,ponyfill:r}),this.updateVoices()}cancel(){this.queue.stop()}getVoices(){return qO}get onvoiceschanged(){return Q(this,"voiceschanged")}set onvoiceschanged(c){Y(this,"voiceschanged",c)}pause(){this.queue.pause()}resume(){this.queue.resume()}speak(c){if(!(c instanceof Lf))throw new Error("invalid utterance");let{reject:u,resolve:h,promise:d}=Gn(),v=({error:g,message:w})=>{let k=new Error(g);k.stack=w,u(k)};return c.addEventListener("end",h),c.addEventListener("error",v),c.preload({deploymentId:n,fetchCredentials:t,outputFormat:s}),this.queue.push(c),d.finally(()=>{c.removeEventListener("end",h),c.removeEventListener("error",v)})}get speaking(){return this.queue.speaking}async updateVoices(){let{customVoiceHostname:c,region:u,speechSynthesisHostname:h,subscriptionKey:d}=await t();n?d&&(console.warn("web-speech-cognitive-services: Listing of custom voice models are only available when using subscription key."),await Mf(async()=>{let v=await xR({customVoiceHostname:c,deploymentId:n,region:u,speechSynthesisHostname:h,subscriptionKey:d});this.getVoices=()=>v})):await Mf(async()=>{let v=await Bf(await t());this.getVoices=()=>v}),this.dispatchEvent(new Xt("voiceschanged"))}}return{speechSynthesis:new o,SpeechSynthesisEvent:Xt,SpeechSynthesisUtterance:Lf}};var Ff=zR;function Tp(i={},...e){return{...Of(i,...e),...Ff(i,...e)}}var Vf=document.createElement("meta");Vf.setAttribute("name","web-speech-cognitive-services");Vf.setAttribute("content","version=8.0.0-main.aa5b13b");document.head.appendChild(Vf);globalThis.WebSpeechCognitiveServices={create:Tp,createSpeechRecognitionPonyfillFromRecognizer:Ki};})();
31
31
  //# sourceMappingURL=web-speech-cognitive-services.production.min.js.map