web-speech-cognitive-services 8.0.0-main.d9ef940 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web-speech-cognitive-services.d.mts +151 -139
- package/dist/web-speech-cognitive-services.d.ts +151 -139
- package/dist/web-speech-cognitive-services.development.js +16 -11
- package/dist/web-speech-cognitive-services.development.js.map +1 -1
- package/dist/web-speech-cognitive-services.js +17 -12
- package/dist/web-speech-cognitive-services.js.map +1 -1
- package/dist/web-speech-cognitive-services.mjs +17 -12
- package/dist/web-speech-cognitive-services.mjs.map +1 -1
- package/dist/web-speech-cognitive-services.production.min.js +11 -11
- package/dist/web-speech-cognitive-services.production.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";(()=>{var FR=Object.create;var Zf=Object.defineProperty;var VR=Object.getOwnPropertyDescriptor;var UR=Object.getOwnPropertyNames;var WR=Object.getPrototypeOf,HR=Object.prototype.hasOwnProperty;var p=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var KR=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of UR(e))!HR.call(i,n)&&n!==t&&Zf(i,n,{get:()=>e[n],enumerable:!(r=VR(e,n))||r.enumerable});return i};var eg=(i,e,t)=>(t=i!=null?FR(WR(i)):{},KR(e||!i||!i.__esModule?Zf(t,"default",{value:i,enumerable:!0}):t,i));var Fp=p(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});Bp.default=$R;var os,GR=new Uint8Array(16);function $R(){if(!os&&(os=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!os))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return os(GR)}});var rg=p(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.default=void 0;var QR=/^(?:[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;as.default=QR});var sn=p(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.default=void 0;var YR=XR(rg());function XR(i){return i&&i.__esModule?i:{default:i}}function ZR(i){return typeof i=="string"&&YR.default.test(i)}var eE=ZR;cs.default=eE});var an=p(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.default=void 0;on.unsafeStringify=ig;var tE=rE(sn());function rE(i){return i&&i.__esModule?i:{default:i}}var ue=[];for(let i=0;i<256;++i)ue.push((i+256).toString(16).slice(1));function ig(i,e=0){return ue[i[e+0]]+ue[i[e+1]]+ue[i[e+2]]+ue[i[e+3]]+"-"+ue[i[e+4]]+ue[i[e+5]]+"-"+ue[i[e+6]]+ue[i[e+7]]+"-"+ue[i[e+8]]+ue[i[e+9]]+"-"+ue[i[e+10]]+ue[i[e+11]]+ue[i[e+12]]+ue[i[e+13]]+ue[i[e+14]]+ue[i[e+15]]}function iE(i,e=0){let t=ig(i,e);if(!(0,tE.default)(t))throw TypeError("Stringified UUID is invalid");return t}var nE=iE;on.default=nE});var sg=p(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.default=void 0;var sE=aE(Fp()),oE=an();function aE(i){return i&&i.__esModule?i:{default:i}}var ng,Vp,Up=0,Wp=0;function cE(i,e,t){let r=e&&t||0,n=e||new Array(16);i=i||{};let s=i.node||ng,o=i.clockseq!==void 0?i.clockseq:Vp;if(s==null||o==null){let l=i.random||(i.rng||sE.default)();s==null&&(s=ng=[l[0]|1,l[1],l[2],l[3],l[4],l[5]]),o==null&&(o=Vp=(l[6]<<8|l[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 d=((a&268435455)*1e4+c)%4294967296;n[r++]=d>>>24&255,n[r++]=d>>>16&255,n[r++]=d>>>8&255,n[r++]=d&255;let h=a/4294967296*1e4&268435455;n[r++]=h>>>8&255,n[r++]=h&255,n[r++]=h>>>24&15|16,n[r++]=h>>>16&255,n[r++]=o>>>8|128,n[r++]=o&255;for(let l=0;l<6;++l)n[r+l]=s[l];return e||(0,oE.unsafeStringify)(n)}var pE=cE;ps.default=pE});var Hp=p(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.default=void 0;var uE=dE(sn());function dE(i){return i&&i.__esModule?i:{default:i}}function hE(i){if(!(0,uE.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 lE=hE;us.default=lE});var Kp=p(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.URL=Ir.DNS=void 0;Ir.default=SE;var vE=an(),fE=gE(Hp());function gE(i){return i&&i.__esModule?i:{default:i}}function mE(i){i=unescape(encodeURIComponent(i));let e=[];for(let t=0;t<i.length;++t)e.push(i.charCodeAt(t));return e}var og="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Ir.DNS=og;var ag="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Ir.URL=ag;function SE(i,e,t){function r(n,s,o,a){var c;if(typeof n=="string"&&(n=mE(n)),typeof s=="string"&&(s=(0,fE.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 d=0;d<16;++d)o[a+d]=u[d];return o}return(0,vE.unsafeStringify)(u)}try{r.name=i}catch{}return r.DNS=og,r.URL=ag,r}});var pg=p(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.default=void 0;function yE(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 CE(PE(RE(i),i.length*8))}function CE(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 cg(i){return(i+64>>>9<<4)+14+1}function PE(i,e){i[e>>5]|=128<<e%32,i[cg(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,d=s;t=Ce(t,r,n,s,i[o],7,-680876936),s=Ce(s,t,r,n,i[o+1],12,-389564586),n=Ce(n,s,t,r,i[o+2],17,606105819),r=Ce(r,n,s,t,i[o+3],22,-1044525330),t=Ce(t,r,n,s,i[o+4],7,-176418897),s=Ce(s,t,r,n,i[o+5],12,1200080426),n=Ce(n,s,t,r,i[o+6],17,-1473231341),r=Ce(r,n,s,t,i[o+7],22,-45705983),t=Ce(t,r,n,s,i[o+8],7,1770035416),s=Ce(s,t,r,n,i[o+9],12,-1958414417),n=Ce(n,s,t,r,i[o+10],17,-42063),r=Ce(r,n,s,t,i[o+11],22,-1990404162),t=Ce(t,r,n,s,i[o+12],7,1804603682),s=Ce(s,t,r,n,i[o+13],12,-40341101),n=Ce(n,s,t,r,i[o+14],17,-1502002290),r=Ce(r,n,s,t,i[o+15],22,1236535329),t=Pe(t,r,n,s,i[o+1],5,-165796510),s=Pe(s,t,r,n,i[o+6],9,-1069501632),n=Pe(n,s,t,r,i[o+11],14,643717713),r=Pe(r,n,s,t,i[o],20,-373897302),t=Pe(t,r,n,s,i[o+5],5,-701558691),s=Pe(s,t,r,n,i[o+10],9,38016083),n=Pe(n,s,t,r,i[o+15],14,-660478335),r=Pe(r,n,s,t,i[o+4],20,-405537848),t=Pe(t,r,n,s,i[o+9],5,568446438),s=Pe(s,t,r,n,i[o+14],9,-1019803690),n=Pe(n,s,t,r,i[o+3],14,-187363961),r=Pe(r,n,s,t,i[o+8],20,1163531501),t=Pe(t,r,n,s,i[o+13],5,-1444681467),s=Pe(s,t,r,n,i[o+2],9,-51403784),n=Pe(n,s,t,r,i[o+7],14,1735328473),r=Pe(r,n,s,t,i[o+12],20,-1926607734),t=Re(t,r,n,s,i[o+5],4,-378558),s=Re(s,t,r,n,i[o+8],11,-2022574463),n=Re(n,s,t,r,i[o+11],16,1839030562),r=Re(r,n,s,t,i[o+14],23,-35309556),t=Re(t,r,n,s,i[o+1],4,-1530992060),s=Re(s,t,r,n,i[o+4],11,1272893353),n=Re(n,s,t,r,i[o+7],16,-155497632),r=Re(r,n,s,t,i[o+10],23,-1094730640),t=Re(t,r,n,s,i[o+13],4,681279174),s=Re(s,t,r,n,i[o],11,-358537222),n=Re(n,s,t,r,i[o+3],16,-722521979),r=Re(r,n,s,t,i[o+6],23,76029189),t=Re(t,r,n,s,i[o+9],4,-640364487),s=Re(s,t,r,n,i[o+12],11,-421815835),n=Re(n,s,t,r,i[o+15],16,530742520),r=Re(r,n,s,t,i[o+2],23,-995338651),t=Ee(t,r,n,s,i[o],6,-198630844),s=Ee(s,t,r,n,i[o+7],10,1126891415),n=Ee(n,s,t,r,i[o+14],15,-1416354905),r=Ee(r,n,s,t,i[o+5],21,-57434055),t=Ee(t,r,n,s,i[o+12],6,1700485571),s=Ee(s,t,r,n,i[o+3],10,-1894986606),n=Ee(n,s,t,r,i[o+10],15,-1051523),r=Ee(r,n,s,t,i[o+1],21,-2054922799),t=Ee(t,r,n,s,i[o+8],6,1873313359),s=Ee(s,t,r,n,i[o+15],10,-30611744),n=Ee(n,s,t,r,i[o+6],15,-1560198380),r=Ee(r,n,s,t,i[o+13],21,1309151649),t=Ee(t,r,n,s,i[o+4],6,-145523070),s=Ee(s,t,r,n,i[o+11],10,-1120210379),n=Ee(n,s,t,r,i[o+2],15,718787259),r=Ee(r,n,s,t,i[o+9],21,-343485551),t=rr(t,a),r=rr(r,c),n=rr(n,u),s=rr(s,d)}return[t,r,n,s]}function RE(i){if(i.length===0)return[];let e=i.length*8,t=new Uint32Array(cg(e));for(let r=0;r<e;r+=8)t[r>>5]|=(i[r/8]&255)<<r%32;return t}function rr(i,e){let t=(i&65535)+(e&65535);return(i>>16)+(e>>16)+(t>>16)<<16|t&65535}function EE(i,e){return i<<e|i>>>32-e}function ds(i,e,t,r,n,s){return rr(EE(rr(rr(e,i),rr(r,s)),n),t)}function Ce(i,e,t,r,n,s,o){return ds(e&t|~e&r,i,e,n,s,o)}function Pe(i,e,t,r,n,s,o){return ds(e&r|t&~r,i,e,n,s,o)}function Re(i,e,t,r,n,s,o){return ds(e^t^r,i,e,n,s,o)}function Ee(i,e,t,r,n,s,o){return ds(t^(e|~r),i,e,n,s,o)}var wE=yE;hs.default=wE});var dg=p(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.default=void 0;var IE=ug(Kp()),TE=ug(pg());function ug(i){return i&&i.__esModule?i:{default:i}}var _E=(0,IE.default)("v3",48,TE.default),AE=_E;ls.default=AE});var hg=p(vs=>{"use strict";Object.defineProperty(vs,"__esModule",{value:!0});vs.default=void 0;var bE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),OE={randomUUID:bE};vs.default=OE});var fg=p(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.default=void 0;var lg=vg(hg()),ME=vg(Fp()),DE=an();function vg(i){return i&&i.__esModule?i:{default:i}}function kE(i,e,t){if(lg.default.randomUUID&&!e&&!i)return lg.default.randomUUID();i=i||{};let r=i.random||(i.rng||ME.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,DE.unsafeStringify)(r)}var NE=kE;fs.default=NE});var gg=p(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.default=void 0;function xE(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 qE(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],d=t[2],h=t[3],l=t[4];for(let g=0;g<80;++g){let _=Math.floor(g/20),M=Jp(c,5)+xE(_,u,d,h)+l+e[_]+a[g]>>>0;l=h,h=d,d=Jp(u,30)>>>0,u=c,c=M}t[0]=t[0]+c>>>0,t[1]=t[1]+u>>>0,t[2]=t[2]+d>>>0,t[3]=t[3]+h>>>0,t[4]=t[4]+l>>>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 zE=qE;gs.default=zE});var Sg=p(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.default=void 0;var jE=mg(Kp()),LE=mg(gg());function mg(i){return i&&i.__esModule?i:{default:i}}var BE=(0,jE.default)("v5",80,LE.default),FE=BE;ms.default=FE});var yg=p(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.default=void 0;var VE="00000000-0000-0000-0000-000000000000";Ss.default=VE});var Cg=p(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.default=void 0;var UE=WE(sn());function WE(i){return i&&i.__esModule?i:{default:i}}function HE(i){if(!(0,UE.default)(i))throw TypeError("Invalid UUID");return parseInt(i.slice(14,15),16)}var KE=HE;ys.default=KE});var Pg=p(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});Object.defineProperty(st,"NIL",{enumerable:!0,get:function(){return YE.default}});Object.defineProperty(st,"parse",{enumerable:!0,get:function(){return tw.default}});Object.defineProperty(st,"stringify",{enumerable:!0,get:function(){return ew.default}});Object.defineProperty(st,"v1",{enumerable:!0,get:function(){return JE.default}});Object.defineProperty(st,"v3",{enumerable:!0,get:function(){return GE.default}});Object.defineProperty(st,"v4",{enumerable:!0,get:function(){return $E.default}});Object.defineProperty(st,"v5",{enumerable:!0,get:function(){return QE.default}});Object.defineProperty(st,"validate",{enumerable:!0,get:function(){return ZE.default}});Object.defineProperty(st,"version",{enumerable:!0,get:function(){return XE.default}});var JE=zt(sg()),GE=zt(dg()),$E=zt(fg()),QE=zt(Sg()),YE=zt(yg()),XE=zt(Cg()),ZE=zt(sn()),ew=zt(an()),tw=zt(Hp());function zt(i){return i&&i.__esModule?i:{default:i}}});var ir=p(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.createNoDashGuid=pi.createGuid=void 0;var rw=Pg(),Rg=()=>rw.v4();pi.createGuid=Rg;var iw=()=>Rg().replace(new RegExp("-","g"),"").toUpperCase();pi.createNoDashGuid=iw});var ui=p(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.PlatformEvent=Tr.EventType=void 0;var nw=ir(),sw;(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"})(sw=Tr.EventType||(Tr.EventType={}));var Gp=class{constructor(e,t){this.privName=e,this.privEventId=nw.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}};Tr.PlatformEvent=Gp});var nu=p(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.AudioStreamNodeErrorEvent=Y.AudioStreamNodeDetachedEvent=Y.AudioStreamNodeAttachedEvent=Y.AudioStreamNodeAttachingEvent=Y.AudioStreamNodeEvent=Y.AudioSourceErrorEvent=Y.AudioSourceOffEvent=Y.AudioSourceReadyEvent=Y.AudioSourceInitializingEvent=Y.AudioSourceEvent=void 0;var $p=ui(),nr=class extends $p.PlatformEvent{constructor(e,t,r=$p.EventType.Info){super(e,r),this.privAudioSourceId=t}get audioSourceId(){return this.privAudioSourceId}};Y.AudioSourceEvent=nr;var Qp=class extends nr{constructor(e){super("AudioSourceInitializingEvent",e)}};Y.AudioSourceInitializingEvent=Qp;var Yp=class extends nr{constructor(e){super("AudioSourceReadyEvent",e)}};Y.AudioSourceReadyEvent=Yp;var Xp=class extends nr{constructor(e){super("AudioSourceOffEvent",e)}};Y.AudioSourceOffEvent=Xp;var Zp=class extends nr{constructor(e,t){super("AudioSourceErrorEvent",e,$p.EventType.Error),this.privError=t}get error(){return this.privError}};Y.AudioSourceErrorEvent=Zp;var _r=class extends nr{constructor(e,t,r){super(e,t),this.privAudioNodeId=r}get audioNodeId(){return this.privAudioNodeId}};Y.AudioStreamNodeEvent=_r;var eu=class extends _r{constructor(e,t){super("AudioStreamNodeAttachingEvent",e,t)}};Y.AudioStreamNodeAttachingEvent=eu;var tu=class extends _r{constructor(e,t){super("AudioStreamNodeAttachedEvent",e,t)}};Y.AudioStreamNodeAttachedEvent=tu;var ru=class extends _r{constructor(e,t){super("AudioStreamNodeDetachedEvent",e,t)}};Y.AudioStreamNodeDetachedEvent=ru;var iu=class extends _r{constructor(e,t,r){super("AudioStreamNodeErrorEvent",e,t),this.privError=r}get error(){return this.privError}};Y.AudioStreamNodeErrorEvent=iu});var Eg=p(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.ConnectionMessageSentEvent=te.ConnectionMessageReceivedEvent=te.ConnectionEstablishErrorEvent=te.ConnectionErrorEvent=te.ConnectionClosedEvent=te.ConnectionEstablishedEvent=te.ConnectionStartEvent=te.ConnectionEvent=te.ServiceEvent=void 0;var Ar=ui(),su=class extends Ar.PlatformEvent{constructor(e,t,r=Ar.EventType.Info){super(e,r),this.privJsonResult=t}get jsonString(){return this.privJsonResult}};te.ServiceEvent=su;var mt=class extends Ar.PlatformEvent{constructor(e,t,r=Ar.EventType.Info){super(e,r),this.privConnectionId=t}get connectionId(){return this.privConnectionId}};te.ConnectionEvent=mt;var ou=class extends mt{constructor(e,t,r){super("ConnectionStartEvent",e),this.privUri=t,this.privHeaders=r}get uri(){return this.privUri}get headers(){return this.privHeaders}};te.ConnectionStartEvent=ou;var au=class extends mt{constructor(e){super("ConnectionEstablishedEvent",e)}};te.ConnectionEstablishedEvent=au;var cu=class extends mt{constructor(e,t,r){super("ConnectionClosedEvent",e,Ar.EventType.Debug),this.privReason=r,this.privStatusCode=t}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};te.ConnectionClosedEvent=cu;var pu=class extends mt{constructor(e,t,r){super("ConnectionErrorEvent",e,Ar.EventType.Debug),this.privMessage=t,this.privType=r}get message(){return this.privMessage}get type(){return this.privType}};te.ConnectionErrorEvent=pu;var uu=class extends mt{constructor(e,t,r){super("ConnectionEstablishErrorEvent",e,Ar.EventType.Error),this.privStatusCode=t,this.privReason=r}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};te.ConnectionEstablishErrorEvent=uu;var du=class extends mt{constructor(e,t,r){super("ConnectionMessageReceivedEvent",e),this.privNetworkReceivedTime=t,this.privMessage=r}get networkReceivedTime(){return this.privNetworkReceivedTime}get message(){return this.privMessage}};te.ConnectionMessageReceivedEvent=du;var hu=class extends mt{constructor(e,t,r){super("ConnectionMessageSentEvent",e),this.privNetworkSentTime=t,this.privMessage=r}get networkSentTime(){return this.privNetworkSentTime}get message(){return this.privMessage}};te.ConnectionMessageSentEvent=hu});var ot=p(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.ObjectDisposedError=sr.InvalidOperationError=sr.ArgumentNullError=void 0;var lu=class extends Error{constructor(e){super(e),this.name="ArgumentNull",this.message=e}};sr.ArgumentNullError=lu;var vu=class extends Error{constructor(e){super(e),this.name="InvalidOperation",this.message=e}};sr.InvalidOperationError=vu;var fu=class extends Error{constructor(e,t){super(t),this.name=e+"ObjectDisposed",this.message=t}};sr.ObjectDisposedError=fu});var mu=p(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.ConnectionMessage=Or.MessageType=void 0;var Cs=ot(),ow=ir(),br;(function(i){i[i.Text=0]="Text",i[i.Binary=1]="Binary"})(br=Or.MessageType||(Or.MessageType={}));var gu=class{constructor(e,t,r,n){if(this.privBody=null,e===br.Text&&t&&typeof t!="string")throw new Cs.InvalidOperationError("Payload must be a string");if(e===br.Binary&&t&&!(t instanceof ArrayBuffer))throw new Cs.InvalidOperationError("Payload must be ArrayBuffer");switch(this.privMessageType=e,this.privBody=t,this.privHeaders=r||{},this.privId=n||ow.createNoDashGuid(),this.messageType){case br.Binary:this.privSize=this.binaryBody!==null?this.binaryBody.byteLength:0;break;case br.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===br.Binary)throw new Cs.InvalidOperationError("Not supported for binary message");return this.privBody}get binaryBody(){if(this.privMessageType===br.Text)throw new Cs.InvalidOperationError("Not supported for text message");return this.privBody}get id(){return this.privId}};Or.ConnectionMessage=gu});var wg=p(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.ConnectionOpenResponse=void 0;var Su=class{constructor(e,t){this.privStatusCode=e,this.privReason=t}get statusCode(){return this.privStatusCode}get reason(){return this.privReason}};Ps.ConnectionOpenResponse=Su});var Ig=p(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});Rs.DeferralMap=void 0;var yu=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}}};Rs.DeferralMap=yu});var Pu=p(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.SendingAgentContextMessageEvent=di.DialogEvent=void 0;var Tg=ui(),Es=class extends Tg.PlatformEvent{constructor(e,t=Tg.EventType.Info){super(e,t)}};di.DialogEvent=Es;var Cu=class extends Es{constructor(e){super("SendingAgentContextMessageEvent"),this.privAgentConfig=e}get agentConfig(){return this.privAgentConfig}};di.SendingAgentContextMessageEvent=Cu});var Eu=p(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.EventSource=void 0;var aw=ot(),cw=ir(),Ru=class{constructor(e){this.privEventListeners={},this.privIsDisposed=!1,this.privConsoleListener=void 0,this.privMetadata=e}onEvent(e){if(this.isDisposed())throw new aw.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=cw.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}};ws.EventSource=Ru});var _g=p(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.Events=void 0;var pw=ot(),uw=Eu(),Is=class i{static setEventSource(e){if(!e)throw new pw.ArgumentNullError("eventSource");i.privInstance=e}static get instance(){return i.privInstance}};Ts.Events=Is;Is.privInstance=new uw.EventSource});var bg=p(Ag=>{"use strict";Object.defineProperty(Ag,"__esModule",{value:!0})});var Og=p(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.ConnectionState=void 0;var dw;(function(i){i[i.None=0]="None",i[i.Connected=1]="Connected",i[i.Connecting=2]="Connecting",i[i.Disconnected=3]="Disconnected"})(dw=cn.ConnectionState||(cn.ConnectionState={}))});var Dg=p(Mg=>{"use strict";Object.defineProperty(Mg,"__esModule",{value:!0})});var Ng=p(kg=>{"use strict";Object.defineProperty(kg,"__esModule",{value:!0})});var qg=p(xg=>{"use strict";Object.defineProperty(xg,"__esModule",{value:!0})});var jg=p(zg=>{"use strict";Object.defineProperty(zg,"__esModule",{value:!0})});var Bg=p(Lg=>{"use strict";Object.defineProperty(Lg,"__esModule",{value:!0})});var Vg=p(Fg=>{"use strict";Object.defineProperty(Fg,"__esModule",{value:!0})});var Wg=p(Ug=>{"use strict";Object.defineProperty(Ug,"__esModule",{value:!0})});var Kg=p(Hg=>{"use strict";Object.defineProperty(Hg,"__esModule",{value:!0})});var Iu=p(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.List=void 0;var hw=ot(),wu=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 hw.ObjectDisposedError("List",this.privDisposeReason)}triggerSubscriptions(e){if(e)for(let t in e)t&&e[t]()}};_s.List=wu});var Au=p(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.marshalPromiseToCallbacks=be.Sink=be.Deferred=be.PromiseResultEventSource=be.PromiseResult=be.PromiseState=void 0;var jt;(function(i){i[i.None=0]="None",i[i.Resolved=1]="Resolved",i[i.Rejected=2]="Rejected"})(jt=be.PromiseState||(be.PromiseState={}));var As=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}};be.PromiseResult=As;var bs=class{constructor(){this.setResult=e=>{this.privOnSetResult(e)},this.setError=e=>{this.privOnSetError(e)},this.on=(e,t)=>{this.privOnSetResult=e,this.privOnSetError=t}}};be.PromiseResultEventSource=bs;var Tu=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}};be.Deferred=Tu;var _u=class{constructor(){this.privState=jt.None,this.privPromiseResult=null,this.privPromiseResultEvents=null,this.privSuccessHandlers=[],this.privErrorHandlers=[],this.privPromiseResultEvents=new bs,this.privPromiseResult=new As(this.privPromiseResultEvents)}get state(){return this.privState}get result(){return this.privPromiseResult}resolve(e){if(this.privState!==jt.None)throw new Error("'Cannot resolve a completed promise'");this.privState=jt.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!==jt.None)throw new Error("'Cannot reject a completed promise'");this.privState=jt.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===jt.None?(this.privSuccessHandlers.push(e),this.privErrorHandlers.push(t)):(this.privState===jt.Resolved?this.executeSuccessCallback(this.privPromiseResult.result,e,t):this.privState===jt.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=[]}};be.Sink=_u;function lw(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{}})}be.marshalPromiseToCallbacks=lw});var Du=p(Os=>{"use strict";Object.defineProperty(Os,"__esModule",{value:!0});Os.Queue=void 0;var bu=ot(),Ou=Iu(),Jg=Au(),pn;(function(i){i[i.Dequeue=0]="Dequeue",i[i.Peek=1]="Peek"})(pn||(pn={}));var Mu=class{constructor(e){this.privPromiseStore=new Ou.List,this.privIsDrainInProgress=!1,this.privIsDisposing=!1,this.privDisposeReason=null,this.privList=e||new Ou.List,this.privDetachables=[],this.privSubscribers=new Ou.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 Jg.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:pn.Dequeue}),this.drain()),e.promise}peek(){this.throwIfDispose();let e=new Jg.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:pn.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===pn.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 bu.InvalidOperationError(this.privDisposeReason):new bu.ObjectDisposedError("Queue");if(this.privIsDisposing)throw new bu.InvalidOperationError("Queue disposing")}};Os.Queue=Mu});var Gg=p(Ds=>{"use strict";Object.defineProperty(Ds,"__esModule",{value:!0});Ds.RawWebsocketMessage=void 0;var Ms=mu(),un=ot(),vw=ir(),ku=class{constructor(e,t,r){if(this.privPayload=null,!t)throw new un.ArgumentNullError("payload");if(e===Ms.MessageType.Binary&&Object.getPrototypeOf(t).constructor.name!=="ArrayBuffer")throw new un.InvalidOperationError("Payload must be ArrayBuffer");if(e===Ms.MessageType.Text&&typeof t!="string")throw new un.InvalidOperationError("Payload must be a string");this.privMessageType=e,this.privPayload=t,this.privId=r||vw.createNoDashGuid()}get messageType(){return this.privMessageType}get payload(){return this.privPayload}get textContent(){if(this.privMessageType===Ms.MessageType.Binary)throw new un.InvalidOperationError("Not supported for binary message");return this.privPayload}get binaryContent(){if(this.privMessageType===Ms.MessageType.Text)throw new un.InvalidOperationError("Not supported for text message");return this.privPayload}get id(){return this.privId}};Ds.RawWebsocketMessage=ku});var $g=p(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.RiffPcmEncoder=void 0;var Nu=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),d=0,h=0;for(;a<u&&a<e.length;)d+=e[a++],h++;o[c++]=d/h}return o}};ks.RiffPcmEncoder=Nu});var Xg=p(Ns=>{"use strict";Object.defineProperty(Ns,"__esModule",{value:!0});Ns.Stream=void 0;var Qg=ot(),fw=ir(),Yg=Du(),xu=class{constructor(e){this.privIsWriteEnded=!1,this.privIsReadEnded=!1,this.privId=e||fw.createNoDashGuid(),this.privReaderQueue=new Yg.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 Qg.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 Yg.Queue)}throwIfClosed(){if(this.privIsWriteEnded)throw new Qg.InvalidOperationError("Stream closed")}};Ns.Stream=xu});var xs=p(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.TranslationStatus=void 0;var gw;(function(i){i[i.Success=0]="Success",i[i.Error=1]="Error"})(gw=dn.TranslationStatus||(dn.TranslationStatus={}))});var Zg=p(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.ChunkedArrayBufferStream=void 0;var mw=P(),qu=class extends mw.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()}};qs.ChunkedArrayBufferStream=qu});var tm=p(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0})});var rm=p(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.Timeout=void 0;var St=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,d=e.get(u);if(typeof d=="number"){let h=t.get(d);if(h===void 0||h!==u)throw new Error("The timer is in an undefined state.")}else if(typeof d<"u")d(),e.delete(u);else throw new Error("The timer is in an undefined state.")}else if(i.isClearResponse(c)){let{id:u}=c,d=t.get(u);if(d===void 0)throw new Error("The timer is in an undefined state.");t.delete(u),e.delete(d)}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 d=Math.random();return e.set(d,c),s.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:d}}),d}}}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"}};zs.Timeout=St;St.workerTimers=null;St.clearTimeout=i=>St.timers().clearTimeout(i);St.setTimeout=(i,e)=>St.timers().setTimeout(i,e);St.timers=St.loadWorkerTimers()});var im=p(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.OCSPCacheUpdateErrorEvent=D.OCSPResponseRetrievedEvent=D.OCSPCacheFetchErrorEvent=D.OCSPVerificationFailedEvent=D.OCSPCacheHitEvent=D.OCSPCacheEntryNeedsRefreshEvent=D.OCSPCacheEntryExpiredEvent=D.OCSPWSUpgradeStartedEvent=D.OCSPStapleReceivedEvent=D.OCSPCacheUpdateCompleteEvent=D.OCSPDiskCacheStoreEvent=D.OCSPMemoryCacheStoreEvent=D.OCSPCacheUpdateNeededEvent=D.OCSPDiskCacheHitEvent=D.OCSPCacheMissEvent=D.OCSPMemoryCacheHitEvent=D.OCSPEvent=void 0;var de=ui(),oe=class extends de.PlatformEvent{constructor(e,t,r){super(e,t),this.privSignature=r}};D.OCSPEvent=oe;var zu=class extends oe{constructor(e){super("OCSPMemoryCacheHitEvent",de.EventType.Debug,e)}};D.OCSPMemoryCacheHitEvent=zu;var ju=class extends oe{constructor(e){super("OCSPCacheMissEvent",de.EventType.Debug,e)}};D.OCSPCacheMissEvent=ju;var Lu=class extends oe{constructor(e){super("OCSPDiskCacheHitEvent",de.EventType.Debug,e)}};D.OCSPDiskCacheHitEvent=Lu;var Bu=class extends oe{constructor(e){super("OCSPCacheUpdateNeededEvent",de.EventType.Debug,e)}};D.OCSPCacheUpdateNeededEvent=Bu;var Fu=class extends oe{constructor(e){super("OCSPMemoryCacheStoreEvent",de.EventType.Debug,e)}};D.OCSPMemoryCacheStoreEvent=Fu;var Vu=class extends oe{constructor(e){super("OCSPDiskCacheStoreEvent",de.EventType.Debug,e)}};D.OCSPDiskCacheStoreEvent=Vu;var Uu=class extends oe{constructor(e){super("OCSPCacheUpdateCompleteEvent",de.EventType.Debug,e)}};D.OCSPCacheUpdateCompleteEvent=Uu;var Wu=class extends oe{constructor(){super("OCSPStapleReceivedEvent",de.EventType.Debug,"")}};D.OCSPStapleReceivedEvent=Wu;var Hu=class extends oe{constructor(e){super("OCSPWSUpgradeStartedEvent",de.EventType.Debug,e)}};D.OCSPWSUpgradeStartedEvent=Hu;var Ku=class extends oe{constructor(e,t){super("OCSPCacheEntryExpiredEvent",de.EventType.Debug,e),this.privExpireTime=t}};D.OCSPCacheEntryExpiredEvent=Ku;var Ju=class extends oe{constructor(e,t,r){super("OCSPCacheEntryNeedsRefreshEvent",de.EventType.Debug,e),this.privExpireTime=r,this.privStartTime=t}};D.OCSPCacheEntryNeedsRefreshEvent=Ju;var Gu=class extends oe{constructor(e,t,r){super("OCSPCacheHitEvent",de.EventType.Debug,e),this.privExpireTime=r,this.privExpireTimeString=new Date(r).toLocaleDateString(),this.privStartTime=t,this.privStartTimeString=new Date(t).toLocaleTimeString()}};D.OCSPCacheHitEvent=Gu;var $u=class extends oe{constructor(e,t){super("OCSPVerificationFailedEvent",de.EventType.Debug,e),this.privError=t}};D.OCSPVerificationFailedEvent=$u;var Qu=class extends oe{constructor(e,t){super("OCSPCacheFetchErrorEvent",de.EventType.Debug,e),this.privError=t}};D.OCSPCacheFetchErrorEvent=Qu;var Yu=class extends oe{constructor(e){super("OCSPResponseRetrievedEvent",de.EventType.Debug,e)}};D.OCSPResponseRetrievedEvent=Yu;var Xu=class extends oe{constructor(e,t){super("OCSPCacheUpdateErrorEvent",de.EventType.Debug,e),this.privError=t}};D.OCSPCacheUpdateErrorEvent=Xu});var sm=p(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.BackgroundEvent=void 0;var nm=P(),Zu=class extends nm.PlatformEvent{constructor(e){super("BackgroundEvent",nm.EventType.Error),this.privError=e}get error(){return this.privError}};js.BackgroundEvent=Zu});var P=p(b=>{"use strict";var Sw=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)&&Sw(e,i,t)};Object.defineProperty(b,"__esModule",{value:!0});N(nu(),b);N(Eg(),b);N(mu(),b);N(wg(),b);N(Ig(),b);N(Pu(),b);N(ot(),b);N(_g(),b);N(Eu(),b);N(ir(),b);N(bg(),b);N(Og(),b);N(Dg(),b);N(Ng(),b);N(qg(),b);N(jg(),b);N(Bg(),b);N(Vg(),b);N(Wg(),b);N(Kg(),b);N(Iu(),b);N(ui(),b);N(Au(),b);N(Du(),b);N(Gg(),b);N($g(),b);N(Xg(),b);var yw=xs();Object.defineProperty(b,"TranslationStatus",{enumerable:!0,get:function(){return yw.TranslationStatus}});N(Zg(),b);N(tm(),b);N(rm(),b);N(im(),b);N(sm(),b)});var we=p(Ls=>{"use strict";Object.defineProperty(Ls,"__esModule",{value:!0});Ls.HeaderNames=void 0;var Le=class{};Ls.HeaderNames=Le;Le.AuthKey="Ocp-Apim-Subscription-Key";Le.Authorization="Authorization";Le.SpIDAuthKey="Apim-Subscription-Id";Le.ConnectionId="X-ConnectionId";Le.ContentType="Content-Type";Le.CustomCommandsAppId="X-CommandsAppId";Le.Path="Path";Le.RequestId="X-RequestId";Le.RequestStreamId="X-StreamId";Le.RequestTimestamp="X-Timestamp"});var Fs=p(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.AuthInfo=void 0;var ed=class{constructor(e,t){this.privHeaderName=e,this.privToken=t}get headerName(){return this.privHeaderName}get token(){return this.privToken}};Bs.AuthInfo=ed});var om=p(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.CognitiveSubscriptionKeyAuthentication=void 0;var Cw=P(),Pw=we(),Rw=Fs(),td=class{constructor(e){if(!e)throw new Cw.ArgumentNullError("subscriptionKey");this.privAuthInfo=new Rw.AuthInfo(Pw.HeaderNames.AuthKey,e)}fetch(e){return Promise.resolve(this.privAuthInfo)}fetchOnExpiry(e){return Promise.resolve(this.privAuthInfo)}};Vs.CognitiveSubscriptionKeyAuthentication=td});var um=p(Ws=>{"use strict";Object.defineProperty(Ws,"__esModule",{value:!0});Ws.CognitiveTokenAuthentication=void 0;var am=P(),cm=Fs(),pm=we(),Us=class i{constructor(e,t){if(!e)throw new am.ArgumentNullError("fetchCallback");if(!t)throw new am.ArgumentNullError("fetchOnExpiryCallback");this.privFetchCallback=e,this.privFetchOnExpiryCallback=t}fetch(e){return this.privFetchCallback(e).then(t=>new cm.AuthInfo(pm.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}fetchOnExpiry(e){return this.privFetchOnExpiryCallback(e).then(t=>new cm.AuthInfo(pm.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}};Ws.CognitiveTokenAuthentication=Us;Us.privTokenPrefix="Bearer "});var hm=p(dm=>{"use strict";Object.defineProperty(dm,"__esModule",{value:!0})});var vm=p(lm=>{"use strict";Object.defineProperty(lm,"__esModule",{value:!0})});var rd=p(()=>{});var id=p(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});Hs.LogLevel=void 0;var Ew=P();Object.defineProperty(Hs,"LogLevel",{enumerable:!0,get:function(){return Ew.EventType}})});var w=p(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.Contracts=void 0;var nd=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)}};Ks.Contracts=nd});var gm=p(yt=>{"use strict";var ww=yt&&yt.__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]}),Iw=yt&&yt.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Tw=yt&&yt.__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)&&ww(e,i,t);return Iw(e,i),e};Object.defineProperty(yt,"__esModule",{value:!0});yt.ConsoleLoggingListener=void 0;var fm=Tw(rd()),hn=id(),_w=w(),sd=class{constructor(e=hn.LogLevel.None){this.privLogPath=void 0,this.privEnableConsoleOutput=!0,this.privLogLevelFilter=e}set logPath(e){_w.Contracts.throwIfNullOrUndefined(fm.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&&
|
|
3
|
-
`,{flag:"a+"}),this.privEnableConsoleOutput)switch(e.eventType){case hn.LogLevel.Debug:console.debug(t);break;case hn.LogLevel.Info:console.info(t);break;case hn.LogLevel.Warning:console.warn(t);break;case hn.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(" | ")}};yt.ConsoleLoggingListener=sd});var Sm=p(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0})});var or=p(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.AudioStreamFormatImpl=Lt.AudioStreamFormat=Lt.AudioFormatTag=void 0;var ln;(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"})(ln=Lt.AudioFormatTag||(Lt.AudioFormatTag={}));var Js=class{static getDefaultInputFormat(){return hi.getDefaultInputFormat()}static getWaveFormat(e,t,r,n){return new hi(e,t,r,n)}static getWaveFormatPCM(e,t,r){return new hi(e,t,r)}};Lt.AudioStreamFormat=Js;var hi=class i extends Js{constructor(e=16e3,t=16,r=1,n=ln.PCM){super();let s=!0;switch(n){case ln.PCM:this.formatTag=1;break;case ln.ALaw:this.formatTag=6;break;case ln.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))}};Lt.AudioStreamFormatImpl=hi});var Pm=p(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.MicAudioSource=Mr.AudioWorkletSourceURLPropertyName=void 0;var ym=C(),he=P(),Cm=or();Mr.AudioWorkletSourceURLPropertyName="MICROPHONE-WorkletSourceUrl";var Gs=class i{constructor(e,t,r,n){this.privRecorder=e,this.deviceId=t,this.privStreams={},this.privOutputChunkSize=i.AUDIOFORMAT.avgBytesPerSec/10,this.privId=r||he.createNoDashGuid(),this.privEvents=new he.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 he.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 he.AudioSourceInitializingEvent(this.privId)),this.privMediaStream&&this.privMediaStream.active?(this.onEvent(new he.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()):t({audio:this.deviceId?{deviceId:this.deviceId}:!0,video:!1},n=>{this.privMediaStream=n,this.onEvent(new he.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()},n=>{let s=`Error occurred during microphone initialization: ${n}`;this.privInitializeDeferral.reject(s),this.onEvent(new he.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 he.AudioSourceErrorEvent(r,""))}return this.privInitializeDeferral.promise}id(){return this.privId}attach(e){return this.onEvent(new he.AudioStreamNodeAttachingEvent(this.privId,e)),this.listen(e).then(t=>(this.onEvent(new he.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(t.readEnded(),delete this.privStreams[e],this.onEvent(new he.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 he.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 he.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:ym.connectivity.Unknown,manufacturer:"Speech SDK",model:e,samplerate:i.AUDIOFORMAT.samplesPerSec,type:ym.type.Microphones}))}setProperty(e,t){if(e===Mr.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 he.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 he.ChunkedArrayBufferStream(this.privOutputChunkSize,e);this.privStreams[e]=t;try{this.privRecorder.record(this.privContext,this.privMediaStream,t)}catch(n){throw this.onEvent(new he.AudioStreamNodeErrorEvent(this.privId,e,n)),n}return t}onEvent(e){this.privEvents.onEvent(e),he.Events.instance.onEvent(e)}createAudioContext(){this.privContext||(this.privContext=Cm.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()}};Mr.MicAudioSource=Gs;Gs.AUDIOFORMAT=Cm.AudioStreamFormat.getDefaultInputFormat()});var Em=p($s=>{"use strict";Object.defineProperty($s,"__esModule",{value:!0});$s.FileAudioSource=void 0;var Rm=C(),ke=P(),Aw=or(),od=class{constructor(e,t,r){this.privStreams={},this.privHeaderEnd=44,this.privId=r||ke.createNoDashGuid(),this.privEvents=new ke.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 ke.AudioSourceErrorEvent(e,"")),Promise.reject(e)}this.onEvent(new ke.AudioSourceInitializingEvent(this.privId)),this.onEvent(new ke.AudioSourceReadyEvent(this.privId))}id(){return this.privId}async attach(e){this.onEvent(new ke.AudioStreamNodeAttachingEvent(this.privId,e));let t=await this.upload(e);return this.onEvent(new ke.AudioStreamNodeAttachedEvent(this.privId,e)),Promise.resolve({detach:async()=>{t.readEnded(),delete this.privStreams[e],this.onEvent(new ke.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 ke.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 ke.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:Rm.connectivity.Unknown,manufacturer:"Speech SDK",model:"File",samplerate:e.samplesPerSec,type:Rm.type.File}))}readHeader(){let t=this.privSource.slice(0,4296),r=new ke.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),d=o.getUint32(24,!0),h=o.getUint16(34,!0),l=36+Math.max(c-16,0);for(;a(l)!=="data";l+=2)if(l>4288){r.reject("Invalid WAV header in file, data block was not found");return}this.privHeaderEnd=l+8,r.resolve(Aw.AudioStreamFormat.getWaveFormatPCM(d,h,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 ke.AudioStreamNodeErrorEvent(this.privId,e,n)),new Error(n)};try{await this.turnOn();let r=await this.privAudioFormatPromise,n=new ke.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),ke.Events.instance.onEvent(e)}};$s.FileAudioSource=od});var wm=p(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.PcmRecorder=void 0;var bw=P(),ad=class{constructor(e){this.privStopInputOnRelease=e}record(e,t,r){let s=new bw.RiffPcmEncoder(e.sampleRate,16e3),o=e.createMediaStreamSource(t),a=()=>{let u=(()=>{let d=0;try{return e.createScriptProcessor(d,1,1)}catch{d=2048;let l=e.sampleRate;for(;d<16384&&l>=32e3;)d<<=1,l>>=1;return e.createScriptProcessor(d,1,1)}})();u.onaudioprocess=d=>{let h=d.inputBuffer.getChannelData(0);if(r&&!r.isClosed){let l=s.encode(h);l&&r.writeStreamChunk({buffer:l,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 Xf=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&&Xf(i,n,{get:()=>e[n],enumerable:!(r=FR(e,n))||r.enumerable});return i};var Zf=(i,e,t)=>(t=i!=null?BR(UR(i)):{},HR(e||!i||!i.__esModule?Xf(t,"default",{value:i,enumerable:!0}):t,i));var Fp=p(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});Bp.default=GR;var as,JR=new Uint8Array(16);function GR(){if(!as&&(as=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!as))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return as(JR)}});var tg=p(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.default=void 0;var $R=/^(?:[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;cs.default=$R});var sn=p(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.default=void 0;var QR=YR(tg());function YR(i){return i&&i.__esModule?i:{default:i}}function XR(i){return typeof i=="string"&&QR.default.test(i)}var ZR=XR;ps.default=ZR});var an=p(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.default=void 0;on.unsafeStringify=rg;var eE=tE(sn());function tE(i){return i&&i.__esModule?i:{default:i}}var ue=[];for(let i=0;i<256;++i)ue.push((i+256).toString(16).slice(1));function rg(i,e=0){return ue[i[e+0]]+ue[i[e+1]]+ue[i[e+2]]+ue[i[e+3]]+"-"+ue[i[e+4]]+ue[i[e+5]]+"-"+ue[i[e+6]]+ue[i[e+7]]+"-"+ue[i[e+8]]+ue[i[e+9]]+"-"+ue[i[e+10]]+ue[i[e+11]]+ue[i[e+12]]+ue[i[e+13]]+ue[i[e+14]]+ue[i[e+15]]}function rE(i,e=0){let t=rg(i,e);if(!(0,eE.default)(t))throw TypeError("Stringified UUID is invalid");return t}var iE=rE;on.default=iE});var ng=p(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.default=void 0;var nE=oE(Fp()),sE=an();function oE(i){return i&&i.__esModule?i:{default:i}}var ig,Vp,Up=0,Wp=0;function aE(i,e,t){let r=e&&t||0,n=e||new Array(16);i=i||{};let s=i.node||ig,o=i.clockseq!==void 0?i.clockseq:Vp;if(s==null||o==null){let l=i.random||(i.rng||nE.default)();s==null&&(s=ig=[l[0]|1,l[1],l[2],l[3],l[4],l[5]]),o==null&&(o=Vp=(l[6]<<8|l[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 d=((a&268435455)*1e4+c)%4294967296;n[r++]=d>>>24&255,n[r++]=d>>>16&255,n[r++]=d>>>8&255,n[r++]=d&255;let h=a/4294967296*1e4&268435455;n[r++]=h>>>8&255,n[r++]=h&255,n[r++]=h>>>24&15|16,n[r++]=h>>>16&255,n[r++]=o>>>8|128,n[r++]=o&255;for(let l=0;l<6;++l)n[r+l]=s[l];return e||(0,sE.unsafeStringify)(n)}var cE=aE;us.default=cE});var Hp=p(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.default=void 0;var pE=uE(sn());function uE(i){return i&&i.__esModule?i:{default:i}}function dE(i){if(!(0,pE.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 hE=dE;ds.default=hE});var Kp=p(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.URL=Ir.DNS=void 0;Ir.default=mE;var lE=an(),vE=fE(Hp());function fE(i){return i&&i.__esModule?i:{default:i}}function gE(i){i=unescape(encodeURIComponent(i));let e=[];for(let t=0;t<i.length;++t)e.push(i.charCodeAt(t));return e}var sg="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Ir.DNS=sg;var og="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Ir.URL=og;function mE(i,e,t){function r(n,s,o,a){var c;if(typeof n=="string"&&(n=gE(n)),typeof s=="string"&&(s=(0,vE.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 d=0;d<16;++d)o[a+d]=u[d];return o}return(0,lE.unsafeStringify)(u)}try{r.name=i}catch{}return r.DNS=sg,r.URL=og,r}});var cg=p(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.default=void 0;function SE(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 yE(CE(PE(i),i.length*8))}function yE(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 ag(i){return(i+64>>>9<<4)+14+1}function CE(i,e){i[e>>5]|=128<<e%32,i[ag(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,d=s;t=Ce(t,r,n,s,i[o],7,-680876936),s=Ce(s,t,r,n,i[o+1],12,-389564586),n=Ce(n,s,t,r,i[o+2],17,606105819),r=Ce(r,n,s,t,i[o+3],22,-1044525330),t=Ce(t,r,n,s,i[o+4],7,-176418897),s=Ce(s,t,r,n,i[o+5],12,1200080426),n=Ce(n,s,t,r,i[o+6],17,-1473231341),r=Ce(r,n,s,t,i[o+7],22,-45705983),t=Ce(t,r,n,s,i[o+8],7,1770035416),s=Ce(s,t,r,n,i[o+9],12,-1958414417),n=Ce(n,s,t,r,i[o+10],17,-42063),r=Ce(r,n,s,t,i[o+11],22,-1990404162),t=Ce(t,r,n,s,i[o+12],7,1804603682),s=Ce(s,t,r,n,i[o+13],12,-40341101),n=Ce(n,s,t,r,i[o+14],17,-1502002290),r=Ce(r,n,s,t,i[o+15],22,1236535329),t=Pe(t,r,n,s,i[o+1],5,-165796510),s=Pe(s,t,r,n,i[o+6],9,-1069501632),n=Pe(n,s,t,r,i[o+11],14,643717713),r=Pe(r,n,s,t,i[o],20,-373897302),t=Pe(t,r,n,s,i[o+5],5,-701558691),s=Pe(s,t,r,n,i[o+10],9,38016083),n=Pe(n,s,t,r,i[o+15],14,-660478335),r=Pe(r,n,s,t,i[o+4],20,-405537848),t=Pe(t,r,n,s,i[o+9],5,568446438),s=Pe(s,t,r,n,i[o+14],9,-1019803690),n=Pe(n,s,t,r,i[o+3],14,-187363961),r=Pe(r,n,s,t,i[o+8],20,1163531501),t=Pe(t,r,n,s,i[o+13],5,-1444681467),s=Pe(s,t,r,n,i[o+2],9,-51403784),n=Pe(n,s,t,r,i[o+7],14,1735328473),r=Pe(r,n,s,t,i[o+12],20,-1926607734),t=Re(t,r,n,s,i[o+5],4,-378558),s=Re(s,t,r,n,i[o+8],11,-2022574463),n=Re(n,s,t,r,i[o+11],16,1839030562),r=Re(r,n,s,t,i[o+14],23,-35309556),t=Re(t,r,n,s,i[o+1],4,-1530992060),s=Re(s,t,r,n,i[o+4],11,1272893353),n=Re(n,s,t,r,i[o+7],16,-155497632),r=Re(r,n,s,t,i[o+10],23,-1094730640),t=Re(t,r,n,s,i[o+13],4,681279174),s=Re(s,t,r,n,i[o],11,-358537222),n=Re(n,s,t,r,i[o+3],16,-722521979),r=Re(r,n,s,t,i[o+6],23,76029189),t=Re(t,r,n,s,i[o+9],4,-640364487),s=Re(s,t,r,n,i[o+12],11,-421815835),n=Re(n,s,t,r,i[o+15],16,530742520),r=Re(r,n,s,t,i[o+2],23,-995338651),t=Ee(t,r,n,s,i[o],6,-198630844),s=Ee(s,t,r,n,i[o+7],10,1126891415),n=Ee(n,s,t,r,i[o+14],15,-1416354905),r=Ee(r,n,s,t,i[o+5],21,-57434055),t=Ee(t,r,n,s,i[o+12],6,1700485571),s=Ee(s,t,r,n,i[o+3],10,-1894986606),n=Ee(n,s,t,r,i[o+10],15,-1051523),r=Ee(r,n,s,t,i[o+1],21,-2054922799),t=Ee(t,r,n,s,i[o+8],6,1873313359),s=Ee(s,t,r,n,i[o+15],10,-30611744),n=Ee(n,s,t,r,i[o+6],15,-1560198380),r=Ee(r,n,s,t,i[o+13],21,1309151649),t=Ee(t,r,n,s,i[o+4],6,-145523070),s=Ee(s,t,r,n,i[o+11],10,-1120210379),n=Ee(n,s,t,r,i[o+2],15,718787259),r=Ee(r,n,s,t,i[o+9],21,-343485551),t=tr(t,a),r=tr(r,c),n=tr(n,u),s=tr(s,d)}return[t,r,n,s]}function PE(i){if(i.length===0)return[];let e=i.length*8,t=new Uint32Array(ag(e));for(let r=0;r<e;r+=8)t[r>>5]|=(i[r/8]&255)<<r%32;return t}function tr(i,e){let t=(i&65535)+(e&65535);return(i>>16)+(e>>16)+(t>>16)<<16|t&65535}function RE(i,e){return i<<e|i>>>32-e}function hs(i,e,t,r,n,s){return tr(RE(tr(tr(e,i),tr(r,s)),n),t)}function Ce(i,e,t,r,n,s,o){return hs(e&t|~e&r,i,e,n,s,o)}function Pe(i,e,t,r,n,s,o){return hs(e&r|t&~r,i,e,n,s,o)}function Re(i,e,t,r,n,s,o){return hs(e^t^r,i,e,n,s,o)}function Ee(i,e,t,r,n,s,o){return hs(t^(e|~r),i,e,n,s,o)}var EE=SE;ls.default=EE});var ug=p(vs=>{"use strict";Object.defineProperty(vs,"__esModule",{value:!0});vs.default=void 0;var wE=pg(Kp()),IE=pg(cg());function pg(i){return i&&i.__esModule?i:{default:i}}var TE=(0,wE.default)("v3",48,IE.default),_E=TE;vs.default=_E});var dg=p(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.default=void 0;var AE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),bE={randomUUID:AE};fs.default=bE});var vg=p(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.default=void 0;var hg=lg(dg()),OE=lg(Fp()),ME=an();function lg(i){return i&&i.__esModule?i:{default:i}}function DE(i,e,t){if(hg.default.randomUUID&&!e&&!i)return hg.default.randomUUID();i=i||{};let r=i.random||(i.rng||OE.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,ME.unsafeStringify)(r)}var kE=DE;gs.default=kE});var fg=p(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.default=void 0;function NE(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 xE(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],d=t[2],h=t[3],l=t[4];for(let g=0;g<80;++g){let _=Math.floor(g/20),M=Jp(c,5)+NE(_,u,d,h)+l+e[_]+a[g]>>>0;l=h,h=d,d=Jp(u,30)>>>0,u=c,c=M}t[0]=t[0]+c>>>0,t[1]=t[1]+u>>>0,t[2]=t[2]+d>>>0,t[3]=t[3]+h>>>0,t[4]=t[4]+l>>>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 qE=xE;ms.default=qE});var mg=p(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.default=void 0;var zE=gg(Kp()),jE=gg(fg());function gg(i){return i&&i.__esModule?i:{default:i}}var LE=(0,zE.default)("v5",80,jE.default),BE=LE;Ss.default=BE});var Sg=p(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.default=void 0;var FE="00000000-0000-0000-0000-000000000000";ys.default=FE});var yg=p(Cs=>{"use strict";Object.defineProperty(Cs,"__esModule",{value:!0});Cs.default=void 0;var VE=UE(sn());function UE(i){return i&&i.__esModule?i:{default:i}}function WE(i){if(!(0,VE.default)(i))throw TypeError("Invalid UUID");return parseInt(i.slice(14,15),16)}var HE=WE;Cs.default=HE});var Cg=p(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});Object.defineProperty(st,"NIL",{enumerable:!0,get:function(){return QE.default}});Object.defineProperty(st,"parse",{enumerable:!0,get:function(){return ew.default}});Object.defineProperty(st,"stringify",{enumerable:!0,get:function(){return ZE.default}});Object.defineProperty(st,"v1",{enumerable:!0,get:function(){return KE.default}});Object.defineProperty(st,"v3",{enumerable:!0,get:function(){return JE.default}});Object.defineProperty(st,"v4",{enumerable:!0,get:function(){return GE.default}});Object.defineProperty(st,"v5",{enumerable:!0,get:function(){return $E.default}});Object.defineProperty(st,"validate",{enumerable:!0,get:function(){return XE.default}});Object.defineProperty(st,"version",{enumerable:!0,get:function(){return YE.default}});var KE=zt(ng()),JE=zt(ug()),GE=zt(vg()),$E=zt(mg()),QE=zt(Sg()),YE=zt(yg()),XE=zt(sn()),ZE=zt(an()),ew=zt(Hp());function zt(i){return i&&i.__esModule?i:{default:i}}});var rr=p(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.createNoDashGuid=pi.createGuid=void 0;var tw=Cg(),Pg=()=>tw.v4();pi.createGuid=Pg;var rw=()=>Pg().replace(new RegExp("-","g"),"").toUpperCase();pi.createNoDashGuid=rw});var ui=p(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.PlatformEvent=Tr.EventType=void 0;var iw=rr(),nw;(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"})(nw=Tr.EventType||(Tr.EventType={}));var Gp=class{constructor(e,t){this.privName=e,this.privEventId=iw.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}};Tr.PlatformEvent=Gp});var nu=p(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.AudioStreamNodeErrorEvent=Y.AudioStreamNodeDetachedEvent=Y.AudioStreamNodeAttachedEvent=Y.AudioStreamNodeAttachingEvent=Y.AudioStreamNodeEvent=Y.AudioSourceErrorEvent=Y.AudioSourceOffEvent=Y.AudioSourceReadyEvent=Y.AudioSourceInitializingEvent=Y.AudioSourceEvent=void 0;var $p=ui(),ir=class extends $p.PlatformEvent{constructor(e,t,r=$p.EventType.Info){super(e,r),this.privAudioSourceId=t}get audioSourceId(){return this.privAudioSourceId}};Y.AudioSourceEvent=ir;var Qp=class extends ir{constructor(e){super("AudioSourceInitializingEvent",e)}};Y.AudioSourceInitializingEvent=Qp;var Yp=class extends ir{constructor(e){super("AudioSourceReadyEvent",e)}};Y.AudioSourceReadyEvent=Yp;var Xp=class extends ir{constructor(e){super("AudioSourceOffEvent",e)}};Y.AudioSourceOffEvent=Xp;var Zp=class extends ir{constructor(e,t){super("AudioSourceErrorEvent",e,$p.EventType.Error),this.privError=t}get error(){return this.privError}};Y.AudioSourceErrorEvent=Zp;var _r=class extends ir{constructor(e,t,r){super(e,t),this.privAudioNodeId=r}get audioNodeId(){return this.privAudioNodeId}};Y.AudioStreamNodeEvent=_r;var eu=class extends _r{constructor(e,t){super("AudioStreamNodeAttachingEvent",e,t)}};Y.AudioStreamNodeAttachingEvent=eu;var tu=class extends _r{constructor(e,t){super("AudioStreamNodeAttachedEvent",e,t)}};Y.AudioStreamNodeAttachedEvent=tu;var ru=class extends _r{constructor(e,t){super("AudioStreamNodeDetachedEvent",e,t)}};Y.AudioStreamNodeDetachedEvent=ru;var iu=class extends _r{constructor(e,t,r){super("AudioStreamNodeErrorEvent",e,t),this.privError=r}get error(){return this.privError}};Y.AudioStreamNodeErrorEvent=iu});var Rg=p(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.ConnectionMessageSentEvent=te.ConnectionMessageReceivedEvent=te.ConnectionEstablishErrorEvent=te.ConnectionErrorEvent=te.ConnectionClosedEvent=te.ConnectionEstablishedEvent=te.ConnectionStartEvent=te.ConnectionEvent=te.ServiceEvent=void 0;var Ar=ui(),su=class extends Ar.PlatformEvent{constructor(e,t,r=Ar.EventType.Info){super(e,r),this.privJsonResult=t}get jsonString(){return this.privJsonResult}};te.ServiceEvent=su;var mt=class extends Ar.PlatformEvent{constructor(e,t,r=Ar.EventType.Info){super(e,r),this.privConnectionId=t}get connectionId(){return this.privConnectionId}};te.ConnectionEvent=mt;var ou=class extends mt{constructor(e,t,r){super("ConnectionStartEvent",e),this.privUri=t,this.privHeaders=r}get uri(){return this.privUri}get headers(){return this.privHeaders}};te.ConnectionStartEvent=ou;var au=class extends mt{constructor(e){super("ConnectionEstablishedEvent",e)}};te.ConnectionEstablishedEvent=au;var cu=class extends mt{constructor(e,t,r){super("ConnectionClosedEvent",e,Ar.EventType.Debug),this.privReason=r,this.privStatusCode=t}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};te.ConnectionClosedEvent=cu;var pu=class extends mt{constructor(e,t,r){super("ConnectionErrorEvent",e,Ar.EventType.Debug),this.privMessage=t,this.privType=r}get message(){return this.privMessage}get type(){return this.privType}};te.ConnectionErrorEvent=pu;var uu=class extends mt{constructor(e,t,r){super("ConnectionEstablishErrorEvent",e,Ar.EventType.Error),this.privStatusCode=t,this.privReason=r}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};te.ConnectionEstablishErrorEvent=uu;var du=class extends mt{constructor(e,t,r){super("ConnectionMessageReceivedEvent",e),this.privNetworkReceivedTime=t,this.privMessage=r}get networkReceivedTime(){return this.privNetworkReceivedTime}get message(){return this.privMessage}};te.ConnectionMessageReceivedEvent=du;var hu=class extends mt{constructor(e,t,r){super("ConnectionMessageSentEvent",e),this.privNetworkSentTime=t,this.privMessage=r}get networkSentTime(){return this.privNetworkSentTime}get message(){return this.privMessage}};te.ConnectionMessageSentEvent=hu});var ot=p(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.ObjectDisposedError=nr.InvalidOperationError=nr.ArgumentNullError=void 0;var lu=class extends Error{constructor(e){super(e),this.name="ArgumentNull",this.message=e}};nr.ArgumentNullError=lu;var vu=class extends Error{constructor(e){super(e),this.name="InvalidOperation",this.message=e}};nr.InvalidOperationError=vu;var fu=class extends Error{constructor(e,t){super(t),this.name=e+"ObjectDisposed",this.message=t}};nr.ObjectDisposedError=fu});var mu=p(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.ConnectionMessage=Or.MessageType=void 0;var Ps=ot(),sw=rr(),br;(function(i){i[i.Text=0]="Text",i[i.Binary=1]="Binary"})(br=Or.MessageType||(Or.MessageType={}));var gu=class{constructor(e,t,r,n){if(this.privBody=null,e===br.Text&&t&&typeof t!="string")throw new Ps.InvalidOperationError("Payload must be a string");if(e===br.Binary&&t&&!(t instanceof ArrayBuffer))throw new Ps.InvalidOperationError("Payload must be ArrayBuffer");switch(this.privMessageType=e,this.privBody=t,this.privHeaders=r||{},this.privId=n||sw.createNoDashGuid(),this.messageType){case br.Binary:this.privSize=this.binaryBody!==null?this.binaryBody.byteLength:0;break;case br.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===br.Binary)throw new Ps.InvalidOperationError("Not supported for binary message");return this.privBody}get binaryBody(){if(this.privMessageType===br.Text)throw new Ps.InvalidOperationError("Not supported for text message");return this.privBody}get id(){return this.privId}};Or.ConnectionMessage=gu});var Eg=p(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});Rs.ConnectionOpenResponse=void 0;var Su=class{constructor(e,t){this.privStatusCode=e,this.privReason=t}get statusCode(){return this.privStatusCode}get reason(){return this.privReason}};Rs.ConnectionOpenResponse=Su});var wg=p(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.DeferralMap=void 0;var yu=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}}};Es.DeferralMap=yu});var Pu=p(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.SendingAgentContextMessageEvent=di.DialogEvent=void 0;var Ig=ui(),ws=class extends Ig.PlatformEvent{constructor(e,t=Ig.EventType.Info){super(e,t)}};di.DialogEvent=ws;var Cu=class extends ws{constructor(e){super("SendingAgentContextMessageEvent"),this.privAgentConfig=e}get agentConfig(){return this.privAgentConfig}};di.SendingAgentContextMessageEvent=Cu});var Eu=p(Is=>{"use strict";Object.defineProperty(Is,"__esModule",{value:!0});Is.EventSource=void 0;var ow=ot(),aw=rr(),Ru=class{constructor(e){this.privEventListeners={},this.privIsDisposed=!1,this.privConsoleListener=void 0,this.privMetadata=e}onEvent(e){if(this.isDisposed())throw new ow.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=aw.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}};Is.EventSource=Ru});var Tg=p(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.Events=void 0;var cw=ot(),pw=Eu(),Ts=class i{static setEventSource(e){if(!e)throw new cw.ArgumentNullError("eventSource");i.privInstance=e}static get instance(){return i.privInstance}};_s.Events=Ts;Ts.privInstance=new pw.EventSource});var Ag=p(_g=>{"use strict";Object.defineProperty(_g,"__esModule",{value:!0})});var bg=p(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.ConnectionState=void 0;var uw;(function(i){i[i.None=0]="None",i[i.Connected=1]="Connected",i[i.Connecting=2]="Connecting",i[i.Disconnected=3]="Disconnected"})(uw=cn.ConnectionState||(cn.ConnectionState={}))});var Mg=p(Og=>{"use strict";Object.defineProperty(Og,"__esModule",{value:!0})});var kg=p(Dg=>{"use strict";Object.defineProperty(Dg,"__esModule",{value:!0})});var xg=p(Ng=>{"use strict";Object.defineProperty(Ng,"__esModule",{value:!0})});var zg=p(qg=>{"use strict";Object.defineProperty(qg,"__esModule",{value:!0})});var Lg=p(jg=>{"use strict";Object.defineProperty(jg,"__esModule",{value:!0})});var Fg=p(Bg=>{"use strict";Object.defineProperty(Bg,"__esModule",{value:!0})});var Ug=p(Vg=>{"use strict";Object.defineProperty(Vg,"__esModule",{value:!0})});var Hg=p(Wg=>{"use strict";Object.defineProperty(Wg,"__esModule",{value:!0})});var Iu=p(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});As.List=void 0;var dw=ot(),wu=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 dw.ObjectDisposedError("List",this.privDisposeReason)}triggerSubscriptions(e){if(e)for(let t in e)t&&e[t]()}};As.List=wu});var Au=p(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.marshalPromiseToCallbacks=be.Sink=be.Deferred=be.PromiseResultEventSource=be.PromiseResult=be.PromiseState=void 0;var jt;(function(i){i[i.None=0]="None",i[i.Resolved=1]="Resolved",i[i.Rejected=2]="Rejected"})(jt=be.PromiseState||(be.PromiseState={}));var bs=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}};be.PromiseResult=bs;var Os=class{constructor(){this.setResult=e=>{this.privOnSetResult(e)},this.setError=e=>{this.privOnSetError(e)},this.on=(e,t)=>{this.privOnSetResult=e,this.privOnSetError=t}}};be.PromiseResultEventSource=Os;var Tu=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}};be.Deferred=Tu;var _u=class{constructor(){this.privState=jt.None,this.privPromiseResult=null,this.privPromiseResultEvents=null,this.privSuccessHandlers=[],this.privErrorHandlers=[],this.privPromiseResultEvents=new Os,this.privPromiseResult=new bs(this.privPromiseResultEvents)}get state(){return this.privState}get result(){return this.privPromiseResult}resolve(e){if(this.privState!==jt.None)throw new Error("'Cannot resolve a completed promise'");this.privState=jt.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!==jt.None)throw new Error("'Cannot reject a completed promise'");this.privState=jt.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===jt.None?(this.privSuccessHandlers.push(e),this.privErrorHandlers.push(t)):(this.privState===jt.Resolved?this.executeSuccessCallback(this.privPromiseResult.result,e,t):this.privState===jt.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=[]}};be.Sink=_u;function hw(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{}})}be.marshalPromiseToCallbacks=hw});var Du=p(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.Queue=void 0;var bu=ot(),Ou=Iu(),Kg=Au(),pn;(function(i){i[i.Dequeue=0]="Dequeue",i[i.Peek=1]="Peek"})(pn||(pn={}));var Mu=class{constructor(e){this.privPromiseStore=new Ou.List,this.privIsDrainInProgress=!1,this.privIsDisposing=!1,this.privDisposeReason=null,this.privList=e||new Ou.List,this.privDetachables=[],this.privSubscribers=new Ou.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 Kg.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:pn.Dequeue}),this.drain()),e.promise}peek(){this.throwIfDispose();let e=new Kg.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:pn.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===pn.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 bu.InvalidOperationError(this.privDisposeReason):new bu.ObjectDisposedError("Queue");if(this.privIsDisposing)throw new bu.InvalidOperationError("Queue disposing")}};Ms.Queue=Mu});var Jg=p(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.RawWebsocketMessage=void 0;var Ds=mu(),un=ot(),lw=rr(),ku=class{constructor(e,t,r){if(this.privPayload=null,!t)throw new un.ArgumentNullError("payload");if(e===Ds.MessageType.Binary&&Object.getPrototypeOf(t).constructor.name!=="ArrayBuffer")throw new un.InvalidOperationError("Payload must be ArrayBuffer");if(e===Ds.MessageType.Text&&typeof t!="string")throw new un.InvalidOperationError("Payload must be a string");this.privMessageType=e,this.privPayload=t,this.privId=r||lw.createNoDashGuid()}get messageType(){return this.privMessageType}get payload(){return this.privPayload}get textContent(){if(this.privMessageType===Ds.MessageType.Binary)throw new un.InvalidOperationError("Not supported for binary message");return this.privPayload}get binaryContent(){if(this.privMessageType===Ds.MessageType.Text)throw new un.InvalidOperationError("Not supported for text message");return this.privPayload}get id(){return this.privId}};ks.RawWebsocketMessage=ku});var Gg=p(Ns=>{"use strict";Object.defineProperty(Ns,"__esModule",{value:!0});Ns.RiffPcmEncoder=void 0;var Nu=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),d=0,h=0;for(;a<u&&a<e.length;)d+=e[a++],h++;o[c++]=d/h}return o}};Ns.RiffPcmEncoder=Nu});var Yg=p(xs=>{"use strict";Object.defineProperty(xs,"__esModule",{value:!0});xs.Stream=void 0;var $g=ot(),vw=rr(),Qg=Du(),xu=class{constructor(e){this.privIsWriteEnded=!1,this.privIsReadEnded=!1,this.privId=e||vw.createNoDashGuid(),this.privReaderQueue=new Qg.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 $g.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 Qg.Queue)}throwIfClosed(){if(this.privIsWriteEnded)throw new $g.InvalidOperationError("Stream closed")}};xs.Stream=xu});var qs=p(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.TranslationStatus=void 0;var fw;(function(i){i[i.Success=0]="Success",i[i.Error=1]="Error"})(fw=dn.TranslationStatus||(dn.TranslationStatus={}))});var Xg=p(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.ChunkedArrayBufferStream=void 0;var gw=P(),qu=class extends gw.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()}};zs.ChunkedArrayBufferStream=qu});var em=p(Zg=>{"use strict";Object.defineProperty(Zg,"__esModule",{value:!0})});var tm=p(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.Timeout=void 0;var St=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,d=e.get(u);if(typeof d=="number"){let h=t.get(d);if(h===void 0||h!==u)throw new Error("The timer is in an undefined state.")}else if(typeof d<"u")d(),e.delete(u);else throw new Error("The timer is in an undefined state.")}else if(i.isClearResponse(c)){let{id:u}=c,d=t.get(u);if(d===void 0)throw new Error("The timer is in an undefined state.");t.delete(u),e.delete(d)}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 d=Math.random();return e.set(d,c),s.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:d}}),d}}}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"}};js.Timeout=St;St.workerTimers=null;St.clearTimeout=i=>St.timers().clearTimeout(i);St.setTimeout=(i,e)=>St.timers().setTimeout(i,e);St.timers=St.loadWorkerTimers()});var rm=p(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.OCSPCacheUpdateErrorEvent=D.OCSPResponseRetrievedEvent=D.OCSPCacheFetchErrorEvent=D.OCSPVerificationFailedEvent=D.OCSPCacheHitEvent=D.OCSPCacheEntryNeedsRefreshEvent=D.OCSPCacheEntryExpiredEvent=D.OCSPWSUpgradeStartedEvent=D.OCSPStapleReceivedEvent=D.OCSPCacheUpdateCompleteEvent=D.OCSPDiskCacheStoreEvent=D.OCSPMemoryCacheStoreEvent=D.OCSPCacheUpdateNeededEvent=D.OCSPDiskCacheHitEvent=D.OCSPCacheMissEvent=D.OCSPMemoryCacheHitEvent=D.OCSPEvent=void 0;var de=ui(),oe=class extends de.PlatformEvent{constructor(e,t,r){super(e,t),this.privSignature=r}};D.OCSPEvent=oe;var zu=class extends oe{constructor(e){super("OCSPMemoryCacheHitEvent",de.EventType.Debug,e)}};D.OCSPMemoryCacheHitEvent=zu;var ju=class extends oe{constructor(e){super("OCSPCacheMissEvent",de.EventType.Debug,e)}};D.OCSPCacheMissEvent=ju;var Lu=class extends oe{constructor(e){super("OCSPDiskCacheHitEvent",de.EventType.Debug,e)}};D.OCSPDiskCacheHitEvent=Lu;var Bu=class extends oe{constructor(e){super("OCSPCacheUpdateNeededEvent",de.EventType.Debug,e)}};D.OCSPCacheUpdateNeededEvent=Bu;var Fu=class extends oe{constructor(e){super("OCSPMemoryCacheStoreEvent",de.EventType.Debug,e)}};D.OCSPMemoryCacheStoreEvent=Fu;var Vu=class extends oe{constructor(e){super("OCSPDiskCacheStoreEvent",de.EventType.Debug,e)}};D.OCSPDiskCacheStoreEvent=Vu;var Uu=class extends oe{constructor(e){super("OCSPCacheUpdateCompleteEvent",de.EventType.Debug,e)}};D.OCSPCacheUpdateCompleteEvent=Uu;var Wu=class extends oe{constructor(){super("OCSPStapleReceivedEvent",de.EventType.Debug,"")}};D.OCSPStapleReceivedEvent=Wu;var Hu=class extends oe{constructor(e){super("OCSPWSUpgradeStartedEvent",de.EventType.Debug,e)}};D.OCSPWSUpgradeStartedEvent=Hu;var Ku=class extends oe{constructor(e,t){super("OCSPCacheEntryExpiredEvent",de.EventType.Debug,e),this.privExpireTime=t}};D.OCSPCacheEntryExpiredEvent=Ku;var Ju=class extends oe{constructor(e,t,r){super("OCSPCacheEntryNeedsRefreshEvent",de.EventType.Debug,e),this.privExpireTime=r,this.privStartTime=t}};D.OCSPCacheEntryNeedsRefreshEvent=Ju;var Gu=class extends oe{constructor(e,t,r){super("OCSPCacheHitEvent",de.EventType.Debug,e),this.privExpireTime=r,this.privExpireTimeString=new Date(r).toLocaleDateString(),this.privStartTime=t,this.privStartTimeString=new Date(t).toLocaleTimeString()}};D.OCSPCacheHitEvent=Gu;var $u=class extends oe{constructor(e,t){super("OCSPVerificationFailedEvent",de.EventType.Debug,e),this.privError=t}};D.OCSPVerificationFailedEvent=$u;var Qu=class extends oe{constructor(e,t){super("OCSPCacheFetchErrorEvent",de.EventType.Debug,e),this.privError=t}};D.OCSPCacheFetchErrorEvent=Qu;var Yu=class extends oe{constructor(e){super("OCSPResponseRetrievedEvent",de.EventType.Debug,e)}};D.OCSPResponseRetrievedEvent=Yu;var Xu=class extends oe{constructor(e,t){super("OCSPCacheUpdateErrorEvent",de.EventType.Debug,e),this.privError=t}};D.OCSPCacheUpdateErrorEvent=Xu});var nm=p(Ls=>{"use strict";Object.defineProperty(Ls,"__esModule",{value:!0});Ls.BackgroundEvent=void 0;var im=P(),Zu=class extends im.PlatformEvent{constructor(e){super("BackgroundEvent",im.EventType.Error),this.privError=e}get error(){return this.privError}};Ls.BackgroundEvent=Zu});var P=p(b=>{"use strict";var mw=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)&&mw(e,i,t)};Object.defineProperty(b,"__esModule",{value:!0});N(nu(),b);N(Rg(),b);N(mu(),b);N(Eg(),b);N(wg(),b);N(Pu(),b);N(ot(),b);N(Tg(),b);N(Eu(),b);N(rr(),b);N(Ag(),b);N(bg(),b);N(Mg(),b);N(kg(),b);N(xg(),b);N(zg(),b);N(Lg(),b);N(Fg(),b);N(Ug(),b);N(Hg(),b);N(Iu(),b);N(ui(),b);N(Au(),b);N(Du(),b);N(Jg(),b);N(Gg(),b);N(Yg(),b);var Sw=qs();Object.defineProperty(b,"TranslationStatus",{enumerable:!0,get:function(){return Sw.TranslationStatus}});N(Xg(),b);N(em(),b);N(tm(),b);N(rm(),b);N(nm(),b)});var we=p(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.HeaderNames=void 0;var Le=class{};Bs.HeaderNames=Le;Le.AuthKey="Ocp-Apim-Subscription-Key";Le.Authorization="Authorization";Le.SpIDAuthKey="Apim-Subscription-Id";Le.ConnectionId="X-ConnectionId";Le.ContentType="Content-Type";Le.CustomCommandsAppId="X-CommandsAppId";Le.Path="Path";Le.RequestId="X-RequestId";Le.RequestStreamId="X-StreamId";Le.RequestTimestamp="X-Timestamp"});var Vs=p(Fs=>{"use strict";Object.defineProperty(Fs,"__esModule",{value:!0});Fs.AuthInfo=void 0;var ed=class{constructor(e,t){this.privHeaderName=e,this.privToken=t}get headerName(){return this.privHeaderName}get token(){return this.privToken}};Fs.AuthInfo=ed});var sm=p(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});Us.CognitiveSubscriptionKeyAuthentication=void 0;var yw=P(),Cw=we(),Pw=Vs(),td=class{constructor(e){if(!e)throw new yw.ArgumentNullError("subscriptionKey");this.privAuthInfo=new Pw.AuthInfo(Cw.HeaderNames.AuthKey,e)}fetch(e){return Promise.resolve(this.privAuthInfo)}fetchOnExpiry(e){return Promise.resolve(this.privAuthInfo)}};Us.CognitiveSubscriptionKeyAuthentication=td});var pm=p(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});Hs.CognitiveTokenAuthentication=void 0;var om=P(),am=Vs(),cm=we(),Ws=class i{constructor(e,t){if(!e)throw new om.ArgumentNullError("fetchCallback");if(!t)throw new om.ArgumentNullError("fetchOnExpiryCallback");this.privFetchCallback=e,this.privFetchOnExpiryCallback=t}fetch(e){return this.privFetchCallback(e).then(t=>new am.AuthInfo(cm.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}fetchOnExpiry(e){return this.privFetchOnExpiryCallback(e).then(t=>new am.AuthInfo(cm.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}};Hs.CognitiveTokenAuthentication=Ws;Ws.privTokenPrefix="Bearer "});var dm=p(um=>{"use strict";Object.defineProperty(um,"__esModule",{value:!0})});var lm=p(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0})});var rd=p(()=>{});var id=p(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.LogLevel=void 0;var Rw=P();Object.defineProperty(Ks,"LogLevel",{enumerable:!0,get:function(){return Rw.EventType}})});var w=p(Js=>{"use strict";Object.defineProperty(Js,"__esModule",{value:!0});Js.Contracts=void 0;var nd=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)}};Js.Contracts=nd});var fm=p(yt=>{"use strict";var Ew=yt&&yt.__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]}),ww=yt&&yt.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Iw=yt&&yt.__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)&&Ew(e,i,t);return ww(e,i),e};Object.defineProperty(yt,"__esModule",{value:!0});yt.ConsoleLoggingListener=void 0;var vm=Iw(rd()),hn=id(),Tw=w(),sd=class{constructor(e=hn.LogLevel.None){this.privLogPath=void 0,this.privEnableConsoleOutput=!0,this.privLogLevelFilter=e}set logPath(e){Tw.Contracts.throwIfNullOrUndefined(vm.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&&vm.writeFileSync(this.privLogPath,t+`
|
|
3
|
+
`,{flag:"a+"}),this.privEnableConsoleOutput)switch(e.eventType){case hn.LogLevel.Debug:console.debug(t);break;case hn.LogLevel.Info:console.info(t);break;case hn.LogLevel.Warning:console.warn(t);break;case hn.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(" | ")}};yt.ConsoleLoggingListener=sd});var mm=p(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0})});var sr=p(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.AudioStreamFormatImpl=Lt.AudioStreamFormat=Lt.AudioFormatTag=void 0;var ln;(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"})(ln=Lt.AudioFormatTag||(Lt.AudioFormatTag={}));var Gs=class{static getDefaultInputFormat(){return hi.getDefaultInputFormat()}static getWaveFormat(e,t,r,n){return new hi(e,t,r,n)}static getWaveFormatPCM(e,t,r){return new hi(e,t,r)}};Lt.AudioStreamFormat=Gs;var hi=class i extends Gs{constructor(e=16e3,t=16,r=1,n=ln.PCM){super();let s=!0;switch(n){case ln.PCM:this.formatTag=1;break;case ln.ALaw:this.formatTag=6;break;case ln.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))}};Lt.AudioStreamFormatImpl=hi});var Cm=p(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.MicAudioSource=Mr.AudioWorkletSourceURLPropertyName=void 0;var Sm=C(),he=P(),ym=sr();Mr.AudioWorkletSourceURLPropertyName="MICROPHONE-WorkletSourceUrl";var $s=class i{constructor(e,t,r,n){this.privRecorder=e,this.deviceId=t,this.privStreams={},this.privOutputChunkSize=i.AUDIOFORMAT.avgBytesPerSec/10,this.privId=r||he.createNoDashGuid(),this.privEvents=new he.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 he.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 he.AudioSourceInitializingEvent(this.privId)),this.privMediaStream&&this.privMediaStream.active?(this.onEvent(new he.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()):t({audio:this.deviceId?{deviceId:this.deviceId}:!0,video:!1},n=>{this.privMediaStream=n,this.onEvent(new he.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()},n=>{let s=`Error occurred during microphone initialization: ${n}`;this.privInitializeDeferral.reject(s),this.onEvent(new he.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 he.AudioSourceErrorEvent(r,""))}return this.privInitializeDeferral.promise}id(){return this.privId}attach(e){return this.onEvent(new he.AudioStreamNodeAttachingEvent(this.privId,e)),this.listen(e).then(t=>(this.onEvent(new he.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(t.readEnded(),delete this.privStreams[e],this.onEvent(new he.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 he.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 he.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:Sm.connectivity.Unknown,manufacturer:"Speech SDK",model:e,samplerate:i.AUDIOFORMAT.samplesPerSec,type:Sm.type.Microphones}))}setProperty(e,t){if(e===Mr.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 he.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 he.ChunkedArrayBufferStream(this.privOutputChunkSize,e);this.privStreams[e]=t;try{this.privRecorder.record(this.privContext,this.privMediaStream,t)}catch(n){throw this.onEvent(new he.AudioStreamNodeErrorEvent(this.privId,e,n)),n}return t}onEvent(e){this.privEvents.onEvent(e),he.Events.instance.onEvent(e)}createAudioContext(){this.privContext||(this.privContext=ym.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()}};Mr.MicAudioSource=$s;$s.AUDIOFORMAT=ym.AudioStreamFormat.getDefaultInputFormat()});var Rm=p(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.FileAudioSource=void 0;var Pm=C(),ke=P(),_w=sr(),od=class{constructor(e,t,r){this.privStreams={},this.privHeaderEnd=44,this.privId=r||ke.createNoDashGuid(),this.privEvents=new ke.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 ke.AudioSourceErrorEvent(e,"")),Promise.reject(e)}this.onEvent(new ke.AudioSourceInitializingEvent(this.privId)),this.onEvent(new ke.AudioSourceReadyEvent(this.privId))}id(){return this.privId}async attach(e){this.onEvent(new ke.AudioStreamNodeAttachingEvent(this.privId,e));let t=await this.upload(e);return this.onEvent(new ke.AudioStreamNodeAttachedEvent(this.privId,e)),Promise.resolve({detach:async()=>{t.readEnded(),delete this.privStreams[e],this.onEvent(new ke.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 ke.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 ke.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:Pm.connectivity.Unknown,manufacturer:"Speech SDK",model:"File",samplerate:e.samplesPerSec,type:Pm.type.File}))}readHeader(){let t=this.privSource.slice(0,4296),r=new ke.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),d=o.getUint32(24,!0),h=o.getUint16(34,!0),l=36+Math.max(c-16,0);for(;a(l)!=="data";l+=2)if(l>4288){r.reject("Invalid WAV header in file, data block was not found");return}this.privHeaderEnd=l+8,r.resolve(_w.AudioStreamFormat.getWaveFormatPCM(d,h,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 ke.AudioStreamNodeErrorEvent(this.privId,e,n)),new Error(n)};try{await this.turnOn();let r=await this.privAudioFormatPromise,n=new ke.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),ke.Events.instance.onEvent(e)}};Qs.FileAudioSource=od});var Em=p(Ys=>{"use strict";Object.defineProperty(Ys,"__esModule",{value:!0});Ys.PcmRecorder=void 0;var Aw=P(),ad=class{constructor(e){this.privStopInputOnRelease=e}record(e,t,r){let s=new Aw.RiffPcmEncoder(e.sampleRate,16e3),o=e.createMediaStreamSource(t),a=()=>{let u=(()=>{let d=0;try{return e.createScriptProcessor(d,1,1)}catch{d=2048;let l=e.sampleRate;for(;d<16384&&l>=32e3;)d<<=1,l>>=1;return e.createScriptProcessor(d,1,1)}})();u.onaudioprocess=d=>{let h=d.inputBuffer.getChannelData(0);if(r&&!r.isClosed){let l=s.encode(h);l&&r.writeStreamChunk({buffer:l,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);`,d=new Blob([u],{type:"application/javascript; charset=utf-8"});this.privSpeechProcessorScript=URL.createObjectURL(d)}e.audioWorklet.addModule(this.privSpeechProcessorScript).then(()=>{let u=new AudioWorkletNode(e,"speech-processor");u.port.onmessage=d=>{let h=d.data;if(r&&!r.isClosed){let l=s.encode(h);l&&r.writeStreamChunk({buffer:l,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}};Qs.PcmRecorder=ad});var Im=p(()=>{});var Tm=p(()=>{});var _m=p(()=>{});var Am=p(()=>{});var bm=p(()=>{});var pd=p(Ke=>{"use strict";var Ow=Ke&&Ke.__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]}),Mw=Ke&&Ke.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Om=Ke&&Ke.__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 Mw(e,i),e},cd=Ke&&Ke.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ke,"__esModule",{value:!0});Ke.WebsocketMessageAdapter=void 0;var Dw=Om(Im()),kw=Om(Tm()),Nw=cd(_m()),xw=cd(Am()),qw=cd(bm()),zw=we(),T=P(),Ys=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[zw.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 qw.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 Nw.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 xw.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(kw.connect(t)):r=Promise.resolve(Dw.connect(t));return r}get isWebsocketOpen(){return this.privWebsocketClient&&this.privWebsocketClient.readyState===this.privWebsocketClient.OPEN}};Ke.WebsocketMessageAdapter=Ys;Ys.forceNpmWebSocket=!1});var Mm=p(Xs=>{"use strict";Object.defineProperty(Xs,"__esModule",{value:!0});Xs.WebsocketConnection=void 0;var ud=P(),jw=pd(),dd=class{constructor(e,t,r,n,s,o=!1,a){if(this.privIsDisposed=!1,!e)throw new ud.ArgumentNullError("uri");if(!n)throw new ud.ArgumentNullError("messageFormatter");this.privMessageFormatter=n;let c="",u=0;if(t){for(let d in t)if(d){c+=u===0&&e.indexOf("?")===-1?"?":"&";let h=encodeURIComponent(d);c+=h;let l=t[d];l&&(l=encodeURIComponent(l),c+=`=${l}`),u++}}if(r){for(let d in r)if(d){c+=u===0&&e.indexOf("?")===-1?"?":"&";let h=encodeURIComponent(r[d]);c+=`${d}=${h}`,u++}}this.privUri=e+c,this.privId=a||ud.createNoDashGuid(),this.privConnectionMessageAdapter=new jw.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}};Xs.WebsocketConnection=dd});var Dm=p(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.ReplayableAudioNode=void 0;var hd=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 ld(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}};Zs.ReplayableAudioNode=hd;var ld=class{constructor(e,t,r){this.chunk=e,this.serial=t,this.byteOffset=r}}});var gd=p(Ct=>{"use strict";var Lw=Ct&&Ct.__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]}),Bw=Ct&&Ct.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Fw=Ct&&Ct.__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)&&Lw(e,i,t);return Bw(e,i),e};Object.defineProperty(Ct,"__esModule",{value:!0});Ct.AudioFileWriter=void 0;var vn=Fw(rd()),vd=w(),fd=class{constructor(e){vd.Contracts.throwIfNullOrUndefined(vn.openSync,`
|
|
18
|
-
File System access not available, please use Push or PullAudioOutputStream`),this.privFd=vn.openSync(e,"w")}set format(e){vd.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=vn.createWriteStream("",{fd:this.privFd,start:t,autoClose:!1}))}write(e){vd.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),vn.writeSync(this.privFd,new Int8Array(this.privAudioFormat.header),0,this.privAudioFormat.header.byteLength,0)),vn.closeSync(this.privFd),this.privFd=void 0}),this.privWriteStream.end())}id(){return this.privId}};Ct.AudioFileWriter=fd});var md=p(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.PullAudioInputStreamImpl=Je.PullAudioInputStream=Je.PushAudioInputStreamImpl=Je.PushAudioInputStream=Je.AudioInputStream=void 0;var eo=C(),le=P(),km=ir(),Vw=f(),Uw=or(),fn=class{constructor(){}static createPushStream(e){return gn.create(e)}static createPullStream(e,t){return mn.create(e,t)}};Je.AudioInputStream=fn;var gn=class extends fn{static create(e){return new to(e)}};Je.PushAudioInputStream=gn;var to=class extends gn{constructor(e){super(),e===void 0?this.privFormat=Uw.AudioStreamFormatImpl.getDefaultInputFormat():this.privFormat=e,this.privEvents=new le.EventSource,this.privId=km.createNoDashGuid(),this.privStream=new le.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 le.AudioSourceInitializingEvent(this.privId)),this.onEvent(new le.AudioSourceReadyEvent(this.privId))}async attach(e){this.onEvent(new le.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn();let t=this.privStream;return this.onEvent(new le.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(this.onEvent(new le.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}}detach(e){this.onEvent(new le.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:eo.connectivity.Unknown,manufacturer:"Speech SDK",model:"PushStream",samplerate:this.privFormat.samplesPerSec,type:eo.type.Stream})}onEvent(e){this.privEvents.onEvent(e),le.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}};Je.PushAudioInputStreamImpl=to;var mn=class extends fn{constructor(){super()}static create(e,t){return new ro(e,t)}};Je.PullAudioInputStream=mn;var ro=class extends mn{constructor(e,t){super(),t===void 0?this.privFormat=Vw.AudioStreamFormat.getDefaultInputFormat():this.privFormat=t,this.privEvents=new le.EventSource,this.privId=km.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 le.AudioSourceInitializingEvent(this.privId)),this.onEvent(new le.AudioSourceReadyEvent(this.privId))}async attach(e){return this.onEvent(new le.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn(),this.onEvent(new le.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:()=>(this.privCallback.close(),this.onEvent(new le.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 le.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:eo.connectivity.Unknown,manufacturer:"Speech SDK",model:"PullStream",samplerate:this.privFormat.samplesPerSec,type:eo.type.Stream})}onEvent(e){this.privEvents.onEvent(e),le.Events.instance.onEvent(e)}};Je.PullAudioInputStreamImpl=ro});var Sd=p(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.SpeechSynthesisOutputFormat=void 0;var Ww;(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"})(Ww=Sn.SpeechSynthesisOutputFormat||(Sn.SpeechSynthesisOutputFormat={}))});var li=p(no=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});no.AudioOutputFormatImpl=void 0;var O=Sd(),A=or(),io=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}};no.AudioOutputFormatImpl=io;io.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 Dr=p(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.PushAudioOutputStreamImpl=Ge.PushAudioOutputStream=Ge.PullAudioOutputStreamImpl=Ge.PullAudioOutputStream=Ge.AudioOutputStream=void 0;var yd=P(),Hw=w(),Kw=li(),yn=class{constructor(){}static createPullStream(){return Cn.create()}};Ge.AudioOutputStream=yn;var Cn=class extends yn{static create(){return new so}};Ge.PullAudioOutputStream=Cn;var so=class extends Cn{constructor(){super(),this.privId=yd.createNoDashGuid(),this.privStream=new yd.Stream}set format(e){e==null&&(this.privFormat=Kw.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){Hw.Contracts.throwIfNullOrUndefined(this.privStream,"must set format before writing"),this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}};Ge.PullAudioOutputStreamImpl=so;var oo=class extends yn{constructor(){super()}static create(e){return new ao(e)}};Ge.PushAudioOutputStream=oo;var ao=class extends oo{constructor(e){super(),this.privId=yd.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}};Ge.PushAudioOutputStreamImpl=ao});var Cd=p(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.AudioOutputConfigImpl=ar.AudioConfigImpl=ar.AudioConfig=void 0;var kr=ae(),Jw=w(),Nr=f(),Gw=gd(),$w=md(),Qw=Dr(),Pn=class i{static fromDefaultMicrophoneInput(){let e=new kr.PcmRecorder(!0);return new Bt(new kr.MicAudioSource(e))}static fromMicrophoneInput(e){let t=new kr.PcmRecorder(!0);return new Bt(new kr.MicAudioSource(t,e))}static fromWavFileInput(e,t="unnamedBuffer.wav"){return new Bt(new kr.FileAudioSource(e,t))}static fromStreamInput(e){if(e instanceof Nr.PullAudioInputStreamCallback)return new Bt(new $w.PullAudioInputStreamImpl(e));if(e instanceof Nr.AudioInputStream)return new Bt(e);if(typeof MediaStream<"u"&&e instanceof MediaStream){let t=new kr.PcmRecorder(!1);return new Bt(new kr.MicAudioSource(t,null,null,e))}throw new Error("Not Supported Type")}static fromDefaultSpeakerOutput(){return new Ft(new Nr.SpeakerAudioDestination)}static fromSpeakerOutput(e){if(e===void 0)return i.fromDefaultSpeakerOutput();if(e instanceof Nr.SpeakerAudioDestination)return new Ft(e);throw new Error("Not Supported Type")}static fromAudioFileOutput(e){return new Ft(new Gw.AudioFileWriter(e))}static fromStreamOutput(e){if(e instanceof Nr.PushAudioOutputStreamCallback)return new Ft(new Qw.PushAudioOutputStreamImpl(e));if(e instanceof Nr.PushAudioOutputStream)return new Ft(e);if(e instanceof Nr.PullAudioOutputStream)return new Ft(e);throw new Error("Not Supported Type")}};ar.AudioConfig=Pn;var Bt=class extends Pn{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(Jw.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}};ar.AudioConfigImpl=Bt;var Ft=class extends Pn{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.")}};ar.AudioOutputConfigImpl=Ft});var Nm=p(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.CancellationReason=void 0;var Yw;(function(i){i[i.Error=0]="Error",i[i.EndOfStream=1]="EndOfStream"})(Yw=Rn.CancellationReason||(Rn.CancellationReason={}))});var xm=p(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.PullAudioInputStreamCallback=void 0;var Pd=class{};co.PullAudioInputStreamCallback=Pd});var qm=p(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.PushAudioOutputStreamCallback=void 0;var Rd=class{};po.PushAudioOutputStreamCallback=Rd});var jm=p(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.KeywordRecognitionModel=void 0;var zm=w(),Ed=class{constructor(){this.privDisposed=!1}static fromFile(e){throw zm.Contracts.throwIfFileDoesNotExist(e,"fileName"),new Error("Not yet implemented.")}static fromStream(e){throw zm.Contracts.throwIfNull(e,"file"),new Error("Not yet implemented.")}close(){this.privDisposed||(this.privDisposed=!0)}};uo.KeywordRecognitionModel=Ed});var Lm=p(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.SessionEventArgs=void 0;var wd=class{constructor(e){this.privSessionId=e}get sessionId(){return this.privSessionId}};ho.SessionEventArgs=wd});var Bm=p(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});lo.RecognitionEventArgs=void 0;var Xw=f(),Id=class extends Xw.SessionEventArgs{constructor(e,t){super(t),this.privOffset=e}get offset(){return this.privOffset}};lo.RecognitionEventArgs=Id});var Fm=p(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.OutputFormat=void 0;var Zw;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(Zw=En.OutputFormat||(En.OutputFormat={}))});var Vm=p(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.IntentRecognitionEventArgs=void 0;var eI=f(),Td=class extends eI.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};vo.IntentRecognitionEventArgs=Td});var Um=p(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.RecognitionResult=void 0;var _d=class{constructor(e,t,r,n,s,o,a,c,u,d){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=d}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}};fo.RecognitionResult=_d});var Wm=p(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.SpeechRecognitionResult=void 0;var tI=f(),Ad=class extends tI.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(e,t,r,n,s,o,a,u,d,h),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};go.SpeechRecognitionResult=Ad});var Hm=p(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.IntentRecognitionResult=void 0;var rI=f(),bd=class extends rI.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(t,r,n,s,o,a,c,void 0,u,d,h),this.privIntentId=e}get intentId(){return this.privIntentId}};mo.IntentRecognitionResult=bd});var Km=p(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.LanguageUnderstandingModelImpl=gi.LanguageUnderstandingModel=void 0;var vi=w(),So=class{constructor(){}static fromEndpoint(e){vi.Contracts.throwIfNull(e,"uri"),vi.Contracts.throwIfNullOrWhitespace(e.hostname,"uri");let t=new fi,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){vi.Contracts.throwIfNullOrWhitespace(e,"appId");let t=new fi;return t.appId=e,t}static fromSubscription(e,t,r){vi.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),vi.Contracts.throwIfNullOrWhitespace(t,"appId"),vi.Contracts.throwIfNullOrWhitespace(r,"region");let n=new fi;return n.appId=t,n.region=r,n.subscriptionKey=e,n}};gi.LanguageUnderstandingModel=So;var fi=class extends So{};gi.LanguageUnderstandingModelImpl=fi});var Gm=p(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.MeetingTranscriptionEventArgs=cr.ConversationTranscriptionEventArgs=cr.SpeechRecognitionEventArgs=void 0;var Jm=f(),yo=class extends Jm.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};cr.SpeechRecognitionEventArgs=yo;var Od=class extends Jm.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};cr.ConversationTranscriptionEventArgs=Od;var Md=class extends yo{};cr.MeetingTranscriptionEventArgs=Md});var mi=p(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});Co.CancellationEventArgsBase=void 0;var iI=f(),Dd=class extends iI.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}};Co.CancellationEventArgsBase=Dd});var $m=p(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.SpeechRecognitionCanceledEventArgs=void 0;var nI=mi(),kd=class extends nI.CancellationEventArgsBase{};Po.SpeechRecognitionCanceledEventArgs=kd});var Qm=p(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});Ro.TranslationRecognitionEventArgs=void 0;var sI=f(),Nd=class extends sI.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};Ro.TranslationRecognitionEventArgs=Nd});var Ym=p(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.TranslationSynthesisEventArgs=void 0;var oI=f(),xd=class extends oI.SessionEventArgs{constructor(e,t){super(t),this.privResult=e}get result(){return this.privResult}};Eo.TranslationSynthesisEventArgs=xd});var zd=p(wo=>{"use strict";Object.defineProperty(wo,"__esModule",{value:!0});wo.TranslationRecognitionResult=void 0;var aI=f(),qd=class i extends aI.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(t,r,n,s,o,a,c,void 0,u,d,h),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}};wo.TranslationRecognitionResult=qd});var Xm=p(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.TranslationSynthesisResult=void 0;var jd=class{constructor(e,t){this.privReason=e,this.privAudio=t}get audio(){return this.privAudio}get reason(){return this.privReason}};Io.TranslationSynthesisResult=jd});var Zm=p(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.ResultReason=void 0;var cI;(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"})(cI=wn.ResultReason||(wn.ResultReason={}))});var eS=p(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.SpeechConfigImpl=Si.SpeechConfig=void 0;var In=C(),xr=w(),I=f(),To=class{constructor(){}static fromSubscription(e,t){xr.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),xr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(I.PropertyId.SpeechServiceConnection_IntentRegion,t),r.setProperty(I.PropertyId.SpeechServiceConnection_Key,e),r}static fromEndpoint(e,t){xr.Contracts.throwIfNull(e,"endpoint");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Endpoint,e.href),t!==void 0&&r.setProperty(I.PropertyId.SpeechServiceConnection_Key,t),r}static fromHost(e,t){xr.Contracts.throwIfNull(e,"hostName");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(I.PropertyId.SpeechServiceConnection_Key,t),r}static fromAuthorizationToken(e,t){xr.Contracts.throwIfNull(e,"authorizationToken"),xr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(I.PropertyId.SpeechServiceConnection_IntentRegion,t),r.authorizationToken=e,r}close(){}};Si.SpeechConfig=To;var qr=class i extends To{constructor(){super(),this.privProperties=new I.PropertyCollection,this.speechRecognitionLanguage="en-US",this.outputFormat=I.OutputFormat.Simple}get properties(){return this.privProperties}get endPoint(){return new URL(this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Endpoint))}get subscriptionKey(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Key)}get region(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Region)}get authorizationToken(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_RecoLanguage)}set speechRecognitionLanguage(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get autoDetectSourceLanguages(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)}set autoDetectSourceLanguages(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e)}get outputFormat(){return I.OutputFormat[this.privProperties.getProperty(In.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privProperties.setProperty(In.OutputFormatPropertyName,I.OutputFormat[e])}get endpointId(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_EndpointId,e)}setProperty(e,t){xr.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(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyPassword],n)}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(In.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(In.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceResponse_ProfanityOption,I.ProfanityOption[e])}enableAudioLogging(){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privProperties.setProperty(I.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privProperties.setProperty(In.ForceDictationPropertyName,"true")}clone(){let e=new i;return e.privProperties=this.privProperties.clone(),e}get speechSynthesisLanguage(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return I.SpeechSynthesisOutputFormat[this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthOutputFormat,I.SpeechSynthesisOutputFormat[e])}};Si.SpeechConfigImpl=qr});var tS=p(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.SpeechTranslationConfigImpl=yi.SpeechTranslationConfig=void 0;var Tn=C(),at=w(),E=f(),_o=class extends E.SpeechConfig{constructor(){super()}static fromSubscription(e,t){at.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),at.Contracts.throwIfNullOrWhitespace(t,"region");let r=new zr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromAuthorizationToken(e,t){at.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),at.Contracts.throwIfNullOrWhitespace(t,"region");let r=new zr;return r.properties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromHost(e,t){at.Contracts.throwIfNull(e,"hostName");let r=new zr;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){at.Contracts.throwIfNull(e,"endpoint"),at.Contracts.throwIfNull(t,"subscriptionKey");let r=new zr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Endpoint,e.href),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}};yi.SpeechTranslationConfig=_o;var zr=class extends _o{constructor(){super(),this.privSpeechProperties=new E.PropertyCollection,this.outputFormat=E.OutputFormat.Simple}set authorizationToken(e){at.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e)}set speechRecognitionLanguage(e){at.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(Tn.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privSpeechProperties.setProperty(Tn.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){at.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){at.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(Tn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privSpeechProperties.setProperty(Tn.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(Tn.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])}};yi.SpeechTranslationConfigImpl=zr});var Bd=p(Ao=>{"use strict";Object.defineProperty(Ao,"__esModule",{value:!0});Ao.PropertyCollection=void 0;var rS=f(),Ld=class i{constructor(){this.privKeys=[],this.privValues=[]}getProperty(e,t){let r;typeof e=="string"?r=e:r=rS.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=rS.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}};Ao.PropertyCollection=Ld});var bo=p(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.PropertyId=void 0;var pI;(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"})(pI=_n.PropertyId||(_n.PropertyId={}))});var nS=p(Do=>{"use strict";Object.defineProperty(Do,"__esModule",{value:!0});Do.Recognizer=void 0;var jr=C(),iS=P(),Oo=w(),Mo=f(),Fd=class i{constructor(e,t,r){this.audioConfig=e!==void 0?e:Mo.AudioConfig.fromDefaultMicrophoneInput(),this.privDisposed=!1,this.privProperties=t.clone(),this.privConnectionFactory=r,this.implCommonRecognizerSetup()}close(e,t){Oo.Contracts.throwIfDisposed(this.privDisposed),iS.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 jr.ServiceRecognizerBase.telemetryDataEnabled}static enableTelemetry(e){jr.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 jr.SpeechServiceConfig(new jr.Context(new jr.OS(e,t,r))));this.privReco=this.createServiceRecognizer(i.getAuthFromProperties(this.privProperties),this.privConnectionFactory,this.audioConfig,n)}async recognizeOnceAsyncImpl(e){Oo.Contracts.throwIfDisposed(this.privDisposed);let t=new iS.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){Oo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop(),await this.privReco.recognize(e,void 0,void 0)}async stopContinuousRecognitionAsyncImpl(){Oo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop()}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}static getAuthFromProperties(e){let t=e.getProperty(Mo.PropertyId.SpeechServiceConnection_Key,void 0);return t&&t!==""?new jr.CognitiveSubscriptionKeyAuthentication(t):new jr.CognitiveTokenAuthentication(()=>{let n=e.getProperty(Mo.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)},()=>{let n=e.getProperty(Mo.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)})}};Do.Recognizer=Fd});var sS=p(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.SpeechRecognizer=void 0;var Ci=C(),ko=P(),pr=w(),Ne=f(),Vd=class i extends Ne.Recognizer{constructor(e,t){let r=e;pr.Contracts.throwIfNull(r,"speechConfig"),pr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_RecoLanguage),Ne.PropertyId[Ne.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Ci.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 pr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(Ne.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){pr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Ne.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return pr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return pr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ci.OutputFormatPropertyName,Ne.OutputFormat[Ne.OutputFormat.Simple])===Ne.OutputFormat[Ne.OutputFormat.Simple]?Ne.OutputFormat.Simple:Ne.OutputFormat.Detailed}get properties(){return this.privProperties}recognizeOnceAsync(e,t){ko.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Ci.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){ko.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Ci.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){ko.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){pr.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e){e&&e()}close(e,t){pr.Contracts.throwIfDisposed(this.privDisposedRecognizer),ko.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 Ci.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Ci.SpeechServiceRecognizer(e,t,s,n,this)}};No.SpeechRecognizer=Vd});var oS=p(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});qo.IntentRecognizer=void 0;var Lr=C(),xo=P(),Ie=w(),Vt=f(),Ud=class extends Vt.Recognizer{constructor(e,t){Ie.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;Ie.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new Lr.IntentConnectionFactory),this.privAddedIntents=[],this.privAddedLmIntents={},this.privDisposedIntentRecognizer=!1,this.privProperties=r.properties,Ie.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(Vt.PropertyId.SpeechServiceConnection_RecoLanguage),Vt.PropertyId[Vt.PropertyId.SpeechServiceConnection_RecoLanguage])}get speechRecognitionLanguage(){return Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.properties.getProperty(Vt.PropertyId.SpeechServiceConnection_RecoLanguage)}get authorizationToken(){return this.properties.getProperty(Vt.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(Vt.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}recognizeOnceAsync(e,t){if(Ie.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)}xo.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Lr.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)}xo.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Lr.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){xo.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){Ie.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e,t){if(e)try{e()}catch(r){t&&t(r)}}addIntent(e,t){Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Ie.Contracts.throwIfNullOrWhitespace(t,"intentId"),Ie.Contracts.throwIfNullOrWhitespace(e,"simplePhrase"),this.privAddedIntents.push([t,e])}addIntentWithLanguageModel(e,t,r){Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Ie.Contracts.throwIfNullOrWhitespace(e,"intentId"),Ie.Contracts.throwIfNull(t,"model");let n=t;Ie.Contracts.throwIfNullOrWhitespace(n.appId,"model.appId"),this.privAddedLmIntents[e]=new Lr.AddedLmIntent(n,r)}addAllIntents(e,t){Ie.Contracts.throwIfNull(e,"model");let r=e;Ie.Contracts.throwIfNullOrWhitespace(r.appId,"model.appId"),this.privUmbrellaIntent=new Lr.AddedLmIntent(r,t)}close(e,t){Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),xo.marshalPromiseToCallbacks(this.dispose(!0),e,t)}createRecognizerConfig(e){return new Lr.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Lr.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(Vt.PropertyId[Vt.PropertyId.SpeechServiceConnection_Key]):r,provider:"LUIS"},ReferenceGrammars:this.privUmbrellaIntent===void 0?n:["luis/"+e+"-PRODUCTION"]}}};qo.IntentRecognizer=Ud});var aS=p(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.VoiceProfileType=void 0;var uI;(function(i){i[i.TextIndependentIdentification=0]="TextIndependentIdentification",i[i.TextDependentVerification=1]="TextDependentVerification",i[i.TextIndependentVerification=2]="TextIndependentVerification"})(uI=An.VoiceProfileType||(An.VoiceProfileType={}))});var Kd=p(Pi=>{"use strict";Object.defineProperty(Pi,"__esModule",{value:!0});Pi.ConnectionMessageImpl=Pi.ConnectionMessage=void 0;var cS=we(),pS=P(),dI=Bd(),hI=bo(),Wd=class{};Pi.ConnectionMessage=Wd;var Hd=class{constructor(e){this.privConnectionMessage=e,this.privProperties=new dI.PropertyCollection,this.privConnectionMessage.headers[cS.HeaderNames.ConnectionId]&&this.privProperties.setProperty(hI.PropertyId.Speech_SessionId,this.privConnectionMessage.headers[cS.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===pS.MessageType.Text}get isBinaryMessage(){return this.privConnectionMessage.messageType===pS.MessageType.Binary}get TextMessage(){return this.privConnectionMessage.textBody}get binaryMessage(){return this.privConnectionMessage.binaryBody}get properties(){return this.privProperties}toString(){return""}};Pi.ConnectionMessageImpl=Hd});var Qd=p(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.Connection=void 0;var Jd=C(),Gd=P(),uS=Kd(),lI=w(),bn=f(),$d=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){Gd.marshalPromiseToCallbacks(this.privInternalData.connect(),e,t)}closeConnection(e,t){if(this.privInternalData instanceof Jd.SynthesisAdapterBase)throw new Error("Disconnecting a synthesizer's connection is currently not supported");Gd.marshalPromiseToCallbacks(this.privInternalData.disconnect(),e,t)}setMessageProperty(e,t,r){if(lI.Contracts.throwIfNullOrWhitespace(t,"propertyName"),this.privInternalData instanceof Jd.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 Jd.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){Gd.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 bn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionClosedEvent"?this.disconnected&&this.disconnected(new bn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionMessageSentEvent"?this.messageSent&&this.messageSent(new bn.ConnectionMessageEventArgs(new uS.ConnectionMessageImpl(e.message))):e.name==="ConnectionMessageReceivedEvent"&&this.messageReceived&&this.messageReceived(new bn.ConnectionMessageEventArgs(new uS.ConnectionMessageImpl(e.message)))}),this.privServiceEventListener=this.privInternalData.serviceEvents.attach(e=>{this.receivedServiceMessage&&this.receivedServiceMessage(new bn.ServiceEventArgs(e.jsonString,e.name))})}};zo.Connection=$d});var dS=p(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.TranslationRecognizer=void 0;var On=C(),jo=P(),vI=Qd(),ct=w(),$=f(),Yd=class i extends $.Recognizer{constructor(e,t,r){let n=e;ct.Contracts.throwIfNull(n,"speechConfig"),super(t,n.properties,r||new On.TranslationConnectionFactory),this.privDisposedTranslationRecognizer=!1,this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)!==void 0&&ct.Contracts.throwIfNullOrWhitespace(this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationVoice),$.PropertyId[$.PropertyId.SpeechServiceConnection_TranslationVoice]),ct.Contracts.throwIfNullOrWhitespace(this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages),$.PropertyId[$.PropertyId.SpeechServiceConnection_TranslationToLanguages]),ct.Contracts.throwIfNullOrWhitespace(this.properties.getProperty($.PropertyId.SpeechServiceConnection_RecoLanguage),$.PropertyId[$.PropertyId.SpeechServiceConnection_RecoLanguage])}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get speechRecognitionLanguage(){return ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty($.PropertyId.SpeechServiceConnection_RecoLanguage)}get targetLanguages(){return ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",")}get voiceName(){return ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty($.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty($.PropertyId.SpeechServiceAuthorization_Token,e)}recognizeOnceAsync(e,t){ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),jo.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(On.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){jo.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(On.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){jo.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}removeTargetLanguage(e){if(ct.Contracts.throwIfNullOrUndefined(e,"language to be removed"),this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0){let t=this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),r=t.indexOf(e);r>-1&&(t.splice(r,1),this.properties.setProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")),this.updateLanguages(t))}}addTargetLanguage(e){ct.Contracts.throwIfNullOrUndefined(e,"language to be added");let t=[];this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?(t=this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),t.includes(e)||(t.push(e),this.properties.setProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))):(this.properties.setProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,e),t=[e]),this.updateLanguages(t)}close(e,t){ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),jo.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 On.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new On.TranslationServiceRecognizer(e,t,s,n,this)}updateLanguages(e){let t=vI.Connection.fromRecognizer(this);t&&(t.setMessageProperty("speech.context","translationcontext",{to:e}),t.sendMessageAsync("event",JSON.stringify({id:"translation",name:"updateLanguage",to:e})))}};Lo.TranslationRecognizer=Yd});var hS=p(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.Translations=void 0;var fI=f(),Xd=class{constructor(){this.privMap=new fI.PropertyCollection}get languages(){return this.privMap.keys}get(e,t){return this.privMap.getProperty(e,t)}set(e,t){this.privMap.setProperty(e,t)}};Bo.Translations=Xd});var lS=p(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.NoMatchReason=void 0;var gI;(function(i){i[i.NotRecognized=0]="NotRecognized",i[i.InitialSilenceTimeout=1]="InitialSilenceTimeout",i[i.InitialBabbleTimeout=2]="InitialBabbleTimeout"})(gI=Mn.NoMatchReason||(Mn.NoMatchReason={}))});var vS=p(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.NoMatchDetails=void 0;var Zd=C(),Fo=f(),eh=class i{constructor(e){this.privReason=e}static fromResult(e){let t=Zd.SimpleSpeechPhrase.fromJSON(e.json),r=Fo.NoMatchReason.NotRecognized;switch(t.RecognitionStatus){case Zd.RecognitionStatus.BabbleTimeout:r=Fo.NoMatchReason.InitialBabbleTimeout;break;case Zd.RecognitionStatus.InitialSilenceTimeout:r=Fo.NoMatchReason.InitialSilenceTimeout;break;default:r=Fo.NoMatchReason.NotRecognized;break}return new i(r)}get reason(){return this.privReason}};Vo.NoMatchDetails=eh});var fS=p(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.TranslationRecognitionCanceledEventArgs=void 0;var th=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}};Uo.TranslationRecognitionCanceledEventArgs=th});var gS=p(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.IntentRecognitionCanceledEventArgs=void 0;var mI=f(),rh=class extends mI.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}};Wo.IntentRecognitionCanceledEventArgs=rh});var nh=p(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});Ho.CancellationDetailsBase=void 0;var ih=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}};Ho.CancellationDetailsBase=ih});var mS=p(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.CancellationDetails=void 0;var Ko=C(),SI=nh(),Ri=f(),sh=class i extends SI.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=Ri.CancellationReason.Error,r=Ri.CancellationErrorCode.NoError;if(e instanceof Ri.RecognitionResult&&e.json){let n=Ko.SimpleSpeechPhrase.fromJSON(e.json);t=Ko.EnumTranslation.implTranslateCancelResult(n.RecognitionStatus)}return e.properties&&(r=Ri.CancellationErrorCode[e.properties.getProperty(Ko.CancellationErrorCodePropertyName,Ri.CancellationErrorCode[Ri.CancellationErrorCode.NoError])]),new i(t,e.errorDetails||Ko.EnumTranslation.implTranslateErrorDetails(r),r)}};Jo.CancellationDetails=sh});var SS=p(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.CancellationErrorCode=void 0;var yI;(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"})(yI=Dn.CancellationErrorCode||(Dn.CancellationErrorCode={}))});var yS=p(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.ConnectionEventArgs=void 0;var CI=f(),oh=class extends CI.SessionEventArgs{};Go.ConnectionEventArgs=oh});var CS=p($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.ServiceEventArgs=void 0;var PI=f(),ah=class extends PI.SessionEventArgs{constructor(e,t,r){super(r),this.privJsonResult=e,this.privEventName=t}get jsonString(){return this.privJsonResult}get eventName(){return this.privEventName}};$o.ServiceEventArgs=ah});var PS=p(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.PhraseListGrammar=void 0;var ch=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()}};Qo.PhraseListGrammar=ch});var Xo=p(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.DialogServiceConfigImpl=Ei.DialogServiceConfig=void 0;var RI=w(),kn=f(),Yo=class{constructor(){}set applicationId(e){}static get DialogTypes(){return{BotFramework:"bot_framework",CustomCommands:"custom_commands"}}};Ei.DialogServiceConfig=Yo;var ph=class extends Yo{constructor(){super(),this.privSpeechConfig=new kn.SpeechConfigImpl}get properties(){return this.privSpeechConfig.properties}get speechRecognitionLanguage(){return this.privSpeechConfig.speechRecognitionLanguage}set speechRecognitionLanguage(e){RI.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(kn.PropertyId.SpeechServiceConnection_ProxyHostName,e),this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyPort,`${t}`),r&&this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyUserName,r),n&&this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyPassword,n)}setServiceProperty(e,t,r){this.privSpeechConfig.setServiceProperty(e,t)}close(){}};Ei.DialogServiceConfigImpl=ph});var RS=p(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.BotFrameworkConfig=void 0;var Br=w(),Ut=Xo(),xe=f(),uh=class extends Ut.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){Br.Contracts.throwIfNullOrWhitespace(e,"subscription"),Br.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Ut.DialogServiceConfigImpl;return n.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(xe.PropertyId.SpeechServiceConnection_Key,e),n.setProperty(xe.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(xe.PropertyId.Conversation_ApplicationId,r),n}static fromAuthorizationToken(e,t,r){Br.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),Br.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Ut.DialogServiceConfigImpl;return n.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(xe.PropertyId.SpeechServiceAuthorization_Token,e),n.setProperty(xe.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(xe.PropertyId.Conversation_ApplicationId,r),n}static fromHost(e,t,r){Br.Contracts.throwIfNullOrUndefined(e,"host");let n=e instanceof URL?e:new URL(`wss://${e}.convai.speech.azure.us`);Br.Contracts.throwIfNullOrUndefined(n,"resolvedHost");let s=new Ut.DialogServiceConfigImpl;return s.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),s.setProperty(xe.PropertyId.SpeechServiceConnection_Host,n.toString()),t!==void 0&&s.setProperty(xe.PropertyId.SpeechServiceConnection_Key,t),s}static fromEndpoint(e,t){Br.Contracts.throwIfNull(e,"endpoint");let r=new Ut.DialogServiceConfigImpl;return r.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),r.setProperty(xe.PropertyId.SpeechServiceConnection_Endpoint,e.toString()),t!==void 0&&r.setProperty(xe.PropertyId.SpeechServiceConnection_Key,t),r}};Zo.BotFrameworkConfig=uh});var ES=p(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});ea.CustomCommandsConfig=void 0;var Fr=w(),Nn=Xo(),Pt=f(),dh=class extends Nn.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){Fr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),Fr.Contracts.throwIfNullOrWhitespace(t,"subscription"),Fr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new Nn.DialogServiceConfigImpl;return n.setProperty(Pt.PropertyId.Conversation_DialogType,Nn.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(Pt.PropertyId.Conversation_ApplicationId,e),n.setProperty(Pt.PropertyId.SpeechServiceConnection_Key,t),n.setProperty(Pt.PropertyId.SpeechServiceConnection_Region,r),n}static fromAuthorizationToken(e,t,r){Fr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),Fr.Contracts.throwIfNullOrWhitespace(t,"authorizationToken"),Fr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new Nn.DialogServiceConfigImpl;return n.setProperty(Pt.PropertyId.Conversation_DialogType,Nn.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(Pt.PropertyId.Conversation_ApplicationId,e),n.setProperty(Pt.PropertyId.SpeechServiceAuthorization_Token,t),n.setProperty(Pt.PropertyId.SpeechServiceConnection_Region,r),n}set applicationId(e){Fr.Contracts.throwIfNullOrWhitespace(e,"value"),this.setProperty(Pt.PropertyId.Conversation_ApplicationId,e)}get applicationId(){return this.getProperty(Pt.PropertyId.Conversation_ApplicationId)}};ea.CustomCommandsConfig=dh});var Wt=p(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.QueryParameterNames=void 0;var H=class{};ta.QueryParameterNames=H;H.BotId="botid";H.CustomSpeechDeploymentId="cid";H.CustomVoiceDeploymentId="deploymentId";H.EnableAudioLogging="storeAudio";H.EnableLanguageId="lidEnabled";H.EnableWordLevelTimestamps="wordLevelTimestamps";H.EndSilenceTimeoutMs="endSilenceTimeoutMs";H.SegmentationSilenceTimeoutMs="segmentationSilenceTimeoutMs";H.Format="format";H.InitialSilenceTimeoutMs="initialSilenceTimeoutMs";H.Language="language";H.Profanity="profanity";H.RequestBotStatusMessages="enableBotMessageStatus";H.StableIntermediateThreshold="stableIntermediateThreshold";H.StableTranslation="stableTranslation";H.TestHooks="testhooks";H.Postprocessing="postprocessing";H.CtsMeetingId="meetingId";H.CtsDeviceId="deviceId";H.CtsIsParticipant="isParticipant";H.EnableAvatar="enableTalkingAvatar"});var $e=p(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.ConnectionFactoryBase=void 0;var EI=C(),ur=f(),dr=Wt(),hh=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([[ur.PropertyId.Speech_SegmentationSilenceTimeoutMs,dr.QueryParameterNames.SegmentationSilenceTimeoutMs],[ur.PropertyId.SpeechServiceConnection_EnableAudioLogging,dr.QueryParameterNames.EnableAudioLogging],[ur.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,dr.QueryParameterNames.EndSilenceTimeoutMs],[ur.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,dr.QueryParameterNames.InitialSilenceTimeoutMs],[ur.PropertyId.SpeechServiceResponse_PostProcessingOption,dr.QueryParameterNames.Postprocessing],[ur.PropertyId.SpeechServiceResponse_ProfanityOption,dr.QueryParameterNames.Profanity],[ur.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,dr.QueryParameterNames.EnableWordLevelTimestamps],[ur.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,dr.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(EI.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())}};ra.ConnectionFactoryBase=hh});var _S=p(na=>{"use strict";Object.defineProperty(na,"__esModule",{value:!0});na.DialogConnectionFactory=void 0;var wS=ae(),wI=C(),Be=f(),IS=$e(),II=C(),TS=we(),ia=Wt(),xn=class i extends IS.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Be.PropertyId.Conversation_ApplicationId,""),s=e.parameters.getProperty(Be.PropertyId.Conversation_DialogType),o=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_Region),a=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),c=e.parameters.getProperty(Be.PropertyId.Conversation_Request_Bot_Status_Messages,"true"),u={};u[TS.HeaderNames.ConnectionId]=r,u[ia.QueryParameterNames.Format]=e.parameters.getProperty(wI.OutputFormatPropertyName,Be.OutputFormat[Be.OutputFormat.Simple]).toLowerCase(),u[ia.QueryParameterNames.Language]=a,u[ia.QueryParameterNames.RequestBotStatusMessages]=c,n&&(u[ia.QueryParameterNames.BotId]=n,s===Be.DialogServiceConfig.DialogTypes.CustomCommands&&(u[TS.HeaderNames.CustomCommandsAppId]=n));let d=s===Be.DialogServiceConfig.DialogTypes.CustomCommands?"commands/":"",h=s===Be.DialogServiceConfig.DialogTypes.CustomCommands?"v1":s===Be.DialogServiceConfig.DialogTypes.BotFramework?"v3":"v0",l={};t.token!=null&&t.token!==""&&(l[t.headerName]=t.token);let g=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_Endpoint,"");if(!g){let M=IS.ConnectionFactoryBase.getHostSuffix(o),J=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_Host,`wss://${o}.${i.BaseUrl}${M}`);g=`${J.endsWith("/")?J:J+"/"}${d}${i.ApiKey}/${h}`}this.setCommonUrlParams(e,u,g);let _=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new wS.WebsocketConnection(g,u,l,new II.WebsocketMessageFormatter,wS.ProxyInfo.fromRecognizerConfig(e),_,r)}};na.DialogConnectionFactory=xn;xn.ApiKey="api";xn.BaseUrl="convai.speech"});var AS=p(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0});oa.DialogServiceConnector=void 0;var TI=_S(),lh=C(),wi=P(),sa=w(),_I=f(),hr=bo(),vh=class extends _I.Recognizer{constructor(e,t){let r=e;sa.Contracts.throwIfNull(e,"dialogConfig"),super(t,r.properties,new TI.DialogConnectionFactory),this.isTurnComplete=!0,this.privIsDisposed=!1,this.privProperties=r.properties.clone();let n=this.buildAgentConfig();this.privReco.agentConfig.set(n)}connect(e,t){wi.marshalPromiseToCallbacks(this.privReco.connect(),e,t)}disconnect(e,t){wi.marshalPromiseToCallbacks(this.privReco.disconnect(),e,t)}get authorizationToken(){return this.properties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){sa.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(hr.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get speechActivityTemplate(){return this.properties.getProperty(hr.PropertyId.Conversation_Speech_Activity_Template)}set speechActivityTemplate(e){this.properties.setProperty(hr.PropertyId.Conversation_Speech_Activity_Template,e)}listenOnceAsync(e,t){if(this.isTurnComplete){sa.Contracts.throwIfDisposed(this.privIsDisposed);let n=(async()=>{await this.privReco.connect(),await this.implRecognizerStop(),this.isTurnComplete=!1;let s=new wi.Deferred;await this.privReco.recognize(lh.RecognitionMode.Conversation,s.resolve,s.reject);let o=await s.promise;return await this.implRecognizerStop(),o})();n.catch(()=>{this.dispose(!0).catch(()=>{})}),wi.marshalPromiseToCallbacks(n.finally(()=>{this.isTurnComplete=!0}),e,t)}}sendActivityAsync(e,t,r){wi.marshalPromiseToCallbacks(this.privReco.sendMessage(e),t,r)}close(e,t){sa.Contracts.throwIfDisposed(this.privIsDisposed),wi.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 lh.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new lh.DialogServiceAdapter(e,t,s,n,this)}buildAgentConfig(){return{botInfo:{commType:this.properties.getProperty("Conversation_Communication_Type","Default"),commandsCulture:void 0,connectionId:this.properties.getProperty(hr.PropertyId.Conversation_Agent_Connection_Id),conversationId:this.properties.getProperty(hr.PropertyId.Conversation_Conversation_Id,void 0),fromId:this.properties.getProperty(hr.PropertyId.Conversation_From_Id,void 0),ttsAudioFormat:this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)},version:.2}}};oa.DialogServiceConnector=vh});var bS=p(aa=>{"use strict";Object.defineProperty(aa,"__esModule",{value:!0});aa.ActivityReceivedEventArgs=void 0;var fh=class{constructor(e,t){this.privActivity=e,this.privAudioStream=t}get activity(){return this.privActivity}get audioStream(){return this.privAudioStream}};aa.ActivityReceivedEventArgs=fh});var OS=p(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.TurnStatusResponsePayload=void 0;var gh=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}}};ca.TurnStatusResponsePayload=gh});var MS=p(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.TurnStatusReceivedEventArgs=void 0;var AI=OS(),mh=class{constructor(e){this.privTurnStatus=AI.TurnStatusResponsePayload.fromJSON(e)}get interactionId(){return this.privTurnStatus.interactionId}get conversationId(){return this.privTurnStatus.conversationId}get statusCode(){return this.privTurnStatus.statusCode}};pa.TurnStatusReceivedEventArgs=mh});var DS=p(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.ServicePropertyChannel=void 0;var bI;(function(i){i[i.UriQueryParameter=0]="UriQueryParameter"})(bI=qn.ServicePropertyChannel||(qn.ServicePropertyChannel={}))});var kS=p(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.ProfanityOption=void 0;var OI;(function(i){i[i.Masked=0]="Masked",i[i.Removed=1]="Removed",i[i.Raw=2]="Raw"})(OI=zn.ProfanityOption||(zn.ProfanityOption={}))});var NS=p(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.BaseAudioPlayer=void 0;var MI=ot(),DI=f(),kI=or(),Sh=class{constructor(e){this.audioContext=null,this.gainNode=null,this.autoUpdateBufferTimer=0,e===void 0&&(e=DI.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=kI.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 MI.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)})}};ua.BaseAudioPlayer=Sh});var xS=p(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.ConnectionMessageEventArgs=void 0;var yh=class{constructor(e){this.privConnectionMessage=e}get message(){return this.privConnectionMessage}toString(){return"Message: "+this.privConnectionMessage.toString()}};da.ConnectionMessageEventArgs=yh});var qS=p(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.VoiceProfile=void 0;var Ch=class{constructor(e,t){this.privId=e,this.privProfileType=t}get profileId(){return this.privId}get profileType(){return this.privProfileType}};ha.VoiceProfile=Ch});var jS=p(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.VoiceProfileEnrollmentCancellationDetails=Ii.VoiceProfileEnrollmentResult=void 0;var zS=C(),ve=f(),Ph=class i{constructor(e,t,r){this.privReason=e,this.privProperties=new ve.PropertyCollection,this.privReason!==ve.ResultReason.Canceled?t&&(this.privDetails=JSON.parse(t),this.privDetails.enrollmentStatus.toLowerCase()==="enrolling"&&(this.privReason=ve.ResultReason.EnrollingVoiceProfile)):(this.privErrorDetails=r,this.privProperties.setProperty(zS.CancellationErrorCodePropertyName,ve.CancellationErrorCode[ve.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"?ve.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ve.ResultReason.EnrolledVoiceProfile:ve.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"?ve.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ve.ResultReason.EnrolledVoiceProfile:ve.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}}};Ii.VoiceProfileEnrollmentResult=Ph;var Rh=class i extends ve.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=ve.CancellationReason.Error,r=ve.CancellationErrorCode.NoError;return e.properties&&(r=ve.CancellationErrorCode[e.properties.getProperty(zS.CancellationErrorCodePropertyName,ve.CancellationErrorCode[ve.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ii.VoiceProfileEnrollmentCancellationDetails=Rh});var BS=p(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});Ti.VoiceProfileCancellationDetails=Ti.VoiceProfileResult=void 0;var LS=C(),NI=w(),Rt=f(),Eh=class{constructor(e,t){this.privReason=e,this.privProperties=new Rt.PropertyCollection,e===Rt.ResultReason.Canceled&&(NI.Contracts.throwIfNullOrUndefined(t,"statusText"),this.privErrorDetails=t,this.privProperties.setProperty(LS.CancellationErrorCodePropertyName,Rt.CancellationErrorCode[Rt.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get properties(){return this.privProperties}get errorDetails(){return this.privErrorDetails}};Ti.VoiceProfileResult=Eh;var wh=class i extends Rt.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=Rt.CancellationReason.Error,r=Rt.CancellationErrorCode.NoError;return e.properties&&(r=Rt.CancellationErrorCode[e.properties.getProperty(LS.CancellationErrorCodePropertyName,Rt.CancellationErrorCode[Rt.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ti.VoiceProfileCancellationDetails=wh});var FS=p(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.VoiceProfilePhraseResult=void 0;var xI=w(),qI=f(),Ih=class extends qI.VoiceProfileResult{constructor(e,t,r,n){super(e,t),this.privPhrases=[],xI.Contracts.throwIfNullOrUndefined(n,"phrase array"),this.privType=r,n&&n[0]&&(this.privPhrases=n)}get phrases(){return this.privPhrases}get type(){return this.privType}};la.VoiceProfilePhraseResult=Ih});var VS=p(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.VoiceProfileClient=void 0;var Th=C(),zI=Cd(),va=w(),Vr=f(),_h=class extends Vr.Recognizer{constructor(e){va.Contracts.throwIfNullOrUndefined(e,"speechConfig");let t=e;va.Contracts.throwIfNull(t,"speechConfig"),super(zI.AudioConfig.fromStreamInput(Vr.AudioInputStream.createPushStream()),t.properties,new Th.VoiceProfileConnectionFactory),this.privProperties=t.properties.clone(),this.privVoiceAdapter=this.privReco,this.privDisposedVoiceAdapter=!1}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Vr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){va.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Vr.PropertyId.SpeechServiceAuthorization_Token,e)}async createProfileAsync(e,t){let r=await this.privVoiceAdapter.createProfile(e,t);return new Vr.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 va.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 Th.VoiceServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedVoiceAdapter||(this.privDisposedVoiceAdapter=!0,e&&await super.dispose(e))}createRecognizerConfig(e){return new Th.RecognizerConfig(e,this.properties)}getResult(e,t){return new Vr.VoiceProfileResult(e.ok?t:Vr.ResultReason.Canceled,e.statusText)}};fa.VoiceProfileClient=_h});var US=p(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.SpeakerRecognizer=void 0;var Ah=C(),Ur=w(),bh=f(),Oh=class extends bh.Recognizer{constructor(e,t){Ur.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;Ur.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new Ah.SpeakerRecognitionConnectionFactory),this.privAudioConfigImpl=t,Ur.Contracts.throwIfNull(this.privAudioConfigImpl,"audioConfig"),this.privDisposedSpeakerRecognizer=!1,this.privProperties=r.properties}get authorizationToken(){return this.properties.getProperty(bh.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Ur.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(bh.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}async recognizeOnceAsync(e){return Ur.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),this.recognizeSpeakerOnceAsyncImpl(e)}async close(){Ur.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.dispose(!0)}async recognizeSpeakerOnceAsyncImpl(e){Ur.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 Ah.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Ah.SpeakerServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedSpeakerRecognizer||e&&(this.privDisposedSpeakerRecognizer=!0,await super.dispose(e))}};ga.SpeakerRecognizer=Oh});var WS=p(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.SpeakerIdentificationModel=void 0;var jI=w(),LI=f(),Mh=class i{constructor(e){if(this.privVoiceProfiles=[],this.privProfileIds=[],jI.Contracts.throwIfNullOrUndefined(e,"VoiceProfiles"),e.length===0)throw new Error("Empty Voice Profiles array");for(let t of e){if(t.profileType!==LI.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"}};ma.SpeakerIdentificationModel=Mh});var KS=p(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.SpeakerVerificationModel=void 0;var BI=w(),HS=f(),Dh=class i{constructor(e){if(BI.Contracts.throwIfNullOrUndefined(e,"VoiceProfile"),e.profileType===HS.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===HS.VoiceProfileType.TextDependentVerification?"TextDependentVerification":"TextIndependentVerification"}};Sa.SpeakerVerificationModel=Dh});var kh=p(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.LanguageIdMode=void 0;var FI;(function(i){i[i.AtStart=0]="AtStart",i[i.Continuous=1]="Continuous"})(FI=jn.LanguageIdMode||(jn.LanguageIdMode={}))});var GS=p(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.AutoDetectSourceLanguageConfig=void 0;var VI=C(),UI=w(),Et=f(),JS=kh(),Nh=class i{constructor(){this.privProperties=new Et.PropertyCollection,this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart"),this.privLanguageIdMode=JS.LanguageIdMode.AtStart}static fromOpenRange(){let e=new i;return e.properties.setProperty(Et.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,VI.AutoDetectSourceLanguagesOpenRangeOptionName),e}static fromLanguages(e){UI.Contracts.throwIfArrayEmptyOrWhitespace(e,"languages");let t=new i;return t.properties.setProperty(Et.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+Et.PropertyId.SpeechServiceConnection_EndpointId.toString();t.properties.setProperty(s,n.endpointId)}}),t.properties.setProperty(Et.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,r.join()),t}get properties(){return this.privProperties}set mode(e){e===JS.LanguageIdMode.Continuous?(this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_LanguageIdMode,"Continuous")):(this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"1"),this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart")),this.privLanguageIdMode=e}};ya.AutoDetectSourceLanguageConfig=Nh});var QS=p(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.AutoDetectSourceLanguageResult=void 0;var $S=w(),xh=class i{constructor(e,t){$S.Contracts.throwIfNullOrUndefined(e,"language"),$S.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}};Ca.AutoDetectSourceLanguageResult=xh});var YS=p(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.SourceLanguageConfig=void 0;var WI=w(),qh=class i{constructor(e,t){WI.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}};Pa.SourceLanguageConfig=qh});var ZS=p(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.SpeakerRecognitionCancellationDetails=Ht.SpeakerRecognitionResult=Ht.SpeakerRecognitionResultType=void 0;var XS=C(),qe=f(),Ra;(function(i){i[i.Verify=0]="Verify",i[i.Identify=1]="Identify"})(Ra=Ht.SpeakerRecognitionResultType||(Ht.SpeakerRecognitionResultType={}));var zh=class{constructor(e,t=qe.ResultReason.RecognizedSpeaker,r=qe.CancellationErrorCode.NoError,n=""){this.privProperties=new qe.PropertyCollection;let s=e.scenario==="TextIndependentIdentification"?Ra.Identify:Ra.Verify;this.privReason=t,this.privReason!==qe.ResultReason.Canceled?s===Ra.Identify?(this.privProfileId=e.identificationResult.identifiedProfile.profileId,this.privScore=e.identificationResult.identifiedProfile.score,this.privReason=qe.ResultReason.RecognizedSpeakers):(this.privScore=e.verificationResult.score,e.verificationResult.recognitionResult.toLowerCase()!=="accept"&&(this.privReason=qe.ResultReason.NoMatch),e.verificationResult.profileId!==void 0&&e.verificationResult.profileId!==""&&(this.privProfileId=e.verificationResult.profileId)):(this.privErrorDetails=n,this.privProperties.setProperty(XS.CancellationErrorCodePropertyName,qe.CancellationErrorCode[r])),this.privProperties.setProperty(qe.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}};Ht.SpeakerRecognitionResult=zh;var jh=class i extends qe.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=qe.CancellationReason.Error,r=qe.CancellationErrorCode.NoError;return e.properties&&(r=qe.CancellationErrorCode[e.properties.getProperty(XS.CancellationErrorCodePropertyName,qe.CancellationErrorCode[qe.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ht.SpeakerRecognitionCancellationDetails=jh});var Lh=p(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.ConversationImpl=_i.Conversation=void 0;var q=C(),Ln=P(),S=w(),x=f(),Ea=class{constructor(){}static createConversationAsync(e,t,r,n){S.Contracts.throwIfNullOrUndefined(e,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),S.Contracts.throwIfNullOrUndefined(e.region,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),!e.subscriptionKey&&!e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceAuthorization_Token])&&S.Contracts.throwIfNullOrUndefined(e.subscriptionKey,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s,o,a;return typeof t=="string"?(s=new Bn(e,t),Ln.marshalPromiseToCallbacks((async()=>{})(),r,n)):(s=new Bn(e),o=t,a=r,s.createConversationAsync(()=>{o&&o()},c=>{a&&a(c)})),s}};_i.Conversation=Ea;var Bn=class extends Ea{constructor(e,t){if(super(),this.privErrors=q.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 q.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case q.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case q.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case q.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case q.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new x.ConversationParticipantsChangedEventArgs(x.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 x.ConversationParticipantsChangedEventArgs(x.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 x.ConversationParticipantsChangedEventArgs(x.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 x.ConversationParticipantsChangedEventArgs(x.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case q.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new x.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case q.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new x.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case q.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new x.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 x.ConversationParticipantsChangedEventArgs(x.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(x.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 x.PropertyCollection,this.privManager=new q.ConversationManager,e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(x.PropertyId[x.PropertyId.SpeechServiceConnection_RecoLanguage],q.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceConnection_RecoLanguage]),t)this.privConversationId=t;else{e.targetLanguages.length===0&&e.addTargetLanguage(this.privLanguage),e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceResponse_ProfanityOption])||e.setProfanity(x.ProfanityOption.Masked);let o=e.getProperty(x.PropertyId[x.PropertyId.ConversationTranslator_Name]);o==null&&(o="Host"),S.Contracts.throwIfNullOrTooLong(o,"nickname",50),S.Contracts.throwIfNullOrTooShort(o,"nickname",2),e.setProperty(x.PropertyId[x.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 q.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 q.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=q.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"),Ln.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){Ln.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){Ln.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"))Ln.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:q.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 x.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:q.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.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:q.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.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:q.ConversationTranslatorMessageTypes.instantMessage})}};_i.ConversationImpl=Bn});var ey=p(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.ConversationCommon=void 0;var Bh=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)}};wa.ConversationCommon=Bh});var ty=p(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.ConversationExpirationEventArgs=void 0;var HI=f(),Fh=class extends HI.SessionEventArgs{constructor(e,t){super(t),this.privExpirationTime=e}get expirationTime(){return this.privExpirationTime}};Ia.ConversationExpirationEventArgs=Fh});var ry=p(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.ConversationParticipantsChangedEventArgs=void 0;var KI=f(),Vh=class extends KI.SessionEventArgs{constructor(e,t,r){super(r),this.privReason=e,this.privParticipant=t}get reason(){return this.privReason}get participants(){return this.privParticipant}};Ta.ConversationParticipantsChangedEventArgs=Vh});var iy=p(_a=>{"use strict";Object.defineProperty(_a,"__esModule",{value:!0});_a.ConversationTranslationCanceledEventArgs=void 0;var JI=mi(),Uh=class extends JI.CancellationEventArgsBase{};_a.ConversationTranslationCanceledEventArgs=Uh});var ny=p(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.ConversationTranslationEventArgs=void 0;var GI=f(),Wh=class extends GI.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};Aa.ConversationTranslationEventArgs=Wh});var sy=p(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.ConversationTranslationResult=void 0;var $I=zd(),Hh=class extends $I.TranslationRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(t,n,s,o,a,c,void 0,void 0,u,d,h),this.privId=e,this.privOrigLang=r}get participantId(){return this.privId}get originalLang(){return this.privOrigLang}};ba.ConversationTranslationResult=Hh});var Jh=p(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});Oa.StringUtils=void 0;var Kh=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],d=c+1<e.length?e[c+1]:"";switch(u){case"{":d==="{"?(a("{"),c++):a=o;break;case"}":d==="}"?(a("}"),c++):(t.hasOwnProperty(n)&&(r+=t[n]),a=s,n="");break;default:a(u);break}}return r}};Oa.StringUtils=Kh});var cy=p(ka=>{"use strict";Object.defineProperty(ka,"__esModule",{value:!0});ka.ConversationTranslatorConnectionFactory=void 0;var Gh=ae(),oy=Jh(),QI=w(),Ma=f(),YI=we(),Qe=Wt(),ay=$e(),$h=C(),Da=class i extends ay.ConnectionFactoryBase{constructor(e){super(),QI.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(Ma.PropertyId.SpeechServiceConnection_Region,""),a={hostSuffix:ay.ConnectionFactoryBase.getHostSuffix(o),path:i.CTS_VIRT_MIC_PATH,region:encodeURIComponent(o)};a[Qe.QueryParameterNames.Language]=encodeURIComponent(e.parameters.getProperty(Ma.PropertyId.SpeechServiceConnection_RecoLanguage,"")),a[Qe.QueryParameterNames.CtsMeetingId]=encodeURIComponent(s.roomId),a[Qe.QueryParameterNames.CtsDeviceId]=encodeURIComponent(s.participantId),a[Qe.QueryParameterNames.CtsIsParticipant]=s.isHost?"":"&"+Qe.QueryParameterNames.CtsIsParticipant;let c="",u={},d={};if(n){c=e.parameters.getProperty(Ma.PropertyId.SpeechServiceConnection_Endpoint),c||(c="wss://"+e.parameters.getProperty(Ma.PropertyId.SpeechServiceConnection_Host,"transcribe.{region}.cts.speech{hostSuffix}")+"{path}"),c=oy.StringUtils.formatString(c,a);let l=new URL(c);l.searchParams.forEach((_,M)=>{u[M]=_}),new $h.TranscriberConnectionFactory().setQueryParams(u,e,c),u[Qe.QueryParameterNames.CtsMeetingId]=a[Qe.QueryParameterNames.CtsMeetingId],u[Qe.QueryParameterNames.CtsDeviceId]=a[Qe.QueryParameterNames.CtsDeviceId],s.isHost||(u[Qe.QueryParameterNames.CtsIsParticipant]=""),Qe.QueryParameterNames.Format in u||(u[Qe.QueryParameterNames.Format]="simple"),l.searchParams.forEach((_,M)=>{l.searchParams.set(M,u[M]),delete u[M]}),c=l.toString()}else{let l=new $h.TranslationConnectionFactory;c=l.getEndpointUrl(e,!0),c=oy.StringUtils.formatString(c,a),l.setQueryParams(u,e,c)}d[YI.HeaderNames.ConnectionId]=r,d[Gh.RestConfigBase.configParams.token]=s.token,t.token&&(d[t.headerName]=t.token);let h=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","").toUpperCase()==="TRUE";return new Gh.WebsocketConnection(c,u,d,new $h.WebsocketMessageFormatter,Gh.ProxyInfo.fromRecognizerConfig(e),h,r)}};ka.ConversationTranslatorConnectionFactory=Da;Da.CTS_VIRT_MIC_PATH="/speech/recognition/dynamicaudio"});var uy=p(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.ConversationTranslator=Wr.SpeechState=void 0;var Fn=C(),XI=cy(),Na=P(),pt=w(),U=f(),ZI=Lh(),py=xa(),ut;(function(i){i[i.Inactive=0]="Inactive",i[i.Connecting=1]="Connecting",i[i.Connected=2]="Connected"})(ut=Wr.SpeechState||(Wr.SpeechState={}));var Qh=class extends U.TranslationRecognizer{constructor(e,t,r,n){super(e,t,new XI.ConversationTranslatorConnectionFactory(n)),this.privSpeechState=ut.Inactive,r&&(this.privTranslator=r,this.sessionStarted=()=>{this.privSpeechState=ut.Connected},this.sessionStopped=()=>{this.privSpeechState=ut.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!==ut.Inactive)try{await this.cancelSpeech()}catch{this.privSpeechState=ut.Inactive}})}get state(){return this.privSpeechState}set state(e){this.privSpeechState=e}set authentication(e){this.privReco.authentication=e}onConnection(){this.privSpeechState=ut.Connected}async onCancelSpeech(){this.privSpeechState=ut.Inactive,await this.cancelSpeech()}fireCancelEvent(e){try{if(this.privTranslator.canceled){let t=new py.ConversationTranslationCanceledEventArgs(U.CancellationReason.Error,e,U.CancellationErrorCode.RuntimeError);this.privTranslator.canceled(this.privTranslator,t)}}catch{}}async cancelSpeech(){try{this.stopContinuousRecognitionAsync(),await this.privReco?.disconnect(),this.privSpeechState=ut.Inactive}catch{}}},Yh=class extends py.ConversationCommon{constructor(e){super(e),this.privErrors=Fn.ConversationConnectionConfig.restErrors,this.privIsDisposed=!1,this.privIsSpeaking=!1,this.privPlaceholderKey="abcdefghijklmnopqrstuvwxyz012345",this.privPlaceholderRegion="westus",this.privProperties=new U.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===ut.Connected||this.privCTRecognizer.state===ut.Connecting||this.privConversation.isMutedByHost)}onToken(e){this.privCTRecognizer.authentication=e}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(Fn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(Fn.ServicePropertiesPropertyName,JSON.stringify(r))}joinConversationAsync(e,t,r,n,s){try{if(typeof e=="string"){pt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),pt.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=Fn.ConversationConnectionConfig.defaultLanguageCode),this.privSpeechTranslationConfig=U.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey,this.privPlaceholderRegion),this.privSpeechTranslationConfig.setProfanity(U.ProfanityOption.Masked),this.privSpeechTranslationConfig.addTargetLanguage(o),this.privSpeechTranslationConfig.setProperty(U.PropertyId[U.PropertyId.SpeechServiceConnection_RecoLanguage],o),this.privSpeechTranslationConfig.setProperty(U.PropertyId[U.PropertyId.ConversationTranslator_Name],t);let a=[U.PropertyId.SpeechServiceConnection_Host,U.PropertyId.ConversationTranslator_Host,U.PropertyId.SpeechServiceConnection_Endpoint,U.PropertyId.SpeechServiceConnection_ProxyHostName,U.PropertyId.SpeechServiceConnection_ProxyPassword,U.PropertyId.SpeechServiceConnection_ProxyPort,U.PropertyId.SpeechServiceConnection_ProxyUserName,"ConversationTranslator_MultiChannelAudio","ConversationTranslator_Region"];for(let u of a){let d=this.privProperties.getProperty(u);if(d){let h=typeof u=="string"?u:U.PropertyId[u];this.privSpeechTranslationConfig.setProperty(h,d)}}let c=JSON.parse(this.privProperties.getProperty(Fn.ServicePropertiesPropertyName,"{}"));for(let u of Object.keys(c))this.privSpeechTranslationConfig.setServiceProperty(u,c[u],U.ServicePropertyChannel.UriQueryParameter);this.privConversation=new ZI.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)},d=>{this.handleError(d,s)})},u=>{this.handleError(u,s)})}else typeof e=="object"?(pt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),pt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privProperties.setProperty(U.PropertyId.ConversationTranslator_Name,t),this.privConversation=e,this.privConversation.conversationTranslator=this,this.privConversation.room.isHost=!0,pt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedConnect),pt.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){Na.marshalPromiseToCallbacks((async()=>{await this.cancelSpeech(),await this.privConversation.endConversationImplAsync(),await this.privConversation.deleteConversationImplAsync(),this.dispose()})(),e,t)}sendTextMessageAsync(e,t,r){try{pt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),pt.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}",e)),this.privConversation.sendTextMessageAsync(e,t,r)}catch(n){this.handleError(n,r)}}startTranscribingAsync(e,t){Na.marshalPromiseToCallbacks((async()=>{try{pt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),pt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privCTRecognizer===void 0&&await this.connectTranslatorRecognizer(),pt.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){Na.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){Na.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=U.AudioConfig.fromDefaultMicrophoneInput()),this.privSpeechTranslationConfig.getProperty(U.PropertyId[U.PropertyId.SpeechServiceConnection_Key])===this.privPlaceholderKey&&this.privSpeechTranslationConfig.setProperty(U.PropertyId[U.PropertyId.SpeechServiceConnection_Key],"");let e=()=>this.privConversation;this.privCTRecognizer=new Qh(this.privSpeechTranslationConfig,this.privAudioConfig,this,e)}catch(e){throw await this.cancelSpeech(),e}}startContinuousRecognition(){return new Promise((e,t)=>{this.privCTRecognizer.startContinuousRecognitionAsync(e,t)})}};Wr.ConversationTranslator=Yh});var dy=p(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.ConversationTranscriber=void 0;var Vn=C(),Xh=P(),Hr=w(),Oe=f(),Zh=class i extends Oe.Recognizer{constructor(e,t){let r=e;Hr.Contracts.throwIfNull(r,"speechConfig"),Hr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(Oe.PropertyId.SpeechServiceConnection_RecoLanguage),Oe.PropertyId[Oe.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Vn.ConversationTranscriberConnectionFactory),this.privProperties.setProperty(Oe.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 Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Oe.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(Oe.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Hr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Oe.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Oe.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Vn.OutputFormatPropertyName,Oe.OutputFormat[Oe.OutputFormat.Simple])===Oe.OutputFormat[Oe.OutputFormat.Simple]?Oe.OutputFormat.Simple:Oe.OutputFormat.Detailed}get properties(){return this.privProperties}startTranscribingAsync(e,t){Xh.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Vn.RecognitionMode.Conversation),e,t)}stopTranscribingAsync(e,t){Xh.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}close(e,t){Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),Xh.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 Vn.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return n.isSpeakerDiarizationEnabled=!0,new Vn.ConversationTranscriptionServiceRecognizer(e,t,s,n,this)}};qa.ConversationTranscriber=Zh});var hy=p(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0});Ai.Participant=Ai.User=void 0;var eT=f(),el=class{constructor(e){this.privUserId=e}get userId(){return this.privUserId}};Ai.User=el;var tl=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 eT.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)}};Ai.Participant=tl});var ly=p(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.ParticipantChangedReason=void 0;var tT;(function(i){i[i.JoinedConversation=0]="JoinedConversation",i[i.LeftConversation=1]="LeftConversation",i[i.Updated=2]="Updated"})(tT=Un.ParticipantChangedReason||(Un.ParticipantChangedReason={}))});var vy=p(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.MeetingImpl=bi.Meeting=void 0;var j=C(),Wn=P(),y=w(),K=f(),za=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(K.PropertyId[K.PropertyId.SpeechServiceAuthorization_Token])&&y.Contracts.throwIfNullOrUndefined(e.subscriptionKey,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s=new ja(e,t);return Wn.marshalPromiseToCallbacks((async()=>{})(),r,n),s}};bi.Meeting=za;var ja=class extends za{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 K.ConversationParticipantsChangedEventArgs(K.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 K.ConversationParticipantsChangedEventArgs(K.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 K.ConversationParticipantsChangedEventArgs(K.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 K.ConversationParticipantsChangedEventArgs(K.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 K.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new K.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new K.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 K.ConversationParticipantsChangedEventArgs(K.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(K.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 K.PropertyCollection,this.privManager=new j.ConversationManager,e.getProperty(K.PropertyId[K.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(K.PropertyId[K.PropertyId.SpeechServiceConnection_RecoLanguage],j.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(K.PropertyId[K.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"),Wn.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){Wn.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){Wn.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"))Wn.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 K.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})}};bi.MeetingImpl=ja});var fy=p(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.MeetingTranscriptionCanceledEventArgs=void 0;var rT=mi(),rl=class extends rT.CancellationEventArgsBase{};La.MeetingTranscriptionCanceledEventArgs=rl});var gy=p(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.MeetingTranscriber=void 0;var iT=C(),il=P(),Hn=w(),Kn=f(),nT=xa(),nl=class{constructor(e){this.privAudioConfig=e,this.privProperties=new Kn.PropertyCollection,this.privRecognizer=void 0,this.privDisposedRecognizer=!1}get speechRecognitionLanguage(){return Hn.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Kn.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get internalData(){return this.privRecognizer.internalData}get connection(){return Kn.Connection.fromRecognizer(this.privRecognizer)}get authorizationToken(){return this.properties.getProperty(Kn.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Hn.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Kn.PropertyId.SpeechServiceAuthorization_Token,e)}joinMeetingAsync(e,t,r){let n=e;Hn.Contracts.throwIfNullOrUndefined(nT.MeetingImpl,"Meeting"),this.privRecognizer=new iT.TranscriberRecognizer(e.config,this.privAudioConfig),Hn.Contracts.throwIfNullOrUndefined(this.privRecognizer,"Recognizer"),this.privRecognizer.connectMeetingCallbacks(this),il.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(),il.marshalPromiseToCallbacks((async()=>{})(),e,t)}close(e,t){Hn.Contracts.throwIfDisposed(this.privDisposedRecognizer),il.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))}};Ba.MeetingTranscriber=nl});var my=p(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});Fa.ConversationTranscriptionResult=void 0;var sT=f(),sl=class extends sT.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(e,t,r,n,s,o,a,u,d,h),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};Fa.ConversationTranscriptionResult=sl});var xa=p(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});var Sy=Lh();Object.defineProperty(re,"Conversation",{enumerable:!0,get:function(){return Sy.Conversation}});Object.defineProperty(re,"ConversationImpl",{enumerable:!0,get:function(){return Sy.ConversationImpl}});var oT=ey();Object.defineProperty(re,"ConversationCommon",{enumerable:!0,get:function(){return oT.ConversationCommon}});var aT=ty();Object.defineProperty(re,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return aT.ConversationExpirationEventArgs}});var cT=ry();Object.defineProperty(re,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return cT.ConversationParticipantsChangedEventArgs}});var pT=iy();Object.defineProperty(re,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return pT.ConversationTranslationCanceledEventArgs}});var uT=ny();Object.defineProperty(re,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return uT.ConversationTranslationEventArgs}});var dT=sy();Object.defineProperty(re,"ConversationTranslationResult",{enumerable:!0,get:function(){return dT.ConversationTranslationResult}});var hT=uy();Object.defineProperty(re,"ConversationTranslator",{enumerable:!0,get:function(){return hT.ConversationTranslator}});var lT=dy();Object.defineProperty(re,"ConversationTranscriber",{enumerable:!0,get:function(){return lT.ConversationTranscriber}});var yy=hy();Object.defineProperty(re,"Participant",{enumerable:!0,get:function(){return yy.Participant}});Object.defineProperty(re,"User",{enumerable:!0,get:function(){return yy.User}});var vT=ly();Object.defineProperty(re,"ParticipantChangedReason",{enumerable:!0,get:function(){return vT.ParticipantChangedReason}});var Cy=vy();Object.defineProperty(re,"Meeting",{enumerable:!0,get:function(){return Cy.Meeting}});Object.defineProperty(re,"MeetingImpl",{enumerable:!0,get:function(){return Cy.MeetingImpl}});var fT=fy();Object.defineProperty(re,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return fT.MeetingTranscriptionCanceledEventArgs}});var gT=gy();Object.defineProperty(re,"MeetingTranscriber",{enumerable:!0,get:function(){return gT.MeetingTranscriber}});var mT=my();Object.defineProperty(re,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return mT.ConversationTranscriptionResult}})});var Va=p(Oi=>{"use strict";Object.defineProperty(Oi,"__esModule",{value:!0});Oi.SynthesisRequest=Oi.Synthesizer=void 0;var Kr=C(),ST=P(),Py=w(),lr=f(),ol=class i{constructor(e){let t=e;Py.Contracts.throwIfNull(t,"speechConfig"),this.privProperties=t.properties.clone(),this.privDisposed=!1,this.privSynthesizing=!1,this.synthesisRequestQueue=new ST.Queue}get authorizationToken(){return this.properties.getProperty(lr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Py.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(lr.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get autoDetectSourceLanguage(){return this.properties.getProperty(lr.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)===Kr.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(lr.PropertyId.SpeechServiceConnection_SynthLanguage,"en-US"),n=this.properties.getProperty(lr.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 Kr.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 Kr.SpeechServiceConfig(new Kr.Context(new Kr.OS(e,t,r)))),s=this.privProperties.getProperty(lr.PropertyId.SpeechServiceConnection_Key,void 0),o=s&&s!==""?new Kr.CognitiveSubscriptionKeyAuthentication(s):new Kr.CognitiveTokenAuthentication(()=>{let a=this.privProperties.getProperty(lr.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(a)},()=>{let a=this.privProperties.getProperty(lr.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}};Oi.Synthesizer=ol;var al=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}};Oi.SynthesisRequest=al});var Ey=p(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.SpeechSynthesizer=void 0;var cl=C(),pl=P(),yT=gd(),CT=li(),PT=Dr(),Ry=w(),vr=f(),RT=Va(),ul=class i extends vr.Synthesizer{constructor(e,t){super(e),t!==null&&(t===void 0?this.audioConfig=typeof window>"u"?void 0:vr.AudioConfig.fromDefaultSpeakerOutput():this.audioConfig=t),this.privConnectionFactory=new cl.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){Ry.Contracts.throwIfDisposed(this.privDisposed),pl.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privAdapter}createSynthesisAdapter(e,t,r){return new cl.SpeechSynthesisAdapter(e,t,r,this,this.audioConfig)}createRestSynthesisAdapter(e,t){return new cl.SynthesisRestAdapter(t,e)}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=CT.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(vr.SpeechSynthesisOutputFormat[this.properties.getProperty(vr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)])}speakImpl(e,t,r,n,s){try{Ry.Contracts.throwIfDisposed(this.privDisposed);let o=pl.createNoDashGuid(),a;s instanceof vr.PushAudioOutputStreamCallback?a=new PT.PushAudioOutputStreamImpl(s):s instanceof vr.PullAudioOutputStream?a=s:s!==void 0?a=new yT.AudioFileWriter(s):a=void 0,this.synthesisRequestQueue.enqueue(new RT.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=pl.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 vr.SynthesisVoicesResult(t,n,void 0)}else return new vr.SynthesisVoicesResult(t,void 0,`Error: ${r.status}: ${r.statusText}`)}};Ua.SpeechSynthesizer=ul});var wy=p(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.SynthesisResult=void 0;var dl=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}};Wa.SynthesisResult=dl});var Iy=p(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.SpeechSynthesisResult=void 0;var ET=f(),hl=class extends ET.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}};Ha.SpeechSynthesisResult=hl});var Ty=p(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.SpeechSynthesisEventArgs=void 0;var ll=class{constructor(e){this.privResult=e}get result(){return this.privResult}};Ka.SpeechSynthesisEventArgs=ll});var _y=p(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.SpeechSynthesisWordBoundaryEventArgs=void 0;var vl=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}};Ja.SpeechSynthesisWordBoundaryEventArgs=vl});var Ay=p(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.SpeechSynthesisBookmarkEventArgs=void 0;var fl=class{constructor(e,t){this.privAudioOffset=e,this.privText=t}get audioOffset(){return this.privAudioOffset}get text(){return this.privText}};Ga.SpeechSynthesisBookmarkEventArgs=fl});var by=p($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.SpeechSynthesisVisemeEventArgs=void 0;var gl=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}};$a.SpeechSynthesisVisemeEventArgs=gl});var Oy=p(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.SpeechSynthesisBoundaryType=void 0;var wT;(function(i){i.Word="WordBoundary",i.Punctuation="PunctuationBoundary",i.Sentence="SentenceBoundary"})(wT=Jn.SpeechSynthesisBoundaryType||(Jn.SpeechSynthesisBoundaryType={}))});var My=p(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.SynthesisVoicesResult=void 0;var Mi=f(),ml=class extends Mi.SynthesisResult{constructor(e,t,r){if(Array.isArray(t)){super(e,Mi.ResultReason.VoicesListRetrieved,void 0,new Mi.PropertyCollection),this.privVoices=[];for(let n of t)this.privVoices.push(new Mi.VoiceInfo(n))}else super(e,Mi.ResultReason.Canceled,r||"Error information unavailable",new Mi.PropertyCollection)}get voices(){return this.privVoices}};Qa.SynthesisVoicesResult=ml});var Dy=p(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.VoiceInfo=wt.SynthesisVoiceType=wt.SynthesisVoiceGender=void 0;var dt;(function(i){i[i.Unknown=0]="Unknown",i[i.Female=1]="Female",i[i.Male=2]="Male",i[i.Neutral=3]="Neutral"})(dt=wt.SynthesisVoiceGender||(wt.SynthesisVoiceGender={}));var Sl;(function(i){i[i.OnlineNeural=1]="OnlineNeural",i[i.OnlineStandard=2]="OnlineStandard",i[i.OfflineNeural=3]="OfflineNeural",i[i.OfflineStandard=4]="OfflineStandard"})(Sl=wt.SynthesisVoiceType||(wt.SynthesisVoiceType={}));var IT={[dt[dt.Neutral]]:dt.Neutral,[dt[dt.Male]]:dt.Male,[dt[dt.Female]]:dt.Female},yl=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")?Sl.OnlineStandard:Sl.OnlineNeural,this.privGender=IT[e.Gender]||dt.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}};wt.VoiceInfo=yl});var Ny=p(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.SpeakerAudioDestination=void 0;var Jr=P(),TT=Dr(),Ye=or(),_T=60*30,ky={[Ye.AudioFormatTag.PCM]:"audio/wav",[Ye.AudioFormatTag.MuLaw]:"audio/x-wav",[Ye.AudioFormatTag.MP3]:"audio/mpeg",[Ye.AudioFormatTag.OGG_OPUS]:"audio/ogg",[Ye.AudioFormatTag.WEBM_OPUS]:"audio/webm; codecs=opus",[Ye.AudioFormatTag.ALaw]:"audio/x-wav",[Ye.AudioFormatTag.FLAC]:"audio/flac"},Cl=class{constructor(e){this.privPlaybackStarted=!1,this.privAppendingToBuffer=!1,this.privMediaSourceOpened=!1,this.privBytesReceived=0,this.privId=e||Jr.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===Ye.AudioFormatTag.PCM||this.privFormat.formatTag===Ye.AudioFormatTag.MuLaw||this.privFormat.formatTag===Ye.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:ky[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=ky[this.privFormat.formatTag];t===void 0?console.warn(`Unknown mimeType for format ${Ye.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=_T,this.privSourceBuffer=this.privMediaSource.addSourceBuffer(t),this.privSourceBuffer.onupdate=()=>{this.updateSourceBuffer().catch(r=>{Jr.Events.instance.onEvent(new Jr.BackgroundEvent(r))})},this.privSourceBuffer.onupdateend=()=>{this.handleSourceBufferUpdateEnd().catch(r=>{Jr.Events.instance.onEvent(new Jr.BackgroundEvent(r))})},this.privSourceBuffer.onupdatestart=()=>{this.privAppendingToBuffer=!1}},this.updateSourceBuffer().catch(r=>{Jr.Events.instance.onEvent(new Jr.BackgroundEvent(r))})):(console.warn(`Format ${Ye.AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`),this.privAudioOutputStream=new TT.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}};Ya.SpeakerAudioDestination=Cl});var xy=p(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.ConversationTranscriptionCanceledEventArgs=void 0;var AT=mi(),Pl=class extends AT.CancellationEventArgsBase{};Xa.ConversationTranscriptionCanceledEventArgs=Pl});var qy=p(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});Za.MeetingTranscriptionCanceledEventArgs=void 0;var bT=mi(),Rl=class extends bT.CancellationEventArgsBase{};Za.MeetingTranscriptionCanceledEventArgs=Rl});var zy=p(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.PronunciationAssessmentGradingSystem=void 0;var OT;(function(i){i[i.FivePoint=1]="FivePoint",i[i.HundredMark=2]="HundredMark"})(OT=Gn.PronunciationAssessmentGradingSystem||(Gn.PronunciationAssessmentGradingSystem={}))});var jy=p($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.PronunciationAssessmentGranularity=void 0;var MT;(function(i){i[i.Phoneme=1]="Phoneme",i[i.Word=2]="Word",i[i.FullText=3]="FullText"})(MT=$n.PronunciationAssessmentGranularity||($n.PronunciationAssessmentGranularity={}))});var Ly=p(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});tc.PronunciationAssessmentConfig=void 0;var ec=w(),Q=f(),El=class i{constructor(e,t=Q.PronunciationAssessmentGradingSystem.FivePoint,r=Q.PronunciationAssessmentGranularity.Phoneme,n=!1){ec.Contracts.throwIfNullOrUndefined(e,"referenceText"),this.privProperties=new Q.PropertyCollection,this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_ReferenceText,e),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_GradingSystem,Q.PronunciationAssessmentGradingSystem[t]),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_Granularity,Q.PronunciationAssessmentGranularity[r]),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_EnableMiscue,String(n))}static fromJSON(e){ec.Contracts.throwIfNullOrUndefined(e,"json");let t=new i("");return t.privProperties=new Q.PropertyCollection,t.properties.setProperty(Q.PropertyId.PronunciationAssessment_Json,e),t}toJSON(){return this.updateJson(),this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_Params)}applyTo(e){this.updateJson();let t=e.internalData;t.expectContentAssessmentResponse=!!this.privContentAssessmentTopic,t.speechContext.setPronunciationAssessmentParams(this.properties.getProperty(Q.PropertyId.PronunciationAssessment_Params),this.privContentAssessmentTopic,t.isSpeakerDiarizationEnabled)}get referenceText(){return this.properties.getProperty(Q.PropertyId.PronunciationAssessment_ReferenceText)}set referenceText(e){ec.Contracts.throwIfNullOrWhitespace(e,"referenceText"),this.properties.setProperty(Q.PropertyId.PronunciationAssessment_ReferenceText,e)}set phonemeAlphabet(e){ec.Contracts.throwIfNullOrWhitespace(e,"phonemeAlphabet"),this.privPhonemeAlphabet=e}set enableMiscue(e){let t=e?"true":"false";this.properties.setProperty(Q.PropertyId.PronunciationAssessment_EnableMiscue,t)}get enableMiscue(){return this.properties.getProperty(Q.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(Q.PropertyId.PronunciationAssessment_Json,"{}"),t=JSON.parse(e),r=this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_ReferenceText);r&&(t.referenceText=r);let n=this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_GradingSystem);n&&(t.gradingSystem=n);let s=this.privProperties.getProperty(Q.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(Q.PropertyId.PronunciationAssessment_EnableMiscue)&&(t.enableMiscue=this.enableMiscue),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_Params,JSON.stringify(t))}};tc.PronunciationAssessmentConfig=El});var By=p(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.PronunciationAssessmentResult=Di.ContentAssessmentResult=void 0;var wl=w(),DT=f(),rc=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}};Di.ContentAssessmentResult=rc;var Il=class i{constructor(e){let t=JSON.parse(e);wl.Contracts.throwIfNullOrUndefined(t.NBest[0],"NBest"),this.privPronJson=t.NBest[0]}static fromResult(e){wl.Contracts.throwIfNullOrUndefined(e,"result");let t=e.properties.getProperty(DT.PropertyId.SpeechServiceResponse_JsonResult);return wl.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 rc(this.detailResult)}};Di.PronunciationAssessmentResult=Il});var Fy=p(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.AvatarConfig=void 0;var kT=w(),NT=f(),Tl=class{constructor(e,t,r){this.privCustomized=!1,kT.Contracts.throwIfNullOrWhitespace(e,"character"),this.character=e,this.style=t,r===void 0&&(r=new NT.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}};ic.AvatarConfig=Tl});var Vy=p(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.AvatarEventArgs=Gr.AvatarEventTypes=void 0;var xT;(function(i){i.SwitchedToSpeaking="SwitchedToSpeaking",i.SwitchedToIdle="SwitchedToIdle",i.SessionClosed="SessionClosed"})(xT=Gr.AvatarEventTypes||(Gr.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}};Gr.AvatarEventArgs=_l});var bl=p(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.SpeechSynthesisConnectionFactory=void 0;var Uy=ae(),Qn=f(),qT=$e(),zT=C(),jT=we(),nc=Wt(),Al=class{constructor(){this.synthesisUri="/cognitiveservices/websocket/v1"}create(e,t,r){let n=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_Region,void 0),o=qT.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_EndpointId,void 0),c=a===void 0?"tts":"voice",u=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_Host,"wss://"+s+"."+c+".speech"+o),d={},h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[jT.HeaderNames.ConnectionId]=r,a!==void 0&&a!==""&&(!n||n.search(nc.QueryParameterNames.CustomVoiceDeploymentId)===-1)&&(d[nc.QueryParameterNames.CustomVoiceDeploymentId]=a),e.avatarEnabled&&(!n||n.search(nc.QueryParameterNames.EnableAvatar)===-1)&&(d[nc.QueryParameterNames.EnableAvatar]="true"),n||(n=u+this.synthesisUri),e.parameters.setProperty(Qn.PropertyId.SpeechServiceConnection_Url,n);let l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new Uy.WebsocketConnection(n,d,h,new zT.WebsocketMessageFormatter,Uy.ProxyInfo.fromParameters(e.parameters),l,r)}};sc.SpeechSynthesisConnectionFactory=Al});var Wy=p(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});ac.AvatarSynthesizer=void 0;var LT=bl(),BT=C(),X=P(),FT=li(),Kt=f(),oc=w(),VT=Va(),Ol=class extends Kt.Synthesizer{constructor(e,t){super(e),oc.Contracts.throwIfNullOrUndefined(t,"avatarConfig"),this.privConnectionFactory=new LT.SpeechSynthesisConnectionFactory,this.privAvatarConfig=t,this.implCommonSynthesizeSetup()}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=FT.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(Kt.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm)}async startAvatarAsync(e){oc.Contracts.throwIfNullOrUndefined(e,"peerConnection"),this.privIceServers=e.getConfiguration().iceServers,oc.Contracts.throwIfNullOrUndefined(this.privIceServers,"Ice servers must be set.");let t=new X.Deferred;e.onicegatheringstatechange=()=>{X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering state: "+e.iceGatheringState,X.EventType.Debug)),e.iceGatheringState==="complete"&&(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering complete.",X.EventType.Info)),t.resolve())},e.onicecandidate=a=>{a.candidate?X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice candidate: "+a.candidate.candidate,X.EventType.Debug)):(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice candidate: complete",X.EventType.Debug)),t.resolve())},setTimeout(()=>{e.iceGatheringState!=="complete"&&(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering timeout.",X.EventType.Warning)),t.resolve())},2e3);let r=await e.createOffer();await e.setLocalDescription(r),await t.promise,X.Events.instance.onEvent(new X.PlatformEvent("peer connection: got local SDP.",X.EventType.Info)),this.privProperties.setProperty(Kt.PropertyId.TalkingAvatarService_WebRTC_SDP,JSON.stringify(e.localDescription));let n=await this.speak("",!1);if(n.reason!==Kt.ResultReason.SynthesizingAudioCompleted)return new Kt.SynthesisResult(n.resultId,n.reason,n.errorDetails,n.properties);let s=atob(n.properties.getProperty(Kt.PropertyId.TalkingAvatarService_WebRTC_SDP)),o=new RTCSessionDescription(JSON.parse(s));return await e.setRemoteDescription(o),new Kt.SynthesisResult(n.resultId,n.reason,void 0,n.properties)}async speakTextAsync(e){let t=await this.speak(e,!1);return new Kt.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async speakSsmlAsync(e){let t=await this.speak(e,!0);return new Kt.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 oc.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 BT.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=X.createNoDashGuid(),n=new X.Deferred;return this.synthesisRequestQueue.enqueue(new VT.SynthesisRequest(r,e,t,s=>{n.resolve(s),this.privSynthesizing=!1,this.adapterSpeak()},s=>{n.reject(s),this.privSynthesizing=!1})),this.adapterSpeak(),n.promise}};ac.AvatarSynthesizer=Ol});var Hy=p(ki=>{"use strict";Object.defineProperty(ki,"__esModule",{value:!0});ki.AvatarVideoFormat=ki.Coordinate=void 0;var Ml=class{constructor(e,t){this.x=e,this.y=t}};ki.Coordinate=Ml;var Dl=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}}};ki.AvatarVideoFormat=Dl});var Ky=p(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});cc.AvatarWebRTCConnectionResult=void 0;var UT=f(),kl=class extends UT.SynthesisResult{constructor(e,t,r,n,s){super(t,r,n,s),this.privSDPAnswer=e}get SDPAnswer(){return this.privSDPAnswer}};cc.AvatarWebRTCConnectionResult=kl});var Jy=p(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.Diagnostics=void 0;var WT=ae(),HT=P(),pc=class{static SetLoggingLevel(e){this.privListener=new WT.ConsoleLoggingListener(e),HT.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)}};uc.Diagnostics=pc;pc.privListener=void 0});var f=p(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});var KT=Cd();Object.defineProperty(v,"AudioConfig",{enumerable:!0,get:function(){return KT.AudioConfig}});var Gy=or();Object.defineProperty(v,"AudioStreamFormat",{enumerable:!0,get:function(){return Gy.AudioStreamFormat}});Object.defineProperty(v,"AudioFormatTag",{enumerable:!0,get:function(){return Gy.AudioFormatTag}});var Nl=md();Object.defineProperty(v,"AudioInputStream",{enumerable:!0,get:function(){return Nl.AudioInputStream}});Object.defineProperty(v,"PullAudioInputStream",{enumerable:!0,get:function(){return Nl.PullAudioInputStream}});Object.defineProperty(v,"PushAudioInputStream",{enumerable:!0,get:function(){return Nl.PushAudioInputStream}});var xl=Dr();Object.defineProperty(v,"AudioOutputStream",{enumerable:!0,get:function(){return xl.AudioOutputStream}});Object.defineProperty(v,"PullAudioOutputStream",{enumerable:!0,get:function(){return xl.PullAudioOutputStream}});Object.defineProperty(v,"PushAudioOutputStream",{enumerable:!0,get:function(){return xl.PushAudioOutputStream}});var JT=Nm();Object.defineProperty(v,"CancellationReason",{enumerable:!0,get:function(){return JT.CancellationReason}});var GT=xm();Object.defineProperty(v,"PullAudioInputStreamCallback",{enumerable:!0,get:function(){return GT.PullAudioInputStreamCallback}});var $T=qm();Object.defineProperty(v,"PushAudioOutputStreamCallback",{enumerable:!0,get:function(){return $T.PushAudioOutputStreamCallback}});var QT=jm();Object.defineProperty(v,"KeywordRecognitionModel",{enumerable:!0,get:function(){return QT.KeywordRecognitionModel}});var YT=Lm();Object.defineProperty(v,"SessionEventArgs",{enumerable:!0,get:function(){return YT.SessionEventArgs}});var XT=Bm();Object.defineProperty(v,"RecognitionEventArgs",{enumerable:!0,get:function(){return XT.RecognitionEventArgs}});var ZT=Fm();Object.defineProperty(v,"OutputFormat",{enumerable:!0,get:function(){return ZT.OutputFormat}});var e_=Vm();Object.defineProperty(v,"IntentRecognitionEventArgs",{enumerable:!0,get:function(){return e_.IntentRecognitionEventArgs}});var t_=Um();Object.defineProperty(v,"RecognitionResult",{enumerable:!0,get:function(){return t_.RecognitionResult}});var r_=Wm();Object.defineProperty(v,"SpeechRecognitionResult",{enumerable:!0,get:function(){return r_.SpeechRecognitionResult}});var i_=Hm();Object.defineProperty(v,"IntentRecognitionResult",{enumerable:!0,get:function(){return i_.IntentRecognitionResult}});var n_=Km();Object.defineProperty(v,"LanguageUnderstandingModel",{enumerable:!0,get:function(){return n_.LanguageUnderstandingModel}});var ql=Gm();Object.defineProperty(v,"SpeechRecognitionEventArgs",{enumerable:!0,get:function(){return ql.SpeechRecognitionEventArgs}});Object.defineProperty(v,"ConversationTranscriptionEventArgs",{enumerable:!0,get:function(){return ql.ConversationTranscriptionEventArgs}});Object.defineProperty(v,"MeetingTranscriptionEventArgs",{enumerable:!0,get:function(){return ql.MeetingTranscriptionEventArgs}});var s_=$m();Object.defineProperty(v,"SpeechRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return s_.SpeechRecognitionCanceledEventArgs}});var o_=Qm();Object.defineProperty(v,"TranslationRecognitionEventArgs",{enumerable:!0,get:function(){return o_.TranslationRecognitionEventArgs}});var a_=Ym();Object.defineProperty(v,"TranslationSynthesisEventArgs",{enumerable:!0,get:function(){return a_.TranslationSynthesisEventArgs}});var c_=zd();Object.defineProperty(v,"TranslationRecognitionResult",{enumerable:!0,get:function(){return c_.TranslationRecognitionResult}});var p_=Xm();Object.defineProperty(v,"TranslationSynthesisResult",{enumerable:!0,get:function(){return p_.TranslationSynthesisResult}});var u_=Zm();Object.defineProperty(v,"ResultReason",{enumerable:!0,get:function(){return u_.ResultReason}});var $y=eS();Object.defineProperty(v,"SpeechConfig",{enumerable:!0,get:function(){return $y.SpeechConfig}});Object.defineProperty(v,"SpeechConfigImpl",{enumerable:!0,get:function(){return $y.SpeechConfigImpl}});var Qy=tS();Object.defineProperty(v,"SpeechTranslationConfig",{enumerable:!0,get:function(){return Qy.SpeechTranslationConfig}});Object.defineProperty(v,"SpeechTranslationConfigImpl",{enumerable:!0,get:function(){return Qy.SpeechTranslationConfigImpl}});var d_=Bd();Object.defineProperty(v,"PropertyCollection",{enumerable:!0,get:function(){return d_.PropertyCollection}});var h_=bo();Object.defineProperty(v,"PropertyId",{enumerable:!0,get:function(){return h_.PropertyId}});var l_=nS();Object.defineProperty(v,"Recognizer",{enumerable:!0,get:function(){return l_.Recognizer}});var v_=sS();Object.defineProperty(v,"SpeechRecognizer",{enumerable:!0,get:function(){return v_.SpeechRecognizer}});var f_=oS();Object.defineProperty(v,"IntentRecognizer",{enumerable:!0,get:function(){return f_.IntentRecognizer}});var g_=aS();Object.defineProperty(v,"VoiceProfileType",{enumerable:!0,get:function(){return g_.VoiceProfileType}});var m_=dS();Object.defineProperty(v,"TranslationRecognizer",{enumerable:!0,get:function(){return m_.TranslationRecognizer}});var S_=hS();Object.defineProperty(v,"Translations",{enumerable:!0,get:function(){return S_.Translations}});var y_=lS();Object.defineProperty(v,"NoMatchReason",{enumerable:!0,get:function(){return y_.NoMatchReason}});var C_=vS();Object.defineProperty(v,"NoMatchDetails",{enumerable:!0,get:function(){return C_.NoMatchDetails}});var P_=fS();Object.defineProperty(v,"TranslationRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return P_.TranslationRecognitionCanceledEventArgs}});var R_=gS();Object.defineProperty(v,"IntentRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return R_.IntentRecognitionCanceledEventArgs}});var E_=nh();Object.defineProperty(v,"CancellationDetailsBase",{enumerable:!0,get:function(){return E_.CancellationDetailsBase}});var w_=mS();Object.defineProperty(v,"CancellationDetails",{enumerable:!0,get:function(){return w_.CancellationDetails}});var I_=SS();Object.defineProperty(v,"CancellationErrorCode",{enumerable:!0,get:function(){return I_.CancellationErrorCode}});var T_=yS();Object.defineProperty(v,"ConnectionEventArgs",{enumerable:!0,get:function(){return T_.ConnectionEventArgs}});var __=CS();Object.defineProperty(v,"ServiceEventArgs",{enumerable:!0,get:function(){return __.ServiceEventArgs}});var A_=Qd();Object.defineProperty(v,"Connection",{enumerable:!0,get:function(){return A_.Connection}});var b_=PS();Object.defineProperty(v,"PhraseListGrammar",{enumerable:!0,get:function(){return b_.PhraseListGrammar}});var O_=Xo();Object.defineProperty(v,"DialogServiceConfig",{enumerable:!0,get:function(){return O_.DialogServiceConfig}});var M_=RS();Object.defineProperty(v,"BotFrameworkConfig",{enumerable:!0,get:function(){return M_.BotFrameworkConfig}});var D_=ES();Object.defineProperty(v,"CustomCommandsConfig",{enumerable:!0,get:function(){return D_.CustomCommandsConfig}});var k_=AS();Object.defineProperty(v,"DialogServiceConnector",{enumerable:!0,get:function(){return k_.DialogServiceConnector}});var N_=bS();Object.defineProperty(v,"ActivityReceivedEventArgs",{enumerable:!0,get:function(){return N_.ActivityReceivedEventArgs}});var x_=MS();Object.defineProperty(v,"TurnStatusReceivedEventArgs",{enumerable:!0,get:function(){return x_.TurnStatusReceivedEventArgs}});var q_=DS();Object.defineProperty(v,"ServicePropertyChannel",{enumerable:!0,get:function(){return q_.ServicePropertyChannel}});var z_=kS();Object.defineProperty(v,"ProfanityOption",{enumerable:!0,get:function(){return z_.ProfanityOption}});var j_=NS();Object.defineProperty(v,"BaseAudioPlayer",{enumerable:!0,get:function(){return j_.BaseAudioPlayer}});var L_=xS();Object.defineProperty(v,"ConnectionMessageEventArgs",{enumerable:!0,get:function(){return L_.ConnectionMessageEventArgs}});var B_=Kd();Object.defineProperty(v,"ConnectionMessage",{enumerable:!0,get:function(){return B_.ConnectionMessage}});var F_=qS();Object.defineProperty(v,"VoiceProfile",{enumerable:!0,get:function(){return F_.VoiceProfile}});var Yy=jS();Object.defineProperty(v,"VoiceProfileEnrollmentResult",{enumerable:!0,get:function(){return Yy.VoiceProfileEnrollmentResult}});Object.defineProperty(v,"VoiceProfileEnrollmentCancellationDetails",{enumerable:!0,get:function(){return Yy.VoiceProfileEnrollmentCancellationDetails}});var Xy=BS();Object.defineProperty(v,"VoiceProfileResult",{enumerable:!0,get:function(){return Xy.VoiceProfileResult}});Object.defineProperty(v,"VoiceProfileCancellationDetails",{enumerable:!0,get:function(){return Xy.VoiceProfileCancellationDetails}});var V_=FS();Object.defineProperty(v,"VoiceProfilePhraseResult",{enumerable:!0,get:function(){return V_.VoiceProfilePhraseResult}});var U_=VS();Object.defineProperty(v,"VoiceProfileClient",{enumerable:!0,get:function(){return U_.VoiceProfileClient}});var W_=US();Object.defineProperty(v,"SpeakerRecognizer",{enumerable:!0,get:function(){return W_.SpeakerRecognizer}});var H_=WS();Object.defineProperty(v,"SpeakerIdentificationModel",{enumerable:!0,get:function(){return H_.SpeakerIdentificationModel}});var K_=KS();Object.defineProperty(v,"SpeakerVerificationModel",{enumerable:!0,get:function(){return K_.SpeakerVerificationModel}});var J_=GS();Object.defineProperty(v,"AutoDetectSourceLanguageConfig",{enumerable:!0,get:function(){return J_.AutoDetectSourceLanguageConfig}});var G_=QS();Object.defineProperty(v,"AutoDetectSourceLanguageResult",{enumerable:!0,get:function(){return G_.AutoDetectSourceLanguageResult}});var $_=YS();Object.defineProperty(v,"SourceLanguageConfig",{enumerable:!0,get:function(){return $_.SourceLanguageConfig}});var zl=ZS();Object.defineProperty(v,"SpeakerRecognitionResult",{enumerable:!0,get:function(){return zl.SpeakerRecognitionResult}});Object.defineProperty(v,"SpeakerRecognitionResultType",{enumerable:!0,get:function(){return zl.SpeakerRecognitionResultType}});Object.defineProperty(v,"SpeakerRecognitionCancellationDetails",{enumerable:!0,get:function(){return zl.SpeakerRecognitionCancellationDetails}});var ze=xa();Object.defineProperty(v,"Conversation",{enumerable:!0,get:function(){return ze.Conversation}});Object.defineProperty(v,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return ze.ConversationExpirationEventArgs}});Object.defineProperty(v,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return ze.ConversationParticipantsChangedEventArgs}});Object.defineProperty(v,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return ze.ConversationTranslationCanceledEventArgs}});Object.defineProperty(v,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return ze.ConversationTranslationEventArgs}});Object.defineProperty(v,"ConversationTranslationResult",{enumerable:!0,get:function(){return ze.ConversationTranslationResult}});Object.defineProperty(v,"ConversationTranslator",{enumerable:!0,get:function(){return ze.ConversationTranslator}});Object.defineProperty(v,"ConversationTranscriber",{enumerable:!0,get:function(){return ze.ConversationTranscriber}});Object.defineProperty(v,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return ze.ConversationTranscriptionResult}});Object.defineProperty(v,"Meeting",{enumerable:!0,get:function(){return ze.Meeting}});Object.defineProperty(v,"MeetingTranscriber",{enumerable:!0,get:function(){return ze.MeetingTranscriber}});Object.defineProperty(v,"Participant",{enumerable:!0,get:function(){return ze.Participant}});Object.defineProperty(v,"ParticipantChangedReason",{enumerable:!0,get:function(){return ze.ParticipantChangedReason}});Object.defineProperty(v,"User",{enumerable:!0,get:function(){return ze.User}});var Q_=Va();Object.defineProperty(v,"Synthesizer",{enumerable:!0,get:function(){return Q_.Synthesizer}});var Y_=Sd();Object.defineProperty(v,"SpeechSynthesisOutputFormat",{enumerable:!0,get:function(){return Y_.SpeechSynthesisOutputFormat}});var X_=Ey();Object.defineProperty(v,"SpeechSynthesizer",{enumerable:!0,get:function(){return X_.SpeechSynthesizer}});var Z_=wy();Object.defineProperty(v,"SynthesisResult",{enumerable:!0,get:function(){return Z_.SynthesisResult}});var eA=Iy();Object.defineProperty(v,"SpeechSynthesisResult",{enumerable:!0,get:function(){return eA.SpeechSynthesisResult}});var tA=Ty();Object.defineProperty(v,"SpeechSynthesisEventArgs",{enumerable:!0,get:function(){return tA.SpeechSynthesisEventArgs}});var rA=_y();Object.defineProperty(v,"SpeechSynthesisWordBoundaryEventArgs",{enumerable:!0,get:function(){return rA.SpeechSynthesisWordBoundaryEventArgs}});var iA=Ay();Object.defineProperty(v,"SpeechSynthesisBookmarkEventArgs",{enumerable:!0,get:function(){return iA.SpeechSynthesisBookmarkEventArgs}});var nA=by();Object.defineProperty(v,"SpeechSynthesisVisemeEventArgs",{enumerable:!0,get:function(){return nA.SpeechSynthesisVisemeEventArgs}});var sA=Oy();Object.defineProperty(v,"SpeechSynthesisBoundaryType",{enumerable:!0,get:function(){return sA.SpeechSynthesisBoundaryType}});var oA=My();Object.defineProperty(v,"SynthesisVoicesResult",{enumerable:!0,get:function(){return oA.SynthesisVoicesResult}});var aA=Dy();Object.defineProperty(v,"VoiceInfo",{enumerable:!0,get:function(){return aA.VoiceInfo}});var cA=Ny();Object.defineProperty(v,"SpeakerAudioDestination",{enumerable:!0,get:function(){return cA.SpeakerAudioDestination}});var pA=xy();Object.defineProperty(v,"ConversationTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return pA.ConversationTranscriptionCanceledEventArgs}});var uA=qy();Object.defineProperty(v,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return uA.MeetingTranscriptionCanceledEventArgs}});var dA=zy();Object.defineProperty(v,"PronunciationAssessmentGradingSystem",{enumerable:!0,get:function(){return dA.PronunciationAssessmentGradingSystem}});var hA=jy();Object.defineProperty(v,"PronunciationAssessmentGranularity",{enumerable:!0,get:function(){return hA.PronunciationAssessmentGranularity}});var lA=Ly();Object.defineProperty(v,"PronunciationAssessmentConfig",{enumerable:!0,get:function(){return lA.PronunciationAssessmentConfig}});var vA=By();Object.defineProperty(v,"PronunciationAssessmentResult",{enumerable:!0,get:function(){return vA.PronunciationAssessmentResult}});var fA=kh();Object.defineProperty(v,"LanguageIdMode",{enumerable:!0,get:function(){return fA.LanguageIdMode}});var gA=Fy();Object.defineProperty(v,"AvatarConfig",{enumerable:!0,get:function(){return gA.AvatarConfig}});var mA=Vy();Object.defineProperty(v,"AvatarEventArgs",{enumerable:!0,get:function(){return mA.AvatarEventArgs}});var SA=Wy();Object.defineProperty(v,"AvatarSynthesizer",{enumerable:!0,get:function(){return SA.AvatarSynthesizer}});var Zy=Hy();Object.defineProperty(v,"AvatarVideoFormat",{enumerable:!0,get:function(){return Zy.AvatarVideoFormat}});Object.defineProperty(v,"Coordinate",{enumerable:!0,get:function(){return Zy.Coordinate}});var yA=Ky();Object.defineProperty(v,"AvatarWebRTCConnectionResult",{enumerable:!0,get:function(){return yA.AvatarWebRTCConnectionResult}});var CA=Jy();Object.defineProperty(v,"Diagnostics",{enumerable:!0,get:function(){return CA.Diagnostics}});var PA=id();Object.defineProperty(v,"LogLevel",{enumerable:!0,get:function(){return PA.LogLevel}})});var eC=p(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});hc.ProxyInfo=void 0;var dc=f(),jl=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(dc.PropertyId.SpeechServiceConnection_ProxyHostName),parseInt(e.getProperty(dc.PropertyId.SpeechServiceConnection_ProxyPort),10),e.getProperty(dc.PropertyId.SpeechServiceConnection_ProxyUserName),e.getProperty(dc.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}};hc.ProxyInfo=jl});var rC=p((P1,tC)=>{"use strict";var RA=new Set(["json","buffer","string"]);tC.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(RA.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 nC=p((R1,iC)=>{"use strict";var EA=rC(),Ll=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}},wA=(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 Ll(u);return t==="json"?u.json():t==="buffer"?u.arrayBuffer():t==="string"?u.text():u};iC.exports=EA(wA)});var oC=p(Jt=>{"use strict";var IA=Jt&&Jt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.RestMessageAdapter=Jt.RestRequestType=void 0;var TA=IA(nC()),sC=P(),lc;(function(i){i.Get="GET",i.Post="POST",i.Delete="DELETE",i.File="file"})(lc=Jt.RestRequestType||(Jt.RestRequestType={}));var Bl=class{constructor(e){if(!e)throw new sC.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 sC.Deferred,o=e===lc.File?"POST":e,a=(u,d={})=>{let h=u;return{data:JSON.stringify(d),headers:JSON.stringify(u.headers),json:d,ok:u.statusCode>=200&&u.statusCode<300,status:u.statusCode,statusText:d.error?d.error.message:h.statusText?h.statusText:h.statusMessage}},c=u=>{let d=TA.default(t,o,this.privHeaders,200,201,202,204,400,401,402,403,404),h=this.queryParams(r)===""?"":`?${this.queryParams(r)}`;d(h,u).then(async l=>{if(e===lc.Delete||l.statusCode===204)s.resolve(a(l));else try{let g=await l.json();s.resolve(a(l,g))}catch{s.resolve(a(l))}}).catch(l=>{s.reject(l)})};return this.privIgnoreCache&&(this.privHeaders["Cache-Control"]="no-cache"),e===lc.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("&")}};Jt.RestMessageAdapter=Bl});var Fl=p(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});vc.RestConfigBase=void 0;var Ni=class i{static get requestOptions(){return i.privDefaultRequestOptions}static get configParams(){return i.privDefaultParams}static get restErrors(){return i.privRestErrors}};vc.RestConfigBase=Ni;Ni.privDefaultRequestOptions={headers:{Accept:"application/json"},ignoreCache:!1,timeout:1e4};Ni.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."};Ni.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 ae=p(fe=>{"use strict";var _A=fe&&fe.__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]}),ht=fe&&fe.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&_A(e,i,t)};Object.defineProperty(fe,"__esModule",{value:!0});ht(gm(),fe);ht(Sm(),fe);ht(Pm(),fe);ht(Em(),fe);ht(wm(),fe);ht(Mm(),fe);ht(pd(),fe);ht(Dm(),fe);ht(eC(),fe);ht(oC(),fe);ht(Fl(),fe)});var pC=p(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});fc.IntentConnectionFactory=void 0;var aC=ae(),Yn=f(),cC=$e(),AA=C(),bA=we(),Vl=class extends cC.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_Endpoint);if(!n){let c=e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_IntentRegion),u=cC.ConnectionFactoryBase.getHostSuffix(c);n=e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_Host,"wss://"+c+".sr.speech"+u)+"/speech/recognition/interactive/cognitiveservices/v1"}let s={format:"simple",language:e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,s,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[bA.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Yn.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new aC.WebsocketConnection(n,s,o,new AA.WebsocketMessageFormatter,aC.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}}};fc.IntentConnectionFactory=Vl});var lC=p(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.VoiceProfileConnectionFactory=xi.SpeakerRecognitionConnectionFactory=void 0;var uC=ae(),$r=f(),dC=$e(),OA=C(),hC=we(),gc=class extends dC.ConnectionFactoryBase{create(e,t,r,n){let s=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Endpoint);if(!s){let u=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Region),d=dC.ConnectionFactoryBase.getHostSuffix(u),h=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Host,`wss://${u}.spr-frontend.speech${d}`),l=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_SpeakerIdMode,"TextIndependentIdentification");s=`${h}/speaker/ws/${this.scenarioToPath(l)}/${r}`}let o={format:"simple",language:e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,o,s);let a={};t.token!==void 0&&t.token!==""&&(a[t.headerName]=t.token),a[hC.HeaderNames.ConnectionId]=n,a[hC.HeaderNames.SpIDAuthKey]=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Key),e.parameters.setProperty($r.PropertyId.SpeechServiceConnection_Url,s);let c=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new uC.WebsocketConnection(s,o,a,new OA.WebsocketMessageFormatter,uC.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"}}},Ul=class extends gc{create(e,t,r){return super.create(e,t,"recognition",r)}};xi.SpeakerRecognitionConnectionFactory=Ul;var Wl=class extends gc{create(e,t,r){return super.create(e,t,"profile",r)}};xi.VoiceProfileConnectionFactory=Wl});var Sc=p(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.RecognitionEndedEvent=ge.RecognitionCompletionStatus=ge.RecognitionStartedEvent=ge.ConnectingToServiceEvent=ge.ListeningStartedEvent=ge.RecognitionTriggeredEvent=ge.SpeechRecognitionEvent=void 0;var mc=P(),fr=class extends mc.PlatformEvent{constructor(e,t,r,n=mc.EventType.Info){super(e,n),this.privRequestId=t,this.privSessionId=r}get requestId(){return this.privRequestId}get sessionId(){return this.privSessionId}};ge.SpeechRecognitionEvent=fr;var Hl=class extends fr{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}};ge.RecognitionTriggeredEvent=Hl;var Kl=class extends fr{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}};ge.ListeningStartedEvent=Kl;var Jl=class extends fr{constructor(e,t,r){super("ConnectingToServiceEvent",e,r),this.privAuthFetchEventid=t}get authFetchEventid(){return this.privAuthFetchEventid}};ge.ConnectingToServiceEvent=Jl;var Gl=class extends fr{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}};ge.RecognitionStartedEvent=Gl;var vC;(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"})(vC=ge.RecognitionCompletionStatus||(ge.RecognitionCompletionStatus={}));var $l=class extends fr{constructor(e,t,r,n,s,o,a,c){super("RecognitionEndedEvent",e,s,a===vC.Success?mc.EventType.Info:mc.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}};ge.RecognitionEndedEvent=$l});var Qr=p(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});yc.SpeechConnectionMessage=void 0;var Ql=P(),Gt=we(),Yl=class i extends Ql.ConnectionMessage{constructor(e,t,r,n,s,o,a,c){if(!t)throw new Ql.ArgumentNullError("path");if(!r)throw new Ql.ArgumentNullError("requestId");let u={};if(u[Gt.HeaderNames.Path]=t,u[Gt.HeaderNames.RequestId]=r,u[Gt.HeaderNames.RequestTimestamp]=new Date().toISOString(),n&&(u[Gt.HeaderNames.ContentType]=n),o&&(u[Gt.HeaderNames.RequestStreamId]=o),a)for(let d in a)d&&(u[d]=a[d]);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()===Gt.HeaderNames.Path.toLowerCase()?t=e.headers[a]:a.toLowerCase()===Gt.HeaderNames.RequestId.toLowerCase()?r=e.headers[a]:a.toLowerCase()===Gt.HeaderNames.ContentType.toLowerCase()?n=e.headers[a]:a.toLowerCase()===Gt.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)}};yc.SpeechConnectionMessage=Yl});var fC=p(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});Pc.ServiceRecognizerBase=void 0;var MA=ae(),Z=P(),B=f(),It=C(),gr=Qr(),Cc=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 Z.ArgumentNullError("authentication");if(!t)throw new Z.ArgumentNullError("connectionFactory");if(!r)throw new Z.ArgumentNullError("audioSource");if(!n)throw new Z.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 It.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new Z.EventSource,this.privServiceEvents=new Z.EventSource,this.privDynamicGrammar=new It.DynamicGrammarBuilder,this.privSpeechContext=new It.SpeechContext(this.privDynamicGrammar),this.privAgentConfig=new It.AgentConfig,this.privRecognizerConfig.parameters.getProperty(B.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?this.privSetTimeout=Z.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=Z.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===It.RecognitionMode.Conversation?"CONVERSATION":this.recognitionMode===It.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(It.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,d=await this.audioSource.deviceInfo;this.privIsLiveAudio=d.type&&d.type===It.type.Microphones,s=new MA.ReplayableAudioNode(c,u.avgBytesPerSec),await this.privRequestSession.onAudioSourceAttachCompleted(s,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:d}}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"?Z.MessageType.Text:Z.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new gr.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 gr.SpeechConnectionMessage(Z.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=gr.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=It.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=It.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 Z.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 gr.SpeechConnectionMessage(Z.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 gr.SpeechConnectionMessage(Z.MessageType.Binary,"audio",this.privRequestSession.requestId,"audio/x-wav",t.header))}connectImpl(){return this.privConnectionPromise!==void 0?this.privConnectionPromise.then(e=>e.state()===Z.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 gr.SpeechConnectionMessage(Z.MessageType.Text,"speech.config",t.requestId,"application/json",r))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===Z.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 d,h;if(!u||u.isEnd?(d=null,h=0):(d=u.buffer,this.privRequestSession.onAudioSent(d.byteLength),s>=this.privRequestSession.bytesSent?h=0:h=Math.max(0,r-Date.now())),h!==0&&await this.delay(h),d!==null&&(r=Date.now()+d.byteLength*1e3/(t.avgBytesPerSec*2)),!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o)if(c.send(new gr.SpeechConnectionMessage(Z.MessageType.Binary,"audio",this.privRequestSession.requestId,null,d)).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=Z.createNoDashGuid();let t=this.privRequestSession.sessionId;this.privConnectionId=t!==void 0?t:Z.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
|
|
17
|
+
registerProcessor('speech-processor', SP);`,d=new Blob([u],{type:"application/javascript; charset=utf-8"});this.privSpeechProcessorScript=URL.createObjectURL(d)}e.audioWorklet.addModule(this.privSpeechProcessorScript).then(()=>{let u=new AudioWorkletNode(e,"speech-processor");u.port.onmessage=d=>{let h=d.data;if(r&&!r.isClosed){let l=s.encode(h);l&&r.writeStreamChunk({buffer:l,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}};Ys.PcmRecorder=ad});var wm=p(()=>{});var Im=p(()=>{});var Tm=p(()=>{});var _m=p(()=>{});var Am=p(()=>{});var pd=p(Ke=>{"use strict";var bw=Ke&&Ke.__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]}),Ow=Ke&&Ke.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),bm=Ke&&Ke.__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)&&bw(e,i,t);return Ow(e,i),e},cd=Ke&&Ke.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ke,"__esModule",{value:!0});Ke.WebsocketMessageAdapter=void 0;var Mw=bm(wm()),Dw=bm(Im()),kw=cd(Tm()),Nw=cd(_m()),xw=cd(Am()),qw=we(),T=P(),Xs=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[qw.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 xw.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 kw.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 Nw.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(Dw.connect(t)):r=Promise.resolve(Mw.connect(t));return r}get isWebsocketOpen(){return this.privWebsocketClient&&this.privWebsocketClient.readyState===this.privWebsocketClient.OPEN}};Ke.WebsocketMessageAdapter=Xs;Xs.forceNpmWebSocket=!1});var Om=p(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.WebsocketConnection=void 0;var ud=P(),zw=pd(),dd=class{constructor(e,t,r,n,s,o=!1,a){if(this.privIsDisposed=!1,!e)throw new ud.ArgumentNullError("uri");if(!n)throw new ud.ArgumentNullError("messageFormatter");this.privMessageFormatter=n;let c="",u=0;if(t){for(let d in t)if(d){c+=u===0&&e.indexOf("?")===-1?"?":"&";let h=encodeURIComponent(d);c+=h;let l=t[d];l&&(l=encodeURIComponent(l),c+=`=${l}`),u++}}if(r){for(let d in r)if(d){c+=u===0&&e.indexOf("?")===-1?"?":"&";let h=encodeURIComponent(r[d]);c+=`${d}=${h}`,u++}}this.privUri=e+c,this.privId=a||ud.createNoDashGuid(),this.privConnectionMessageAdapter=new zw.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}};Zs.WebsocketConnection=dd});var Mm=p(eo=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});eo.ReplayableAudioNode=void 0;var hd=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 ld(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}};eo.ReplayableAudioNode=hd;var ld=class{constructor(e,t,r){this.chunk=e,this.serial=t,this.byteOffset=r}}});var gd=p(Ct=>{"use strict";var jw=Ct&&Ct.__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]}),Lw=Ct&&Ct.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Bw=Ct&&Ct.__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)&&jw(e,i,t);return Lw(e,i),e};Object.defineProperty(Ct,"__esModule",{value:!0});Ct.AudioFileWriter=void 0;var vn=Bw(rd()),vd=w(),fd=class{constructor(e){vd.Contracts.throwIfNullOrUndefined(vn.openSync,`
|
|
18
|
+
File System access not available, please use Push or PullAudioOutputStream`),this.privFd=vn.openSync(e,"w")}set format(e){vd.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=vn.createWriteStream("",{fd:this.privFd,start:t,autoClose:!1}))}write(e){vd.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),vn.writeSync(this.privFd,new Int8Array(this.privAudioFormat.header),0,this.privAudioFormat.header.byteLength,0)),vn.closeSync(this.privFd),this.privFd=void 0}),this.privWriteStream.end())}id(){return this.privId}};Ct.AudioFileWriter=fd});var md=p(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.PullAudioInputStreamImpl=Je.PullAudioInputStream=Je.PushAudioInputStreamImpl=Je.PushAudioInputStream=Je.AudioInputStream=void 0;var to=C(),le=P(),Dm=rr(),Fw=f(),Vw=sr(),fn=class{constructor(){}static createPushStream(e){return gn.create(e)}static createPullStream(e,t){return mn.create(e,t)}};Je.AudioInputStream=fn;var gn=class extends fn{static create(e){return new ro(e)}};Je.PushAudioInputStream=gn;var ro=class extends gn{constructor(e){super(),e===void 0?this.privFormat=Vw.AudioStreamFormatImpl.getDefaultInputFormat():this.privFormat=e,this.privEvents=new le.EventSource,this.privId=Dm.createNoDashGuid(),this.privStream=new le.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 le.AudioSourceInitializingEvent(this.privId)),this.onEvent(new le.AudioSourceReadyEvent(this.privId))}async attach(e){this.onEvent(new le.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn();let t=this.privStream;return this.onEvent(new le.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(this.onEvent(new le.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}}detach(e){this.onEvent(new le.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:to.connectivity.Unknown,manufacturer:"Speech SDK",model:"PushStream",samplerate:this.privFormat.samplesPerSec,type:to.type.Stream})}onEvent(e){this.privEvents.onEvent(e),le.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}};Je.PushAudioInputStreamImpl=ro;var mn=class extends fn{constructor(){super()}static create(e,t){return new io(e,t)}};Je.PullAudioInputStream=mn;var io=class extends mn{constructor(e,t){super(),t===void 0?this.privFormat=Fw.AudioStreamFormat.getDefaultInputFormat():this.privFormat=t,this.privEvents=new le.EventSource,this.privId=Dm.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 le.AudioSourceInitializingEvent(this.privId)),this.onEvent(new le.AudioSourceReadyEvent(this.privId))}async attach(e){return this.onEvent(new le.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn(),this.onEvent(new le.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:()=>(this.privCallback.close(),this.onEvent(new le.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 le.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:to.connectivity.Unknown,manufacturer:"Speech SDK",model:"PullStream",samplerate:this.privFormat.samplesPerSec,type:to.type.Stream})}onEvent(e){this.privEvents.onEvent(e),le.Events.instance.onEvent(e)}};Je.PullAudioInputStreamImpl=io});var Sd=p(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.SpeechSynthesisOutputFormat=void 0;var Uw;(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"})(Uw=Sn.SpeechSynthesisOutputFormat||(Sn.SpeechSynthesisOutputFormat={}))});var li=p(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.AudioOutputFormatImpl=void 0;var O=Sd(),A=sr(),no=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}};so.AudioOutputFormatImpl=no;no.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 Dr=p(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.PushAudioOutputStreamImpl=Ge.PushAudioOutputStream=Ge.PullAudioOutputStreamImpl=Ge.PullAudioOutputStream=Ge.AudioOutputStream=void 0;var yd=P(),Ww=w(),Hw=li(),yn=class{constructor(){}static createPullStream(){return Cn.create()}};Ge.AudioOutputStream=yn;var Cn=class extends yn{static create(){return new oo}};Ge.PullAudioOutputStream=Cn;var oo=class extends Cn{constructor(){super(),this.privId=yd.createNoDashGuid(),this.privStream=new yd.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){Ww.Contracts.throwIfNullOrUndefined(this.privStream,"must set format before writing"),this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}};Ge.PullAudioOutputStreamImpl=oo;var ao=class extends yn{constructor(){super()}static create(e){return new co(e)}};Ge.PushAudioOutputStream=ao;var co=class extends ao{constructor(e){super(),this.privId=yd.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}};Ge.PushAudioOutputStreamImpl=co});var Cd=p(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.AudioOutputConfigImpl=or.AudioConfigImpl=or.AudioConfig=void 0;var kr=ae(),Kw=w(),Nr=f(),Jw=gd(),Gw=md(),$w=Dr(),Pn=class i{static fromDefaultMicrophoneInput(){let e=new kr.PcmRecorder(!0);return new Bt(new kr.MicAudioSource(e))}static fromMicrophoneInput(e){let t=new kr.PcmRecorder(!0);return new Bt(new kr.MicAudioSource(t,e))}static fromWavFileInput(e,t="unnamedBuffer.wav"){return new Bt(new kr.FileAudioSource(e,t))}static fromStreamInput(e){if(e instanceof Nr.PullAudioInputStreamCallback)return new Bt(new Gw.PullAudioInputStreamImpl(e));if(e instanceof Nr.AudioInputStream)return new Bt(e);if(typeof MediaStream<"u"&&e instanceof MediaStream){let t=new kr.PcmRecorder(!1);return new Bt(new kr.MicAudioSource(t,null,null,e))}throw new Error("Not Supported Type")}static fromDefaultSpeakerOutput(){return new Ft(new Nr.SpeakerAudioDestination)}static fromSpeakerOutput(e){if(e===void 0)return i.fromDefaultSpeakerOutput();if(e instanceof Nr.SpeakerAudioDestination)return new Ft(e);throw new Error("Not Supported Type")}static fromAudioFileOutput(e){return new Ft(new Jw.AudioFileWriter(e))}static fromStreamOutput(e){if(e instanceof Nr.PushAudioOutputStreamCallback)return new Ft(new $w.PushAudioOutputStreamImpl(e));if(e instanceof Nr.PushAudioOutputStream)return new Ft(e);if(e instanceof Nr.PullAudioOutputStream)return new Ft(e);throw new Error("Not Supported Type")}};or.AudioConfig=Pn;var Bt=class extends Pn{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(Kw.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}};or.AudioConfigImpl=Bt;var Ft=class extends Pn{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.")}};or.AudioOutputConfigImpl=Ft});var km=p(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.CancellationReason=void 0;var Qw;(function(i){i[i.Error=0]="Error",i[i.EndOfStream=1]="EndOfStream"})(Qw=Rn.CancellationReason||(Rn.CancellationReason={}))});var Nm=p(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.PullAudioInputStreamCallback=void 0;var Pd=class{};po.PullAudioInputStreamCallback=Pd});var xm=p(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.PushAudioOutputStreamCallback=void 0;var Rd=class{};uo.PushAudioOutputStreamCallback=Rd});var zm=p(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.KeywordRecognitionModel=void 0;var qm=w(),Ed=class{constructor(){this.privDisposed=!1}static fromFile(e){throw qm.Contracts.throwIfFileDoesNotExist(e,"fileName"),new Error("Not yet implemented.")}static fromStream(e){throw qm.Contracts.throwIfNull(e,"file"),new Error("Not yet implemented.")}close(){this.privDisposed||(this.privDisposed=!0)}};ho.KeywordRecognitionModel=Ed});var jm=p(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});lo.SessionEventArgs=void 0;var wd=class{constructor(e){this.privSessionId=e}get sessionId(){return this.privSessionId}};lo.SessionEventArgs=wd});var Lm=p(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.RecognitionEventArgs=void 0;var Yw=f(),Id=class extends Yw.SessionEventArgs{constructor(e,t){super(t),this.privOffset=e}get offset(){return this.privOffset}};vo.RecognitionEventArgs=Id});var Bm=p(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.OutputFormat=void 0;var Xw;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(Xw=En.OutputFormat||(En.OutputFormat={}))});var Fm=p(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.IntentRecognitionEventArgs=void 0;var Zw=f(),Td=class extends Zw.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};fo.IntentRecognitionEventArgs=Td});var Vm=p(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.RecognitionResult=void 0;var _d=class{constructor(e,t,r,n,s,o,a,c,u,d){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=d}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}};go.RecognitionResult=_d});var Um=p(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.SpeechRecognitionResult=void 0;var eI=f(),Ad=class extends eI.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(e,t,r,n,s,o,a,u,d,h),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};mo.SpeechRecognitionResult=Ad});var Wm=p(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.IntentRecognitionResult=void 0;var tI=f(),bd=class extends tI.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(t,r,n,s,o,a,c,void 0,u,d,h),this.privIntentId=e}get intentId(){return this.privIntentId}};So.IntentRecognitionResult=bd});var Hm=p(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.LanguageUnderstandingModelImpl=gi.LanguageUnderstandingModel=void 0;var vi=w(),yo=class{constructor(){}static fromEndpoint(e){vi.Contracts.throwIfNull(e,"uri"),vi.Contracts.throwIfNullOrWhitespace(e.hostname,"uri");let t=new fi,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){vi.Contracts.throwIfNullOrWhitespace(e,"appId");let t=new fi;return t.appId=e,t}static fromSubscription(e,t,r){vi.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),vi.Contracts.throwIfNullOrWhitespace(t,"appId"),vi.Contracts.throwIfNullOrWhitespace(r,"region");let n=new fi;return n.appId=t,n.region=r,n.subscriptionKey=e,n}};gi.LanguageUnderstandingModel=yo;var fi=class extends yo{};gi.LanguageUnderstandingModelImpl=fi});var Jm=p(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.MeetingTranscriptionEventArgs=ar.ConversationTranscriptionEventArgs=ar.SpeechRecognitionEventArgs=void 0;var Km=f(),Co=class extends Km.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};ar.SpeechRecognitionEventArgs=Co;var Od=class extends Km.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};ar.ConversationTranscriptionEventArgs=Od;var Md=class extends Co{};ar.MeetingTranscriptionEventArgs=Md});var mi=p(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.CancellationEventArgsBase=void 0;var rI=f(),Dd=class extends rI.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}};Po.CancellationEventArgsBase=Dd});var Gm=p(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});Ro.SpeechRecognitionCanceledEventArgs=void 0;var iI=mi(),kd=class extends iI.CancellationEventArgsBase{};Ro.SpeechRecognitionCanceledEventArgs=kd});var $m=p(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.TranslationRecognitionEventArgs=void 0;var nI=f(),Nd=class extends nI.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};Eo.TranslationRecognitionEventArgs=Nd});var Qm=p(wo=>{"use strict";Object.defineProperty(wo,"__esModule",{value:!0});wo.TranslationSynthesisEventArgs=void 0;var sI=f(),xd=class extends sI.SessionEventArgs{constructor(e,t){super(t),this.privResult=e}get result(){return this.privResult}};wo.TranslationSynthesisEventArgs=xd});var zd=p(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.TranslationRecognitionResult=void 0;var oI=f(),qd=class i extends oI.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(t,r,n,s,o,a,c,void 0,u,d,h),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}};Io.TranslationRecognitionResult=qd});var Ym=p(To=>{"use strict";Object.defineProperty(To,"__esModule",{value:!0});To.TranslationSynthesisResult=void 0;var jd=class{constructor(e,t){this.privReason=e,this.privAudio=t}get audio(){return this.privAudio}get reason(){return this.privReason}};To.TranslationSynthesisResult=jd});var Xm=p(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.ResultReason=void 0;var aI;(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"})(aI=wn.ResultReason||(wn.ResultReason={}))});var Zm=p(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.SpeechConfigImpl=Si.SpeechConfig=void 0;var In=C(),xr=w(),I=f(),_o=class{constructor(){}static fromSubscription(e,t){xr.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),xr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(I.PropertyId.SpeechServiceConnection_IntentRegion,t),r.setProperty(I.PropertyId.SpeechServiceConnection_Key,e),r}static fromEndpoint(e,t){xr.Contracts.throwIfNull(e,"endpoint");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Endpoint,e.href),t!==void 0&&r.setProperty(I.PropertyId.SpeechServiceConnection_Key,t),r}static fromHost(e,t){xr.Contracts.throwIfNull(e,"hostName");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(I.PropertyId.SpeechServiceConnection_Key,t),r}static fromAuthorizationToken(e,t){xr.Contracts.throwIfNull(e,"authorizationToken"),xr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(I.PropertyId.SpeechServiceConnection_IntentRegion,t),r.authorizationToken=e,r}close(){}};Si.SpeechConfig=_o;var qr=class i extends _o{constructor(){super(),this.privProperties=new I.PropertyCollection,this.speechRecognitionLanguage="en-US",this.outputFormat=I.OutputFormat.Simple}get properties(){return this.privProperties}get endPoint(){return new URL(this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Endpoint))}get subscriptionKey(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Key)}get region(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Region)}get authorizationToken(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_RecoLanguage)}set speechRecognitionLanguage(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get autoDetectSourceLanguages(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)}set autoDetectSourceLanguages(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e)}get outputFormat(){return I.OutputFormat[this.privProperties.getProperty(In.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privProperties.setProperty(In.OutputFormatPropertyName,I.OutputFormat[e])}get endpointId(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_EndpointId,e)}setProperty(e,t){xr.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(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyPassword],n)}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(In.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(In.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceResponse_ProfanityOption,I.ProfanityOption[e])}enableAudioLogging(){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privProperties.setProperty(I.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privProperties.setProperty(In.ForceDictationPropertyName,"true")}clone(){let e=new i;return e.privProperties=this.privProperties.clone(),e}get speechSynthesisLanguage(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return I.SpeechSynthesisOutputFormat[this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthOutputFormat,I.SpeechSynthesisOutputFormat[e])}};Si.SpeechConfigImpl=qr});var eS=p(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.SpeechTranslationConfigImpl=yi.SpeechTranslationConfig=void 0;var Tn=C(),at=w(),E=f(),Ao=class extends E.SpeechConfig{constructor(){super()}static fromSubscription(e,t){at.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),at.Contracts.throwIfNullOrWhitespace(t,"region");let r=new zr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromAuthorizationToken(e,t){at.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),at.Contracts.throwIfNullOrWhitespace(t,"region");let r=new zr;return r.properties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromHost(e,t){at.Contracts.throwIfNull(e,"hostName");let r=new zr;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){at.Contracts.throwIfNull(e,"endpoint"),at.Contracts.throwIfNull(t,"subscriptionKey");let r=new zr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Endpoint,e.href),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}};yi.SpeechTranslationConfig=Ao;var zr=class extends Ao{constructor(){super(),this.privSpeechProperties=new E.PropertyCollection,this.outputFormat=E.OutputFormat.Simple}set authorizationToken(e){at.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e)}set speechRecognitionLanguage(e){at.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(Tn.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privSpeechProperties.setProperty(Tn.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){at.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){at.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(Tn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privSpeechProperties.setProperty(Tn.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(Tn.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])}};yi.SpeechTranslationConfigImpl=zr});var Bd=p(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.PropertyCollection=void 0;var tS=f(),Ld=class i{constructor(){this.privKeys=[],this.privValues=[]}getProperty(e,t){let r;typeof e=="string"?r=e:r=tS.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=tS.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}};bo.PropertyCollection=Ld});var Oo=p(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.PropertyId=void 0;var cI;(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"})(cI=_n.PropertyId||(_n.PropertyId={}))});var iS=p(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.Recognizer=void 0;var jr=C(),rS=P(),Mo=w(),Do=f(),Fd=class i{constructor(e,t,r){this.audioConfig=e!==void 0?e:Do.AudioConfig.fromDefaultMicrophoneInput(),this.privDisposed=!1,this.privProperties=t.clone(),this.privConnectionFactory=r,this.implCommonRecognizerSetup()}close(e,t){Mo.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 jr.ServiceRecognizerBase.telemetryDataEnabled}static enableTelemetry(e){jr.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 jr.SpeechServiceConfig(new jr.Context(new jr.OS(e,t,r))));this.privReco=this.createServiceRecognizer(i.getAuthFromProperties(this.privProperties),this.privConnectionFactory,this.audioConfig,n)}async recognizeOnceAsyncImpl(e){Mo.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){Mo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop(),await this.privReco.recognize(e,void 0,void 0)}async stopContinuousRecognitionAsyncImpl(){Mo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop()}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}static getAuthFromProperties(e){let t=e.getProperty(Do.PropertyId.SpeechServiceConnection_Key,void 0);return t&&t!==""?new jr.CognitiveSubscriptionKeyAuthentication(t):new jr.CognitiveTokenAuthentication(()=>{let n=e.getProperty(Do.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)},()=>{let n=e.getProperty(Do.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)})}};ko.Recognizer=Fd});var nS=p(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.SpeechRecognizer=void 0;var Ci=C(),No=P(),cr=w(),Ne=f(),Vd=class i extends Ne.Recognizer{constructor(e,t){let r=e;cr.Contracts.throwIfNull(r,"speechConfig"),cr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_RecoLanguage),Ne.PropertyId[Ne.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Ci.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 cr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(Ne.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){cr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Ne.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return cr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return cr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ci.OutputFormatPropertyName,Ne.OutputFormat[Ne.OutputFormat.Simple])===Ne.OutputFormat[Ne.OutputFormat.Simple]?Ne.OutputFormat.Simple:Ne.OutputFormat.Detailed}get properties(){return this.privProperties}recognizeOnceAsync(e,t){No.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Ci.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){No.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Ci.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){No.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){cr.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e){e&&e()}close(e,t){cr.Contracts.throwIfDisposed(this.privDisposedRecognizer),No.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 Ci.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Ci.SpeechServiceRecognizer(e,t,s,n,this)}};xo.SpeechRecognizer=Vd});var sS=p(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.IntentRecognizer=void 0;var Lr=C(),qo=P(),Ie=w(),Vt=f(),Ud=class extends Vt.Recognizer{constructor(e,t){Ie.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;Ie.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new Lr.IntentConnectionFactory),this.privAddedIntents=[],this.privAddedLmIntents={},this.privDisposedIntentRecognizer=!1,this.privProperties=r.properties,Ie.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(Vt.PropertyId.SpeechServiceConnection_RecoLanguage),Vt.PropertyId[Vt.PropertyId.SpeechServiceConnection_RecoLanguage])}get speechRecognitionLanguage(){return Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.properties.getProperty(Vt.PropertyId.SpeechServiceConnection_RecoLanguage)}get authorizationToken(){return this.properties.getProperty(Vt.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(Vt.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}recognizeOnceAsync(e,t){if(Ie.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)}qo.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Lr.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)}qo.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Lr.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){qo.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){Ie.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e,t){if(e)try{e()}catch(r){t&&t(r)}}addIntent(e,t){Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Ie.Contracts.throwIfNullOrWhitespace(t,"intentId"),Ie.Contracts.throwIfNullOrWhitespace(e,"simplePhrase"),this.privAddedIntents.push([t,e])}addIntentWithLanguageModel(e,t,r){Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Ie.Contracts.throwIfNullOrWhitespace(e,"intentId"),Ie.Contracts.throwIfNull(t,"model");let n=t;Ie.Contracts.throwIfNullOrWhitespace(n.appId,"model.appId"),this.privAddedLmIntents[e]=new Lr.AddedLmIntent(n,r)}addAllIntents(e,t){Ie.Contracts.throwIfNull(e,"model");let r=e;Ie.Contracts.throwIfNullOrWhitespace(r.appId,"model.appId"),this.privUmbrellaIntent=new Lr.AddedLmIntent(r,t)}close(e,t){Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),qo.marshalPromiseToCallbacks(this.dispose(!0),e,t)}createRecognizerConfig(e){return new Lr.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Lr.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(Vt.PropertyId[Vt.PropertyId.SpeechServiceConnection_Key]):r,provider:"LUIS"},ReferenceGrammars:this.privUmbrellaIntent===void 0?n:["luis/"+e+"-PRODUCTION"]}}};zo.IntentRecognizer=Ud});var oS=p(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.VoiceProfileType=void 0;var pI;(function(i){i[i.TextIndependentIdentification=0]="TextIndependentIdentification",i[i.TextDependentVerification=1]="TextDependentVerification",i[i.TextIndependentVerification=2]="TextIndependentVerification"})(pI=An.VoiceProfileType||(An.VoiceProfileType={}))});var Kd=p(Pi=>{"use strict";Object.defineProperty(Pi,"__esModule",{value:!0});Pi.ConnectionMessageImpl=Pi.ConnectionMessage=void 0;var aS=we(),cS=P(),uI=Bd(),dI=Oo(),Wd=class{};Pi.ConnectionMessage=Wd;var Hd=class{constructor(e){this.privConnectionMessage=e,this.privProperties=new uI.PropertyCollection,this.privConnectionMessage.headers[aS.HeaderNames.ConnectionId]&&this.privProperties.setProperty(dI.PropertyId.Speech_SessionId,this.privConnectionMessage.headers[aS.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===cS.MessageType.Text}get isBinaryMessage(){return this.privConnectionMessage.messageType===cS.MessageType.Binary}get TextMessage(){return this.privConnectionMessage.textBody}get binaryMessage(){return this.privConnectionMessage.binaryBody}get properties(){return this.privProperties}toString(){return""}};Pi.ConnectionMessageImpl=Hd});var Qd=p(jo=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});jo.Connection=void 0;var Jd=C(),Gd=P(),pS=Kd(),hI=w(),bn=f(),$d=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){Gd.marshalPromiseToCallbacks(this.privInternalData.connect(),e,t)}closeConnection(e,t){if(this.privInternalData instanceof Jd.SynthesisAdapterBase)throw new Error("Disconnecting a synthesizer's connection is currently not supported");Gd.marshalPromiseToCallbacks(this.privInternalData.disconnect(),e,t)}setMessageProperty(e,t,r){if(hI.Contracts.throwIfNullOrWhitespace(t,"propertyName"),this.privInternalData instanceof Jd.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 Jd.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){Gd.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 bn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionClosedEvent"?this.disconnected&&this.disconnected(new bn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionMessageSentEvent"?this.messageSent&&this.messageSent(new bn.ConnectionMessageEventArgs(new pS.ConnectionMessageImpl(e.message))):e.name==="ConnectionMessageReceivedEvent"&&this.messageReceived&&this.messageReceived(new bn.ConnectionMessageEventArgs(new pS.ConnectionMessageImpl(e.message)))}),this.privServiceEventListener=this.privInternalData.serviceEvents.attach(e=>{this.receivedServiceMessage&&this.receivedServiceMessage(new bn.ServiceEventArgs(e.jsonString,e.name))})}};jo.Connection=$d});var uS=p(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.TranslationRecognizer=void 0;var On=C(),Lo=P(),lI=Qd(),ct=w(),$=f(),Yd=class i extends $.Recognizer{constructor(e,t,r){let n=e;ct.Contracts.throwIfNull(n,"speechConfig"),super(t,n.properties,r||new On.TranslationConnectionFactory),this.privDisposedTranslationRecognizer=!1,this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)!==void 0&&ct.Contracts.throwIfNullOrWhitespace(this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationVoice),$.PropertyId[$.PropertyId.SpeechServiceConnection_TranslationVoice]),ct.Contracts.throwIfNullOrWhitespace(this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages),$.PropertyId[$.PropertyId.SpeechServiceConnection_TranslationToLanguages]),ct.Contracts.throwIfNullOrWhitespace(this.properties.getProperty($.PropertyId.SpeechServiceConnection_RecoLanguage),$.PropertyId[$.PropertyId.SpeechServiceConnection_RecoLanguage])}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get speechRecognitionLanguage(){return ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty($.PropertyId.SpeechServiceConnection_RecoLanguage)}get targetLanguages(){return ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",")}get voiceName(){return ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty($.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty($.PropertyId.SpeechServiceAuthorization_Token,e)}recognizeOnceAsync(e,t){ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),Lo.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(On.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){Lo.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(On.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){Lo.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}removeTargetLanguage(e){if(ct.Contracts.throwIfNullOrUndefined(e,"language to be removed"),this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0){let t=this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),r=t.indexOf(e);r>-1&&(t.splice(r,1),this.properties.setProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")),this.updateLanguages(t))}}addTargetLanguage(e){ct.Contracts.throwIfNullOrUndefined(e,"language to be added");let t=[];this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?(t=this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),t.includes(e)||(t.push(e),this.properties.setProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))):(this.properties.setProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,e),t=[e]),this.updateLanguages(t)}close(e,t){ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),Lo.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 On.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new On.TranslationServiceRecognizer(e,t,s,n,this)}updateLanguages(e){let t=lI.Connection.fromRecognizer(this);t&&(t.setMessageProperty("speech.context","translationcontext",{to:e}),t.sendMessageAsync("event",JSON.stringify({id:"translation",name:"updateLanguage",to:e})))}};Bo.TranslationRecognizer=Yd});var dS=p(Fo=>{"use strict";Object.defineProperty(Fo,"__esModule",{value:!0});Fo.Translations=void 0;var vI=f(),Xd=class{constructor(){this.privMap=new vI.PropertyCollection}get languages(){return this.privMap.keys}get(e,t){return this.privMap.getProperty(e,t)}set(e,t){this.privMap.setProperty(e,t)}};Fo.Translations=Xd});var hS=p(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.NoMatchReason=void 0;var fI;(function(i){i[i.NotRecognized=0]="NotRecognized",i[i.InitialSilenceTimeout=1]="InitialSilenceTimeout",i[i.InitialBabbleTimeout=2]="InitialBabbleTimeout"})(fI=Mn.NoMatchReason||(Mn.NoMatchReason={}))});var lS=p(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.NoMatchDetails=void 0;var Zd=C(),Vo=f(),eh=class i{constructor(e){this.privReason=e}static fromResult(e){let t=Zd.SimpleSpeechPhrase.fromJSON(e.json),r=Vo.NoMatchReason.NotRecognized;switch(t.RecognitionStatus){case Zd.RecognitionStatus.BabbleTimeout:r=Vo.NoMatchReason.InitialBabbleTimeout;break;case Zd.RecognitionStatus.InitialSilenceTimeout:r=Vo.NoMatchReason.InitialSilenceTimeout;break;default:r=Vo.NoMatchReason.NotRecognized;break}return new i(r)}get reason(){return this.privReason}};Uo.NoMatchDetails=eh});var vS=p(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.TranslationRecognitionCanceledEventArgs=void 0;var th=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}};Wo.TranslationRecognitionCanceledEventArgs=th});var fS=p(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});Ho.IntentRecognitionCanceledEventArgs=void 0;var gI=f(),rh=class extends gI.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}};Ho.IntentRecognitionCanceledEventArgs=rh});var nh=p(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.CancellationDetailsBase=void 0;var ih=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}};Ko.CancellationDetailsBase=ih});var gS=p(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.CancellationDetails=void 0;var Jo=C(),mI=nh(),Ri=f(),sh=class i extends mI.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=Ri.CancellationReason.Error,r=Ri.CancellationErrorCode.NoError;if(e instanceof Ri.RecognitionResult&&e.json){let n=Jo.SimpleSpeechPhrase.fromJSON(e.json);t=Jo.EnumTranslation.implTranslateCancelResult(n.RecognitionStatus)}return e.properties&&(r=Ri.CancellationErrorCode[e.properties.getProperty(Jo.CancellationErrorCodePropertyName,Ri.CancellationErrorCode[Ri.CancellationErrorCode.NoError])]),new i(t,e.errorDetails||Jo.EnumTranslation.implTranslateErrorDetails(r),r)}};Go.CancellationDetails=sh});var mS=p(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.CancellationErrorCode=void 0;var SI;(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"})(SI=Dn.CancellationErrorCode||(Dn.CancellationErrorCode={}))});var SS=p($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.ConnectionEventArgs=void 0;var yI=f(),oh=class extends yI.SessionEventArgs{};$o.ConnectionEventArgs=oh});var yS=p(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.ServiceEventArgs=void 0;var CI=f(),ah=class extends CI.SessionEventArgs{constructor(e,t,r){super(r),this.privJsonResult=e,this.privEventName=t}get jsonString(){return this.privJsonResult}get eventName(){return this.privEventName}};Qo.ServiceEventArgs=ah});var CS=p(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.PhraseListGrammar=void 0;var ch=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()}};Yo.PhraseListGrammar=ch});var Zo=p(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.DialogServiceConfigImpl=Ei.DialogServiceConfig=void 0;var PI=w(),kn=f(),Xo=class{constructor(){}set applicationId(e){}static get DialogTypes(){return{BotFramework:"bot_framework",CustomCommands:"custom_commands"}}};Ei.DialogServiceConfig=Xo;var ph=class extends Xo{constructor(){super(),this.privSpeechConfig=new kn.SpeechConfigImpl}get properties(){return this.privSpeechConfig.properties}get speechRecognitionLanguage(){return this.privSpeechConfig.speechRecognitionLanguage}set speechRecognitionLanguage(e){PI.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(kn.PropertyId.SpeechServiceConnection_ProxyHostName,e),this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyPort,`${t}`),r&&this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyUserName,r),n&&this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyPassword,n)}setServiceProperty(e,t,r){this.privSpeechConfig.setServiceProperty(e,t)}close(){}};Ei.DialogServiceConfigImpl=ph});var PS=p(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});ea.BotFrameworkConfig=void 0;var Br=w(),Ut=Zo(),xe=f(),uh=class extends Ut.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){Br.Contracts.throwIfNullOrWhitespace(e,"subscription"),Br.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Ut.DialogServiceConfigImpl;return n.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(xe.PropertyId.SpeechServiceConnection_Key,e),n.setProperty(xe.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(xe.PropertyId.Conversation_ApplicationId,r),n}static fromAuthorizationToken(e,t,r){Br.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),Br.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Ut.DialogServiceConfigImpl;return n.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(xe.PropertyId.SpeechServiceAuthorization_Token,e),n.setProperty(xe.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(xe.PropertyId.Conversation_ApplicationId,r),n}static fromHost(e,t,r){Br.Contracts.throwIfNullOrUndefined(e,"host");let n=e instanceof URL?e:new URL(`wss://${e}.convai.speech.azure.us`);Br.Contracts.throwIfNullOrUndefined(n,"resolvedHost");let s=new Ut.DialogServiceConfigImpl;return s.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),s.setProperty(xe.PropertyId.SpeechServiceConnection_Host,n.toString()),t!==void 0&&s.setProperty(xe.PropertyId.SpeechServiceConnection_Key,t),s}static fromEndpoint(e,t){Br.Contracts.throwIfNull(e,"endpoint");let r=new Ut.DialogServiceConfigImpl;return r.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),r.setProperty(xe.PropertyId.SpeechServiceConnection_Endpoint,e.toString()),t!==void 0&&r.setProperty(xe.PropertyId.SpeechServiceConnection_Key,t),r}};ea.BotFrameworkConfig=uh});var RS=p(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.CustomCommandsConfig=void 0;var Fr=w(),Nn=Zo(),Pt=f(),dh=class extends Nn.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){Fr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),Fr.Contracts.throwIfNullOrWhitespace(t,"subscription"),Fr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new Nn.DialogServiceConfigImpl;return n.setProperty(Pt.PropertyId.Conversation_DialogType,Nn.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(Pt.PropertyId.Conversation_ApplicationId,e),n.setProperty(Pt.PropertyId.SpeechServiceConnection_Key,t),n.setProperty(Pt.PropertyId.SpeechServiceConnection_Region,r),n}static fromAuthorizationToken(e,t,r){Fr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),Fr.Contracts.throwIfNullOrWhitespace(t,"authorizationToken"),Fr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new Nn.DialogServiceConfigImpl;return n.setProperty(Pt.PropertyId.Conversation_DialogType,Nn.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(Pt.PropertyId.Conversation_ApplicationId,e),n.setProperty(Pt.PropertyId.SpeechServiceAuthorization_Token,t),n.setProperty(Pt.PropertyId.SpeechServiceConnection_Region,r),n}set applicationId(e){Fr.Contracts.throwIfNullOrWhitespace(e,"value"),this.setProperty(Pt.PropertyId.Conversation_ApplicationId,e)}get applicationId(){return this.getProperty(Pt.PropertyId.Conversation_ApplicationId)}};ta.CustomCommandsConfig=dh});var Wt=p(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.QueryParameterNames=void 0;var H=class{};ra.QueryParameterNames=H;H.BotId="botid";H.CustomSpeechDeploymentId="cid";H.CustomVoiceDeploymentId="deploymentId";H.EnableAudioLogging="storeAudio";H.EnableLanguageId="lidEnabled";H.EnableWordLevelTimestamps="wordLevelTimestamps";H.EndSilenceTimeoutMs="endSilenceTimeoutMs";H.SegmentationSilenceTimeoutMs="segmentationSilenceTimeoutMs";H.Format="format";H.InitialSilenceTimeoutMs="initialSilenceTimeoutMs";H.Language="language";H.Profanity="profanity";H.RequestBotStatusMessages="enableBotMessageStatus";H.StableIntermediateThreshold="stableIntermediateThreshold";H.StableTranslation="stableTranslation";H.TestHooks="testhooks";H.Postprocessing="postprocessing";H.CtsMeetingId="meetingId";H.CtsDeviceId="deviceId";H.CtsIsParticipant="isParticipant";H.EnableAvatar="enableTalkingAvatar"});var $e=p(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.ConnectionFactoryBase=void 0;var RI=C(),pr=f(),ur=Wt(),hh=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([[pr.PropertyId.Speech_SegmentationSilenceTimeoutMs,ur.QueryParameterNames.SegmentationSilenceTimeoutMs],[pr.PropertyId.SpeechServiceConnection_EnableAudioLogging,ur.QueryParameterNames.EnableAudioLogging],[pr.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,ur.QueryParameterNames.EndSilenceTimeoutMs],[pr.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,ur.QueryParameterNames.InitialSilenceTimeoutMs],[pr.PropertyId.SpeechServiceResponse_PostProcessingOption,ur.QueryParameterNames.Postprocessing],[pr.PropertyId.SpeechServiceResponse_ProfanityOption,ur.QueryParameterNames.Profanity],[pr.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,ur.QueryParameterNames.EnableWordLevelTimestamps],[pr.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,ur.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(RI.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())}};ia.ConnectionFactoryBase=hh});var TS=p(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.DialogConnectionFactory=void 0;var ES=ae(),EI=C(),Be=f(),wS=$e(),wI=C(),IS=we(),na=Wt(),xn=class i extends wS.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Be.PropertyId.Conversation_ApplicationId,""),s=e.parameters.getProperty(Be.PropertyId.Conversation_DialogType),o=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_Region),a=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),c=e.parameters.getProperty(Be.PropertyId.Conversation_Request_Bot_Status_Messages,"true"),u={};u[IS.HeaderNames.ConnectionId]=r,u[na.QueryParameterNames.Format]=e.parameters.getProperty(EI.OutputFormatPropertyName,Be.OutputFormat[Be.OutputFormat.Simple]).toLowerCase(),u[na.QueryParameterNames.Language]=a,u[na.QueryParameterNames.RequestBotStatusMessages]=c,n&&(u[na.QueryParameterNames.BotId]=n,s===Be.DialogServiceConfig.DialogTypes.CustomCommands&&(u[IS.HeaderNames.CustomCommandsAppId]=n));let d=s===Be.DialogServiceConfig.DialogTypes.CustomCommands?"commands/":"",h=s===Be.DialogServiceConfig.DialogTypes.CustomCommands?"v1":s===Be.DialogServiceConfig.DialogTypes.BotFramework?"v3":"v0",l={};t.token!=null&&t.token!==""&&(l[t.headerName]=t.token);let g=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_Endpoint,"");if(!g){let M=wS.ConnectionFactoryBase.getHostSuffix(o),J=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_Host,`wss://${o}.${i.BaseUrl}${M}`);g=`${J.endsWith("/")?J:J+"/"}${d}${i.ApiKey}/${h}`}this.setCommonUrlParams(e,u,g);let _=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new ES.WebsocketConnection(g,u,l,new wI.WebsocketMessageFormatter,ES.ProxyInfo.fromRecognizerConfig(e),_,r)}};sa.DialogConnectionFactory=xn;xn.ApiKey="api";xn.BaseUrl="convai.speech"});var _S=p(aa=>{"use strict";Object.defineProperty(aa,"__esModule",{value:!0});aa.DialogServiceConnector=void 0;var II=TS(),lh=C(),wi=P(),oa=w(),TI=f(),dr=Oo(),vh=class extends TI.Recognizer{constructor(e,t){let r=e;oa.Contracts.throwIfNull(e,"dialogConfig"),super(t,r.properties,new II.DialogConnectionFactory),this.isTurnComplete=!0,this.privIsDisposed=!1,this.privProperties=r.properties.clone();let n=this.buildAgentConfig();this.privReco.agentConfig.set(n)}connect(e,t){wi.marshalPromiseToCallbacks(this.privReco.connect(),e,t)}disconnect(e,t){wi.marshalPromiseToCallbacks(this.privReco.disconnect(),e,t)}get authorizationToken(){return this.properties.getProperty(dr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){oa.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(dr.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get speechActivityTemplate(){return this.properties.getProperty(dr.PropertyId.Conversation_Speech_Activity_Template)}set speechActivityTemplate(e){this.properties.setProperty(dr.PropertyId.Conversation_Speech_Activity_Template,e)}listenOnceAsync(e,t){if(this.isTurnComplete){oa.Contracts.throwIfDisposed(this.privIsDisposed);let n=(async()=>{await this.privReco.connect(),await this.implRecognizerStop(),this.isTurnComplete=!1;let s=new wi.Deferred;await this.privReco.recognize(lh.RecognitionMode.Conversation,s.resolve,s.reject);let o=await s.promise;return await this.implRecognizerStop(),o})();n.catch(()=>{this.dispose(!0).catch(()=>{})}),wi.marshalPromiseToCallbacks(n.finally(()=>{this.isTurnComplete=!0}),e,t)}}sendActivityAsync(e,t,r){wi.marshalPromiseToCallbacks(this.privReco.sendMessage(e),t,r)}close(e,t){oa.Contracts.throwIfDisposed(this.privIsDisposed),wi.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 lh.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new lh.DialogServiceAdapter(e,t,s,n,this)}buildAgentConfig(){return{botInfo:{commType:this.properties.getProperty("Conversation_Communication_Type","Default"),commandsCulture:void 0,connectionId:this.properties.getProperty(dr.PropertyId.Conversation_Agent_Connection_Id),conversationId:this.properties.getProperty(dr.PropertyId.Conversation_Conversation_Id,void 0),fromId:this.properties.getProperty(dr.PropertyId.Conversation_From_Id,void 0),ttsAudioFormat:this.properties.getProperty(dr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)},version:.2}}};aa.DialogServiceConnector=vh});var AS=p(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.ActivityReceivedEventArgs=void 0;var fh=class{constructor(e,t){this.privActivity=e,this.privAudioStream=t}get activity(){return this.privActivity}get audioStream(){return this.privAudioStream}};ca.ActivityReceivedEventArgs=fh});var bS=p(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.TurnStatusResponsePayload=void 0;var gh=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}}};pa.TurnStatusResponsePayload=gh});var OS=p(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.TurnStatusReceivedEventArgs=void 0;var _I=bS(),mh=class{constructor(e){this.privTurnStatus=_I.TurnStatusResponsePayload.fromJSON(e)}get interactionId(){return this.privTurnStatus.interactionId}get conversationId(){return this.privTurnStatus.conversationId}get statusCode(){return this.privTurnStatus.statusCode}};ua.TurnStatusReceivedEventArgs=mh});var MS=p(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.ServicePropertyChannel=void 0;var AI;(function(i){i[i.UriQueryParameter=0]="UriQueryParameter"})(AI=qn.ServicePropertyChannel||(qn.ServicePropertyChannel={}))});var DS=p(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.ProfanityOption=void 0;var bI;(function(i){i[i.Masked=0]="Masked",i[i.Removed=1]="Removed",i[i.Raw=2]="Raw"})(bI=zn.ProfanityOption||(zn.ProfanityOption={}))});var kS=p(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.BaseAudioPlayer=void 0;var OI=ot(),MI=f(),DI=sr(),Sh=class{constructor(e){this.audioContext=null,this.gainNode=null,this.autoUpdateBufferTimer=0,e===void 0&&(e=MI.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=DI.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 OI.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)})}};da.BaseAudioPlayer=Sh});var NS=p(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.ConnectionMessageEventArgs=void 0;var yh=class{constructor(e){this.privConnectionMessage=e}get message(){return this.privConnectionMessage}toString(){return"Message: "+this.privConnectionMessage.toString()}};ha.ConnectionMessageEventArgs=yh});var xS=p(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.VoiceProfile=void 0;var Ch=class{constructor(e,t){this.privId=e,this.privProfileType=t}get profileId(){return this.privId}get profileType(){return this.privProfileType}};la.VoiceProfile=Ch});var zS=p(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.VoiceProfileEnrollmentCancellationDetails=Ii.VoiceProfileEnrollmentResult=void 0;var qS=C(),ve=f(),Ph=class i{constructor(e,t,r){this.privReason=e,this.privProperties=new ve.PropertyCollection,this.privReason!==ve.ResultReason.Canceled?t&&(this.privDetails=JSON.parse(t),this.privDetails.enrollmentStatus.toLowerCase()==="enrolling"&&(this.privReason=ve.ResultReason.EnrollingVoiceProfile)):(this.privErrorDetails=r,this.privProperties.setProperty(qS.CancellationErrorCodePropertyName,ve.CancellationErrorCode[ve.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"?ve.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ve.ResultReason.EnrolledVoiceProfile:ve.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"?ve.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ve.ResultReason.EnrolledVoiceProfile:ve.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}}};Ii.VoiceProfileEnrollmentResult=Ph;var Rh=class i extends ve.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=ve.CancellationReason.Error,r=ve.CancellationErrorCode.NoError;return e.properties&&(r=ve.CancellationErrorCode[e.properties.getProperty(qS.CancellationErrorCodePropertyName,ve.CancellationErrorCode[ve.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ii.VoiceProfileEnrollmentCancellationDetails=Rh});var LS=p(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});Ti.VoiceProfileCancellationDetails=Ti.VoiceProfileResult=void 0;var jS=C(),kI=w(),Rt=f(),Eh=class{constructor(e,t){this.privReason=e,this.privProperties=new Rt.PropertyCollection,e===Rt.ResultReason.Canceled&&(kI.Contracts.throwIfNullOrUndefined(t,"statusText"),this.privErrorDetails=t,this.privProperties.setProperty(jS.CancellationErrorCodePropertyName,Rt.CancellationErrorCode[Rt.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get properties(){return this.privProperties}get errorDetails(){return this.privErrorDetails}};Ti.VoiceProfileResult=Eh;var wh=class i extends Rt.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=Rt.CancellationReason.Error,r=Rt.CancellationErrorCode.NoError;return e.properties&&(r=Rt.CancellationErrorCode[e.properties.getProperty(jS.CancellationErrorCodePropertyName,Rt.CancellationErrorCode[Rt.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ti.VoiceProfileCancellationDetails=wh});var BS=p(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});va.VoiceProfilePhraseResult=void 0;var NI=w(),xI=f(),Ih=class extends xI.VoiceProfileResult{constructor(e,t,r,n){super(e,t),this.privPhrases=[],NI.Contracts.throwIfNullOrUndefined(n,"phrase array"),this.privType=r,n&&n[0]&&(this.privPhrases=n)}get phrases(){return this.privPhrases}get type(){return this.privType}};va.VoiceProfilePhraseResult=Ih});var FS=p(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.VoiceProfileClient=void 0;var Th=C(),qI=Cd(),fa=w(),Vr=f(),_h=class extends Vr.Recognizer{constructor(e){fa.Contracts.throwIfNullOrUndefined(e,"speechConfig");let t=e;fa.Contracts.throwIfNull(t,"speechConfig"),super(qI.AudioConfig.fromStreamInput(Vr.AudioInputStream.createPushStream()),t.properties,new Th.VoiceProfileConnectionFactory),this.privProperties=t.properties.clone(),this.privVoiceAdapter=this.privReco,this.privDisposedVoiceAdapter=!1}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Vr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){fa.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Vr.PropertyId.SpeechServiceAuthorization_Token,e)}async createProfileAsync(e,t){let r=await this.privVoiceAdapter.createProfile(e,t);return new Vr.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 fa.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 Th.VoiceServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedVoiceAdapter||(this.privDisposedVoiceAdapter=!0,e&&await super.dispose(e))}createRecognizerConfig(e){return new Th.RecognizerConfig(e,this.properties)}getResult(e,t){return new Vr.VoiceProfileResult(e.ok?t:Vr.ResultReason.Canceled,e.statusText)}};ga.VoiceProfileClient=_h});var VS=p(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.SpeakerRecognizer=void 0;var Ah=C(),Ur=w(),bh=f(),Oh=class extends bh.Recognizer{constructor(e,t){Ur.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;Ur.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new Ah.SpeakerRecognitionConnectionFactory),this.privAudioConfigImpl=t,Ur.Contracts.throwIfNull(this.privAudioConfigImpl,"audioConfig"),this.privDisposedSpeakerRecognizer=!1,this.privProperties=r.properties}get authorizationToken(){return this.properties.getProperty(bh.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Ur.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(bh.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}async recognizeOnceAsync(e){return Ur.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),this.recognizeSpeakerOnceAsyncImpl(e)}async close(){Ur.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.dispose(!0)}async recognizeSpeakerOnceAsyncImpl(e){Ur.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 Ah.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Ah.SpeakerServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedSpeakerRecognizer||e&&(this.privDisposedSpeakerRecognizer=!0,await super.dispose(e))}};ma.SpeakerRecognizer=Oh});var US=p(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.SpeakerIdentificationModel=void 0;var zI=w(),jI=f(),Mh=class i{constructor(e){if(this.privVoiceProfiles=[],this.privProfileIds=[],zI.Contracts.throwIfNullOrUndefined(e,"VoiceProfiles"),e.length===0)throw new Error("Empty Voice Profiles array");for(let t of e){if(t.profileType!==jI.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"}};Sa.SpeakerIdentificationModel=Mh});var HS=p(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.SpeakerVerificationModel=void 0;var LI=w(),WS=f(),Dh=class i{constructor(e){if(LI.Contracts.throwIfNullOrUndefined(e,"VoiceProfile"),e.profileType===WS.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===WS.VoiceProfileType.TextDependentVerification?"TextDependentVerification":"TextIndependentVerification"}};ya.SpeakerVerificationModel=Dh});var kh=p(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.LanguageIdMode=void 0;var BI;(function(i){i[i.AtStart=0]="AtStart",i[i.Continuous=1]="Continuous"})(BI=jn.LanguageIdMode||(jn.LanguageIdMode={}))});var JS=p(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.AutoDetectSourceLanguageConfig=void 0;var FI=C(),VI=w(),Et=f(),KS=kh(),Nh=class i{constructor(){this.privProperties=new Et.PropertyCollection,this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart"),this.privLanguageIdMode=KS.LanguageIdMode.AtStart}static fromOpenRange(){let e=new i;return e.properties.setProperty(Et.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,FI.AutoDetectSourceLanguagesOpenRangeOptionName),e}static fromLanguages(e){VI.Contracts.throwIfArrayEmptyOrWhitespace(e,"languages");let t=new i;return t.properties.setProperty(Et.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+Et.PropertyId.SpeechServiceConnection_EndpointId.toString();t.properties.setProperty(s,n.endpointId)}}),t.properties.setProperty(Et.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,r.join()),t}get properties(){return this.privProperties}set mode(e){e===KS.LanguageIdMode.Continuous?(this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_LanguageIdMode,"Continuous")):(this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"1"),this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart")),this.privLanguageIdMode=e}};Ca.AutoDetectSourceLanguageConfig=Nh});var $S=p(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.AutoDetectSourceLanguageResult=void 0;var GS=w(),xh=class i{constructor(e,t){GS.Contracts.throwIfNullOrUndefined(e,"language"),GS.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}};Pa.AutoDetectSourceLanguageResult=xh});var QS=p(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.SourceLanguageConfig=void 0;var UI=w(),qh=class i{constructor(e,t){UI.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}};Ra.SourceLanguageConfig=qh});var XS=p(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.SpeakerRecognitionCancellationDetails=Ht.SpeakerRecognitionResult=Ht.SpeakerRecognitionResultType=void 0;var YS=C(),qe=f(),Ea;(function(i){i[i.Verify=0]="Verify",i[i.Identify=1]="Identify"})(Ea=Ht.SpeakerRecognitionResultType||(Ht.SpeakerRecognitionResultType={}));var zh=class{constructor(e,t=qe.ResultReason.RecognizedSpeaker,r=qe.CancellationErrorCode.NoError,n=""){this.privProperties=new qe.PropertyCollection;let s=e.scenario==="TextIndependentIdentification"?Ea.Identify:Ea.Verify;this.privReason=t,this.privReason!==qe.ResultReason.Canceled?s===Ea.Identify?(this.privProfileId=e.identificationResult.identifiedProfile.profileId,this.privScore=e.identificationResult.identifiedProfile.score,this.privReason=qe.ResultReason.RecognizedSpeakers):(this.privScore=e.verificationResult.score,e.verificationResult.recognitionResult.toLowerCase()!=="accept"&&(this.privReason=qe.ResultReason.NoMatch),e.verificationResult.profileId!==void 0&&e.verificationResult.profileId!==""&&(this.privProfileId=e.verificationResult.profileId)):(this.privErrorDetails=n,this.privProperties.setProperty(YS.CancellationErrorCodePropertyName,qe.CancellationErrorCode[r])),this.privProperties.setProperty(qe.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}};Ht.SpeakerRecognitionResult=zh;var jh=class i extends qe.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=qe.CancellationReason.Error,r=qe.CancellationErrorCode.NoError;return e.properties&&(r=qe.CancellationErrorCode[e.properties.getProperty(YS.CancellationErrorCodePropertyName,qe.CancellationErrorCode[qe.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ht.SpeakerRecognitionCancellationDetails=jh});var Lh=p(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.ConversationImpl=_i.Conversation=void 0;var q=C(),Ln=P(),S=w(),x=f(),wa=class{constructor(){}static createConversationAsync(e,t,r,n){S.Contracts.throwIfNullOrUndefined(e,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),S.Contracts.throwIfNullOrUndefined(e.region,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),!e.subscriptionKey&&!e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceAuthorization_Token])&&S.Contracts.throwIfNullOrUndefined(e.subscriptionKey,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s,o,a;return typeof t=="string"?(s=new Bn(e,t),Ln.marshalPromiseToCallbacks((async()=>{})(),r,n)):(s=new Bn(e),o=t,a=r,s.createConversationAsync(()=>{o&&o()},c=>{a&&a(c)})),s}};_i.Conversation=wa;var Bn=class extends wa{constructor(e,t){if(super(),this.privErrors=q.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 q.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case q.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case q.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case q.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case q.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new x.ConversationParticipantsChangedEventArgs(x.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 x.ConversationParticipantsChangedEventArgs(x.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 x.ConversationParticipantsChangedEventArgs(x.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 x.ConversationParticipantsChangedEventArgs(x.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case q.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new x.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case q.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new x.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case q.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new x.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 x.ConversationParticipantsChangedEventArgs(x.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(x.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 x.PropertyCollection,this.privManager=new q.ConversationManager,e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(x.PropertyId[x.PropertyId.SpeechServiceConnection_RecoLanguage],q.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceConnection_RecoLanguage]),t)this.privConversationId=t;else{e.targetLanguages.length===0&&e.addTargetLanguage(this.privLanguage),e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceResponse_ProfanityOption])||e.setProfanity(x.ProfanityOption.Masked);let o=e.getProperty(x.PropertyId[x.PropertyId.ConversationTranslator_Name]);o==null&&(o="Host"),S.Contracts.throwIfNullOrTooLong(o,"nickname",50),S.Contracts.throwIfNullOrTooShort(o,"nickname",2),e.setProperty(x.PropertyId[x.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 q.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 q.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=q.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"),Ln.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){Ln.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){Ln.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"))Ln.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:q.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 x.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:q.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.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:q.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.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:q.ConversationTranslatorMessageTypes.instantMessage})}};_i.ConversationImpl=Bn});var ZS=p(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.ConversationCommon=void 0;var Bh=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)}};Ia.ConversationCommon=Bh});var ey=p(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.ConversationExpirationEventArgs=void 0;var WI=f(),Fh=class extends WI.SessionEventArgs{constructor(e,t){super(t),this.privExpirationTime=e}get expirationTime(){return this.privExpirationTime}};Ta.ConversationExpirationEventArgs=Fh});var ty=p(_a=>{"use strict";Object.defineProperty(_a,"__esModule",{value:!0});_a.ConversationParticipantsChangedEventArgs=void 0;var HI=f(),Vh=class extends HI.SessionEventArgs{constructor(e,t,r){super(r),this.privReason=e,this.privParticipant=t}get reason(){return this.privReason}get participants(){return this.privParticipant}};_a.ConversationParticipantsChangedEventArgs=Vh});var ry=p(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.ConversationTranslationCanceledEventArgs=void 0;var KI=mi(),Uh=class extends KI.CancellationEventArgsBase{};Aa.ConversationTranslationCanceledEventArgs=Uh});var iy=p(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.ConversationTranslationEventArgs=void 0;var JI=f(),Wh=class extends JI.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};ba.ConversationTranslationEventArgs=Wh});var ny=p(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});Oa.ConversationTranslationResult=void 0;var GI=zd(),Hh=class extends GI.TranslationRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(t,n,s,o,a,c,void 0,void 0,u,d,h),this.privId=e,this.privOrigLang=r}get participantId(){return this.privId}get originalLang(){return this.privOrigLang}};Oa.ConversationTranslationResult=Hh});var Jh=p(Ma=>{"use strict";Object.defineProperty(Ma,"__esModule",{value:!0});Ma.StringUtils=void 0;var Kh=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],d=c+1<e.length?e[c+1]:"";switch(u){case"{":d==="{"?(a("{"),c++):a=o;break;case"}":d==="}"?(a("}"),c++):(t.hasOwnProperty(n)&&(r+=t[n]),a=s,n="");break;default:a(u);break}}return r}};Ma.StringUtils=Kh});var ay=p(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.ConversationTranslatorConnectionFactory=void 0;var Gh=ae(),sy=Jh(),$I=w(),Da=f(),QI=we(),Qe=Wt(),oy=$e(),$h=C(),ka=class i extends oy.ConnectionFactoryBase{constructor(e){super(),$I.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(Da.PropertyId.SpeechServiceConnection_Region,""),a={hostSuffix:oy.ConnectionFactoryBase.getHostSuffix(o),path:i.CTS_VIRT_MIC_PATH,region:encodeURIComponent(o)};a[Qe.QueryParameterNames.Language]=encodeURIComponent(e.parameters.getProperty(Da.PropertyId.SpeechServiceConnection_RecoLanguage,"")),a[Qe.QueryParameterNames.CtsMeetingId]=encodeURIComponent(s.roomId),a[Qe.QueryParameterNames.CtsDeviceId]=encodeURIComponent(s.participantId),a[Qe.QueryParameterNames.CtsIsParticipant]=s.isHost?"":"&"+Qe.QueryParameterNames.CtsIsParticipant;let c="",u={},d={};if(n){c=e.parameters.getProperty(Da.PropertyId.SpeechServiceConnection_Endpoint),c||(c="wss://"+e.parameters.getProperty(Da.PropertyId.SpeechServiceConnection_Host,"transcribe.{region}.cts.speech{hostSuffix}")+"{path}"),c=sy.StringUtils.formatString(c,a);let l=new URL(c);l.searchParams.forEach((_,M)=>{u[M]=_}),new $h.TranscriberConnectionFactory().setQueryParams(u,e,c),u[Qe.QueryParameterNames.CtsMeetingId]=a[Qe.QueryParameterNames.CtsMeetingId],u[Qe.QueryParameterNames.CtsDeviceId]=a[Qe.QueryParameterNames.CtsDeviceId],s.isHost||(u[Qe.QueryParameterNames.CtsIsParticipant]=""),Qe.QueryParameterNames.Format in u||(u[Qe.QueryParameterNames.Format]="simple"),l.searchParams.forEach((_,M)=>{l.searchParams.set(M,u[M]),delete u[M]}),c=l.toString()}else{let l=new $h.TranslationConnectionFactory;c=l.getEndpointUrl(e,!0),c=sy.StringUtils.formatString(c,a),l.setQueryParams(u,e,c)}d[QI.HeaderNames.ConnectionId]=r,d[Gh.RestConfigBase.configParams.token]=s.token,t.token&&(d[t.headerName]=t.token);let h=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","").toUpperCase()==="TRUE";return new Gh.WebsocketConnection(c,u,d,new $h.WebsocketMessageFormatter,Gh.ProxyInfo.fromRecognizerConfig(e),h,r)}};Na.ConversationTranslatorConnectionFactory=ka;ka.CTS_VIRT_MIC_PATH="/speech/recognition/dynamicaudio"});var py=p(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.ConversationTranslator=Wr.SpeechState=void 0;var Fn=C(),YI=ay(),xa=P(),pt=w(),U=f(),XI=Lh(),cy=qa(),ut;(function(i){i[i.Inactive=0]="Inactive",i[i.Connecting=1]="Connecting",i[i.Connected=2]="Connected"})(ut=Wr.SpeechState||(Wr.SpeechState={}));var Qh=class extends U.TranslationRecognizer{constructor(e,t,r,n){super(e,t,new YI.ConversationTranslatorConnectionFactory(n)),this.privSpeechState=ut.Inactive,r&&(this.privTranslator=r,this.sessionStarted=()=>{this.privSpeechState=ut.Connected},this.sessionStopped=()=>{this.privSpeechState=ut.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!==ut.Inactive)try{await this.cancelSpeech()}catch{this.privSpeechState=ut.Inactive}})}get state(){return this.privSpeechState}set state(e){this.privSpeechState=e}set authentication(e){this.privReco.authentication=e}onConnection(){this.privSpeechState=ut.Connected}async onCancelSpeech(){this.privSpeechState=ut.Inactive,await this.cancelSpeech()}fireCancelEvent(e){try{if(this.privTranslator.canceled){let t=new cy.ConversationTranslationCanceledEventArgs(U.CancellationReason.Error,e,U.CancellationErrorCode.RuntimeError);this.privTranslator.canceled(this.privTranslator,t)}}catch{}}async cancelSpeech(){try{this.stopContinuousRecognitionAsync(),await this.privReco?.disconnect(),this.privSpeechState=ut.Inactive}catch{}}},Yh=class extends cy.ConversationCommon{constructor(e){super(e),this.privErrors=Fn.ConversationConnectionConfig.restErrors,this.privIsDisposed=!1,this.privIsSpeaking=!1,this.privPlaceholderKey="abcdefghijklmnopqrstuvwxyz012345",this.privPlaceholderRegion="westus",this.privProperties=new U.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===ut.Connected||this.privCTRecognizer.state===ut.Connecting||this.privConversation.isMutedByHost)}onToken(e){this.privCTRecognizer.authentication=e}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(Fn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(Fn.ServicePropertiesPropertyName,JSON.stringify(r))}joinConversationAsync(e,t,r,n,s){try{if(typeof e=="string"){pt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),pt.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=Fn.ConversationConnectionConfig.defaultLanguageCode),this.privSpeechTranslationConfig=U.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey,this.privPlaceholderRegion),this.privSpeechTranslationConfig.setProfanity(U.ProfanityOption.Masked),this.privSpeechTranslationConfig.addTargetLanguage(o),this.privSpeechTranslationConfig.setProperty(U.PropertyId[U.PropertyId.SpeechServiceConnection_RecoLanguage],o),this.privSpeechTranslationConfig.setProperty(U.PropertyId[U.PropertyId.ConversationTranslator_Name],t);let a=[U.PropertyId.SpeechServiceConnection_Host,U.PropertyId.ConversationTranslator_Host,U.PropertyId.SpeechServiceConnection_Endpoint,U.PropertyId.SpeechServiceConnection_ProxyHostName,U.PropertyId.SpeechServiceConnection_ProxyPassword,U.PropertyId.SpeechServiceConnection_ProxyPort,U.PropertyId.SpeechServiceConnection_ProxyUserName,"ConversationTranslator_MultiChannelAudio","ConversationTranslator_Region"];for(let u of a){let d=this.privProperties.getProperty(u);if(d){let h=typeof u=="string"?u:U.PropertyId[u];this.privSpeechTranslationConfig.setProperty(h,d)}}let c=JSON.parse(this.privProperties.getProperty(Fn.ServicePropertiesPropertyName,"{}"));for(let u of Object.keys(c))this.privSpeechTranslationConfig.setServiceProperty(u,c[u],U.ServicePropertyChannel.UriQueryParameter);this.privConversation=new XI.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)},d=>{this.handleError(d,s)})},u=>{this.handleError(u,s)})}else typeof e=="object"?(pt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),pt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privProperties.setProperty(U.PropertyId.ConversationTranslator_Name,t),this.privConversation=e,this.privConversation.conversationTranslator=this,this.privConversation.room.isHost=!0,pt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedConnect),pt.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){xa.marshalPromiseToCallbacks((async()=>{await this.cancelSpeech(),await this.privConversation.endConversationImplAsync(),await this.privConversation.deleteConversationImplAsync(),this.dispose()})(),e,t)}sendTextMessageAsync(e,t,r){try{pt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),pt.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}",e)),this.privConversation.sendTextMessageAsync(e,t,r)}catch(n){this.handleError(n,r)}}startTranscribingAsync(e,t){xa.marshalPromiseToCallbacks((async()=>{try{pt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),pt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privCTRecognizer===void 0&&await this.connectTranslatorRecognizer(),pt.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){xa.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){xa.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=U.AudioConfig.fromDefaultMicrophoneInput()),this.privSpeechTranslationConfig.getProperty(U.PropertyId[U.PropertyId.SpeechServiceConnection_Key])===this.privPlaceholderKey&&this.privSpeechTranslationConfig.setProperty(U.PropertyId[U.PropertyId.SpeechServiceConnection_Key],"");let e=()=>this.privConversation;this.privCTRecognizer=new Qh(this.privSpeechTranslationConfig,this.privAudioConfig,this,e)}catch(e){throw await this.cancelSpeech(),e}}startContinuousRecognition(){return new Promise((e,t)=>{this.privCTRecognizer.startContinuousRecognitionAsync(e,t)})}};Wr.ConversationTranslator=Yh});var uy=p(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.ConversationTranscriber=void 0;var Vn=C(),Xh=P(),Hr=w(),Oe=f(),Zh=class i extends Oe.Recognizer{constructor(e,t){let r=e;Hr.Contracts.throwIfNull(r,"speechConfig"),Hr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(Oe.PropertyId.SpeechServiceConnection_RecoLanguage),Oe.PropertyId[Oe.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Vn.ConversationTranscriberConnectionFactory),this.privProperties.setProperty(Oe.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 Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Oe.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(Oe.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Hr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Oe.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Oe.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Vn.OutputFormatPropertyName,Oe.OutputFormat[Oe.OutputFormat.Simple])===Oe.OutputFormat[Oe.OutputFormat.Simple]?Oe.OutputFormat.Simple:Oe.OutputFormat.Detailed}get properties(){return this.privProperties}startTranscribingAsync(e,t){Xh.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Vn.RecognitionMode.Conversation),e,t)}stopTranscribingAsync(e,t){Xh.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}close(e,t){Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),Xh.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 Vn.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return n.isSpeakerDiarizationEnabled=!0,new Vn.ConversationTranscriptionServiceRecognizer(e,t,s,n,this)}};za.ConversationTranscriber=Zh});var dy=p(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0});Ai.Participant=Ai.User=void 0;var ZI=f(),el=class{constructor(e){this.privUserId=e}get userId(){return this.privUserId}};Ai.User=el;var tl=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 ZI.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)}};Ai.Participant=tl});var hy=p(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.ParticipantChangedReason=void 0;var eT;(function(i){i[i.JoinedConversation=0]="JoinedConversation",i[i.LeftConversation=1]="LeftConversation",i[i.Updated=2]="Updated"})(eT=Un.ParticipantChangedReason||(Un.ParticipantChangedReason={}))});var ly=p(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.MeetingImpl=bi.Meeting=void 0;var j=C(),Wn=P(),y=w(),K=f(),ja=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(K.PropertyId[K.PropertyId.SpeechServiceAuthorization_Token])&&y.Contracts.throwIfNullOrUndefined(e.subscriptionKey,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s=new La(e,t);return Wn.marshalPromiseToCallbacks((async()=>{})(),r,n),s}};bi.Meeting=ja;var La=class extends ja{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 K.ConversationParticipantsChangedEventArgs(K.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 K.ConversationParticipantsChangedEventArgs(K.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 K.ConversationParticipantsChangedEventArgs(K.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 K.ConversationParticipantsChangedEventArgs(K.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 K.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new K.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new K.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 K.ConversationParticipantsChangedEventArgs(K.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(K.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 K.PropertyCollection,this.privManager=new j.ConversationManager,e.getProperty(K.PropertyId[K.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(K.PropertyId[K.PropertyId.SpeechServiceConnection_RecoLanguage],j.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(K.PropertyId[K.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"),Wn.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){Wn.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){Wn.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"))Wn.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 K.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})}};bi.MeetingImpl=La});var vy=p(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.MeetingTranscriptionCanceledEventArgs=void 0;var tT=mi(),rl=class extends tT.CancellationEventArgsBase{};Ba.MeetingTranscriptionCanceledEventArgs=rl});var fy=p(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});Fa.MeetingTranscriber=void 0;var rT=C(),il=P(),Hn=w(),Kn=f(),iT=qa(),nl=class{constructor(e){this.privAudioConfig=e,this.privProperties=new Kn.PropertyCollection,this.privRecognizer=void 0,this.privDisposedRecognizer=!1}get speechRecognitionLanguage(){return Hn.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Kn.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get internalData(){return this.privRecognizer.internalData}get connection(){return Kn.Connection.fromRecognizer(this.privRecognizer)}get authorizationToken(){return this.properties.getProperty(Kn.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Hn.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Kn.PropertyId.SpeechServiceAuthorization_Token,e)}joinMeetingAsync(e,t,r){let n=e;Hn.Contracts.throwIfNullOrUndefined(iT.MeetingImpl,"Meeting"),this.privRecognizer=new rT.TranscriberRecognizer(e.config,this.privAudioConfig),Hn.Contracts.throwIfNullOrUndefined(this.privRecognizer,"Recognizer"),this.privRecognizer.connectMeetingCallbacks(this),il.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(),il.marshalPromiseToCallbacks((async()=>{})(),e,t)}close(e,t){Hn.Contracts.throwIfDisposed(this.privDisposedRecognizer),il.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))}};Fa.MeetingTranscriber=nl});var gy=p(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.ConversationTranscriptionResult=void 0;var nT=f(),sl=class extends nT.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(e,t,r,n,s,o,a,u,d,h),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};Va.ConversationTranscriptionResult=sl});var qa=p(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});var my=Lh();Object.defineProperty(re,"Conversation",{enumerable:!0,get:function(){return my.Conversation}});Object.defineProperty(re,"ConversationImpl",{enumerable:!0,get:function(){return my.ConversationImpl}});var sT=ZS();Object.defineProperty(re,"ConversationCommon",{enumerable:!0,get:function(){return sT.ConversationCommon}});var oT=ey();Object.defineProperty(re,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return oT.ConversationExpirationEventArgs}});var aT=ty();Object.defineProperty(re,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return aT.ConversationParticipantsChangedEventArgs}});var cT=ry();Object.defineProperty(re,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return cT.ConversationTranslationCanceledEventArgs}});var pT=iy();Object.defineProperty(re,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return pT.ConversationTranslationEventArgs}});var uT=ny();Object.defineProperty(re,"ConversationTranslationResult",{enumerable:!0,get:function(){return uT.ConversationTranslationResult}});var dT=py();Object.defineProperty(re,"ConversationTranslator",{enumerable:!0,get:function(){return dT.ConversationTranslator}});var hT=uy();Object.defineProperty(re,"ConversationTranscriber",{enumerable:!0,get:function(){return hT.ConversationTranscriber}});var Sy=dy();Object.defineProperty(re,"Participant",{enumerable:!0,get:function(){return Sy.Participant}});Object.defineProperty(re,"User",{enumerable:!0,get:function(){return Sy.User}});var lT=hy();Object.defineProperty(re,"ParticipantChangedReason",{enumerable:!0,get:function(){return lT.ParticipantChangedReason}});var yy=ly();Object.defineProperty(re,"Meeting",{enumerable:!0,get:function(){return yy.Meeting}});Object.defineProperty(re,"MeetingImpl",{enumerable:!0,get:function(){return yy.MeetingImpl}});var vT=vy();Object.defineProperty(re,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return vT.MeetingTranscriptionCanceledEventArgs}});var fT=fy();Object.defineProperty(re,"MeetingTranscriber",{enumerable:!0,get:function(){return fT.MeetingTranscriber}});var gT=gy();Object.defineProperty(re,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return gT.ConversationTranscriptionResult}})});var Ua=p(Oi=>{"use strict";Object.defineProperty(Oi,"__esModule",{value:!0});Oi.SynthesisRequest=Oi.Synthesizer=void 0;var Kr=C(),mT=P(),Cy=w(),hr=f(),ol=class i{constructor(e){let t=e;Cy.Contracts.throwIfNull(t,"speechConfig"),this.privProperties=t.properties.clone(),this.privDisposed=!1,this.privSynthesizing=!1,this.synthesisRequestQueue=new mT.Queue}get authorizationToken(){return this.properties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Cy.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)===Kr.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 Kr.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 Kr.SpeechServiceConfig(new Kr.Context(new Kr.OS(e,t,r)))),s=this.privProperties.getProperty(hr.PropertyId.SpeechServiceConnection_Key,void 0),o=s&&s!==""?new Kr.CognitiveSubscriptionKeyAuthentication(s):new Kr.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}};Oi.Synthesizer=ol;var al=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}};Oi.SynthesisRequest=al});var Ry=p(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.SpeechSynthesizer=void 0;var cl=C(),pl=P(),ST=gd(),yT=li(),CT=Dr(),Py=w(),lr=f(),PT=Ua(),ul=class i extends lr.Synthesizer{constructor(e,t){super(e),t!==null&&(t===void 0?this.audioConfig=typeof window>"u"?void 0:lr.AudioConfig.fromDefaultSpeakerOutput():this.audioConfig=t),this.privConnectionFactory=new cl.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){Py.Contracts.throwIfDisposed(this.privDisposed),pl.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privAdapter}createSynthesisAdapter(e,t,r){return new cl.SpeechSynthesisAdapter(e,t,r,this,this.audioConfig)}createRestSynthesisAdapter(e,t){return new cl.SynthesisRestAdapter(t,e)}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=yT.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(lr.SpeechSynthesisOutputFormat[this.properties.getProperty(lr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)])}speakImpl(e,t,r,n,s){try{Py.Contracts.throwIfDisposed(this.privDisposed);let o=pl.createNoDashGuid(),a;s instanceof lr.PushAudioOutputStreamCallback?a=new CT.PushAudioOutputStreamImpl(s):s instanceof lr.PullAudioOutputStream?a=s:s!==void 0?a=new ST.AudioFileWriter(s):a=void 0,this.synthesisRequestQueue.enqueue(new PT.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=pl.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 lr.SynthesisVoicesResult(t,n,void 0)}else return new lr.SynthesisVoicesResult(t,void 0,`Error: ${r.status}: ${r.statusText}`)}};Wa.SpeechSynthesizer=ul});var Ey=p(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.SynthesisResult=void 0;var dl=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}};Ha.SynthesisResult=dl});var wy=p(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.SpeechSynthesisResult=void 0;var RT=f(),hl=class extends RT.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}};Ka.SpeechSynthesisResult=hl});var Iy=p(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.SpeechSynthesisEventArgs=void 0;var ll=class{constructor(e){this.privResult=e}get result(){return this.privResult}};Ja.SpeechSynthesisEventArgs=ll});var Ty=p(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.SpeechSynthesisWordBoundaryEventArgs=void 0;var vl=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}};Ga.SpeechSynthesisWordBoundaryEventArgs=vl});var _y=p($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.SpeechSynthesisBookmarkEventArgs=void 0;var fl=class{constructor(e,t){this.privAudioOffset=e,this.privText=t}get audioOffset(){return this.privAudioOffset}get text(){return this.privText}};$a.SpeechSynthesisBookmarkEventArgs=fl});var Ay=p(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.SpeechSynthesisVisemeEventArgs=void 0;var gl=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}};Qa.SpeechSynthesisVisemeEventArgs=gl});var by=p(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.SpeechSynthesisBoundaryType=void 0;var ET;(function(i){i.Word="WordBoundary",i.Punctuation="PunctuationBoundary",i.Sentence="SentenceBoundary"})(ET=Jn.SpeechSynthesisBoundaryType||(Jn.SpeechSynthesisBoundaryType={}))});var Oy=p(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.SynthesisVoicesResult=void 0;var Mi=f(),ml=class extends Mi.SynthesisResult{constructor(e,t,r){if(Array.isArray(t)){super(e,Mi.ResultReason.VoicesListRetrieved,void 0,new Mi.PropertyCollection),this.privVoices=[];for(let n of t)this.privVoices.push(new Mi.VoiceInfo(n))}else super(e,Mi.ResultReason.Canceled,r||"Error information unavailable",new Mi.PropertyCollection)}get voices(){return this.privVoices}};Ya.SynthesisVoicesResult=ml});var My=p(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.VoiceInfo=wt.SynthesisVoiceType=wt.SynthesisVoiceGender=void 0;var dt;(function(i){i[i.Unknown=0]="Unknown",i[i.Female=1]="Female",i[i.Male=2]="Male",i[i.Neutral=3]="Neutral"})(dt=wt.SynthesisVoiceGender||(wt.SynthesisVoiceGender={}));var Sl;(function(i){i[i.OnlineNeural=1]="OnlineNeural",i[i.OnlineStandard=2]="OnlineStandard",i[i.OfflineNeural=3]="OfflineNeural",i[i.OfflineStandard=4]="OfflineStandard"})(Sl=wt.SynthesisVoiceType||(wt.SynthesisVoiceType={}));var wT={[dt[dt.Neutral]]:dt.Neutral,[dt[dt.Male]]:dt.Male,[dt[dt.Female]]:dt.Female},yl=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")?Sl.OnlineStandard:Sl.OnlineNeural,this.privGender=wT[e.Gender]||dt.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}};wt.VoiceInfo=yl});var ky=p(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.SpeakerAudioDestination=void 0;var Jr=P(),IT=Dr(),Ye=sr(),TT=60*30,Dy={[Ye.AudioFormatTag.PCM]:"audio/wav",[Ye.AudioFormatTag.MuLaw]:"audio/x-wav",[Ye.AudioFormatTag.MP3]:"audio/mpeg",[Ye.AudioFormatTag.OGG_OPUS]:"audio/ogg",[Ye.AudioFormatTag.WEBM_OPUS]:"audio/webm; codecs=opus",[Ye.AudioFormatTag.ALaw]:"audio/x-wav",[Ye.AudioFormatTag.FLAC]:"audio/flac"},Cl=class{constructor(e){this.privPlaybackStarted=!1,this.privAppendingToBuffer=!1,this.privMediaSourceOpened=!1,this.privBytesReceived=0,this.privId=e||Jr.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===Ye.AudioFormatTag.PCM||this.privFormat.formatTag===Ye.AudioFormatTag.MuLaw||this.privFormat.formatTag===Ye.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:Dy[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=Dy[this.privFormat.formatTag];t===void 0?console.warn(`Unknown mimeType for format ${Ye.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=TT,this.privSourceBuffer=this.privMediaSource.addSourceBuffer(t),this.privSourceBuffer.onupdate=()=>{this.updateSourceBuffer().catch(r=>{Jr.Events.instance.onEvent(new Jr.BackgroundEvent(r))})},this.privSourceBuffer.onupdateend=()=>{this.handleSourceBufferUpdateEnd().catch(r=>{Jr.Events.instance.onEvent(new Jr.BackgroundEvent(r))})},this.privSourceBuffer.onupdatestart=()=>{this.privAppendingToBuffer=!1}},this.updateSourceBuffer().catch(r=>{Jr.Events.instance.onEvent(new Jr.BackgroundEvent(r))})):(console.warn(`Format ${Ye.AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`),this.privAudioOutputStream=new IT.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}};Xa.SpeakerAudioDestination=Cl});var Ny=p(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});Za.ConversationTranscriptionCanceledEventArgs=void 0;var _T=mi(),Pl=class extends _T.CancellationEventArgsBase{};Za.ConversationTranscriptionCanceledEventArgs=Pl});var xy=p(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.MeetingTranscriptionCanceledEventArgs=void 0;var AT=mi(),Rl=class extends AT.CancellationEventArgsBase{};ec.MeetingTranscriptionCanceledEventArgs=Rl});var qy=p(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.PronunciationAssessmentGradingSystem=void 0;var bT;(function(i){i[i.FivePoint=1]="FivePoint",i[i.HundredMark=2]="HundredMark"})(bT=Gn.PronunciationAssessmentGradingSystem||(Gn.PronunciationAssessmentGradingSystem={}))});var zy=p($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.PronunciationAssessmentGranularity=void 0;var OT;(function(i){i[i.Phoneme=1]="Phoneme",i[i.Word=2]="Word",i[i.FullText=3]="FullText"})(OT=$n.PronunciationAssessmentGranularity||($n.PronunciationAssessmentGranularity={}))});var jy=p(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.PronunciationAssessmentConfig=void 0;var tc=w(),Q=f(),El=class i{constructor(e,t=Q.PronunciationAssessmentGradingSystem.FivePoint,r=Q.PronunciationAssessmentGranularity.Phoneme,n=!1){tc.Contracts.throwIfNullOrUndefined(e,"referenceText"),this.privProperties=new Q.PropertyCollection,this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_ReferenceText,e),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_GradingSystem,Q.PronunciationAssessmentGradingSystem[t]),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_Granularity,Q.PronunciationAssessmentGranularity[r]),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_EnableMiscue,String(n))}static fromJSON(e){tc.Contracts.throwIfNullOrUndefined(e,"json");let t=new i("");return t.privProperties=new Q.PropertyCollection,t.properties.setProperty(Q.PropertyId.PronunciationAssessment_Json,e),t}toJSON(){return this.updateJson(),this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_Params)}applyTo(e){this.updateJson();let t=e.internalData;t.expectContentAssessmentResponse=!!this.privContentAssessmentTopic,t.speechContext.setPronunciationAssessmentParams(this.properties.getProperty(Q.PropertyId.PronunciationAssessment_Params),this.privContentAssessmentTopic,t.isSpeakerDiarizationEnabled)}get referenceText(){return this.properties.getProperty(Q.PropertyId.PronunciationAssessment_ReferenceText)}set referenceText(e){tc.Contracts.throwIfNullOrWhitespace(e,"referenceText"),this.properties.setProperty(Q.PropertyId.PronunciationAssessment_ReferenceText,e)}set phonemeAlphabet(e){tc.Contracts.throwIfNullOrWhitespace(e,"phonemeAlphabet"),this.privPhonemeAlphabet=e}set enableMiscue(e){let t=e?"true":"false";this.properties.setProperty(Q.PropertyId.PronunciationAssessment_EnableMiscue,t)}get enableMiscue(){return this.properties.getProperty(Q.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(Q.PropertyId.PronunciationAssessment_Json,"{}"),t=JSON.parse(e),r=this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_ReferenceText);r&&(t.referenceText=r);let n=this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_GradingSystem);n&&(t.gradingSystem=n);let s=this.privProperties.getProperty(Q.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(Q.PropertyId.PronunciationAssessment_EnableMiscue)&&(t.enableMiscue=this.enableMiscue),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_Params,JSON.stringify(t))}};rc.PronunciationAssessmentConfig=El});var Ly=p(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.PronunciationAssessmentResult=Di.ContentAssessmentResult=void 0;var wl=w(),MT=f(),ic=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}};Di.ContentAssessmentResult=ic;var Il=class i{constructor(e){let t=JSON.parse(e);wl.Contracts.throwIfNullOrUndefined(t.NBest[0],"NBest"),this.privPronJson=t.NBest[0]}static fromResult(e){wl.Contracts.throwIfNullOrUndefined(e,"result");let t=e.properties.getProperty(MT.PropertyId.SpeechServiceResponse_JsonResult);return wl.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 ic(this.detailResult)}};Di.PronunciationAssessmentResult=Il});var By=p(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.AvatarConfig=void 0;var DT=w(),kT=f(),Tl=class{constructor(e,t,r){this.privCustomized=!1,DT.Contracts.throwIfNullOrWhitespace(e,"character"),this.character=e,this.style=t,r===void 0&&(r=new kT.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}};nc.AvatarConfig=Tl});var Fy=p(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.AvatarEventArgs=Gr.AvatarEventTypes=void 0;var NT;(function(i){i.SwitchedToSpeaking="SwitchedToSpeaking",i.SwitchedToIdle="SwitchedToIdle",i.SessionClosed="SessionClosed"})(NT=Gr.AvatarEventTypes||(Gr.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}};Gr.AvatarEventArgs=_l});var bl=p(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.SpeechSynthesisConnectionFactory=void 0;var Vy=ae(),Qn=f(),xT=$e(),qT=C(),zT=we(),sc=Wt(),Al=class{constructor(){this.synthesisUri="/cognitiveservices/websocket/v1"}create(e,t,r){let n=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_Region,void 0),o=xT.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_EndpointId,void 0),c=a===void 0?"tts":"voice",u=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_Host,"wss://"+s+"."+c+".speech"+o),d={},h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[zT.HeaderNames.ConnectionId]=r,a!==void 0&&a!==""&&(!n||n.search(sc.QueryParameterNames.CustomVoiceDeploymentId)===-1)&&(d[sc.QueryParameterNames.CustomVoiceDeploymentId]=a),e.avatarEnabled&&(!n||n.search(sc.QueryParameterNames.EnableAvatar)===-1)&&(d[sc.QueryParameterNames.EnableAvatar]="true"),n||(n=u+this.synthesisUri),e.parameters.setProperty(Qn.PropertyId.SpeechServiceConnection_Url,n);let l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new Vy.WebsocketConnection(n,d,h,new qT.WebsocketMessageFormatter,Vy.ProxyInfo.fromParameters(e.parameters),l,r)}};oc.SpeechSynthesisConnectionFactory=Al});var Uy=p(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});cc.AvatarSynthesizer=void 0;var jT=bl(),LT=C(),X=P(),BT=li(),Kt=f(),ac=w(),FT=Ua(),Ol=class extends Kt.Synthesizer{constructor(e,t){super(e),ac.Contracts.throwIfNullOrUndefined(t,"avatarConfig"),this.privConnectionFactory=new jT.SpeechSynthesisConnectionFactory,this.privAvatarConfig=t,this.implCommonSynthesizeSetup()}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=BT.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(Kt.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm)}async startAvatarAsync(e){ac.Contracts.throwIfNullOrUndefined(e,"peerConnection"),this.privIceServers=e.getConfiguration().iceServers,ac.Contracts.throwIfNullOrUndefined(this.privIceServers,"Ice servers must be set.");let t=new X.Deferred;e.onicegatheringstatechange=()=>{X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering state: "+e.iceGatheringState,X.EventType.Debug)),e.iceGatheringState==="complete"&&(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering complete.",X.EventType.Info)),t.resolve())},e.onicecandidate=a=>{a.candidate?X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice candidate: "+a.candidate.candidate,X.EventType.Debug)):(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice candidate: complete",X.EventType.Debug)),t.resolve())},setTimeout(()=>{e.iceGatheringState!=="complete"&&(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering timeout.",X.EventType.Warning)),t.resolve())},2e3);let r=await e.createOffer();await e.setLocalDescription(r),await t.promise,X.Events.instance.onEvent(new X.PlatformEvent("peer connection: got local SDP.",X.EventType.Info)),this.privProperties.setProperty(Kt.PropertyId.TalkingAvatarService_WebRTC_SDP,JSON.stringify(e.localDescription));let n=await this.speak("",!1);if(n.reason!==Kt.ResultReason.SynthesizingAudioCompleted)return new Kt.SynthesisResult(n.resultId,n.reason,n.errorDetails,n.properties);let s=atob(n.properties.getProperty(Kt.PropertyId.TalkingAvatarService_WebRTC_SDP)),o=new RTCSessionDescription(JSON.parse(s));return await e.setRemoteDescription(o),new Kt.SynthesisResult(n.resultId,n.reason,void 0,n.properties)}async speakTextAsync(e){let t=await this.speak(e,!1);return new Kt.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async speakSsmlAsync(e){let t=await this.speak(e,!0);return new Kt.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 ac.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 LT.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=X.createNoDashGuid(),n=new X.Deferred;return this.synthesisRequestQueue.enqueue(new FT.SynthesisRequest(r,e,t,s=>{n.resolve(s),this.privSynthesizing=!1,this.adapterSpeak()},s=>{n.reject(s),this.privSynthesizing=!1})),this.adapterSpeak(),n.promise}};cc.AvatarSynthesizer=Ol});var Wy=p(ki=>{"use strict";Object.defineProperty(ki,"__esModule",{value:!0});ki.AvatarVideoFormat=ki.Coordinate=void 0;var Ml=class{constructor(e,t){this.x=e,this.y=t}};ki.Coordinate=Ml;var Dl=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}}};ki.AvatarVideoFormat=Dl});var Hy=p(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});pc.AvatarWebRTCConnectionResult=void 0;var VT=f(),kl=class extends VT.SynthesisResult{constructor(e,t,r,n,s){super(t,r,n,s),this.privSDPAnswer=e}get SDPAnswer(){return this.privSDPAnswer}};pc.AvatarWebRTCConnectionResult=kl});var Ky=p(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});dc.Diagnostics=void 0;var UT=ae(),WT=P(),uc=class{static SetLoggingLevel(e){this.privListener=new UT.ConsoleLoggingListener(e),WT.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)}};dc.Diagnostics=uc;uc.privListener=void 0});var f=p(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});var HT=Cd();Object.defineProperty(v,"AudioConfig",{enumerable:!0,get:function(){return HT.AudioConfig}});var Jy=sr();Object.defineProperty(v,"AudioStreamFormat",{enumerable:!0,get:function(){return Jy.AudioStreamFormat}});Object.defineProperty(v,"AudioFormatTag",{enumerable:!0,get:function(){return Jy.AudioFormatTag}});var Nl=md();Object.defineProperty(v,"AudioInputStream",{enumerable:!0,get:function(){return Nl.AudioInputStream}});Object.defineProperty(v,"PullAudioInputStream",{enumerable:!0,get:function(){return Nl.PullAudioInputStream}});Object.defineProperty(v,"PushAudioInputStream",{enumerable:!0,get:function(){return Nl.PushAudioInputStream}});var xl=Dr();Object.defineProperty(v,"AudioOutputStream",{enumerable:!0,get:function(){return xl.AudioOutputStream}});Object.defineProperty(v,"PullAudioOutputStream",{enumerable:!0,get:function(){return xl.PullAudioOutputStream}});Object.defineProperty(v,"PushAudioOutputStream",{enumerable:!0,get:function(){return xl.PushAudioOutputStream}});var KT=km();Object.defineProperty(v,"CancellationReason",{enumerable:!0,get:function(){return KT.CancellationReason}});var JT=Nm();Object.defineProperty(v,"PullAudioInputStreamCallback",{enumerable:!0,get:function(){return JT.PullAudioInputStreamCallback}});var GT=xm();Object.defineProperty(v,"PushAudioOutputStreamCallback",{enumerable:!0,get:function(){return GT.PushAudioOutputStreamCallback}});var $T=zm();Object.defineProperty(v,"KeywordRecognitionModel",{enumerable:!0,get:function(){return $T.KeywordRecognitionModel}});var QT=jm();Object.defineProperty(v,"SessionEventArgs",{enumerable:!0,get:function(){return QT.SessionEventArgs}});var YT=Lm();Object.defineProperty(v,"RecognitionEventArgs",{enumerable:!0,get:function(){return YT.RecognitionEventArgs}});var XT=Bm();Object.defineProperty(v,"OutputFormat",{enumerable:!0,get:function(){return XT.OutputFormat}});var ZT=Fm();Object.defineProperty(v,"IntentRecognitionEventArgs",{enumerable:!0,get:function(){return ZT.IntentRecognitionEventArgs}});var e_=Vm();Object.defineProperty(v,"RecognitionResult",{enumerable:!0,get:function(){return e_.RecognitionResult}});var t_=Um();Object.defineProperty(v,"SpeechRecognitionResult",{enumerable:!0,get:function(){return t_.SpeechRecognitionResult}});var r_=Wm();Object.defineProperty(v,"IntentRecognitionResult",{enumerable:!0,get:function(){return r_.IntentRecognitionResult}});var i_=Hm();Object.defineProperty(v,"LanguageUnderstandingModel",{enumerable:!0,get:function(){return i_.LanguageUnderstandingModel}});var ql=Jm();Object.defineProperty(v,"SpeechRecognitionEventArgs",{enumerable:!0,get:function(){return ql.SpeechRecognitionEventArgs}});Object.defineProperty(v,"ConversationTranscriptionEventArgs",{enumerable:!0,get:function(){return ql.ConversationTranscriptionEventArgs}});Object.defineProperty(v,"MeetingTranscriptionEventArgs",{enumerable:!0,get:function(){return ql.MeetingTranscriptionEventArgs}});var n_=Gm();Object.defineProperty(v,"SpeechRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return n_.SpeechRecognitionCanceledEventArgs}});var s_=$m();Object.defineProperty(v,"TranslationRecognitionEventArgs",{enumerable:!0,get:function(){return s_.TranslationRecognitionEventArgs}});var o_=Qm();Object.defineProperty(v,"TranslationSynthesisEventArgs",{enumerable:!0,get:function(){return o_.TranslationSynthesisEventArgs}});var a_=zd();Object.defineProperty(v,"TranslationRecognitionResult",{enumerable:!0,get:function(){return a_.TranslationRecognitionResult}});var c_=Ym();Object.defineProperty(v,"TranslationSynthesisResult",{enumerable:!0,get:function(){return c_.TranslationSynthesisResult}});var p_=Xm();Object.defineProperty(v,"ResultReason",{enumerable:!0,get:function(){return p_.ResultReason}});var Gy=Zm();Object.defineProperty(v,"SpeechConfig",{enumerable:!0,get:function(){return Gy.SpeechConfig}});Object.defineProperty(v,"SpeechConfigImpl",{enumerable:!0,get:function(){return Gy.SpeechConfigImpl}});var $y=eS();Object.defineProperty(v,"SpeechTranslationConfig",{enumerable:!0,get:function(){return $y.SpeechTranslationConfig}});Object.defineProperty(v,"SpeechTranslationConfigImpl",{enumerable:!0,get:function(){return $y.SpeechTranslationConfigImpl}});var u_=Bd();Object.defineProperty(v,"PropertyCollection",{enumerable:!0,get:function(){return u_.PropertyCollection}});var d_=Oo();Object.defineProperty(v,"PropertyId",{enumerable:!0,get:function(){return d_.PropertyId}});var h_=iS();Object.defineProperty(v,"Recognizer",{enumerable:!0,get:function(){return h_.Recognizer}});var l_=nS();Object.defineProperty(v,"SpeechRecognizer",{enumerable:!0,get:function(){return l_.SpeechRecognizer}});var v_=sS();Object.defineProperty(v,"IntentRecognizer",{enumerable:!0,get:function(){return v_.IntentRecognizer}});var f_=oS();Object.defineProperty(v,"VoiceProfileType",{enumerable:!0,get:function(){return f_.VoiceProfileType}});var g_=uS();Object.defineProperty(v,"TranslationRecognizer",{enumerable:!0,get:function(){return g_.TranslationRecognizer}});var m_=dS();Object.defineProperty(v,"Translations",{enumerable:!0,get:function(){return m_.Translations}});var S_=hS();Object.defineProperty(v,"NoMatchReason",{enumerable:!0,get:function(){return S_.NoMatchReason}});var y_=lS();Object.defineProperty(v,"NoMatchDetails",{enumerable:!0,get:function(){return y_.NoMatchDetails}});var C_=vS();Object.defineProperty(v,"TranslationRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return C_.TranslationRecognitionCanceledEventArgs}});var P_=fS();Object.defineProperty(v,"IntentRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return P_.IntentRecognitionCanceledEventArgs}});var R_=nh();Object.defineProperty(v,"CancellationDetailsBase",{enumerable:!0,get:function(){return R_.CancellationDetailsBase}});var E_=gS();Object.defineProperty(v,"CancellationDetails",{enumerable:!0,get:function(){return E_.CancellationDetails}});var w_=mS();Object.defineProperty(v,"CancellationErrorCode",{enumerable:!0,get:function(){return w_.CancellationErrorCode}});var I_=SS();Object.defineProperty(v,"ConnectionEventArgs",{enumerable:!0,get:function(){return I_.ConnectionEventArgs}});var T_=yS();Object.defineProperty(v,"ServiceEventArgs",{enumerable:!0,get:function(){return T_.ServiceEventArgs}});var __=Qd();Object.defineProperty(v,"Connection",{enumerable:!0,get:function(){return __.Connection}});var A_=CS();Object.defineProperty(v,"PhraseListGrammar",{enumerable:!0,get:function(){return A_.PhraseListGrammar}});var b_=Zo();Object.defineProperty(v,"DialogServiceConfig",{enumerable:!0,get:function(){return b_.DialogServiceConfig}});var O_=PS();Object.defineProperty(v,"BotFrameworkConfig",{enumerable:!0,get:function(){return O_.BotFrameworkConfig}});var M_=RS();Object.defineProperty(v,"CustomCommandsConfig",{enumerable:!0,get:function(){return M_.CustomCommandsConfig}});var D_=_S();Object.defineProperty(v,"DialogServiceConnector",{enumerable:!0,get:function(){return D_.DialogServiceConnector}});var k_=AS();Object.defineProperty(v,"ActivityReceivedEventArgs",{enumerable:!0,get:function(){return k_.ActivityReceivedEventArgs}});var N_=OS();Object.defineProperty(v,"TurnStatusReceivedEventArgs",{enumerable:!0,get:function(){return N_.TurnStatusReceivedEventArgs}});var x_=MS();Object.defineProperty(v,"ServicePropertyChannel",{enumerable:!0,get:function(){return x_.ServicePropertyChannel}});var q_=DS();Object.defineProperty(v,"ProfanityOption",{enumerable:!0,get:function(){return q_.ProfanityOption}});var z_=kS();Object.defineProperty(v,"BaseAudioPlayer",{enumerable:!0,get:function(){return z_.BaseAudioPlayer}});var j_=NS();Object.defineProperty(v,"ConnectionMessageEventArgs",{enumerable:!0,get:function(){return j_.ConnectionMessageEventArgs}});var L_=Kd();Object.defineProperty(v,"ConnectionMessage",{enumerable:!0,get:function(){return L_.ConnectionMessage}});var B_=xS();Object.defineProperty(v,"VoiceProfile",{enumerable:!0,get:function(){return B_.VoiceProfile}});var Qy=zS();Object.defineProperty(v,"VoiceProfileEnrollmentResult",{enumerable:!0,get:function(){return Qy.VoiceProfileEnrollmentResult}});Object.defineProperty(v,"VoiceProfileEnrollmentCancellationDetails",{enumerable:!0,get:function(){return Qy.VoiceProfileEnrollmentCancellationDetails}});var Yy=LS();Object.defineProperty(v,"VoiceProfileResult",{enumerable:!0,get:function(){return Yy.VoiceProfileResult}});Object.defineProperty(v,"VoiceProfileCancellationDetails",{enumerable:!0,get:function(){return Yy.VoiceProfileCancellationDetails}});var F_=BS();Object.defineProperty(v,"VoiceProfilePhraseResult",{enumerable:!0,get:function(){return F_.VoiceProfilePhraseResult}});var V_=FS();Object.defineProperty(v,"VoiceProfileClient",{enumerable:!0,get:function(){return V_.VoiceProfileClient}});var U_=VS();Object.defineProperty(v,"SpeakerRecognizer",{enumerable:!0,get:function(){return U_.SpeakerRecognizer}});var W_=US();Object.defineProperty(v,"SpeakerIdentificationModel",{enumerable:!0,get:function(){return W_.SpeakerIdentificationModel}});var H_=HS();Object.defineProperty(v,"SpeakerVerificationModel",{enumerable:!0,get:function(){return H_.SpeakerVerificationModel}});var K_=JS();Object.defineProperty(v,"AutoDetectSourceLanguageConfig",{enumerable:!0,get:function(){return K_.AutoDetectSourceLanguageConfig}});var J_=$S();Object.defineProperty(v,"AutoDetectSourceLanguageResult",{enumerable:!0,get:function(){return J_.AutoDetectSourceLanguageResult}});var G_=QS();Object.defineProperty(v,"SourceLanguageConfig",{enumerable:!0,get:function(){return G_.SourceLanguageConfig}});var zl=XS();Object.defineProperty(v,"SpeakerRecognitionResult",{enumerable:!0,get:function(){return zl.SpeakerRecognitionResult}});Object.defineProperty(v,"SpeakerRecognitionResultType",{enumerable:!0,get:function(){return zl.SpeakerRecognitionResultType}});Object.defineProperty(v,"SpeakerRecognitionCancellationDetails",{enumerable:!0,get:function(){return zl.SpeakerRecognitionCancellationDetails}});var ze=qa();Object.defineProperty(v,"Conversation",{enumerable:!0,get:function(){return ze.Conversation}});Object.defineProperty(v,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return ze.ConversationExpirationEventArgs}});Object.defineProperty(v,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return ze.ConversationParticipantsChangedEventArgs}});Object.defineProperty(v,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return ze.ConversationTranslationCanceledEventArgs}});Object.defineProperty(v,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return ze.ConversationTranslationEventArgs}});Object.defineProperty(v,"ConversationTranslationResult",{enumerable:!0,get:function(){return ze.ConversationTranslationResult}});Object.defineProperty(v,"ConversationTranslator",{enumerable:!0,get:function(){return ze.ConversationTranslator}});Object.defineProperty(v,"ConversationTranscriber",{enumerable:!0,get:function(){return ze.ConversationTranscriber}});Object.defineProperty(v,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return ze.ConversationTranscriptionResult}});Object.defineProperty(v,"Meeting",{enumerable:!0,get:function(){return ze.Meeting}});Object.defineProperty(v,"MeetingTranscriber",{enumerable:!0,get:function(){return ze.MeetingTranscriber}});Object.defineProperty(v,"Participant",{enumerable:!0,get:function(){return ze.Participant}});Object.defineProperty(v,"ParticipantChangedReason",{enumerable:!0,get:function(){return ze.ParticipantChangedReason}});Object.defineProperty(v,"User",{enumerable:!0,get:function(){return ze.User}});var $_=Ua();Object.defineProperty(v,"Synthesizer",{enumerable:!0,get:function(){return $_.Synthesizer}});var Q_=Sd();Object.defineProperty(v,"SpeechSynthesisOutputFormat",{enumerable:!0,get:function(){return Q_.SpeechSynthesisOutputFormat}});var Y_=Ry();Object.defineProperty(v,"SpeechSynthesizer",{enumerable:!0,get:function(){return Y_.SpeechSynthesizer}});var X_=Ey();Object.defineProperty(v,"SynthesisResult",{enumerable:!0,get:function(){return X_.SynthesisResult}});var Z_=wy();Object.defineProperty(v,"SpeechSynthesisResult",{enumerable:!0,get:function(){return Z_.SpeechSynthesisResult}});var eA=Iy();Object.defineProperty(v,"SpeechSynthesisEventArgs",{enumerable:!0,get:function(){return eA.SpeechSynthesisEventArgs}});var tA=Ty();Object.defineProperty(v,"SpeechSynthesisWordBoundaryEventArgs",{enumerable:!0,get:function(){return tA.SpeechSynthesisWordBoundaryEventArgs}});var rA=_y();Object.defineProperty(v,"SpeechSynthesisBookmarkEventArgs",{enumerable:!0,get:function(){return rA.SpeechSynthesisBookmarkEventArgs}});var iA=Ay();Object.defineProperty(v,"SpeechSynthesisVisemeEventArgs",{enumerable:!0,get:function(){return iA.SpeechSynthesisVisemeEventArgs}});var nA=by();Object.defineProperty(v,"SpeechSynthesisBoundaryType",{enumerable:!0,get:function(){return nA.SpeechSynthesisBoundaryType}});var sA=Oy();Object.defineProperty(v,"SynthesisVoicesResult",{enumerable:!0,get:function(){return sA.SynthesisVoicesResult}});var oA=My();Object.defineProperty(v,"VoiceInfo",{enumerable:!0,get:function(){return oA.VoiceInfo}});var aA=ky();Object.defineProperty(v,"SpeakerAudioDestination",{enumerable:!0,get:function(){return aA.SpeakerAudioDestination}});var cA=Ny();Object.defineProperty(v,"ConversationTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return cA.ConversationTranscriptionCanceledEventArgs}});var pA=xy();Object.defineProperty(v,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return pA.MeetingTranscriptionCanceledEventArgs}});var uA=qy();Object.defineProperty(v,"PronunciationAssessmentGradingSystem",{enumerable:!0,get:function(){return uA.PronunciationAssessmentGradingSystem}});var dA=zy();Object.defineProperty(v,"PronunciationAssessmentGranularity",{enumerable:!0,get:function(){return dA.PronunciationAssessmentGranularity}});var hA=jy();Object.defineProperty(v,"PronunciationAssessmentConfig",{enumerable:!0,get:function(){return hA.PronunciationAssessmentConfig}});var lA=Ly();Object.defineProperty(v,"PronunciationAssessmentResult",{enumerable:!0,get:function(){return lA.PronunciationAssessmentResult}});var vA=kh();Object.defineProperty(v,"LanguageIdMode",{enumerable:!0,get:function(){return vA.LanguageIdMode}});var fA=By();Object.defineProperty(v,"AvatarConfig",{enumerable:!0,get:function(){return fA.AvatarConfig}});var gA=Fy();Object.defineProperty(v,"AvatarEventArgs",{enumerable:!0,get:function(){return gA.AvatarEventArgs}});var mA=Uy();Object.defineProperty(v,"AvatarSynthesizer",{enumerable:!0,get:function(){return mA.AvatarSynthesizer}});var Xy=Wy();Object.defineProperty(v,"AvatarVideoFormat",{enumerable:!0,get:function(){return Xy.AvatarVideoFormat}});Object.defineProperty(v,"Coordinate",{enumerable:!0,get:function(){return Xy.Coordinate}});var SA=Hy();Object.defineProperty(v,"AvatarWebRTCConnectionResult",{enumerable:!0,get:function(){return SA.AvatarWebRTCConnectionResult}});var yA=Ky();Object.defineProperty(v,"Diagnostics",{enumerable:!0,get:function(){return yA.Diagnostics}});var CA=id();Object.defineProperty(v,"LogLevel",{enumerable:!0,get:function(){return CA.LogLevel}})});var Zy=p(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});lc.ProxyInfo=void 0;var hc=f(),jl=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(hc.PropertyId.SpeechServiceConnection_ProxyHostName),parseInt(e.getProperty(hc.PropertyId.SpeechServiceConnection_ProxyPort),10),e.getProperty(hc.PropertyId.SpeechServiceConnection_ProxyUserName),e.getProperty(hc.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}};lc.ProxyInfo=jl});var tC=p((C1,eC)=>{"use strict";var PA=new Set(["json","buffer","string"]);eC.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(PA.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 iC=p((P1,rC)=>{"use strict";var RA=tC(),Ll=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}},EA=(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 Ll(u);return t==="json"?u.json():t==="buffer"?u.arrayBuffer():t==="string"?u.text():u};rC.exports=RA(EA)});var sC=p(Jt=>{"use strict";var wA=Jt&&Jt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.RestMessageAdapter=Jt.RestRequestType=void 0;var IA=wA(iC()),nC=P(),vc;(function(i){i.Get="GET",i.Post="POST",i.Delete="DELETE",i.File="file"})(vc=Jt.RestRequestType||(Jt.RestRequestType={}));var Bl=class{constructor(e){if(!e)throw new nC.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 nC.Deferred,o=e===vc.File?"POST":e,a=(u,d={})=>{let h=u;return{data:JSON.stringify(d),headers:JSON.stringify(u.headers),json:d,ok:u.statusCode>=200&&u.statusCode<300,status:u.statusCode,statusText:d.error?d.error.message:h.statusText?h.statusText:h.statusMessage}},c=u=>{let d=IA.default(t,o,this.privHeaders,200,201,202,204,400,401,402,403,404),h=this.queryParams(r)===""?"":`?${this.queryParams(r)}`;d(h,u).then(async l=>{if(e===vc.Delete||l.statusCode===204)s.resolve(a(l));else try{let g=await l.json();s.resolve(a(l,g))}catch{s.resolve(a(l))}}).catch(l=>{s.reject(l)})};return this.privIgnoreCache&&(this.privHeaders["Cache-Control"]="no-cache"),e===vc.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("&")}};Jt.RestMessageAdapter=Bl});var Fl=p(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});fc.RestConfigBase=void 0;var Ni=class i{static get requestOptions(){return i.privDefaultRequestOptions}static get configParams(){return i.privDefaultParams}static get restErrors(){return i.privRestErrors}};fc.RestConfigBase=Ni;Ni.privDefaultRequestOptions={headers:{Accept:"application/json"},ignoreCache:!1,timeout:1e4};Ni.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."};Ni.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 ae=p(fe=>{"use strict";var TA=fe&&fe.__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]}),ht=fe&&fe.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&TA(e,i,t)};Object.defineProperty(fe,"__esModule",{value:!0});ht(fm(),fe);ht(mm(),fe);ht(Cm(),fe);ht(Rm(),fe);ht(Em(),fe);ht(Om(),fe);ht(pd(),fe);ht(Mm(),fe);ht(Zy(),fe);ht(sC(),fe);ht(Fl(),fe)});var cC=p(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.IntentConnectionFactory=void 0;var oC=ae(),Yn=f(),aC=$e(),_A=C(),AA=we(),Vl=class extends aC.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_Endpoint);if(!n){let c=e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_IntentRegion),u=aC.ConnectionFactoryBase.getHostSuffix(c);n=e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_Host,"wss://"+c+".sr.speech"+u)+"/speech/recognition/interactive/cognitiveservices/v1"}let s={format:"simple",language:e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,s,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[AA.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Yn.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new oC.WebsocketConnection(n,s,o,new _A.WebsocketMessageFormatter,oC.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}}};gc.IntentConnectionFactory=Vl});var hC=p(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.VoiceProfileConnectionFactory=xi.SpeakerRecognitionConnectionFactory=void 0;var pC=ae(),$r=f(),uC=$e(),bA=C(),dC=we(),mc=class extends uC.ConnectionFactoryBase{create(e,t,r,n){let s=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Endpoint);if(!s){let u=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Region),d=uC.ConnectionFactoryBase.getHostSuffix(u),h=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Host,`wss://${u}.spr-frontend.speech${d}`),l=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_SpeakerIdMode,"TextIndependentIdentification");s=`${h}/speaker/ws/${this.scenarioToPath(l)}/${r}`}let o={format:"simple",language:e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,o,s);let a={};t.token!==void 0&&t.token!==""&&(a[t.headerName]=t.token),a[dC.HeaderNames.ConnectionId]=n,a[dC.HeaderNames.SpIDAuthKey]=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Key),e.parameters.setProperty($r.PropertyId.SpeechServiceConnection_Url,s);let c=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new pC.WebsocketConnection(s,o,a,new bA.WebsocketMessageFormatter,pC.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"}}},Ul=class extends mc{create(e,t,r){return super.create(e,t,"recognition",r)}};xi.SpeakerRecognitionConnectionFactory=Ul;var Wl=class extends mc{create(e,t,r){return super.create(e,t,"profile",r)}};xi.VoiceProfileConnectionFactory=Wl});var yc=p(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.RecognitionEndedEvent=ge.RecognitionCompletionStatus=ge.RecognitionStartedEvent=ge.ConnectingToServiceEvent=ge.ListeningStartedEvent=ge.RecognitionTriggeredEvent=ge.SpeechRecognitionEvent=void 0;var Sc=P(),vr=class extends Sc.PlatformEvent{constructor(e,t,r,n=Sc.EventType.Info){super(e,n),this.privRequestId=t,this.privSessionId=r}get requestId(){return this.privRequestId}get sessionId(){return this.privSessionId}};ge.SpeechRecognitionEvent=vr;var Hl=class extends vr{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}};ge.RecognitionTriggeredEvent=Hl;var Kl=class extends vr{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}};ge.ListeningStartedEvent=Kl;var Jl=class extends vr{constructor(e,t,r){super("ConnectingToServiceEvent",e,r),this.privAuthFetchEventid=t}get authFetchEventid(){return this.privAuthFetchEventid}};ge.ConnectingToServiceEvent=Jl;var Gl=class extends vr{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}};ge.RecognitionStartedEvent=Gl;var lC;(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"})(lC=ge.RecognitionCompletionStatus||(ge.RecognitionCompletionStatus={}));var $l=class extends vr{constructor(e,t,r,n,s,o,a,c){super("RecognitionEndedEvent",e,s,a===lC.Success?Sc.EventType.Info:Sc.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}};ge.RecognitionEndedEvent=$l});var Qr=p(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});Cc.SpeechConnectionMessage=void 0;var Ql=P(),Gt=we(),Yl=class i extends Ql.ConnectionMessage{constructor(e,t,r,n,s,o,a,c){if(!t)throw new Ql.ArgumentNullError("path");if(!r)throw new Ql.ArgumentNullError("requestId");let u={};if(u[Gt.HeaderNames.Path]=t,u[Gt.HeaderNames.RequestId]=r,u[Gt.HeaderNames.RequestTimestamp]=new Date().toISOString(),n&&(u[Gt.HeaderNames.ContentType]=n),o&&(u[Gt.HeaderNames.RequestStreamId]=o),a)for(let d in a)d&&(u[d]=a[d]);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()===Gt.HeaderNames.Path.toLowerCase()?t=e.headers[a]:a.toLowerCase()===Gt.HeaderNames.RequestId.toLowerCase()?r=e.headers[a]:a.toLowerCase()===Gt.HeaderNames.ContentType.toLowerCase()?n=e.headers[a]:a.toLowerCase()===Gt.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)}};Cc.SpeechConnectionMessage=Yl});var vC=p(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});Rc.ServiceRecognizerBase=void 0;var OA=ae(),Z=P(),B=f(),It=C(),fr=Qr(),Pc=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 Z.ArgumentNullError("authentication");if(!t)throw new Z.ArgumentNullError("connectionFactory");if(!r)throw new Z.ArgumentNullError("audioSource");if(!n)throw new Z.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 It.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new Z.EventSource,this.privServiceEvents=new Z.EventSource,this.privDynamicGrammar=new It.DynamicGrammarBuilder,this.privSpeechContext=new It.SpeechContext(this.privDynamicGrammar),this.privAgentConfig=new It.AgentConfig,this.privRecognizerConfig.parameters.getProperty(B.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?this.privSetTimeout=Z.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=Z.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===It.RecognitionMode.Conversation?"CONVERSATION":this.recognitionMode===It.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(It.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,d=await this.audioSource.deviceInfo;this.privIsLiveAudio=d.type&&d.type===It.type.Microphones,s=new OA.ReplayableAudioNode(c,u.avgBytesPerSec),await this.privRequestSession.onAudioSourceAttachCompleted(s,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:d}}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"?Z.MessageType.Text:Z.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new fr.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 fr.SpeechConnectionMessage(Z.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=fr.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=It.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=It.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 Z.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 fr.SpeechConnectionMessage(Z.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 fr.SpeechConnectionMessage(Z.MessageType.Binary,"audio",this.privRequestSession.requestId,"audio/x-wav",t.header))}connectImpl(){return this.privConnectionPromise!==void 0?this.privConnectionPromise.then(e=>e.state()===Z.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 fr.SpeechConnectionMessage(Z.MessageType.Text,"speech.config",t.requestId,"application/json",r))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===Z.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 d,h;if(!u||u.isEnd?(d=null,h=0):(d=u.buffer,this.privRequestSession.onAudioSent(d.byteLength),s>=this.privRequestSession.bytesSent?h=0:h=Math.max(0,r-Date.now())),h!==0&&await this.delay(h),d!==null&&(r=Date.now()+d.byteLength*1e3/(t.avgBytesPerSec*2)),!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o)if(c.send(new fr.SpeechConnectionMessage(Z.MessageType.Binary,"audio",this.privRequestSession.requestId,null,d)).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=Z.createNoDashGuid();let t=this.privRequestSession.sessionId;this.privConnectionId=t!==void 0?t:Z.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 fr.SpeechConnectionMessage(Z.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)}};Rc.ServiceRecognizerBase=Pc;Pc.telemetryDataEnabled=!0});var fC=p(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});Ec.ConversationServiceRecognizer=void 0;var Xe=f(),Tt=C(),Xl=class extends Tt.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=Tt.SimpleSpeechPhrase.fromJSON(e),r=Tt.EnumTranslation.implTranslateRecognitionResult(t.RecognitionStatus),n,s=new Xe.PropertyCollection;s.setProperty(Xe.PropertyId.SpeechServiceResponse_JsonResult,e);let o=t.Offset+this.privRequestSession.currentTurnAudioOffset,a=o;if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+t.Offset+t.Duration),Xe.ResultReason.Canceled===r){let c=Tt.EnumTranslation.implTranslateCancelResult(t.RecognitionStatus),u=Tt.EnumTranslation.implTranslateCancelErrorCode(t.RecognitionStatus);await this.cancelRecognitionLocal(c,u,Tt.EnumTranslation.implTranslateErrorDetails(u))}else if(!(this.privRequestSession.isSpeechEnded&&r===Xe.ResultReason.NoMatch&&t.RecognitionStatus!==Tt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(Tt.OutputFormatPropertyName)===Xe.OutputFormat[Xe.OutputFormat.Simple])n=new Xe.SpeechRecognitionResult(this.privRequestSession.requestId,r,t.DisplayText,t.Duration,o,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,e,s);else{let c=Tt.DetailedSpeechPhrase.fromJSON(e),u=c.Offset+this.privRequestSession.currentTurnAudioOffset,d=c.getJsonWithCorrectedOffsets(u);n=new Xe.SpeechRecognitionResult(this.privRequestSession.requestId,r,c.Text,c.Duration,u,c.Language,c.LanguageDetectionConfidence,c.SpeakerId,void 0,d,s),a=n.offset}this.handleRecognizedCallback(n,a,this.privRequestSession.sessionId)}}handleSpeechHypothesis(e){let t=Tt.SpeechHypothesis.fromJSON(e),r=t.Offset+this.privRequestSession.currentTurnAudioOffset,n=new Xe.PropertyCollection;n.setProperty(Xe.PropertyId.SpeechServiceResponse_JsonResult,e);let s=new Xe.SpeechRecognitionResult(this.privRequestSession.requestId,Xe.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)}};Ec.ConversationServiceRecognizer=Xl});var mC=p(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.RecognizerConfig=_t.SpeechResultFormat=_t.RecognitionMode=void 0;var wc=f(),gC=C(),Ic;(function(i){i[i.Interactive=0]="Interactive",i[i.Conversation=1]="Conversation",i[i.Dictation=2]="Dictation"})(Ic=_t.RecognitionMode||(_t.RecognitionMode={}));var MA;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(MA=_t.SpeechResultFormat||(_t.SpeechResultFormat={}));var Zl=class{constructor(e,t){this.privSpeechServiceConfig=e||new gC.SpeechServiceConfig(new gC.Context(null)),this.privParameters=t,this.privMaxRetryCount=parseInt(t.getProperty("SPEECH-Error-MaxRetryCount","4"),10),this.privLanguageIdMode=t.getProperty(wc.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===Ic.Interactive?8e3:25e3,this.privSpeechServiceConfig.Recognition=Ic[e]}get SpeechServiceConfig(){return this.privSpeechServiceConfig}get recognitionActivityTimeout(){return this.privRecognitionActivityTimeout}get isContinuousRecognition(){return this.privRecognitionMode!==Ic.Interactive}get languageIdMode(){return this.privLanguageIdMode}get autoDetectSourceLanguages(){return this.parameters.getProperty(wc.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,void 0)}get recognitionEndpointVersion(){return this.parameters.getProperty(wc.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+wc.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}};_t.RecognizerConfig=Zl});var yC=p(SC=>{"use strict";Object.defineProperty(SC,"__esModule",{value:!0})});var PC=p(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});Tc.WebsocketMessageFormatter=void 0;var Ze=P(),CC=`\r
|
|
20
20
|
`,ev=class{toConnectionMessage(e){let t=new Ze.Deferred;try{if(e.messageType===Ze.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 Ze.ConnectionMessage(e.messageType,s,n,e.id))}else if(e.messageType===Ze.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 Ze.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 Ze.Deferred;try{if(e.messageType===Ze.MessageType.Text){let r=`${this.makeHeaders(e)}${PC}${e.textBody?e.textBody:""}`;t.resolve(new Ze.RawWebsocketMessage(Ze.MessageType.Text,r,e.id))}else if(e.messageType===Ze.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 d=new Int8Array(n);c.set(d,2+a)}let u=c.buffer;t.resolve(new Ze.RawWebsocketMessage(Ze.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]}${PC}`);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}};Ic.WebsocketMessageFormatter=ev});var TC=p(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});Tc.SpeechConnectionFactory=void 0;var EC=ae(),wC=C(),mr=f(),IC=$e(),tv=C(),kA=we(),Yr=Wt(),rv=class extends IC.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(mr.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(mr.PropertyId.SpeechServiceConnection_Region,void 0),o=IC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(mr.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(mr.PropertyId.SpeechServiceConnection_EndpointId,void 0),d=e.parameters.getProperty(mr.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(u?(!n||n.search(Yr.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[Yr.QueryParameterNames.CustomSpeechDeploymentId]=u):d&&(!n||n.search(Yr.QueryParameterNames.Language)===-1)&&(c[Yr.QueryParameterNames.Language]=d),(!n||n.search(Yr.QueryParameterNames.Format)===-1)&&(c[Yr.QueryParameterNames.Format]=e.parameters.getProperty(wC.OutputFormatPropertyName,mr.OutputFormat[mr.OutputFormat.Simple]).toLowerCase()),e.autoDetectSourceLanguages!==void 0&&(c[Yr.QueryParameterNames.EnableLanguageId]="true"),this.setCommonUrlParams(e,c,n),!n)switch(e.recognitionMode){case tv.RecognitionMode.Conversation:e.parameters.getProperty(wC.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 tv.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 h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[kA.HeaderNames.ConnectionId]=r;let l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new EC.WebsocketConnection(n,c,h,new tv.WebsocketMessageFormatter,EC.ProxyInfo.fromRecognizerConfig(e),l,r),_=g.uri;return e.parameters.setProperty(mr.PropertyId.SpeechServiceConnection_Url,_),g}};Tc.SpeechConnectionFactory=rv});var bC=p(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});_c.ConversationTranscriberConnectionFactory=void 0;var _C=ae(),Fe=f(),NA=C(),AC=$e(),xA=C(),qA=we(),et=Wt(),iv=class extends AC.ConnectionFactoryBase{constructor(){super(...arguments),this.universalUri="/speech/universal/v2"}create(e,t,r){let n=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_Region,void 0),o=AC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_EndpointId,void 0),d=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);u?(!n||n.search(et.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[et.QueryParameterNames.CustomSpeechDeploymentId]=u):d&&(!n||n.search(et.QueryParameterNames.Language)===-1)&&(c[et.QueryParameterNames.Language]=d),e.autoDetectSourceLanguages!==void 0&&(c[et.QueryParameterNames.EnableLanguageId]="true"),this.setV2UrlParams(e,c,n),n||(n=`${a}${this.universalUri}`);let h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[qA.HeaderNames.ConnectionId]=r;let l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new _C.WebsocketConnection(n,c,h,new xA.WebsocketMessageFormatter,_C.ProxyInfo.fromRecognizerConfig(e),l,r),_=g.uri;return e.parameters.setProperty(Fe.PropertyId.SpeechServiceConnection_Url,_),g}setV2UrlParams(e,t,r){new Map([[Fe.PropertyId.Speech_SegmentationSilenceTimeoutMs,et.QueryParameterNames.SegmentationSilenceTimeoutMs],[Fe.PropertyId.SpeechServiceConnection_EnableAudioLogging,et.QueryParameterNames.EnableAudioLogging],[Fe.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,et.QueryParameterNames.EndSilenceTimeoutMs],[Fe.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,et.QueryParameterNames.InitialSilenceTimeoutMs],[Fe.PropertyId.SpeechServiceResponse_PostProcessingOption,et.QueryParameterNames.Postprocessing],[Fe.PropertyId.SpeechServiceResponse_ProfanityOption,et.QueryParameterNames.Profanity],[Fe.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,et.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(NA.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}};_c.ConversationTranscriberConnectionFactory=iv});var kC=p(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});Ac.TranscriberConnectionFactory=void 0;var OC=ae(),Ve=f(),MC=$e(),DC=C(),zA=we(),Xn=Wt(),nv=class extends MC.ConnectionFactoryBase{constructor(){super(...arguments),this.multiaudioRelativeUri="/speech/recognition/multiaudio"}create(e,t,r){let n=e.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_Region,"centralus"),o=MC.ConnectionFactoryBase.getHostSuffix(s),a="wss://transcribe."+s+".cts.speech"+o+this.multiaudioRelativeUri,c=e.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_Host,a),u={};this.setQueryParams(u,e,n),n||(n=c);let d={};t.token!==void 0&&t.token!==""&&(d[t.headerName]=t.token),d[zA.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Ve.PropertyId.SpeechServiceConnection_Url,n);let h=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new OC.WebsocketConnection(n,u,d,new DC.WebsocketMessageFormatter,OC.ProxyInfo.fromRecognizerConfig(e),h,r)}setQueryParams(e,t,r){let n=t.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_EndpointId,void 0),s=t.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);n&&!(Xn.QueryParameterNames.CustomSpeechDeploymentId in e)&&(e[Xn.QueryParameterNames.CustomSpeechDeploymentId]=n),s&&!(Xn.QueryParameterNames.Language in e)&&(e[Xn.QueryParameterNames.Language]=s);let o=t.parameters.getProperty(Ve.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true",a=t.parameters.getProperty(DC.OutputFormatPropertyName,Ve.OutputFormat[Ve.OutputFormat.Simple])!==Ve.OutputFormat[Ve.OutputFormat.Simple];(o||a)&&(e[Xn.QueryParameterNames.Format]=Ve.OutputFormat[Ve.OutputFormat.Detailed].toLowerCase()),this.setCommonUrlParams(t,e,r)}};Ac.TranscriberConnectionFactory=nv});var zC=p(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.TranslationConnectionFactory=void 0;var NC=ae(),jA=Jh(),$t=f(),xC=$e(),sv=C(),LA=we(),qC=Wt(),ov=class extends xC.ConnectionFactoryBase{create(e,t,r){let n=this.getEndpointUrl(e),s={};e.autoDetectSourceLanguages!==void 0&&(s[qC.QueryParameterNames.EnableLanguageId]="true"),this.setQueryParams(s,e,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[LA.HeaderNames.ConnectionId]=r,e.parameters.setProperty($t.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new NC.WebsocketConnection(n,s,o,new sv.WebsocketMessageFormatter,NC.ProxyInfo.fromRecognizerConfig(e),a,r)}getEndpointUrl(e,t){let r=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Region),n=xC.ConnectionFactoryBase.getHostSuffix(r),s=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Endpoint,void 0);return s||(e.autoDetectSourceLanguages!==void 0?s=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Host,"wss://{region}.stt.speech"+n)+"/speech/universal/v2":s=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Host,"wss://{region}.s2s.speech"+n)+"/speech/translation/cognitiveservices/v1"),t===!0?s:jA.StringUtils.formatString(s,{region:r})}setQueryParams(e,t,r){e.from=t.parameters.getProperty($t.PropertyId.SpeechServiceConnection_RecoLanguage),e.to=t.parameters.getProperty($t.PropertyId.SpeechServiceConnection_TranslationToLanguages),e.scenario=t.recognitionMode===sv.RecognitionMode.Interactive?"interactive":t.recognitionMode===sv.RecognitionMode.Conversation?"conversation":"",this.setCommonUrlParams(t,e,r),this.setUrlParameter($t.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,qC.QueryParameterNames.StableTranslation,t,e,r);let n=t.parameters.getProperty($t.PropertyId.SpeechServiceConnection_TranslationVoice,void 0);n!==void 0&&(e.voice=n,e.features="texttospeech")}};bc.TranslationConnectionFactory=ov});var jC=p(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.EnumTranslation=void 0;var ce=f(),ie=C(),av=class{static implTranslateRecognitionResult(e,t=!1){let r=ce.ResultReason.Canceled;switch(e){case ie.RecognitionStatus.Success:r=ce.ResultReason.RecognizedSpeech;break;case ie.RecognitionStatus.EndOfDictation:r=t?ce.ResultReason.RecognizedSpeech:ce.ResultReason.NoMatch;break;case ie.RecognitionStatus.NoMatch:case ie.RecognitionStatus.InitialSilenceTimeout:case ie.RecognitionStatus.BabbleTimeout:r=ce.ResultReason.NoMatch;break;case ie.RecognitionStatus.Error:case ie.RecognitionStatus.BadRequest:case ie.RecognitionStatus.Forbidden:default:r=ce.ResultReason.Canceled;break}return r}static implTranslateCancelResult(e){let t=ce.CancellationReason.EndOfStream;switch(e){case ie.RecognitionStatus.Success:case ie.RecognitionStatus.EndOfDictation:case ie.RecognitionStatus.NoMatch:t=ce.CancellationReason.EndOfStream;break;case ie.RecognitionStatus.InitialSilenceTimeout:case ie.RecognitionStatus.BabbleTimeout:case ie.RecognitionStatus.Error:case ie.RecognitionStatus.BadRequest:case ie.RecognitionStatus.Forbidden:default:t=ce.CancellationReason.Error;break}return t}static implTranslateCancelErrorCode(e){let t=ce.CancellationErrorCode.NoError;switch(e){case ie.RecognitionStatus.Error:t=ce.CancellationErrorCode.ServiceError;break;case ie.RecognitionStatus.TooManyRequests:t=ce.CancellationErrorCode.TooManyRequests;break;case ie.RecognitionStatus.BadRequest:t=ce.CancellationErrorCode.BadRequestParameters;break;case ie.RecognitionStatus.Forbidden:t=ce.CancellationErrorCode.Forbidden;break;default:t=ce.CancellationErrorCode.NoError;break}return t}static implTranslateErrorDetails(e){let t="The speech service encountered an internal error and could not continue.";switch(e){case ce.CancellationErrorCode.Forbidden:t="The recognizer is using a free subscription that ran out of quota.";break;case ce.CancellationErrorCode.BadRequestParameters:t="Invalid parameter or unsupported audio format in the request.";break;case ce.CancellationErrorCode.TooManyRequests:t="The number of parallel requests exceeded the number of allowed concurrent transcriptions.";break;default:break}return t}};Oc.EnumTranslation=av});var LC=p(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.RecognitionStatus=Sr.SynthesisStatus=void 0;var BA;(function(i){i[i.Success=0]="Success",i[i.SynthesisEnd=1]="SynthesisEnd",i[i.Error=2]="Error"})(BA=Sr.SynthesisStatus||(Sr.SynthesisStatus={}));var FA;(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"})(FA=Sr.RecognitionStatus||(Sr.RecognitionStatus={}))});var FC=p(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.TranslationSynthesisEnd=void 0;var BC=C(),cv=class i{constructor(e){this.privSynthesisEnd=JSON.parse(e),this.privSynthesisEnd.SynthesisStatus&&(this.privSynthesisEnd.SynthesisStatus=BC.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]),this.privSynthesisEnd.Status&&(this.privSynthesisEnd.SynthesisStatus=BC.SynthesisStatus[this.privSynthesisEnd.Status])}static fromJSON(e){return new i(e)}get SynthesisStatus(){return this.privSynthesisEnd.SynthesisStatus}get FailureReason(){return this.privSynthesisEnd.FailureReason}};Mc.TranslationSynthesisEnd=cv});var VC=p(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});Dc.TranslationHypothesis=void 0;var VA=w(),UA=xs(),pv=class i{constructor(e){this.privTranslationHypothesis=e,this.privTranslationHypothesis.Translation.TranslationStatus=UA.TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus]}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){VA.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}};Dc.TranslationHypothesis=pv});var UC=p(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.TranslationPhrase=void 0;var WA=w(),HA=C(),KA=xs(),uv=class i{constructor(e){this.privTranslationPhrase=e,this.privTranslationPhrase.RecognitionStatus=HA.RecognitionStatus[this.privTranslationPhrase.RecognitionStatus],this.privTranslationPhrase.Translation!==void 0&&(this.privTranslationPhrase.Translation.TranslationStatus=KA.TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus])}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){WA.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}};kc.TranslationPhrase=uv});var HC=p(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});Nc.TranslationServiceRecognizer=void 0;var WC=P(),z=f(),Te=C(),dv=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),d=Te.EnumTranslation.implTranslateCancelErrorCode(o.RecognitionStatus);await this.cancelRecognitionLocal(u,d,Te.EnumTranslation.implTranslateErrorDetails(d))}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===WC.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 d of e.Translation.Translations)r.set(d.Language,d.Text||d.DisplayText)}let n,s;e instanceof Te.TranslationPhrase?(e.Translation&&e.Translation.TranslationStatus===WC.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{}}};Nc.TranslationServiceRecognizer=dv});var KC=p(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.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}};xc.SpeechDetected=hv});var JC=p(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});qc.SpeechHypothesis=void 0;var lv=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}};qc.SpeechHypothesis=lv});var GC=p(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.SpeechKeyword=void 0;var vv=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}};zc.SpeechKeyword=vv});var $C=p(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.SpeechServiceRecognizer=void 0;var me=f(),tt=C(),fv=class extends tt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeechRecognizer=s}async processTypeSpecificMessages(e){let t,r=new me.PropertyCollection;r.setProperty(me.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=tt.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new me.SpeechRecognitionResult(this.privRequestSession.requestId,me.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 me.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=tt.SimpleSpeechPhrase.fromJSON(e.textBody),u=tt.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus,this.privExpectContentAssessmentResponse);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),me.ResultReason.Canceled===u){let d=tt.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),h=tt.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(d,h,tt.EnumTranslation.implTranslateErrorDetails(h))}else{if(!(this.privRequestSession.isSpeechEnded&&u===me.ResultReason.NoMatch&&c.RecognitionStatus!==tt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(tt.OutputFormatPropertyName)===me.OutputFormat[me.OutputFormat.Simple])t=new me.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 h=tt.DetailedSpeechPhrase.fromJSON(e.textBody),l=h.Offset+this.privRequestSession.currentTurnAudioOffset,g=h.getJsonWithCorrectedOffsets(l);t=new me.SpeechRecognitionResult(this.privRequestSession.requestId,u,h.RecognitionStatus===tt.RecognitionStatus.Success?h.NBest[0].Display:void 0,h.Duration,l,h.Language,h.LanguageDetectionConfidence,void 0,void 0,g,r)}let d=new me.SpeechRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognized)try{this.privSpeechRecognizer.recognized(this.privSpeechRecognizer,d)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(d){this.privErrorCallback&&this.privErrorCallback(d)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){let o=new me.PropertyCollection;if(o.setProperty(tt.CancellationErrorCodePropertyName,me.CancellationErrorCode[n]),this.privSpeechRecognizer.canceled){let a=new me.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new me.SpeechRecognitionResult(t,me.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{}}}};jc.SpeechServiceRecognizer=fv});var QC=p(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});Lc.ConversationTranscriptionServiceRecognizer=void 0;var Me=f(),rt=C(),gv=class extends rt.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 Me.PropertyCollection;r.setProperty(Me.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=rt.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,Me.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 Me.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=rt.SimpleSpeechPhrase.fromJSON(e.textBody),u=rt.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),Me.ResultReason.Canceled===u){let d=rt.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),h=rt.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(d,h,rt.EnumTranslation.implTranslateErrorDetails(h))}else if(!(this.privRequestSession.isSpeechEnded&&u===Me.ResultReason.NoMatch&&c.RecognitionStatus!==rt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(rt.OutputFormatPropertyName)===Me.OutputFormat[Me.OutputFormat.Simple])t=new Me.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 h=rt.DetailedSpeechPhrase.fromJSON(e.textBody),l=h.Offset+this.privRequestSession.currentTurnAudioOffset,g=h.getJsonWithCorrectedOffsets(l);t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,u,h.RecognitionStatus===rt.RecognitionStatus.Success?h.NBest[0].Display:void 0,h.Duration,l,h.Language,h.LanguageDetectionConfidence,c.SpeakerId,void 0,g,r)}let d=new Me.ConversationTranscriptionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribed)try{this.privConversationTranscriber.transcribed(this.privConversationTranscriber,d)}catch{}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){if(new Me.PropertyCollection().setProperty(rt.CancellationErrorCodePropertyName,Me.CancellationErrorCode[n]),this.privConversationTranscriber.canceled){let a=new Me.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationTranscriber.canceled(this.privConversationTranscriber,a)}catch{}}}};Lc.ConversationTranscriptionServiceRecognizer=gv});var XC=p(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});Bc.TranscriptionServiceRecognizer=void 0;var JA=P(),Qt=f(),YC=C(),GA=Qr(),mv=class extends YC.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(Qt.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 Qt.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 Qt.SpeechRecognitionEventArgs(e,t,r);this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer,n)}catch{}}cancelRecognition(e,t,r,n,s){let o=new Qt.PropertyCollection;if(o.setProperty(YC.CancellationErrorCodePropertyName,Qt.CancellationErrorCode[n]),this.privTranscriberRecognizer.IsMeetingRecognizer()){if(this.privTranscriberRecognizer.canceled){let a=new Qt.MeetingTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}}else if(this.privTranscriberRecognizer.canceled){let a=new Qt.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new Qt.SpeechRecognitionResult(t,Qt.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 GA.SpeechConnectionMessage(JA.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}};Bc.TranscriptionServiceRecognizer=mv});var ZC=p(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});Fc.DetailedSpeechPhrase=void 0;var $A=C(),Sv=class i{constructor(e){this.privDetailedSpeechPhrase=JSON.parse(e),this.privDetailedSpeechPhrase.RecognitionStatus=$A.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}};Fc.DetailedSpeechPhrase=Sv});var eP=p(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});Vc.SimpleSpeechPhrase=void 0;var QA=C(),yv=class i{constructor(e){this.privSimpleSpeechPhrase=JSON.parse(e),this.privSimpleSpeechPhrase.RecognitionStatus=QA.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}};Vc.SimpleSpeechPhrase=yv});var tP=p(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.AddedLmIntent=void 0;var Cv=class{constructor(e,t){this.modelImpl=e,this.intentName=t}};Uc.AddedLmIntent=Cv});var iP=p(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});Wc.IntentServiceRecognizer=void 0;var rP=P(),ne=f(),qi=C(),Pv=class extends qi.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 ne.PropertyCollection;switch(e.messageType===rP.MessageType.Text&&s.setProperty(ne.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.hypothesis":let a=qi.SpeechHypothesis.fromJSON(e.textBody);if(t=new ne.IntentRecognitionResult(void 0,this.privRequestSession.requestId,ne.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 ne.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=qi.SimpleSpeechPhrase.fromJSON(e.textBody);t=new ne.IntentRecognitionResult(void 0,this.privRequestSession.requestId,qi.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus),c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,e.textBody,s),r=new ne.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(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}};this.privIntentDataSent===!1||ne.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 ne.IntentRecognitionEventArgs(new ne.IntentRecognitionResult,0,this.privRequestSession.sessionId)}let d=qi.IntentResponse.fromJSON(e.textBody);if(d!==null&&d.topScoringIntent&&d.topScoringIntent.intent){let h=this.privAddedLmIntents[d.topScoringIntent.intent];if(this.privUmbrellaIntent!==void 0&&(h=this.privUmbrellaIntent),h){let l=h===void 0||h.intentName===void 0?d.topScoringIntent.intent:h.intentName,g=r.result.reason;l!==void 0&&(g=ne.ResultReason.RecognizedIntent);let _=r.result.properties!==void 0?r.result.properties:new ne.PropertyCollection;_.setProperty(ne.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,e.textBody),r=new ne.IntentRecognitionEventArgs(new ne.IntentRecognitionResult(l,r.result.resultId,g,r.result.text,r.result.duration,r.result.offset,void 0,void 0,r.result.errorDetails,r.result.json,_),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(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}n=!0;break;default:break}let o=new rP.Deferred;return o.resolve(n),o.promise}cancelRecognition(e,t,r,n,s){let o=new ne.PropertyCollection;if(o.setProperty(qi.CancellationErrorCodePropertyName,ne.CancellationErrorCode[n]),this.privIntentRecognizer.canceled){let a=new ne.IntentRecognitionCanceledEventArgs(r,s,n,void 0,void 0,e);try{this.privIntentRecognizer.canceled(this.privIntentRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new ne.IntentRecognitionResult(void 0,t,ne.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{}}}};Wc.IntentServiceRecognizer=Pv});var nP=p(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});Hc.IntentResponse=void 0;var Rv=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}};Hc.IntentResponse=Rv});var oP=p(sP=>{"use strict";Object.defineProperty(sP,"__esModule",{value:!0})});var cP=p(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.ServiceTelemetryListener=void 0;var Yt=P(),aP=Sc(),Ev=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 aP.RecognitionTriggeredEvent&&e.requestId===this.privRequestId&&(this.privListeningTriggerMetric={End:e.eventTime,Name:"ListeningTrigger",Start:e.eventTime}),e instanceof Yt.AudioStreamNodeAttachingEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Yt.AudioStreamNodeAttachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Yt.AudioSourceErrorEvent&&e.audioSourceId===this.privAudioSourceId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof Yt.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 Yt.AudioStreamNodeDetachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Name:"Microphone",Start:this.privMicStartTime})),e instanceof aP.ConnectingToServiceEvent&&e.requestId===this.privRequestId&&(this.privConnectionId=e.sessionId),e instanceof Yt.ConnectionStartEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionStartTime=e.eventTime),e instanceof Yt.ConnectionEstablishedEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof Yt.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 Yt.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()}}};Kc.ServiceTelemetryListener=Ev});var pP=p(Gc=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});Gc.RequestSession=void 0;var zi=P(),Jc=Sc(),YA=cP(),wv=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=zi.createNoDashGuid(),this.privAudioNodeId=zi.createNoDashGuid(),this.privTurnDeferral=new zi.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 YA.ServiceTelemetryListener(this.privRequestId,this.privAudioSourceId,this.privAudioNodeId),this.onEvent(new Jc.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 Jc.ListeningStartedEvent(this.privRequestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}onPreConnectionStart(e,t){this.privAuthFetchEventId=e,this.privSessionId=t,this.onEvent(new Jc.ConnectingToServiceEvent(this.privRequestId,this.privAuthFetchEventId,this.privSessionId))}async onAuthCompleted(e){e&&await this.onComplete()}async onConnectionEstablishCompleted(e,t){if(e===200){this.onEvent(new Jc.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=zi.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 zi.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),zi.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())}};Gc.RequestSession=wv});var uP=p($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.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)}};$c.SpeechContext=Iv});var dP=p(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});Qc.DynamicGrammarBuilder=void 0;var Tv=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}};Qc.DynamicGrammarBuilder=Tv});var lP=p(hP=>{"use strict";Object.defineProperty(hP,"__esModule",{value:!0})});var Av=p(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.MessageDataStreamType=Xr.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}};Xr.ActivityPayloadResponse=_v;var XA;(function(i){i[i.None=0]="None",i[i.TextToSpeechAudio=1]="TextToSpeechAudio"})(XA=Xr.MessageDataStreamType||(Xr.MessageDataStreamType={}))});var vP=p(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});Yc.DialogServiceTurnState=void 0;var ZA=li(),eb=Dr(),tb=Av(),bv=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===tb.MessageDataStreamType.TextToSpeechAudio&&(this.privAudioStream=eb.AudioOutputStream.createPullStream(),this.privAudioStream.format=t!==void 0?t:ZA.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)}};Yc.DialogServiceTurnState=bv});var gP=p(Xc=>{"use strict";Object.defineProperty(Xc,"__esModule",{value:!0});Xc.DialogServiceTurnStateManager=void 0;var fP=ot(),rb=vP(),Ov=class{constructor(){this.privTurnMap=new Map}StartTurn(e){if(this.privTurnMap.has(e))throw new fP.InvalidOperationError("Service error: There is already a turn with id:"+e);let t=new rb.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 fP.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}};Xc.DialogServiceTurnStateManager=Ov});var mP=p(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});ep.DialogServiceAdapter=void 0;var ib=ae(),nb=Pu(),_e=P(),sb=li(),k=f(),ob=gP(),At=C(),ab=Av(),Zc=Qr(),Mv=class extends At.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privEvents=new _e.EventSource,this.privDialogServiceConnector=s,this.receiveMessageOverride=()=>this.receiveDialogMessageOverride(),this.privTurnStateManager=new ob.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=_e.createGuid(),r=_e.createNoDashGuid(),n={context:{interactionId:t},messagePayload:JSON.parse(e),version:.5},s=JSON.stringify(n);await(await this.fetchConnection()).send(new Zc.SpeechConnectionMessage(_e.MessageType.Text,"agent",r,"application/json",s))}async privDisconnect(){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.agentConfigSent=!1}processTypeSpecificMessages(e){let t=new k.PropertyCollection;e.messageType===_e.MessageType.Text&&t.setProperty(k.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let r,n;switch(e.path.toLowerCase()){case"speech.phrase":let o=At.SimpleSpeechPhrase.fromJSON(e.textBody);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus!==At.RecognitionStatus.TooManyRequests&&o.RecognitionStatus!==At.RecognitionStatus.Error){let l=this.fireEventForResult(o,t);if(this.privLastResult=l.result,this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,l)}catch{}}n=!0;break;case"speech.hypothesis":let a=At.SpeechHypothesis.fromJSON(e.textBody),c=a.Offset+this.privRequestSession.currentTurnAudioOffset;r=new k.SpeechRecognitionResult(this.privRequestSession.requestId,k.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 k.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 d=At.SpeechKeyword.fromJSON(e.textBody);r=new k.SpeechRecognitionResult(this.privRequestSession.requestId,d.Status==="Accepted"?k.ResultReason.RecognizedKeyword:k.ResultReason.NoMatch,d.Text,d.Duration,d.Offset,void 0,void 0,void 0,void 0,e.textBody,t),d.Status!=="Accepted"&&(this.privLastResult=r);let h=new k.SpeechRecognitionEventArgs(r,r.duration,r.resultId);if(this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,h)}catch{}n=!0;break;case"audio":{let l=e.requestId.toUpperCase(),g=this.privTurnStateManager.GetTurn(l);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 _e.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 k.PropertyCollection;o.setProperty(At.CancellationErrorCodePropertyName,k.CancellationErrorCode[n]);let a=new k.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privDialogServiceConnector.canceled(this.privDialogServiceConnector,a)}catch{}if(this.privSuccessCallback){let c=new k.SpeechRecognitionResult(void 0,k.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(k.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(l){return await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.ConnectionFailure,l),Promise.resolve()}let d=new k.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,d),this.sendAudio(u).then(()=>{},async l=>{await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.RuntimeError,l)})}dialogConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}receiveDialogMessageOverride(){let e=new _e.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=Zc.SpeechConnectionMessage.fromConnectionMessage(o);switch(a.path.toLowerCase()){case"turn.start":{let _=a.requestId.toUpperCase(),M=this.privRequestSession.requestId.toUpperCase();_!==M?this.privTurnStateManager.StartTurn(_):this.privRequestSession.onServiceTurnStartResponse()}break;case"speech.startdetected":let u=At.SpeechDetected.fromJSON(a.textBody),d=new k.RecognitionEventArgs(u.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,d);break;case"speech.enddetected":let h;a.textBody.length>0?h=a.textBody:h="{ Offset: 0 }";let l=At.SpeechDetected.fromJSON(h);this.privRequestSession.onServiceRecognized(l.Offset+this.privRequestSession.currentTurnAudioOffset);let g=new k.RecognitionEventArgs(l.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,g);break;case"turn.end":{let _=a.requestId.toUpperCase(),M=this.privRequestSession.requestId.toUpperCase();if(_!==M)this.privTurnStateManager.CompleteTurn(_);else{let J=new k.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,J),this.privSuccessCallback&&this.privLastResult){try{this.privSuccessCallback(this.privLastResult),this.privLastResult=null}catch(F){this.privErrorCallback&&this.privErrorCallback(F)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}}break;default:try{await this.processTypeSpecificMessages(a)||this.serviceEvents&&this.serviceEvents.onEvent(new _e.ServiceEvent(a.path.toLowerCase(),a.textBody))}catch{}}return t()}catch{this.terminateMessageLoop=!0,e.resolve()}};return t().catch(r=>{_e.Events.instance.onEvent(new _e.BackgroundEvent(r))}),e.promise}async startMessageLoop(){this.terminateMessageLoop=!1;try{await this.receiveDialogMessageOverride()}catch(e){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.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(k.PropertyId.Conversation_DialogType)===k.DialogServiceConfig.DialogTypes.CustomCommands){let r=this.agentConfig.get();r.botInfo.commandsCulture=this.privRecognizerConfig.parameters.getProperty(k.PropertyId.SpeechServiceConnection_RecoLanguage,"en-us"),this.agentConfig.set(r)}this.onEvent(new nb.SendingAgentContextMessageEvent(this.agentConfig));let t=this.agentConfig.toJsonString();return this.agentConfigSent=!0,e.send(new Zc.SpeechConnectionMessage(_e.MessageType.Text,"agent.config",this.privRequestSession.requestId,"application/json",t))}}sendAgentContext(e){let t=_e.createGuid(),r=this.privDialogServiceConnector.properties.getProperty(k.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 Zc.SpeechConnectionMessage(_e.MessageType.Text,"speech.agent.context",this.privRequestSession.requestId,"application/json",s))}fireEventForResult(e,t){let r=At.EnumTranslation.implTranslateRecognitionResult(e.RecognitionStatus),n=e.Offset+this.privRequestSession.currentTurnAudioOffset,s=new k.SpeechRecognitionResult(this.privRequestSession.requestId,r,e.DisplayText,e.Duration,n,e.Language,e.LanguageDetectionConfidence,void 0,void 0,JSON.stringify(e),t);return new k.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,sb.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(k.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0))),a=new k.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 k.TurnStatusReceivedEventArgs(e.textBody))}catch{}break;default:_e.Events.instance.onEvent(new _e.BackgroundEvent(`Unexpected response of type ${t.messageType}. Ignoring.`));break}}onEvent(e){this.privEvents.onEvent(e),_e.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"}])}};ep.DialogServiceAdapter=Mv});var SP=p(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});tp.AgentConfig=void 0;var Dv=class{toJsonString(){return JSON.stringify(this.iPrivConfig)}get(){return this.iPrivConfig}set(e){this.iPrivConfig=e}};tp.AgentConfig=Dv});var ip=p(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.ConversationConnectionConfig=void 0;var cb=Fl(),bt=class i extends cb.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}};rp.ConversationConnectionConfig=bt;bt.privHost="dev.microsofttranslator.com";bt.privRestPath="/capito/room";bt.privApiVersion="2.0";bt.privDefaultLanguageCode="en-US";bt.privClientAppId="FC539C22-1767-4F1F-84BC-B4D811114F15";bt.privWebSocketPath="/capito/translate";bt.privTranscriptionEventKeys=["iCalUid","callId","organizer","FLAC","MTUri","DifferentiateGuestSpeakers","audiorecording","Threadid","OrganizerMri","OrganizerTenantId","UserToken"]});var yP=p(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});sp.ConversationManager=void 0;var np=ae(),yr=w(),Xt=f(),Zr=ip(),kv=class{constructor(){this.privRequestParams=Zr.ConversationConnectionConfig.configParams,this.privErrors=Zr.ConversationConnectionConfig.restErrors,this.privHost=Zr.ConversationConnectionConfig.host,this.privApiVersion=Zr.ConversationConnectionConfig.apiVersion,this.privRestPath=Zr.ConversationConnectionConfig.restPath,this.privRestAdapter=new np.RestMessageAdapter({})}createOrJoin(e,t,r,n){try{yr.Contracts.throwIfNullOrUndefined(e,"args");let s=e.getProperty(Xt.PropertyId.SpeechServiceConnection_RecoLanguage,Zr.ConversationConnectionConfig.defaultLanguageCode),o=e.getProperty(Xt.PropertyId.ConversationTranslator_Name,"conversation_host"),a=e.getProperty(Xt.PropertyId.ConversationTranslator_Host,this.privHost),c=e.getProperty(Xt.PropertyId.ConversationTranslator_CorrelationId),u=e.getProperty(Xt.PropertyId.SpeechServiceConnection_Key),d=e.getProperty(Xt.PropertyId.SpeechServiceConnection_Region),h=e.getProperty(Xt.PropertyId.SpeechServiceAuthorization_Token);yr.Contracts.throwIfNullOrWhitespace(s,"languageCode"),yr.Contracts.throwIfNullOrWhitespace(o,"nickname"),yr.Contracts.throwIfNullOrWhitespace(a,"endpointHost");let l={};l[this.privRequestParams.apiVersion]=this.privApiVersion,l[this.privRequestParams.languageCode]=s,l[this.privRequestParams.nickname]=o;let g={};c&&(g[this.privRequestParams.correlationId]=c),g[this.privRequestParams.clientAppId]=Zr.ConversationConnectionConfig.clientAppId,t!==void 0?l[this.privRequestParams.roomId]=t:(yr.Contracts.throwIfNullOrUndefined(d,this.privErrors.authInvalidSubscriptionRegion),g[this.privRequestParams.subscriptionRegion]=d,u?g[this.privRequestParams.subscriptionKey]=u:h?g[this.privRequestParams.authorization]=`Bearer ${h}`:yr.Contracts.throwIfNullOrUndefined(u,this.privErrors.authInvalidSubscriptionKey));let _={};_.headers=g,this.privRestAdapter.options=_;let M=`https://${a}${this.privRestPath}`;this.privRestAdapter.request(np.RestRequestType.Post,M,l,null).then(J=>{let F=np.RestMessageAdapter.extractHeaderValue(this.privRequestParams.requestId,J.headers);if(!J.ok){if(n){let ye=this.privErrors.invalidCreateJoinConversationResponse.replace("{status}",J.status.toString()),V;try{V=JSON.parse(J.data),ye+=` [${V.error.code}: ${V.error.message}]`}catch{ye+=` [${J.data}]`}F&&(ye+=` ${F}`),n(ye)}return}let ee=JSON.parse(J.data);if(ee&&(ee.requestId=F),r){try{r(ee)}catch(ye){n&&n(ye)}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{yr.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","config")),yr.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","token"));let s=e.getProperty(Xt.PropertyId.ConversationTranslator_Host,this.privHost),o=e.getProperty(Xt.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 d=`https://${s}${this.privRestPath}`;this.privRestAdapter.request(np.RestRequestType.Delete,d,a,null).then(h=>{h.ok,r()}).catch(()=>{})}catch(s){if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}})}};sp.ConversationManager=kv});var xv=p(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});op.ConversationConnectionMessage=void 0;var pb=P(),Nv=class extends pb.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}};op.ConversationConnectionMessage=Nv});var PP=p(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});ap.ConversationWebsocketMessageFormatter=void 0;var ei=P(),CP=xv(),qv=class{toConnectionMessage(e){let t=new ei.Deferred;try{if(e.messageType===ei.MessageType.Text){let r=new CP.ConversationConnectionMessage(e.messageType,e.textContent,{},e.id);t.resolve(r)}else e.messageType===ei.MessageType.Binary&&t.resolve(new CP.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 ei.Deferred;try{if(e.messageType===ei.MessageType.Text){let r=`${e.textBody?e.textBody:""}`;t.resolve(new ei.RawWebsocketMessage(ei.MessageType.Text,r,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}};ap.ConversationWebsocketMessageFormatter=qv});var EP=p(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});cp.ConversationConnectionFactory=void 0;var RP=ae(),ub=P(),db=w(),zv=f(),hb=$e(),ji=ip(),lb=PP(),jv=class extends hb.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(zv.PropertyId.ConversationTranslator_Host,ji.ConversationConnectionConfig.host),s=e.parameters.getProperty(zv.PropertyId.ConversationTranslator_CorrelationId,ub.createGuid()),o=`wss://${n}${ji.ConversationConnectionConfig.webSocketPath}`,a=e.parameters.getProperty(zv.PropertyId.ConversationTranslator_Token,void 0);db.Contracts.throwIfNullOrUndefined(a,"token");let c={};c[ji.ConversationConnectionConfig.configParams.apiVersion]=ji.ConversationConnectionConfig.apiVersion,c[ji.ConversationConnectionConfig.configParams.token]=a,c[ji.ConversationConnectionConfig.configParams.correlationId]=s;let u=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new RP.WebsocketConnection(o,c,{},new lb.ConversationWebsocketMessageFormatter,RP.ProxyInfo.fromRecognizerConfig(e),u,r)}};cp.ConversationConnectionFactory=jv});var wP=p(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});pp.ConversationRequestSession=void 0;var Lv=P(),Bv=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privSessionId=e,this.privRequestId=Lv.createNoDashGuid(),this.privRequestCompletionDeferral=new Lv.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=Lv.createNoDashGuid():this.onComplete()}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach()}}onComplete(){}};pp.ConversationRequestSession=Bv});var Jv=p(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.ConversationReceivedTranslationEventArgs=je.ParticipantsListEventArgs=je.ParticipantAttributeEventArgs=je.ParticipantEventArgs=je.LockRoomEventArgs=je.MuteAllEventArgs=void 0;var Zn=f(),Fv=class extends Zn.SessionEventArgs{constructor(e,t){super(t),this.privIsMuted=e}get isMuted(){return this.privIsMuted}};je.MuteAllEventArgs=Fv;var Vv=class extends Zn.SessionEventArgs{constructor(e,t){super(t),this.privIsLocked=e}get isMuted(){return this.privIsLocked}};je.LockRoomEventArgs=Vv;var Uv=class extends Zn.SessionEventArgs{constructor(e,t){super(t),this.privParticipant=e}get participant(){return this.privParticipant}};je.ParticipantEventArgs=Uv;var Wv=class extends Zn.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}};je.ParticipantAttributeEventArgs=Wv;var Hv=class extends Zn.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}};je.ParticipantsListEventArgs=Hv;var Kv=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}};je.ConversationReceivedTranslationEventArgs=Kv});var $v=p(Cr=>{"use strict";Object.defineProperty(Cr,"__esModule",{value:!0});Cr.ConversationTranslatorCommandTypes=Cr.ConversationTranslatorMessageTypes=Cr.InternalParticipants=void 0;var Gv=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)}};Cr.InternalParticipants=Gv;Cr.ConversationTranslatorMessageTypes={command:"command",final:"final",info:"info",instantMessage:"instant_message",keepAlive:"keep_alive",partial:"partial",participantCommand:"participant_command",translatedMessage:"translated_message"};Cr.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 IP=p(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});up.CommandResponsePayload=void 0;var vb=i=>JSON.parse(i),Qv=class i{constructor(e){this.privCommandResponse=vb(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)}};up.CommandResponsePayload=Qv});var TP=p(Li=>{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});Li.ParticipantPayloadResponse=Li.ParticipantsListPayloadResponse=void 0;var fb=i=>JSON.parse(i),gb=i=>JSON.parse(i),Yv=class i{constructor(e){this.privParticipantsPayloadResponse=fb(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)}};Li.ParticipantsListPayloadResponse=Yv;var Xv=class i{constructor(e){this.privParticipantPayloadResponse=gb(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)}};Li.ParticipantPayloadResponse=Xv});var _P=p(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.TextResponsePayload=Bi.SpeechResponsePayload=void 0;var mb=i=>JSON.parse(i),Sb=i=>JSON.parse(i),Zv=class i{constructor(e){this.privSpeechResponse=mb(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)}};Bi.SpeechResponsePayload=Zv;var ef=class i{constructor(e){this.privTextResponse=Sb(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)}};Bi.TextResponsePayload=ef});var OP=p(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});var yb=IP();Object.defineProperty(ti,"CommandResponsePayload",{enumerable:!0,get:function(){return yb.CommandResponsePayload}});var AP=TP();Object.defineProperty(ti,"ParticipantsListPayloadResponse",{enumerable:!0,get:function(){return AP.ParticipantsListPayloadResponse}});Object.defineProperty(ti,"ParticipantPayloadResponse",{enumerable:!0,get:function(){return AP.ParticipantPayloadResponse}});var bP=_P();Object.defineProperty(ti,"SpeechResponsePayload",{enumerable:!0,get:function(){return bP.SpeechResponsePayload}});Object.defineProperty(ti,"TextResponsePayload",{enumerable:!0,get:function(){return bP.TextResponsePayload}})});var kP=p(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});dp.ConversationServiceAdapter=void 0;var es=P(),lt=f(),MP=C(),DP=xv(),Cb=wP(),Ue=Jv(),Pr=$v(),ts=OP(),tf=class extends MP.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 Cb.ConversationRequestSession(es.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 DP.ConversationConnectionMessage(es.MessageType.Text,e))}async sendMessageAsync(e){await(await this.fetchConnection()).send(new DP.ConversationConnectionMessage(es.MessageType.Text,e))}privDisconnect(){if(!this.terminateMessageLoop)return this.cancelRecognition(this.privConversationRequestSession.sessionId,this.privConversationRequestSession.requestId,lt.CancellationReason.Error,lt.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,Promise.resolve()}async processTypeSpecificMessages(){return!0}cancelRecognition(e,t,r,n,s){this.terminateMessageLoop=!0;let o=new lt.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 es.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=ts.CommandResponsePayload.fromJSON(r.textBody);switch(a.command.toLowerCase()){case"participantlist":let g=ts.ParticipantsListPayloadResponse.fromJSON(r.textBody),_=g.participants.map(V=>({avatar:V.avatar,displayName:V.nickname,id:V.participantId,isHost:V.ishost,isMuted:V.ismuted,isUsingTts:V.usetts,preferredLanguage:V.locale}));this.privConversationServiceConnector.participantsListReceived&&this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector,new Ue.ParticipantsListEventArgs(g.roomid,g.token,g.translateTo,g.profanityFilter,g.roomProfanityFilter,g.roomLocked,g.muteAll,_,n));break;case"settranslatetolanguages":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Pr.ConversationTranslatorCommandTypes.setTranslateToLanguages,a.value,n));break;case"setprofanityfiltering":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Pr.ConversationTranslatorCommandTypes.setProfanityFiltering,a.value,n));break;case"setmute":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Pr.ConversationTranslatorCommandTypes.setMute,a.value,n));break;case"setmuteall":this.privConversationServiceConnector.muteAllCommandReceived&&this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector,new Ue.MuteAllEventArgs(a.value,n));break;case"roomexpirationwarning":this.privConversationServiceConnector.conversationExpiration&&this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector,new lt.ConversationExpirationEventArgs(a.value,this.privConversationRequestSession.sessionId));break;case"setusetts":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Pr.ConversationTranslatorCommandTypes.setUseTTS,a.value,n));break;case"setlockstate":this.privConversationServiceConnector.lockRoomCommandReceived&&this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector,new Ue.LockRoomEventArgs(a.value,n));break;case"changenickname":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Pr.ConversationTranslatorCommandTypes.changeNickname,a.value,n));break;case"joinsession":let M=ts.ParticipantPayloadResponse.fromJSON(r.textBody),J={avatar:M.avatar,displayName:M.nickname,id:M.participantId,isHost:M.ishost,isMuted:M.ismuted,isUsingTts:M.usetts,preferredLanguage:M.locale};this.privConversationServiceConnector.participantJoinCommandReceived&&this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantEventArgs(J,n));break;case"leavesession":let F={id:a.participantId};this.privConversationServiceConnector.participantLeaveCommandReceived&&this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantEventArgs(F,n));break;case"disconnectsession":let ee={id:a.participantId};break;case"token":let ye=new MP.CognitiveTokenAuthentication(()=>{let V=a.token;return Promise.resolve(V)},()=>{let V=a.token;return Promise.resolve(V)});this.authentication=ye,this.privConversationServiceConnector.onToken(ye);break;default:break}break;case"partial":case"final":let c=ts.SpeechResponsePayload.fromJSON(r.textBody),u=s==="final"?lt.ResultReason.TranslatedParticipantSpeech:lt.ResultReason.TranslatingParticipantSpeech,d=new lt.ConversationTranslationResult(c.participantId,this.getTranslations(c.translations),c.language,c.id,u,c.recognition,void 0,void 0,r.textBody,void 0);c.isFinal?((d.text!==void 0&&d.text.length>0||c.id===this.privLastPartialUtteranceId)&&(o=!0),o&&this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ue.ConversationReceivedTranslationEventArgs(Pr.ConversationTranslatorMessageTypes.final,d,n))):d.text!==void 0&&(this.privLastPartialUtteranceId=c.id,this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ue.ConversationReceivedTranslationEventArgs(Pr.ConversationTranslatorMessageTypes.partial,d,n)));break;case"translated_message":let h=ts.TextResponsePayload.fromJSON(r.textBody),l=new lt.ConversationTranslationResult(h.participantId,this.getTranslations(h.translations),h.language,void 0,void 0,h.originalText,void 0,void 0,void 0,r.textBody,void 0);this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ue.ConversationReceivedTranslationEventArgs(Pr.ConversationTranslatorMessageTypes.instantMessage,l,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:"",lt.CancellationReason.Error,lt.CancellationErrorCode.RuntimeError,t),null}}configConnection(){return this.isDisposed()?Promise.resolve(void 0):this.privConnectionConfigPromise!==void 0?this.privConnectionConfigPromise.then(e=>e.state()===es.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 lt.Translations;for(let r of e)t.set(r.lang,r.translation)}return t}};dp.ConversationServiceAdapter=tf});var NP=p(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.ConversationTranslatorRecognizer=Ui.ConversationRecognizerFactory=void 0;var Pb=C(),Fi=P(),Vi=w(),rf=f(),Rb=EP(),Eb=kP(),nf=class{static fromConfig(e,t,r){return new hp(e,t,r)}};Ui.ConversationRecognizerFactory=nf;var hp=class extends rf.Recognizer{constructor(e,t,r){let n=t;Vi.Contracts.throwIfNull(n,"speechConfig");let s=e;Vi.Contracts.throwIfNull(s,"conversationImpl"),super(r,n.properties,new Rb.ConversationConnectionFactory),this.privConversation=s,this.privIsDisposed=!1,this.privProperties=n.properties.clone(),this.privConnection=rf.Connection.fromRecognizer(this),this.privProperties.getProperty(rf.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?(this.privSetTimeout=Fi.Timeout.setTimeout,this.privClearTimeout=Fi.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{Vi.Contracts.throwIfDisposed(this.privIsDisposed),Vi.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{Vi.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=>{Fi.Events.instance.onEvent(new Fi.BackgroundEvent(n))})}}sendRequest(e,t,r){try{Vi.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=>{Fi.Events.instance.onEvent(new Fi.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 Pb.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Eb.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)}};Ui.ConversationTranslatorRecognizer=hp});var qP=p(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});vp.TranscriberRecognizer=void 0;var xP=P(),vt=w(),Wi=f(),lp=C(),sf=class extends Wi.Recognizer{constructor(e,t){let r=e;vt.Contracts.throwIfNull(r,"speechTranslationConfig");let n=t;vt.Contracts.throwIfNull(n,"audioConfigImpl"),vt.Contracts.throwIfNullOrWhitespace(r.speechRecognitionLanguage,Wi.PropertyId[Wi.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new lp.TranscriberConnectionFactory),this.privDisposedRecognizer=!1,this.isMeetingRecognizer=!1}get speechRecognitionLanguage(){return vt.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Wi.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Wi.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){vt.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Wi.PropertyId.SpeechServiceAuthorization_Token,e)}set conversation(e){vt.Contracts.throwIfNullOrUndefined(e,"Conversation"),this.isMeetingRecognizer=!1,this.privConversation=e}getConversationInfo(){return vt.Contracts.throwIfNullOrUndefined(this.privConversation,"Conversation"),this.privConversation.conversationInfo}set meeting(e){vt.Contracts.throwIfNullOrUndefined(e,"Meeting"),this.isMeetingRecognizer=!0,this.privMeeting=e}getMeetingInfo(){return vt.Contracts.throwIfNullOrUndefined(this.privMeeting,"Meeting"),this.privMeeting.meetingInfo}IsMeetingRecognizer(){return this.isMeetingRecognizer}startContinuousRecognitionAsync(e,t){xP.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(lp.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;vt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendSpeechEventAsync(e,t)}async pushMeetingEvent(e,t){let r=this.privReco;vt.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 lp.RecognizerConfig(e,this.properties)}createServiceRecognizer(e,t,r,n){let s=r;return new lp.TranscriptionServiceRecognizer(e,t,s,n,this)}};vp.TranscriberRecognizer=sf});var zP=p(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});var wb=yP();Object.defineProperty(De,"ConversationManager",{enumerable:!0,get:function(){return wb.ConversationManager}});var Ib=ip();Object.defineProperty(De,"ConversationConnectionConfig",{enumerable:!0,get:function(){return Ib.ConversationConnectionConfig}});var Tb=NP();Object.defineProperty(De,"ConversationRecognizerFactory",{enumerable:!0,get:function(){return Tb.ConversationRecognizerFactory}});var _b=qP();Object.defineProperty(De,"TranscriberRecognizer",{enumerable:!0,get:function(){return _b.TranscriberRecognizer}});var Hi=Jv();Object.defineProperty(De,"ConversationReceivedTranslationEventArgs",{enumerable:!0,get:function(){return Hi.ConversationReceivedTranslationEventArgs}});Object.defineProperty(De,"LockRoomEventArgs",{enumerable:!0,get:function(){return Hi.LockRoomEventArgs}});Object.defineProperty(De,"MuteAllEventArgs",{enumerable:!0,get:function(){return Hi.MuteAllEventArgs}});Object.defineProperty(De,"ParticipantAttributeEventArgs",{enumerable:!0,get:function(){return Hi.ParticipantAttributeEventArgs}});Object.defineProperty(De,"ParticipantEventArgs",{enumerable:!0,get:function(){return Hi.ParticipantEventArgs}});Object.defineProperty(De,"ParticipantsListEventArgs",{enumerable:!0,get:function(){return Hi.ParticipantsListEventArgs}});var of=$v();Object.defineProperty(De,"ConversationTranslatorCommandTypes",{enumerable:!0,get:function(){return of.ConversationTranslatorCommandTypes}});Object.defineProperty(De,"ConversationTranslatorMessageTypes",{enumerable:!0,get:function(){return of.ConversationTranslatorMessageTypes}});Object.defineProperty(De,"InternalParticipants",{enumerable:!0,get:function(){return of.InternalParticipants}})});var cf=p(ri=>{"use strict";Object.defineProperty(ri,"__esModule",{value:!0});ri.SynthesisAudioMetadata=ri.MetadataType=void 0;var Ab;(function(i){i.WordBoundary="WordBoundary",i.Bookmark="Bookmark",i.Viseme="Viseme",i.SentenceBoundary="SentenceBoundary",i.SessionEnd="SessionEnd",i.AvatarSignal="TalkingAvatarSignal"})(Ab=ri.MetadataType||(ri.MetadataType={}));var af=class i{constructor(e){this.privSynthesisAudioMetadata=JSON.parse(e)}static fromJSON(e){return new i(e)}get Metadata(){return this.privSynthesisAudioMetadata.Metadata}};ri.SynthesisAudioMetadata=af});var LP=p(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.SynthesisStartedEvent=Ot.ConnectingToSynthesisServiceEvent=Ot.SynthesisTriggeredEvent=Ot.SpeechSynthesisEvent=void 0;var jP=P(),Ki=class extends jP.PlatformEvent{constructor(e,t,r=jP.EventType.Info){super(e,r),this.privRequestId=t}get requestId(){return this.privRequestId}};Ot.SpeechSynthesisEvent=Ki;var pf=class extends Ki{constructor(e,t,r){super("SynthesisTriggeredEvent",e),this.privSessionAudioDestinationId=t,this.privTurnAudioDestinationId=r}get audioSessionDestinationId(){return this.privSessionAudioDestinationId}get audioTurnDestinationId(){return this.privTurnAudioDestinationId}};Ot.SynthesisTriggeredEvent=pf;var uf=class extends Ki{constructor(e,t){super("ConnectingToSynthesisServiceEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};Ot.ConnectingToSynthesisServiceEvent=uf;var df=class extends Ki{constructor(e,t){super("SynthesisStartedEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};Ot.SynthesisStartedEvent=df});var BP=p(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});mp.SynthesisTurn=void 0;var fp=P(),bb=Dr(),gp=f(),Ob=cf(),hf=LP(),lf=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=fp.createNoDashGuid(),this.privTurnDeferral=new fp.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 gp.PropertyCollection;return e.setProperty(gp.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 bb.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 fp.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 gp.SpeechSynthesisResult(this.requestId,gp.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){fp.Events.instance.onEvent(e)}static isXmlTag(e){return e.length>=2&&e[0]==="<"&&e[e.length-1]===">"}updateTextOffset(e,t){t===Ob.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)}};mp.SynthesisTurn=lf});var FP=p(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});yp.SynthesisAdapterBase=void 0;var Ae=P(),We=f(),it=C(),Ji=Qr(),Sp=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 Ae.ArgumentNullError("authentication");if(!t)throw new Ae.ArgumentNullError("connectionFactory");if(!r)throw new Ae.ArgumentNullError("synthesizerConfig");this.privAuthentication=e,this.privConnectionFactory=t,this.privSynthesizerConfig=r,this.privIsDisposed=!1,this.privSessionAudioDestination=n,this.privSynthesisTurn=new it.SynthesisTurn,this.privConnectionEvents=new Ae.EventSource,this.privServiceEvents=new Ae.EventSource,this.privSynthesisContext=new it.SynthesisContext,this.privAgentConfig=new it.AgentConfig,this.connectionEvents.attach(s=>{if(s.name==="ConnectionClosedEvent"){let o=s;o.statusCode!==1e3&&this.cancelSynthesisLocal(We.CancellationReason.Error,o.statusCode===1007?We.CancellationErrorCode.BadRequestParameters:We.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"?Ae.MessageType.Text:Ae.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new Ji.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(We.CancellationReason.Error,We.CancellationErrorCode.ConnectionFailure,c),Promise.reject(c)}}async stopSpeaking(){return await this.connectImpl(),(await this.fetchConnection()).send(new Ji.SpeechConnectionMessage(Ae.MessageType.Text,"synthesis.control",this.privSynthesisTurn.requestId,"application/json",JSON.stringify({action:"stop"})))}cancelSynthesis(e,t,r,n){let s=new We.PropertyCollection;s.setProperty(it.CancellationErrorCodePropertyName,We.CancellationErrorCode[r]);let o=new We.SpeechSynthesisResult(e,We.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=Ji.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=it.SynthesisAudioMetadata.fromJSON(r.textBody).Metadata;for(let o of n)switch(o.Type){case it.MetadataType.WordBoundary:case it.MetadataType.SentenceBoundary:this.privSynthesisTurn.onTextBoundaryEvent(o);let a=new We.SpeechSynthesisWordBoundaryEventArgs(o.Data.Offset,o.Data.Duration,o.Data.text.Text,o.Data.text.Length,o.Type===it.MetadataType.WordBoundary?this.privSynthesisTurn.currentTextOffset:this.privSynthesisTurn.currentSentenceOffset,o.Data.text.BoundaryType);this.onWordBoundary(a);break;case it.MetadataType.Bookmark:let c=new We.SpeechSynthesisBookmarkEventArgs(o.Data.Offset,o.Data.Bookmark);this.onBookmarkReached(c);break;case it.MetadataType.Viseme:if(this.privSynthesisTurn.onVisemeMetadataReceived(o),o.Data.IsLastAnimation){let u=new We.SpeechSynthesisVisemeEventArgs(o.Data.Offset,o.Data.VisemeId,this.privSynthesisTurn.getAndClearVisemeAnimation());this.onVisemeReceived(u)}break;case it.MetadataType.AvatarSignal:this.onAvatarEvent(o);break;case it.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 Ae.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 Ji.SpeechConnectionMessage(Ae.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()===Ae.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()));this.privAuthFetchEventId=Ae.createNoDashGuid(),this.privConnectionId=Ae.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(We.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 Ji.SpeechConnectionMessage(Ae.MessageType.Text,"speech.config",this.privSynthesisTurn.requestId,"application/json",t))}sendSsmlMessage(e,t,r){return e.send(new Ji.SpeechConnectionMessage(Ae.MessageType.Text,"ssml",r,"application/ssml+xml",t))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===Ae.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){}};yp.SynthesisAdapterBase=Sp;Sp.telemetryDataEnabled=!0});var UP=p(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});Cp.AvatarSynthesisAdapter=void 0;var VP=f(),Mb=C(),vf=class extends Mb.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(VP.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 VP.AvatarEventArgs(e.Data.Offset,e.Data.Name);try{this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer,t)}catch{}}}};Cp.AvatarSynthesisAdapter=vf});var WP=p(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});Pp.SpeechSynthesisAdapter=void 0;var Rr=f(),Db=C(),ff=class extends Db.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 Rr.SpeechSynthesisEventArgs(new Rr.SpeechSynthesisResult(e,Rr.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 Rr.SpeechSynthesisEventArgs(new Rr.SpeechSynthesisResult(this.privSynthesisTurn.requestId,Rr.ResultReason.SynthesizingAudio,t));this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer,r)}catch{}}onSynthesisCancelled(e){if(this.privSpeechSynthesizer.SynthesisCanceled){let t=new Rr.SpeechSynthesisEventArgs(e);try{this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer,t)}catch{}}}onSynthesisCompleted(e){if(this.privSpeechSynthesizer.synthesisCompleted)try{this.privSpeechSynthesizer.synthesisCompleted(this.privSpeechSynthesizer,new Rr.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{}}};Pp.SpeechSynthesisAdapter=ff});var HP=p(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});Rp.SynthesisRestAdapter=void 0;var gf=ae(),mf=f(),kb=$e(),Nb=we(),Sf=class{constructor(e,t){let r=e.parameters.getProperty(mf.PropertyId.SpeechServiceConnection_Endpoint,void 0);if(!r){let s=e.parameters.getProperty(mf.PropertyId.SpeechServiceConnection_Region,"westus"),o=kb.ConnectionFactoryBase.getHostSuffix(s);r=e.parameters.getProperty(mf.PropertyId.SpeechServiceConnection_Host,`https://${s}.tts.speech${o}`)}this.privUri=`${r}/cognitiveservices/voices/list`;let n=gf.RestConfigBase.requestOptions;this.privRestAdapter=new gf.RestMessageAdapter(n),this.privAuthentication=t}getVoicesList(e){return this.privRestAdapter.setHeaders(Nb.HeaderNames.ConnectionId,e),this.privAuthentication.fetch(e).then(t=>(this.privRestAdapter.setHeaders(t.headerName,t.token),this.privRestAdapter.request(gf.RestRequestType.Get,this.privUri)))}};Rp.SynthesisRestAdapter=Sf});var GP=p(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.SynthesizerConfig=ii.SynthesisServiceType=void 0;var KP=C(),JP;(function(i){i[i.Standard=0]="Standard",i[i.Custom=1]="Custom"})(JP=ii.SynthesisServiceType||(ii.SynthesisServiceType={}));var yf=class{constructor(e,t){this.privSynthesisServiceType=JP.Standard,this.avatarEnabled=!1,this.privSpeechServiceConfig=e||new KP.SpeechServiceConfig(new KP.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}};ii.SynthesizerConfig=yf});var $P=p(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});Ep.SynthesisContext=void 0;var Cf=f(),Pf=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(Cf.PropertyId.SpeechServiceResponse_RequestPunctuationBoundary,!!e?.wordBoundary),sentenceBoundaryEnabled:e?.properties.getProperty(Cf.PropertyId.SpeechServiceResponse_RequestSentenceBoundary,!1),sessionEndEnabled:!0,visemeEnabled:!!e?.visemeReceived,wordBoundaryEnabled:e?.properties.getProperty(Cf.PropertyId.SpeechServiceResponse_RequestWordBoundary,!!e?.wordBoundary)},outputFormat:this.privAudioOutputFormat.requestAudioFormatString},language:{autoDetection:e?.autoDetectSourceLanguage}}}};Ep.SynthesisContext=Pf});var QP=p(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});wp.SpeakerRecognitionConfig=void 0;var xb=C(),Rf=class{constructor(e,t){this.privContext=e||new xb.Context(null),this.privParameters=t}get parameters(){return this.privParameters}get Context(){return this.privContext}};wp.SpeakerRecognitionConfig=Rf});var XP=p(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0});Tp.SpeakerServiceRecognizer=void 0;var qb=ae(),Ip=P(),Se=f(),YP=C(),zb=Qr(),Ef=class extends YP.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 Se.PropertyCollection;switch(e.messageType===Ip.MessageType.Text&&r.setProperty(Se.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 Se.SpeakerRecognitionResult(s,Se.ResultReason.Canceled,Se.CancellationErrorCode.ServiceError,s.status.reason):o=new Se.SpeakerRecognitionResult(s,Se.ResultReason.RecognizedSpeaker),this.privResultDeferral&&this.privResultDeferral.resolve(o),t=!0;break;default:break}let n=new Ip.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){if(new Se.PropertyCollection().setProperty(YP.CancellationErrorCodePropertyName,Se.CancellationErrorCode[n]),this.privResultDeferral){let a=new Se.SpeakerRecognitionResult({scenario:this.privSpeakerModel.scenario,status:{statusCode:s,reason:s}},Se.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 Ip.Deferred),this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(Se.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 qb.ReplayableAudioNode(n,s.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(a,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:o};try{await t,await r}catch(d){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Se.CancellationReason.Error,Se.CancellationErrorCode.ConnectionFailure,d)}let c=new Se.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,c),this.receiveMessage(),this.sendAudio(a).then(()=>{},d=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Se.CancellationReason.Error,Se.CancellationErrorCode.RuntimeError,d)}),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 zb.SpeechConnectionMessage(Ip.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}}};Tp.SpeakerServiceRecognizer=Ef});var eR=p(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});_p.VoiceServiceRecognizer=void 0;var jb=ae(),Mt=P(),L=f(),ZP=C(),wf=Qr(),If=class extends ZP.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privDeferralMap=new Mt.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===Mt.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 Mt.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){new L.PropertyCollection().setProperty(ZP.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 Mt.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 Mt.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 Mt.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 jb.ReplayableAudioNode(s,o.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(c,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:a};try{await r,await n}catch(h){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.ConnectionFailure,h)}let u=new L.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,u),this.receiveMessage(),this.sendAudio(c).then(()=>{},h=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.RuntimeError,h)}),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 wf.SpeechConnectionMessage(Mt.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 wf.SpeechConnectionMessage(Mt.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 Mt.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 wf.SpeechConnectionMessage(Mt.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"}};_p.VoiceServiceRecognizer=If});var tR=p(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.type=pe.connectivity=pe.Device=pe.OS=pe.System=pe.Context=pe.SpeechServiceConfig=void 0;var Tf=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()}};pe.SpeechServiceConfig=Tf;var _f=class{constructor(e){this.system=new Ap,this.os=e}};pe.Context=_f;var Ap=class{constructor(){let e="1.36.0";this.name="SpeechSDK",this.version=e,this.build="JavaScript",this.lang="JavaScript"}};pe.System=Ap;var Af=class{constructor(e,t,r){this.platform=e,this.name=t,this.version=r}};pe.OS=Af;var bf=class{constructor(e,t,r){this.manufacturer=e,this.model=t,this.version=r}};pe.Device=bf;var Lb;(function(i){i.Bluetooth="Bluetooth",i.Wired="Wired",i.WiFi="WiFi",i.Cellular="Cellular",i.InBuilt="InBuilt",i.Unknown="Unknown"})(Lb=pe.connectivity||(pe.connectivity={}));var Bb;(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"})(Bb=pe.type||(pe.type={}))});var C=p(m=>{"use strict";var Fb=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)&&Fb(e,i,t)};Object.defineProperty(m,"__esModule",{value:!0});m.AutoDetectSourceLanguagesOpenRangeOptionName=m.ForceDictationPropertyName=m.ServicePropertiesPropertyName=m.CancellationErrorCodePropertyName=m.OutputFormatPropertyName=void 0;R(om(),m);R(um(),m);R(Fs(),m);R(hm(),m);R(vm(),m);R(pC(),m);R(lC(),m);R(Sc(),m);R(fC(),m);R(gC(),m);R(SC(),m);R(CC(),m);R(RC(),m);R(TC(),m);R(bC(),m);R(kC(),m);R(zC(),m);R(bl(),m);R(jC(),m);R(LC(),m);R(FC(),m);R(VC(),m);R(UC(),m);R(HC(),m);R(KC(),m);R(JC(),m);R(GC(),m);R($C(),m);R(QC(),m);R(XC(),m);R(ZC(),m);R(eP(),m);R(tP(),m);R(iP(),m);R(nP(),m);R(oP(),m);R(pP(),m);R(uP(),m);R(dP(),m);R(lP(),m);R(mP(),m);R(SP(),m);R(zP(),m);R(cf(),m);R(BP(),m);R(FP(),m);var Vb=UP();Object.defineProperty(m,"AvatarSynthesisAdapter",{enumerable:!0,get:function(){return Vb.AvatarSynthesisAdapter}});var Ub=WP();Object.defineProperty(m,"SpeechSynthesisAdapter",{enumerable:!0,get:function(){return Ub.SpeechSynthesisAdapter}});R(HP(),m);R(GP(),m);R($P(),m);R(QP(),m);R(XP(),m);R(eR(),m);R(tR(),m);m.OutputFormatPropertyName="OutputFormat";m.CancellationErrorCodePropertyName="CancellationErrorCode";m.ServicePropertiesPropertyName="ServiceProperties";m.ForceDictationPropertyName="ForceDictation";m.AutoDetectSourceLanguagesOpenRangeOptionName="OpenRange"});var rR=p(ni=>{"use strict";var Wb=ni&&ni.__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]}),Hb=ni&&ni.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&Wb(e,i,t)};Object.defineProperty(ni,"__esModule",{value:!0});var Kb=C();new Kb.AgentConfig;Hb(f(),ni)});function JR(i){return typeof i=="function"}function rn(i){return JR(i)?i():i}var tg=!0;function nn(i){let{audioConfig:e,authorizationToken:t,enableTelemetry:r,looseEvent:n,referenceGrammars:s,region:o="westus",speechRecognitionEndpointId:a,subscriptionKey:c,textNormalization:u}=i,{credentials:d,looseEvents:h}=i;if(typeof n<"u"&&(console.warn('web-speech-cognitive-services: The option "looseEvent" should be named as "looseEvents".'),h=n),!d){if(!t&&!c)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."),d=async()=>typeof i.authorizationToken<"u"?{authorizationToken:await rn(i.authorizationToken),region:o}:{region:o,subscriptionKey:await rn(i.subscriptionKey)}}return Object.freeze({audioConfig:e,enableTelemetry:r,fetchCredentials:async()=>{let{authorizationToken:l,customVoiceHostname:g,region:_,speechRecognitionHostname:M,speechSynthesisHostname:J,subscriptionKey:F}=await rn(d);if(!l&&!F||l&&F)throw new Error('web-speech-cognitive-services: Either "authorizationToken" or "subscriptionKey" must be provided.');if(!_&&!(M&&J))throw new Error('web-speech-cognitive-services: Either "region" or "speechRecognitionHostname" and "speechSynthesisHostname" must be set.');if(_&&(g||M||J))throw new Error('web-speech-cognitive-services: Only either "region" or "customVoiceHostname", "speechRecognitionHostname" and "speechSynthesisHostname" can be set.');if(l){if(typeof l!="string")throw new Error('web-speech-cognitive-services: "authorizationToken" must be a string.')}else if(typeof F!="string")throw new Error('web-speech-cognitive-services: "subscriptionKey" must be a string.');return tg&&F&&(console.warn("web-speech-cognitive-services: In production environment, subscription key should not be used, authorization token should be used instead."),tg=!1),{...typeof l<"u"?{authorizationToken:l}:{subscriptionKey:F},...typeof _<"u"?{region:_}:{customVoiceHostname:g,speechRecognitionHostname:M,speechSynthesisHostname:J}}},looseEvents:!!h,referenceGrammars:s&&Object.freeze([...s]),speechRecognitionEndpointId:a,textNormalization:u})}var Dt=eg(rR()),Gi={AudioConfig:Dt.AudioConfig,OutputFormat:Dt.OutputFormat,ResultReason:Dt.ResultReason,SpeechConfig:Dt.SpeechConfig,SpeechRecognizer:Dt.SpeechRecognizer};function rs(){let i={};return i.promise=new Promise((e,t)=>{i.resolve=e,i.reject=t}),i}function iR(){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=rs())).promise}}var $i=class{constructor({confidence:e,transcript:t}){this.#t=e,this.#e=t}#t;#e;get confidence(){return this.#t}get transcript(){return this.#e}};var si=class{constructor(e){if(!e)throw new Error("array must be set.");this.#t=e;for(let t in e)Object.defineProperty(this,t,{enumerable:!0,get(){return e[t]}})}#t;[Symbol.iterator](){return this.#t[Symbol.iterator]()}get length(){return this.#t.length}};var oi=class extends si{constructor(e){super(e.results),this.#t=e.isFinal}#t;get isFinal(){return this.#t}};var{ResultReason:{RecognizingSpeech:Jb,RecognizedSpeech:Of}}=Gi;function Mf(i,e){let{maxAlternatives:t=1/0,textNormalization:r="display"}=e||{},n=typeof i.json=="string"?JSON.parse(i.json):i.json;return i.reason===Jb||i.reason===Of&&!n.NBest?new oi({isFinal:i.reason===Of,results:[new $i({confidence:.5,transcript:i.text})]}):i.reason===Of?new oi({isFinal:!0,results:(n.NBest||[]).slice(0,t).map(({Confidence:s,Display:o,ITN:a,Lexical:c,MaskedITN:u})=>new $i({confidence:s,transcript:r==="itn"?a:r==="lexical"?c:r==="maskeditn"?u:o}))}):new oi({isFinal:!1,results:[]})}function Qi(i,e=void 0){return(...t)=>new Promise((r,n)=>i.apply(e,[...t,r,n]))}var is=class{constructor(e){this.#t=e,this.#e={}}#t;#e;getProperty(e){return this.#e[e]}setProperty(e,t){let r=this.#e[e];r&&this.#t.removeEventListener(e,r),t&&this.#t.addEventListener(e,t),this.#e[e]=t}};var nR=eg(nu());function Df(i){let e=Array.from(new Int16Array(i));return e.reduce((t,r)=>t+Math.abs(r),0)/e.length}function kf(i){let e=i,t=e.attach,r=e.attach.bind(e),n=!1,s=!1;return e.attach=async()=>{let o=await r("");return{...o,read:async()=>{let a=await o.read();return!n&&Df(a.buffer)>150&&(e.events.onEvent(new nR.AudioSourceEvent("FirstAudibleChunk","")),n=!0),s?{buffer:new ArrayBuffer(0),isEnd:!0,timeReceived:Date.now()}:a}}},{audioConfig:i,pause:()=>{s=!0},unprepare:()=>{e.attach=t}}}function bp({duration:i,errorDetails:e,json:t,offset:r,properties:n,reason:s,resultId:o,text:a}){return Object.freeze({duration:i,errorDetails:e,json:t&&JSON.parse(t),offset:r,properties:n,reason:s,resultId:o,text:a})}var ai=class{constructor(){this.#t=[]}addFromString(){throw new Error("JSGF is not supported")}#t;get phrases(){return this.#t}set phrases(e){if(Array.isArray(e))this.#t=Object.freeze([...e]);else if(typeof e=="string")this.#t=Object.freeze([e]);else throw new Error("The provided value is not an array or of type 'string'")}};var kt=class extends Event{constructor(e,{error:t,message:r}){super(e),this.#t=t,this.#e=r}#t;#e;get error(){return this.#t}get message(){return this.#e}get type(){return"error"}};var Nt=class extends si{constructor(e){super(e)}};var W=class extends Event{constructor(e,{data:t,resultIndex:r,results:n}={}){super(e),this.#t=t,this.#e=r,this.#r=n||new Nt([])}#t;#e;#r;get data(){return this.#t}get resultIndex(){return this.#e}get results(){return this.#r}get type(){return super.type}};var{ResultReason:Gb,SpeechRecognizer:$b}=Gi;function Zt({createRecognizer:i,enableTelemetry:e,looseEvents:t,referenceGrammars:r,textNormalization:n}){$b.enableTelemetry(e!==!1);class s extends EventTarget{#t=!1;#e=new is(this);#r=new ai;#i=!1;#n=typeof window<"u"?window.document.documentElement.getAttribute("lang")||window.navigator.language:"en-US";#s=1;emitCognitiveServices(a,c){this.dispatchEvent(new W("cognitiveservices",{data:{...c,type:a}}))}get continuous(){return this.#t}set continuous(a){this.#t=a}get grammars(){return this.#r}set grammars(a){if(a instanceof ai)this.#r=a;else throw new Error("The provided value is not of type 'SpeechGrammarList'")}get interimResults(){return this.#i}set interimResults(a){this.#i=a}get maxAlternatives(){return this.#s}set maxAlternatives(a){this.#s=a}get lang(){return this.#n}set lang(a){this.#n=a}get onaudioend(){return this.#e.getProperty("audioend")}set onaudioend(a){this.#e.setProperty("audioend",a)}get onaudiostart(){return this.#e.getProperty("audiostart")}set onaudiostart(a){this.#e.setProperty("audiostart",a)}get oncognitiveservices(){return this.#e.getProperty("cognitiveservices")}set oncognitiveservices(a){this.#e.setProperty("cognitiveservices",a)}get onend(){return this.#e.getProperty("end")}set onend(a){this.#e.setProperty("end",a)}get onerror(){return this.#e.getProperty("error")}set onerror(a){this.#e.setProperty("error",a)}get onresult(){return this.#e.getProperty("result")}set onresult(a){this.#e.setProperty("result",a)}get onsoundend(){return this.#e.getProperty("soundend")}set onsoundend(a){this.#e.setProperty("soundend",a)}get onsoundstart(){return this.#e.getProperty("soundstart")}set onsoundstart(a){this.#e.setProperty("soundstart",a)}get onspeechend(){return this.#e.getProperty("speechend")}set onspeechend(a){this.#e.setProperty("speechend",a)}get onspeechstart(){return this.#e.getProperty("speechstart")}set onspeechstart(a){this.#e.setProperty("speechstart",a)}get onstart(){return this.#e.getProperty("start")}set onstart(a){this.#e.setProperty("start",a)}abort;stop;start(){this._startOnce().catch(a=>{this.dispatchEvent(new kt("error",{error:a,message:a&&(a.stack||a.message)}))})}async _startOnce(){let a=await i(this.lang),{pause:c,unprepare:u}=kf(a.audioConfig);try{let d=iR(),h,l,g,{detach:_}=a.audioConfig.events.attach(V=>{let{name:G}=V;G==="AudioSourceReadyEvent"?d.push({audioSourceReady:{}}):G==="AudioSourceOffEvent"?d.push({audioSourceOff:{}}):G==="FirstAudibleChunk"&&d.push({firstAudibleChunk:{}})});a.canceled=(V,{errorDetails:G,offset:nt,reason:wr,sessionId:qp})=>{d.push({canceled:{errorDetails:G,offset:nt,reason:wr,sessionId:qp}})},a.recognized=(V,{offset:G,result:nt,sessionId:wr})=>{d.push({recognized:{offset:G,result:bp(nt),sessionId:wr}})},a.recognizing=(V,{offset:G,result:nt,sessionId:wr})=>{d.push({recognizing:{offset:G,result:bp(nt),sessionId:wr}})},a.sessionStarted=(V,{sessionId:G})=>{d.push({sessionStarted:{sessionId:G}})},a.sessionStopped=(V,{sessionId:G})=>{d.push({sessionStopped:{sessionId:G}})},a.speechStartDetected=(V,{offset:G,sessionId:nt})=>{d.push({speechStartDetected:{offset:G,sessionId:nt}})},a.speechEndDetected=(V,{sessionId:G})=>{d.push({speechEndDetected:{sessionId:G}})};let{phrases:M}=this.grammars,{dynamicGrammar:J}=a.privReco;r&&r.length&&J.addReferenceGrammar([...r]),M&&M.length&&J.addPhrase([...M]),await Qi(a.startContinuousRecognitionAsync,a)(),typeof a.stopContinuousRecognitionAsync=="function"?(this.abort=()=>d.push({abort:{}}),this.stop=()=>d.push({stop:{}})):this.abort=this.stop=void 0;let F,ee,ye=[];for(let V=0;!g||F;V++){let G=await d.shift(),{abort:nt,audioSourceOff:wr,audioSourceReady:qp,canceled:Xf,firstAudibleChunk:LR,recognized:ci,recognizing:zp,stop:BR}=G;Object.keys(G).forEach(tn=>this.emitCognitiveServices(tn,G[tn]));let jp=Xf&&Xf.errorDetails;if(/Permission\sdenied/u.test(jp||"")){ee=new kt("error",{error:"not-allowed"});break}if(V||this.dispatchEvent(new W("start")),jp){/1006/u.test(jp)?(F||(this.dispatchEvent(new W("audiostart")),this.dispatchEvent(new W("audioend"))),ee=new kt("error",{error:"network"})):ee=new kt("error",{error:"unknown"});break}else if(nt||BR)nt?(ee=new kt("error",{error:"aborted"}),g="abort"):(c(),g="stop"),nt&&a.stopContinuousRecognitionAsync&&await Qi(a.stopContinuousRecognitionAsync,a)();else if(qp)this.dispatchEvent(new W("audiostart")),F=!0;else if(LR)this.dispatchEvent(new W("soundstart")),h=!0;else if(wr){l&&this.dispatchEvent(new W("speechend")),h&&this.dispatchEvent(new W("soundend")),F&&this.dispatchEvent(new W("audioend")),F=h=l=!1;break}else if(g!=="abort"){if(ci&&ci.result&&ci.result.reason===Gb.NoMatch){if(!this.continuous||g==="stop"){ee=new W("result",{results:new Nt(ye)}),a.stopContinuousRecognitionAsync&&await Qi(a.stopContinuousRecognitionAsync,a)();break}}else if(ci||zp)if(F||(this.dispatchEvent(new W("audiostart")),F=!0),h||(this.dispatchEvent(new W("soundstart")),h=!0),l||(this.dispatchEvent(new W("speechstart")),l=!0),ci){let tn=Mf(ci.result,{maxAlternatives:this.maxAlternatives,textNormalization:n}),Lp=!!tn[0]?.transcript;Lp&&(ye=[...ye,tn],this.continuous&&this.dispatchEvent(new W("result",{results:new Nt(ye)}))),this.continuous&&Lp?ee=void 0:ee=new W("result",{results:new Nt(ye)}),(!this.continuous||g==="stop")&&a.stopContinuousRecognitionAsync&&await Qi(a.stopContinuousRecognitionAsync,a)(),t&&ee&&Lp&&(this.dispatchEvent(ee),ee=void 0)}else zp&&this.interimResults&&this.dispatchEvent(new W("result",{results:new Nt([...ye,Mf(zp.result,{maxAlternatives:this.maxAlternatives,textNormalization:n})])}))}}l&&this.dispatchEvent(new W("speechend")),h&&this.dispatchEvent(new W("soundend")),F&&this.dispatchEvent(new W("audioend")),ee&&(ee.type==="result"&&!ee.results.length&&(ee=new kt("error",{error:"no-speech"})),this.dispatchEvent(ee)),this.dispatchEvent(new W("end")),_()}catch(d){throw console.error(d),d}finally{u(),a.dispose(!1)}}}return{SpeechGrammarList:ai,SpeechRecognition:s,SpeechRecognitionEvent:W}}var{AudioConfig:Qb,OutputFormat:Yb,SpeechConfig:Op,SpeechRecognizer:Xb}=Gi;function Mp(i){let{audioConfig:e=Qb.fromDefaultMicrophoneInput(),enableTelemetry:t=!0,fetchCredentials:r,looseEvents:n,referenceGrammars:s,speechRecognitionEndpointId:o,textNormalization:a="display"}=nn(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."),{}):Zt({createRecognizer:async u=>{let d=await r(),h;if(typeof d.speechRecognitionHostname<"u"){let l=new URL("wss://hostname:443");l.hostname=d.speechRecognitionHostname,d.authorizationToken?(h=Op.fromHost(l),h.authorizationToken=d.authorizationToken):h=Op.fromHost(l,d.subscriptionKey)}else h=typeof d.authorizationToken<"u"?Op.fromAuthorizationToken(d.authorizationToken,d.region):Op.fromSubscription(d.subscriptionKey,d.region);return o&&(h.endpointId=o),h.outputFormat=Yb.Detailed,h.speechRecognitionLanguage=u||"en-US",new Xb(h,e)},enableTelemetry:t,looseEvents:n,referenceGrammars:s,textNormalization:a})}var Nf=Mp;function Lf(i,e,...t){if(!i)throw new TypeError(fR(e,t))}function fR(i,e){let t=0;return i.replace(/%[os]/gu,()=>gR(e[t++]))}function gR(i){return typeof i!="object"||i===null?String(i):Object.prototype.toString.call(i)}var sR;function Zb(i){try{let e=i instanceof Error?i:new Error(gR(i));if(sR){sR(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 ft=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,oR;var gt=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{if(oR){oR({...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{}}},eO=new gt("W01","Unable to initialize event under dispatching."),tO=new gt("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),rO=new gt("W03","Assigning any truthy value to 'returnValue' property has no effect."),iO=new gt("W04","Unable to preventDefault on non-cancelable events."),nO=new gt("W05","Unable to preventDefault inside passive event listener invocation."),sO=new gt("W06","An event listener wasn't added because it has been added already: %o, %o"),xf=new gt("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),aR=new gt("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),oO=new gt("W09","Event attribute handler must be a function: %o"),He=class{static get NONE(){return cR}static get CAPTURING_PHASE(){return pR}static get AT_TARGET(){return uR}static get BUBBLING_PHASE(){return dR}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let r=t??{};jf.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 se(this).type}get target(){return se(this).target}get srcElement(){return se(this).target}get currentTarget(){return se(this).currentTarget}composedPath(){let e=se(this).currentTarget;return e?[e]:[]}get NONE(){return cR}get CAPTURING_PHASE(){return pR}get AT_TARGET(){return uR}get BUBBLING_PHASE(){return dR}get eventPhase(){return se(this).dispatchFlag?2:0}stopPropagation(){se(this).stopPropagationFlag=!0}get cancelBubble(){return se(this).stopPropagationFlag}set cancelBubble(e){e?se(this).stopPropagationFlag=!0:tO.warn()}stopImmediatePropagation(){let e=se(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return se(this).bubbles}get cancelable(){return se(this).cancelable}get returnValue(){return!se(this).canceledFlag}set returnValue(e){e?rO.warn():hR(se(this))}preventDefault(){hR(se(this))}get defaultPrevented(){return se(this).canceledFlag}get composed(){return se(this).composed}get isTrusted(){return!1}get timeStamp(){return se(this).timeStamp}initEvent(e,t=!1,r=!1){let n=se(this);if(n.dispatchFlag){eO.warn();return}jf.set(this,{...n,type:String(e),bubbles:!!t,cancelable:!!r,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},cR=0,pR=1,uR=2,dR=3,jf=new WeakMap;function se(i,e="this"){let t=jf.get(i);return Lf(t!=null,"'%s' must be an object that Event constructor created, but got another one: %o",e,i),t}function hR(i){if(i.inPassiveListenerFlag){nO.warn();return}if(!i.cancelable){iO.warn();return}i.canceledFlag=!0}Object.defineProperty(He,"NONE",{enumerable:!0});Object.defineProperty(He,"CAPTURING_PHASE",{enumerable:!0});Object.defineProperty(He,"AT_TARGET",{enumerable:!0});Object.defineProperty(He,"BUBBLING_PHASE",{enumerable:!0});var qf=Object.getOwnPropertyNames(He.prototype);for(let i=0;i<qf.length;++i)qf[i]!=="constructor"&&Object.defineProperty(He.prototype,qf[i],{enumerable:!0});typeof ft<"u"&&typeof ft.Event<"u"&&Object.setPrototypeOf(He.prototype,ft.Event.prototype);function aO(i){return ft.DOMException?new ft.DOMException(i,"InvalidStateError"):(Yi==null&&(Yi=class mR extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,mR)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(Yi.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),vR(Yi),vR(Yi.prototype)),new Yi(i))}var Yi,lR={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 vR(i){let e=Object.keys(lR);for(let t=0;t<e.length;++t){let r=e[t],n=lR[r];Object.defineProperty(i,r,{get(){return n},configurable:!0,enumerable:!0})}}var Zi=class extends He{static wrap(e){return new(yR(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),SR.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,CR(e,n))}}stopPropagation(){super.stopPropagation();let{original:e}=Er(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;let{original:t}=Er(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:e}=Er(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;let{original:t}=Er(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();let{original:e}=Er(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){let{original:e}=Er(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},SR=new WeakMap;function Er(i){let e=SR.get(i);return Lf(e!=null,"'this' is expected an Event object, but got",i),e}var Dp=new WeakMap;Dp.set(Object.prototype,Zi);typeof ft<"u"&&typeof ft.Event<"u"&&Dp.set(ft.Event.prototype,Zi);function yR(i){let e=Object.getPrototypeOf(i);if(e==null)return Zi;let t=Dp.get(e);return t==null&&(t=cO(yR(e),e),Dp.set(e,t)),t}function cO(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],CR(e,r[n]));return t}function CR(i,e){let t=Object.getOwnPropertyDescriptor(i,e);return{get(){let r=Er(this).original,n=r[e];return typeof n=="function"?n.bind(r):n},set(r){let n=Er(this).original;n[e]=r},configurable:t.configurable,enumerable:t.enumerable}}function pO(i,e,t,r,n,s){return{callback:i,flags:(e?1:0)|(t?2:0)|(r?4:0),signal:n,signalListener:s}}function uO(i){i.flags|=8}function PR(i){return(i.flags&1)===1}function RR(i){return(i.flags&2)===2}function ER(i){return(i.flags&4)===4}function dO(i){return(i.flags&8)===8}function hO({callback:i},e,t){try{typeof i=="function"?i.call(e,t):typeof i.handleEvent=="function"&&i.handleEvent(t)}catch(r){Zb(r)}}function wR({listeners:i},e,t){for(let r=0;r<i.length;++r)if(i[r].callback===e&&PR(i[r])===t)return r;return-1}function IR(i,e,t,r,n,s){let o;s&&(o=Bf.bind(null,i,e,t),s.addEventListener("abort",o));let a=pO(e,t,r,n,s,o);return i.cow?(i.cow=!1,i.listeners=[...i.listeners,a]):i.listeners.push(a),a}function Bf(i,e,t){let r=wR(i,e,t);return r!==-1?TR(i,r):!1}function TR(i,e,t=!1){let r=i.listeners[e];return uO(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 lO(){return Object.create(null)}function _R(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 er=class{constructor(){AR.set(this,lO())}addEventListener(e,t,r){let n=Xi(this),{callback:s,capture:o,once:a,passive:c,signal:u,type:d}=vO(e,t,r);if(s==null||u?.aborted)return;let h=_R(n,d),l=wR(h,s,o);if(l!==-1){gO(h.listeners[l],c,a,u);return}IR(h,s,o,c,a,u)}removeEventListener(e,t,r){let n=Xi(this),{callback:s,capture:o,type:a}=fO(e,t,r),c=n[a];s!=null&&c&&Bf(c,s,o)}dispatchEvent(e){let t=Xi(this)[String(e.type)];if(t==null)return!0;let r=e instanceof He?e:Zi.wrap(e),n=se(r,"event");if(n.dispatchFlag)throw aO("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(!dO(c)&&(ER(c)&&TR(t,a,!s)&&(a-=1),n.inPassiveListenerFlag=RR(c),hO(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}},AR=new WeakMap;function Xi(i,e="this"){let t=AR.get(i);return Lf(t!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",e,i),t}function vO(i,e,t){var r;return bR(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 fO(i,e,t){return bR(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 bR(i){if(!(typeof i=="function"||typeof i=="object"&&i!==null&&typeof i.handleEvent=="function")){if(i==null||typeof i=="object"){aR.warn(i);return}throw new TypeError(fR(aR.message,[i]))}}function gO(i,e,t,r){sO.warn(PR(i)?"capture":"bubble",i.callback),RR(i)!==e&&xf.warn("passive"),ER(i)!==t&&xf.warn("once"),i.signal!==r&&xf.warn("signal")}var zf=Object.getOwnPropertyNames(er.prototype);for(let i=0;i<zf.length;++i)zf[i]!=="constructor"&&Object.defineProperty(er.prototype,zf[i],{enumerable:!0});typeof ft<"u"&&typeof ft.EventTarget<"u"&&Object.setPrototypeOf(er.prototype,ft.EventTarget.prototype);function xt(i,e){var t,r;return(r=(t=Xi(i,"target")[e])===null||t===void 0?void 0:t.attrCallback)!==null&&r!==void 0?r:null}function qt(i,e,t){t!=null&&typeof t!="function"&&oO.warn(t),typeof t=="function"||typeof t=="object"&&t!==null?mO(i,e,t):SO(i,e)}function mO(i,e,t){let r=_R(Xi(i,"target"),String(e));r.attrCallback=t,r.attrListener==null&&(r.attrListener=IR(r,yO(r),!1,!1,!1,void 0))}function SO(i,e){let r=Xi(i,"target")[String(e)];r&&r.attrListener&&(Bf(r,r.attrListener.callback,!1),r.attrCallback=r.attrListener=void 0)}function yO(i){return function(e){let t=i.attrCallback;typeof t=="function"&&t.call(this,e)}}function OR(i){return!!((typeof i=="function"||typeof i=="object")&&i&&"then"in i&&typeof i.then=="function")}function Ff(i,e){return new Promise(t=>{try{let r=i.call(e);OR(r)?r.then(t,()=>t(void 0)):t(r)}catch{t(void 0)}})}var MR=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function CO(i,e){return!!(i===e||MR(i)&&MR(e))}function PO(i,e){if(i.length!==e.length)return!1;for(var t=0;t<i.length;t++)if(!CO(i[t],e[t]))return!1;return!0}function DR(i,e){e===void 0&&(e=PO);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 kp=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 Np=class{constructor({audioContext:i,ponyfill:e}){this.consumer=null,this.paused=!1,this.queue=[],this.getAudioContext=DR(()=>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 kp(this.getAudioContext()),await this.consumer.start(this.queue),this.consumer=null}stop(){this.queue.splice(0),this.consumer&&this.consumer.stop()}};var tr=class extends He{constructor(e){super(e)}};function kR(){let i={};return i.promise=new Promise((e,t)=>{i.reject=t,i.resolve=e}),i}var Vf=class{constructor(){this.#t=i=>{let e=this.#e.shift();e&&e.resolve(i),this.#r&&(this.#r.resolve(i),this.#r=void 0)}}#t;#e=[];#r=void 0;get eventListener(){return this.#t}[Symbol.iterator](){return{next:()=>({done:!1,value:this.upcoming()})}}one(){let i=kR();return this.#e.push(i),i.promise}upcoming(){return this.#r||(this.#r=kR()),this.#r.promise}};var NR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ss=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(ns=0;ns<NR.length;ns++)ss[NR.charCodeAt(ns)]=ns;var ns;var xR=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),d=new Uint8Array(u);for(r=0;r<t;r+=4)s=ss[i.charCodeAt(r)],o=ss[i.charCodeAt(r+1)],a=ss[i.charCodeAt(r+2)],c=ss[i.charCodeAt(r+3)],d[n++]=s<<2|o>>4,d[n++]=(o&15)<<4|a>>2,d[n++]=(a&3)<<6|c&63;return u};function Uf(i){let e=Math.round((i-1)*100);return e>=0&&(e="+"+e),e+"%"}function Wf({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 Ze.ConnectionMessage(e.messageType,s,n,e.id))}else if(e.messageType===Ze.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 Ze.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 Ze.Deferred;try{if(e.messageType===Ze.MessageType.Text){let r=`${this.makeHeaders(e)}${CC}${e.textBody?e.textBody:""}`;t.resolve(new Ze.RawWebsocketMessage(Ze.MessageType.Text,r,e.id))}else if(e.messageType===Ze.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 d=new Int8Array(n);c.set(d,2+a)}let u=c.buffer;t.resolve(new Ze.RawWebsocketMessage(Ze.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]}${CC}`);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}};Tc.WebsocketMessageFormatter=ev});var IC=p(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});_c.SpeechConnectionFactory=void 0;var RC=ae(),EC=C(),gr=f(),wC=$e(),tv=C(),DA=we(),Yr=Wt(),rv=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(gr.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(gr.PropertyId.SpeechServiceConnection_Region,void 0),o=wC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(gr.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(gr.PropertyId.SpeechServiceConnection_EndpointId,void 0),d=e.parameters.getProperty(gr.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(u?(!n||n.search(Yr.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[Yr.QueryParameterNames.CustomSpeechDeploymentId]=u):d&&(!n||n.search(Yr.QueryParameterNames.Language)===-1)&&(c[Yr.QueryParameterNames.Language]=d),(!n||n.search(Yr.QueryParameterNames.Format)===-1)&&(c[Yr.QueryParameterNames.Format]=e.parameters.getProperty(EC.OutputFormatPropertyName,gr.OutputFormat[gr.OutputFormat.Simple]).toLowerCase()),e.autoDetectSourceLanguages!==void 0&&(c[Yr.QueryParameterNames.EnableLanguageId]="true"),this.setCommonUrlParams(e,c,n),!n)switch(e.recognitionMode){case tv.RecognitionMode.Conversation:e.parameters.getProperty(EC.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 tv.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 h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[DA.HeaderNames.ConnectionId]=r;let l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new RC.WebsocketConnection(n,c,h,new tv.WebsocketMessageFormatter,RC.ProxyInfo.fromRecognizerConfig(e),l,r),_=g.uri;return e.parameters.setProperty(gr.PropertyId.SpeechServiceConnection_Url,_),g}};_c.SpeechConnectionFactory=rv});var AC=p(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});Ac.ConversationTranscriberConnectionFactory=void 0;var TC=ae(),Fe=f(),kA=C(),_C=$e(),NA=C(),xA=we(),et=Wt(),iv=class extends _C.ConnectionFactoryBase{constructor(){super(...arguments),this.universalUri="/speech/universal/v2"}create(e,t,r){let n=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_Region,void 0),o=_C.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_EndpointId,void 0),d=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);u?(!n||n.search(et.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[et.QueryParameterNames.CustomSpeechDeploymentId]=u):d&&(!n||n.search(et.QueryParameterNames.Language)===-1)&&(c[et.QueryParameterNames.Language]=d),e.autoDetectSourceLanguages!==void 0&&(c[et.QueryParameterNames.EnableLanguageId]="true"),this.setV2UrlParams(e,c,n),n||(n=`${a}${this.universalUri}`);let h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[xA.HeaderNames.ConnectionId]=r;let l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new TC.WebsocketConnection(n,c,h,new NA.WebsocketMessageFormatter,TC.ProxyInfo.fromRecognizerConfig(e),l,r),_=g.uri;return e.parameters.setProperty(Fe.PropertyId.SpeechServiceConnection_Url,_),g}setV2UrlParams(e,t,r){new Map([[Fe.PropertyId.Speech_SegmentationSilenceTimeoutMs,et.QueryParameterNames.SegmentationSilenceTimeoutMs],[Fe.PropertyId.SpeechServiceConnection_EnableAudioLogging,et.QueryParameterNames.EnableAudioLogging],[Fe.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,et.QueryParameterNames.EndSilenceTimeoutMs],[Fe.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,et.QueryParameterNames.InitialSilenceTimeoutMs],[Fe.PropertyId.SpeechServiceResponse_PostProcessingOption,et.QueryParameterNames.Postprocessing],[Fe.PropertyId.SpeechServiceResponse_ProfanityOption,et.QueryParameterNames.Profanity],[Fe.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,et.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(kA.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}};Ac.ConversationTranscriberConnectionFactory=iv});var DC=p(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.TranscriberConnectionFactory=void 0;var bC=ae(),Ve=f(),OC=$e(),MC=C(),qA=we(),Xn=Wt(),nv=class extends OC.ConnectionFactoryBase{constructor(){super(...arguments),this.multiaudioRelativeUri="/speech/recognition/multiaudio"}create(e,t,r){let n=e.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_Region,"centralus"),o=OC.ConnectionFactoryBase.getHostSuffix(s),a="wss://transcribe."+s+".cts.speech"+o+this.multiaudioRelativeUri,c=e.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_Host,a),u={};this.setQueryParams(u,e,n),n||(n=c);let d={};t.token!==void 0&&t.token!==""&&(d[t.headerName]=t.token),d[qA.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Ve.PropertyId.SpeechServiceConnection_Url,n);let h=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new bC.WebsocketConnection(n,u,d,new MC.WebsocketMessageFormatter,bC.ProxyInfo.fromRecognizerConfig(e),h,r)}setQueryParams(e,t,r){let n=t.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_EndpointId,void 0),s=t.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);n&&!(Xn.QueryParameterNames.CustomSpeechDeploymentId in e)&&(e[Xn.QueryParameterNames.CustomSpeechDeploymentId]=n),s&&!(Xn.QueryParameterNames.Language in e)&&(e[Xn.QueryParameterNames.Language]=s);let o=t.parameters.getProperty(Ve.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true",a=t.parameters.getProperty(MC.OutputFormatPropertyName,Ve.OutputFormat[Ve.OutputFormat.Simple])!==Ve.OutputFormat[Ve.OutputFormat.Simple];(o||a)&&(e[Xn.QueryParameterNames.Format]=Ve.OutputFormat[Ve.OutputFormat.Detailed].toLowerCase()),this.setCommonUrlParams(t,e,r)}};bc.TranscriberConnectionFactory=nv});var qC=p(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.TranslationConnectionFactory=void 0;var kC=ae(),zA=Jh(),$t=f(),NC=$e(),sv=C(),jA=we(),xC=Wt(),ov=class extends NC.ConnectionFactoryBase{create(e,t,r){let n=this.getEndpointUrl(e),s={};e.autoDetectSourceLanguages!==void 0&&(s[xC.QueryParameterNames.EnableLanguageId]="true"),this.setQueryParams(s,e,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[jA.HeaderNames.ConnectionId]=r,e.parameters.setProperty($t.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new kC.WebsocketConnection(n,s,o,new sv.WebsocketMessageFormatter,kC.ProxyInfo.fromRecognizerConfig(e),a,r)}getEndpointUrl(e,t){let r=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Region),n=NC.ConnectionFactoryBase.getHostSuffix(r),s=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Endpoint,void 0);return s||(e.autoDetectSourceLanguages!==void 0?s=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Host,"wss://{region}.stt.speech"+n)+"/speech/universal/v2":s=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Host,"wss://{region}.s2s.speech"+n)+"/speech/translation/cognitiveservices/v1"),t===!0?s:zA.StringUtils.formatString(s,{region:r})}setQueryParams(e,t,r){e.from=t.parameters.getProperty($t.PropertyId.SpeechServiceConnection_RecoLanguage),e.to=t.parameters.getProperty($t.PropertyId.SpeechServiceConnection_TranslationToLanguages),e.scenario=t.recognitionMode===sv.RecognitionMode.Interactive?"interactive":t.recognitionMode===sv.RecognitionMode.Conversation?"conversation":"",this.setCommonUrlParams(t,e,r),this.setUrlParameter($t.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,xC.QueryParameterNames.StableTranslation,t,e,r);let n=t.parameters.getProperty($t.PropertyId.SpeechServiceConnection_TranslationVoice,void 0);n!==void 0&&(e.voice=n,e.features="texttospeech")}};Oc.TranslationConnectionFactory=ov});var zC=p(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.EnumTranslation=void 0;var ce=f(),ie=C(),av=class{static implTranslateRecognitionResult(e,t=!1){let r=ce.ResultReason.Canceled;switch(e){case ie.RecognitionStatus.Success:r=ce.ResultReason.RecognizedSpeech;break;case ie.RecognitionStatus.EndOfDictation:r=t?ce.ResultReason.RecognizedSpeech:ce.ResultReason.NoMatch;break;case ie.RecognitionStatus.NoMatch:case ie.RecognitionStatus.InitialSilenceTimeout:case ie.RecognitionStatus.BabbleTimeout:r=ce.ResultReason.NoMatch;break;case ie.RecognitionStatus.Error:case ie.RecognitionStatus.BadRequest:case ie.RecognitionStatus.Forbidden:default:r=ce.ResultReason.Canceled;break}return r}static implTranslateCancelResult(e){let t=ce.CancellationReason.EndOfStream;switch(e){case ie.RecognitionStatus.Success:case ie.RecognitionStatus.EndOfDictation:case ie.RecognitionStatus.NoMatch:t=ce.CancellationReason.EndOfStream;break;case ie.RecognitionStatus.InitialSilenceTimeout:case ie.RecognitionStatus.BabbleTimeout:case ie.RecognitionStatus.Error:case ie.RecognitionStatus.BadRequest:case ie.RecognitionStatus.Forbidden:default:t=ce.CancellationReason.Error;break}return t}static implTranslateCancelErrorCode(e){let t=ce.CancellationErrorCode.NoError;switch(e){case ie.RecognitionStatus.Error:t=ce.CancellationErrorCode.ServiceError;break;case ie.RecognitionStatus.TooManyRequests:t=ce.CancellationErrorCode.TooManyRequests;break;case ie.RecognitionStatus.BadRequest:t=ce.CancellationErrorCode.BadRequestParameters;break;case ie.RecognitionStatus.Forbidden:t=ce.CancellationErrorCode.Forbidden;break;default:t=ce.CancellationErrorCode.NoError;break}return t}static implTranslateErrorDetails(e){let t="The speech service encountered an internal error and could not continue.";switch(e){case ce.CancellationErrorCode.Forbidden:t="The recognizer is using a free subscription that ran out of quota.";break;case ce.CancellationErrorCode.BadRequestParameters:t="Invalid parameter or unsupported audio format in the request.";break;case ce.CancellationErrorCode.TooManyRequests:t="The number of parallel requests exceeded the number of allowed concurrent transcriptions.";break;default:break}return t}};Mc.EnumTranslation=av});var jC=p(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.RecognitionStatus=mr.SynthesisStatus=void 0;var LA;(function(i){i[i.Success=0]="Success",i[i.SynthesisEnd=1]="SynthesisEnd",i[i.Error=2]="Error"})(LA=mr.SynthesisStatus||(mr.SynthesisStatus={}));var BA;(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"})(BA=mr.RecognitionStatus||(mr.RecognitionStatus={}))});var BC=p(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});Dc.TranslationSynthesisEnd=void 0;var LC=C(),cv=class i{constructor(e){this.privSynthesisEnd=JSON.parse(e),this.privSynthesisEnd.SynthesisStatus&&(this.privSynthesisEnd.SynthesisStatus=LC.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]),this.privSynthesisEnd.Status&&(this.privSynthesisEnd.SynthesisStatus=LC.SynthesisStatus[this.privSynthesisEnd.Status])}static fromJSON(e){return new i(e)}get SynthesisStatus(){return this.privSynthesisEnd.SynthesisStatus}get FailureReason(){return this.privSynthesisEnd.FailureReason}};Dc.TranslationSynthesisEnd=cv});var FC=p(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.TranslationHypothesis=void 0;var FA=w(),VA=qs(),pv=class i{constructor(e){this.privTranslationHypothesis=e,this.privTranslationHypothesis.Translation.TranslationStatus=VA.TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus]}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){FA.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}};kc.TranslationHypothesis=pv});var VC=p(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});Nc.TranslationPhrase=void 0;var UA=w(),WA=C(),HA=qs(),uv=class i{constructor(e){this.privTranslationPhrase=e,this.privTranslationPhrase.RecognitionStatus=WA.RecognitionStatus[this.privTranslationPhrase.RecognitionStatus],this.privTranslationPhrase.Translation!==void 0&&(this.privTranslationPhrase.Translation.TranslationStatus=HA.TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus])}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){UA.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}};Nc.TranslationPhrase=uv});var WC=p(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.TranslationServiceRecognizer=void 0;var UC=P(),z=f(),Te=C(),dv=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),d=Te.EnumTranslation.implTranslateCancelErrorCode(o.RecognitionStatus);await this.cancelRecognitionLocal(u,d,Te.EnumTranslation.implTranslateErrorDetails(d))}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===UC.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 d of e.Translation.Translations)r.set(d.Language,d.Text||d.DisplayText)}let n,s;e instanceof Te.TranslationPhrase?(e.Translation&&e.Translation.TranslationStatus===UC.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{}}};xc.TranslationServiceRecognizer=dv});var HC=p(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});qc.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}};qc.SpeechDetected=hv});var KC=p(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.SpeechHypothesis=void 0;var lv=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}};zc.SpeechHypothesis=lv});var JC=p(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.SpeechKeyword=void 0;var vv=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}};jc.SpeechKeyword=vv});var GC=p(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});Lc.SpeechServiceRecognizer=void 0;var me=f(),tt=C(),fv=class extends tt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeechRecognizer=s}async processTypeSpecificMessages(e){let t,r=new me.PropertyCollection;r.setProperty(me.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=tt.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new me.SpeechRecognitionResult(this.privRequestSession.requestId,me.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 me.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=tt.SimpleSpeechPhrase.fromJSON(e.textBody),u=tt.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus,this.privExpectContentAssessmentResponse);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),me.ResultReason.Canceled===u){let d=tt.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),h=tt.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(d,h,tt.EnumTranslation.implTranslateErrorDetails(h))}else{if(!(this.privRequestSession.isSpeechEnded&&u===me.ResultReason.NoMatch&&c.RecognitionStatus!==tt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(tt.OutputFormatPropertyName)===me.OutputFormat[me.OutputFormat.Simple])t=new me.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 h=tt.DetailedSpeechPhrase.fromJSON(e.textBody),l=h.Offset+this.privRequestSession.currentTurnAudioOffset,g=h.getJsonWithCorrectedOffsets(l);t=new me.SpeechRecognitionResult(this.privRequestSession.requestId,u,h.RecognitionStatus===tt.RecognitionStatus.Success?h.NBest[0].Display:void 0,h.Duration,l,h.Language,h.LanguageDetectionConfidence,void 0,void 0,g,r)}let d=new me.SpeechRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognized)try{this.privSpeechRecognizer.recognized(this.privSpeechRecognizer,d)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(d){this.privErrorCallback&&this.privErrorCallback(d)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){let o=new me.PropertyCollection;if(o.setProperty(tt.CancellationErrorCodePropertyName,me.CancellationErrorCode[n]),this.privSpeechRecognizer.canceled){let a=new me.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new me.SpeechRecognitionResult(t,me.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{}}}};Lc.SpeechServiceRecognizer=fv});var $C=p(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});Bc.ConversationTranscriptionServiceRecognizer=void 0;var Me=f(),rt=C(),gv=class extends rt.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 Me.PropertyCollection;r.setProperty(Me.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=rt.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,Me.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 Me.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=rt.SimpleSpeechPhrase.fromJSON(e.textBody),u=rt.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),Me.ResultReason.Canceled===u){let d=rt.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),h=rt.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(d,h,rt.EnumTranslation.implTranslateErrorDetails(h))}else if(!(this.privRequestSession.isSpeechEnded&&u===Me.ResultReason.NoMatch&&c.RecognitionStatus!==rt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(rt.OutputFormatPropertyName)===Me.OutputFormat[Me.OutputFormat.Simple])t=new Me.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 h=rt.DetailedSpeechPhrase.fromJSON(e.textBody),l=h.Offset+this.privRequestSession.currentTurnAudioOffset,g=h.getJsonWithCorrectedOffsets(l);t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,u,h.RecognitionStatus===rt.RecognitionStatus.Success?h.NBest[0].Display:void 0,h.Duration,l,h.Language,h.LanguageDetectionConfidence,c.SpeakerId,void 0,g,r)}let d=new Me.ConversationTranscriptionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribed)try{this.privConversationTranscriber.transcribed(this.privConversationTranscriber,d)}catch{}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){if(new Me.PropertyCollection().setProperty(rt.CancellationErrorCodePropertyName,Me.CancellationErrorCode[n]),this.privConversationTranscriber.canceled){let a=new Me.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationTranscriber.canceled(this.privConversationTranscriber,a)}catch{}}}};Bc.ConversationTranscriptionServiceRecognizer=gv});var YC=p(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});Fc.TranscriptionServiceRecognizer=void 0;var KA=P(),Qt=f(),QC=C(),JA=Qr(),mv=class extends QC.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(Qt.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 Qt.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 Qt.SpeechRecognitionEventArgs(e,t,r);this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer,n)}catch{}}cancelRecognition(e,t,r,n,s){let o=new Qt.PropertyCollection;if(o.setProperty(QC.CancellationErrorCodePropertyName,Qt.CancellationErrorCode[n]),this.privTranscriberRecognizer.IsMeetingRecognizer()){if(this.privTranscriberRecognizer.canceled){let a=new Qt.MeetingTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}}else if(this.privTranscriberRecognizer.canceled){let a=new Qt.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new Qt.SpeechRecognitionResult(t,Qt.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 JA.SpeechConnectionMessage(KA.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}};Fc.TranscriptionServiceRecognizer=mv});var XC=p(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});Vc.DetailedSpeechPhrase=void 0;var GA=C(),Sv=class i{constructor(e){this.privDetailedSpeechPhrase=JSON.parse(e),this.privDetailedSpeechPhrase.RecognitionStatus=GA.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}};Vc.DetailedSpeechPhrase=Sv});var ZC=p(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.SimpleSpeechPhrase=void 0;var $A=C(),yv=class i{constructor(e){this.privSimpleSpeechPhrase=JSON.parse(e),this.privSimpleSpeechPhrase.RecognitionStatus=$A.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}};Uc.SimpleSpeechPhrase=yv});var eP=p(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});Wc.AddedLmIntent=void 0;var Cv=class{constructor(e,t){this.modelImpl=e,this.intentName=t}};Wc.AddedLmIntent=Cv});var rP=p(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});Hc.IntentServiceRecognizer=void 0;var tP=P(),ne=f(),qi=C(),Pv=class extends qi.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 ne.PropertyCollection;switch(e.messageType===tP.MessageType.Text&&s.setProperty(ne.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.hypothesis":let a=qi.SpeechHypothesis.fromJSON(e.textBody);if(t=new ne.IntentRecognitionResult(void 0,this.privRequestSession.requestId,ne.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 ne.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=qi.SimpleSpeechPhrase.fromJSON(e.textBody);t=new ne.IntentRecognitionResult(void 0,this.privRequestSession.requestId,qi.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus),c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,e.textBody,s),r=new ne.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(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}};this.privIntentDataSent===!1||ne.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 ne.IntentRecognitionEventArgs(new ne.IntentRecognitionResult,0,this.privRequestSession.sessionId)}let d=qi.IntentResponse.fromJSON(e.textBody);if(d!==null&&d.topScoringIntent&&d.topScoringIntent.intent){let h=this.privAddedLmIntents[d.topScoringIntent.intent];if(this.privUmbrellaIntent!==void 0&&(h=this.privUmbrellaIntent),h){let l=h===void 0||h.intentName===void 0?d.topScoringIntent.intent:h.intentName,g=r.result.reason;l!==void 0&&(g=ne.ResultReason.RecognizedIntent);let _=r.result.properties!==void 0?r.result.properties:new ne.PropertyCollection;_.setProperty(ne.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,e.textBody),r=new ne.IntentRecognitionEventArgs(new ne.IntentRecognitionResult(l,r.result.resultId,g,r.result.text,r.result.duration,r.result.offset,void 0,void 0,r.result.errorDetails,r.result.json,_),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(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}n=!0;break;default:break}let o=new tP.Deferred;return o.resolve(n),o.promise}cancelRecognition(e,t,r,n,s){let o=new ne.PropertyCollection;if(o.setProperty(qi.CancellationErrorCodePropertyName,ne.CancellationErrorCode[n]),this.privIntentRecognizer.canceled){let a=new ne.IntentRecognitionCanceledEventArgs(r,s,n,void 0,void 0,e);try{this.privIntentRecognizer.canceled(this.privIntentRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new ne.IntentRecognitionResult(void 0,t,ne.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{}}}};Hc.IntentServiceRecognizer=Pv});var iP=p(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.IntentResponse=void 0;var Rv=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}};Kc.IntentResponse=Rv});var sP=p(nP=>{"use strict";Object.defineProperty(nP,"__esModule",{value:!0})});var aP=p(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});Jc.ServiceTelemetryListener=void 0;var Yt=P(),oP=yc(),Ev=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 oP.RecognitionTriggeredEvent&&e.requestId===this.privRequestId&&(this.privListeningTriggerMetric={End:e.eventTime,Name:"ListeningTrigger",Start:e.eventTime}),e instanceof Yt.AudioStreamNodeAttachingEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Yt.AudioStreamNodeAttachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Yt.AudioSourceErrorEvent&&e.audioSourceId===this.privAudioSourceId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof Yt.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 Yt.AudioStreamNodeDetachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Name:"Microphone",Start:this.privMicStartTime})),e instanceof oP.ConnectingToServiceEvent&&e.requestId===this.privRequestId&&(this.privConnectionId=e.sessionId),e instanceof Yt.ConnectionStartEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionStartTime=e.eventTime),e instanceof Yt.ConnectionEstablishedEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof Yt.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 Yt.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()}}};Jc.ServiceTelemetryListener=Ev});var cP=p($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.RequestSession=void 0;var zi=P(),Gc=yc(),QA=aP(),wv=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=zi.createNoDashGuid(),this.privAudioNodeId=zi.createNoDashGuid(),this.privTurnDeferral=new zi.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 QA.ServiceTelemetryListener(this.privRequestId,this.privAudioSourceId,this.privAudioNodeId),this.onEvent(new Gc.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 Gc.ListeningStartedEvent(this.privRequestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}onPreConnectionStart(e,t){this.privAuthFetchEventId=e,this.privSessionId=t,this.onEvent(new Gc.ConnectingToServiceEvent(this.privRequestId,this.privAuthFetchEventId,this.privSessionId))}async onAuthCompleted(e){e&&await this.onComplete()}async onConnectionEstablishCompleted(e,t){if(e===200){this.onEvent(new Gc.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=zi.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 zi.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),zi.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())}};$c.RequestSession=wv});var pP=p(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});Qc.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)}};Qc.SpeechContext=Iv});var uP=p(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});Yc.DynamicGrammarBuilder=void 0;var Tv=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}};Yc.DynamicGrammarBuilder=Tv});var hP=p(dP=>{"use strict";Object.defineProperty(dP,"__esModule",{value:!0})});var Av=p(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.MessageDataStreamType=Xr.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}};Xr.ActivityPayloadResponse=_v;var YA;(function(i){i[i.None=0]="None",i[i.TextToSpeechAudio=1]="TextToSpeechAudio"})(YA=Xr.MessageDataStreamType||(Xr.MessageDataStreamType={}))});var lP=p(Xc=>{"use strict";Object.defineProperty(Xc,"__esModule",{value:!0});Xc.DialogServiceTurnState=void 0;var XA=li(),ZA=Dr(),eb=Av(),bv=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===eb.MessageDataStreamType.TextToSpeechAudio&&(this.privAudioStream=ZA.AudioOutputStream.createPullStream(),this.privAudioStream.format=t!==void 0?t:XA.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)}};Xc.DialogServiceTurnState=bv});var fP=p(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.DialogServiceTurnStateManager=void 0;var vP=ot(),tb=lP(),Ov=class{constructor(){this.privTurnMap=new Map}StartTurn(e){if(this.privTurnMap.has(e))throw new vP.InvalidOperationError("Service error: There is already a turn with id:"+e);let t=new tb.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 vP.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}};Zc.DialogServiceTurnStateManager=Ov});var gP=p(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});tp.DialogServiceAdapter=void 0;var rb=ae(),ib=Pu(),_e=P(),nb=li(),k=f(),sb=fP(),At=C(),ob=Av(),ep=Qr(),Mv=class extends At.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privEvents=new _e.EventSource,this.privDialogServiceConnector=s,this.receiveMessageOverride=()=>this.receiveDialogMessageOverride(),this.privTurnStateManager=new sb.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=_e.createGuid(),r=_e.createNoDashGuid(),n={context:{interactionId:t},messagePayload:JSON.parse(e),version:.5},s=JSON.stringify(n);await(await this.fetchConnection()).send(new ep.SpeechConnectionMessage(_e.MessageType.Text,"agent",r,"application/json",s))}async privDisconnect(){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.agentConfigSent=!1}processTypeSpecificMessages(e){let t=new k.PropertyCollection;e.messageType===_e.MessageType.Text&&t.setProperty(k.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let r,n;switch(e.path.toLowerCase()){case"speech.phrase":let o=At.SimpleSpeechPhrase.fromJSON(e.textBody);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus!==At.RecognitionStatus.TooManyRequests&&o.RecognitionStatus!==At.RecognitionStatus.Error){let l=this.fireEventForResult(o,t);if(this.privLastResult=l.result,this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,l)}catch{}}n=!0;break;case"speech.hypothesis":let a=At.SpeechHypothesis.fromJSON(e.textBody),c=a.Offset+this.privRequestSession.currentTurnAudioOffset;r=new k.SpeechRecognitionResult(this.privRequestSession.requestId,k.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 k.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 d=At.SpeechKeyword.fromJSON(e.textBody);r=new k.SpeechRecognitionResult(this.privRequestSession.requestId,d.Status==="Accepted"?k.ResultReason.RecognizedKeyword:k.ResultReason.NoMatch,d.Text,d.Duration,d.Offset,void 0,void 0,void 0,void 0,e.textBody,t),d.Status!=="Accepted"&&(this.privLastResult=r);let h=new k.SpeechRecognitionEventArgs(r,r.duration,r.resultId);if(this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,h)}catch{}n=!0;break;case"audio":{let l=e.requestId.toUpperCase(),g=this.privTurnStateManager.GetTurn(l);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 _e.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 k.PropertyCollection;o.setProperty(At.CancellationErrorCodePropertyName,k.CancellationErrorCode[n]);let a=new k.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privDialogServiceConnector.canceled(this.privDialogServiceConnector,a)}catch{}if(this.privSuccessCallback){let c=new k.SpeechRecognitionResult(void 0,k.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(k.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(l){return await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.ConnectionFailure,l),Promise.resolve()}let d=new k.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,d),this.sendAudio(u).then(()=>{},async l=>{await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.RuntimeError,l)})}dialogConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}receiveDialogMessageOverride(){let e=new _e.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=ep.SpeechConnectionMessage.fromConnectionMessage(o);switch(a.path.toLowerCase()){case"turn.start":{let _=a.requestId.toUpperCase(),M=this.privRequestSession.requestId.toUpperCase();_!==M?this.privTurnStateManager.StartTurn(_):this.privRequestSession.onServiceTurnStartResponse()}break;case"speech.startdetected":let u=At.SpeechDetected.fromJSON(a.textBody),d=new k.RecognitionEventArgs(u.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,d);break;case"speech.enddetected":let h;a.textBody.length>0?h=a.textBody:h="{ Offset: 0 }";let l=At.SpeechDetected.fromJSON(h);this.privRequestSession.onServiceRecognized(l.Offset+this.privRequestSession.currentTurnAudioOffset);let g=new k.RecognitionEventArgs(l.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,g);break;case"turn.end":{let _=a.requestId.toUpperCase(),M=this.privRequestSession.requestId.toUpperCase();if(_!==M)this.privTurnStateManager.CompleteTurn(_);else{let J=new k.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,J),this.privSuccessCallback&&this.privLastResult){try{this.privSuccessCallback(this.privLastResult),this.privLastResult=null}catch(F){this.privErrorCallback&&this.privErrorCallback(F)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}}break;default:try{await this.processTypeSpecificMessages(a)||this.serviceEvents&&this.serviceEvents.onEvent(new _e.ServiceEvent(a.path.toLowerCase(),a.textBody))}catch{}}return t()}catch{this.terminateMessageLoop=!0,e.resolve()}};return t().catch(r=>{_e.Events.instance.onEvent(new _e.BackgroundEvent(r))}),e.promise}async startMessageLoop(){this.terminateMessageLoop=!1;try{await this.receiveDialogMessageOverride()}catch(e){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.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(k.PropertyId.Conversation_DialogType)===k.DialogServiceConfig.DialogTypes.CustomCommands){let r=this.agentConfig.get();r.botInfo.commandsCulture=this.privRecognizerConfig.parameters.getProperty(k.PropertyId.SpeechServiceConnection_RecoLanguage,"en-us"),this.agentConfig.set(r)}this.onEvent(new ib.SendingAgentContextMessageEvent(this.agentConfig));let t=this.agentConfig.toJsonString();return this.agentConfigSent=!0,e.send(new ep.SpeechConnectionMessage(_e.MessageType.Text,"agent.config",this.privRequestSession.requestId,"application/json",t))}}sendAgentContext(e){let t=_e.createGuid(),r=this.privDialogServiceConnector.properties.getProperty(k.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 ep.SpeechConnectionMessage(_e.MessageType.Text,"speech.agent.context",this.privRequestSession.requestId,"application/json",s))}fireEventForResult(e,t){let r=At.EnumTranslation.implTranslateRecognitionResult(e.RecognitionStatus),n=e.Offset+this.privRequestSession.currentTurnAudioOffset,s=new k.SpeechRecognitionResult(this.privRequestSession.requestId,r,e.DisplayText,e.Duration,n,e.Language,e.LanguageDetectionConfidence,void 0,void 0,JSON.stringify(e),t);return new k.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=ob.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,nb.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(k.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0))),a=new k.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 k.TurnStatusReceivedEventArgs(e.textBody))}catch{}break;default:_e.Events.instance.onEvent(new _e.BackgroundEvent(`Unexpected response of type ${t.messageType}. Ignoring.`));break}}onEvent(e){this.privEvents.onEvent(e),_e.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"}])}};tp.DialogServiceAdapter=Mv});var mP=p(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.AgentConfig=void 0;var Dv=class{toJsonString(){return JSON.stringify(this.iPrivConfig)}get(){return this.iPrivConfig}set(e){this.iPrivConfig=e}};rp.AgentConfig=Dv});var np=p(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});ip.ConversationConnectionConfig=void 0;var ab=Fl(),bt=class i extends ab.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}};ip.ConversationConnectionConfig=bt;bt.privHost="dev.microsofttranslator.com";bt.privRestPath="/capito/room";bt.privApiVersion="2.0";bt.privDefaultLanguageCode="en-US";bt.privClientAppId="FC539C22-1767-4F1F-84BC-B4D811114F15";bt.privWebSocketPath="/capito/translate";bt.privTranscriptionEventKeys=["iCalUid","callId","organizer","FLAC","MTUri","DifferentiateGuestSpeakers","audiorecording","Threadid","OrganizerMri","OrganizerTenantId","UserToken"]});var SP=p(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});op.ConversationManager=void 0;var sp=ae(),Sr=w(),Xt=f(),Zr=np(),kv=class{constructor(){this.privRequestParams=Zr.ConversationConnectionConfig.configParams,this.privErrors=Zr.ConversationConnectionConfig.restErrors,this.privHost=Zr.ConversationConnectionConfig.host,this.privApiVersion=Zr.ConversationConnectionConfig.apiVersion,this.privRestPath=Zr.ConversationConnectionConfig.restPath,this.privRestAdapter=new sp.RestMessageAdapter({})}createOrJoin(e,t,r,n){try{Sr.Contracts.throwIfNullOrUndefined(e,"args");let s=e.getProperty(Xt.PropertyId.SpeechServiceConnection_RecoLanguage,Zr.ConversationConnectionConfig.defaultLanguageCode),o=e.getProperty(Xt.PropertyId.ConversationTranslator_Name,"conversation_host"),a=e.getProperty(Xt.PropertyId.ConversationTranslator_Host,this.privHost),c=e.getProperty(Xt.PropertyId.ConversationTranslator_CorrelationId),u=e.getProperty(Xt.PropertyId.SpeechServiceConnection_Key),d=e.getProperty(Xt.PropertyId.SpeechServiceConnection_Region),h=e.getProperty(Xt.PropertyId.SpeechServiceAuthorization_Token);Sr.Contracts.throwIfNullOrWhitespace(s,"languageCode"),Sr.Contracts.throwIfNullOrWhitespace(o,"nickname"),Sr.Contracts.throwIfNullOrWhitespace(a,"endpointHost");let l={};l[this.privRequestParams.apiVersion]=this.privApiVersion,l[this.privRequestParams.languageCode]=s,l[this.privRequestParams.nickname]=o;let g={};c&&(g[this.privRequestParams.correlationId]=c),g[this.privRequestParams.clientAppId]=Zr.ConversationConnectionConfig.clientAppId,t!==void 0?l[this.privRequestParams.roomId]=t:(Sr.Contracts.throwIfNullOrUndefined(d,this.privErrors.authInvalidSubscriptionRegion),g[this.privRequestParams.subscriptionRegion]=d,u?g[this.privRequestParams.subscriptionKey]=u:h?g[this.privRequestParams.authorization]=`Bearer ${h}`:Sr.Contracts.throwIfNullOrUndefined(u,this.privErrors.authInvalidSubscriptionKey));let _={};_.headers=g,this.privRestAdapter.options=_;let M=`https://${a}${this.privRestPath}`;this.privRestAdapter.request(sp.RestRequestType.Post,M,l,null).then(J=>{let F=sp.RestMessageAdapter.extractHeaderValue(this.privRequestParams.requestId,J.headers);if(!J.ok){if(n){let ye=this.privErrors.invalidCreateJoinConversationResponse.replace("{status}",J.status.toString()),V;try{V=JSON.parse(J.data),ye+=` [${V.error.code}: ${V.error.message}]`}catch{ye+=` [${J.data}]`}F&&(ye+=` ${F}`),n(ye)}return}let ee=JSON.parse(J.data);if(ee&&(ee.requestId=F),r){try{r(ee)}catch(ye){n&&n(ye)}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{Sr.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","config")),Sr.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","token"));let s=e.getProperty(Xt.PropertyId.ConversationTranslator_Host,this.privHost),o=e.getProperty(Xt.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 d=`https://${s}${this.privRestPath}`;this.privRestAdapter.request(sp.RestRequestType.Delete,d,a,null).then(h=>{h.ok,r()}).catch(()=>{})}catch(s){if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}})}};op.ConversationManager=kv});var xv=p(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});ap.ConversationConnectionMessage=void 0;var cb=P(),Nv=class extends cb.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}};ap.ConversationConnectionMessage=Nv});var CP=p(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});cp.ConversationWebsocketMessageFormatter=void 0;var ei=P(),yP=xv(),qv=class{toConnectionMessage(e){let t=new ei.Deferred;try{if(e.messageType===ei.MessageType.Text){let r=new yP.ConversationConnectionMessage(e.messageType,e.textContent,{},e.id);t.resolve(r)}else e.messageType===ei.MessageType.Binary&&t.resolve(new yP.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 ei.Deferred;try{if(e.messageType===ei.MessageType.Text){let r=`${e.textBody?e.textBody:""}`;t.resolve(new ei.RawWebsocketMessage(ei.MessageType.Text,r,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}};cp.ConversationWebsocketMessageFormatter=qv});var RP=p(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});pp.ConversationConnectionFactory=void 0;var PP=ae(),pb=P(),ub=w(),zv=f(),db=$e(),ji=np(),hb=CP(),jv=class extends db.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(zv.PropertyId.ConversationTranslator_Host,ji.ConversationConnectionConfig.host),s=e.parameters.getProperty(zv.PropertyId.ConversationTranslator_CorrelationId,pb.createGuid()),o=`wss://${n}${ji.ConversationConnectionConfig.webSocketPath}`,a=e.parameters.getProperty(zv.PropertyId.ConversationTranslator_Token,void 0);ub.Contracts.throwIfNullOrUndefined(a,"token");let c={};c[ji.ConversationConnectionConfig.configParams.apiVersion]=ji.ConversationConnectionConfig.apiVersion,c[ji.ConversationConnectionConfig.configParams.token]=a,c[ji.ConversationConnectionConfig.configParams.correlationId]=s;let u=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new PP.WebsocketConnection(o,c,{},new hb.ConversationWebsocketMessageFormatter,PP.ProxyInfo.fromRecognizerConfig(e),u,r)}};pp.ConversationConnectionFactory=jv});var EP=p(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});up.ConversationRequestSession=void 0;var Lv=P(),Bv=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privSessionId=e,this.privRequestId=Lv.createNoDashGuid(),this.privRequestCompletionDeferral=new Lv.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=Lv.createNoDashGuid():this.onComplete()}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach()}}onComplete(){}};up.ConversationRequestSession=Bv});var Jv=p(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.ConversationReceivedTranslationEventArgs=je.ParticipantsListEventArgs=je.ParticipantAttributeEventArgs=je.ParticipantEventArgs=je.LockRoomEventArgs=je.MuteAllEventArgs=void 0;var Zn=f(),Fv=class extends Zn.SessionEventArgs{constructor(e,t){super(t),this.privIsMuted=e}get isMuted(){return this.privIsMuted}};je.MuteAllEventArgs=Fv;var Vv=class extends Zn.SessionEventArgs{constructor(e,t){super(t),this.privIsLocked=e}get isMuted(){return this.privIsLocked}};je.LockRoomEventArgs=Vv;var Uv=class extends Zn.SessionEventArgs{constructor(e,t){super(t),this.privParticipant=e}get participant(){return this.privParticipant}};je.ParticipantEventArgs=Uv;var Wv=class extends Zn.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}};je.ParticipantAttributeEventArgs=Wv;var Hv=class extends Zn.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}};je.ParticipantsListEventArgs=Hv;var Kv=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}};je.ConversationReceivedTranslationEventArgs=Kv});var $v=p(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.ConversationTranslatorCommandTypes=yr.ConversationTranslatorMessageTypes=yr.InternalParticipants=void 0;var Gv=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)}};yr.InternalParticipants=Gv;yr.ConversationTranslatorMessageTypes={command:"command",final:"final",info:"info",instantMessage:"instant_message",keepAlive:"keep_alive",partial:"partial",participantCommand:"participant_command",translatedMessage:"translated_message"};yr.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(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});dp.CommandResponsePayload=void 0;var lb=i=>JSON.parse(i),Qv=class i{constructor(e){this.privCommandResponse=lb(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)}};dp.CommandResponsePayload=Qv});var IP=p(Li=>{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});Li.ParticipantPayloadResponse=Li.ParticipantsListPayloadResponse=void 0;var vb=i=>JSON.parse(i),fb=i=>JSON.parse(i),Yv=class i{constructor(e){this.privParticipantsPayloadResponse=vb(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)}};Li.ParticipantsListPayloadResponse=Yv;var Xv=class i{constructor(e){this.privParticipantPayloadResponse=fb(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)}};Li.ParticipantPayloadResponse=Xv});var TP=p(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.TextResponsePayload=Bi.SpeechResponsePayload=void 0;var gb=i=>JSON.parse(i),mb=i=>JSON.parse(i),Zv=class i{constructor(e){this.privSpeechResponse=gb(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)}};Bi.SpeechResponsePayload=Zv;var ef=class i{constructor(e){this.privTextResponse=mb(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)}};Bi.TextResponsePayload=ef});var bP=p(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});var Sb=wP();Object.defineProperty(ti,"CommandResponsePayload",{enumerable:!0,get:function(){return Sb.CommandResponsePayload}});var _P=IP();Object.defineProperty(ti,"ParticipantsListPayloadResponse",{enumerable:!0,get:function(){return _P.ParticipantsListPayloadResponse}});Object.defineProperty(ti,"ParticipantPayloadResponse",{enumerable:!0,get:function(){return _P.ParticipantPayloadResponse}});var AP=TP();Object.defineProperty(ti,"SpeechResponsePayload",{enumerable:!0,get:function(){return AP.SpeechResponsePayload}});Object.defineProperty(ti,"TextResponsePayload",{enumerable:!0,get:function(){return AP.TextResponsePayload}})});var DP=p(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});hp.ConversationServiceAdapter=void 0;var es=P(),lt=f(),OP=C(),MP=xv(),yb=EP(),Ue=Jv(),Cr=$v(),ts=bP(),tf=class extends OP.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 yb.ConversationRequestSession(es.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 MP.ConversationConnectionMessage(es.MessageType.Text,e))}async sendMessageAsync(e){await(await this.fetchConnection()).send(new MP.ConversationConnectionMessage(es.MessageType.Text,e))}privDisconnect(){if(!this.terminateMessageLoop)return this.cancelRecognition(this.privConversationRequestSession.sessionId,this.privConversationRequestSession.requestId,lt.CancellationReason.Error,lt.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,Promise.resolve()}async processTypeSpecificMessages(){return!0}cancelRecognition(e,t,r,n,s){this.terminateMessageLoop=!0;let o=new lt.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 es.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=ts.CommandResponsePayload.fromJSON(r.textBody);switch(a.command.toLowerCase()){case"participantlist":let g=ts.ParticipantsListPayloadResponse.fromJSON(r.textBody),_=g.participants.map(V=>({avatar:V.avatar,displayName:V.nickname,id:V.participantId,isHost:V.ishost,isMuted:V.ismuted,isUsingTts:V.usetts,preferredLanguage:V.locale}));this.privConversationServiceConnector.participantsListReceived&&this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector,new Ue.ParticipantsListEventArgs(g.roomid,g.token,g.translateTo,g.profanityFilter,g.roomProfanityFilter,g.roomLocked,g.muteAll,_,n));break;case"settranslatetolanguages":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.setTranslateToLanguages,a.value,n));break;case"setprofanityfiltering":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.setProfanityFiltering,a.value,n));break;case"setmute":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.setMute,a.value,n));break;case"setmuteall":this.privConversationServiceConnector.muteAllCommandReceived&&this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector,new Ue.MuteAllEventArgs(a.value,n));break;case"roomexpirationwarning":this.privConversationServiceConnector.conversationExpiration&&this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector,new lt.ConversationExpirationEventArgs(a.value,this.privConversationRequestSession.sessionId));break;case"setusetts":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.setUseTTS,a.value,n));break;case"setlockstate":this.privConversationServiceConnector.lockRoomCommandReceived&&this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector,new Ue.LockRoomEventArgs(a.value,n));break;case"changenickname":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.changeNickname,a.value,n));break;case"joinsession":let M=ts.ParticipantPayloadResponse.fromJSON(r.textBody),J={avatar:M.avatar,displayName:M.nickname,id:M.participantId,isHost:M.ishost,isMuted:M.ismuted,isUsingTts:M.usetts,preferredLanguage:M.locale};this.privConversationServiceConnector.participantJoinCommandReceived&&this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantEventArgs(J,n));break;case"leavesession":let F={id:a.participantId};this.privConversationServiceConnector.participantLeaveCommandReceived&&this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantEventArgs(F,n));break;case"disconnectsession":let ee={id:a.participantId};break;case"token":let ye=new OP.CognitiveTokenAuthentication(()=>{let V=a.token;return Promise.resolve(V)},()=>{let V=a.token;return Promise.resolve(V)});this.authentication=ye,this.privConversationServiceConnector.onToken(ye);break;default:break}break;case"partial":case"final":let c=ts.SpeechResponsePayload.fromJSON(r.textBody),u=s==="final"?lt.ResultReason.TranslatedParticipantSpeech:lt.ResultReason.TranslatingParticipantSpeech,d=new lt.ConversationTranslationResult(c.participantId,this.getTranslations(c.translations),c.language,c.id,u,c.recognition,void 0,void 0,r.textBody,void 0);c.isFinal?((d.text!==void 0&&d.text.length>0||c.id===this.privLastPartialUtteranceId)&&(o=!0),o&&this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ue.ConversationReceivedTranslationEventArgs(Cr.ConversationTranslatorMessageTypes.final,d,n))):d.text!==void 0&&(this.privLastPartialUtteranceId=c.id,this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ue.ConversationReceivedTranslationEventArgs(Cr.ConversationTranslatorMessageTypes.partial,d,n)));break;case"translated_message":let h=ts.TextResponsePayload.fromJSON(r.textBody),l=new lt.ConversationTranslationResult(h.participantId,this.getTranslations(h.translations),h.language,void 0,void 0,h.originalText,void 0,void 0,void 0,r.textBody,void 0);this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ue.ConversationReceivedTranslationEventArgs(Cr.ConversationTranslatorMessageTypes.instantMessage,l,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:"",lt.CancellationReason.Error,lt.CancellationErrorCode.RuntimeError,t),null}}configConnection(){return this.isDisposed()?Promise.resolve(void 0):this.privConnectionConfigPromise!==void 0?this.privConnectionConfigPromise.then(e=>e.state()===es.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 lt.Translations;for(let r of e)t.set(r.lang,r.translation)}return t}};hp.ConversationServiceAdapter=tf});var kP=p(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.ConversationTranslatorRecognizer=Ui.ConversationRecognizerFactory=void 0;var Cb=C(),Fi=P(),Vi=w(),rf=f(),Pb=RP(),Rb=DP(),nf=class{static fromConfig(e,t,r){return new lp(e,t,r)}};Ui.ConversationRecognizerFactory=nf;var lp=class extends rf.Recognizer{constructor(e,t,r){let n=t;Vi.Contracts.throwIfNull(n,"speechConfig");let s=e;Vi.Contracts.throwIfNull(s,"conversationImpl"),super(r,n.properties,new Pb.ConversationConnectionFactory),this.privConversation=s,this.privIsDisposed=!1,this.privProperties=n.properties.clone(),this.privConnection=rf.Connection.fromRecognizer(this),this.privProperties.getProperty(rf.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?(this.privSetTimeout=Fi.Timeout.setTimeout,this.privClearTimeout=Fi.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{Vi.Contracts.throwIfDisposed(this.privIsDisposed),Vi.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{Vi.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=>{Fi.Events.instance.onEvent(new Fi.BackgroundEvent(n))})}}sendRequest(e,t,r){try{Vi.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=>{Fi.Events.instance.onEvent(new Fi.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 Cb.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Rb.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)}};Ui.ConversationTranslatorRecognizer=lp});var xP=p(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});fp.TranscriberRecognizer=void 0;var NP=P(),vt=w(),Wi=f(),vp=C(),sf=class extends Wi.Recognizer{constructor(e,t){let r=e;vt.Contracts.throwIfNull(r,"speechTranslationConfig");let n=t;vt.Contracts.throwIfNull(n,"audioConfigImpl"),vt.Contracts.throwIfNullOrWhitespace(r.speechRecognitionLanguage,Wi.PropertyId[Wi.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new vp.TranscriberConnectionFactory),this.privDisposedRecognizer=!1,this.isMeetingRecognizer=!1}get speechRecognitionLanguage(){return vt.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Wi.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Wi.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){vt.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Wi.PropertyId.SpeechServiceAuthorization_Token,e)}set conversation(e){vt.Contracts.throwIfNullOrUndefined(e,"Conversation"),this.isMeetingRecognizer=!1,this.privConversation=e}getConversationInfo(){return vt.Contracts.throwIfNullOrUndefined(this.privConversation,"Conversation"),this.privConversation.conversationInfo}set meeting(e){vt.Contracts.throwIfNullOrUndefined(e,"Meeting"),this.isMeetingRecognizer=!0,this.privMeeting=e}getMeetingInfo(){return vt.Contracts.throwIfNullOrUndefined(this.privMeeting,"Meeting"),this.privMeeting.meetingInfo}IsMeetingRecognizer(){return this.isMeetingRecognizer}startContinuousRecognitionAsync(e,t){NP.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(vp.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){NP.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}async close(){this.privDisposedRecognizer||await this.dispose(!0)}async pushConversationEvent(e,t){let r=this.privReco;vt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendSpeechEventAsync(e,t)}async pushMeetingEvent(e,t){let r=this.privReco;vt.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 vp.RecognizerConfig(e,this.properties)}createServiceRecognizer(e,t,r,n){let s=r;return new vp.TranscriptionServiceRecognizer(e,t,s,n,this)}};fp.TranscriberRecognizer=sf});var qP=p(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});var Eb=SP();Object.defineProperty(De,"ConversationManager",{enumerable:!0,get:function(){return Eb.ConversationManager}});var wb=np();Object.defineProperty(De,"ConversationConnectionConfig",{enumerable:!0,get:function(){return wb.ConversationConnectionConfig}});var Ib=kP();Object.defineProperty(De,"ConversationRecognizerFactory",{enumerable:!0,get:function(){return Ib.ConversationRecognizerFactory}});var Tb=xP();Object.defineProperty(De,"TranscriberRecognizer",{enumerable:!0,get:function(){return Tb.TranscriberRecognizer}});var Hi=Jv();Object.defineProperty(De,"ConversationReceivedTranslationEventArgs",{enumerable:!0,get:function(){return Hi.ConversationReceivedTranslationEventArgs}});Object.defineProperty(De,"LockRoomEventArgs",{enumerable:!0,get:function(){return Hi.LockRoomEventArgs}});Object.defineProperty(De,"MuteAllEventArgs",{enumerable:!0,get:function(){return Hi.MuteAllEventArgs}});Object.defineProperty(De,"ParticipantAttributeEventArgs",{enumerable:!0,get:function(){return Hi.ParticipantAttributeEventArgs}});Object.defineProperty(De,"ParticipantEventArgs",{enumerable:!0,get:function(){return Hi.ParticipantEventArgs}});Object.defineProperty(De,"ParticipantsListEventArgs",{enumerable:!0,get:function(){return Hi.ParticipantsListEventArgs}});var of=$v();Object.defineProperty(De,"ConversationTranslatorCommandTypes",{enumerable:!0,get:function(){return of.ConversationTranslatorCommandTypes}});Object.defineProperty(De,"ConversationTranslatorMessageTypes",{enumerable:!0,get:function(){return of.ConversationTranslatorMessageTypes}});Object.defineProperty(De,"InternalParticipants",{enumerable:!0,get:function(){return of.InternalParticipants}})});var cf=p(ri=>{"use strict";Object.defineProperty(ri,"__esModule",{value:!0});ri.SynthesisAudioMetadata=ri.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=ri.MetadataType||(ri.MetadataType={}));var af=class i{constructor(e){this.privSynthesisAudioMetadata=JSON.parse(e)}static fromJSON(e){return new i(e)}get Metadata(){return this.privSynthesisAudioMetadata.Metadata}};ri.SynthesisAudioMetadata=af});var jP=p(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.SynthesisStartedEvent=Ot.ConnectingToSynthesisServiceEvent=Ot.SynthesisTriggeredEvent=Ot.SpeechSynthesisEvent=void 0;var zP=P(),Ki=class extends zP.PlatformEvent{constructor(e,t,r=zP.EventType.Info){super(e,r),this.privRequestId=t}get requestId(){return this.privRequestId}};Ot.SpeechSynthesisEvent=Ki;var pf=class extends Ki{constructor(e,t,r){super("SynthesisTriggeredEvent",e),this.privSessionAudioDestinationId=t,this.privTurnAudioDestinationId=r}get audioSessionDestinationId(){return this.privSessionAudioDestinationId}get audioTurnDestinationId(){return this.privTurnAudioDestinationId}};Ot.SynthesisTriggeredEvent=pf;var uf=class extends Ki{constructor(e,t){super("ConnectingToSynthesisServiceEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};Ot.ConnectingToSynthesisServiceEvent=uf;var df=class extends Ki{constructor(e,t){super("SynthesisStartedEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};Ot.SynthesisStartedEvent=df});var LP=p(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});Sp.SynthesisTurn=void 0;var gp=P(),Ab=Dr(),mp=f(),bb=cf(),hf=jP(),lf=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=gp.createNoDashGuid(),this.privTurnDeferral=new gp.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 mp.PropertyCollection;return e.setProperty(mp.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 Ab.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 gp.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 mp.SpeechSynthesisResult(this.requestId,mp.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){gp.Events.instance.onEvent(e)}static isXmlTag(e){return e.length>=2&&e[0]==="<"&&e[e.length-1]===">"}updateTextOffset(e,t){t===bb.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)}};Sp.SynthesisTurn=lf});var BP=p(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});Cp.SynthesisAdapterBase=void 0;var Ae=P(),We=f(),it=C(),Ji=Qr(),yp=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 Ae.ArgumentNullError("authentication");if(!t)throw new Ae.ArgumentNullError("connectionFactory");if(!r)throw new Ae.ArgumentNullError("synthesizerConfig");this.privAuthentication=e,this.privConnectionFactory=t,this.privSynthesizerConfig=r,this.privIsDisposed=!1,this.privSessionAudioDestination=n,this.privSynthesisTurn=new it.SynthesisTurn,this.privConnectionEvents=new Ae.EventSource,this.privServiceEvents=new Ae.EventSource,this.privSynthesisContext=new it.SynthesisContext,this.privAgentConfig=new it.AgentConfig,this.connectionEvents.attach(s=>{if(s.name==="ConnectionClosedEvent"){let o=s;o.statusCode!==1e3&&this.cancelSynthesisLocal(We.CancellationReason.Error,o.statusCode===1007?We.CancellationErrorCode.BadRequestParameters:We.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"?Ae.MessageType.Text:Ae.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new Ji.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(We.CancellationReason.Error,We.CancellationErrorCode.ConnectionFailure,c),Promise.reject(c)}}async stopSpeaking(){return await this.connectImpl(),(await this.fetchConnection()).send(new Ji.SpeechConnectionMessage(Ae.MessageType.Text,"synthesis.control",this.privSynthesisTurn.requestId,"application/json",JSON.stringify({action:"stop"})))}cancelSynthesis(e,t,r,n){let s=new We.PropertyCollection;s.setProperty(it.CancellationErrorCodePropertyName,We.CancellationErrorCode[r]);let o=new We.SpeechSynthesisResult(e,We.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=Ji.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=it.SynthesisAudioMetadata.fromJSON(r.textBody).Metadata;for(let o of n)switch(o.Type){case it.MetadataType.WordBoundary:case it.MetadataType.SentenceBoundary:this.privSynthesisTurn.onTextBoundaryEvent(o);let a=new We.SpeechSynthesisWordBoundaryEventArgs(o.Data.Offset,o.Data.Duration,o.Data.text.Text,o.Data.text.Length,o.Type===it.MetadataType.WordBoundary?this.privSynthesisTurn.currentTextOffset:this.privSynthesisTurn.currentSentenceOffset,o.Data.text.BoundaryType);this.onWordBoundary(a);break;case it.MetadataType.Bookmark:let c=new We.SpeechSynthesisBookmarkEventArgs(o.Data.Offset,o.Data.Bookmark);this.onBookmarkReached(c);break;case it.MetadataType.Viseme:if(this.privSynthesisTurn.onVisemeMetadataReceived(o),o.Data.IsLastAnimation){let u=new We.SpeechSynthesisVisemeEventArgs(o.Data.Offset,o.Data.VisemeId,this.privSynthesisTurn.getAndClearVisemeAnimation());this.onVisemeReceived(u)}break;case it.MetadataType.AvatarSignal:this.onAvatarEvent(o);break;case it.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 Ae.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 Ji.SpeechConnectionMessage(Ae.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()===Ae.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()));this.privAuthFetchEventId=Ae.createNoDashGuid(),this.privConnectionId=Ae.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(We.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 Ji.SpeechConnectionMessage(Ae.MessageType.Text,"speech.config",this.privSynthesisTurn.requestId,"application/json",t))}sendSsmlMessage(e,t,r){return e.send(new Ji.SpeechConnectionMessage(Ae.MessageType.Text,"ssml",r,"application/ssml+xml",t))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===Ae.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){}};Cp.SynthesisAdapterBase=yp;yp.telemetryDataEnabled=!0});var VP=p(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});Pp.AvatarSynthesisAdapter=void 0;var FP=f(),Ob=C(),vf=class extends Ob.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(FP.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 FP.AvatarEventArgs(e.Data.Offset,e.Data.Name);try{this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer,t)}catch{}}}};Pp.AvatarSynthesisAdapter=vf});var UP=p(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});Rp.SpeechSynthesisAdapter=void 0;var Pr=f(),Mb=C(),ff=class extends Mb.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 Pr.SpeechSynthesisEventArgs(new Pr.SpeechSynthesisResult(e,Pr.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 Pr.SpeechSynthesisEventArgs(new Pr.SpeechSynthesisResult(this.privSynthesisTurn.requestId,Pr.ResultReason.SynthesizingAudio,t));this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer,r)}catch{}}onSynthesisCancelled(e){if(this.privSpeechSynthesizer.SynthesisCanceled){let t=new Pr.SpeechSynthesisEventArgs(e);try{this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer,t)}catch{}}}onSynthesisCompleted(e){if(this.privSpeechSynthesizer.synthesisCompleted)try{this.privSpeechSynthesizer.synthesisCompleted(this.privSpeechSynthesizer,new Pr.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{}}};Rp.SpeechSynthesisAdapter=ff});var WP=p(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});Ep.SynthesisRestAdapter=void 0;var gf=ae(),mf=f(),Db=$e(),kb=we(),Sf=class{constructor(e,t){let r=e.parameters.getProperty(mf.PropertyId.SpeechServiceConnection_Endpoint,void 0);if(!r){let s=e.parameters.getProperty(mf.PropertyId.SpeechServiceConnection_Region,"westus"),o=Db.ConnectionFactoryBase.getHostSuffix(s);r=e.parameters.getProperty(mf.PropertyId.SpeechServiceConnection_Host,`https://${s}.tts.speech${o}`)}this.privUri=`${r}/cognitiveservices/voices/list`;let n=gf.RestConfigBase.requestOptions;this.privRestAdapter=new gf.RestMessageAdapter(n),this.privAuthentication=t}getVoicesList(e){return this.privRestAdapter.setHeaders(kb.HeaderNames.ConnectionId,e),this.privAuthentication.fetch(e).then(t=>(this.privRestAdapter.setHeaders(t.headerName,t.token),this.privRestAdapter.request(gf.RestRequestType.Get,this.privUri)))}};Ep.SynthesisRestAdapter=Sf});var JP=p(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.SynthesizerConfig=ii.SynthesisServiceType=void 0;var HP=C(),KP;(function(i){i[i.Standard=0]="Standard",i[i.Custom=1]="Custom"})(KP=ii.SynthesisServiceType||(ii.SynthesisServiceType={}));var yf=class{constructor(e,t){this.privSynthesisServiceType=KP.Standard,this.avatarEnabled=!1,this.privSpeechServiceConfig=e||new HP.SpeechServiceConfig(new HP.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}};ii.SynthesizerConfig=yf});var GP=p(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});wp.SynthesisContext=void 0;var Cf=f(),Pf=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(Cf.PropertyId.SpeechServiceResponse_RequestPunctuationBoundary,!!e?.wordBoundary),sentenceBoundaryEnabled:e?.properties.getProperty(Cf.PropertyId.SpeechServiceResponse_RequestSentenceBoundary,!1),sessionEndEnabled:!0,visemeEnabled:!!e?.visemeReceived,wordBoundaryEnabled:e?.properties.getProperty(Cf.PropertyId.SpeechServiceResponse_RequestWordBoundary,!!e?.wordBoundary)},outputFormat:this.privAudioOutputFormat.requestAudioFormatString},language:{autoDetection:e?.autoDetectSourceLanguage}}}};wp.SynthesisContext=Pf});var $P=p(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});Ip.SpeakerRecognitionConfig=void 0;var Nb=C(),Rf=class{constructor(e,t){this.privContext=e||new Nb.Context(null),this.privParameters=t}get parameters(){return this.privParameters}get Context(){return this.privContext}};Ip.SpeakerRecognitionConfig=Rf});var YP=p(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});_p.SpeakerServiceRecognizer=void 0;var xb=ae(),Tp=P(),Se=f(),QP=C(),qb=Qr(),Ef=class extends QP.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 Se.PropertyCollection;switch(e.messageType===Tp.MessageType.Text&&r.setProperty(Se.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 Se.SpeakerRecognitionResult(s,Se.ResultReason.Canceled,Se.CancellationErrorCode.ServiceError,s.status.reason):o=new Se.SpeakerRecognitionResult(s,Se.ResultReason.RecognizedSpeaker),this.privResultDeferral&&this.privResultDeferral.resolve(o),t=!0;break;default:break}let n=new Tp.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){if(new Se.PropertyCollection().setProperty(QP.CancellationErrorCodePropertyName,Se.CancellationErrorCode[n]),this.privResultDeferral){let a=new Se.SpeakerRecognitionResult({scenario:this.privSpeakerModel.scenario,status:{statusCode:s,reason:s}},Se.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 Tp.Deferred),this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(Se.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 xb.ReplayableAudioNode(n,s.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(a,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:o};try{await t,await r}catch(d){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Se.CancellationReason.Error,Se.CancellationErrorCode.ConnectionFailure,d)}let c=new Se.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,c),this.receiveMessage(),this.sendAudio(a).then(()=>{},d=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Se.CancellationReason.Error,Se.CancellationErrorCode.RuntimeError,d)}),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 qb.SpeechConnectionMessage(Tp.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}}};_p.SpeakerServiceRecognizer=Ef});var ZP=p(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});Ap.VoiceServiceRecognizer=void 0;var zb=ae(),Mt=P(),L=f(),XP=C(),wf=Qr(),If=class extends XP.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privDeferralMap=new Mt.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===Mt.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 Mt.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){new L.PropertyCollection().setProperty(XP.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 Mt.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 Mt.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 Mt.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 zb.ReplayableAudioNode(s,o.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(c,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:a};try{await r,await n}catch(h){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.ConnectionFailure,h)}let u=new L.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,u),this.receiveMessage(),this.sendAudio(c).then(()=>{},h=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.RuntimeError,h)}),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 wf.SpeechConnectionMessage(Mt.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 wf.SpeechConnectionMessage(Mt.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 Mt.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 wf.SpeechConnectionMessage(Mt.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"}};Ap.VoiceServiceRecognizer=If});var eR=p(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.type=pe.connectivity=pe.Device=pe.OS=pe.System=pe.Context=pe.SpeechServiceConfig=void 0;var Tf=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()}};pe.SpeechServiceConfig=Tf;var _f=class{constructor(e){this.system=new bp,this.os=e}};pe.Context=_f;var bp=class{constructor(){let e="1.36.0";this.name="SpeechSDK",this.version=e,this.build="JavaScript",this.lang="JavaScript"}};pe.System=bp;var Af=class{constructor(e,t,r){this.platform=e,this.name=t,this.version=r}};pe.OS=Af;var bf=class{constructor(e,t,r){this.manufacturer=e,this.model=t,this.version=r}};pe.Device=bf;var jb;(function(i){i.Bluetooth="Bluetooth",i.Wired="Wired",i.WiFi="WiFi",i.Cellular="Cellular",i.InBuilt="InBuilt",i.Unknown="Unknown"})(jb=pe.connectivity||(pe.connectivity={}));var Lb;(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"})(Lb=pe.type||(pe.type={}))});var C=p(m=>{"use strict";var Bb=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)&&Bb(e,i,t)};Object.defineProperty(m,"__esModule",{value:!0});m.AutoDetectSourceLanguagesOpenRangeOptionName=m.ForceDictationPropertyName=m.ServicePropertiesPropertyName=m.CancellationErrorCodePropertyName=m.OutputFormatPropertyName=void 0;R(sm(),m);R(pm(),m);R(Vs(),m);R(dm(),m);R(lm(),m);R(cC(),m);R(hC(),m);R(yc(),m);R(vC(),m);R(fC(),m);R(mC(),m);R(yC(),m);R(PC(),m);R(IC(),m);R(AC(),m);R(DC(),m);R(qC(),m);R(bl(),m);R(zC(),m);R(jC(),m);R(BC(),m);R(FC(),m);R(VC(),m);R(WC(),m);R(HC(),m);R(KC(),m);R(JC(),m);R(GC(),m);R($C(),m);R(YC(),m);R(XC(),m);R(ZC(),m);R(eP(),m);R(rP(),m);R(iP(),m);R(sP(),m);R(cP(),m);R(pP(),m);R(uP(),m);R(hP(),m);R(gP(),m);R(mP(),m);R(qP(),m);R(cf(),m);R(LP(),m);R(BP(),m);var Fb=VP();Object.defineProperty(m,"AvatarSynthesisAdapter",{enumerable:!0,get:function(){return Fb.AvatarSynthesisAdapter}});var Vb=UP();Object.defineProperty(m,"SpeechSynthesisAdapter",{enumerable:!0,get:function(){return Vb.SpeechSynthesisAdapter}});R(WP(),m);R(JP(),m);R(GP(),m);R($P(),m);R(YP(),m);R(ZP(),m);R(eR(),m);m.OutputFormatPropertyName="OutputFormat";m.CancellationErrorCodePropertyName="CancellationErrorCode";m.ServicePropertiesPropertyName="ServiceProperties";m.ForceDictationPropertyName="ForceDictation";m.AutoDetectSourceLanguagesOpenRangeOptionName="OpenRange"});var tR=p(ni=>{"use strict";var Ub=ni&&ni.__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]}),Wb=ni&&ni.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&Ub(e,i,t)};Object.defineProperty(ni,"__esModule",{value:!0});var Hb=C();new Hb.AgentConfig;Wb(f(),ni)});function KR(i){return typeof i=="function"}function rn(i){return KR(i)?i():i}var eg=!0;function nn(i){let{audioConfig:e,authorizationToken:t,enableTelemetry:r,looseEvent:n,referenceGrammars:s,region:o="westus",speechRecognitionEndpointId:a,subscriptionKey:c,textNormalization:u}=i,{credentials:d,looseEvents:h}=i;if(typeof n<"u"&&(console.warn('web-speech-cognitive-services: The option "looseEvent" should be named as "looseEvents".'),h=n),!d){if(!t&&!c)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."),d=async()=>typeof i.authorizationToken<"u"?{authorizationToken:await rn(i.authorizationToken),region:o}:{region:o,subscriptionKey:await rn(i.subscriptionKey)}}return Object.freeze({audioConfig:e,enableTelemetry:r,fetchCredentials:async()=>{let{authorizationToken:l,customVoiceHostname:g,region:_,speechRecognitionHostname:M,speechSynthesisHostname:J,subscriptionKey:F}=await rn(d);if(!l&&!F||l&&F)throw new Error('web-speech-cognitive-services: Either "authorizationToken" or "subscriptionKey" must be provided.');if(!_&&!(M&&J))throw new Error('web-speech-cognitive-services: Either "region" or "speechRecognitionHostname" and "speechSynthesisHostname" must be set.');if(_&&(g||M||J))throw new Error('web-speech-cognitive-services: Only either "region" or "customVoiceHostname", "speechRecognitionHostname" and "speechSynthesisHostname" can be set.');if(l){if(typeof l!="string")throw new Error('web-speech-cognitive-services: "authorizationToken" must be a string.')}else if(typeof F!="string")throw new Error('web-speech-cognitive-services: "subscriptionKey" must be a string.');return eg&&F&&(console.warn("web-speech-cognitive-services: In production environment, subscription key should not be used, authorization token should be used instead."),eg=!1),{...typeof l<"u"?{authorizationToken:l}:{subscriptionKey:F},...typeof _<"u"?{region:_}:{customVoiceHostname:g,speechRecognitionHostname:M,speechSynthesisHostname:J}}},looseEvents:!!h,referenceGrammars:s&&Object.freeze([...s]),speechRecognitionEndpointId:a,textNormalization:u})}var Dt=Zf(tR()),Gi={AudioConfig:Dt.AudioConfig,OutputFormat:Dt.OutputFormat,ResultReason:Dt.ResultReason,SpeechConfig:Dt.SpeechConfig,SpeechRecognizer:Dt.SpeechRecognizer};function rs(){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=rs())).promise}}var $i=class{constructor({confidence:e,transcript:t}){this.#t=e,this.#e=t}#t;#e;get confidence(){return this.#t}get transcript(){return this.#e}};var si=class{constructor(e){if(!e)throw new Error("array must be set.");this.#t=e;for(let t in e)Object.defineProperty(this,t,{enumerable:!0,get(){return e[t]}})}#t;[Symbol.iterator](){return this.#t[Symbol.iterator]()}get length(){return this.#t.length}};var oi=class extends si{constructor(e){super(e.results),this.#t=e.isFinal}#t;get isFinal(){return this.#t}};var{ResultReason:{RecognizingSpeech:Kb,RecognizedSpeech:Of}}=Gi;function Mf(i,e){let{maxAlternatives:t=1/0,textNormalization:r="display"}=e||{},n=typeof i.json=="string"?JSON.parse(i.json):i.json;return i.reason===Kb||i.reason===Of&&!n.NBest?new oi({isFinal:i.reason===Of,results:[new $i({confidence:.5,transcript:i.text})]}):i.reason===Of?new oi({isFinal:!0,results:(n.NBest||[]).slice(0,t).map(({Confidence:s,Display:o,ITN:a,Lexical:c,MaskedITN:u})=>new $i({confidence:s,transcript:r==="itn"?a:r==="lexical"?c:r==="maskeditn"?u:o}))}):new oi({isFinal:!1,results:[]})}function Qi(i,e=void 0){return(...t)=>new Promise((r,n)=>i.apply(e,[...t,r,n]))}var is=class{constructor(e){this.#t=e,this.#e={}}#t;#e;getProperty(e){return this.#e[e]}setProperty(e,t){let r=this.#e[e];r&&this.#t.removeEventListener(e,r),t&&this.#t.addEventListener(e,t),this.#e[e]=t}};var iR=Zf(nu());function Df(i){let e=Array.from(new Int16Array(i));return e.reduce((t,r)=>t+Math.abs(r),0)/e.length}function kf(i){let e=i,t=e.attach,r=e.attach.bind(e),n=!1,s=!1;return e.attach=async()=>{let o=await r("");return{...o,read:async()=>{let a=await o.read();return!n&&Df(a.buffer)>150&&(e.events.onEvent(new iR.AudioSourceEvent("FirstAudibleChunk","")),n=!0),s?{buffer:new ArrayBuffer(0),isEnd:!0,timeReceived:Date.now()}:a}}},{audioConfig:i,pause:()=>{s=!0},unprepare:()=>{e.attach=t}}}function Op({duration:i,errorDetails:e,json:t,offset:r,properties:n,reason:s,resultId:o,text:a}){return Object.freeze({duration:i,errorDetails:e,json:t&&JSON.parse(t),offset:r,properties:n,reason:s,resultId:o,text:a})}var ai=class{constructor(){this.#t=[]}addFromString(){throw new Error("JSGF is not supported")}addFromURI(){throw new Error("JSGF is not supported")}item(){throw new Error("JSGF is not supported")}get length(){throw new Error("JSGF is not supported")}#t;get phrases(){return this.#t}set phrases(e){if(Array.isArray(e))this.#t=Object.freeze([...e]);else if(typeof e=="string")this.#t=Object.freeze([e]);else throw new Error("The provided value is not an array or of type 'string'")}};var kt=class extends Event{constructor(e,{error:t,message:r}){super(e),this.#t=t,this.#e=r}#t;#e;get error(){return this.#t}get message(){return this.#e}get type(){return"error"}};var Nt=class extends si{constructor(e){super(e)}};var W=class extends Event{constructor(e,{data:t,resultIndex:r,results:n}={}){super(e),this.#t=t,this.#e=r,this.#r=n||new Nt([])}#t;#e;#r;get data(){return this.#t}get resultIndex(){return this.#e}get results(){return this.#r}get type(){return super.type}};var{ResultReason:Jb,SpeechRecognizer:Gb}=Gi;function Rr({createRecognizer:i,enableTelemetry:e,looseEvents:t,referenceGrammars:r,textNormalization:n}){Gb.enableTelemetry(e!==!1);class s extends EventTarget{#t=!1;#e=new is(this);#r=new ai;#i=!1;#n=typeof window<"u"?window.document.documentElement.getAttribute("lang")||window.navigator.language:"en-US";#s=1;emitCognitiveServices(a,c){this.dispatchEvent(new W("cognitiveservices",{data:{...c,type:a}}))}get continuous(){return this.#t}set continuous(a){this.#t=a}get grammars(){return this.#r}set grammars(a){if(a instanceof ai)this.#r=a;else throw new Error("The provided value is not of type 'SpeechGrammarList'")}get interimResults(){return this.#i}set interimResults(a){this.#i=a}get maxAlternatives(){return this.#s}set maxAlternatives(a){this.#s=a}get lang(){return this.#n}set lang(a){this.#n=a}get onaudioend(){return this.#e.getProperty("audioend")}set onaudioend(a){this.#e.setProperty("audioend",a)}get onaudiostart(){return this.#e.getProperty("audiostart")}set onaudiostart(a){this.#e.setProperty("audiostart",a)}get oncognitiveservices(){return this.#e.getProperty("cognitiveservices")}set oncognitiveservices(a){this.#e.setProperty("cognitiveservices",a)}get onend(){return this.#e.getProperty("end")}set onend(a){this.#e.setProperty("end",a)}get onerror(){return this.#e.getProperty("error")}set onerror(a){this.#e.setProperty("error",a)}get onresult(){return this.#e.getProperty("result")}set onresult(a){this.#e.setProperty("result",a)}get onsoundend(){return this.#e.getProperty("soundend")}set onsoundend(a){this.#e.setProperty("soundend",a)}get onsoundstart(){return this.#e.getProperty("soundstart")}set onsoundstart(a){this.#e.setProperty("soundstart",a)}get onspeechend(){return this.#e.getProperty("speechend")}set onspeechend(a){this.#e.setProperty("speechend",a)}get onspeechstart(){return this.#e.getProperty("speechstart")}set onspeechstart(a){this.#e.setProperty("speechstart",a)}get onstart(){return this.#e.getProperty("start")}set onstart(a){this.#e.setProperty("start",a)}abort;stop;start(){this._startOnce().catch(a=>{this.dispatchEvent(new kt("error",{error:a,message:a&&(a.stack||a.message)}))})}async _startOnce(){let a=await i(this.lang),{pause:c,unprepare:u}=kf(a.audioConfig);try{let d=rR(),h,l,g,{detach:_}=a.audioConfig.events.attach(V=>{let{name:G}=V;G==="AudioSourceReadyEvent"?d.push({audioSourceReady:{}}):G==="AudioSourceOffEvent"?d.push({audioSourceOff:{}}):G==="FirstAudibleChunk"&&d.push({firstAudibleChunk:{}})});a.canceled=(V,{errorDetails:G,offset:nt,reason:wr,sessionId:qp})=>{d.push({canceled:{errorDetails:G,offset:nt,reason:wr,sessionId:qp}})},a.recognized=(V,{offset:G,result:nt,sessionId:wr})=>{d.push({recognized:{offset:G,result:Op(nt),sessionId:wr}})},a.recognizing=(V,{offset:G,result:nt,sessionId:wr})=>{d.push({recognizing:{offset:G,result:Op(nt),sessionId:wr}})},a.sessionStarted=(V,{sessionId:G})=>{d.push({sessionStarted:{sessionId:G}})},a.sessionStopped=(V,{sessionId:G})=>{d.push({sessionStopped:{sessionId:G}})},a.speechStartDetected=(V,{offset:G,sessionId:nt})=>{d.push({speechStartDetected:{offset:G,sessionId:nt}})},a.speechEndDetected=(V,{sessionId:G})=>{d.push({speechEndDetected:{sessionId:G}})};let{phrases:M}=this.grammars,{dynamicGrammar:J}=a.privReco;r&&r.length&&J.addReferenceGrammar([...r]),M&&M.length&&J.addPhrase([...M]),await Qi(a.startContinuousRecognitionAsync,a)(),typeof a.stopContinuousRecognitionAsync=="function"?(this.abort=()=>d.push({abort:{}}),this.stop=()=>d.push({stop:{}})):this.abort=this.stop=void 0;let F,ee,ye=[];for(let V=0;!g||F;V++){let G=await d.shift(),{abort:nt,audioSourceOff:wr,audioSourceReady:qp,canceled:Yf,firstAudibleChunk:jR,recognized:ci,recognizing:zp,stop:LR}=G;Object.keys(G).forEach(tn=>this.emitCognitiveServices(tn,G[tn]));let jp=Yf&&Yf.errorDetails;if(/Permission\sdenied/u.test(jp||"")){ee=new kt("error",{error:"not-allowed"});break}if(V||this.dispatchEvent(new W("start")),jp){/1006/u.test(jp)?(F||(this.dispatchEvent(new W("audiostart")),this.dispatchEvent(new W("audioend"))),ee=new kt("error",{error:"network"})):ee=new kt("error",{error:"unknown"});break}else if(nt||LR)nt?(ee=new kt("error",{error:"aborted"}),g="abort"):(c(),g="stop"),nt&&a.stopContinuousRecognitionAsync&&await Qi(a.stopContinuousRecognitionAsync,a)();else if(qp)this.dispatchEvent(new W("audiostart")),F=!0;else if(jR)this.dispatchEvent(new W("soundstart")),h=!0;else if(wr){l&&this.dispatchEvent(new W("speechend")),h&&this.dispatchEvent(new W("soundend")),F&&this.dispatchEvent(new W("audioend")),F=h=l=!1;break}else if(g!=="abort"){if(ci&&ci.result&&ci.result.reason===Jb.NoMatch){if(!this.continuous||g==="stop"){ee=new W("result",{results:new Nt(ye)}),a.stopContinuousRecognitionAsync&&await Qi(a.stopContinuousRecognitionAsync,a)();break}}else if(ci||zp)if(F||(this.dispatchEvent(new W("audiostart")),F=!0),h||(this.dispatchEvent(new W("soundstart")),h=!0),l||(this.dispatchEvent(new W("speechstart")),l=!0),ci){let tn=Mf(ci.result,{maxAlternatives:this.maxAlternatives,textNormalization:n}),Lp=!!tn[0]?.transcript;Lp&&(ye=[...ye,tn],this.continuous&&this.dispatchEvent(new W("result",{results:new Nt(ye)}))),this.continuous&&Lp?ee=void 0:ee=new W("result",{results:new Nt(ye)}),(!this.continuous||g==="stop")&&a.stopContinuousRecognitionAsync&&await Qi(a.stopContinuousRecognitionAsync,a)(),t&&ee&&Lp&&(this.dispatchEvent(ee),ee=void 0)}else zp&&this.interimResults&&this.dispatchEvent(new W("result",{results:new Nt([...ye,Mf(zp.result,{maxAlternatives:this.maxAlternatives,textNormalization:n})])}))}}l&&this.dispatchEvent(new W("speechend")),h&&this.dispatchEvent(new W("soundend")),F&&this.dispatchEvent(new W("audioend")),ee&&(ee.type==="result"&&!ee.results.length&&(ee=new kt("error",{error:"no-speech"})),this.dispatchEvent(ee)),this.dispatchEvent(new W("end")),_()}catch(d){throw console.error(d),d}finally{u(),a.dispose(!1)}}}return{SpeechGrammarList:ai,SpeechRecognition:s,SpeechRecognitionEvent:W}}var{AudioConfig:$b,OutputFormat:Qb,SpeechConfig:Mp,SpeechRecognizer:Yb}=Gi;function ns(i){let{audioConfig:e=$b.fromDefaultMicrophoneInput(),enableTelemetry:t=!0,fetchCredentials:r,looseEvents:n,referenceGrammars:s,speechRecognitionEndpointId:o,textNormalization:a="display"}=nn(i);if(!e&&(!window.navigator.mediaDevices||!window.navigator.mediaDevices.getUserMedia))throw new Error("web-speech-cognitive-services: This browser does not support Media Capture and Streams API and it will not work with Cognitive Services Speech Services.");return Rr({createRecognizer:async u=>{let d=await r(),h;if(typeof d.speechRecognitionHostname<"u"){let l=new URL("wss://hostname:443");l.hostname=d.speechRecognitionHostname,d.authorizationToken?(h=Mp.fromHost(l),h.authorizationToken=d.authorizationToken):h=Mp.fromHost(l,d.subscriptionKey)}else h=typeof d.authorizationToken<"u"?Mp.fromAuthorizationToken(d.authorizationToken,d.region):Mp.fromSubscription(d.subscriptionKey,d.region);return o&&(h.endpointId=o),h.outputFormat=Qb.Detailed,h.speechRecognitionLanguage=u||"en-US",new Yb(h,e)},enableTelemetry:t,looseEvents:n,referenceGrammars:s,textNormalization:a})}function jf(i,e,...t){if(!i)throw new TypeError(vR(e,t))}function vR(i,e){let t=0;return i.replace(/%[os]/gu,()=>fR(e[t++]))}function fR(i){return typeof i!="object"||i===null?String(i):Object.prototype.toString.call(i)}var nR;function Xb(i){try{let e=i instanceof Error?i:new Error(fR(i));if(nR){nR(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 ft=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,sR;var gt=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{if(sR){sR({...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{}}},Zb=new gt("W01","Unable to initialize event under dispatching."),eO=new gt("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),tO=new gt("W03","Assigning any truthy value to 'returnValue' property has no effect."),rO=new gt("W04","Unable to preventDefault on non-cancelable events."),iO=new gt("W05","Unable to preventDefault inside passive event listener invocation."),nO=new gt("W06","An event listener wasn't added because it has been added already: %o, %o"),Nf=new gt("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),oR=new gt("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),sO=new gt("W09","Event attribute handler must be a function: %o"),He=class{static get NONE(){return aR}static get CAPTURING_PHASE(){return cR}static get AT_TARGET(){return pR}static get BUBBLING_PHASE(){return uR}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let r=t??{};zf.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 se(this).type}get target(){return se(this).target}get srcElement(){return se(this).target}get currentTarget(){return se(this).currentTarget}composedPath(){let e=se(this).currentTarget;return e?[e]:[]}get NONE(){return aR}get CAPTURING_PHASE(){return cR}get AT_TARGET(){return pR}get BUBBLING_PHASE(){return uR}get eventPhase(){return se(this).dispatchFlag?2:0}stopPropagation(){se(this).stopPropagationFlag=!0}get cancelBubble(){return se(this).stopPropagationFlag}set cancelBubble(e){e?se(this).stopPropagationFlag=!0:eO.warn()}stopImmediatePropagation(){let e=se(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return se(this).bubbles}get cancelable(){return se(this).cancelable}get returnValue(){return!se(this).canceledFlag}set returnValue(e){e?tO.warn():dR(se(this))}preventDefault(){dR(se(this))}get defaultPrevented(){return se(this).canceledFlag}get composed(){return se(this).composed}get isTrusted(){return!1}get timeStamp(){return se(this).timeStamp}initEvent(e,t=!1,r=!1){let n=se(this);if(n.dispatchFlag){Zb.warn();return}zf.set(this,{...n,type:String(e),bubbles:!!t,cancelable:!!r,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},aR=0,cR=1,pR=2,uR=3,zf=new WeakMap;function se(i,e="this"){let t=zf.get(i);return jf(t!=null,"'%s' must be an object that Event constructor created, but got another one: %o",e,i),t}function dR(i){if(i.inPassiveListenerFlag){iO.warn();return}if(!i.cancelable){rO.warn();return}i.canceledFlag=!0}Object.defineProperty(He,"NONE",{enumerable:!0});Object.defineProperty(He,"CAPTURING_PHASE",{enumerable:!0});Object.defineProperty(He,"AT_TARGET",{enumerable:!0});Object.defineProperty(He,"BUBBLING_PHASE",{enumerable:!0});var xf=Object.getOwnPropertyNames(He.prototype);for(let i=0;i<xf.length;++i)xf[i]!=="constructor"&&Object.defineProperty(He.prototype,xf[i],{enumerable:!0});typeof ft<"u"&&typeof ft.Event<"u"&&Object.setPrototypeOf(He.prototype,ft.Event.prototype);function oO(i){return ft.DOMException?new ft.DOMException(i,"InvalidStateError"):(Yi==null&&(Yi=class gR extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,gR)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(Yi.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),lR(Yi),lR(Yi.prototype)),new Yi(i))}var Yi,hR={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 lR(i){let e=Object.keys(hR);for(let t=0;t<e.length;++t){let r=e[t],n=hR[r];Object.defineProperty(i,r,{get(){return n},configurable:!0,enumerable:!0})}}var Zi=class extends He{static wrap(e){return new(SR(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),mR.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,yR(e,n))}}stopPropagation(){super.stopPropagation();let{original:e}=Er(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;let{original:t}=Er(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:e}=Er(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;let{original:t}=Er(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();let{original:e}=Er(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){let{original:e}=Er(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},mR=new WeakMap;function Er(i){let e=mR.get(i);return jf(e!=null,"'this' is expected an Event object, but got",i),e}var Dp=new WeakMap;Dp.set(Object.prototype,Zi);typeof ft<"u"&&typeof ft.Event<"u"&&Dp.set(ft.Event.prototype,Zi);function SR(i){let e=Object.getPrototypeOf(i);if(e==null)return Zi;let t=Dp.get(e);return t==null&&(t=aO(SR(e),e),Dp.set(e,t)),t}function aO(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],yR(e,r[n]));return t}function yR(i,e){let t=Object.getOwnPropertyDescriptor(i,e);return{get(){let r=Er(this).original,n=r[e];return typeof n=="function"?n.bind(r):n},set(r){let n=Er(this).original;n[e]=r},configurable:t.configurable,enumerable:t.enumerable}}function cO(i,e,t,r,n,s){return{callback:i,flags:(e?1:0)|(t?2:0)|(r?4:0),signal:n,signalListener:s}}function pO(i){i.flags|=8}function CR(i){return(i.flags&1)===1}function PR(i){return(i.flags&2)===2}function RR(i){return(i.flags&4)===4}function uO(i){return(i.flags&8)===8}function dO({callback:i},e,t){try{typeof i=="function"?i.call(e,t):typeof i.handleEvent=="function"&&i.handleEvent(t)}catch(r){Xb(r)}}function ER({listeners:i},e,t){for(let r=0;r<i.length;++r)if(i[r].callback===e&&CR(i[r])===t)return r;return-1}function wR(i,e,t,r,n,s){let o;s&&(o=Lf.bind(null,i,e,t),s.addEventListener("abort",o));let a=cO(e,t,r,n,s,o);return i.cow?(i.cow=!1,i.listeners=[...i.listeners,a]):i.listeners.push(a),a}function Lf(i,e,t){let r=ER(i,e,t);return r!==-1?IR(i,r):!1}function IR(i,e,t=!1){let r=i.listeners[e];return pO(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 hO(){return Object.create(null)}function TR(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 Zt=class{constructor(){_R.set(this,hO())}addEventListener(e,t,r){let n=Xi(this),{callback:s,capture:o,once:a,passive:c,signal:u,type:d}=lO(e,t,r);if(s==null||u?.aborted)return;let h=TR(n,d),l=ER(h,s,o);if(l!==-1){fO(h.listeners[l],c,a,u);return}wR(h,s,o,c,a,u)}removeEventListener(e,t,r){let n=Xi(this),{callback:s,capture:o,type:a}=vO(e,t,r),c=n[a];s!=null&&c&&Lf(c,s,o)}dispatchEvent(e){let t=Xi(this)[String(e.type)];if(t==null)return!0;let r=e instanceof He?e:Zi.wrap(e),n=se(r,"event");if(n.dispatchFlag)throw oO("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(!uO(c)&&(RR(c)&&IR(t,a,!s)&&(a-=1),n.inPassiveListenerFlag=PR(c),dO(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}},_R=new WeakMap;function Xi(i,e="this"){let t=_R.get(i);return jf(t!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",e,i),t}function lO(i,e,t){var r;return AR(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 vO(i,e,t){return AR(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 AR(i){if(!(typeof i=="function"||typeof i=="object"&&i!==null&&typeof i.handleEvent=="function")){if(i==null||typeof i=="object"){oR.warn(i);return}throw new TypeError(vR(oR.message,[i]))}}function fO(i,e,t,r){nO.warn(CR(i)?"capture":"bubble",i.callback),PR(i)!==e&&Nf.warn("passive"),RR(i)!==t&&Nf.warn("once"),i.signal!==r&&Nf.warn("signal")}var qf=Object.getOwnPropertyNames(Zt.prototype);for(let i=0;i<qf.length;++i)qf[i]!=="constructor"&&Object.defineProperty(Zt.prototype,qf[i],{enumerable:!0});typeof ft<"u"&&typeof ft.EventTarget<"u"&&Object.setPrototypeOf(Zt.prototype,ft.EventTarget.prototype);function xt(i,e){var t,r;return(r=(t=Xi(i,"target")[e])===null||t===void 0?void 0:t.attrCallback)!==null&&r!==void 0?r:null}function qt(i,e,t){t!=null&&typeof t!="function"&&sO.warn(t),typeof t=="function"||typeof t=="object"&&t!==null?gO(i,e,t):mO(i,e)}function gO(i,e,t){let r=TR(Xi(i,"target"),String(e));r.attrCallback=t,r.attrListener==null&&(r.attrListener=wR(r,SO(r),!1,!1,!1,void 0))}function mO(i,e){let r=Xi(i,"target")[String(e)];r&&r.attrListener&&(Lf(r,r.attrListener.callback,!1),r.attrCallback=r.attrListener=void 0)}function SO(i){return function(e){let t=i.attrCallback;typeof t=="function"&&t.call(this,e)}}function bR(i){return!!((typeof i=="function"||typeof i=="object")&&i&&"then"in i&&typeof i.then=="function")}function Bf(i,e){return new Promise(t=>{try{let r=i.call(e);bR(r)?r.then(t,()=>t(void 0)):t(r)}catch{t(void 0)}})}var OR=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function yO(i,e){return!!(i===e||OR(i)&&OR(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 MR(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 kp=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 Np=class{constructor({audioContext:i,ponyfill:e}){this.consumer=null,this.paused=!1,this.queue=[],this.getAudioContext=MR(()=>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 kp(this.getAudioContext()),await this.consumer.start(this.queue),this.consumer=null}stop(){this.queue.splice(0),this.consumer&&this.consumer.stop()}};var er=class extends He{constructor(e){super(e)}};function DR(){let i={};return i.promise=new Promise((e,t)=>{i.reject=t,i.resolve=e}),i}var Ff=class{constructor(){this.#t=i=>{let e=this.#e.shift();e&&e.resolve(i),this.#r&&(this.#r.resolve(i),this.#r=void 0)}}#t;#e=[];#r=void 0;get eventListener(){return this.#t}[Symbol.iterator](){return{next:()=>({done:!1,value:this.upcoming()})}}one(){let i=DR();return this.#e.push(i),i.promise}upcoming(){return this.#r||(this.#r=DR()),this.#r.promise}};var kR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",os=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(ss=0;ss<kR.length;ss++)os[kR.charCodeAt(ss)]=ss;var ss;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),d=new Uint8Array(u);for(r=0;r<t;r+=4)s=os[i.charCodeAt(r)],o=os[i.charCodeAt(r+1)],a=os[i.charCodeAt(r+2)],c=os[i.charCodeAt(r+3)],d[n++]=s<<2|o>>4,d[n++]=(o&15)<<4|a>>2,d[n++]=(a&3)<<6|c&63;return u};function Vf(i){let e=Math.round((i-1)*100);return e>=0&&(e="+"+e),e+"%"}function Uf({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="${
|
|
26
|
+
<prosody pitch="${Vf(e)}" rate="${Vf(t)}" volume="${Vf(s)}">
|
|
27
27
|
${r}
|
|
28
28
|
</prosody>
|
|
29
29
|
</voice>
|
|
30
|
-
</speak>`}var
|
|
30
|
+
</speak>`}var PO=/^\s*<speak(\s|\/?>)/u,RO=/^\s*<\?xml\s/u;function Wf(i){return PO.test(i)||RO.test(i)}var EO="en-US",wO="riff-16khz-16bit-mono-pcm",IO="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)",TO="SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU3LjU2LjEwMQAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU3LjY0AAAAAAAAAAAAAAAAJAUHAAAAAAAAAYYoRBqpAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy45OS41VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMQpg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";async function xR({deploymentId:i,fetchCredentials:e,lang:t=EO,outputFormat:r=wO,pitch:n,rate:s,text:o,voice:a=IO,volume:c}){if(!o)return NR(TO);let{authorizationToken:u,region:d,speechSynthesisHostname:h,subscriptionKey:l}=await e();if(u&&l||!u&&!l)throw new Error('Only "authorizationToken" or "subscriptionKey" should be set.');if(d&&h||!d&&!h)throw new Error('Only "region" or "speechSynthesisHostnamename" should be set.');let g=Wf(o)?o:Uf({lang:t,pitch:n,rate:s,text:o,voice:a,volume:c}),_=h||(i?`${encodeURI(d)}.voice.speech.microsoft.com`:`${encodeURI(d)}.tts.speech.microsoft.com`),M=i?`?deploymentId=${encodeURI(i)}`:"",J=`https://${_}/cognitiveservices/v1${M}`,F=await fetch(J,{headers:{"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":r,...u?{Authorization:`Bearer ${u}`}:{"Ocp-Apim-Subscription-Key":l}},method:"POST",body:g});if(!F.ok)throw new Error(`web-speech-cognitive-services: Failed to syntheis speech, server returned ${F.status}`);return F.arrayBuffer()}function Hf(i,e,t){return i.addEventListener(e,t),()=>i.removeEventListener(e,t)}function _O(i,e){return new Promise((t,r)=>{let n=i.decodeAudioData(e,t,r);n&&typeof n.then=="function"&&t(n)})}function AO(i,e,t){return new Promise((r,n)=>{let s=new Ff,o=new Ff,a=Hf(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 Kf=class extends Zt{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 xt(this,"boundary")}set onboundary(e){qt(this,"boundary",e)}get onend(){return xt(this,"end")}set onend(e){qt(this,"end",e)}get onerror(){return xt(this,"error")}set onerror(e){qt(this,"error",e)}get onmark(){return xt(this,"mark")}set onmark(e){qt(this,"mark",e)}get onpause(){return xt(this,"pause")}set onpause(e){qt(this,"pause",e)}get onresume(){return xt(this,"resume")}set onresume(e){qt(this,"resume",e)}get onstart(){return xt(this,"start")}set onstart(e){qt(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=xR({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 er("start"));let t=e.createBufferSource(),r=await _O(e,await this.arrayBufferPromise);this._playingSource=t,await AO(e,r,t),this._playingSource=null,this.dispatchEvent(new er("end"))}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:"synthesis-failed",message:t.stack}))}}stop(){this._playingSource&&this._playingSource.stop()}},Jf=Kf;var en=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 bO({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 qR({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r}){let{models:n}=await bO({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r});return n.map(({properties:{Gender:s},locale:o,name:a})=>new en({gender:s,lang:o,voiceURI:a})).sort(({name:s},{name:o})=>s>o?1:s<o?-1:0)}async function Gf({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 en({gender:a,lang:c,voiceURI:u})).sort(({name:a},{name:c})=>a>c?1:a<c?-1:0)}var OO="audio-24khz-160kbitrate-mono-mp3",MO=[],zR=i=>{let{audioContext:e,fetchCredentials:t,ponyfill:r={AudioContext:window.AudioContext||window.webkitAudioContext},speechSynthesisDeploymentId:n,speechSynthesisOutputFormat:s=OO}=nn(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 Zt{constructor(){super(),this.queue=new Np({audioContext:e,ponyfill:r}),this.updateVoices()}cancel(){this.queue.stop()}getVoices(){return MO}get onvoiceschanged(){return xt(this,"voiceschanged")}set onvoiceschanged(c){qt(this,"voiceschanged",c)}pause(){this.queue.pause()}resume(){this.queue.resume()}speak(c){if(!(c instanceof Jf))throw new Error("invalid utterance");let{reject:u,resolve:d,promise:h}=rs(),l=({error:g,message:_})=>{let M=new Error(g);M.stack=_,u(M)};return c.addEventListener("end",d),c.addEventListener("error",l),c.preload({deploymentId:n,fetchCredentials:t,outputFormat:s}),this.queue.push(c),h.finally(()=>{c.removeEventListener("end",d),c.removeEventListener("error",l)})}get speaking(){return this.queue.speaking}async updateVoices(){let{customVoiceHostname:c,region:u,speechSynthesisHostname:d,subscriptionKey:h}=await t();n?h&&(console.warn("web-speech-cognitive-services: Listing of custom voice models are only available when using subscription key."),await Bf(async()=>{let l=await qR({customVoiceHostname:c,deploymentId:n,region:u,speechSynthesisHostname:d,subscriptionKey:h});this.getVoices=()=>l})):await Bf(async()=>{let l=await Gf(await t());this.getVoices=()=>l}),this.dispatchEvent(new er("voiceschanged"))}}return{speechSynthesis:new o,SpeechSynthesisEvent:er,SpeechSynthesisUtterance:Jf}};var $f=zR;function xp(i={}){return{...ns(i),...$f(i)}}var Qf=document.createElement("meta");Qf.setAttribute("name","web-speech-cognitive-services");Qf.setAttribute("content","version=8.0.0");document.head.appendChild(Qf);globalThis.WebSpeechCognitiveServices={create:xp,createSpeechRecognitionPonyfillFromRecognizer:Rr};})();
|
|
31
31
|
//# sourceMappingURL=web-speech-cognitive-services.production.min.js.map
|