PageSourceSearch

https://studio.d-id.com/v0.1262.0/assets/microsoft.cognitiveservices.speech.sdk-D1LxciGb.js

js d-id.com collected 2026-09-24 08:00:29 UTC 475,705 bytes, 23 lines download raw bytes

1import{lR as Th,R as Ah}from"./index-dK-KQR3u.js";function wh(t,r){for(var i=0;i<r.length;i++){const u=r[i];if(typeof u!="string"&&!Array.isArray(u)){for(const o in u)if(o!=="default"&&!(o in t)){const a=Object.getOwnPropertyDescriptor(u,o);a&&Object.defineProperty(t,o,a.get?a:{enumerable:!0,get:()=>u[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}const _h={},bh=Object.freeze(Object.defineProperty({__proto__:null,default:_h},Symbol.toStringTag,{value:"Module"}));var ee={},te={},De={},re={},b={},Gi={},ie={},Qi={},ke={},Wi={},ys;function fp(){if(ys)return Wi;ys=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.default=i;let t;const r=new Uint8Array(16);function i(){if(!t&&(t=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!t))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(r)}return Wi}var be={},Ne={},ze={},Rs;function Mh(){if(Rs)return ze;Rs=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.default=void 0;var t=/^(?:[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;return ze.default=t,ze}var Ps;function $i(){if(Ps)return Ne;Ps=1,Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.default=void 0;var t=r(Mh());function r(o){return o&&o.__esModule?o:{default:o}}function i(o){return typeof o=="string"&&t.default.test(o)}var u=i;return Ne.default=u,Ne}var Es;function Ki(){if(Es)return be;Es=1,Object.defineProperty(be,"__esModule",{value:!0}),be.default=void 0,be.unsafeStringify=u;var t=r($i());function r(n){return n&&n.__esModule?n:{default:n}}const i=[];for(let n=0;n<256;++n)i.push((n+256).toString(16).slice(1));function u(n,e=0){return i[n[e+0]]+i[n[e+1]]+i[n[e+2]]+i[n[e+3]]+"-"+i[n[e+4]]+i[n[e+5]]+"-"+i[n[e+6]]+i[n[e+7]]+"-"+i[n[e+8]]+i[n[e+9]]+"-"+i[n[e+10]]+i[n[e+11]]+i[n[e+12]]+i[n[e+13]]+i[n[e+14]]+i[n[e+15]]}function o(n,e=0){const s=u(n,e);if(!(0,t.default)(s))throw TypeError("Stringified UUID is invalid");return s}var a=o;return be.default=a,be}var Is;function Oh(){if(Is)return ke;Is=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.default=void 0;var t=i(fp()),r=Ki();function i(c){return c&&c.__esModule?c:{default:c}}let u,o,a=0,n=0;function e(c,p,d){let h=p&&d||0;const l=p||new Array(16);c=c||{};let v=c.node||u,f=c.clockseq!==void 0?c.clockseq:o;if(v==null||f==null){const P=c.random||(c.rng||t.default)();v==null&&(v=u=[P[0]|1,P[1],P[2],P[3],P[4],P[5]]),f==null&&(f=o=(P[6]<<8|P[7])&16383)}let g=c.msecs!==void 0?c.msecs:Date.now(),m=c.nsecs!==void 0?c.nsecs:n+1;const S=g-a+(m-n)/1e4;if(S<0&&c.clockseq===void 0&&(f=f+1&16383),(S<0||g>a)&&c.nsecs===void 0&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=g,n=m,o=f,g+=122192928e5;const C=((g&268435455)*1e4+m)%4294967296;l[h++]=C>>>24&255,l[h++]=C>>>16&255,l[h++]=C>>>8&255,l[h++]=C&255;const R=g/4294967296*1e4&268435455;l[h++]=R>>>8&255,l[h++]=R&255,l[h++]=R>>>24&15|16,l[h++]=R>>>16&255,l[h++]=f>>>8|128,l[h++]=f&255;for(let P=0;P<6;++P)l[h+P]=v[P];return p||(0,r.unsafeStringify)(l)}var s=e;return ke.default=s,ke}var je={},Q={},qe={},Ts;function gp(){if(Ts)return qe;Ts=1,Object.defineProperty(qe,"__esModule",{value:!0}),qe.default=void 0;var t=r($i());function r(o){return o&&o.__esModule?o:{default:o}}function i(o){if(!(0,t.default)(o))throw TypeError("Invalid UUID");let a;const n=new Uint8Array(16);return n[0]=(a=parseInt(o.slice(0,8),16))>>>24,n[1]=a>>>16&255,n[2]=a>>>8&255,n[3]=a&255,n[4]=(a=parseInt(o.slice(9,13),16))>>>8,n[5]=a&255,n[6]=(a=parseInt(o.slice(14,18),16))>>>8,n[7]=a&255,n[8]=(a=parseInt(o.slice(19,23),16))>>>8,n[9]=a&255,n[10]=(a=parseInt(o.slice(24,36),16))/1099511627776&255,n[11]=a/4294967296&255,n[12]=a>>>24&255,n[13]=a>>>16&255,n[14]=a>>>8&255,n[15]=a&255,n}var u=i;return qe.default=u,qe}var As;function mp(){if(As)return Q;As=1,Object.defineProperty(Q,"__esModule",{value:!0}),Q.URL=Q.DNS=void 0,Q.default=n;var t=Ki(),r=i(gp());function i(e){return e&&e.__esModule?e:{default:e}}function u(e){e=unescape(encodeURIComponent(e));const s=[];for(let c=0;c<e.length;++c)s.push(e.charCodeAt(c));return s}const o="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Q.DNS=o;const a="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Q.URL=a;function n(e,s,c){function p(d,h,l,v){var f;
1if(typeof d=="string"&&(d=u(d)),typeof h=="string"&&(h=(0,r.default)(h)),((f=h)===null||f===void 0?void 0:f.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let g=new Uint8Array(16+d.length);if(g.set(h),g.set(d,h.length),g=c(g),g[6]=g[6]&15|s,g[8]=g[8]&63|128,l){v=v||0;for(let m=0;m<16;++m)l[v+m]=g[m];return l}return(0,t.unsafeStringify)(g)}try{p.name=e}catch{}return p.DNS=o,p.URL=a,p}return Q}var Le={},ws;function Dh(){if(ws)return Le;ws=1,Object.defineProperty(Le,"__esModule",{value:!0}),Le.default=void 0;function t(l){if(typeof l=="string"){const v=unescape(encodeURIComponent(l));l=new Uint8Array(v.length);for(let f=0;f<v.length;++f)l[f]=v.charCodeAt(f)}return r(u(o(l),l.length*8))}function r(l){const v=[],f=l.length*32,g="0123456789abcdef";for(let m=0;m<f;m+=8){const S=l[m>>5]>>>m%32&255,C=parseInt(g.charAt(S>>>4&15)+g.charAt(S&15),16);v.push(C)}return v}function i(l){return(l+64>>>9<<4)+14+1}function u(l,v){l[v>>5]|=128<<v%32,l[i(v)-1]=v;let f=1732584193,g=-271733879,m=-1732584194,S=271733878;for(let C=0;C<l.length;C+=16){const R=f,P=g,A=m,M=S;f=s(f,g,m,S,l[C],7,-680876936),S=s(S,f,g,m,l[C+1],12,-389564586),m=s(m,S,f,g,l[C+2],17,606105819),g=s(g,m,S,f,l[C+3],22,-1044525330),f=s(f,g,m,S,l[C+4],7,-176418897),S=s(S,f,g,m,l[C+5],12,1200080426),m=s(m,S,f,g,l[C+6],17,-1473231341),g=s(g,m,S,f,l[C+7],22,-45705983),f=s(f,g,m,S,l[C+8],7,1770035416),S=s(S,f,g,m,l[C+9],12,-1958414417),m=s(m,S,f,g,l[C+10],17,-42063),g=s(g,m,S,f,l[C+11],22,-1990404162),f=s(f,g,m,S,l[C+12],7,1804603682),S=s(S,f,g,m,l[C+13],12,-40341101),m=s(m,S,f,g,l[C+14],17,-1502002290),g=s(g,m,S,f,l[C+15],22,1236535329),f=c(f,g,m,S,l[C+1],5,-165796510),S=c(S,f,g,m,l[C+6],9,-1069501632),m=c(m,S,f,g,l[C+11],14,643717713),g=c(g,m,S,f,l[C],20,-373897302),f=c(f,g,m,S,l[C+5],5,-701558691),S=c(S,f,g,m,l[C+10],9,38016083),m=c(m,S,f,g,l[C+15],14,-660478335),g=c(g,m,S,f,l[C+4],20,-405537848),f=c(f,g,m,S,l[C+9],5,568446438),S=c(S,f,g,m,l[C+14],9,-1019803690),m=c(m,S,f,g,l[C+3],14,-187363961),g=c(g,m,S,f,l[C+8],20,1163531501),f=c(f,g,m,S,l[C+13],5,-1444681467),S=c(S,f,g,m,l[C+2],9,-51403784),m=c(m,S,f,g,l[C+7],14,1735328473),g=c(g,m,S,f,l[C+12],20,-1926607734),f=p(f,g,m,S,l[C+5],4,-378558),S=p(S,f,g,m,l[C+8],11,-2022574463),m=p(m,S,f,g,l[C+11],16,1839030562),g=p(g,m,S,f,l[C+14],23,-35309556),f=p(f,g,m,S,l[C+1],4,-1530992060),S=p(S,f,g,m,l[C+4],11,1272893353),m=p(m,S,f,g,l[C+7],16,-155497632),g=p(g,m,S,f,l[C+10],23,-1094730640),f=p(f,g,m,S,l[C+13],4,681279174),S=p(S,f,g,m,l[C],11,-358537222),m=p(m,S,f,g,l[C+3],16,-722521979),g=p(g,m,S,f,l[C+6],23,76029189),f=p(f,g,m,S,l[C+9],4,-640364487),S=p(S,f,g,m,l[C+12],11,-421815835),m=p(m,S,f,g,l[C+15],16,530742520),g=p(g,m,S,f,l[C+2],23,-995338651),f=d(f,g,m,S,l[C],6,-198630844),S=d(S,f,g,m,l[C+7],10,1126891415),m=d(m,S,f,g,l[C+14],15,-1416354905),g=d(g,m,S,f,l[C+5],21,-57434055),f=d(f,g,m,S,l[C+12],6,1700485571),S=d(S,f,g,m,l[C+3],10,-1894986606),m=d(m,S,f,g,l[C+10],15,-1051523),g=d(g,m,S,f,l[C+1],21,-2054922799),f=d(f,g,m,S,l[C+8],6,1873313359),S=d(S,f,g,m,l[C+15],10,-30611744),m=d(m,S,f,g,l[C+6],15,-1560198380),g=d(g,m,S,f,l[C+13],21,1309151649),f=d(f,g,m,S,l[C+4],6,-145523070),S=d(S,f,g,m,l[C+11],10,-1120210379),m=d(m,S,f,g,l[C+2],15,718787259),g=d(g,m,S,f,l[C+9],21,-343485551),f=a(f,R),g=a(g,P),m=a(m,A),S=a(S,M)}return[f,g,m,S]}function o(l){if(l.length===0)return[];const v=l.length*8,f=new Uint32Array(i(v));for(let g=0;g<v;g+=8)f[g>>5]|=(l[g/8]&255)<<g%32;return f}function a(l,v){const f=(l&65535)+(v&65535);return(l>>16)+(v>>16)+(f>>16)<<16|f&65535}function n(l,v){return l<<v|l>>>32-v}function e(l,v,f,g,m,S){return a(n(a(a(v,l),a(g,S)),m),f)}function s(l,v,f,g,m,S,C){return e(v&f|~v&g,l,v,m,S,C)}function c(l,v,f,g,m,S,C){return e(v&g|f&~g,l,v,m,S,C)}function p(l,v,f,g,m,S,C){return e(v^f^g,l,v,m,S,C)}function d(l,v,f,g,m,S,C){return e(f^(v|~g),l,v,m,S,C)}var h=t;return Le.default=h,Le}var _s;function kh(){if(_s)return je;_s=1,Object.defineProperty(je,"__esModule",{value:!0}),je.default=void 0;var t=i(mp()),r=i(Dh());function i(a){return a&&a.__esModule?a:{default:a}}var o=(0,t.default)("v3",48,r.default);return je.default=o,je}var Be={},xe={},bs;function Nh(){if(bs)return xe;
1bs=1,Object.defineProperty(xe,"__esModule",{value:!0}),xe.default=void 0;var r={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};return xe.default=r,xe}var Ms;function zh(){if(Ms)return Be;Ms=1,Object.defineProperty(Be,"__esModule",{value:!0}),Be.default=void 0;var t=u(Nh()),r=u(fp()),i=Ki();function u(n){return n&&n.__esModule?n:{default:n}}function o(n,e,s){if(t.default.randomUUID&&!e&&!n)return t.default.randomUUID();n=n||{};const c=n.random||(n.rng||r.default)();if(c[6]=c[6]&15|64,c[8]=c[8]&63|128,e){s=s||0;for(let p=0;p<16;++p)e[s+p]=c[p];return e}return(0,i.unsafeStringify)(c)}var a=o;return Be.default=a,Be}var Fe={},Ue={},Os;function jh(){if(Os)return Ue;Os=1,Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.default=void 0;function t(o,a,n,e){switch(o){case 0:return a&n^~a&e;case 1:return a^n^e;case 2:return a&n^a&e^n&e;case 3:return a^n^e}}function r(o,a){return o<<a|o>>>32-a}function i(o){const a=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof o=="string"){const p=unescape(encodeURIComponent(o));o=[];for(let d=0;d<p.length;
1++d)o.push(p.charCodeAt(d))}else Array.isArray(o)||(o=Array.prototype.slice.call(o));o.push(128);const e=o.length/4+2,s=Math.ceil(e/16),c=new Array(s);for(let p=0;p<s;++p){const d=new Uint32Array(16);for(let h=0;h<16;++h)d[h]=o[p*64+h*4]<<24|o[p*64+h*4+1]<<16|o[p*64+h*4+2]<<8|o[p*64+h*4+3];c[p]=d}c[s-1][14]=(o.length-1)*8/Math.pow(2,32),c[s-1][14]=Math.floor(c[s-1][14]),c[s-1][15]=(o.length-1)*8&4294967295;for(let p=0;p<s;++p){const d=new Uint32Array(80);for(let m=0;m<16;++m)d[m]=c[p][m];for(let m=16;m<80;++m)d[m]=r(d[m-3]^d[m-8]^d[m-14]^d[m-16],1);let h=n[0],l=n[1],v=n[2],f=n[3],g=n[4];for(let m=0;m<80;++m){const S=Math.floor(m/20),C=r(h,5)+t(S,l,v,f)+g+a[S]+d[m]>>>0;g=f,f=v,v=r(l,30)>>>0,l=h,h=C}n[0]=n[0]+h>>>0,n[1]=n[1]+l>>>0,n[2]=n[2]+v>>>0,n[3]=n[3]+f>>>0,n[4]=n[4]+g>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var u=i;return Ue.default=u,Ue}var Ds;function qh(){if(Ds)return Fe;Ds=1,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.default=void 0;var t=i(mp()),r=i(jh());function i(a){return a&&a.__esModule?a:{default:a}}var o=(0,t.default)("v5",80,r.default);return Fe.default=o,Fe}var We={},ks;function Lh(){if(ks)return We;ks=1,Object.defineProperty(We,"__esModule",{value:!0}),We.default=void 0;var t="00000000-0000-0000-0000-000000000000";return We.default=t,We}var He={},Ns;function Bh(){if(Ns)return He;Ns=1,Object.defineProperty(He,"__esModule",{value:!0}),He.default=void 0;var t=r($i());function r(o){return o&&o.__esModule?o:{default:o}}function i(o){if(!(0,t.default)(o))throw TypeError("Invalid UUID");return parseInt(o.slice(14,15),16)}var u=i;return He.default=u,He}var zs;function xh(){return zs||(zs=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"NIL",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(t,"v1",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(t,"v3",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(t,"v4",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(t,"v5",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(t,"validate",{enumerable:!0,get:function(){return e.default}}),Object.defineProperty(t,"version",{enumerable:!0,get:function(){return n.default}});var r=p(Oh()),i=p(kh()),u=p(zh()),o=p(qh()),a=p(Lh()),n=p(Bh()),e=p($i()),s=p(Ki()),c=p(gp());function p(d){return d&&d.__esModule?d:{default:d}}})(Qi)),Qi}var js;function Ae(){if(js)return ie;js=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.createNoDashGuid=ie.createGuid=void 0;const t=xh(),r=()=>t.v4();ie.createGuid=r;const i=()=>r().replace(new RegExp("-","g"),"").toUpperCase();return ie.createNoDashGuid=i,ie}var qs;function Li(){return qs||(qs=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformEvent=t.EventType=void 0;const r=Ae();(function(u){u[u.Debug=0]="Debug",u[u.Info=1]="Info",u[u.Warning=2]="Warning",u[u.Error=3]="Error",u[u.None=4]="None"})(t.EventType||(t.EventType={}));class i{constructor(o,a){this.privName=o,this.privEventId=r.createNoDashGuid(),this.privEventTime=new Date().toISOString(),this.privEventType=a,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}}t.PlatformEvent=i})(Gi)),Gi}var Ls;function Fh(){if(Ls)return b;Ls=1,Object.defineProperty(b,"__esModule",{value:!0}),b.AudioStreamNodeErrorEvent=b.AudioStreamNodeDetachedEvent=b.AudioStreamNodeAttachedEvent=b.AudioStreamNodeAttachingEvent=b.AudioStreamNodeEvent=b.AudioSourceErrorEvent=b.AudioSourceOffEvent=b.AudioSourceReadyEvent=b.AudioSourceInitializingEvent=b.AudioSourceEvent=void 0;const t=Li();class r extends t.PlatformEvent{constructor(h,l,v=t.EventType.Info){super(h,v),this.privAudioSourceId=l}get audioSourceId(){return this.privAudioSourceId}}b.AudioSourceEvent=r;class i extends r{constructor(h){super("AudioSourceInitializingEvent",h)}}b.AudioSourceInitializingEvent=i;class u extends r{constructor(h){super("AudioSourceReadyEvent",h)}}b.AudioSourceReadyEvent=u;class o extends r{constructor(h){super("AudioSourceOffEvent",h)}}b.AudioSourceOffEvent=o;class a extends r{constructor(h,l){super("AudioSourceErrorEvent",h,t.EventType.Error),this.privError=l}get error(){return this.privError}}b.AudioSourceErrorEvent=a;
1class n extends r{constructor(h,l,v){super(h,l),this.privAudioNodeId=v}get audioNodeId(){return this.privAudioNodeId}}b.AudioStreamNodeEvent=n;class e extends n{constructor(h,l){super("AudioStreamNodeAttachingEvent",h,l)}}b.AudioStreamNodeAttachingEvent=e;class s extends n{constructor(h,l){super("AudioStreamNodeAttachedEvent",h,l)}}b.AudioStreamNodeAttachedEvent=s;class c extends n{constructor(h,l){super("AudioStreamNodeDetachedEvent",h,l)}}b.AudioStreamNodeDetachedEvent=c;class p extends n{constructor(h,l,v){super("AudioStreamNodeErrorEvent",h,l),this.privError=v}get error(){return this.privError}}return b.AudioStreamNodeErrorEvent=p,b}var O={},Bs;function Uh(){if(Bs)return O;Bs=1,Object.defineProperty(O,"__esModule",{value:!0}),O.ConnectionMessageSentEvent=O.ConnectionMessageReceivedEvent=O.ConnectionEstablishErrorEvent=O.ConnectionErrorEvent=O.ConnectionClosedEvent=O.ConnectionEstablishedEvent=O.ConnectionStartEvent=O.ConnectionEvent=O.ServiceEvent=void 0;const t=Li();class r extends t.PlatformEvent{constructor(d,h,l=t.EventType.Info){super(d,l),this.privJsonResult=h}get jsonString(){return this.privJsonResult}}O.ServiceEvent=r;class i extends t.PlatformEvent{constructor(d,h,l=t.EventType.Info){super(d,l),this.privConnectionId=h}get connectionId(){return this.privConnectionId}}O.ConnectionEvent=i;class u extends i{constructor(d,h,l){super("ConnectionStartEvent",d),this.privUri=h,this.privHeaders=l}get uri(){return this.privUri}get headers(){return this.privHeaders}}O.ConnectionStartEvent=u;class o extends i{constructor(d){super("ConnectionEstablishedEvent",d)}}O.ConnectionEstablishedEvent=o;class a extends i{constructor(d,h,l){super("ConnectionClosedEvent",d,t.EventType.Debug),this.privReason=l,this.privStatusCode=h}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}}O.ConnectionClosedEvent=a;class n extends i{constructor(d,h,l){super("ConnectionErrorEvent",d,t.EventType.Debug),this.privMessage=h,this.privType=l}get message(){return this.privMessage}get type(){return this.privType}}O.ConnectionErrorEvent=n;class e extends i{constructor(d,h,l){super("ConnectionEstablishErrorEvent",d,t.EventType.Error),this.privStatusCode=h,this.privReason=l}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}}O.ConnectionEstablishErrorEvent=e;class s extends i{constructor(d,h,l){super("ConnectionMessageReceivedEvent",d),this.privNetworkReceivedTime=h,this.privMessage=l}get networkReceivedTime(){return this.privNetworkReceivedTime}get message(){return this.privMessage}}O.ConnectionMessageReceivedEvent=s;class c extends i{constructor(d,h,l){super("ConnectionMessageSentEvent",d),this.privNetworkSentTime=h,this.privMessage=l}get networkSentTime(){return this.privNetworkSentTime}get message(){return this.privMessage}}return O.ConnectionMessageSentEvent=c,O}var Xi={},$={},xs;function V(){if(xs)return $;xs=1,Object.defineProperty($,"__esModule",{value:!0}),$.ObjectDisposedError=$.InvalidOperationError=$.ArgumentNullError=void 0;class t extends Error{constructor(o){super(o),this.name="ArgumentNull",this.message=o}}$.ArgumentNullError=t;class r extends Error{constructor(o){super(o),this.name="InvalidOperation",this.message=o}}$.InvalidOperationError=r;class i extends Error{constructor(o,a){super(a),this.name=o+"ObjectDisposed",this.message=a}}return $.ObjectDisposedError=i,$}var Fs;function Sp(){return Fs||(Fs=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionMessage=t.MessageType=void 0;const r=V(),i=Ae();var u;(function(a){a[a.Text=0]="Text",a[a.Binary=1]="Binary"})(u=t.MessageType||(t.MessageType={}));class o{constructor(n,e,s,c){if(this.privBody=null,n===u.Text&&e&&typeof e!="string")throw new r.InvalidOperationError("Payload must be a string");if(n===u.Binary&&e&&!(e instanceof ArrayBuffer))throw new r.InvalidOperationError("Payload must be ArrayBuffer");switch(this.privMessageType=n,this.privBody=e,this.privHeaders=s||{},this.privId=c||i.createNoDashGuid(),this.messageType){case u.Binary:this.privSize=this.binaryBody!==null?this.binaryBody.byteLength:0;break;case u.Text:this.privSize=this.textBody.length}}
1get messageType(){return this.privMessageType}get headers(){return this.privHeaders}get body(){return this.privBody}get textBody(){if(this.privMessageType===u.Binary)throw new r.InvalidOperationError("Not supported for binary message");return this.privBody}get binaryBody(){if(this.privMessageType===u.Text)throw new r.InvalidOperationError("Not supported for text message");return this.privBody}get id(){return this.privId}}t.ConnectionMessage=o})(Xi)),Xi}var Ve={},Us;function Wh(){if(Us)return Ve;Us=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.ConnectionOpenResponse=void 0;let t=class{constructor(i,u){this.privStatusCode=i,this.privReason=u}get statusCode(){return this.privStatusCode}get reason(){return this.privReason}};return Ve.ConnectionOpenResponse=t,Ve}var $e={},Ws;function Hh(){if(Ws)return $e;Ws=1,Object.defineProperty($e,"__esModule",{value:!0}),$e.DeferralMap=void 0;let t=class{constructor(){this.privMap={}}add(i,u){this.privMap[i]=u}getId(i){return this.privMap[i]}complete(i,u){try{this.privMap[i].resolve(u)}catch(o){this.privMap[i].reject(o)}finally{this.privMap[i]=void 0}}};return $e.DeferralMap=t,$e}var ne={},Hs;function Cp(){if(Hs)return ne;Hs=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.SendingAgentContextMessageEvent=ne.DialogEvent=void 0;const t=Li();class r extends t.PlatformEvent{constructor(o,a=t.EventType.Info){super(o,a)}}ne.DialogEvent=r;class i extends r{constructor(o){super("SendingAgentContextMessageEvent"),this.privAgentConfig=o}get agentConfig(){return this.privAgentConfig}}return ne.SendingAgentContextMessageEvent=i,ne}var Ke={},Je={},Vs;function yp(){if(Vs)return Je;Vs=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.EventSource=void 0;const t=V(),r=Ae();let i=class{constructor(o){this.privEventListeners={},this.privIsDisposed=!1,this.privConsoleListener=void 0,this.privMetadata=o}onEvent(o){if(this.isDisposed())throw new t.ObjectDisposedError("EventSource");if(this.metadata)for(const a in this.metadata)a&&o.metadata&&(o.metadata[a]||(o.metadata[a]=this.metadata[a]));for(const a in this.privEventListeners)a&&this.privEventListeners[a]&&this.privEventListeners[a](o)}attach(o){const a=r.createNoDashGuid();return this.privEventListeners[a]=o,{detach:()=>(delete this.privEventListeners[a],Promise.resolve())}}attachListener(o){return this.attach(a=>o.onEvent(a))}attachConsoleListener(o){return this.privConsoleListener&&this.privConsoleListener.detach(),this.privConsoleListener=this.attach(a=>o.onEvent(a)),this.privConsoleListener}isDisposed(){return this.privIsDisposed}dispose(){this.privEventListeners=null,this.privIsDisposed=!0}get metadata(){return this.privMetadata}};return Je.EventSource=i,Je}var $s;function Vh(){if($s)return Ke;$s=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.Events=void 0;const t=V(),r=yp();let i=class Yn{static setEventSource(o){if(!o)throw new t.ArgumentNullError("eventSource");Yn.privInstance=o}static get instance(){return Yn.privInstance}};return Ke.Events=i,i.privInstance=new r.EventSource,Ke}var Zi={},Ks;function $h(){return Ks||(Ks=1,Object.defineProperty(Zi,"__esModule",{value:!0})),Zi}var Yi={},Js;function Kh(){return Js||(Js=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionState=void 0,(function(r){r[r.None=0]="None",r[r.Connected=1]="Connected",r[r.Connecting=2]="Connecting",r[r.Disconnected=3]="Disconnected"})(t.ConnectionState||(t.ConnectionState={}))})(Yi)),Yi}var en={},Gs;function Jh(){return Gs||(Gs=1,Object.defineProperty(en,"__esModule",{value:!0})),en}var tn={},Qs;function Gh(){return Qs||(Qs=1,Object.defineProperty(tn,"__esModule",{value:!0})),tn}var rn={},Xs;function Qh(){return Xs||(Xs=1,Object.defineProperty(rn,"__esModule",{value:!0}
1)),rn}var nn={},Zs;function Xh(){return Zs||(Zs=1,Object.defineProperty(nn,"__esModule",{value:!0})),nn}var sn={},Ys;function Zh(){return Ys||(Ys=1,Object.defineProperty(sn,"__esModule",{value:!0})),sn}var on={},eo;function Yh(){return eo||(eo=1,Object.defineProperty(on,"__esModule",{value:!0})),on}var an={},to;function el(){return to||(to=1,Object.defineProperty(an,"__esModule",{value:!0})),an}var cn={},ro;function tl(){return ro||(ro=1,Object.defineProperty(cn,"__esModule",{value:!0})),cn}var Ge={},io;function Rp(){if(io)return Ge;io=1,Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.List=void 0;const t=V();let r=class Ee{constructor(u){if(this.privSubscriptionIdCounter=0,this.privAddSubscriptions={},this.privRemoveSubscriptions={},this.privDisposedSubscriptions={},this.privDisposeReason=null,this.privList=[],u)for(const o of u)this.privList.push(o)}get(u){return this.throwIfDisposed(),this.privList[u]}first(){return this.get(0)}last(){return this.get(this.length()-1)}add(u){this.throwIfDisposed(),this.insertAt(this.privList.length,u)}insertAt(u,o){this.throwIfDisposed(),u===0?this.privList.unshift(o):u===this.privList.length?this.privList.push(o):this.privList.splice(u,0,o),this.triggerSubscriptions(this.privAddSubscriptions)}removeFirst(){return this.throwIfDisposed(),this.removeAt(0)}removeLast(){return this.throwIfDisposed(),this.removeAt(this.length()-1)}removeAt(u){return this.throwIfDisposed(),this.remove(u,1)[0]}remove(u,o){this.throwIfDisposed();const a=this.privList.splice(u,o);return this.triggerSubscriptions(this.privRemoveSubscriptions),a}clear(){this.throwIfDisposed(),this.remove(0,this.length())}length(){return this.throwIfDisposed(),this.privList.length}onAdded(u){this.throwIfDisposed();const o=this.privSubscriptionIdCounter++;return this.privAddSubscriptions[o]=u,{detach:()=>(delete this.privAddSubscriptions[o],Promise.resolve())}}onRemoved(u){this.throwIfDisposed();const o=this.privSubscriptionIdCounter++;return this.privRemoveSubscriptions[o]=u,{detach:()=>(delete this.privRemoveSubscriptions[o],Promise.resolve())}}onDisposed(u){this.throwIfDisposed();const o=this.privSubscriptionIdCounter++;return this.privDisposedSubscriptions[o]=u,{detach:()=>(delete this.privDisposedSubscriptions[o],Promise.resolve())}}join(u){return this.throwIfDisposed(),this.privList.join(u)}toArray(){const u=Array();return this.privList.forEach(o=>{u.push(o)}),u}any(u){return this.throwIfDisposed(),u?this.where(u).length()>0:this.length()>0}all(u){return this.throwIfDisposed(),this.where(u).length()===this.length()}forEach(u){this.throwIfDisposed();for(let o=0;o<this.length();o++)u(this.privList[o],o)}select(u){this.throwIfDisposed();const o=[];for(let a=0;a<this.privList.length;a++)o.push(u(this.privList[a],a));return new Ee(o)}where(u){this.throwIfDisposed();const o=new Ee;for(let a=0;a<this.privList.length;a++)u(this.privList[a],a)&&o.add(this.privList[a]);return o}orderBy(u){this.throwIfDisposed();const a=this.toArray().sort(u);return new Ee(a)}orderByDesc(u){return this.throwIfDisposed(),this.orderBy((o,a)=>u(a,o))}clone(){return this.throwIfDisposed(),new Ee(this.toArray())}concat(u){return this.throwIfDisposed(),new Ee(this.privList.concat(u.toArray()))}concatArray(u){return this.throwIfDisposed(),new Ee(this.privList.concat(u))}isDisposed(){return this.privList==null}dispose(u){this.isDisposed()||(this.privDisposeReason=u,this.privList=null,this.privAddSubscriptions=null,this.privRemoveSubscriptions=null,this.triggerSubscriptions(this.privDisposedSubscriptions))}throwIfDisposed(){if(this.isDisposed())throw new t.ObjectDisposedError("List",this.privDisposeReason)}triggerSubscriptions(u){if(u)for(const o in u)o&&u[o]()}};return Ge.List=r,Ge}var un={},no;function Pp(){return no||(no=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.marshalPromiseToCallbacks=t.Sink=t.Deferred=t.PromiseResultEventSource=t.PromiseResult=t.PromiseState=void 0;var r;(function(e){e[e.None=0]="None",e[e.Resolved=1]="Resolved",e[e.Rejected=2]="Rejected"})(r=t.PromiseState||(t.PromiseState={}));class i{constructor(s){this.throwIfError=()=>{if(this.isError)throw this.error},s.on(c=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!1,this.privResult=c)},c=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!0,this.privError=c)})}get isCompleted(){return this.privIsCompleted}get isError(){return this.privIsError}get error(){return this.privError}get result(){return this.privResult}}t.PromiseResult=i;class u{constructor(){this.setResult=s=>{this.privOnSetResult(s)},this.setError=s=>{this.privOnSetError(s)},this.on=(s,c)=>{this.privOnSetResult=s,this.privOnSetError=c}}}t.PromiseResultEventSource=u;class o{constructor(){this.resolve=s=>(this.privResolve(s),this),this.reject=s=>(this.privReject(s),this),this.privPromise=new Promise((s,c)=>{this.privResolve=s,this.privReject=c})}get promise(){return this.privPromise}}t.Deferred=o;class a{constructor(){this.privState=r.None,this.privPromiseResult=null,this.privPromiseResultEvents=null,this.privSuccessHandlers=[],this.privErrorHandlers=[],this.privPromiseResultEvents=new u,this.privPromiseResult=new i(this.privPromiseResultEvents)}get state(){return this.privState}get result(){return this.privPromiseResult}resolve(s){if(this.privState!==r.None)throw new Error("'Cannot resolve a completed promise'");this.privState=r.Resolved,this.privPromiseResultEvents.setResult(s);for(let c=0;c<this.privSuccessHandlers.length;c++)this.executeSuccessCallback(s,this.privSuccessHandlers[c],this.privErrorHandlers[c]);this.detachHandlers()}reject(s){if(this.privState!==r.None)throw new Error("'Cannot reject a completed promise'");this.privState=r.Rejected,this.privPromiseResultEvents.setError(s);for(const c of this.privErrorHandlers)this.executeErrorCallback(s,c);this.detachHandlers()}on(s,c){s==null&&(s=()=>{}),this.privState===r.None?(this.privSuccessHandlers.push(s),this.privErrorHandlers.push(c)):(this.privState===r.Resolved?this.executeSuccessCallback(this.privPromiseResult.result,s,c):this.privState===r.Rejected&&this.executeErrorCallback(this.privPromiseResult.error,c),this.detachHandlers())}executeSuccessCallback(s,c,p){try{c(s)}catch(d){this.executeErrorCallback(`'Unhandled callback error: ${d}'`,p)}}executeErrorCallback(s,c){if(c)try{c(s)}catch(p){throw new Error(`'Unhandled callback error: ${p}. InnerError: ${s}'`)}else throw new Error(`'Unhandled error: ${s}'`)}detachHandlers(){this.privErrorHandlers=[],this.privSuccessHandlers=[]}}t.Sink=a;function n(e,s,c){e.then(p=>{try{s&&s(p)}catch(d){if(c)try{if(d instanceof Error){const h=d;c(h.name+": "+h.message)}else c(d)}catch{}}},p=>{if(c)try{if(p instanceof Error){const d=p;c(d.name+": "+d.message)}
1else c(p)}catch{}})}t.marshalPromiseToCallbacks=n})(un)),un}var Qe={},so;function Ep(){if(so)return Qe;so=1,Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.Queue=void 0;const t=V(),r=Rp(),i=Pp();var u;(function(a){a[a.Dequeue=0]="Dequeue",a[a.Peek=1]="Peek"})(u||(u={}));let o=class{constructor(n){this.privPromiseStore=new r.List,this.privIsDrainInProgress=!1,this.privIsDisposing=!1,this.privDisposeReason=null,this.privList=n||new r.List,this.privDetachables=[],this.privSubscribers=new r.List,this.privDetachables.push(this.privList.onAdded(()=>this.drain()))}enqueue(n){this.throwIfDispose(),this.enqueueFromPromise(new Promise(e=>e(n)))}enqueueFromPromise(n){this.throwIfDispose(),n.then(e=>{this.privList.add(e)},()=>{})}dequeue(){this.throwIfDispose();const n=new i.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:n,type:u.Dequeue}),this.drain()),n.promise}peek(){this.throwIfDispose();const n=new i.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:n,type:u.Peek}),this.drain()),n.promise}length(){return this.throwIfDispose(),this.privList.length()}isDisposed(){return this.privSubscribers==null}async drainAndDispose(n,e){if(!this.isDisposed()&&!this.privIsDisposing){this.privDisposeReason=e,this.privIsDisposing=!0;const s=this.privSubscribers;if(s){for(;s.length()>0;)s.removeFirst().deferral.resolve(void 0);this.privSubscribers===s&&(this.privSubscribers=s)}for(const c of this.privDetachables)await c.detach();if(this.privPromiseStore.length()>0&&n){const c=[];return this.privPromiseStore.toArray().forEach(p=>{c.push(p)}),Promise.all(c).finally(()=>{this.privSubscribers=null,this.privList.forEach(p=>{n(p)}),this.privList=null}).then()}else this.privSubscribers=null,this.privList=null}}async dispose(n){await this.drainAndDispose(null,n)}drain(){if(!this.privIsDrainInProgress&&!this.privIsDisposing){this.privIsDrainInProgress=!0;const n=this.privSubscribers,e=this.privList;if(n&&e){for(;e.length()>0&&n.length()>0&&!this.privIsDisposing;){const s=n.removeFirst();if(s.type===u.Peek)s.deferral.resolve(e.first());else{const c=e.removeFirst();s.deferral.resolve(c)}}this.privSubscribers===n&&(this.privSubscribers=n),this.privList===e&&(this.privList=e)}this.privIsDrainInProgress=!1}}throwIfDispose(){if(this.isDisposed())throw this.privDisposeReason?new t.InvalidOperationError(this.privDisposeReason):new t.ObjectDisposedError("Queue");if(this.privIsDisposing)throw new t.InvalidOperationError("Queue disposing")}};return Qe.Queue=o,Qe}var Xe={},oo;function rl(){if(oo)return Xe;oo=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.RawWebsocketMessage=void 0;const t=Sp(),r=V(),i=Ae();let u=class{constructor(a,n,e){if(this.privPayload=null,!n)throw new r.ArgumentNullError("payload");if(a===t.MessageType.Binary&&Object.getPrototypeOf(n).constructor.name!=="ArrayBuffer")throw new r.InvalidOperationError("Payload must be ArrayBuffer");if(a===t.MessageType.Text&&typeof n!="string")throw new r.InvalidOperationError("Payload must be a string");this.privMessageType=a,this.privPayload=n,this.privId=e||i.createNoDashGuid()}get messageType(){return this.privMessageType}get payload(){return this.privPayload}
1get textContent(){if(this.privMessageType===t.MessageType.Binary)throw new r.InvalidOperationError("Not supported for binary message");return this.privPayload}get binaryContent(){if(this.privMessageType===t.MessageType.Text)throw new r.InvalidOperationError("Not supported for text message");return this.privPayload}get id(){return this.privId}};return Xe.RawWebsocketMessage=u,Xe}var Ze={},ao;function il(){if(ao)return Ze;ao=1,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.RiffPcmEncoder=void 0;let t=class{constructor(i,u){this.privActualSampleRate=i,this.privDesiredSampleRate=u}encode(i){const u=this.downSampleAudioFrame(i,this.privActualSampleRate,this.privDesiredSampleRate);if(!u)return null;const o=u.length*2,a=new ArrayBuffer(o),n=new DataView(a);return this.floatTo16BitPCM(n,0,u),a}setString(i,u,o){for(let a=0;a<o.length;a++)i.setUint8(u+a,o.charCodeAt(a))}floatTo16BitPCM(i,u,o){for(let a=0;a<o.length;a++,u+=2){const n=Math.max(-1,Math.min(1,o[a]));i.setInt16(u,n<0?n*32768:n*32767,!0)}}downSampleAudioFrame(i,u,o){if(!i)return null;if(o===u||o>u)return i;const a=u/o,n=Math.round(i.length/a),e=new Float32Array(n);let s=0,c=0;for(;c<n;){const p=Math.round((c+1)*a);let d=0,h=0;for(;s<p&&s<i.length;)d+=i[s++],h++;e[c++]=d/h}return e}};return Ze.RiffPcmEncoder=t,Ze}var Ye={},co;function nl(){if(co)return Ye;co=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.Stream=void 0;const t=V(),r=Ae(),i=Ep();let u=class{constructor(a){this.privIsWriteEnded=!1,this.privIsReadEnded=!1,this.privId=a||r.createNoDashGuid(),this.privReaderQueue=new i.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(a){if(this.throwIfClosed(),!this.privReaderQueue.isDisposed())try{this.privReaderQueue.enqueue(a)}catch{}}read(){if(this.privIsReadEnded)throw new t.InvalidOperationError("Stream read has already finished");return this.privReaderQueue.dequeue().then(async a=>((a===void 0||a.isEnd)&&await this.privReaderQueue.dispose("End of stream reached"),a))}readEnded(){this.privIsReadEnded||(this.privIsReadEnded=!0,this.privReaderQueue=new i.Queue)}throwIfClosed(){if(this.privIsWriteEnded)throw new t.InvalidOperationError("Stream closed")}};return Ye.Stream=u,Ye}var pn={},uo;function cs(){return uo||(uo=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.TranslationStatus=void 0,(function(r){r[r.Success=0]="Success",r[r.Error=1]="Error"})(t.TranslationStatus||(t.TranslationStatus={}))})(pn)),pn}var et={},po;function sl(){if(po)return et;po=1,Object.defineProperty(et,"__esModule",{value:!0}),et.ChunkedArrayBufferStream=void 0;const t=I();let r=class extends t.Stream{constructor(u,o){super(o),this.privTargetChunkSize=u,this.privNextBufferReadyBytes=0}writeStreamChunk(u){if(u.isEnd||this.privNextBufferReadyBytes===0&&u.buffer.byteLength===this.privTargetChunkSize){super.writeStreamChunk(u);return}let o=0;for(;o<u.buffer.byteLength;){this.privNextBufferToWrite===void 0&&(this.privNextBufferToWrite=new ArrayBuffer(this.privTargetChunkSize),this.privNextBufferStartTime=u.timeReceived);const a=Math.min(u.buffer.byteLength-o,this.privTargetChunkSize-this.privNextBufferReadyBytes),n=new Uint8Array(this.privNextBufferToWrite),e=new Uint8Array(u.buffer.slice(o,a+o));n.set(e,this.privNextBufferReadyBytes),this.privNextBufferReadyBytes+=a,o+=a,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()}};return et.ChunkedArrayBufferStream=r,et}var dn={},ho;function ol(){return ho||(ho=1,Object.defineProperty(dn,"__esModule",{value:!0})),dn}var tt={},lo;function al(){if(lo)return tt;
1lo=1,Object.defineProperty(tt,"__esModule",{value:!0}),tt.Timeout=void 0;let t=class X{static load(){const i=new Map([[0,()=>{}]]),u=new Map,a="data:text/javascript;base64,"+btoa(`!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return a})),n.d(t,"d",(function(){return d}));const r=new Map,o=new Map,i=e=>{const t=r.get(e);if(void 0===t)throw new Error('There is no interval scheduled with the given id "'.concat(e,'".'));clearTimeout(t),r.delete(e)},u=e=>{const t=o.get(e);if(void 0===t)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(t),o.delete(e)},f=(e,t)=>{let n,r;if("performance"in self){const o=performance.now();n=o,r=e-Math.max(0,o-t)}else n=Date.now(),r=e;return{expected:n+r,remainingDelay:r}},c=(e,t,n,r)=>{const o="performance"in self?performance.now():Date.now();o>n?postMessage({id:null,method:"call",params:{timerId:t}}):e.set(t,setTimeout(c,n-o,e,t,n))},a=(e,t,n)=>{const{expected:o,remainingDelay:i}=f(e,n);r.set(t,setTimeout(c,i,r,t,o))},d=(e,t,n)=>{const{expected:r,remainingDelay:i}=f(e,n);o.set(t,setTimeout(c,i,o,t,r))}},function(e,t,n){"use strict";n.r(t);var r=n(2);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(3);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(4);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o);var f=n(5);for(var o in f)"default"!==o&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var c=n(6);for(var o in c)"default"!==o&&function(e){n.d(t,e,(function(){return c[e]}))}(o);var a=n(7);for(var o in a)"default"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var d=n(8);for(var o in d)"default"!==o&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var s=n(9);for(var o in s)"default"!==o&&function(e){n.d(t,e,(function(){return s[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(11);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(12);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(13);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(1);for(var i in o)"default"!==i&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var u=n(10);for(var i in u)"default"!==i&&function(e){n.d(t,e,(function(){return u[e]}))}(i);addEventListener("message",({data:e})=>{try{if("clear"===e.method){const{id:t,params:{timerId:n}}=e;Object(r.b)(n),postMessage({error:null,id:t})}else{if("set"!==e.method)throw new Error('The given method "'.concat(e.method,'" is not supported'));{const{params:{delay:t,now:n,timerId:o}}=e;Object(r.d)(t,o,n)}}}catch(t){postMessage({error:{message:t.message},id:e.id,result:null})}})}]);`),n=new Worker(a);return n.addEventListener("message",({data:c})=>{if(X.isCallNotification(c)){const{params:{timerId:p}}=c,d=i.get(p);if(typeof d=="number"){const h=u.get(d);if(h===void 0||h!==p)throw new Error("The timer is in an undefined state.")}else if(typeof d<"u")d(),i.delete(p);else throw new Error("The timer is in an undefined state.")}else if(X.isClearResponse(c)){const{id:p}=c,d=u.get(p);if(d===void 0)throw new Error("The timer is in an undefined state.");
1u.delete(p),i.delete(d)}else{const{error:{message:p}}=c;throw new Error(p)}}),{clearTimeout:c=>{const p=Math.random();u.set(p,c),i.set(c,p),n.postMessage({id:p,method:"clear",params:{timerId:c}})},setTimeout:(c,p)=>{const d=Math.random();return i.set(d,c),n.postMessage({id:null,method:"set",params:{delay:p,now:performance.now(),timerId:d}}),d}}}static loadWorkerTimers(){return()=>(X.workerTimers!==null||(X.workerTimers=X.load()),X.workerTimers)}static isCallNotification(i){return i.method!==void 0&&i.method==="call"}static isClearResponse(i){return i.error===null&&typeof i.id=="number"}};return tt.Timeout=t,t.workerTimers=null,t.clearTimeout=r=>t.timers().clearTimeout(r),t.setTimeout=(r,i)=>t.timers().setTimeout(r,i),t.timers=t.loadWorkerTimers(),tt}var w={},vo;function cl(){if(vo)return w;vo=1,Object.defineProperty(w,"__esModule",{value:!0}),w.OCSPCacheUpdateErrorEvent=w.OCSPResponseRetrievedEvent=w.OCSPCacheFetchErrorEvent=w.OCSPVerificationFailedEvent=w.OCSPCacheHitEvent=w.OCSPCacheEntryNeedsRefreshEvent=w.OCSPCacheEntryExpiredEvent=w.OCSPWSUpgradeStartedEvent=w.OCSPStapleReceivedEvent=w.OCSPCacheUpdateCompleteEvent=w.OCSPDiskCacheStoreEvent=w.OCSPMemoryCacheStoreEvent=w.OCSPCacheUpdateNeededEvent=w.OCSPDiskCacheHitEvent=w.OCSPCacheMissEvent=w.OCSPMemoryCacheHitEvent=w.OCSPEvent=void 0;const t=Li();class r extends t.PlatformEvent{constructor(C,R,P){super(C,R),this.privSignature=P}}w.OCSPEvent=r;class i extends r{constructor(C){super("OCSPMemoryCacheHitEvent",t.EventType.Debug,C)}}w.OCSPMemoryCacheHitEvent=i;class u extends r{constructor(C){super("OCSPCacheMissEvent",t.EventType.Debug,C)}}w.OCSPCacheMissEvent=u;class o extends r{constructor(C){super("OCSPDiskCacheHitEvent",t.EventType.Debug,C)}}w.OCSPDiskCacheHitEvent=o;class a extends r{constructor(C){super("OCSPCacheUpdateNeededEvent",t.EventType.Debug,C)}}w.OCSPCacheUpdateNeededEvent=a;class n extends r{constructor(C){super("OCSPMemoryCacheStoreEvent",t.EventType.Debug,C)}}w.OCSPMemoryCacheStoreEvent=n;class e extends r{constructor(C){super("OCSPDiskCacheStoreEvent",t.EventType.Debug,C)}}w.OCSPDiskCacheStoreEvent=e;class s extends r{constructor(C){super("OCSPCacheUpdateCompleteEvent",t.EventType.Debug,C)}}w.OCSPCacheUpdateCompleteEvent=s;class c extends r{constructor(){super("OCSPStapleReceivedEvent",t.EventType.Debug,"")}}w.OCSPStapleReceivedEvent=c;class p extends r{constructor(C){super("OCSPWSUpgradeStartedEvent",t.EventType.Debug,C)}}w.OCSPWSUpgradeStartedEvent=p;class d extends r{constructor(C,R){super("OCSPCacheEntryExpiredEvent",t.EventType.Debug,C),this.privExpireTime=R}}w.OCSPCacheEntryExpiredEvent=d;class h extends r{constructor(C,R,P){super("OCSPCacheEntryNeedsRefreshEvent",t.EventType.Debug,C),this.privExpireTime=P,this.privStartTime=R}}w.OCSPCacheEntryNeedsRefreshEvent=h;class l extends r{constructor(C,R,P){super("OCSPCacheHitEvent",t.EventType.Debug,C),this.privExpireTime=P,this.privExpireTimeString=new Date(P).toLocaleDateString(),this.privStartTime=R,this.privStartTimeString=new Date(R).toLocaleTimeString()}}w.OCSPCacheHitEvent=l;class v extends r{constructor(C,R){super("OCSPVerificationFailedEvent",t.EventType.Debug,C),this.privError=R}}w.OCSPVerificationFailedEvent=v;class f extends r{constructor(C,R){super("OCSPCacheFetchErrorEvent",t.EventType.Debug,C),this.privError=R}}w.OCSPCacheFetchErrorEvent=f;class g extends r{constructor(C){super("OCSPResponseRetrievedEvent",t.EventType.Debug,C)}}w.OCSPResponseRetrievedEvent=g;class m extends r{constructor(C,R){super("OCSPCacheUpdateErrorEvent",t.EventType.Debug,C),this.privError=R}}return w.OCSPCacheUpdateErrorEvent=m,w}var rt={},fo;function ul(){if(fo)return rt;fo=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.BackgroundEvent=void 0;const t=I();class r extends t.PlatformEvent{constructor(u){super("BackgroundEvent",t.EventType.Error),this.privError=u}get error(){return this.privError}}return rt.BackgroundEvent=r,rt}var go;function I(){return go||(go=1,(function(t){var r=re&&re.__createBinding||(Object.create?(function(o,a,n,e){e===void 0&&(e=n),Object.defineProperty(o,e,{enumerable:!0,get:function(){return a[n]}})}):(function(o,a,n,e){e===void 0&&(e=n),o[e]=a[n]})),i=re&&re.__exportStar||function(o,a){for(var n in o)n!=="default"&&!a.hasOwnProperty(n)&&r(a,o,n)};
1Object.defineProperty(t,"__esModule",{value:!0}),i(Fh(),t),i(Uh(),t),i(Sp(),t),i(Wh(),t),i(Hh(),t),i(Cp(),t),i(V(),t),i(Vh(),t),i(yp(),t),i(Ae(),t),i($h(),t),i(Kh(),t),i(Jh(),t),i(Gh(),t),i(Qh(),t),i(Xh(),t),i(Zh(),t),i(Yh(),t),i(el(),t),i(tl(),t),i(Rp(),t),i(Li(),t),i(Pp(),t),i(Ep(),t),i(rl(),t),i(il(),t),i(nl(),t);var u=cs();Object.defineProperty(t,"TranslationStatus",{enumerable:!0,get:function(){return u.TranslationStatus}}),i(sl(),t),i(ol(),t),i(al(),t),i(cl(),t),i(ul(),t)})(re)),re}var it={},mo;function N(){if(mo)return it;mo=1,Object.defineProperty(it,"__esModule",{value:!0}),it.HeaderNames=void 0;let t=class{};return it.HeaderNames=t,t.AuthKey="Ocp-Apim-Subscription-Key",t.Authorization="Authorization",t.SpIDAuthKey="Apim-Subscription-Id",t.ConnectionId="X-ConnectionId",t.ContentType="Content-Type",t.CustomCommandsAppId="X-CommandsAppId",t.Path="Path",t.RequestId="X-RequestId",t.RequestStreamId="X-StreamId",t.RequestTimestamp="X-Timestamp",it}var nt={},So;function us(){if(So)return nt;So=1,Object.defineProperty(nt,"__esModule",{value:!0}),nt.AuthInfo=void 0;class t{constructor(i,u){this.privHeaderName=i,this.privToken=u}get headerName(){return this.privHeaderName}get token(){return this.privToken}}return nt.AuthInfo=t,nt}var Co;function pl(){if(Co)return De;Co=1,Object.defineProperty(De,"__esModule",{value:!0}),De.CognitiveSubscriptionKeyAuthentication=void 0;const t=I(),r=N(),i=us();let u=class{constructor(a){if(!a)throw new t.ArgumentNullError("subscriptionKey");this.privAuthInfo=new i.AuthInfo(r.HeaderNames.AuthKey,a)}fetch(a){return Promise.resolve(this.privAuthInfo)}fetchOnExpiry(a){return Promise.resolve(this.privAuthInfo)}};return De.CognitiveSubscriptionKeyAuthentication=u,De}var st={},yo;function dl(){if(yo)return st;yo=1,Object.defineProperty(st,"__esModule",{value:!0}),st.CognitiveTokenAuthentication=void 0;const t=I(),r=us(),i=N();let u=class es{constructor(a,n){if(!a)throw new t.ArgumentNullError("fetchCallback");if(!n)throw new t.ArgumentNullError("fetchOnExpiryCallback");this.privFetchCallback=a,this.privFetchOnExpiryCallback=n}fetch(a){return this.privFetchCallback(a).then(n=>new r.AuthInfo(i.HeaderNames.Authorization,n===void 0?void 0:es.privTokenPrefix+n))}fetchOnExpiry(a){return this.privFetchOnExpiryCallback(a).then(n=>new r.AuthInfo(i.HeaderNames.Authorization,n===void 0?void 0:es.privTokenPrefix+n))}};return st.CognitiveTokenAuthentication=u,u.privTokenPrefix="Bearer ",st}var hn={},Ro;function hl(){return Ro||(Ro=1,Object.defineProperty(hn,"__esModule",{value:!0})),hn}var ln={},Po;function ll(){return Po||(Po=1,Object.defineProperty(ln,"__esModule",{value:!0})),ln}var ot={},se={},F={};const Te=Th(bh);var vn={},Eo;function Ip(){return Eo||(Eo=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.LogLevel=void 0;const r=I();Object.defineProperty(t,"LogLevel",{enumerable:!0,get:function(){return r.EventType}})})(vn)),vn}var at={},Io;function T(){if(Io)return at;
1Io=1,Object.defineProperty(at,"__esModule",{value:!0}),at.Contracts=void 0;let t=class Ie{static throwIfNullOrUndefined(i,u){if(i==null)throw new Error("throwIfNullOrUndefined:"+u)}static throwIfNull(i,u){if(i===null)throw new Error("throwIfNull:"+u)}static throwIfNullOrWhitespace(i,u){if(Ie.throwIfNullOrUndefined(i,u),(""+i).trim().length<1)throw new Error("throwIfNullOrWhitespace:"+u)}static throwIfNullOrTooLong(i,u,o){if(Ie.throwIfNullOrUndefined(i,u),(""+i).length>o)throw new Error("throwIfNullOrTooLong:"+u+" (more than "+o.toString()+" characters)")}static throwIfNullOrTooShort(i,u,o){if(Ie.throwIfNullOrUndefined(i,u),(""+i).length<o)throw new Error("throwIfNullOrTooShort:"+u+" (less than "+o.toString()+" characters)")}static throwIfDisposed(i){if(i)throw new Error("the object is already disposed")}static throwIfArrayEmptyOrWhitespace(i,u){if(Ie.throwIfNullOrUndefined(i,u),i.length===0)throw new Error("throwIfArrayEmptyOrWhitespace:"+u);for(const o of i)Ie.throwIfNullOrWhitespace(o,u)}static throwIfFileDoesNotExist(i,u){Ie.throwIfNullOrWhitespace(i,u)}static throwIfNotUndefined(i,u){if(i!==void 0)throw new Error("throwIfNotUndefined:"+u)}};return at.Contracts=t,at}var To;function vl(){if(To)return F;To=1;var t=F&&F.__createBinding||(Object.create?(function(e,s,c,p){p===void 0&&(p=c),Object.defineProperty(e,p,{enumerable:!0,get:function(){return s[c]}})}):(function(e,s,c,p){p===void 0&&(p=c),e[p]=s[c]})),r=F&&F.__setModuleDefault||(Object.create?(function(e,s){Object.defineProperty(e,"default",{enumerable:!0,value:s})}):function(e,s){e.default=s}),i=F&&F.__importStar||function(e){if(e&&e.__esModule)return e;var s={};if(e!=null)for(var c in e)c!=="default"&&Object.hasOwnProperty.call(e,c)&&t(s,e,c);return r(s,e),s};Object.defineProperty(F,"__esModule",{value:!0}),F.ConsoleLoggingListener=void 0;const u=i(Te),o=Ip(),a=T();let n=class{constructor(s=o.LogLevel.None){this.privLogPath=void 0,this.privEnableConsoleOutput=!0,this.privLogLevelFilter=s}set logPath(s){a.Contracts.throwIfNullOrUndefined(u.openSync,`
2File System access not available`),this.privLogPath=s}set enableConsoleOutput(s){this.privEnableConsoleOutput=s}onEvent(s){if(s.eventType>=this.privLogLevelFilter){const c=this.toString(s);if(this.logCallback&&this.logCallback(c),this.privLogPath&&u.writeFileSync(this.privLogPath,c+`
3`,{flag:"a+"}),this.privEnableConsoleOutput)switch(s.eventType){case o.LogLevel.Debug:console.debug(c);break;case o.LogLevel.Info:console.info(c);break;case o.LogLevel.Warning:console.warn(c);break;case o.LogLevel.Error:console.error(c);break;default:console.log(c);break}}}toString(s){const c=[`${s.eventTime}`,`${s.name}`],p=s;for(const d in p)if(d&&s.hasOwnProperty(d)&&d!=="eventTime"&&d!=="eventType"&&d!=="eventId"&&d!=="name"&&d!=="constructor"){const h=p[d];let l="<NULL>";h!=null&&(typeof h=="number"||typeof h=="string"?l=h.toString():l=JSON.stringify(h)),c.push(`${d}: ${l}`)}return c.join(" | ")}};return F.ConsoleLoggingListener=n,F}var fn={},Ao;function fl(){return Ao||(Ao=1,Object.defineProperty(fn,"__esModule",{value:!0})),fn}var gn={},mn={},wo;function we(){return wo||(wo=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.AudioStreamFormatImpl=t.AudioStreamFormat=t.AudioFormatTag=void 0;var r;(function(o){o[o.PCM=1]="PCM",o[o.MuLaw=2]="MuLaw",o[o.Siren=3]="Siren",o[o.MP3=4]="MP3",o[o.SILKSkype=5]="SILKSkype",o[o.OGG_OPUS=6]="OGG_OPUS",o[o.WEBM_OPUS=7]="WEBM_OPUS",o[o.ALaw=8]="ALaw",o[o.FLAC=9]="FLAC",o[o.OPUS=10]="OPUS",o[o.AMR_WB=11]="AMR_WB",o[o.G722=12]="G722"})(r=t.AudioFormatTag||(t.AudioFormatTag={}));
3class i{static getDefaultInputFormat(){return u.getDefaultInputFormat()}static getWaveFormat(a,n,e,s){return new u(a,n,e,s)}static getWaveFormatPCM(a,n,e){return new u(a,n,e)}}t.AudioStreamFormat=i;class u extends i{constructor(a=16e3,n=16,e=1,s=r.PCM){super();let c=!0;switch(s){case r.PCM:this.formatTag=1;break;case r.ALaw:this.formatTag=6;break;case r.MuLaw:this.formatTag=7;break;default:c=!1}if(this.bitsPerSample=n,this.samplesPerSec=a,this.channels=e,this.avgBytesPerSec=this.samplesPerSec*this.channels*(this.bitsPerSample/8),this.blockAlign=this.channels*Math.max(this.bitsPerSample,8),c){this.privHeader=new ArrayBuffer(44);const p=new DataView(this.privHeader);this.setString(p,0,"RIFF"),p.setUint32(4,0,!0),this.setString(p,8,"WAVEfmt "),p.setUint32(16,16,!0),p.setUint16(20,this.formatTag,!0),p.setUint16(22,this.channels,!0),p.setUint32(24,this.samplesPerSec,!0),p.setUint32(28,this.avgBytesPerSec,!0),p.setUint16(32,this.channels*(this.bitsPerSample/8),!0),p.setUint16(34,this.bitsPerSample,!0),this.setString(p,36,"data"),p.setUint32(40,0,!0)}}static getDefaultInputFormat(){return new u}static getAudioContext(a){const n=window.AudioContext||window.webkitAudioContext||!1;if(n)return a!==void 0&&navigator.mediaDevices.getSupportedConstraints().sampleRate?new n({sampleRate:a}):new n;throw new Error("Browser does not support Web Audio API (AudioContext is not available).")}close(){}get header(){return this.privHeader}setString(a,n,e){for(let s=0;s<e.length;s++)a.setUint8(n+s,e.charCodeAt(s))}}t.AudioStreamFormatImpl=u})(mn)),mn}var _o;function gl(){return _o||(_o=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.MicAudioSource=t.AudioWorkletSourceURLPropertyName=void 0;const r=E(),i=I(),u=we();t.AudioWorkletSourceURLPropertyName="MICROPHONE-WorkletSourceUrl";class o{constructor(n,e,s,c){this.privRecorder=n,this.deviceId=e,this.privStreams={},this.privOutputChunkSize=o.AUDIOFORMAT.avgBytesPerSec/10,this.privId=s||i.createNoDashGuid(),this.privEvents=new i.EventSource,this.privMediaStream=c||null,this.privIsClosing=!1}get format(){return Promise.resolve(o.AUDIOFORMAT)}turnOn(){if(this.privInitializeDeferral)return this.privInitializeDeferral.promise;this.privInitializeDeferral=new i.Deferred;try{this.createAudioContext()}catch(s){if(s instanceof Error){const c=s;this.privInitializeDeferral.reject(c.name+": "+c.message)}else this.privInitializeDeferral.reject(s);return this.privInitializeDeferral.promise}const n=window.navigator;let e=n.getUserMedia||n.webkitGetUserMedia||n.mozGetUserMedia||n.msGetUserMedia;if(n.mediaDevices&&(e=(s,c,p)=>{n.mediaDevices.getUserMedia(s).then(c).catch(p)}),e){const s=()=>{this.onEvent(new i.AudioSourceInitializingEvent(this.privId)),this.privMediaStream&&this.privMediaStream.active?(this.onEvent(new i.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()):e({audio:this.deviceId?{deviceId:this.deviceId}:!0,video:!1},c=>{this.privMediaStream=c,this.onEvent(new i.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()},c=>{const p=`Error occurred during microphone initialization: ${c}`;this.privInitializeDeferral.reject(p),this.onEvent(new i.AudioSourceErrorEvent(this.privId,p))})};this.privContext.state==="suspended"?this.privContext.resume().then(s).catch(c=>{this.privInitializeDeferral.reject(`Failed to initialize audio context: ${c}`)}):s()}else{const s="Browser does not support getUserMedia.";this.privInitializeDeferral.reject(s),this.onEvent(new i.AudioSourceErrorEvent(s,""))}return this.privInitializeDeferral.promise}id(){return this.privId}attach(n){return this.onEvent(new i.AudioStreamNodeAttachingEvent(this.privId,n)),this.listen(n).then(e=>(this.onEvent(new i.AudioStreamNodeAttachedEvent(this.privId,n)),{detach:async()=>(e.readEnded(),delete this.privStreams[n],this.onEvent(new i.AudioStreamNodeDetachedEvent(this.privId,n)),this.turnOff()),id:()=>n,read:()=>e.read()}))}detach(n){n&&this.privStreams[n]&&(this.privStreams[n].close(),delete this.privStreams[n],this.onEvent(new i.AudioStreamNodeDetachedEvent(this.privId,n)))}async turnOff(){for(const n in this.privStreams)if(n){const e=this.privStreams[n];e&&e.close()}
3this.onEvent(new i.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(n=>({bitspersample:o.AUDIOFORMAT.bitsPerSample,channelcount:o.AUDIOFORMAT.channels,connectivity:r.connectivity.Unknown,manufacturer:"Speech SDK",model:n,samplerate:o.AUDIOFORMAT.samplesPerSec,type:r.type.Microphones}))}setProperty(n,e){if(n===t.AudioWorkletSourceURLPropertyName)this.privRecorder.setWorkletUrl(e);else throw new Error("Property '"+n+"' is not supported on Microphone.")}getMicrophoneLabel(){const n="microphone";if(this.privMicrophoneLabel!==void 0)return Promise.resolve(this.privMicrophoneLabel);if(this.privMediaStream===void 0||!this.privMediaStream.active)return Promise.resolve(n);this.privMicrophoneLabel=n;const e=this.privMediaStream.getTracks()[0].getSettings().deviceId;if(e===void 0)return Promise.resolve(this.privMicrophoneLabel);const s=new i.Deferred;return navigator.mediaDevices.enumerateDevices().then(c=>{for(const p of c)if(p.deviceId===e){this.privMicrophoneLabel=p.label;break}s.resolve(this.privMicrophoneLabel)},()=>s.resolve(this.privMicrophoneLabel)),s.promise}async listen(n){await this.turnOn();const e=new i.ChunkedArrayBufferStream(this.privOutputChunkSize,n);this.privStreams[n]=e;try{this.privRecorder.record(this.privContext,this.privMediaStream,e)}catch(c){throw this.onEvent(new i.AudioStreamNodeErrorEvent(this.privId,n,c)),c}return e}onEvent(n){this.privEvents.onEvent(n),i.Events.instance.onEvent(n)}createAudioContext(){this.privContext||(this.privContext=u.AudioStreamFormatImpl.getAudioContext(o.AUDIOFORMAT.samplesPerSec))}async destroyAudioContext(){if(!this.privContext)return;this.privRecorder.releaseMediaResources(this.privContext);let n=!1;"close"in this.privContext&&(n=!0),n?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()}}t.MicAudioSource=o,o.AUDIOFORMAT=u.AudioStreamFormat.getDefaultInputFormat()})(gn)),gn}var ct={},bo;function ml(){if(bo)return ct;bo=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.FileAudioSource=void 0;const t=E(),r=I(),i=we();let u=class{constructor(a,n,e){this.privStreams={},this.privHeaderEnd=44,this.privId=e||r.createNoDashGuid(),this.privEvents=new r.EventSource,this.privSource=a,typeof window<"u"&&typeof Blob<"u"&&this.privSource instanceof Blob?this.privFilename=a.name:this.privFilename=n||"unknown.wav",this.privAudioFormatPromise=this.readHeader()}get format(){return this.privAudioFormatPromise}turnOn(){if(this.privFilename.lastIndexOf(".wav")!==this.privFilename.length-4){const a=this.privFilename+" is not supported. Only WAVE files are allowed at the moment.";return this.onEvent(new r.AudioSourceErrorEvent(a,"")),Promise.reject(a)}this.onEvent(new r.AudioSourceInitializingEvent(this.privId)),this.onEvent(new r.AudioSourceReadyEvent(this.privId))}id(){return this.privId}async attach(a){this.onEvent(new r.AudioStreamNodeAttachingEvent(this.privId,a));const n=await this.upload(a);return this.onEvent(new r.AudioStreamNodeAttachedEvent(this.privId,a)),Promise.resolve({detach:async()=>{n.readEnded(),delete this.privStreams[a],this.onEvent(new r.AudioStreamNodeDetachedEvent(this.privId,a)),await this.turnOff()},id:()=>a,read:()=>n.read()})}detach(a){a&&this.privStreams[a]&&(this.privStreams[a].close(),delete this.privStreams[a],this.onEvent(new r.AudioStreamNodeDetachedEvent(this.privId,a)))}turnOff(){for(const a in this.privStreams)if(a){const n=this.privStreams[a];n&&!n.isClosed&&n.close()}return this.onEvent(new r.AudioSourceOffEvent(this.privId)),Promise.resolve()}get events(){return this.privEvents}get deviceInfo(){return this.privAudioFormatPromise.then(a=>Promise.resolve({bitspersample:a.bitsPerSample,channelcount:a.channels,connectivity:t.connectivity.Unknown,manufacturer:"Speech SDK",model:"File",samplerate:a.samplesPerSec,type:t.type.File}))}readHeader(){const n=this.privSource.slice(0,4296),e=new r.Deferred,s=c=>{const p=new DataView(c),d=m=>String.fromCharCode(p.getUint8(m),p.getUint8(m+1),p.getUint8(m+2),p.getUint8(m+3));if(d(0)!=="RIFF"){e.reject("Invalid WAV header in file, RIFF was not found");return}if(d(8)!=="WAVE"||d(12)!=="fmt "){e.reject("Invalid WAV header in file, WAVEfmt was not found");return}
3const h=p.getInt32(16,!0),l=p.getUint16(22,!0),v=p.getUint32(24,!0),f=p.getUint16(34,!0);let g=36+Math.max(h-16,0);for(;d(g)!=="data";g+=2)if(g>4288){e.reject("Invalid WAV header in file, data block was not found");return}this.privHeaderEnd=g+8,e.resolve(i.AudioStreamFormat.getWaveFormatPCM(v,f,l))};if(typeof window<"u"&&typeof Blob<"u"&&n instanceof Blob){const c=new FileReader;c.onload=p=>{const d=p.target.result;s(d)},c.readAsArrayBuffer(n)}else{const c=n;s(c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength))}return e.promise}async upload(a){const n=e=>{const s=`Error occurred while processing '${this.privFilename}'. ${e}`;throw this.onEvent(new r.AudioStreamNodeErrorEvent(this.privId,a,s)),new Error(s)};try{await this.turnOn();const e=await this.privAudioFormatPromise,s=new r.ChunkedArrayBufferStream(e.avgBytesPerSec/10,a);this.privStreams[a]=s;const c=this.privSource.slice(this.privHeaderEnd),p=d=>{s.isClosed||(s.writeStreamChunk({buffer:d,isEnd:!1,timeReceived:Date.now()}),s.close())};if(typeof window<"u"&&typeof Blob<"u"&&c instanceof Blob){const d=new FileReader;d.onerror=h=>n(h.toString()),d.onload=h=>{const l=h.target.result;p(l)},d.readAsArrayBuffer(c)}else{const d=c;p(d.buffer.slice(d.byteOffset,d.byteOffset+d.byteLength))}return s}catch(e){n(e)}}onEvent(a){this.privEvents.onEvent(a),r.Events.instance.onEvent(a)}};return ct.FileAudioSource=u,ct}var ut={},Mo;function Sl(){if(Mo)return ut;Mo=1,Object.defineProperty(ut,"__esModule",{value:!0}),ut.PcmRecorder=void 0;const t=I();class r{constructor(u){this.privStopInputOnRelease=u}record(u,o,a){const e=new t.RiffPcmEncoder(u.sampleRate,16e3),s=u.createMediaStreamSource(o),c=()=>{const d=(()=>{let h=0;try{return u.createScriptProcessor(h,1,1)}catch{h=2048;let v=u.sampleRate;for(;h<16384&&v>=32e3;)h<<=1,v>>=1;return u.createScriptProcessor(h,1,1)}})();d.onaudioprocess=h=>{const l=h.inputBuffer.getChannelData(0);if(a&&!a.isClosed){const v=e.encode(l);v&&a.writeStreamChunk({buffer:v,isEnd:!1,timeReceived:Date.now()})}},s.connect(d),d.connect(u.destination),this.privMediaResources={scriptProcessorNode:d,source:s,stream:o}},p=!!this.privSpeechProcessorScript&&this.privSpeechProcessorScript.toLowerCase()==="ignore";
3if(u.audioWorklet&&!p){if(!this.privSpeechProcessorScript){const d=`class SP extends AudioWorkletProcessor {
4                    constructor(options) {
5                      super(options);
6                    }
7                    process(inputs, outputs) {
8                      const input = inputs[0];
9                      const output = [];
10                      for (let channel = 0; channel < input.length; channel += 1) {
11                        output[channel] = input[channel];
12                      }
13                      this.port.postMessage(output[0]);
14                      return true;
15                    }
16                  }
17                  registerProcessor('speech-processor', SP);`,h=new Blob([d],{type:"application/javascript; charset=utf-8"});this.privSpeechProcessorScript=URL.createObjectURL(h)}u.audioWorklet.addModule(this.privSpeechProcessorScript).then(()=>{const d=new AudioWorkletNode(u,"speech-processor");d.port.onmessage=h=>{const l=h.data;if(a&&!a.isClosed){const v=e.encode(l);v&&a.writeStreamChunk({buffer:v,isEnd:!1,timeReceived:Date.now()})}},s.connect(d),d.connect(u.destination),this.privMediaResources={scriptProcessorNode:d,source:s,stream:o}}).catch(()=>{c()})}else try{c()}catch(d){throw new Error(`Unable to start audio worklet node for PCMRecorder: ${d}`)}}releaseMediaResources(u){this.privMediaResources&&(this.privMediaResources.scriptProcessorNode&&(this.privMediaResources.scriptProcessorNode.disconnect(u.destination),this.privMediaResources.scriptProcessorNode=null),this.privMediaResources.source&&(this.privMediaResources.source.disconnect(),this.privStopInputOnRelease&&this.privMediaResources.stream.getTracks().forEach(o=>o.stop()),this.privMediaResources.source=null))}setWorkletUrl(u){this.privSpeechProcessorScript=u}}return ut.PcmRecorder=r,ut}var pt={},L={},Oo;function Tp(){if(Oo)return L;Oo=1;var t=L&&L.__createBinding||(Object.create?(function(h,l,v,f){f===void 0&&(f=v),Object.defineProperty(h,f,{enumerable:!0,get:function(){return l[v]}})}):(function(h,l,v,f){f===void 0&&(f=v),h[f]=l[v]})),r=L&&L.__setModuleDefault||(Object.create?(function(h,l){Object.defineProperty(h,"default",{enumerable:!0,value:l})}):function(h,l){h.default=l}),i=L&&L.__importStar||function(h){if(h&&h.__esModule)return h;var l={};if(h!=null)for(var v in h)v!=="default"&&Object.hasOwnProperty.call(h,v)&&t(l,h,v);return r(l,h),l},u=L&&L.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(L,"__esModule",{value:!0}),L.WebsocketMessageAdapter=void 0;const o=i(Te),a=i(Te),n=u(Te),e=u(Te),s=u(Te),c=N(),p=I();let d=class ts{constructor(l,v,f,g,m,S){if(!l)throw new p.ArgumentNullError("uri");if(!f)throw new p.ArgumentNullError("messageFormatter");this.proxyInfo=g,this.privConnectionEvents=new p.EventSource,this.privConnectionId=v,this.privMessageFormatter=f,this.privConnectionState=p.ConnectionState.None,this.privUri=l,this.privHeaders=m,this.privEnableCompression=S,this.privHeaders[c.HeaderNames.ConnectionId]=this.privConnectionId,this.privLastErrorReceived=""}get state(){return this.privConnectionState}open(){if(this.privConnectionState===p.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 p.Deferred,this.privCertificateValidatedDeferral=new p.Deferred,this.privConnectionState=p.ConnectionState.Connecting;try{if(typeof WebSocket<"u"&&!ts.forceNpmWebSocket)this.privCertificateValidatedDeferral.resolve(),this.privWebsocketClient=new WebSocket(this.privUri);else{const l={headers:this.privHeaders,perMessageDeflate:this.privEnableCompression};this.privCertificateValidatedDeferral.resolve(),l.agent=this.getAgent();let f=new URL(this.privUri).protocol;(f==null?void 0:f.toLocaleLowerCase())==="wss:"?f="https:":(f==null?void 0:f.toLocaleLowerCase())==="ws:"&&(f="http:"),l.agent.protocol=f,this.privWebsocketClient=new s.default(this.privUri,l)}this.privWebsocketClient.binaryType="arraybuffer",this.privReceivingMessageQueue=new p.Queue,this.privDisconnectDeferral=new p.Deferred,this.privSendMessageQueue=new p.Queue,this.processSendQueue().catch(l=>
17{p.Events.instance.onEvent(new p.BackgroundEvent(l))})}catch(l){return this.privConnectionEstablishDeferral.resolve(new p.ConnectionOpenResponse(500,l)),this.privConnectionEstablishDeferral.promise}return this.onEvent(new p.ConnectionStartEvent(this.privConnectionId,this.privUri)),this.privWebsocketClient.onopen=()=>{this.privCertificateValidatedDeferral.promise.then(()=>{this.privConnectionState=p.ConnectionState.Connected,this.onEvent(new p.ConnectionEstablishedEvent(this.privConnectionId)),this.privConnectionEstablishDeferral.resolve(new p.ConnectionOpenResponse(200,""))},l=>{this.privConnectionEstablishDeferral.reject(l)})},this.privWebsocketClient.onerror=l=>{this.onEvent(new p.ConnectionErrorEvent(this.privConnectionId,l.message,l.type)),this.privLastErrorReceived=l.message},this.privWebsocketClient.onclose=l=>{this.privConnectionState===p.ConnectionState.Connecting?(this.privConnectionState=p.ConnectionState.Disconnected,this.privConnectionEstablishDeferral.resolve(new p.ConnectionOpenResponse(l.code,l.reason+" "+this.privLastErrorReceived))):(this.privConnectionState=p.ConnectionState.Disconnected,this.privWebsocketClient=null,this.onEvent(new p.ConnectionClosedEvent(this.privConnectionId,l.code,l.reason))),this.onClose(l.code,l.reason).catch(v=>{p.Events.instance.onEvent(new p.BackgroundEvent(v))})},this.privWebsocketClient.onmessage=l=>{const v=new Date().toISOString();if(this.privConnectionState===p.ConnectionState.Connected){const f=new p.Deferred;if(this.privReceivingMessageQueue.enqueueFromPromise(f.promise),l.data instanceof ArrayBuffer){const g=new p.RawWebsocketMessage(p.MessageType.Binary,l.data);this.privMessageFormatter.toConnectionMessage(g).then(m=>{this.onEvent(new p.ConnectionMessageReceivedEvent(this.privConnectionId,v,m)),f.resolve(m)},m=>{f.reject(`Invalid binary message format. Error: ${m}`)})}else{const g=new p.RawWebsocketMessage(p.MessageType.Text,l.data);this.privMessageFormatter.toConnectionMessage(g).then(m=>{this.onEvent(new p.ConnectionMessageReceivedEvent(this.privConnectionId,v,m)),f.resolve(m)},m=>{f.reject(`Invalid text message format. Error: ${m}`)})}}},this.privConnectionEstablishDeferral.promise}send(l){if(this.privConnectionState!==p.ConnectionState.Connected)return Promise.reject(`Cannot send on connection that is in ${p.ConnectionState[this.privConnectionState]} state`);const v=new p.Deferred,f=new p.Deferred;return this.privSendMessageQueue.enqueueFromPromise(f.promise),this.privMessageFormatter.fromConnectionMessage(l).then(g=>{f.resolve({Message:l,RawWebsocketMessage:g,sendStatusDeferral:v})},g=>{f.reject(`Error formatting the message. ${g}`)}),v.promise}read(){return this.privConnectionState!==p.ConnectionState.Connected?Promise.reject(`Cannot read on connection that is in ${this.privConnectionState} state`):this.privReceivingMessageQueue.dequeue()}close(l){if(this.privWebsocketClient)this.privConnectionState!==p.ConnectionState.Disconnected&&this.privWebsocketClient.close(1e3,l||"Normal closure by client");else return Promise.resolve();return this.privDisconnectDeferral.promise}get events(){return this.privConnectionEvents}sendRawMessage(l){try{if(!l)return Promise.resolve();if(this.onEvent(new p.ConnectionMessageSentEvent(this.privConnectionId,new Date().toISOString(),l.Message)),this.isWebsocketOpen)this.privWebsocketClient.send(l.RawWebsocketMessage.payload);else return Promise.reject("websocket send error: Websocket not ready "+this.privConnectionId+" "+l.Message.id+" "+new Error().stack);return Promise.resolve()}catch(v){return Promise.reject(`websocket send error: ${v}`)}}async onClose(l,v){const f=`Connection closed. ${l}: ${v}`;this.privConnectionState=p.ConnectionState.Disconnected,this.privDisconnectDeferral.resolve(),await this.privReceivingMessageQueue.drainAndDispose(()=>{},f),await this.privSendMessageQueue.drainAndDispose(g=>{g.sendStatusDeferral.reject(f)},f)}async processSendQueue(){for(;;){const v=await this.privSendMessageQueue.dequeue();if(!v)return;try{await this.sendRawMessage(v),v.sendStatusDeferral.resolve()}catch(f){v.sendStatusDeferral.reject(f)}}}onEvent(l){this.privConnectionEvents.onEvent(l),p.Events.instance.onEvent(l)}getAgent(){const l=new n.default.Agent(this.createConnection);return this.proxyInfo!==void 0&&this.proxyInfo.HostName!==void 0&&this.proxyInfo.Port>0&&(l.proxyInfo=this.proxyInfo),l}static GetProxyAgent(l){const v={host:l.HostName,port:l.Port};return l.UserName?v.headers={"Proxy-Authentication":"Basic "+new Buffer(`${l.UserName}:${l.Password===void 0?"":l.Password}`).toString("base64")}:v.headers={},v.headers.requestOCSP="true",new e.default(v)}createConnection(l,v){let f;if(v={...v,requestOCSP:!0,servername:v.host},this.proxyInfo){const m=ts.GetProxyAgent(this.proxyInfo);f=new Promise((S,C)=>{m.callback(l,v,(R,P)=>{R?C(R):S(P)})})}else v.secureEndpoint?f=Promise.resolve(a.connect(v)):f=Promise.resolve(o.connect(v));return f}get isWebsocketOpen(){return this.privWebsocketClient&&this.privWebsocketClient.readyState===this.privWebsocketClient.OPEN}};return L.WebsocketMessageAdapter=d,d.forceNpmWebSocket=!1,L}var Do;
17function Cl(){if(Do)return pt;Do=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.WebsocketConnection=void 0;const t=I(),r=Tp();let i=class{constructor(o,a,n,e,s,c=!1,p){if(this.privIsDisposed=!1,!o)throw new t.ArgumentNullError("uri");if(!e)throw new t.ArgumentNullError("messageFormatter");this.privMessageFormatter=e;let d="",h=0;if(a){for(const l in a)if(l){d+=h===0&&o.indexOf("?")===-1?"?":"&";const v=encodeURIComponent(l);d+=v;let f=a[l];f&&(f=encodeURIComponent(f),d+=`=${f}`),h++}}if(n){for(const l in n)if(l){d+=h===0&&o.indexOf("?")===-1?"?":"&";const v=encodeURIComponent(n[l]);d+=`${l}=${v}`,h++}}this.privUri=o+d,this.privId=p||t.createNoDashGuid(),this.privConnectionMessageAdapter=new r.WebsocketMessageAdapter(this.privUri,this.id,this.privMessageFormatter,s,n,c)}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(o){return this.privConnectionMessageAdapter.send(o)}read(){return this.privConnectionMessageAdapter.read()}get events(){return this.privConnectionMessageAdapter.events}};return pt.WebsocketConnection=i,pt}var dt={},ko;function yl(){if(ko)return dt;
17ko=1,Object.defineProperty(dt,"__esModule",{value:!0}),dt.ReplayableAudioNode=void 0;let t=class{constructor(u,o){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=u,this.privBytesPerSecond=o}id(){return this.privAudioNode.id()}read(){if(this.privReplay&&this.privBuffers.length!==0){const u=this.privReplayOffset-this.privBufferStartOffset;let o=Math.round(u*this.privBytesPerSecond*1e-7);o%2!==0&&o++;let a=0;for(;a<this.privBuffers.length&&o>=this.privBuffers[a].chunk.buffer.byteLength;)o-=this.privBuffers[a++].chunk.buffer.byteLength;if(a<this.privBuffers.length){const n=this.privBuffers[a].chunk.buffer.slice(o);return this.privReplayOffset+=n.byteLength/this.privBytesPerSecond*1e7,a===this.privBuffers.length-1&&(this.privReplay=!1),Promise.resolve({buffer:n,isEnd:!1,timeReceived:this.privBuffers[a].chunk.timeReceived})}}return this.privAudioNode.read().then(u=>(u&&u.buffer&&(this.privBuffers.push(new r(u,this.privBufferSerial++,this.privBufferedBytes)),this.privBufferedBytes+=u.buffer.byteLength),u))}detach(){return this.privBuffers=void 0,this.privAudioNode.detach()}replay(){this.privBuffers&&this.privBuffers.length!==0&&(this.privReplay=!0,this.privReplayOffset=this.privLastShrinkOffset)}shrinkBuffers(u){if(this.privBuffers===void 0||this.privBuffers.length===0)return;this.privLastShrinkOffset=u;const o=u-this.privBufferStartOffset;let a=Math.round(o*this.privBytesPerSecond*1e-7),n=0;for(;n<this.privBuffers.length&&a>=this.privBuffers[n].chunk.buffer.byteLength;)a-=this.privBuffers[n++].chunk.buffer.byteLength;this.privBufferStartOffset=Math.round(u-a/this.privBytesPerSecond*1e7),this.privBuffers=this.privBuffers.slice(n)}findTimeAtOffset(u){if(u<this.privBufferStartOffset||this.privBuffers===void 0)return 0;for(const o of this.privBuffers){const a=o.byteOffset/this.privBytesPerSecond*1e7,n=a+o.chunk.buffer.byteLength/this.privBytesPerSecond*1e7;if(u>=a&&u<=n)return o.chunk.timeReceived}return 0}};dt.ReplayableAudioNode=t;class r{constructor(u,o,a){this.chunk=u,this.serial=o,this.byteOffset=a}}return dt}var ht={},Sn={},K={},U={},No;function Ap(){if(No)return U;No=1;var t=U&&U.__createBinding||(Object.create?(function(n,e,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return e[s]}})}):(function(n,e,s,c){c===void 0&&(c=s),n[c]=e[s]})),r=U&&U.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),i=U&&U.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var s in n)s!=="default"&&Object.hasOwnProperty.call(n,s)&&t(e,n,s);return r(e,n),e};Object.defineProperty(U,"__esModule",{value:!0}),U.AudioFileWriter=void 0;const u=i(Te),o=T();let a=class{constructor(e){o.Contracts.throwIfNullOrUndefined(u.openSync,`
18File System access not available, please use Push or PullAudioOutputStream`),this.privFd=u.openSync(e,"w")}set format(e){o.Contracts.throwIfNotUndefined(this.privAudioFormat,"format is already set"),this.privAudioFormat=e;let s=0;this.privAudioFormat.hasHeader&&(s=this.privAudioFormat.header.byteLength),this.privFd!==void 0&&(this.privWriteStream=u.createWriteStream("",{fd:this.privFd,start:s,autoClose:!1}))}write(e){o.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),u.writeSync(this.privFd,new Int8Array(this.privAudioFormat.header),0,this.privAudioFormat.header.byteLength,0)),u.closeSync(this.privFd),this.privFd=void 0}),this.privWriteStream.end())}id(){return this.privId}};return U.AudioFileWriter=a,U}var B={},zo;function wp(){if(zo)return B;zo=1,Object.defineProperty(B,"__esModule",{value:!0}),B.PullAudioInputStreamImpl=B.PullAudioInputStream=B.PushAudioInputStreamImpl=B.PushAudioInputStream=B.AudioInputStream=void 0;const t=E(),r=I(),i=Ae(),u=y(),o=we();let a=class{constructor(){}static createPushStream(d){return n.create(d)}static createPullStream(d,h){return s.create(d,h)}};B.AudioInputStream=a;
18class n extends a{static create(d){return new e(d)}}B.PushAudioInputStream=n;class e extends n{constructor(d){super(),d===void 0?this.privFormat=o.AudioStreamFormatImpl.getDefaultInputFormat():this.privFormat=d,this.privEvents=new r.EventSource,this.privId=i.createNoDashGuid(),this.privStream=new r.ChunkedArrayBufferStream(this.privFormat.avgBytesPerSec/10)}get format(){return Promise.resolve(this.privFormat)}write(d){this.privStream.writeStreamChunk({buffer:d,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}id(){return this.privId}turnOn(){this.onEvent(new r.AudioSourceInitializingEvent(this.privId)),this.onEvent(new r.AudioSourceReadyEvent(this.privId))}async attach(d){this.onEvent(new r.AudioStreamNodeAttachingEvent(this.privId,d)),await this.turnOn();const h=this.privStream;return this.onEvent(new r.AudioStreamNodeAttachedEvent(this.privId,d)),{detach:async()=>(this.onEvent(new r.AudioStreamNodeDetachedEvent(this.privId,d)),this.turnOff()),id:()=>d,read:()=>h.read()}}detach(d){this.onEvent(new r.AudioStreamNodeDetachedEvent(this.privId,d))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:t.connectivity.Unknown,manufacturer:"Speech SDK",model:"PushStream",samplerate:this.privFormat.samplesPerSec,type:t.type.Stream})}onEvent(d){this.privEvents.onEvent(d),r.Events.instance.onEvent(d)}toBuffer(d){const h=Buffer.alloc(d.byteLength),l=new Uint8Array(d);for(let v=0;v<h.length;++v)h[v]=l[v];return h}}B.PushAudioInputStreamImpl=e;class s extends a{constructor(){super()}static create(d,h){return new c(d,h)}}B.PullAudioInputStream=s;class c extends s{constructor(d,h){super(),h===void 0?this.privFormat=u.AudioStreamFormat.getDefaultInputFormat():this.privFormat=h,this.privEvents=new r.EventSource,this.privId=i.createNoDashGuid(),this.privCallback=d,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 r.AudioSourceInitializingEvent(this.privId)),this.onEvent(new r.AudioSourceReadyEvent(this.privId))}async attach(d){return this.onEvent(new r.AudioStreamNodeAttachingEvent(this.privId,d)),await this.turnOn(),this.onEvent(new r.AudioStreamNodeAttachedEvent(this.privId,d)),{detach:()=>(this.privCallback.close(),this.onEvent(new r.AudioStreamNodeDetachedEvent(this.privId,d)),this.turnOff()),id:()=>d,read:()=>{let h=0,l;for(;h<this.privBufferSize;){const v=new ArrayBuffer(this.privBufferSize-h),f=this.privCallback.read(v);if(l===void 0?l=v:new Int8Array(l).set(new Int8Array(v),h),f===0)break;h+=f}return Promise.resolve({buffer:l.slice(0,h),isEnd:this.privIsClosed||h===0,timeReceived:Date.now()})}}}detach(d){this.onEvent(new r.AudioStreamNodeDetachedEvent(this.privId,d))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:t.connectivity.Unknown,manufacturer:"Speech SDK",model:"PullStream",samplerate:this.privFormat.samplesPerSec,type:t.type.Stream})}onEvent(d){this.privEvents.onEvent(d),r.Events.instance.onEvent(d)}}return B.PullAudioInputStreamImpl=c,B}var x={},lt={},Cn={},jo;function _p(){return jo||(jo=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisOutputFormat=void 0,(function(r){r[r.Raw8Khz8BitMonoMULaw=0]="Raw8Khz8BitMonoMULaw",r[r.Riff16Khz16KbpsMonoSiren=1]="Riff16Khz16KbpsMonoSiren",r[r.Audio16Khz16KbpsMonoSiren=2]="Audio16Khz16KbpsMonoSiren",r[r.Audio16Khz32KBitRateMonoMp3=3]="Audio16Khz32KBitRateMonoMp3",r[r.Audio16Khz128KBitRateMonoMp3=4]="Audio16Khz128KBitRateMonoMp3",r[r.Audio16Khz64KBitRateMonoMp3=5]="Audio16Khz64KBitRateMonoMp3",r[r.Audio24Khz48KBitRateMonoMp3=6]="Audio24Khz48KBitRateMonoMp3",r[r.Audio24Khz96KBitRateMonoMp3=7]="Audio24Khz96KBitRateMonoMp3",r[r.Audio24Khz160KBitRateMonoMp3=8]="Audio24Khz160KBitRateMonoMp3",r[r.Raw16Khz16BitMonoTrueSilk=9]="Raw16Khz16BitMonoTrueSilk",r[r.Riff16Khz16BitMonoPcm=10]="Riff16Khz16BitMonoPcm",r[r.Riff8Khz16BitMonoPcm=11]="Riff8Khz16BitMonoPcm",r[r.Riff24Khz16BitMonoPcm=12]="Riff24Khz16BitMonoPcm",r[r.Riff8Khz8BitMonoMULaw=13]="Riff8Khz8BitMonoMULaw",r[r.Raw16Khz16BitMonoPcm=14]="Raw16Khz16BitMonoPcm",r[r.Raw24Khz16BitMonoPcm=15]="Raw24Khz16BitMonoPcm",r[r.Raw8Khz16BitMonoPcm=16]="Raw8Khz16BitMonoPcm",r[r.Ogg16Khz16BitMonoOpus=17]="Ogg16Khz16BitMonoOpus",r[r.Ogg24Khz16BitMonoOpus=18]="Ogg24Khz16BitMonoOpus",r[r.Raw48Khz16BitMonoPcm=19]="Raw48Khz16BitMonoPcm",r[r.Riff48Khz16BitMonoPcm=20]="Riff48Khz16BitMonoPcm",r[r.Audio48Khz96KBitRateMonoMp3=21]="Audio48Khz96KBitRateMonoMp3",r[r.Audio48Khz192KBitRateMonoMp3=22]="Audio48Khz192KBitRateMonoMp3",r[r.Ogg48Khz16BitMonoOpus=23]="Ogg48Khz16BitMonoOpus",r[r.Webm16Khz16BitMonoOpus=24]="Webm16Khz16BitMonoOpus",r[r.Webm24Khz16BitMonoOpus=25]="Webm24Khz16BitMonoOpus",r[r.Raw24Khz16BitMonoTrueSilk=26]="Raw24Khz16BitMonoTrueSilk",r[r.Raw8Khz8BitMonoALaw=27]="Raw8Khz8BitMonoALaw",r[r.Riff8Khz8BitMonoALaw=28]="Riff8Khz8BitMonoALaw",r[r.Webm24Khz16Bit24KbpsMonoOpus=29]="Webm24Khz16Bit24KbpsMonoOpus",r[r.Audio16Khz16Bit32KbpsMonoOpus=30]="Audio16Khz16Bit32KbpsMonoOpus",r[r.Audio24Khz16Bit48KbpsMonoOpus=31]="Audio24Khz16Bit48KbpsMonoOpus",r[r.Audio24Khz16Bit24KbpsMonoOpus=32]="Audio24Khz16Bit24KbpsMonoOpus",r[r.Raw22050Hz16BitMonoPcm=33]="Raw22050Hz16BitMonoPcm",r[r.Riff22050Hz16BitMonoPcm=34]="Riff22050Hz16BitMonoPcm",r[r.Raw44100Hz16BitMonoPcm=35]="Raw44100Hz16BitMonoPcm",r[r.Riff44100Hz16BitMonoPcm=36]="Riff44100Hz16BitMonoPcm",r[r.AmrWb16000Hz=37]="AmrWb16000Hz",r[r.G72216Khz64Kbps=38]="G72216Khz64Kbps"})(t.SpeechSynthesisOutputFormat||(t.SpeechSynthesisOutputFormat={}))})(Cn)),Cn}var qo;function Bi(){if(qo)return lt;
18qo=1,Object.defineProperty(lt,"__esModule",{value:!0}),lt.AudioOutputFormatImpl=void 0;const t=_p(),r=we();class i extends r.AudioStreamFormatImpl{constructor(o,a,n,e,s,c,p,d,h){super(n,c,a,o),this.formatTag=o,this.avgBytesPerSec=e,this.blockAlign=s,this.priAudioFormatString=p,this.priRequestAudioFormatString=d,this.priHasHeader=h}static fromSpeechSynthesisOutputFormat(o){return o===void 0?i.getDefaultOutputFormat():i.fromSpeechSynthesisOutputFormatString(i.SpeechSynthesisOutputFormatToString[o])}static fromSpeechSynthesisOutputFormatString(o){switch(o){case"raw-8khz-8bit-mono-mulaw":return new i(r.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,o,o,!1);case"riff-16khz-16kbps-mono-siren":return new i(r.AudioFormatTag.Siren,1,16e3,2e3,40,0,o,"audio-16khz-16kbps-mono-siren",!0);case"audio-16khz-16kbps-mono-siren":return new i(r.AudioFormatTag.Siren,1,16e3,2e3,40,0,o,o,!1);case"audio-16khz-32kbitrate-mono-mp3":return new i(r.AudioFormatTag.MP3,1,16e3,4096,2,16,o,o,!1);case"audio-16khz-128kbitrate-mono-mp3":return new i(r.AudioFormatTag.MP3,1,16e3,16384,2,16,o,o,!1);case"audio-16khz-64kbitrate-mono-mp3":return new i(r.AudioFormatTag.MP3,1,16e3,8192,2,16,o,o,!1);case"audio-24khz-48kbitrate-mono-mp3":return new i(r.AudioFormatTag.MP3,1,24e3,6144,2,16,o,o,!1);case"audio-24khz-96kbitrate-mono-mp3":return new i(r.AudioFormatTag.MP3,1,24e3,12288,2,16,o,o,!1);case"audio-24khz-160kbitrate-mono-mp3":return new i(r.AudioFormatTag.MP3,1,24e3,20480,2,16,o,o,!1);case"raw-16khz-16bit-mono-truesilk":return new i(r.AudioFormatTag.SILKSkype,1,16e3,32e3,2,16,o,o,!1);case"riff-8khz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,8e3,16e3,2,16,o,"raw-8khz-16bit-mono-pcm",!0);case"riff-24khz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,24e3,48e3,2,16,o,"raw-24khz-16bit-mono-pcm",!0);case"riff-8khz-8bit-mono-mulaw":return new i(r.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,o,"raw-8khz-8bit-mono-mulaw",!0);case"raw-16khz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,16e3,32e3,2,16,o,"raw-16khz-16bit-mono-pcm",!1);case"raw-24khz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,24e3,48e3,2,16,o,"raw-24khz-16bit-mono-pcm",!1);case"raw-8khz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,8e3,16e3,2,16,o,"raw-8khz-16bit-mono-pcm",!1);case"ogg-16khz-16bit-mono-opus":return new i(r.AudioFormatTag.OGG_OPUS,1,16e3,8192,2,16,o,o,!1);case"ogg-24khz-16bit-mono-opus":return new i(r.AudioFormatTag.OGG_OPUS,1,24e3,8192,2,16,o,o,!1);case"raw-48khz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,48e3,96e3,2,16,o,"raw-48khz-16bit-mono-pcm",!1);case"riff-48khz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,48e3,96e3,2,16,o,"raw-48khz-16bit-mono-pcm",!0);case"audio-48khz-96kbitrate-mono-mp3":return new i(r.AudioFormatTag.MP3,1,48e3,12288,2,16,o,o,!1);case"audio-48khz-192kbitrate-mono-mp3":return new i(r.AudioFormatTag.MP3,1,48e3,24576,2,16,o,o,!1);case"ogg-48khz-16bit-mono-opus":return new i(r.AudioFormatTag.OGG_OPUS,1,48e3,12e3,2,16,o,o,!1);case"webm-16khz-16bit-mono-opus":return new i(r.AudioFormatTag.WEBM_OPUS,1,16e3,4e3,2,16,o,o,!1);case"webm-24khz-16bit-mono-opus":return new i(r.AudioFormatTag.WEBM_OPUS,1,24e3,6e3,2,16,o,o,!1);case"webm-24khz-16bit-24kbps-mono-opus":return new i(r.AudioFormatTag.WEBM_OPUS,1,24e3,3e3,2,16,o,o,!1);case"audio-16khz-16bit-32kbps-mono-opus":return new i(r.AudioFormatTag.OPUS,1,16e3,4e3,2,16,o,o,!1);case"audio-24khz-16bit-48kbps-mono-opus":return new i(r.AudioFormatTag.OPUS,1,24e3,6e3,2,16,o,o,!1);case"audio-24khz-16bit-24kbps-mono-opus":return new i(r.AudioFormatTag.OPUS,1,24e3,3e3,2,16,o,o,!1);case"audio-24khz-16bit-mono-flac":return new i(r.AudioFormatTag.FLAC,1,24e3,24e3,2,16,o,o,!1);case"audio-48khz-16bit-mono-flac":return new i(r.AudioFormatTag.FLAC,1,48e3,3e4,2,16,o,o,!1);case"raw-24khz-16bit-mono-truesilk":return new i(r.AudioFormatTag.SILKSkype,1,24e3,48e3,2,16,o,o,!1);case"raw-8khz-8bit-mono-alaw":return new i(r.AudioFormatTag.ALaw,1,8e3,8e3,1,8,o,o,!1);case"riff-8khz-8bit-mono-alaw":return new i(r.AudioFormatTag.ALaw,1,8e3,8e3,1,8,o,"raw-8khz-8bit-mono-alaw",!0);case"raw-22050hz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,22050,44100,2,16,o,o,!1);case"riff-22050hz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,22050,44100,2,16,o,"raw-22050hz-16bit-mono-pcm",!0);case"raw-44100hz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,44100,88200,2,16,o,o,!1);case"riff-44100hz-16bit-mono-pcm":return new i(r.AudioFormatTag.PCM,1,44100,88200,2,16,o,"raw-44100hz-16bit-mono-pcm",!0);case"amr-wb-16000h":return new i(r.AudioFormatTag.AMR_WB,1,16e3,3052,2,16,o,o,!1);case"g722-16khz-64kbps":return new i(r.AudioFormatTag.G722,1,16e3,8e3,2,16,o,o,!1);case"riff-16khz-16bit-mono-pcm":default:return new i(r.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}
18get header(){if(this.hasHeader)return this.privHeader}updateHeader(o){if(this.priHasHeader){const a=new DataView(this.privHeader);a.setUint32(4,o+this.privHeader.byteLength-8,!0),a.setUint32(40,o,!0)}}get requestAudioFormatString(){return this.priRequestAudioFormatString}addHeader(o){if(!this.hasHeader)return o;this.updateHeader(o.byteLength);const a=new Uint8Array(o.byteLength+this.header.byteLength);return a.set(new Uint8Array(this.header),0),a.set(new Uint8Array(o),this.header.byteLength),a.buffer}}return lt.AudioOutputFormatImpl=i,i.SpeechSynthesisOutputFormatToString={[t.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]:"raw-8khz-8bit-mono-mulaw",[t.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]:"riff-16khz-16kbps-mono-siren",[t.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]:"audio-16khz-16kbps-mono-siren",[t.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]:"audio-16khz-32kbitrate-mono-mp3",[t.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]:"audio-16khz-128kbitrate-mono-mp3",[t.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]:"audio-16khz-64kbitrate-mono-mp3",[t.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]:"audio-24khz-48kbitrate-mono-mp3",[t.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]:"audio-24khz-96kbitrate-mono-mp3",[t.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]:"audio-24khz-160kbitrate-mono-mp3",[t.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]:"raw-16khz-16bit-mono-truesilk",[t.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]:"riff-16khz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]:"riff-8khz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]:"riff-24khz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]:"riff-8khz-8bit-mono-mulaw",[t.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]:"raw-16khz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]:"raw-24khz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]:"raw-8khz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus]:"ogg-16khz-16bit-mono-opus",[t.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus]:"ogg-24khz-16bit-mono-opus",[t.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm]:"raw-48khz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm]:"riff-48khz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3]:"audio-48khz-96kbitrate-mono-mp3",[t.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3]:"audio-48khz-192kbitrate-mono-mp3",[t.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus]:"ogg-48khz-16bit-mono-opus",[t.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus]:"webm-16khz-16bit-mono-opus",[t.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus]:"webm-24khz-16bit-mono-opus",[t.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus]:"webm-24khz-16bit-24kbps-mono-opus",[t.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk]:"raw-24khz-16bit-mono-truesilk",[t.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw]:"raw-8khz-8bit-mono-alaw",[t.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw]:"riff-8khz-8bit-mono-alaw",[t.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus]:"audio-16khz-16bit-32kbps-mono-opus",[t.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus]:"audio-24khz-16bit-48kbps-mono-opus",[t.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus]:"audio-24khz-16bit-24kbps-mono-opus",[t.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm]:"raw-22050hz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]:"riff-22050hz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]:"raw-44100hz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]:"riff-44100hz-16bit-mono-pcm",[t.SpeechSynthesisOutputFormat.AmrWb16000Hz]:"amr-wb-16000hz",[t.SpeechSynthesisOutputFormat.G72216Khz64Kbps]:"g722-16khz-64kbps"},lt}var Lo;function Me(){if(Lo)return x;Lo=1,Object.defineProperty(x,"__esModule",{value:!0}),x.PushAudioOutputStreamImpl=x.PushAudioOutputStream=x.PullAudioOutputStreamImpl=x.PullAudioOutputStream=x.AudioOutputStream=void 0;const t=I(),r=T(),i=Bi();let u=class{constructor(){}static createPullStream(){return o.create()}};x.AudioOutputStream=u;class o extends u{static create(){return new a}}x.PullAudioOutputStream=o;class a extends o{constructor(){super(),this.privId=t.createNoDashGuid(),this.privStream=new t.Stream}set format(c){c==null&&(this.privFormat=i.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privFormat=c}get format(){return this.privFormat}get isClosed(){return this.privStream.isClosed}id(){return this.privId}async read(c){const p=new Int8Array(c);let d=0;if(this.privLastChunkView!==void 0){if(this.privLastChunkView.length>c.byteLength)return p.set(this.privLastChunkView.slice(0,c.byteLength)),this.privLastChunkView=this.privLastChunkView.slice(c.byteLength),Promise.resolve(c.byteLength);p.set(this.privLastChunkView),d=this.privLastChunkView.length,this.privLastChunkView=void 0}for(;d<c.byteLength&&!this.privStream.isReadEnded;){const h=await this.privStream.read();if(h!==void 0&&!h.isEnd){let l;h.buffer.byteLength>c.byteLength-d?(l=h.buffer.slice(0,c.byteLength-d),this.privLastChunkView=new Int8Array(h.buffer.slice(c.byteLength-d))):l=h.buffer,p.set(new Int8Array(l),d),d+=l.byteLength}else this.privStream.readEnded()}return d}write(c){r.Contracts.throwIfNullOrUndefined(this.privStream,"must set format before writing"),this.privStream.writeStreamChunk({buffer:c,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}}x.PullAudioOutputStreamImpl=a;
18class n extends u{constructor(){super()}static create(c){return new e(c)}}x.PushAudioOutputStream=n;class e extends n{constructor(c){super(),this.privId=t.createNoDashGuid(),this.privCallback=c}set format(c){}write(c){this.privCallback.write&&this.privCallback.write(c)}close(){this.privCallback.close&&this.privCallback.close()}id(){return this.privId}}return x.PushAudioOutputStreamImpl=e,x}var Bo;function Mp(){if(Bo)return K;Bo=1,Object.defineProperty(K,"__esModule",{value:!0}),K.AudioOutputConfigImpl=K.AudioConfigImpl=K.AudioConfig=void 0;const t=D(),r=T(),i=y(),u=Ap(),o=wp(),a=Me();let n=class bp{static fromDefaultMicrophoneInput(){const p=new t.PcmRecorder(!0);return new e(new t.MicAudioSource(p))}static fromMicrophoneInput(p){const d=new t.PcmRecorder(!0);return new e(new t.MicAudioSource(d,p))}static fromWavFileInput(p,d="unnamedBuffer.wav"){return new e(new t.FileAudioSource(p,d))}static fromStreamInput(p){if(p instanceof i.PullAudioInputStreamCallback)return new e(new o.PullAudioInputStreamImpl(p));if(p instanceof i.AudioInputStream)return new e(p);if(typeof MediaStream<"u"&&p instanceof MediaStream){const d=new t.PcmRecorder(!1);return new e(new t.MicAudioSource(d,null,null,p))}throw new Error("Not Supported Type")}static fromDefaultSpeakerOutput(){return new s(new i.SpeakerAudioDestination)}static fromSpeakerOutput(p){if(p===void 0)return bp.fromDefaultSpeakerOutput();if(p instanceof i.SpeakerAudioDestination)return new s(p);throw new Error("Not Supported Type")}static fromAudioFileOutput(p){return new s(new u.AudioFileWriter(p))}static fromStreamOutput(p){if(p instanceof i.PushAudioOutputStreamCallback)return new s(new a.PushAudioOutputStreamImpl(p));if(p instanceof i.PushAudioOutputStream)return new s(p);if(p instanceof i.PullAudioOutputStream)return new s(p);throw new Error("Not Supported Type")}};K.AudioConfig=n;class e extends n{constructor(p){super(),this.privSource=p}get format(){return this.privSource.format}close(p,d){this.privSource.turnOff().then(()=>{p&&p()},h=>{d&&d(h)})}id(){return this.privSource.id()}turnOn(){return this.privSource.turnOn()}attach(p){return this.privSource.attach(p)}detach(p){return this.privSource.detach(p)}turnOff(){return this.privSource.turnOff()}get events(){return this.privSource.events}setProperty(p,d){if(r.Contracts.throwIfNull(d,"value"),this.privSource.setProperty!==void 0)this.privSource.setProperty(p,d);else throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(p,d){if(this.privSource.getProperty!==void 0)return this.privSource.getProperty(p,d);throw new Error("This AudioConfig instance does not support getting properties.")}get deviceInfo(){return this.privSource.deviceInfo}}K.AudioConfigImpl=e;class s extends n{constructor(p){super(),this.privDestination=p}set format(p){this.privDestination.format=p}write(p){this.privDestination.write(p)}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.")}}return K.AudioOutputConfigImpl=s,K}var yn={},xo;function Rl(){return xo||(xo=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.CancellationReason=void 0,(function(r){r[r.Error=0]="Error",r[r.EndOfStream=1]="EndOfStream"})(t.CancellationReason||(t.CancellationReason={}))})(yn)),yn}var vt={},Fo;function Pl(){if(Fo)return vt;Fo=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.PullAudioInputStreamCallback=void 0;let t=class{};return vt.PullAudioInputStreamCallback=t,vt}var ft={},Uo;function El(){if(Uo)return ft;Uo=1,Object.defineProperty(ft,"__esModule",{value:!0}),ft.PushAudioOutputStreamCallback=void 0;let t=class{};return ft.PushAudioOutputStreamCallback=t,ft}var gt={},Wo;function Il(){if(Wo)return gt;Wo=1,Object.defineProperty(gt,"__esModule",{value:!0}),gt.KeywordRecognitionModel=void 0;const t=T();let r=class{constructor(){this.privDisposed=!1}static fromFile(u){throw t.Contracts.throwIfFileDoesNotExist(u,"fileName"),new Error("Not yet implemented.")}static fromStream(u){throw t.Contracts.throwIfNull(u,"file"),new Error("Not yet implemented.")}close(){this.privDisposed||(this.privDisposed=!0)}};return gt.KeywordRecognitionModel=r,gt}var mt={},Ho;function Tl(){if(Ho)return mt;
18Ho=1,Object.defineProperty(mt,"__esModule",{value:!0}),mt.SessionEventArgs=void 0;let t=class{constructor(i){this.privSessionId=i}get sessionId(){return this.privSessionId}};return mt.SessionEventArgs=t,mt}var St={},Vo;function Al(){if(Vo)return St;Vo=1,Object.defineProperty(St,"__esModule",{value:!0}),St.RecognitionEventArgs=void 0;const t=y();let r=class extends t.SessionEventArgs{constructor(u,o){super(o),this.privOffset=u}get offset(){return this.privOffset}};return St.RecognitionEventArgs=r,St}var Rn={},$o;function wl(){return $o||($o=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.OutputFormat=void 0,(function(r){r[r.Simple=0]="Simple",r[r.Detailed=1]="Detailed"})(t.OutputFormat||(t.OutputFormat={}))})(Rn)),Rn}var Ct={},Ko;function _l(){if(Ko)return Ct;Ko=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.IntentRecognitionEventArgs=void 0;const t=y();let r=class extends t.RecognitionEventArgs{constructor(u,o,a){super(o,a),this.privResult=u}get result(){return this.privResult}};return Ct.IntentRecognitionEventArgs=r,Ct}var yt={},Jo;function bl(){if(Jo)return yt;Jo=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.RecognitionResult=void 0;let t=class{constructor(i,u,o,a,n,e,s,c,p,d){this.privResultId=i,this.privReason=u,this.privText=o,this.privDuration=a,this.privOffset=n,this.privLanguage=e,this.privLanguageDetectionConfidence=s,this.privErrorDetails=c,this.privJson=p,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}};return yt.RecognitionResult=t,yt}var Rt={},Go;function Ml(){if(Go)return Rt;
18Go=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.SpeechRecognitionResult=void 0;const t=y();let r=class extends t.RecognitionResult{constructor(u,o,a,n,e,s,c,p,d,h,l){super(u,o,a,n,e,s,c,d,h,l),this.privSpeakerId=p}get speakerId(){return this.privSpeakerId}};return Rt.SpeechRecognitionResult=r,Rt}var Pt={},Qo;function Ol(){if(Qo)return Pt;Qo=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.IntentRecognitionResult=void 0;const t=y();let r=class extends t.SpeechRecognitionResult{constructor(u,o,a,n,e,s,c,p,d,h,l){super(o,a,n,e,s,c,p,void 0,d,h,l),this.privIntentId=u}get intentId(){return this.privIntentId}};return Pt.IntentRecognitionResult=r,Pt}var oe={},Xo;function Dl(){if(Xo)return oe;Xo=1,Object.defineProperty(oe,"__esModule",{value:!0}),oe.LanguageUnderstandingModelImpl=oe.LanguageUnderstandingModel=void 0;const t=T();let r=class{constructor(){}static fromEndpoint(o){t.Contracts.throwIfNull(o,"uri"),t.Contracts.throwIfNullOrWhitespace(o.hostname,"uri");const a=new i,n=o.host.indexOf(".");if(n===-1)throw new Error("Could not determine region from endpoint");a.region=o.host.substr(0,n);const e=o.pathname.lastIndexOf("/")+1;if(e===-1)throw new Error("Could not determine appId from endpoint");if(a.appId=o.pathname.substr(e),a.subscriptionKey=o.searchParams.get("subscription-key"),a.subscriptionKey===void 0)throw new Error("Could not determine subscription key from endpoint");return a}static fromAppId(o){t.Contracts.throwIfNullOrWhitespace(o,"appId");const a=new i;return a.appId=o,a}static fromSubscription(o,a,n){t.Contracts.throwIfNullOrWhitespace(o,"subscriptionKey"),t.Contracts.throwIfNullOrWhitespace(a,"appId"),t.Contracts.throwIfNullOrWhitespace(n,"region");const e=new i;return e.appId=a,e.region=n,e.subscriptionKey=o,e}};oe.LanguageUnderstandingModel=r;class i extends r{}return oe.LanguageUnderstandingModelImpl=i,oe}var J={},Zo;function kl(){if(Zo)return J;Zo=1,Object.defineProperty(J,"__esModule",{value:!0}),J.MeetingTranscriptionEventArgs=J.ConversationTranscriptionEventArgs=J.SpeechRecognitionEventArgs=void 0;const t=y();let r=class extends t.RecognitionEventArgs{constructor(a,n,e){super(n,e),this.privResult=a}get result(){return this.privResult}};J.SpeechRecognitionEventArgs=r;class i extends t.RecognitionEventArgs{constructor(a,n,e){super(n,e),this.privResult=a}get result(){return this.privResult}}J.ConversationTranscriptionEventArgs=i;class u extends r{}return J.MeetingTranscriptionEventArgs=u,J}var Et={},It={},Yo;function xi(){if(Yo)return It;Yo=1,Object.defineProperty(It,"__esModule",{value:!0}),It.CancellationEventArgsBase=void 0;const t=y();let r=class extends t.RecognitionEventArgs{constructor(u,o,a,n,e){super(n,e),this.privReason=u,this.privErrorDetails=o,this.privErrorCode=a}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};return It.CancellationEventArgsBase=r,It}var ea;function Nl(){if(ea)return Et;ea=1,Object.defineProperty(Et,"__esModule",{value:!0}),Et.SpeechRecognitionCanceledEventArgs=void 0;const t=xi();let r=class extends t.CancellationEventArgsBase{};return Et.SpeechRecognitionCanceledEventArgs=r,Et}var Tt={},ta;function zl(){if(ta)return Tt;ta=1,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.TranslationRecognitionEventArgs=void 0;const t=y();let r=class extends t.RecognitionEventArgs{constructor(u,o,a){super(o,a),this.privResult=u}get result(){return this.privResult}};return Tt.TranslationRecognitionEventArgs=r,Tt}var At={},ra;function jl(){if(ra)return At;ra=1,Object.defineProperty(At,"__esModule",{value:!0}),At.TranslationSynthesisEventArgs=void 0;const t=y();let r=class extends t.SessionEventArgs{constructor(u,o){super(o),this.privResult=u}get result(){return this.privResult}};return At.TranslationSynthesisEventArgs=r,At}var wt={},ia;function Dp(){if(ia)return wt;ia=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.TranslationRecognitionResult=void 0;const t=y();let r=class Op extends t.SpeechRecognitionResult{constructor(u,o,a,n,e,s,c,p,d,h,l){super(o,a,n,e,s,c,p,void 0,d,h,l),this.privTranslations=u}static fromSpeechRecognitionResult(u){return new Op(void 0,u.resultId,u.reason,u.text,u.duration,u.offset,u.language,u.languageDetectionConfidence,u.errorDetails,u.json,u.properties)}get translations(){return this.privTranslations}};return wt.TranslationRecognitionResult=r,wt}var _t={},na;function ql(){if(na)return _t;
18na=1,Object.defineProperty(_t,"__esModule",{value:!0}),_t.TranslationSynthesisResult=void 0;let t=class{constructor(i,u){this.privReason=i,this.privAudio=u}get audio(){return this.privAudio}get reason(){return this.privReason}};return _t.TranslationSynthesisResult=t,_t}var Pn={},sa;function Ll(){return sa||(sa=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ResultReason=void 0,(function(r){r[r.NoMatch=0]="NoMatch",r[r.Canceled=1]="Canceled",r[r.RecognizingSpeech=2]="RecognizingSpeech",r[r.RecognizedSpeech=3]="RecognizedSpeech",r[r.RecognizedKeyword=4]="RecognizedKeyword",r[r.RecognizingIntent=5]="RecognizingIntent",r[r.RecognizedIntent=6]="RecognizedIntent",r[r.TranslatingSpeech=7]="TranslatingSpeech",r[r.TranslatedSpeech=8]="TranslatedSpeech",r[r.SynthesizingAudio=9]="SynthesizingAudio",r[r.SynthesizingAudioCompleted=10]="SynthesizingAudioCompleted",r[r.SynthesizingAudioStarted=11]="SynthesizingAudioStarted",r[r.EnrollingVoiceProfile=12]="EnrollingVoiceProfile",r[r.EnrolledVoiceProfile=13]="EnrolledVoiceProfile",r[r.RecognizedSpeakers=14]="RecognizedSpeakers",r[r.RecognizedSpeaker=15]="RecognizedSpeaker",r[r.ResetVoiceProfile=16]="ResetVoiceProfile",r[r.DeletedVoiceProfile=17]="DeletedVoiceProfile",r[r.VoicesListRetrieved=18]="VoicesListRetrieved",r[r.TranslatingParticipantSpeech=19]="TranslatingParticipantSpeech",r[r.TranslatedParticipantSpeech=20]="TranslatedParticipantSpeech",r[r.TranslatedInstantMessage=21]="TranslatedInstantMessage",r[r.TranslatedParticipantInstantMessage=22]="TranslatedParticipantInstantMessage"})(t.ResultReason||(t.ResultReason={}))})(Pn)),Pn}var ae={},oa;function Bl(){if(oa)return ae;oa=1,Object.defineProperty(ae,"__esModule",{value:!0}),ae.SpeechConfigImpl=ae.SpeechConfig=void 0;const t=E(),r=T(),i=y();let u=class{constructor(){}static fromSubscription(n,e){r.Contracts.throwIfNullOrWhitespace(n,"subscriptionKey"),r.Contracts.throwIfNullOrWhitespace(e,"region");const s=new o;return s.setProperty(i.PropertyId.SpeechServiceConnection_Region,e),s.setProperty(i.PropertyId.SpeechServiceConnection_IntentRegion,e),s.setProperty(i.PropertyId.SpeechServiceConnection_Key,n),s}static fromEndpoint(n,e){r.Contracts.throwIfNull(n,"endpoint");const s=new o;return s.setProperty(i.PropertyId.SpeechServiceConnection_Endpoint,n.href),e!==void 0&&s.setProperty(i.PropertyId.SpeechServiceConnection_Key,e),s}static fromHost(n,e){r.Contracts.throwIfNull(n,"hostName");const s=new o;return s.setProperty(i.PropertyId.SpeechServiceConnection_Host,n.protocol+"//"+n.hostname+(n.port===""?"":":"+n.port)),e!==void 0&&s.setProperty(i.PropertyId.SpeechServiceConnection_Key,e),s}static fromAuthorizationToken(n,e){r.Contracts.throwIfNull(n,"authorizationToken"),r.Contracts.throwIfNullOrWhitespace(e,"region");const s=new o;return s.setProperty(i.PropertyId.SpeechServiceConnection_Region,e),s.setProperty(i.PropertyId.SpeechServiceConnection_IntentRegion,e),s.authorizationToken=n,s}close(){}};ae.SpeechConfig=u;class o extends u{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(n){this.privProperties.setProperty(i.PropertyId.SpeechServiceAuthorization_Token,n)}get speechRecognitionLanguage(){return this.privProperties.getProperty(i.PropertyId.SpeechServiceConnection_RecoLanguage)}set speechRecognitionLanguage(n){this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_RecoLanguage,n)}get autoDetectSourceLanguages(){return this.privProperties.getProperty(i.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)}set autoDetectSourceLanguages(n){this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,n)}get outputFormat(){return i.OutputFormat[this.privProperties.getProperty(t.OutputFormatPropertyName,void 0)]}set outputFormat(n){this.privProperties.setProperty(t.OutputFormatPropertyName,i.OutputFormat[n])}get endpointId(){return this.privProperties.getProperty(i.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(n){this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_EndpointId,n)}setProperty(n,e){r.Contracts.throwIfNull(e,"value"),this.privProperties.setProperty(n,e)}getProperty(n,e){return this.privProperties.getProperty(n,e)}setProxy(n,e,s,c){this.setProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_ProxyHostName],n),this.setProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_ProxyPort],e),this.setProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_ProxyUserName],s),this.setProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_ProxyPassword],c)}setServiceProperty(n,e){const s=JSON.parse(this.privProperties.getProperty(t.ServicePropertiesPropertyName,"{}"));s[n]=e,this.privProperties.setProperty(t.ServicePropertiesPropertyName,JSON.stringify(s))}setProfanity(n){this.privProperties.setProperty(i.PropertyId.SpeechServiceResponse_ProfanityOption,i.ProfanityOption[n])}enableAudioLogging(){this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privProperties.setProperty(i.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privProperties.setProperty(t.ForceDictationPropertyName,"true")}clone(){const n=new o;return n.privProperties=this.privProperties.clone(),n}get speechSynthesisLanguage(){return this.privProperties.getProperty(i.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(n){this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_SynthLanguage,n)}get speechSynthesisVoiceName(){return this.privProperties.getProperty(i.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(n){this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_SynthVoice,n)}get speechSynthesisOutputFormat(){return i.SpeechSynthesisOutputFormat[this.privProperties.getProperty(i.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(n){this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_SynthOutputFormat,i.SpeechSynthesisOutputFormat[n])}}return ae.SpeechConfigImpl=o,ae}var ce={},aa;function xl(){if(aa)return ce;
18aa=1,Object.defineProperty(ce,"__esModule",{value:!0}),ce.SpeechTranslationConfigImpl=ce.SpeechTranslationConfig=void 0;const t=E(),r=T(),i=y();let u=class extends i.SpeechConfig{constructor(){super()}static fromSubscription(n,e){r.Contracts.throwIfNullOrWhitespace(n,"subscriptionKey"),r.Contracts.throwIfNullOrWhitespace(e,"region");const s=new o;return s.properties.setProperty(i.PropertyId.SpeechServiceConnection_Key,n),s.properties.setProperty(i.PropertyId.SpeechServiceConnection_Region,e),s}static fromAuthorizationToken(n,e){r.Contracts.throwIfNullOrWhitespace(n,"authorizationToken"),r.Contracts.throwIfNullOrWhitespace(e,"region");const s=new o;return s.properties.setProperty(i.PropertyId.SpeechServiceAuthorization_Token,n),s.properties.setProperty(i.PropertyId.SpeechServiceConnection_Region,e),s}static fromHost(n,e){r.Contracts.throwIfNull(n,"hostName");const s=new o;return s.setProperty(i.PropertyId.SpeechServiceConnection_Host,n.protocol+"//"+n.hostname+(n.port===""?"":":"+n.port)),e!==void 0&&s.setProperty(i.PropertyId.SpeechServiceConnection_Key,e),s}static fromEndpoint(n,e){r.Contracts.throwIfNull(n,"endpoint"),r.Contracts.throwIfNull(e,"subscriptionKey");const s=new o;return s.properties.setProperty(i.PropertyId.SpeechServiceConnection_Endpoint,n.href),s.properties.setProperty(i.PropertyId.SpeechServiceConnection_Key,e),s}};ce.SpeechTranslationConfig=u;class o extends u{constructor(){super(),this.privSpeechProperties=new i.PropertyCollection,this.outputFormat=i.OutputFormat.Simple}set authorizationToken(n){r.Contracts.throwIfNullOrWhitespace(n,"value"),this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceAuthorization_Token,n)}set speechRecognitionLanguage(n){r.Contracts.throwIfNullOrWhitespace(n,"value"),this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceConnection_RecoLanguage,n)}get speechRecognitionLanguage(){return this.privSpeechProperties.getProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_RecoLanguage])}get subscriptionKey(){return this.privSpeechProperties.getProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_Key])}get outputFormat(){return i.OutputFormat[this.privSpeechProperties.getProperty(t.OutputFormatPropertyName,void 0)]}set outputFormat(n){this.privSpeechProperties.setProperty(t.OutputFormatPropertyName,i.OutputFormat[n])}get endpointId(){return this.privSpeechProperties.getProperty(i.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(n){this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceConnection_EndpointId,n)}addTargetLanguage(n){r.Contracts.throwIfNullOrWhitespace(n,"value");const e=this.targetLanguages;e.includes(n)||(e.push(n),this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceConnection_TranslationToLanguages,e.join(",")))}get targetLanguages(){return this.privSpeechProperties.getProperty(i.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?this.privSpeechProperties.getProperty(i.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","):[]}get voiceName(){return this.getProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_TranslationVoice])}set voiceName(n){r.Contracts.throwIfNullOrWhitespace(n,"value"),this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceConnection_TranslationVoice,n)}get region(){return this.privSpeechProperties.getProperty(i.PropertyId.SpeechServiceConnection_Region)}setProxy(n,e,s,c){this.setProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_ProxyHostName],n),this.setProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_ProxyPort],e),this.setProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_ProxyUserName],s),this.setProperty(i.PropertyId[i.PropertyId.SpeechServiceConnection_ProxyPassword],c)}getProperty(n,e){return this.privSpeechProperties.getProperty(n,e)}setProperty(n,e){this.privSpeechProperties.setProperty(n,e)}get properties(){return this.privSpeechProperties}close(){}setServiceProperty(n,e){const s=JSON.parse(this.privSpeechProperties.getProperty(t.ServicePropertiesPropertyName,"{}"));s[n]=e,this.privSpeechProperties.setProperty(t.ServicePropertiesPropertyName,JSON.stringify(s))}setProfanity(n){this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceResponse_ProfanityOption,i.ProfanityOption[n])}enableAudioLogging(){this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privSpeechProperties.setProperty(t.ForceDictationPropertyName,"true")}get speechSynthesisLanguage(){return this.privSpeechProperties.getProperty(i.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(n){this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceConnection_SynthLanguage,n)}get speechSynthesisVoiceName(){return this.privSpeechProperties.getProperty(i.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(n){this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceConnection_SynthVoice,n)}get speechSynthesisOutputFormat(){return i.SpeechSynthesisOutputFormat[this.privSpeechProperties.getProperty(i.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(n){this.privSpeechProperties.setProperty(i.PropertyId.SpeechServiceConnection_SynthOutputFormat,i.SpeechSynthesisOutputFormat[n])}}return ce.SpeechTranslationConfigImpl=o,ce}var bt={},ca;function Np(){if(ca)return bt;
18ca=1,Object.defineProperty(bt,"__esModule",{value:!0}),bt.PropertyCollection=void 0;const t=y();let r=class kp{constructor(){this.privKeys=[],this.privValues=[]}getProperty(u,o){let a;typeof u=="string"?a=u:a=t.PropertyId[u];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===a)return this.privValues[n];if(o!==void 0)return String(o)}setProperty(u,o){let a;typeof u=="string"?a=u:a=t.PropertyId[u];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===a){this.privValues[n]=o;return}this.privKeys.push(a),this.privValues.push(o)}clone(){const u=new kp;for(let o=0;o<this.privKeys.length;o++)u.privKeys.push(this.privKeys[o]),u.privValues.push(this.privValues[o]);return u}mergeTo(u){this.privKeys.forEach(o=>{if(u.getProperty(o,void 0)===void 0){const a=this.getProperty(o);u.setProperty(o,a)}})}get keys(){return this.privKeys}};return bt.PropertyCollection=r,bt}var En={},ua;function ps(){return ua||(ua=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.PropertyId=void 0,(function(r){r[r.SpeechServiceConnection_Key=0]="SpeechServiceConnection_Key",r[r.SpeechServiceConnection_Endpoint=1]="SpeechServiceConnection_Endpoint",r[r.SpeechServiceConnection_Region=2]="SpeechServiceConnection_Region",r[r.SpeechServiceAuthorization_Token=3]="SpeechServiceAuthorization_Token",r[r.SpeechServiceAuthorization_Type=4]="SpeechServiceAuthorization_Type",r[r.SpeechServiceConnection_EndpointId=5]="SpeechServiceConnection_EndpointId",r[r.SpeechServiceConnection_TranslationToLanguages=6]="SpeechServiceConnection_TranslationToLanguages",r[r.SpeechServiceConnection_TranslationVoice=7]="SpeechServiceConnection_TranslationVoice",r[r.SpeechServiceConnection_TranslationFeatures=8]="SpeechServiceConnection_TranslationFeatures",r[r.SpeechServiceConnection_IntentRegion=9]="SpeechServiceConnection_IntentRegion",r[r.SpeechServiceConnection_ProxyHostName=10]="SpeechServiceConnection_ProxyHostName",r[r.SpeechServiceConnection_ProxyPort=11]="SpeechServiceConnection_ProxyPort",r[r.SpeechServiceConnection_ProxyUserName=12]="SpeechServiceConnection_ProxyUserName",r[r.SpeechServiceConnection_ProxyPassword=13]="SpeechServiceConnection_ProxyPassword",r[r.SpeechServiceConnection_RecoMode=14]="SpeechServiceConnection_RecoMode",r[r.SpeechServiceConnection_RecoLanguage=15]="SpeechServiceConnection_RecoLanguage",r[r.Speech_SessionId=16]="Speech_SessionId",r[r.SpeechServiceConnection_SynthLanguage=17]="SpeechServiceConnection_SynthLanguage",r[r.SpeechServiceConnection_SynthVoice=18]="SpeechServiceConnection_SynthVoice",r[r.SpeechServiceConnection_SynthOutputFormat=19]="SpeechServiceConnection_SynthOutputFormat",r[r.SpeechServiceConnection_AutoDetectSourceLanguages=20]="SpeechServiceConnection_AutoDetectSourceLanguages",r[r.SpeechServiceResponse_RequestDetailedResultTrueFalse=21]="SpeechServiceResponse_RequestDetailedResultTrueFalse",r[r.SpeechServiceResponse_RequestProfanityFilterTrueFalse=22]="SpeechServiceResponse_RequestProfanityFilterTrueFalse",r[r.SpeechServiceResponse_JsonResult=23]="SpeechServiceResponse_JsonResult",r[r.SpeechServiceResponse_JsonErrorDetails=24]="SpeechServiceResponse_JsonErrorDetails",r[r.CancellationDetails_Reason=25]="CancellationDetails_Reason",r[r.CancellationDetails_ReasonText=26]="CancellationDetails_ReasonText",r[r.CancellationDetails_ReasonDetailedText=27]="CancellationDetails_ReasonDetailedText",r[r.LanguageUnderstandingServiceResponse_JsonResult=28]="LanguageUnderstandingServiceResponse_JsonResult",r[r.SpeechServiceConnection_Url=29]="SpeechServiceConnection_Url",r[r.SpeechServiceConnection_InitialSilenceTimeoutMs=30]="SpeechServiceConnection_InitialSilenceTimeoutMs",r[r.SpeechServiceConnection_EndSilenceTimeoutMs=31]="SpeechServiceConnection_EndSilenceTimeoutMs",r[r.Speech_SegmentationSilenceTimeoutMs=32]="Speech_SegmentationSilenceTimeoutMs",r[r.SpeechServiceConnection_EnableAudioLogging=33]="SpeechServiceConnection_EnableAudioLogging",r[r.SpeechServiceConnection_LanguageIdMode=34]="SpeechServiceConnection_LanguageIdMode",r[r.SpeechServiceConnection_RecognitionEndpointVersion=35]="SpeechServiceConnection_RecognitionEndpointVersion",r[r.SpeechServiceConnection_SpeakerIdMode=36]="SpeechServiceConnection_SpeakerIdMode",r[r.SpeechServiceResponse_ProfanityOption=37]="SpeechServiceResponse_ProfanityOption",r[r.SpeechServiceResponse_PostProcessingOption=38]="SpeechServiceResponse_PostProcessingOption",r[r.SpeechServiceResponse_RequestWordLevelTimestamps=39]="SpeechServiceResponse_RequestWordLevelTimestamps",r[r.SpeechServiceResponse_StableParti
18alResultThreshold=40]="SpeechServiceResponse_StablePartialResultThreshold",r[r.SpeechServiceResponse_OutputFormatOption=41]="SpeechServiceResponse_OutputFormatOption",r[r.SpeechServiceResponse_TranslationRequestStablePartialResult=42]="SpeechServiceResponse_TranslationRequestStablePartialResult",r[r.SpeechServiceResponse_RequestWordBoundary=43]="SpeechServiceResponse_RequestWordBoundary",r[r.SpeechServiceResponse_RequestPunctuationBoundary=44]="SpeechServiceResponse_RequestPunctuationBoundary",r[r.SpeechServiceResponse_RequestSentenceBoundary=45]="SpeechServiceResponse_RequestSentenceBoundary",r[r.Conversation_ApplicationId=46]="Conversation_ApplicationId",r[r.Conversation_DialogType=47]="Conversation_DialogType",r[r.Conversation_Initial_Silence_Timeout=48]="Conversation_Initial_Silence_Timeout",r[r.Conversation_From_Id=49]="Conversation_From_Id",r[r.Conversation_Conversation_Id=50]="Conversation_Conversation_Id",r[r.Conversation_Custom_Voice_Deployment_Ids=51]="Conversation_Custom_Voice_Deployment_Ids",r[r.Conversation_Speech_Activity_Template=52]="Conversation_Speech_Activity_Template",r[r.Conversation_Request_Bot_Status_Messages=53]="Conversation_Request_Bot_Status_Messages",r[r.Conversation_Agent_Connection_Id=54]="Conversation_Agent_Connection_Id",r[r.SpeechServiceConnection_Host=55]="SpeechServiceConnection_Host",r[r.ConversationTranslator_Host=56]="ConversationTranslator_Host",r[r.ConversationTranslator_Name=57]="ConversationTranslator_Name",r[r.ConversationTranslator_CorrelationId=58]="ConversationTranslator_CorrelationId",r[r.ConversationTranslator_Token=59]="ConversationTranslator_Token",r[r.PronunciationAssessment_ReferenceText=60]="PronunciationAssessment_ReferenceText",r[r.PronunciationAssessment_GradingSystem=61]="PronunciationAssessment_GradingSystem",r[r.PronunciationAssessment_Granularity=62]="PronunciationAssessment_Granularity",r[r.PronunciationAssessment_EnableMiscue=63]="PronunciationAssessment_EnableMiscue",r[r.PronunciationAssessment_Json=64]="PronunciationAssessment_Json",r[r.PronunciationAssessment_Params=65]="PronunciationAssessment_Params",r[r.SpeakerRecognition_Api_Version=66]="SpeakerRecognition_Api_Version",r[r.WebWorkerLoadType=67]="WebWorkerLoadType",r[r.TalkingAvatarService_WebRTC_SDP=68]="TalkingAvatarService_WebRTC_SDP"})(t.PropertyId||(t.PropertyId={}))})(En)),En}var Mt={},pa;function Fl(){if(pa)return Mt;pa=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.Recognizer=void 0;const t=E(),r=I(),i=T(),u=y();let o=class zp{constructor(n,e,s){this.audioConfig=n!==void 0?n:u.AudioConfig.fromDefaultMicrophoneInput(),this.privDisposed=!1,this.privProperties=e.clone(),this.privConnectionFactory=s,this.implCommonRecognizerSetup()}close(n,e){i.Contracts.throwIfDisposed(this.privDisposed),r.marshalPromiseToCallbacks(this.dispose(!0),n,e)}get internalData(){return this.privReco}async dispose(n){this.privDisposed||(this.privDisposed=!0,n&&this.privReco&&(await this.privReco.audioSource.turnOff(),await this.privReco.dispose()))}static get telemetryEnabled(){return t.ServiceRecognizerBase.telemetryDataEnabled}static enableTelemetry(n){t.ServiceRecognizerBase.telemetryDataEnabled=n}implCommonRecognizerSetup(){let n=typeof window<"u"?"Browser":"Node",e="unknown",s="unknown";typeof navigator<"u"&&(n=n+"/"+navigator.platform,e=navigator.userAgent,s=navigator.appVersion);const c=this.createRecognizerConfig(new t.SpeechServiceConfig(new t.Context(new t.OS(n,e,s))));this.privReco=this.createServiceRecognizer(zp.getAuthFromProperties(this.privProperties),this.privConnectionFactory,this.audioConfig,c)}async recognizeOnceAsyncImpl(n){i.Contracts.throwIfDisposed(this.privDisposed);const e=new r.Deferred;await this.implRecognizerStop(),await this.privReco.recognize(n,e.resolve,e.reject);const s=await e.promise;return await this.implRecognizerStop(),s}async startContinuousRecognitionAsyncImpl(n){i.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop(),await this.privReco.recognize(n,void 0,void 0)}async stopContinuousRecognitionAsyncImpl(){i.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop()}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing(
18)}static getAuthFromProperties(n){const e=n.getProperty(u.PropertyId.SpeechServiceConnection_Key,void 0);return e&&e!==""?new t.CognitiveSubscriptionKeyAuthentication(e):new t.CognitiveTokenAuthentication(()=>{const c=n.getProperty(u.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(c)},()=>{const c=n.getProperty(u.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(c)})}};return Mt.Recognizer=o,Mt}var Ot={},da;function Ul(){if(da)return Ot;da=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.SpeechRecognizer=void 0;const t=E(),r=I(),i=T(),u=y();let o=class jp extends u.Recognizer{constructor(n,e){const s=n;i.Contracts.throwIfNull(s,"speechConfig"),i.Contracts.throwIfNullOrWhitespace(s.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage),u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage]),super(e,s.properties,new t.SpeechConnectionFactory),this.privDisposedRecognizer=!1}static FromConfig(n,e,s){const c=n;return e.properties.mergeTo(c.properties),new jp(n,s)}get endpointId(){return i.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(u.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(n){i.Contracts.throwIfNullOrWhitespace(n,"token"),this.properties.setProperty(u.PropertyId.SpeechServiceAuthorization_Token,n)}get speechRecognitionLanguage(){return i.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return i.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(t.OutputFormatPropertyName,u.OutputFormat[u.OutputFormat.Simple])===u.OutputFormat[u.OutputFormat.Simple]?u.OutputFormat.Simple:u.OutputFormat.Detailed}get properties(){return this.privProperties}recognizeOnceAsync(n,e){r.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(t.RecognitionMode.Interactive),n,e)}startContinuousRecognitionAsync(n,e){r.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(t.RecognitionMode.Conversation),n,e)}stopContinuousRecognitionAsync(n,e){r.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),n,e)}startKeywordRecognitionAsync(n,e,s){i.Contracts.throwIfNull(n,"model"),s&&s("Not yet implemented.")}stopKeywordRecognitionAsync(n){n&&n()}close(n,e){i.Contracts.throwIfDisposed(this.privDisposedRecognizer),r.marshalPromiseToCallbacks(this.dispose(!0),n,e)}async dispose(n){this.privDisposedRecognizer||(n&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(n))}createRecognizerConfig(n){return new t.RecognizerConfig(n,this.privProperties)}createServiceRecognizer(n,e,s,c){const p=s;return new t.SpeechServiceRecognizer(n,e,p,c,this)}};return Ot.SpeechRecognizer=o,Ot}var Dt={},ha;function Wl(){if(ha)return Dt;ha=1,Object.defineProperty(Dt,"__esModule",{value:!0}),Dt.IntentRecognizer=void 0;const t=E(),r=I(),i=T(),u=y();let o=class extends u.Recognizer{constructor(n,e){i.Contracts.throwIfNullOrUndefined(n,"speechConfig");const s=n;i.Contracts.throwIfNullOrUndefined(s,"speechConfig"),super(e,s.properties,new t.IntentConnectionFactory),this.privAddedIntents=[],this.privAddedLmIntents={},this.privDisposedIntentRecognizer=!1,this.privProperties=s.properties,i.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage),u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage])}get speechRecognitionLanguage(){return i.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage)}get authorizationToken(){return this.properties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(n){this.properties.setProperty(u.PropertyId.SpeechServiceAuthorization_Token,n)}get properties(){return this.privProperties}recognizeOnceAsync(n,e){if(i.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){const s=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",s.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(s.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}r.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(t.RecognitionMode.Interactive),n,e)}startContinuousRecognitionAsync(n,e){if(Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){const s=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",s.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(s.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}r.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(t.RecognitionMode.Conversation),n,e)}stopContinuousRecognitionAsync(n,e){r.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),n,e)}startKeywordRecognitionAsync(n,e,s){i.Contracts.throwIfNull(n,"model"),s&&s("Not yet implemented.")}stopKeywordRecognitionAsync(n,e){if(n)try{n()}catch(s){e&&e(s)}}addIntent(n,e){i.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),i.Contracts.throwIfNullOrWhitespace(e,"intentId"),i.Contracts.throwIfNullOrWhitespace(n,"simplePhrase"),this.privAddedIntents.push([e,n])}addIntentWithLanguageModel(n,e,s){i.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),i.Contracts.throwIfNullOrWhitespace(n,"intentId"),i.Contracts.throwIfNull(e,"model");const c=e;i.Contracts.throwIfNullOrWhitespace(c.appId,"model.appId"),this.privAddedLmIntents[n]=new t.AddedLmIntent(c,s)}addAllIntents(n,e){i.Contracts.throwIfNull(n,"model");const s=n;i.Contracts.throwIfNullOrWhitespace(s.appId,"model.appId"),this.privUmbrellaIntent=new t.AddedLmIntent(s,e)}close(n,e){i.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),r.marshalPromiseToCallbacks(this.dispose(!0),n,e)}createRecognizerConfig(n){return new t.RecognizerConfig(n,this.privProperties)}createServiceRecognizer(n,e,s,c){const p=s;return new t.IntentServiceRecognizer(n,e,p,c,this)}async dispose(n){this.privDisposedIntentRecognizer||n&&(this.privDisposedIntentRecognizer=!0,await super.dispose(n))}buildSpeechContext(){let n,e,s;const c=[];this.privUmbrellaIntent!==void 0&&(n=this.privUmbrellaIntent.modelImpl.appId,e=this.privUmbrellaIntent.modelImpl.region,s=this.privUmbrellaIntent.modelImpl.subscriptionKey);for(const p of Object.keys(this.privAddedLmIntents)){const d=this.privAddedLmIntents[p];if(n===void 0)n=d.modelImpl.appId;else if(n!==d.modelImpl.appId)throw new Error("Intents must all be from the same LUIS model");if(e===void 0)e=d.modelImpl.region;else if(e!==d.modelImpl.region)throw new Error("Intents must all be from the same LUIS model in a single region");if(s===void 0)s=d.modelImpl.subscriptionKey;else if(s!==d.modelImpl.subscriptionKey)throw new Error("Intents must all use the same subscription key");const h="luis/"+n+"-PRODUCTION#"+p;c.push(h)}return{Intent:{id:n,key:s===void 0?this.privProperties.getProperty(u.PropertyId[u.PropertyId.SpeechServiceConnection_Key]):s,provider:"LUIS"},ReferenceGrammars:this.privUmbrellaIntent===void 0?c:["luis/"+n+"-PRODUCTION"]}}};return Dt.IntentRecognizer=o,Dt}var In={},la;function Hl(){return la||(la=1,(function(t){Object.defineProperty(t,"__esMo
18dule",{value:!0}),t.VoiceProfileType=void 0,(function(r){r[r.TextIndependentIdentification=0]="TextIndependentIdentification",r[r.TextDependentVerification=1]="TextDependentVerification",r[r.TextIndependentVerification=2]="TextIndependentVerification"})(t.VoiceProfileType||(t.VoiceProfileType={}))})(In)),In}var kt={},Nt={},ue={},va;function qp(){if(va)return ue;va=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.ConnectionMessageImpl=ue.ConnectionMessage=void 0;const t=N(),r=I(),i=Np(),u=ps();let o=class{};ue.ConnectionMessage=o;class a{constructor(e){this.privConnectionMessage=e,this.privProperties=new i.PropertyCollection,this.privConnectionMessage.headers[t.HeaderNames.ConnectionId]&&this.privProperties.setProperty(u.PropertyId.Speech_SessionId,this.privConnectionMessage.headers[t.HeaderNames.ConnectionId]),Object.keys(this.privConnectionMessage.headers).forEach(s=>{this.privProperties.setProperty(s,this.privConnectionMessage.headers[s])})}get path(){return this.privConnectionMessage.headers[Object.keys(this.privConnectionMessage.headers).find(e=>e.toLowerCase()==="path".toLowerCase())]}get isTextMessage(){return this.privConnectionMessage.messageType===r.MessageType.Text}get isBinaryMessage(){return this.privConnectionMessage.messageType===r.MessageType.Binary}get TextMessage(){return this.privConnectionMessage.textBody}get binaryMessage(){return this.privConnectionMessage.binaryBody}get properties(){return this.privProperties}toString(){return""}}return ue.ConnectionMessageImpl=a,ue}var fa;function Lp(){if(fa)return Nt;fa=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.Connection=void 0;const t=E(),r=I(),i=qp(),u=T(),o=y();let a=class rs{static fromRecognizer(e){const s=e.internalData,c=new rs;return c.privInternalData=s,c.setupEvents(),c}static fromSynthesizer(e){const s=e.internalData,c=new rs;return c.privInternalData=s,c.setupEvents(),c}openConnection(e,s){r.marshalPromiseToCallbacks(this.privInternalData.connect(),e,s)}closeConnection(e,s){if(this.privInternalData instanceof t.SynthesisAdapterBase)throw new Error("Disconnecting a synthesizer's connection is currently not supported");r.marshalPromiseToCallbacks(this.privInternalData.disconnect(),e,s)}setMessageProperty(e,s,c){if(u.Contracts.throwIfNullOrWhitespace(s,"propertyName"),this.privInternalData instanceof t.ServiceRecognizerBase){if(e.toLowerCase()!=="speech.context")throw new Error("Only speech.context message property sets are currently supported for recognizer");this.privInternalData.speechContext.setSection(s,c)}else if(this.privInternalData instanceof t.SynthesisAdapterBase){if(e.toLowerCase()!=="synthesis.context")throw new Error("Only synthesis.context message property sets are currently supported for synthesizer");this.privInternalData.synthesisContext.setSection(s,c)}}sendMessageAsync(e,s,c,p){r.marshalPromiseToCallbacks(this.privInternalData.sendNetworkMessage(e,s),c,p)}close(){}setupEvents(){this.privEventListener=this.privInternalData.connectionEvents.attach(e=>{e.name==="ConnectionEstablishedEvent"?this.connected&&this.connected(new o.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionClosedEvent"?this.disconnected&&this.disconnected(new o.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionMessageSentEvent"?this.messageSent&&this.messageSent(new o.ConnectionMessageEventArgs(new i.ConnectionMessageImpl(e.message))):e.name==="ConnectionMessageReceivedEvent"&&this.messageReceived&&this.messageReceived(new o.ConnectionMessageEventArgs(new i.ConnectionMessageImpl(e.message)))}),this.privServiceEventListener=this.privInternalData.serviceEvents.attach(e=>{this.receivedServiceMessage&&this.receivedServiceMessage(new o.ServiceEventArgs(e.jsonString,e.name))})}};return Nt.Connection=a,Nt}var ga;
18function Vl(){if(ga)return kt;ga=1,Object.defineProperty(kt,"__esModule",{value:!0}),kt.TranslationRecognizer=void 0;const t=E(),r=I(),i=Lp(),u=T(),o=y();let a=class Bp extends o.Recognizer{constructor(e,s,c){const p=e;u.Contracts.throwIfNull(p,"speechConfig"),super(s,p.properties,c||new t.TranslationConnectionFactory),this.privDisposedTranslationRecognizer=!1,this.properties.getProperty(o.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)!==void 0&&u.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(o.PropertyId.SpeechServiceConnection_TranslationVoice),o.PropertyId[o.PropertyId.SpeechServiceConnection_TranslationVoice]),u.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(o.PropertyId.SpeechServiceConnection_TranslationToLanguages),o.PropertyId[o.PropertyId.SpeechServiceConnection_TranslationToLanguages]),u.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(o.PropertyId.SpeechServiceConnection_RecoLanguage),o.PropertyId[o.PropertyId.SpeechServiceConnection_RecoLanguage])}static FromConfig(e,s,c){const p=e;return s.properties.mergeTo(p.properties),new Bp(e,c)}get speechRecognitionLanguage(){return u.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(o.PropertyId.SpeechServiceConnection_RecoLanguage)}get targetLanguages(){return u.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(o.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",")}get voiceName(){return u.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(o.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(o.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(o.PropertyId.SpeechServiceAuthorization_Token,e)}recognizeOnceAsync(e,s){u.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),r.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(t.RecognitionMode.Interactive),e,s)}startContinuousRecognitionAsync(e,s){r.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(t.RecognitionMode.Conversation),e,s)}stopContinuousRecognitionAsync(e,s){r.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,s)}removeTargetLanguage(e){if(u.Contracts.throwIfNullOrUndefined(e,"language to be removed"),this.properties.getProperty(o.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0){const s=this.properties.getProperty(o.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),c=s.indexOf(e);c>-1&&(s.splice(c,1),this.properties.setProperty(o.PropertyId.SpeechServiceConnection_TranslationToLanguages,s.join(",")),this.updateLanguages(s))}}addTargetLanguage(e){u.Contracts.throwIfNullOrUndefined(e,"language to be added");let s=[];this.properties.getProperty(o.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?(s=this.properties.getProperty(o.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),s.includes(e)||(s.push(e),this.properties.setProperty(o.PropertyId.SpeechServiceConnection_TranslationToLanguages,s.join(",")))):(this.properties.setProperty(o.PropertyId.SpeechServiceConnection_TranslationToLanguages,e),s=[e]),this.updateLanguages(s)}close(e,s){u.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),r.marshalPromiseToCallbacks(this.dispose(!0),e,s)}onConnection(){}async dispose(e){this.privDisposedTranslationRecognizer||(this.privDisposedTranslationRecognizer=!0,e&&(await this.implRecognizerStop(),await super.dispose(e)))}createRecognizerConfig(e){return new t.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,s,c,p){const d=c;return new t.TranslationServiceRecognizer(e,s,d,p,this)}updateLanguages(e){const s=i.Connection.fromRecognizer(this);s&&(s.setMessageProperty("speech.context","translationcontext",{to:e}),s.sendMessageAsync("event",JSON.stringify({id:"translation",name:"updateLanguage",to:e})))}};return kt.TranslationRecognizer=a,kt}var zt={},ma;function $l(){if(ma)return zt;
18ma=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.Translations=void 0;const t=y();let r=class{constructor(){this.privMap=new t.PropertyCollection}get languages(){return this.privMap.keys}get(u,o){return this.privMap.getProperty(u,o)}set(u,o){this.privMap.setProperty(u,o)}};return zt.Translations=r,zt}var Tn={},Sa;function Kl(){return Sa||(Sa=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.NoMatchReason=void 0,(function(r){r[r.NotRecognized=0]="NotRecognized",r[r.InitialSilenceTimeout=1]="InitialSilenceTimeout",r[r.InitialBabbleTimeout=2]="InitialBabbleTimeout"})(t.NoMatchReason||(t.NoMatchReason={}))})(Tn)),Tn}var jt={},Ca;function Jl(){if(Ca)return jt;Ca=1,Object.defineProperty(jt,"__esModule",{value:!0}),jt.NoMatchDetails=void 0;const t=E(),r=y();let i=class xp{constructor(o){this.privReason=o}static fromResult(o){const a=t.SimpleSpeechPhrase.fromJSON(o.json);let n=r.NoMatchReason.NotRecognized;switch(a.RecognitionStatus){case t.RecognitionStatus.BabbleTimeout:n=r.NoMatchReason.InitialBabbleTimeout;break;case t.RecognitionStatus.InitialSilenceTimeout:n=r.NoMatchReason.InitialSilenceTimeout;break;default:n=r.NoMatchReason.NotRecognized;break}return new xp(n)}get reason(){return this.privReason}};return jt.NoMatchDetails=i,jt}var qt={},ya;function Gl(){if(ya)return qt;ya=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.TranslationRecognitionCanceledEventArgs=void 0;let t=class{constructor(i,u,o,a,n){this.privCancelReason=u,this.privErrorDetails=o,this.privResult=n,this.privSessionId=i,this.privErrorCode=a}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}};return qt.TranslationRecognitionCanceledEventArgs=t,qt}var Lt={},Ra;function Ql(){if(Ra)return Lt;Ra=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.IntentRecognitionCanceledEventArgs=void 0;const t=y();let r=class extends t.IntentRecognitionEventArgs{constructor(u,o,a,n,e,s){super(n,e,s),this.privReason=u,this.privErrorDetails=o,this.privErrorCode=a}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};return Lt.IntentRecognitionCanceledEventArgs=r,Lt}var Bt={},Pa;function Fp(){if(Pa)return Bt;Pa=1,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.CancellationDetailsBase=void 0;let t=class{constructor(i,u,o){this.privReason=i,this.privErrorDetails=u,this.privErrorCode=o}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get ErrorCode(){return this.privErrorCode}};return Bt.CancellationDetailsBase=t,Bt}var xt={},Ea;function Xl(){if(Ea)return xt;Ea=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.CancellationDetails=void 0;const t=E(),r=Fp(),i=y();let u=class Up extends r.CancellationDetailsBase{constructor(a,n,e){super(a,n,e)}static fromResult(a){let n=i.CancellationReason.Error,e=i.CancellationErrorCode.NoError;if(a instanceof i.RecognitionResult&&a.json){const s=t.SimpleSpeechPhrase.fromJSON(a.json);n=t.EnumTranslation.implTranslateCancelResult(s.RecognitionStatus)}return a.properties&&(e=i.CancellationErrorCode[a.properties.getProperty(t.CancellationErrorCodePropertyName,i.CancellationErrorCode[i.CancellationErrorCode.NoError])]),new Up(n,a.errorDetails||t.EnumTranslation.implTranslateErrorDetails(e),e)}};return xt.CancellationDetails=u,xt}var An={},Ia;function Zl(){return Ia||(Ia=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.CancellationErrorCode=void 0,(function(r){r[r.NoError=0]="NoError",r[r.AuthenticationFailure=1]="AuthenticationFailure",r[r.BadRequestParameters=2]="BadRequestParameters",r[r.TooManyRequests=3]="TooManyRequests",r[r.ConnectionFailure=4]="ConnectionFailure",r[r.ServiceTimeout=5]="ServiceTimeout",r[r.ServiceError=6]="ServiceError",r[r.RuntimeError=7]="RuntimeError",r[r.Forbidden=8]="Forbidden"})(t.CancellationErrorCode||(t.CancellationErrorCode={}))})(An)),An}var Ft={},Ta;function Yl(){if(Ta)return Ft;
18Ta=1,Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.ConnectionEventArgs=void 0;const t=y();let r=class extends t.SessionEventArgs{};return Ft.ConnectionEventArgs=r,Ft}var Ut={},Aa;function ev(){if(Aa)return Ut;Aa=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.ServiceEventArgs=void 0;const t=y();let r=class extends t.SessionEventArgs{constructor(u,o,a){super(a),this.privJsonResult=u,this.privEventName=o}get jsonString(){return this.privJsonResult}get eventName(){return this.privEventName}};return Ut.ServiceEventArgs=r,Ut}var Wt={},wa;function tv(){if(wa)return Wt;wa=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.PhraseListGrammar=void 0;let t=class Wp{constructor(i){this.privGrammerBuilder=i.dynamicGrammar}static fromRecognizer(i){const u=i.internalData;return new Wp(u)}addPhrase(i){this.privGrammerBuilder.addPhrase(i)}addPhrases(i){this.privGrammerBuilder.addPhrase(i)}clear(){this.privGrammerBuilder.clearPhrases()}};return Wt.PhraseListGrammar=t,Wt}var pe={},_a;function ds(){if(_a)return pe;_a=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.DialogServiceConfigImpl=pe.DialogServiceConfig=void 0;const t=T(),r=y();let i=class{constructor(){}set applicationId(a){}static get DialogTypes(){return{BotFramework:"bot_framework",CustomCommands:"custom_commands"}}};pe.DialogServiceConfig=i;class u extends i{constructor(){super(),this.privSpeechConfig=new r.SpeechConfigImpl}get properties(){return this.privSpeechConfig.properties}get speechRecognitionLanguage(){return this.privSpeechConfig.speechRecognitionLanguage}set speechRecognitionLanguage(a){t.Contracts.throwIfNullOrWhitespace(a,"value"),this.privSpeechConfig.speechRecognitionLanguage=a}get outputFormat(){return this.privSpeechConfig.outputFormat}set outputFormat(a){this.privSpeechConfig.outputFormat=a}setProperty(a,n){this.privSpeechConfig.setProperty(a,n)}getProperty(a,n){return this.privSpeechConfig.getProperty(a)}setProxy(a,n,e,s){this.setProperty(r.PropertyId.SpeechServiceConnection_ProxyHostName,a),this.setProperty(r.PropertyId.SpeechServiceConnection_ProxyPort,`${n}`),e&&this.setProperty(r.PropertyId.SpeechServiceConnection_ProxyUserName,e),s&&this.setProperty(r.PropertyId.SpeechServiceConnection_ProxyPassword,s)}setServiceProperty(a,n,e){this.privSpeechConfig.setServiceProperty(a,n)}close(){}}return pe.DialogServiceConfigImpl=u,pe}var Ht={},ba;function rv(){if(ba)return Ht;ba=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.BotFrameworkConfig=void 0;const t=T(),r=ds(),i=y();let u=class extends r.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(a,n,e){t.Contracts.throwIfNullOrWhitespace(a,"subscription"),t.Contracts.throwIfNullOrWhitespace(n,"region");const s=new r.DialogServiceConfigImpl;return s.setProperty(i.PropertyId.Conversation_DialogType,r.DialogServiceConfig.DialogTypes.BotFramework),s.setProperty(i.PropertyId.SpeechServiceConnection_Key,a),s.setProperty(i.PropertyId.SpeechServiceConnection_Region,n),e&&s.setProperty(i.PropertyId.Conversation_ApplicationId,e),s}static fromAuthorizationToken(a,n,e){t.Contracts.throwIfNullOrWhitespace(a,"authorizationToken"),t.Contracts.throwIfNullOrWhitespace(n,"region");const s=new r.DialogServiceConfigImpl;return s.setProperty(i.PropertyId.Conversation_DialogType,r.DialogServiceConfig.DialogTypes.BotFramework),s.setProperty(i.PropertyId.SpeechServiceAuthorization_Token,a),s.setProperty(i.PropertyId.SpeechServiceConnection_Region,n),e&&s.setProperty(i.PropertyId.Conversation_ApplicationId,e),s}static fromHost(a,n,e){t.Contracts.throwIfNullOrUndefined(a,"host");const s=a instanceof URL?a:new URL(`wss://${a}.convai.speech.azure.us`);t.Contracts.throwIfNullOrUndefined(s,"resolvedHost");const c=new r.DialogServiceConfigImpl;return c.setProperty(i.PropertyId.Conversation_DialogType,r.DialogServiceConfig.DialogTypes.BotFramework),c.setProperty(i.PropertyId.SpeechServiceConnection_Host,s.toString()),n!==void 0&&c.setProperty(i.PropertyId.SpeechServiceConnection_Key,n),c}static fromEndpoint(a,n){t.Contracts.throwIfNull(a,"endpoint");const e=new r.DialogServiceConfigImpl;return e.setProperty(i.PropertyId.Conversation_DialogType,r.DialogServiceConfig.DialogTypes.BotFramework),e.setProperty(i.PropertyId.SpeechServiceConnection_Endpoint,a.toString()),n!==void 0&&e.setProperty(i.PropertyId.SpeechServiceConnection_Key,n),e}};return Ht.BotFrameworkConfig=u,Ht}var Vt={},Ma;function iv(){if(Ma)return Vt;
18Ma=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.CustomCommandsConfig=void 0;const t=T(),r=ds(),i=y();let u=class extends r.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(a,n,e){t.Contracts.throwIfNullOrWhitespace(a,"applicationId"),t.Contracts.throwIfNullOrWhitespace(n,"subscription"),t.Contracts.throwIfNullOrWhitespace(e,"region");const s=new r.DialogServiceConfigImpl;return s.setProperty(i.PropertyId.Conversation_DialogType,r.DialogServiceConfig.DialogTypes.CustomCommands),s.setProperty(i.PropertyId.Conversation_ApplicationId,a),s.setProperty(i.PropertyId.SpeechServiceConnection_Key,n),s.setProperty(i.PropertyId.SpeechServiceConnection_Region,e),s}static fromAuthorizationToken(a,n,e){t.Contracts.throwIfNullOrWhitespace(a,"applicationId"),t.Contracts.throwIfNullOrWhitespace(n,"authorizationToken"),t.Contracts.throwIfNullOrWhitespace(e,"region");const s=new r.DialogServiceConfigImpl;return s.setProperty(i.PropertyId.Conversation_DialogType,r.DialogServiceConfig.DialogTypes.CustomCommands),s.setProperty(i.PropertyId.Conversation_ApplicationId,a),s.setProperty(i.PropertyId.SpeechServiceAuthorization_Token,n),s.setProperty(i.PropertyId.SpeechServiceConnection_Region,e),s}set applicationId(a){t.Contracts.throwIfNullOrWhitespace(a,"value"),this.setProperty(i.PropertyId.Conversation_ApplicationId,a)}get applicationId(){return this.getProperty(i.PropertyId.Conversation_ApplicationId)}};return Vt.CustomCommandsConfig=u,Vt}var $t={},Kt={},Jt={},Gt={},Oa;function Y(){if(Oa)return Gt;Oa=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.QueryParameterNames=void 0;let t=class{};return Gt.QueryParameterNames=t,t.BotId="botid",t.CustomSpeechDeploymentId="cid",t.CustomVoiceDeploymentId="deploymentId",t.EnableAudioLogging="storeAudio",t.EnableLanguageId="lidEnabled",t.EnableWordLevelTimestamps="wordLevelTimestamps",t.EndSilenceTimeoutMs="endSilenceTimeoutMs",t.SegmentationSilenceTimeoutMs="segmentationSilenceTimeoutMs",t.Format="format",t.InitialSilenceTimeoutMs="initialSilenceTimeoutMs",t.Language="language",t.Profanity="profanity",t.RequestBotStatusMessages="enableBotMessageStatus",t.StableIntermediateThreshold="stableIntermediateThreshold",t.StableTranslation="stableTranslation",t.TestHooks="testhooks",t.Postprocessing="postprocessing",t.CtsMeetingId="meetingId",t.CtsDeviceId="deviceId",t.CtsIsParticipant="isParticipant",t.EnableAvatar="enableTalkingAvatar",Gt}var Da;function H(){if(Da)return Jt;Da=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.ConnectionFactoryBase=void 0;const t=E(),r=y(),i=Y();let u=class{static getHostSuffix(a){if(a){if(a.toLowerCase().startsWith("china"))return".azure.cn";if(a.toLowerCase().startsWith("usgov"))return".azure.us"}return".microsoft.com"}setCommonUrlParams(a,n,e){new Map([[r.PropertyId.Speech_SegmentationSilenceTimeoutMs,i.QueryParameterNames.SegmentationSilenceTimeoutMs],[r.PropertyId.SpeechServiceConnection_EnableAudioLogging,i.QueryParameterNames.EnableAudioLogging],[r.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,i.QueryParameterNames.EndSilenceTimeoutMs],[r.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,i.QueryParameterNames.InitialSilenceTimeoutMs],[r.PropertyId.SpeechServiceResponse_PostProcessingOption,i.QueryParameterNames.Postprocessing],[r.PropertyId.SpeechServiceResponse_ProfanityOption,i.QueryParameterNames.Profanity],[r.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,i.QueryParameterNames.EnableWordLevelTimestamps],[r.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,i.QueryParameterNames.StableIntermediateThreshold]]).forEach((p,d)=>{this.setUrlParameter(d,p,a,n,e)});const c=JSON.parse(a.parameters.getProperty(t.ServicePropertiesPropertyName,"{}"));Object.keys(c).forEach(p=>{n[p]=c[p]})}setUrlParameter(a,n,e,s,c){const p=e.parameters.getProperty(a,void 0);p&&(!c||c.search(n)===-1)&&(s[n]=p.toLocaleLowerCase())}};return Jt.ConnectionFactoryBase=u,Jt}var ka;function nv(){if(ka)return Kt;ka=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.DialogConnectionFactory=void 0;const t=D(),r=E(),i=y(),u=H(),o=E(),a=N(),n=Y();class e extends u.ConnectionFactoryBase{create(c,p,d){const h=c.parameters.getProperty(i.PropertyId.Conversation_ApplicationId,""),l=c.parameters.getProperty(i.PropertyId.Conversation_DialogType),v=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Region),f=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),g=c.parameters.getProperty(i.PropertyId.Conversation_Request_Bot_Status_Messages,"true"),m={};m[a.HeaderNames.ConnectionId]=d,m[n.QueryParameterNames.Format]=c.parameters.getProperty(r.OutputFormatPropertyName,i.OutputFormat[i.OutputFormat.Simple]).toLowerCase(),m[n.QueryParameterNames.Language]=f,m[n.QueryParameterNames.RequestBotStatusMessages]=g,h&&(m[n.QueryParameterNames.BotId]=h,l===i.DialogServiceConfig.DialogTypes.CustomCommands&&(m[a.HeaderNames.CustomCommandsAppId]=h));const S=l===i.DialogServiceConfig.DialogTypes.CustomCommands?"commands/":"",C=l===i.DialogServiceConfig.DialogTypes.CustomCommands?"v1":l===i.DialogServiceConfig.DialogTypes.BotFramework?"v3":"v0",R={};p.token!=null&&p.token!==""&&(R[p.headerName]=p.token);let P=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Endpoint,"");if(!P){const M=u.ConnectionFactoryBase.getHostSuffix(v),_=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Host,`wss://${v}.${e.BaseUrl}${M}`);P=`${_.endsWith("/")?_:_+"/"}${S}${e.ApiKey}/${C}`}this.setCommonUrlParams(c,m,P);const A=c.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new t.WebsocketConnection(P,m,R,new o.WebsocketMessageFormatter,t.ProxyInfo.fromRecognizerConfig(c),A,d)}}return Kt.DialogConnectionFactory=e,e.ApiKey="api",e.BaseUrl="convai.speech",Kt}var Na;function sv(){if(Na)return $t;
18Na=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.DialogServiceConnector=void 0;const t=nv(),r=E(),i=I(),u=T(),o=y(),a=ps();let n=class extends o.Recognizer{constructor(s,c){const p=s;u.Contracts.throwIfNull(s,"dialogConfig"),super(c,p.properties,new t.DialogConnectionFactory),this.isTurnComplete=!0,this.privIsDisposed=!1,this.privProperties=p.properties.clone();const d=this.buildAgentConfig();this.privReco.agentConfig.set(d)}connect(s,c){i.marshalPromiseToCallbacks(this.privReco.connect(),s,c)}disconnect(s,c){i.marshalPromiseToCallbacks(this.privReco.disconnect(),s,c)}get authorizationToken(){return this.properties.getProperty(a.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(s){u.Contracts.throwIfNullOrWhitespace(s,"token"),this.properties.setProperty(a.PropertyId.SpeechServiceAuthorization_Token,s)}get properties(){return this.privProperties}get speechActivityTemplate(){return this.properties.getProperty(a.PropertyId.Conversation_Speech_Activity_Template)}set speechActivityTemplate(s){this.properties.setProperty(a.PropertyId.Conversation_Speech_Activity_Template,s)}listenOnceAsync(s,c){if(this.isTurnComplete){u.Contracts.throwIfDisposed(this.privIsDisposed);const d=(async()=>{await this.privReco.connect(),await this.implRecognizerStop(),this.isTurnComplete=!1;const h=new i.Deferred;await this.privReco.recognize(r.RecognitionMode.Conversation,h.resolve,h.reject);const l=await h.promise;return await this.implRecognizerStop(),l})();d.catch(()=>{this.dispose(!0).catch(()=>{})}),i.marshalPromiseToCallbacks(d.finally(()=>{this.isTurnComplete=!0}),s,c)}}sendActivityAsync(s,c,p){i.marshalPromiseToCallbacks(this.privReco.sendMessage(s),c,p)}close(s,c){u.Contracts.throwIfDisposed(this.privIsDisposed),i.marshalPromiseToCallbacks(this.dispose(!0),s,c)}async dispose(s){this.privIsDisposed||s&&(this.privIsDisposed=!0,await this.implRecognizerStop(),await super.dispose(s))}createRecognizerConfig(s){return new r.RecognizerConfig(s,this.privProperties)}createServiceRecognizer(s,c,p,d){const h=p;return new r.DialogServiceAdapter(s,c,h,d,this)}buildAgentConfig(){return{botInfo:{commType:this.properties.getProperty("Conversation_Communication_Type","Default"),commandsCulture:void 0,connectionId:this.properties.getProperty(a.PropertyId.Conversation_Agent_Connection_Id),conversationId:this.properties.getProperty(a.PropertyId.Conversation_Conversation_Id,void 0),fromId:this.properties.getProperty(a.PropertyId.Conversation_From_Id,void 0),ttsAudioFormat:this.properties.getProperty(a.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)},version:.2}}};return $t.DialogServiceConnector=n,$t}var Qt={},za;function ov(){if(za)return Qt;za=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.ActivityReceivedEventArgs=void 0;let t=class{constructor(i,u){this.privActivity=i,this.privAudioStream=u}get activity(){return this.privActivity}get audioStream(){return this.privAudioStream}};return Qt.ActivityReceivedEventArgs=t,Qt}var Xt={},Zt={},ja;function av(){if(ja)return Zt;ja=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.TurnStatusResponsePayload=void 0;class t{constructor(i){this.privMessageStatusResponse=JSON.parse(i)}static fromJSON(i){return new t(i)}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}}}return Zt.TurnStatusResponsePayload=t,Zt}var qa;function cv(){if(qa)return Xt;qa=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.TurnStatusReceivedEventArgs=void 0;const t=av();let r=class{constructor(u){this.privTurnStatus=t.TurnStatusResponsePayload.fromJSON(u)}get interactionId(){return this.privTurnStatus.interactionId}get conversationId(){return this.privTurnStatus.conversationId}get statusCode(){return this.privTurnStatus.statusCode}};return Xt.TurnStatusReceivedEventArgs=r,Xt}var wn={},La;function uv(){return La||(La=1,(function(t){Object.defineProperty(t,"__esMo
18dule",{value:!0}),t.ServicePropertyChannel=void 0,(function(r){r[r.UriQueryParameter=0]="UriQueryParameter"})(t.ServicePropertyChannel||(t.ServicePropertyChannel={}))})(wn)),wn}var _n={},Ba;function pv(){return Ba||(Ba=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ProfanityOption=void 0,(function(r){r[r.Masked=0]="Masked",r[r.Removed=1]="Removed",r[r.Raw=2]="Raw"})(t.ProfanityOption||(t.ProfanityOption={}))})(_n)),_n}var Yt={},xa;function dv(){if(xa)return Yt;xa=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.BaseAudioPlayer=void 0;const t=V(),r=y(),i=we();let u=class{constructor(a){this.audioContext=null,this.gainNode=null,this.autoUpdateBufferTimer=0,a===void 0&&(a=r.AudioStreamFormat.getDefaultInputFormat()),this.init(a)}playAudioSample(a,n,e){try{this.ensureInitializedContext();const s=this.formatAudioData(a),c=new Float32Array(this.samples.length+s.length);c.set(this.samples,0),c.set(s,this.samples.length),this.samples=c,n&&n()}catch(s){e&&e(s)}}stopAudio(a,n){this.audioContext!==null&&(this.samples=new Float32Array,clearInterval(this.autoUpdateBufferTimer),this.audioContext.close().then(()=>{a&&a()},e=>{n&&n(e)}),this.audioContext=null)}init(a){this.audioFormat=a,this.samples=new Float32Array}ensureInitializedContext(){if(this.audioContext===null){this.createAudioContext();const a=200;this.autoUpdateBufferTimer=setInterval(()=>{this.updateAudioBuffer()},a)}}createAudioContext(){this.audioContext=i.AudioStreamFormatImpl.getAudioContext(),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.gainNode.connect(this.audioContext.destination),this.startTime=this.audioContext.currentTime}formatAudioData(a){switch(this.audioFormat.bitsPerSample){case 8:return this.formatArrayBuffer(new Int8Array(a),128);case 16:return this.formatArrayBuffer(new Int16Array(a),32768);case 32:return this.formatArrayBuffer(new Int32Array(a),2147483648);default:throw new t.InvalidOperationError("Only WAVE_FORMAT_PCM (8/16/32 bps) format supported at this time")}}formatArrayBuffer(a,n){const e=new Float32Array(a.length);for(let s=0;s<a.length;s++)e[s]=a[s]/n;return e}updateAudioBuffer(){if(this.samples.length===0)return;const a=this.audioFormat.channels,n=this.audioContext.createBufferSource(),e=this.samples.length/a,s=this.audioContext.createBuffer(a,e,this.audioFormat.samplesPerSec);for(let c=0;c<a;c++){let p=c;const d=s.getChannelData(c);for(let h=0;h<this.samples.length;h++,p+=a)d[h]=this.samples[p]}this.startTime<this.audioContext.currentTime&&(this.startTime=this.audioContext.currentTime),n.buffer=s,n.connect(this.gainNode),n.start(this.startTime),this.startTime+=s.duration,this.samples=new Float32Array}async playAudio(a){this.audioContext===null&&this.createAudioContext();const n=this.audioContext.createBufferSource(),e=this.audioContext.destination;await this.audioContext.decodeAudioData(a,s=>{n.buffer=s,n.connect(e),n.start(0)})}};return Yt.BaseAudioPlayer=u,Yt}var er={},Fa;function hv(){if(Fa)return er;Fa=1,Object.defineProperty(er,"__esModule",{value:!0}),er.ConnectionMessageEventArgs=void 0;let t=class{constructor(i){this.privConnectionMessage=i}get message(){return this.privConnectionMessage}toString(){return"Message: "+this.privConnectionMessage.toString()}};return er.ConnectionMessageEventArgs=t,er}var tr={},Ua;function lv(){if(Ua)return tr;Ua=1,Object.defineProperty(tr,"__esModule",{value:!0}),tr.VoiceProfile=void 0;let t=class{constructor(i,u){this.privId=i,this.privProfileType=u}get profileId(){return this.privId}get profileType(){return this.privProfileType}};return tr.VoiceProfile=t,tr}var de={},Wa;function vv(){if(Wa)return de;Wa=1,Object.defineProperty(de,"__esModule",{value:!0}),de.VoiceProfileEnrollmentCancellationDetails=de.VoiceProfileEnrollmentResult=void 0;const t=E(),r=y();let i=class is{constructor(a,n,e){this.privReason=a,this.privProperties=new r.PropertyCollection,this.privReason!==r.ResultReason.Canceled?n&&(this.privDetails=JSON.parse(n),this.privDetails.enrollmentStatus.toLowerCase()==="enrolling"&&(this.privReason=r.ResultReason.EnrollingVoiceProfile)):(this.privErrorDetails=e,this.privProperties.setProperty(t.CancellationErrorCodePropertyName,r.CancellationErrorCode[r.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(a){const n=[];for(const e of a.value){const s=e.enrollmentStatus.toLowerCase()==="enrolling"?r.ResultReason.EnrollingVoiceProfile:e.enrollmentStatus.toLowerCase()==="enrolled"?r.ResultReason.EnrolledVoiceProfile:r.ResultReason.Canceled,c=new is(s,null,null);
18c.privDetails=this.getIdentificationDetails(e),n.push(c)}return n}static FromVerificationProfileList(a){const n=[];for(const e of a.value){const s=e.enrollmentStatus.toLowerCase()==="enrolling"?r.ResultReason.EnrollingVoiceProfile:e.enrollmentStatus.toLowerCase()==="enrolled"?r.ResultReason.EnrolledVoiceProfile:r.ResultReason.Canceled,c=new is(s,null,null);c.privDetails=this.getVerificationDetails(e),n.push(c)}return n}static getIdentificationDetails(a){return{audioLength:a.audioLength?parseFloat(a.audioLength):0,audioSpeechLength:a.audioSpeechLength?parseFloat(a.audioSpeechLength):0,enrollmentStatus:a.enrollmentStatus,enrollmentsCount:a.enrollmentsCount||0,enrollmentsLength:a.enrollmentsLength?parseFloat(a.enrollmentsLength):0,enrollmentsSpeechLength:a.enrollmentsSpeechLength?parseFloat(a.enrollmentsSpeechLength):0,profileId:a.profileId||a.identificationProfileId,remainingEnrollmentsSpeechLength:a.remainingEnrollmentsSpeechLength?parseFloat(a.remainingEnrollmentsSpeechLength):0}}static getVerificationDetails(a){return{audioLength:a.audioLength?parseFloat(a.audioLength):0,audioSpeechLength:a.audioSpeechLength?parseFloat(a.audioSpeechLength):0,enrollmentStatus:a.enrollmentStatus,enrollmentsCount:a.enrollmentsCount,enrollmentsLength:a.enrollmentsLength?parseFloat(a.enrollmentsLength):0,enrollmentsSpeechLength:a.enrollmentsSpeechLength?parseFloat(a.enrollmentsSpeechLength):0,profileId:a.profileId||a.verificationProfileId,remainingEnrollmentsCount:a.remainingEnrollments||a.remainingEnrollmentsCount,remainingEnrollmentsSpeechLength:a.remainingEnrollmentsSpeechLength?parseFloat(a.remainingEnrollmentsSpeechLength):0}}};de.VoiceProfileEnrollmentResult=i;class u extends r.CancellationDetailsBase{constructor(a,n,e){super(a,n,e)}static fromResult(a){const n=r.CancellationReason.Error;let e=r.CancellationErrorCode.NoError;return a.properties&&(e=r.CancellationErrorCode[a.properties.getProperty(t.CancellationErrorCodePropertyName,r.CancellationErrorCode[r.CancellationErrorCode.NoError])]),new u(n,a.errorDetails,e)}}return de.VoiceProfileEnrollmentCancellationDetails=u,de}var he={},Ha;function fv(){if(Ha)return he;Ha=1,Object.defineProperty(he,"__esModule",{value:!0}),he.VoiceProfileCancellationDetails=he.VoiceProfileResult=void 0;const t=E(),r=T(),i=y();let u=class{constructor(n,e){this.privReason=n,this.privProperties=new i.PropertyCollection,n===i.ResultReason.Canceled&&(r.Contracts.throwIfNullOrUndefined(e,"statusText"),this.privErrorDetails=e,this.privProperties.setProperty(t.CancellationErrorCodePropertyName,i.CancellationErrorCode[i.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get properties(){return this.privProperties}get errorDetails(){return this.privErrorDetails}};he.VoiceProfileResult=u;class o extends i.CancellationDetailsBase{constructor(n,e,s){super(n,e,s)}static fromResult(n){const e=i.CancellationReason.Error;let s=i.CancellationErrorCode.NoError;return n.properties&&(s=i.CancellationErrorCode[n.properties.getProperty(t.CancellationErrorCodePropertyName,i.CancellationErrorCode[i.CancellationErrorCode.NoError])]),new o(e,n.errorDetails,s)}}return he.VoiceProfileCancellationDetails=o,he}var rr={},Va;function gv(){if(Va)return rr;Va=1,Object.defineProperty(rr,"__esModule",{value:!0}),rr.VoiceProfilePhraseResult=void 0;const t=T(),r=y();let i=class extends r.VoiceProfileResult{constructor(o,a,n,e){super(o,a),this.privPhrases=[],t.Contracts.throwIfNullOrUndefined(e,"phrase array"),this.privType=n,e&&e[0]&&(this.privPhrases=e)}get phrases(){return this.privPhrases}get type(){return this.privType}};return rr.VoiceProfilePhraseResult=i,rr}var ir={},$a;function mv(){if($a)return ir;$a=1,Object.defineProperty(ir,"__esModule",{value:!0}),ir.VoiceProfileClient=void 0;const t=E(),r=Mp(),i=T(),u=y();let o=class extends u.Recognizer{constructor(n){i.Contracts.throwIfNullOrUndefined(n,"speechConfig");const e=n;i.Contracts.throwIfNull(e,"speechConfig"),super(r.AudioConfig.fromStreamInput(u.AudioInputStream.createPushStream()),e.properties,new t.VoiceProfileConnectionFactory),this.privProperties=e.properties.clone(),this.privVoiceAdapter=this.privReco,this.privDisposedVoiceAdapter=!1}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token)}
18set authorizationToken(n){i.Contracts.throwIfNullOrWhitespace(n,"token"),this.properties.setProperty(u.PropertyId.SpeechServiceAuthorization_Token,n)}async createProfileAsync(n,e){const s=await this.privVoiceAdapter.createProfile(n,e);return new u.VoiceProfile(s[0],n)}async retrieveEnrollmentResultAsync(n){return this.privVoiceAdapter.retrieveEnrollmentResult(n)}async getAllProfilesAsync(n){return this.privVoiceAdapter.getAllProfiles(n)}async getActivationPhrasesAsync(n,e){return this.privVoiceAdapter.getActivationPhrases(n,e)}async enrollProfileAsync(n,e){const s=e;return i.Contracts.throwIfNullOrUndefined(s,"audioConfig"),this.audioConfig=e,this.privVoiceAdapter.SpeakerAudioSource=s,this.privVoiceAdapter.enrollProfile(n)}async deleteProfileAsync(n){return this.privVoiceAdapter.deleteProfile(n)}async resetProfileAsync(n){return this.privVoiceAdapter.resetProfile(n)}async close(){await this.dispose(!0)}createServiceRecognizer(n,e,s,c){const p=s;return new t.VoiceServiceRecognizer(n,e,p,c,this)}async dispose(n){this.privDisposedVoiceAdapter||(this.privDisposedVoiceAdapter=!0,n&&await super.dispose(n))}createRecognizerConfig(n){return new t.RecognizerConfig(n,this.properties)}getResult(n,e){return new u.VoiceProfileResult(n.ok?e:u.ResultReason.Canceled,n.statusText)}};return ir.VoiceProfileClient=o,ir}var nr={},Ka;function Sv(){if(Ka)return nr;Ka=1,Object.defineProperty(nr,"__esModule",{value:!0}),nr.SpeakerRecognizer=void 0;const t=E(),r=T(),i=y();let u=class extends i.Recognizer{constructor(a,n){r.Contracts.throwIfNullOrUndefined(a,"speechConfig");const e=a;r.Contracts.throwIfNullOrUndefined(e,"speechConfig"),super(n,e.properties,new t.SpeakerRecognitionConnectionFactory),this.privAudioConfigImpl=n,r.Contracts.throwIfNull(this.privAudioConfigImpl,"audioConfig"),this.privDisposedSpeakerRecognizer=!1,this.privProperties=e.properties}get authorizationToken(){return this.properties.getProperty(i.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(a){r.Contracts.throwIfNullOrWhitespace(a,"token"),this.properties.setProperty(i.PropertyId.SpeechServiceAuthorization_Token,a)}get properties(){return this.privProperties}async recognizeOnceAsync(a){return r.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),this.recognizeSpeakerOnceAsyncImpl(a)}async close(){r.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.dispose(!0)}async recognizeSpeakerOnceAsyncImpl(a){r.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.implRecognizerStop();const n=await this.privReco.recognizeSpeaker(a);return await this.implRecognizerStop(),n}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing(
18)}createRecognizerConfig(a){return new t.RecognizerConfig(a,this.privProperties)}createServiceRecognizer(a,n,e,s){const c=e;return new t.SpeakerServiceRecognizer(a,n,c,s,this)}async dispose(a){this.privDisposedSpeakerRecognizer||a&&(this.privDisposedSpeakerRecognizer=!0,await super.dispose(a))}};return nr.SpeakerRecognizer=u,nr}var sr={},Ja;function Cv(){if(Ja)return sr;Ja=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.SpeakerIdentificationModel=void 0;const t=T(),r=y();let i=class Hp{constructor(o){if(this.privVoiceProfiles=[],this.privProfileIds=[],t.Contracts.throwIfNullOrUndefined(o,"VoiceProfiles"),o.length===0)throw new Error("Empty Voice Profiles array");for(const a of o){if(a.profileType!==r.VoiceProfileType.TextIndependentIdentification)throw new Error("Identification model can only be created from Identification profile: "+a.profileId);this.privVoiceProfiles.push(a),this.privProfileIds.push(a.profileId)}}static fromProfiles(o){return new Hp(o)}get voiceProfileIds(){return this.privProfileIds.join(",")}get profileIds(){return this.privProfileIds}get scenario(){return"TextIndependentIdentification"}};return sr.SpeakerIdentificationModel=i,sr}var or={},Ga;function yv(){if(Ga)return or;Ga=1,Object.defineProperty(or,"__esModule",{value:!0}),or.SpeakerVerificationModel=void 0;const t=T(),r=y();let i=class Vp{constructor(o){if(t.Contracts.throwIfNullOrUndefined(o,"VoiceProfile"),o.profileType===r.VoiceProfileType.TextIndependentIdentification)throw new Error("Verification model cannot be created from Identification profile");this.privVoiceProfile=o}static fromProfile(o){return new Vp(o)}get voiceProfile(){return this.privVoiceProfile}get profileIds(){return[this.voiceProfile.profileId]}get scenario(){return this.voiceProfile.profileType===r.VoiceProfileType.TextDependentVerification?"TextDependentVerification":"TextIndependentVerification"}};return or.SpeakerVerificationModel=i,or}var ar={},bn={},Qa;function $p(){return Qa||(Qa=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.LanguageIdMode=void 0,(function(r){r[r.AtStart=0]="AtStart",r[r.Continuous=1]="Continuous"})(t.LanguageIdMode||(t.LanguageIdMode={}))})(bn)),bn}var Xa;function Rv(){if(Xa)return ar;Xa=1,Object.defineProperty(ar,"__esModule",{value:!0}),ar.AutoDetectSourceLanguageConfig=void 0;const t=E(),r=T(),i=y(),u=$p();let o=class Hi{constructor(){this.privProperties=new i.PropertyCollection,this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart"),this.privLanguageIdMode=u.LanguageIdMode.AtStart}static fromOpenRange(){const n=new Hi;return n.properties.setProperty(i.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,t.AutoDetectSourceLanguagesOpenRangeOptionName),n}static fromLanguages(n){r.Contracts.throwIfArrayEmptyOrWhitespace(n,"languages");const e=new Hi;return e.properties.setProperty(i.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,n.join()),e}static fromSourceLanguageConfigs(n){if(n.length<1)throw new Error("Expected non-empty SourceLanguageConfig array.");const e=new Hi,s=[];return n.forEach(c=>{if(s.push(c.language),c.endpointId!==void 0&&c.endpointId!==""){const p=c.language+i.PropertyId.SpeechServiceConnection_EndpointId.toString();e.properties.setProperty(p,c.endpointId)}}),e.properties.setProperty(i.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,s.join()),e}get properties(){return this.privProperties}set mode(n){n===u.LanguageIdMode.Continuous?(this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_LanguageIdMode,"Continuous")):(this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"1"),this.privProperties.setProperty(i.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart")),this.privLanguageIdMode=n}};return ar.AutoDetectSourceLanguageConfig=o,ar}var cr={},Za;function Pv(){if(Za)return cr;Za=1,Object.defineProperty(cr,"__esModule",{value:!0}),cr.AutoDetectSourceLanguageResult=void 0;const t=T();let r=class ns{constructor(u,o){t.Contracts.throwIfNullOrUndefined(u,"language"),t.Contracts.throwIfNullOrUndefined(o,"languageDetectionConfidence"),this.privLanguage=u,this.privLanguageDetectionConfidence=o}static fromResult(u){return new ns(u.language,u.languageDetectionConfidence)}static fromConversationTranscriptionResult(u){return new ns(u.language,u.languageDetectionConfidence)}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}};return cr.AutoDetectSourceLanguageResult=r,cr}var ur={},Ya;function Ev(){if(Ya)return ur;
18Ya=1,Object.defineProperty(ur,"__esModule",{value:!0}),ur.SourceLanguageConfig=void 0;const t=T();let r=class Kp{constructor(u,o){t.Contracts.throwIfNullOrUndefined(u,"language"),this.privLanguage=u,this.privEndpointId=o}static fromLanguage(u,o){return new Kp(u,o)}get language(){return this.privLanguage}get endpointId(){return this.privEndpointId}};return ur.SourceLanguageConfig=r,ur}var Mn={},ec;function Iv(){return ec||(ec=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakerRecognitionCancellationDetails=t.SpeakerRecognitionResult=t.SpeakerRecognitionResultType=void 0;const r=E(),i=y();var u;(function(n){n[n.Verify=0]="Verify",n[n.Identify=1]="Identify"})(u=t.SpeakerRecognitionResultType||(t.SpeakerRecognitionResultType={}));class o{constructor(e,s=i.ResultReason.RecognizedSpeaker,c=i.CancellationErrorCode.NoError,p=""){this.privProperties=new i.PropertyCollection;const d=e.scenario==="TextIndependentIdentification"?u.Identify:u.Verify;this.privReason=s,this.privReason!==i.ResultReason.Canceled?d===u.Identify?(this.privProfileId=e.identificationResult.identifiedProfile.profileId,this.privScore=e.identificationResult.identifiedProfile.score,this.privReason=i.ResultReason.RecognizedSpeakers):(this.privScore=e.verificationResult.score,e.verificationResult.recognitionResult.toLowerCase()!=="accept"&&(this.privReason=i.ResultReason.NoMatch),e.verificationResult.profileId!==void 0&&e.verificationResult.profileId!==""&&(this.privProfileId=e.verificationResult.profileId)):(this.privErrorDetails=p,this.privProperties.setProperty(r.CancellationErrorCodePropertyName,i.CancellationErrorCode[c])),this.privProperties.setProperty(i.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}}t.SpeakerRecognitionResult=o;class a extends i.CancellationDetailsBase{constructor(e,s,c){super(e,s,c)}static fromResult(e){const s=i.CancellationReason.Error;let c=i.CancellationErrorCode.NoError;return e.properties&&(c=i.CancellationErrorCode[e.properties.getProperty(r.CancellationErrorCodePropertyName,i.CancellationErrorCode[i.CancellationErrorCode.NoError])]),new a(s,e.errorDetails,c)}}t.SpeakerRecognitionCancellationDetails=a})(Mn)),Mn}var On={},le={},tc;function Jp(){if(tc)return le;
18tc=1,Object.defineProperty(le,"__esModule",{value:!0}),le.ConversationImpl=le.Conversation=void 0;const t=E(),r=I(),i=T(),u=y();let o=class{constructor(){}static createConversationAsync(e,s,c,p){i.Contracts.throwIfNullOrUndefined(e,t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),i.Contracts.throwIfNullOrUndefined(e.region,t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),!e.subscriptionKey&&!e.getProperty(u.PropertyId[u.PropertyId.SpeechServiceAuthorization_Token])&&i.Contracts.throwIfNullOrUndefined(e.subscriptionKey,t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let d,h,l;return typeof s=="string"?(d=new a(e,s),r.marshalPromiseToCallbacks((async()=>{})(),c,p)):(d=new a(e),h=s,l=c,d.createConversationAsync((()=>{h&&h()}),v=>{l&&l(v)})),d}};le.Conversation=o;class a extends o{constructor(e,s){if(super(),this.privErrors=t.ConversationConnectionConfig.restErrors,this.onConnected=d=>{var h;this.privIsConnected=!0;try{(h=this.privConversationTranslator)!=null&&h.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,d)}catch{}},this.onDisconnected=d=>{var h;try{(h=this.privConversationTranslator)!=null&&h.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,d)}catch{}finally{this.close(!1)}},this.onCanceled=(d,h)=>{var l;try{(l=this.privConversationTranslator)!=null&&l.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,h)}catch{}},this.onParticipantUpdateCommandReceived=(d,h)=>{try{const l=this.privParticipants.getParticipant(h.id);if(l!==void 0){switch(h.key){case t.ConversationTranslatorCommandTypes.changeNickname:l.displayName=h.value;break;case t.ConversationTranslatorCommandTypes.setUseTTS:l.isUsingTts=h.value;break;case t.ConversationTranslatorCommandTypes.setProfanityFiltering:l.profanity=h.value;break;case t.ConversationTranslatorCommandTypes.setMute:l.isMuted=h.value;break;case t.ConversationTranslatorCommandTypes.setTranslateToLanguages:l.translateToLanguages=h.value;break}this.privParticipants.addOrUpdateParticipant(l),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.Updated,[this.toParticipant(l)],h.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(d,h)=>
18{try{this.privParticipants.participants.forEach(l=>l.isMuted=l.isHost?!1:h.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.Updated,this.toParticipants(!1),h.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(d,h)=>{try{const l=this.privParticipants.addOrUpdateParticipant(h.participant);l!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.JoinedConversation,[this.toParticipant(l)],h.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(d,h)=>{try{const l=this.privParticipants.getParticipant(h.participant.id);l!==void 0&&(this.privParticipants.deleteParticipant(h.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.LeftConversation,[this.toParticipant(l)],h.sessionId)))}catch{}},this.onTranslationReceived=(d,h)=>{try{switch(h.command){case t.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new u.ConversationTranslationEventArgs(h.payload,void 0,h.sessionId));break;case t.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new u.ConversationTranslationEventArgs(h.payload,void 0,h.sessionId));break;case t.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new u.ConversationTranslationEventArgs(h.payload,void 0,h.sessionId));break}}catch{}},this.onParticipantsListReceived=(d,h)=>{var l;try{if(h.sessionToken!==void 0&&h.sessionToken!==null&&(this.privRoom.token=h.sessionToken),this.privParticipants.participants=[...h.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),h.sessionId)),this.me.isHost){const v=(l=this.privConversationTranslator)==null?void 0:l.properties.getProperty(u.PropertyId.ConversationTranslator_Name);v!==void 0&&v.length>0&&v!==this.me.displayName&&this.changeNicknameAsync(v)}}catch{}},this.onConversationExpiration=(d,h)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,h)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new u.PropertyCollection,this.privManager=new t.ConversationManager,e.getProperty(u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage],t.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage]),s)this.privConversationId=s;else{e.targetLanguages.length===0&&e.addTargetLanguage(this.privLanguage),e.getProperty(u.PropertyId[u.PropertyId.SpeechServiceResponse_ProfanityOption])||e.setProfanity(u.ProfanityOption.Masked);let h=e.getProperty(u.PropertyId[u.PropertyId.ConversationTranslator_Name]);h==null&&(h="Host"),i.Contracts.throwIfNullOrTooLong(h,"nickname",50),i.Contracts.throwIfNullOrTooShort(h,"nickname",2),e.setProperty(u.PropertyId[u.PropertyId.ConversationTranslator_Name],h)}this.privConfig=e;const p=e;i.Contracts.throwIfNull(p,"speechConfig"),this.privProperties=p.properties.clone(),this.privIsConnected=!1,this.privParticipants=new t.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(){var e,s;
18return(e=this.privParticipants.me)!=null&&e.isHost?!1:(s=this.privParticipants.me)==null?void 0:s.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get conversationInfo(){const e=this.conversationId,s=this.participants.map(d=>({id:d.id,preferredLanguage:d.preferredLanguage,voice:d.voice})),c={};for(const d of t.ConversationConnectionConfig.transcriptionEventKeys){const h=this.properties.getProperty(d,"");h!==""&&(c[d]=h)}return{id:e,participants:s,conversationProperties:c}}get canSend(){var e;return this.privIsConnected&&!((e=this.privParticipants.me)!=null&&e.isMuted)}get canSendAsHost(){var e;return this.privIsConnected&&((e=this.privParticipants.me)==null?void 0:e.isHost)}get authorizationToken(){return this.privToken}set authorizationToken(e){i.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}set conversationTranslator(e){this.privConversationTranslator=e}onToken(e){this.privConversationTranslator.onToken(e)}createConversationAsync(e,s){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),s),this.privManager.createOrJoin(this.privProperties,void 0,(c=>{c||this.handleError(new Error(this.privErrors.permissionDeniedConnect),s),this.privRoom=c,this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}startConversationAsync(e,s){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),s),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer=t.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,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}addParticipantAsync(e,s,c){i.Contracts.throwIfNullOrUndefined(e,"Participant"),r.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),s,c)}joinConversationAsync(e,s,c,p,d){try{i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),i.Contracts.throwIfNullOrWhitespace(s,this.privErrors.invalidArgs.replace("{arg}","nickname")),i.Contracts.throwIfNullOrWhitespace(c,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,(h=>{i.Contracts.throwIfNullOrUndefined(h,this.privErrors.permissionDeniedConnect),this.privRoom=h,this.privConfig.authorizationToken=h.cognitiveSpeechAuthToken,p&&p(h.cognitiveSpeechAuthToken)}),(h=>{this.handleError(h,d)}))}catch(h){this.handleError(h,d)}}deleteConversationAsync(e,s){r.marshalPromiseToCallbacks(this.deleteConversationImplAsync(),e,s)}async deleteConversationImplAsync(){i.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),i.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endConversationAsync(e,s){r.marshalPromiseToCallbacks(this.endConversationImplAsync(),e,s)}endConversationImplAsync(){return this.close(!0)}lockConversationAsync(e,s){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),s),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),(()=>{this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}muteAllParticipantsAsync(e,s){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),s),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),(()=>{this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}muteParticipantAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),c),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),(()=>{this.handleCallback(s,c)}),(d=>{this.handleError(d,c)}))}catch(p){this.handleError(p,c)}}removeParticipantAsync(e,s,c){try{if(i.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))r.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),s,c);else{i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),c);let p="";
18typeof e=="string"?p=e:e.hasOwnProperty("id")?p=e.id:e.hasOwnProperty("userId")&&(p=e.userId),i.Contracts.throwIfNullOrWhitespace(p,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(h=>h.id===p)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(p),(()=>{this.handleCallback(s,c)}),(h=>{this.handleError(h,c)}))}}catch(p){this.handleError(p,c)}}unlockConversationAsync(e,s){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),s),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),(()=>{this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}unmuteAllParticipantsAsync(e,s){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),s),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),(()=>{this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}unmuteParticipantAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),c),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),(()=>{this.handleCallback(s,c)}),(d=>{this.handleError(d,c)}))}catch(p){this.handleError(p,c)}}sendTextMessageAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),(()=>{this.handleCallback(s,c)}),(p=>{this.handleError(p,c)}))}catch(p){this.handleError(p,c)}}setTranslatedLanguagesAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),(()=>{this.handleCallback(s,c)}),(p=>{this.handleError(p,c)}))}catch(p){this.handleError(p,c)}}changeNicknameAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),(()=>{this.handleCallback(s,c)}),(p=>{this.handleError(p,c)}))}catch(p){this.handleError(p,c)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),this.privConfig=void 0,this.privLanguage=void 0,this.privProperties=void 0,this.privRoom=void 0,this.privToken=void 0,this.privManager=void 0,this.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.conversation=this}getKeepAlive(){const e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){const c=this.conversationInfo;return c.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(c,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);const s=this.conversationInfo;return s.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(s,"leave")}async close(e){var s;try{this.privIsConnected=!1,await((s=this.privConversationRecognizer)==null?void 0:s.close()),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(c){throw c}e&&this.dispose()}handleCallback(e,s){if(e){try{e()}catch(c){s&&s(c)}e=void 0}}handleError(e,s){if(s)if(e instanceof Error){const c=e;s(c.name+": "+c.message)}else s(e)}toParticipants(e){const s=this.privParticipants.participants.map(c=>this.toParticipant(c));return e?s:s.filter(c=>c.isHost===!1)}toParticipant(e){return new u.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:e})}
18getMuteCommand(e,s){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),i.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:s})}getLockCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),i.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),i.Contracts.throwIfNullOrWhitespace(e,"nickname"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),i.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:t.ConversationTranslatorMessageTypes.instantMessage})}}return le.ConversationImpl=a,le}var pr={},rc;function Tv(){if(rc)return pr;rc=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.ConversationCommon=void 0;let t=class{constructor(i){this.privAudioConfig=i}handleCallback(i,u){if(i){try{i()}catch(o){u&&u(o)}i=void 0}}handleError(i,u){if(u)if(i instanceof Error){const o=i;u(o.name+": "+o.message)}else u(i)}};return pr.ConversationCommon=t,pr}var dr={},ic;function Av(){if(ic)return dr;ic=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.ConversationExpirationEventArgs=void 0;const t=y();let r=class extends t.SessionEventArgs{constructor(u,o){super(o),this.privExpirationTime=u}get expirationTime(){return this.privExpirationTime}};return dr.ConversationExpirationEventArgs=r,dr}var hr={},nc;function wv(){if(nc)return hr;nc=1,Object.defineProperty(hr,"__esModule",{value:!0}),hr.ConversationParticipantsChangedEventArgs=void 0;const t=y();let r=class extends t.SessionEventArgs{constructor(u,o,a){super(a),this.privReason=u,this.privParticipant=o}get reason(){return this.privReason}get participants(){return this.privParticipant}};return hr.ConversationParticipantsChangedEventArgs=r,hr}var lr={},sc;function _v(){if(sc)return lr;sc=1,Object.defineProperty(lr,"__esModule",{value:!0}),lr.ConversationTranslationCanceledEventArgs=void 0;const t=xi();let r=class extends t.CancellationEventArgsBase{};return lr.ConversationTranslationCanceledEventArgs=r,lr}var vr={},oc;function bv(){if(oc)return vr;oc=1,Object.defineProperty(vr,"__esModule",{value:!0}),vr.ConversationTranslationEventArgs=void 0;const t=y();let r=class extends t.RecognitionEventArgs{constructor(u,o,a){super(o,a),this.privResult=u}get result(){return this.privResult}};return vr.ConversationTranslationEventArgs=r,vr}var fr={},ac;function Mv(){if(ac)return fr;
18ac=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.ConversationTranslationResult=void 0;const t=Dp();let r=class extends t.TranslationRecognitionResult{constructor(u,o,a,n,e,s,c,p,d,h,l){super(o,n,e,s,c,p,void 0,void 0,d,h,l),this.privId=u,this.privOrigLang=a}get participantId(){return this.privId}get originalLang(){return this.privOrigLang}};return fr.ConversationTranslationResult=r,fr}var Dn={},gr={},mr={},cc;function Gp(){if(cc)return mr;cc=1,Object.defineProperty(mr,"__esModule",{value:!0}),mr.StringUtils=void 0;let t=class{static formatString(i,u){if(!i)return"";if(!u)return i;let o="",a="";const n=c=>{o+=c},e=c=>{a+=c};let s=n;for(let c=0;c<i.length;c++){const p=i[c],d=c+1<i.length?i[c+1]:"";switch(p){case"{":d==="{"?(s("{"),c++):s=e;break;case"}":d==="}"?(s("}"),c++):(u.hasOwnProperty(a)&&(o+=u[a]),s=n,a="");break;default:s(p);break}}return o}};return mr.StringUtils=t,mr}var uc;function Ov(){if(uc)return gr;uc=1,Object.defineProperty(gr,"__esModule",{value:!0}),gr.ConversationTranslatorConnectionFactory=void 0;const t=D(),r=Gp(),i=T(),u=y(),o=N(),a=Y(),n=H(),e=E();let s=class Qp extends n.ConnectionFactoryBase{constructor(p){super(),i.Contracts.throwIfNullOrUndefined(p,"convGetter"),this.privConvGetter=p}create(p,d,h){const l=p.parameters.getProperty("ConversationTranslator_MultiChannelAudio","").toUpperCase()==="TRUE",v=this.privConvGetter().room,f=v.cognitiveSpeechRegion||p.parameters.getProperty(u.PropertyId.SpeechServiceConnection_Region,""),g={hostSuffix:n.ConnectionFactoryBase.getHostSuffix(f),path:Qp.CTS_VIRT_MIC_PATH,region:encodeURIComponent(f)};g[a.QueryParameterNames.Language]=encodeURIComponent(p.parameters.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage,"")),g[a.QueryParameterNames.CtsMeetingId]=encodeURIComponent(v.roomId),g[a.QueryParameterNames.CtsDeviceId]=encodeURIComponent(v.participantId),g[a.QueryParameterNames.CtsIsParticipant]=v.isHost?"":"&"+a.QueryParameterNames.CtsIsParticipant;let m="";const S={},C={};if(l){m=p.parameters.getProperty(u.PropertyId.SpeechServiceConnection_Endpoint),m||(m="wss://"+p.parameters.getProperty(u.PropertyId.SpeechServiceConnection_Host,"transcribe.{region}.cts.speech{hostSuffix}")+"{path}"),m=r.StringUtils.formatString(m,g);const P=new URL(m);P.searchParams.forEach((M,_)=>{S[_]=M}),new e.TranscriberConnectionFactory().setQueryParams(S,p,m),S[a.QueryParameterNames.CtsMeetingId]=g[a.QueryParameterNames.CtsMeetingId],S[a.QueryParameterNames.CtsDeviceId]=g[a.QueryParameterNames.CtsDeviceId],v.isHost||(S[a.QueryParameterNames.CtsIsParticipant]=""),a.QueryParameterNames.Format in S||(S[a.QueryParameterNames.Format]="simple"),P.searchParams.forEach((M,_)=>{P.searchParams.set(_,S[_]),delete S[_]}),m=P.toString()}else{const P=new e.TranslationConnectionFactory;m=P.getEndpointUrl(p,!0),m=r.StringUtils.formatString(m,g),P.setQueryParams(S,p,m)}C[o.HeaderNames.ConnectionId]=h,C[t.RestConfigBase.configParams.token]=v.token,d.token&&(C[d.headerName]=d.token);const R=p.parameters.getProperty("SPEECH-EnableWebsocketCompression","").toUpperCase()==="TRUE";return new t.WebsocketConnection(m,S,C,new e.WebsocketMessageFormatter,t.ProxyInfo.fromRecognizerConfig(p),R,h)}};return gr.ConversationTranslatorConnectionFactory=s,s.CTS_VIRT_MIC_PATH="/speech/recognition/dynamicaudio",gr}var pc;function Dv(){return pc||(pc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranslator=t.SpeechState=void 0;const r=E(),i=Ov(),u=I(),o=T(),a=y(),n=Jp(),e=hs();var s;(function(d){d[d.Inactive=0]="Inactive",d[d.Connecting=1]="Connecting",d[d.Connected=2]="Connected"})(s=t.SpeechState||(t.SpeechState={}));class c extends a.TranslationRecognizer{constructor(h,l,v,f){super(h,l,new i.ConversationTranslatorConnectionFactory(f)),this.privSpeechState=s.Inactive,v&&(this.privTranslator=v,this.sessionStarted=()=>{this.privSpeechState=s.Connected},this.sessionStopped=()=>{this.privSpeechState=s.Inactive},this.recognizing=(g,m)=>{this.privTranslator.recognizing&&this.privTranslator.recognizing(this.privTranslator,m)},this.recognized=async(g,m)=>{var S;(S=m.result)!=null&&S.errorDetails?(await this.cancelSpeech(),this.fireCancelEvent(m.result.errorDetails)):this.privTranslator.recognized&&this.privTranslator.recognized(this.privTranslator,m)},this.canceled=async()=>
18{if(this.privSpeechState!==s.Inactive)try{await this.cancelSpeech()}catch{this.privSpeechState=s.Inactive}})}get state(){return this.privSpeechState}set state(h){this.privSpeechState=h}set authentication(h){this.privReco.authentication=h}onConnection(){this.privSpeechState=s.Connected}async onCancelSpeech(){this.privSpeechState=s.Inactive,await this.cancelSpeech()}fireCancelEvent(h){try{if(this.privTranslator.canceled){const l=new e.ConversationTranslationCanceledEventArgs(a.CancellationReason.Error,h,a.CancellationErrorCode.RuntimeError);this.privTranslator.canceled(this.privTranslator,l)}}catch{}}async cancelSpeech(){var h;try{this.stopContinuousRecognitionAsync(),await((h=this.privReco)==null?void 0:h.disconnect()),this.privSpeechState=s.Inactive}catch{}}}class p extends e.ConversationCommon{constructor(h){super(h),this.privErrors=r.ConversationConnectionConfig.restErrors,this.privIsDisposed=!1,this.privIsSpeaking=!1,this.privPlaceholderKey="abcdefghijklmnopqrstuvwxyz012345",this.privPlaceholderRegion="westus",this.privProperties=new a.PropertyCollection}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get participants(){var h;return(h=this.privConversation)==null?void 0:h.participants}get canSpeak(){return!(!this.privConversation.isConnected||!this.privCTRecognizer||this.privIsSpeaking||this.privCTRecognizer.state===s.Connected||this.privCTRecognizer.state===s.Connecting||this.privConversation.isMutedByHost)}onToken(h){this.privCTRecognizer.authentication=h}setServiceProperty(h,l){const v=JSON.parse(this.privProperties.getProperty(r.ServicePropertiesPropertyName,"{}"));v[h]=l,this.privProperties.setProperty(r.ServicePropertiesPropertyName,JSON.stringify(v))}joinConversationAsync(h,l,v,f,g){try{if(typeof h=="string"){o.Contracts.throwIfNullOrUndefined(h,this.privErrors.invalidArgs.replace("{arg}","conversation id")),o.Contracts.throwIfNullOrWhitespace(l,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privConversation&&this.handleError(new Error(this.privErrors.permissionDeniedStart),g);let m=v;(m==null||m==="")&&(m=r.ConversationConnectionConfig.defaultLanguageCode),this.privSpeechTranslationConfig=a.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey,this.privPlaceholderRegion),this.privSpeechTranslationConfig.setProfanity(a.ProfanityOption.Masked),this.privSpeechTranslationConfig.addTargetLanguage(m),this.privSpeechTranslationConfig.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_RecoLanguage],m),this.privSpeechTranslationConfig.setProperty(a.PropertyId[a.PropertyId.ConversationTranslator_Name],l);const S=[a.PropertyId.SpeechServiceConnection_Host,a.PropertyId.ConversationTranslator_Host,a.PropertyId.SpeechServiceConnection_Endpoint,a.PropertyId.SpeechServiceConnection_ProxyHostName,a.PropertyId.SpeechServiceConnection_ProxyPassword,a.PropertyId.SpeechServiceConnection_ProxyPort,a.PropertyId.SpeechServiceConnection_ProxyUserName,"ConversationTranslator_MultiChannelAudio","ConversationTranslator_Region"];for(const R of S){const P=this.privProperties.getProperty(R);if(P){const A=typeof R=="string"?R:a.PropertyId[R];this.privSpeechTranslationConfig.setProperty(A,P)}}const C=JSON.parse(this.privProperties.getProperty(r.ServicePropertiesPropertyName,"{}"));for(const R of Object.keys(C))this.privSpeechTranslationConfig.setServiceProperty(R,C[R],a.ServicePropertyChannel.UriQueryParameter);this.privConversation=new n.ConversationImpl(this.privSpeechTranslationConfig),this.privConversation.conversationTranslator=this,this.privConversation.joinConversationAsync(h,l,m,(R=>{R||this.handleError(new Error(this.privErrors.permissionDeniedConnect),g),this.privSpeechTranslationConfig.authorizationToken=R,this.privConversation.room.isHost=!1,this.privConversation.startConversationAsync((()=>{this.handleCallback(f,g)}),(P=>{this.handleError(P,g)}))}),(R=>{this.handleError(R,g)}))}else typeof h=="object"?(o.Contracts.throwIfNullOrUndefined(h,this.privErrors.invalidArgs.replace("{arg}","conversation id")),o.Contracts.throwIfNullOrWhitespace(l,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privProperties.setProperty(a.PropertyId.ConversationTranslator_Name,l),this.privConversation=h,this.privConversation.conversationTranslator=this,this.privConversation.room.isHost=!0,o.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedConnect),o.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privSpeechTranslationConfig=h.config,this.handleCallback(v,f)):this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}
18","invalid conversation type")),f)}catch(m){this.handleError(m,typeof v=="string"?g:f)}}leaveConversationAsync(h,l){u.marshalPromiseToCallbacks((async()=>{await this.cancelSpeech(),await this.privConversation.endConversationImplAsync(),await this.privConversation.deleteConversationImplAsync(),this.dispose()})(),h,l)}sendTextMessageAsync(h,l,v){try{o.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),o.Contracts.throwIfNullOrWhitespace(h,this.privErrors.invalidArgs.replace("{arg}",h)),this.privConversation.sendTextMessageAsync(h,l,v)}catch(f){this.handleError(f,v)}}startTranscribingAsync(h,l){u.marshalPromiseToCallbacks((async()=>{try{o.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),o.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privCTRecognizer===void 0&&await this.connectTranslatorRecognizer(),o.Contracts.throwIfNullOrUndefined(this.privCTRecognizer,this.privErrors.permissionDeniedSend),this.canSpeak||this.handleError(new Error(this.privErrors.permissionDeniedSend),l),await this.startContinuousRecognition(),this.privIsSpeaking=!0}catch(v){throw this.privIsSpeaking=!1,await this.cancelSpeech(),v}})(),h,l)}stopTranscribingAsync(h,l){u.marshalPromiseToCallbacks((async()=>{try{if(!this.privIsSpeaking){await this.cancelSpeech();return}this.privIsSpeaking=!1,await new Promise((v,f)=>{this.privCTRecognizer.stopContinuousRecognitionAsync(v,f)})}catch{await this.cancelSpeech()}})(),h,l)}isDisposed(){return this.privIsDisposed}dispose(h,l,v){u.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)})(),l,v)}async cancelSpeech(){var h;try{this.privIsSpeaking=!1,await((h=this.privCTRecognizer)==null?void 0:h.onCancelSpeech()),this.privCTRecognizer=void 0}catch{}}async connectTranslatorRecognizer(){try{this.privAudioConfig===void 0&&(this.privAudioConfig=a.AudioConfig.fromDefaultMicrophoneInput()),this.privSpeechTranslationConfig.getProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_Key])===this.privPlaceholderKey&&this.privSpeechTranslationConfig.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_Key],"");const h=()=>this.privConversation;this.privCTRecognizer=new c(this.privSpeechTranslationConfig,this.privAudioConfig,this,h)}catch(h){throw await this.cancelSpeech(),h}}startContinuousRecognition(){return new Promise((h,l)=>{this.privCTRecognizer.startContinuousRecognitionAsync(h,l)})}}t.ConversationTranslator=p})(Dn)),Dn}var Sr={},dc;function kv(){if(dc)return Sr;
18dc=1,Object.defineProperty(Sr,"__esModule",{value:!0}),Sr.ConversationTranscriber=void 0;const t=E(),r=I(),i=T(),u=y();let o=class Xp extends u.Recognizer{constructor(n,e){const s=n;i.Contracts.throwIfNull(s,"speechConfig"),i.Contracts.throwIfNullOrWhitespace(s.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage),u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage]),super(e,s.properties,new t.ConversationTranscriberConnectionFactory),this.privProperties.setProperty(u.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privDisposedRecognizer=!1}static FromConfig(n,e,s){const c=n;return e.properties.mergeTo(c.properties),new Xp(n,s)}get endpointId(){return i.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(u.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(n){i.Contracts.throwIfNullOrWhitespace(n,"token"),this.properties.setProperty(u.PropertyId.SpeechServiceAuthorization_Token,n)}get speechRecognitionLanguage(){return i.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return i.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(t.OutputFormatPropertyName,u.OutputFormat[u.OutputFormat.Simple])===u.OutputFormat[u.OutputFormat.Simple]?u.OutputFormat.Simple:u.OutputFormat.Detailed}get properties(){return this.privProperties}startTranscribingAsync(n,e){r.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(t.RecognitionMode.Conversation),n,e)}stopTranscribingAsync(n,e){r.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),n,e)}close(n,e){i.Contracts.throwIfDisposed(this.privDisposedRecognizer),r.marshalPromiseToCallbacks(this.dispose(!0),n,e)}async dispose(n){this.privDisposedRecognizer||(n&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(n))}createRecognizerConfig(n){return new t.RecognizerConfig(n,this.privProperties)}createServiceRecognizer(n,e,s,c){const p=s;return c.isSpeakerDiarizationEnabled=!0,new t.ConversationTranscriptionServiceRecognizer(n,e,p,c,this)}};return Sr.ConversationTranscriber=o,Sr}var ve={},hc;function Nv(){if(hc)return ve;
18hc=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.Participant=ve.User=void 0;const t=y();class r{constructor(o){this.privUserId=o}get userId(){return this.privUserId}}ve.User=r;class i{constructor(o,a,n,e,s,c,p,d){this.privId=o,this.privAvatar=a,this.privDisplayName=n,this.privIsHost=e,this.privIsMuted=s,this.privIsUsingTts=c,this.privPreferredLanguage=p,this.privVoice=d,this.privProperties=new t.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(o,a,n){return new i(o,"",o,!1,!1,!1,a,n)}}return ve.Participant=i,ve}var kn={},lc;function zv(){return lc||(lc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ParticipantChangedReason=void 0,(function(r){r[r.JoinedConversation=0]="JoinedConversation",r[r.LeftConversation=1]="LeftConversation",r[r.Updated=2]="Updated"})(t.ParticipantChangedReason||(t.ParticipantChangedReason={}))})(kn)),kn}var fe={},vc;function jv(){if(vc)return fe;vc=1,Object.defineProperty(fe,"__esModule",{value:!0}),fe.MeetingImpl=fe.Meeting=void 0;const t=E(),r=I(),i=T(),u=y();let o=class{constructor(){}static createMeetingAsync(e,s,c,p){if(i.Contracts.throwIfNullOrUndefined(e,t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),i.Contracts.throwIfNullOrUndefined(e.region,t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),i.Contracts.throwIfNull(s,"meetingId"),s.length===0)throw new Error("meetingId cannot be empty");!e.subscriptionKey&&!e.getProperty(u.PropertyId[u.PropertyId.SpeechServiceAuthorization_Token])&&i.Contracts.throwIfNullOrUndefined(e.subscriptionKey,t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));const d=new a(e,s);return r.marshalPromiseToCallbacks((async()=>{})(),c,p),d}};fe.Meeting=o;class a extends o{constructor(e,s){super(),this.privErrors=t.ConversationConnectionConfig.restErrors,this.onConnected=d=>{var h;this.privIsConnected=!0;try{(h=this.privConversationTranslator)!=null&&h.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,d)}catch{}},this.onDisconnected=d=>{var h;try{(h=this.privConversationTranslator)!=null&&h.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,d)}catch{}finally{this.close(!1)}},this.onCanceled=(d,h)=>{var l;try{(l=this.privConversationTranslator)!=null&&l.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,h)}catch{}},this.onParticipantUpdateCommandReceived=(d,h)=>{try{const l=this.privParticipants.getParticipant(h.id);if(l!==void 0){switch(h.key){case t.ConversationTranslatorCommandTypes.changeNickname:l.displayName=h.value;break;case t.ConversationTranslatorCommandTypes.setUseTTS:l.isUsingTts=h.value;break;case t.ConversationTranslatorCommandTypes.setProfanityFiltering:l.profanity=h.value;break;case t.ConversationTranslatorCommandTypes.setMute:l.isMuted=h.value;break;case t.ConversationTranslatorCommandTypes.setTranslateToLanguages:l.translateToLanguages=h.value;break}this.privParticipants.addOrUpdateParticipant(l),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.Updated,[this.toParticipant(l)],h.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(d,h)=>
18{try{this.privParticipants.participants.forEach(l=>l.isMuted=l.isHost?!1:h.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.Updated,this.toParticipants(!1),h.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(d,h)=>{try{const l=this.privParticipants.addOrUpdateParticipant(h.participant);l!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.JoinedConversation,[this.toParticipant(l)],h.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(d,h)=>{try{const l=this.privParticipants.getParticipant(h.participant.id);l!==void 0&&(this.privParticipants.deleteParticipant(h.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.LeftConversation,[this.toParticipant(l)],h.sessionId)))}catch{}},this.onTranslationReceived=(d,h)=>{try{switch(h.command){case t.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new u.ConversationTranslationEventArgs(h.payload,void 0,h.sessionId));break;case t.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new u.ConversationTranslationEventArgs(h.payload,void 0,h.sessionId));break;case t.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new u.ConversationTranslationEventArgs(h.payload,void 0,h.sessionId));break}}catch{}},this.onParticipantsListReceived=(d,h)=>{var l;try{if(h.sessionToken!==void 0&&h.sessionToken!==null&&(this.privRoom.token=h.sessionToken),this.privParticipants.participants=[...h.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new u.ConversationParticipantsChangedEventArgs(u.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),h.sessionId)),this.me.isHost){const v=(l=this.privConversationTranslator)==null?void 0:l.properties.getProperty(u.PropertyId.ConversationTranslator_Name);v!==void 0&&v.length>0&&v!==this.me.displayName&&this.changeNicknameAsync(v)}}catch{}},this.onConversationExpiration=(d,h)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,h)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new u.PropertyCollection,this.privManager=new t.ConversationManager,e.getProperty(u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage],t.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(u.PropertyId[u.PropertyId.SpeechServiceConnection_RecoLanguage]),this.privConversationId=s,this.privConfig=e;const p=e;i.Contracts.throwIfNull(p,"speechConfig"),this.privProperties=p.properties.clone(),this.privIsConnected=!1,this.privParticipants=new t.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(){var e,s;return(e=this.privParticipants.me)!=null&&e.isHost?!1:(s=this.privParticipants.me)==null?void 0:s.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get meetingInfo(){const e=this.meetingId,s=this.participants.map(d=>({id:d.id,preferredLanguage:d.preferredLanguage,voice:d.voice})),c={};for(const d of t.ConversationConnectionConfig.transcriptionEventKeys){const h=this.properties.getProperty(d,"");h!==""&&(c[d]=h)}return{id:e,participants:s,meetingProperties:c}}get canSend(){var e;return this.privIsConnected&&!((e=this.privParticipants.me)!=null&&e.isMuted)}get canSendAsHost(){var e;return this.privIsConnected&&((e=this.privParticipants.me)==null?void 0:e.isHost)}get authorizationToken(){return this.privToken}set authorizationToken(e){i.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}createMeetingAsync(e,s){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),s),this.privManager.createOrJoin(this.privProperties,void 0,(c=>{c||this.handleError(new Error(this.privErrors.permissionDeniedConnect),s),this.privRoom=c,this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}startMeetingAsync(e,s){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),s),i.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,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}addParticipantAsync(e,s,c){i.Contracts.throwIfNullOrUndefined(e,"Participant"),r.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),s,c)}joinMeetingAsync(e,s,c,p,d){try{i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),i.Contracts.throwIfNullOrWhitespace(s,this.privErrors.invalidArgs.replace("{arg}","nickname")),i.Contracts.throwIfNullOrWhitespace(c,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,(h=>{i.Contracts.throwIfNullOrUndefined(h,this.privErrors.permissionDeniedConnect),this.privRoom=h,this.privConfig.authorizationToken=h.cognitiveSpeechAuthToken,p&&p(h.cognitiveSpeechAuthToken)}),(h=>{this.handleError(h,d)}))}catch(h){this.handleError(h,d)}}deleteMeetingAsync(e,s){r.marshalPromiseToCallbacks(this.deleteMeetingImplAsync(),e,s)}async deleteMeetingImplAsync(){i.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),i.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endMeetingAsync(e,s){r.marshalPromiseToCallbacks(this.endMeetingImplAsync(),e,s)}endMeetingImplAsync(){return this.close(!0)}lockMeetingAsync(e,s){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),s),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),(()=>{this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}muteAllParticipantsAsync(e,s){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),s),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),(()=>{this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}muteParticipantAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),c),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),(()=>{this.handleCallback(s,c)}),(d=>{this.handleError(d,c)}))}catch(p){this.handleError(p,c)}}removeParticipantAsync(e,s,c){try{if(i.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))r.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),s,c);else{i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),c);let p="";
18typeof e=="string"?p=e:e.hasOwnProperty("id")?p=e.id:e.hasOwnProperty("userId")&&(p=e.userId),i.Contracts.throwIfNullOrWhitespace(p,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(h=>h.id===p)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(p),(()=>{this.handleCallback(s,c)}),(h=>{this.handleError(h,c)}))}}catch(p){this.handleError(p,c)}}unlockMeetingAsync(e,s){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),s),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),(()=>{this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}unmuteAllParticipantsAsync(e,s){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),s),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),(()=>{this.handleCallback(e,s)}),(c=>{this.handleError(c,s)}))}catch(c){this.handleError(c,s)}}unmuteParticipantAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),c),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),(()=>{this.handleCallback(s,c)}),(d=>{this.handleError(d,c)}))}catch(p){this.handleError(p,c)}}sendTextMessageAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),(()=>{this.handleCallback(s,c)}),(p=>{this.handleError(p,c)}))}catch(p){this.handleError(p,c)}}setTranslatedLanguagesAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),(()=>{this.handleCallback(s,c)}),(p=>{this.handleError(p,c)}))}catch(p){this.handleError(p,c)}}changeNicknameAsync(e,s,c){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),i.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),i.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),c),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),(()=>{this.handleCallback(s,c)}),(p=>{this.handleError(p,c)}))}catch(p){this.handleError(p,c)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),this.privConfig=void 0,this.privLanguage=void 0,this.privProperties=void 0,this.privRoom=void 0,this.privToken=void 0,this.privManager=void 0,this.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.meeting=this}getKeepAlive(){const e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){const c=this.meetingInfo;return c.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(c,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);const s=this.meetingInfo;return s.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(s,"leave")}async close(e){var s;try{this.privIsConnected=!1,await((s=this.privConversationRecognizer)==null?void 0:s.close()),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(c){throw c}e&&this.dispose()}handleCallback(e,s){if(e){try{e()}catch(c){s&&s(c)}e=void 0}}handleError(e,s){if(s)if(e instanceof Error){const c=e;s(c.name+": "+c.message)}else s(e)}toParticipants(e){const s=this.privParticipants.participants.map(c=>this.toParticipant(c));return e?s:s.filter(c=>c.isHost===!1)}toParticipant(e){return new u.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingd"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:e})}
18getMuteCommand(e,s){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),i.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:s})}getLockCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),i.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),i.Contracts.throwIfNullOrWhitespace(e,"nickname"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:t.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:t.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return i.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),i.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),i.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:t.ConversationTranslatorMessageTypes.instantMessage})}}return fe.MeetingImpl=a,fe}var Cr={},fc;function qv(){if(fc)return Cr;fc=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.MeetingTranscriptionCanceledEventArgs=void 0;const t=xi();class r extends t.CancellationEventArgsBase{}return Cr.MeetingTranscriptionCanceledEventArgs=r,Cr}var yr={},gc;function Lv(){if(gc)return yr;
18gc=1,Object.defineProperty(yr,"__esModule",{value:!0}),yr.MeetingTranscriber=void 0;const t=E(),r=I(),i=T(),u=y(),o=hs();let a=class{constructor(e){this.privAudioConfig=e,this.privProperties=new u.PropertyCollection,this.privRecognizer=void 0,this.privDisposedRecognizer=!1}get speechRecognitionLanguage(){return i.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(u.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get internalData(){return this.privRecognizer.internalData}get connection(){return u.Connection.fromRecognizer(this.privRecognizer)}get authorizationToken(){return this.properties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){i.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(u.PropertyId.SpeechServiceAuthorization_Token,e)}joinMeetingAsync(e,s,c){const p=e;i.Contracts.throwIfNullOrUndefined(o.MeetingImpl,"Meeting"),this.privRecognizer=new t.TranscriberRecognizer(e.config,this.privAudioConfig),i.Contracts.throwIfNullOrUndefined(this.privRecognizer,"Recognizer"),this.privRecognizer.connectMeetingCallbacks(this),r.marshalPromiseToCallbacks(p.connectTranscriberRecognizer(this.privRecognizer),s,c)}startTranscribingAsync(e,s){this.privRecognizer.startContinuousRecognitionAsync(e,s)}stopTranscribingAsync(e,s){this.privRecognizer.stopContinuousRecognitionAsync(e,s)}leaveMeetingAsync(e,s){this.privRecognizer.disconnectCallbacks(),r.marshalPromiseToCallbacks((async()=>{})(),e,s)}close(e,s){i.Contracts.throwIfDisposed(this.privDisposedRecognizer),r.marshalPromiseToCallbacks(this.dispose(!0),e,s)}async dispose(e){this.privDisposedRecognizer||(this.privRecognizer&&(await this.privRecognizer.close(),this.privRecognizer=void 0),e&&(this.privDisposedRecognizer=!0))}};return yr.MeetingTranscriber=a,yr}var Rr={},mc;function Bv(){if(mc)return Rr;mc=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.ConversationTranscriptionResult=void 0;const t=y();let r=class extends t.RecognitionResult{constructor(u,o,a,n,e,s,c,p,d,h,l){super(u,o,a,n,e,s,c,d,h,l),this.privSpeakerId=p}get speakerId(){return this.privSpeakerId}};return Rr.ConversationTranscriptionResult=r,Rr}var Sc;function hs(){return Sc||(Sc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});var r=Jp();Object.defineProperty(t,"Conversation",{enumerable:!0,get:function(){return r.Conversation}}),Object.defineProperty(t,"ConversationImpl",{enumerable:!0,get:function(){return r.ConversationImpl}});var i=Tv();Object.defineProperty(t,"ConversationCommon",{enumerable:!0,get:function(){return i.ConversationCommon}});var u=Av();Object.defineProperty(t,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return u.ConversationExpirationEventArgs}});var o=wv();Object.defineProperty(t,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return o.ConversationParticipantsChangedEventArgs}});var a=_v();Object.defineProperty(t,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return a.ConversationTranslationCanceledEventArgs}});var n=bv();Object.defineProperty(t,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return n.ConversationTranslationEventArgs}});var e=Mv();Object.defineProperty(t,"ConversationTranslationResult",{enumerable:!0,get:function(){return e.ConversationTranslationResult}});var s=Dv();Object.defineProperty(t,"ConversationTranslator",{enumerable:!0,get:function(){return s.ConversationTranslator}});var c=kv();Object.defineProperty(t,"ConversationTranscriber",{enumerable:!0,get:function(){return c.ConversationTranscriber}});var p=Nv();Object.defineProperty(t,"Participant",{enumerable:!0,get:function(){return p.Participant}}),Object.defineProperty(t,"User",{enumerable:!0,get:function(){return p.User}});var d=zv();Object.defineProperty(t,"ParticipantChangedReason",{enumerable:!0,get:function(){return d.ParticipantChangedReason}});var h=jv();Object.defineProperty(t,"Meeting",{enumerable:!0,get:function(){return h.Meeting}}),Object.defineProperty(t,"MeetingImpl",{enumerable:!0,get:function(){return h.MeetingImpl}});var l=qv();Object.defineProperty(t,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return l.MeetingTranscriptionCanceledEventArgs}});var v=Lv();Object.defineProperty(t,"MeetingTranscriber",{enumerable:!0,get:function(){return v.MeetingTranscriber}});var f=Bv();Object.defineProperty(t,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return f.ConversationTranscriptionResult}})})(On)),On}var ge={},Cc;function ls(){if(Cc)return ge;
18Cc=1,Object.defineProperty(ge,"__esModule",{value:!0}),ge.SynthesisRequest=ge.Synthesizer=void 0;const t=E(),r=I(),i=T(),u=y();let o=class Zp{constructor(e){const s=e;i.Contracts.throwIfNull(s,"speechConfig"),this.privProperties=s.properties.clone(),this.privDisposed=!1,this.privSynthesizing=!1,this.synthesisRequestQueue=new r.Queue}get authorizationToken(){return this.properties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){i.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(u.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get autoDetectSourceLanguage(){return this.properties.getProperty(u.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)===t.AutoDetectSourceLanguagesOpenRangeOptionName}buildSsml(e){const s={"af-ZA":"af-ZA-AdriNeural","am-ET":"am-ET-AmehaNeural","ar-AE":"ar-AE-FatimaNeural","ar-BH":"ar-BH-AliNeural","ar-DZ":"ar-DZ-AminaNeural","ar-EG":"ar-EG-SalmaNeural","ar-IQ":"ar-IQ-BasselNeural","ar-JO":"ar-JO-SanaNeural","ar-KW":"ar-KW-FahedNeural","ar-LY":"ar-LY-ImanNeural","ar-MA":"ar-MA-JamalNeural","ar-QA":"ar-QA-AmalNeural","ar-SA":"ar-SA-HamedNeural","ar-SY":"ar-SY-AmanyNeural","ar-TN":"ar-TN-HediNeural","ar-YE":"ar-YE-MaryamNeural","bg-BG":"bg-BG-BorislavNeural","bn-BD":"bn-BD-NabanitaNeural","bn-IN":"bn-IN-BashkarNeural","ca-ES":"ca-ES-JoanaNeural","cs-CZ":"cs-CZ-AntoninNeural","cy-GB":"cy-GB-AledNeural","da-DK":"da-DK-ChristelNeural","de-AT":"de-AT-IngridNeural","de-CH":"de-CH-JanNeural","de-DE":"de-DE-KatjaNeural","el-GR":"el-GR-AthinaNeural","en-AU":"en-AU-NatashaNeural","en-CA":"en-CA-ClaraNeural","en-GB":"en-GB-LibbyNeural","en-HK":"en-HK-SamNeural","en-IE":"en-IE-ConnorNeural","en-IN":"en-IN-NeerjaNeural","en-KE":"en-KE-AsiliaNeural","en-NG":"en-NG-AbeoNeural","en-NZ":"en-NZ-MitchellNeural","en-PH":"en-PH-JamesNeural","en-SG":"en-SG-LunaNeural","en-TZ":"en-TZ-ElimuNeural","en-US":"en-US-AvaMultilingualNeural","en-ZA":"en-ZA-LeahNeural","es-AR":"es-AR-ElenaNeural","es-BO":"es-BO-MarceloNeural","es-CL":"es-CL-CatalinaNeural","es-CO":"es-CO-GonzaloNeural","es-CR":"es-CR-JuanNeural","es-CU":"es-CU-BelkysNeural","es-DO":"es-DO-EmilioNeural","es-EC":"es-EC-AndreaNeural","es-ES":"es-ES-AlvaroNeural","es-GQ":"es-GQ-JavierNeural","es-GT":"es-GT-AndresNeural","es-HN":"es-HN-CarlosNeural","es-MX":"es-MX-DaliaNeural","es-NI":"es-NI-FedericoNeural","es-PA":"es-PA-MargaritaNeural","es-PE":"es-PE-AlexNeural","es-PR":"es-PR-KarinaNeural","es-PY":"es-PY-MarioNeural","es-SV":"es-SV-LorenaNeural","es-US":"es-US-AlonsoNeural","es-UY":"es-UY-MateoNeural","es-VE":"es-VE-PaolaNeural","et-EE":"et-EE-AnuNeural","fa-IR":"fa-IR-DilaraNeural","fi-FI":"fi-FI-SelmaNeural","fil-PH":"fil-PH-AngeloNeural","fr-BE":"fr-BE-CharlineNeural","fr-CA":"fr-CA-SylvieNeural","fr-CH":"fr-CH-ArianeNeural","fr-FR":"fr-FR-DeniseNeural","ga-IE":"ga-IE-ColmNeural","gl-ES":"gl-ES-RoiNeural","gu-IN":"gu-IN-DhwaniNeural","he-IL":"he-IL-AvriNeural","hi-IN":"hi-IN-MadhurNeural","hr-HR":"hr-HR-GabrijelaNeural","hu-HU":"hu-HU-NoemiNeural","id-ID":"id-ID-ArdiNeural","is-IS":"is-IS-GudrunNeural","it-IT":"it-IT-IsabellaNeural","ja-JP":"ja-JP-NanamiNeural","jv-ID":"jv-ID-DimasNeural","kk-KZ":"kk-KZ-AigulNeural","km-KH":"km-KH-PisethNeural","kn-IN":"kn-IN-GaganNeural","ko-KR":"ko-KR-SunHiNeural","lo-LA":"lo-LA-ChanthavongNeural","lt-LT":"lt-LT-LeonasNeural","lv-LV":"lv-LV-EveritaNeural","mk-MK":"mk-MK-AleksandarNeural","ml-IN":"ml-IN-MidhunNeural","mr-IN":"mr-IN-AarohiNeural","ms-MY":"ms-MY-OsmanNeural","mt-MT":"mt-MT-GraceNeural","my-MM":"my-MM-NilarNeural","nb-NO":"nb-NO-PernilleNeural","nl-BE":"nl-BE-ArnaudNeural","nl-NL":"nl-NL-ColetteNeural","pl-PL":"pl-PL-AgnieszkaNeural","ps-AF":"ps-AF-GulNawazNeural","pt-BR":"pt-BR-FranciscaNeural","pt-PT":"pt-PT-DuarteNeural","ro-RO":"ro-RO-AlinaNeural","ru-RU":"ru-RU-SvetlanaNeural","si-LK":"si-LK-SameeraNeural","sk-SK":"sk-SK-LukasNeural","sl-SI":"sl-SI-PetraNeural","so-SO":"so-SO-MuuseNeural","sr-RS":"sr-RS-NicholasNeural","su-ID":"su-ID-JajangNeural","sv-SE":"sv-SE-SofieNeural","sw-KE":"sw-KE-RafikiNeural","sw-TZ":"sw-TZ-DaudiNeural","ta-IN":"ta-IN-PallaviNeural","ta-LK":"ta-LK-KumarNeural","ta-SG":"ta-SG-AnbuNeural","te-IN":"te-IN-MohanNeural","th-TH":"th-TH-PremwadeeNeural","tr-TR":"tr-TR-AhmetNeural","uk-UA":"uk-UA-OstapNeural","ur-IN":"ur-IN-GulNeural","ur-PK":"ur-PK-AsadNeural","uz-UZ":"uz-UZ-MadinaNeural","vi-VN":"vi-VN-HoaiMyNeural","zh-CN":"zh-CN-XiaoxiaoNeural","zh-HK":"zh-HK-HiuMaanNeural","zh-TW":"zh-TW-HsiaoChenNeural","zu-ZA":"zu-ZA-ThandoNeural"};let c=this.properties.getProperty(u.PropertyId.SpeechServiceConnection_SynthLanguage,"en-US"),p=this.properties.getProperty(u.PropertyId.SpeechServiceConnection_SynthVoice,""),d=Zp.XMLEncode(e);return this.autoDetectSourceLanguage?c="en-US":p=p||s[c],p&&(d=`<voice name='${p}'>${d}</voice>`),d=`<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='${c}'>${d}</speak>`,d}async dispose(e){this.privDisposed||(e&&this.privAdapter&&await this.privAdapter.dispose(),this.privDisposed=!0)}async adapterSpeak(){if(!this.privDisposed&&!this.privSynthesizing){this.privSynthesizing=!0;const e=await this.synthesisRequestQueue.dequeue();return this.privAdapter.Speak(e.text,e.isSSML,e.requestId,e.cb,e.err,e.dataStream)}}createSynthesizerConfig(e){return new t.SynthesizerConfig(e,this.privProperties)}implCommonSynthesizeSetup(){let e=typeof window<"u"?"Browser":"Node",s="unknown",c="unknown";typeof navigator<"u"&&(e=e+"/"+navigator.platform,s=navigator.userAgent,c=navigator.appVersion);const p=this.createSynthesizerConfig(new t.SpeechServiceConfig(new t.Context(new t.OS(e,s,c)))),d=this.privProperties.getProperty(u.PropertyId.SpeechServiceConnection_Key,void 0),h=d&&d!==""?new t.CognitiveSubscriptionKeyAuthentication(d):new t.CognitiveTokenAuthentication(()=>{const l=this.privProperties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(l)},()=>{const l=this.privProperties.getProperty(u.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(l)});this.privAdapter=this.createSynthesisAdapter(h,this.privConnectionFactory,p),this.privRestAdapter=this.createRestSynthesisAdapter(h,p)}static XMLEncode(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}};ge.Synthesizer=o;class a{constructor(e,s,c,p,d,h){this.requestId=e,this.text=s,this.isSSML=c,this.cb=p,this.err=d,this.dataStream=h}}return ge.SynthesisRequest=a,ge}var Pr={},yc;function xv(){if(yc)return Pr;
18yc=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.SpeechSynthesizer=void 0;const t=E(),r=I(),i=Ap(),u=Bi(),o=Me(),a=T(),n=y(),e=ls();let s=class Yp extends n.Synthesizer{constructor(p,d){super(p),d!==null&&(d===void 0?this.audioConfig=typeof window>"u"?void 0:n.AudioConfig.fromDefaultSpeakerOutput():this.audioConfig=d),this.privConnectionFactory=new t.SpeechSynthesisConnectionFactory,this.implCommonSynthesizeSetup()}static FromConfig(p,d,h){const l=p;return d.properties.mergeTo(l.properties),new Yp(p,h)}speakTextAsync(p,d,h,l){this.speakImpl(p,!1,d,h,l)}speakSsmlAsync(p,d,h,l){this.speakImpl(p,!0,d,h,l)}async getVoicesAsync(p=""){return this.getVoices(p)}close(p,d){a.Contracts.throwIfDisposed(this.privDisposed),r.marshalPromiseToCallbacks(this.dispose(!0),p,d)}get internalData(){return this.privAdapter}createSynthesisAdapter(p,d,h){return new t.SpeechSynthesisAdapter(p,d,h,this,this.audioConfig)}createRestSynthesisAdapter(p,d){return new t.SynthesisRestAdapter(d,p)}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=u.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(n.SpeechSynthesisOutputFormat[this.properties.getProperty(n.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)])}speakImpl(p,d,h,l,v){try{a.Contracts.throwIfDisposed(this.privDisposed);const f=r.createNoDashGuid();let g;v instanceof n.PushAudioOutputStreamCallback?g=new o.PushAudioOutputStreamImpl(v):v instanceof n.PullAudioOutputStream?g=v:v!==void 0?g=new i.AudioFileWriter(v):g=void 0,this.synthesisRequestQueue.enqueue(new e.SynthesisRequest(f,p,d,m=>{if(this.privSynthesizing=!1,h)try{h(m)}catch(S){l&&l(S)}h=void 0,this.adapterSpeak().catch(()=>{})},m=>{l&&l(m)},g)),this.adapterSpeak().catch(()=>{})}catch(f){if(l)if(f instanceof Error){const g=f;l(g.name+": "+g.message)}else l(f);this.dispose(!0).catch(()=>{})}}async getVoices(p){const d=r.createNoDashGuid(),h=await this.privRestAdapter.getVoicesList(d);if(h.ok&&Array.isArray(h.json)){let l=h.json;return p&&p.length>0&&(l=l.filter(v=>!!v.Locale&&v.Locale.toLowerCase()===p.toLowerCase())),new n.SynthesisVoicesResult(d,l,void 0)}else return new n.SynthesisVoicesResult(d,void 0,`Error: ${h.status}: ${h.statusText}`)}};return Pr.SpeechSynthesizer=s,Pr}var Er={},Rc;function Fv(){if(Rc)return Er;Rc=1,Object.defineProperty(Er,"__esModule",{value:!0}),Er.SynthesisResult=void 0;let t=class{constructor(i,u,o,a){this.privResultId=i,this.privReason=u,this.privErrorDetails=o,this.privProperties=a}get resultId(){return this.privResultId}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get properties(){return this.privProperties}};return Er.SynthesisResult=t,Er}var Ir={},Pc;function Uv(){if(Pc)return Ir;Pc=1,Object.defineProperty(Ir,"__esModule",{value:!0}),Ir.SpeechSynthesisResult=void 0;const t=y();let r=class extends t.SynthesisResult{constructor(u,o,a,n,e,s){super(u,o,n,e),this.privAudioData=a,this.privAudioDuration=s}get audioData(){return this.privAudioData}get audioDuration(){return this.privAudioDuration}};return Ir.SpeechSynthesisResult=r,Ir}var Tr={},Ec;function Wv(){if(Ec)return Tr;Ec=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.SpeechSynthesisEventArgs=void 0;let t=class{constructor(i){this.privResult=i}get result(){return this.privResult}};return Tr.SpeechSynthesisEventArgs=t,Tr}var Ar={},Ic;function Hv(){if(Ic)return Ar;Ic=1,Object.defineProperty(Ar,"__esModule",{value:!0}),Ar.SpeechSynthesisWordBoundaryEventArgs=void 0;let t=class{constructor(i,u,o,a,n,e){this.privAudioOffset=i,this.privDuration=u,this.privText=o,this.privWordLength=a,this.privTextOffset=n,this.privBoundaryType=e}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}};return Ar.SpeechSynthesisWordBoundaryEventArgs=t,Ar}var wr={},Tc;function Vv(){if(Tc)return wr;Tc=1,Object.defineProperty(wr,"__esModule",{value:!0}),wr.SpeechSynthesisBookmarkEventArgs=void 0;let t=class{constructor(i,u){this.privAudioOffset=i,this.privText=u}get audioOffset(){return this.privAudioOffset}get text(){return this.privText}};return wr.SpeechSynthesisBookmarkEventArgs=t,wr}var _r={},Ac;function $v(){if(Ac)return _r;
18Ac=1,Object.defineProperty(_r,"__esModule",{value:!0}),_r.SpeechSynthesisVisemeEventArgs=void 0;let t=class{constructor(i,u,o){this.privAudioOffset=i,this.privVisemeId=u,this.privAnimation=o}get audioOffset(){return this.privAudioOffset}get visemeId(){return this.privVisemeId}get animation(){return this.privAnimation}};return _r.SpeechSynthesisVisemeEventArgs=t,_r}var Nn={},wc;function Kv(){return wc||(wc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SpeechSynthesisBoundaryType=void 0,(function(r){r.Word="WordBoundary",r.Punctuation="PunctuationBoundary",r.Sentence="SentenceBoundary"})(t.SpeechSynthesisBoundaryType||(t.SpeechSynthesisBoundaryType={}))})(Nn)),Nn}var br={},_c;function Jv(){if(_c)return br;_c=1,Object.defineProperty(br,"__esModule",{value:!0}),br.SynthesisVoicesResult=void 0;const t=y();let r=class extends t.SynthesisResult{constructor(u,o,a){if(Array.isArray(o)){super(u,t.ResultReason.VoicesListRetrieved,void 0,new t.PropertyCollection),this.privVoices=[];for(const n of o)this.privVoices.push(new t.VoiceInfo(n))}else super(u,t.ResultReason.Canceled,a||"Error information unavailable",new t.PropertyCollection)}get voices(){return this.privVoices}};return br.SynthesisVoicesResult=r,br}var zn={},bc;function Gv(){return bc||(bc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceInfo=t.SynthesisVoiceType=t.SynthesisVoiceGender=void 0;var r;(function(a){a[a.Unknown=0]="Unknown",a[a.Female=1]="Female",a[a.Male=2]="Male",a[a.Neutral=3]="Neutral"})(r=t.SynthesisVoiceGender||(t.SynthesisVoiceGender={}));var i;(function(a){a[a.OnlineNeural=1]="OnlineNeural",a[a.OnlineStandard=2]="OnlineStandard",a[a.OfflineNeural=3]="OfflineNeural",a[a.OfflineStandard=4]="OfflineStandard"})(i=t.SynthesisVoiceType||(t.SynthesisVoiceType={}));const u={[r[r.Neutral]]:r.Neutral,[r[r.Male]]:r.Male,[r[r.Female]]:r.Female};class o{constructor(n){if(this.privStyleList=[],n){if(this.privName=n.Name,this.privLocale=n.Locale,this.privShortName=n.ShortName,this.privLocaleName=n.LocaleName,this.privDisplayName=n.DisplayName,this.privLocalName=n.LocalName,this.privVoiceType=n.VoiceType.endsWith("Standard")?i.OnlineStandard:i.OnlineNeural,this.privGender=u[n.Gender]||r.Unknown,n.StyleList&&Array.isArray(n.StyleList))for(const e of n.StyleList)this.privStyleList.push(e);this.privSampleRateHertz=n.SampleRateHertz,this.privStatus=n.Status,n.ExtendedPropertyMap&&(this.privExtendedPropertyMap=n.ExtendedPropertyMap),this.privWordsPerMinute=n.WordsPerMinute,Array.isArray(n.SecondaryLocaleList)&&(this.privSecondaryLocaleList=[...n.SecondaryLocaleList]),Array.isArray(n.RolePlayList)&&(this.privRolePlayList=[...n.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}}t.VoiceInfo=o})(zn)),zn}var Mr={},Mc;function Qv(){if(Mc)return Mr;Mc=1,Object.defineProperty(Mr,"__esModule",{value:!0}),Mr.SpeakerAudioDestination=void 0;const t=I(),r=Me(),i=we(),u=1800,o={[i.AudioFormatTag.PCM]:"audio/wav",[i.AudioFormatTag.MuLaw]:"audio/x-wav",[i.AudioFormatTag.MP3]:"audio/mpeg",[i.AudioFormatTag.OGG_OPUS]:"audio/ogg",[i.AudioFormatTag.WEBM_OPUS]:"audio/webm; codecs=opus",[i.AudioFormatTag.ALaw]:"audio/x-wav",[i.AudioFormatTag.FLAC]:"audio/flac",[i.AudioFormatTag.AMR_WB]:"audio/amr-wb",[i.AudioFormatTag.G722]:"audio/G722"};let a=class{constructor(e){this.privPlaybackStarted=!1,this.privAppendingToBuffer=!1,this.privMediaSourceOpened=!1,this.privBytesReceived=0,this.privId=e||t.createNoDashGuid(),this.privIsPaused=!1,this.privIsClosed=!1}
18id(){return this.privId}write(e,s,c){this.privAudioBuffer!==void 0?(this.privAudioBuffer.push(e),this.updateSourceBuffer().then(()=>{s&&s()},p=>{c&&c(p)})):this.privAudioOutputStream!==void 0&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength)}close(e,s){if(this.privIsClosed=!0,this.privSourceBuffer!==void 0)this.handleSourceBufferUpdateEnd().then(()=>{e&&e()},c=>{s&&s(c)});else if(this.privAudioOutputStream!==void 0&&typeof window<"u")if((this.privFormat.formatTag===i.AudioFormatTag.PCM||this.privFormat.formatTag===i.AudioFormatTag.MuLaw||this.privFormat.formatTag===i.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 c=new ArrayBuffer(this.privBytesReceived);this.privAudioOutputStream.read(c).then(()=>{c=this.privFormat.addHeader(c);const p=new Blob([c],{type:o[this.privFormat.formatTag]});this.privAudio.src=window.URL.createObjectURL(p),this.notifyPlayback().then(()=>{e&&e()},d=>{s&&s(d)})},p=>{s&&s(p)})}else this.onAudioEnd&&this.onAudioEnd(this)}set format(e){if(typeof AudioContext<"u"||typeof window<"u"&&typeof window.webkitAudioContext<"u"){this.privFormat=e;const s=o[this.privFormat.formatTag];s===void 0?console.warn(`Unknown mimeType for format ${i.AudioFormatTag[this.privFormat.formatTag]}; playback is not supported.`):typeof MediaSource<"u"&&MediaSource.isTypeSupported(s)?(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=u,this.privSourceBuffer=this.privMediaSource.addSourceBuffer(s),this.privSourceBuffer.onupdate=()=>{this.updateSourceBuffer().catch(c=>{t.Events.instance.onEvent(new t.BackgroundEvent(c))})},this.privSourceBuffer.onupdateend=()=>{this.handleSourceBufferUpdateEnd().catch(c=>{t.Events.instance.onEvent(new t.BackgroundEvent(c))})},this.privSourceBuffer.onupdatestart=()=>{this.privAppendingToBuffer=!1}},this.updateSourceBuffer().catch(c=>{t.Events.instance.onEvent(new t.BackgroundEvent(c))})):(console.warn(`Format ${i.AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`),this.privAudioOutputStream=new r.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privFormat,this.privAudio=new Audio)}}get volume(){var e;return((e=this.privAudio)==null?void 0:e.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,s){this.privIsPaused&&this.privAudio!==void 0&&(this.privAudio.play().then(()=>{e&&e()},c=>{s&&s(c)}),this.privIsPaused=!1)}get internalAudio(){return this.privAudio}async updateSourceBuffer(){if(this.privAudioBuffer!==void 0&&this.privAudioBuffer.length>0&&this.sourceBufferAvailable()){this.privAppendingToBuffer=!0;const 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}};return Mr.SpeakerAudioDestination=a,Mr}var Or={},Oc;
18function Xv(){if(Oc)return Or;Oc=1,Object.defineProperty(Or,"__esModule",{value:!0}),Or.ConversationTranscriptionCanceledEventArgs=void 0;const t=xi();let r=class extends t.CancellationEventArgsBase{};return Or.ConversationTranscriptionCanceledEventArgs=r,Or}var Dr={},Dc;function Zv(){if(Dc)return Dr;Dc=1,Object.defineProperty(Dr,"__esModule",{value:!0}),Dr.MeetingTranscriptionCanceledEventArgs=void 0;const t=xi();let r=class extends t.CancellationEventArgsBase{};return Dr.MeetingTranscriptionCanceledEventArgs=r,Dr}var jn={},kc;function Yv(){return kc||(kc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.PronunciationAssessmentGradingSystem=void 0,(function(r){r[r.FivePoint=1]="FivePoint",r[r.HundredMark=2]="HundredMark"})(t.PronunciationAssessmentGradingSystem||(t.PronunciationAssessmentGradingSystem={}))})(jn)),jn}var qn={},Nc;function ef(){return Nc||(Nc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.PronunciationAssessmentGranularity=void 0,(function(r){r[r.Phoneme=1]="Phoneme",r[r.Word=2]="Word",r[r.FullText=3]="FullText"})(t.PronunciationAssessmentGranularity||(t.PronunciationAssessmentGranularity={}))})(qn)),qn}var kr={},zc;function tf(){if(zc)return kr;zc=1,Object.defineProperty(kr,"__esModule",{value:!0}),kr.PronunciationAssessmentConfig=void 0;const t=T(),r=y();let i=class ed{constructor(o,a=r.PronunciationAssessmentGradingSystem.FivePoint,n=r.PronunciationAssessmentGranularity.Phoneme,e=!1){t.Contracts.throwIfNullOrUndefined(o,"referenceText"),this.privProperties=new r.PropertyCollection,this.privProperties.setProperty(r.PropertyId.PronunciationAssessment_ReferenceText,o),this.privProperties.setProperty(r.PropertyId.PronunciationAssessment_GradingSystem,r.PronunciationAssessmentGradingSystem[a]),this.privProperties.setProperty(r.PropertyId.PronunciationAssessment_Granularity,r.PronunciationAssessmentGranularity[n]),this.privProperties.setProperty(r.PropertyId.PronunciationAssessment_EnableMiscue,String(e))}static fromJSON(o){t.Contracts.throwIfNullOrUndefined(o,"json");const a=new ed("");return a.privProperties=new r.PropertyCollection,a.properties.setProperty(r.PropertyId.PronunciationAssessment_Json,o),a}toJSON(){return this.updateJson(),this.privProperties.getProperty(r.PropertyId.PronunciationAssessment_Params)}applyTo(o){this.updateJson();const a=o.internalData;a.expectContentAssessmentResponse=!!this.privContentAssessmentTopic,a.speechContext.setPronunciationAssessmentParams(this.properties.getProperty(r.PropertyId.PronunciationAssessment_Params),this.privContentAssessmentTopic,a.isSpeakerDiarizationEnabled)}get referenceText(){return this.properties.getProperty(r.PropertyId.PronunciationAssessment_ReferenceText)}set referenceText(o){t.Contracts.throwIfNullOrWhitespace(o,"referenceText"),this.properties.setProperty(r.PropertyId.PronunciationAssessment_ReferenceText,o)}set phonemeAlphabet(o){t.Contracts.throwIfNullOrWhitespace(o,"phonemeAlphabet"),this.privPhonemeAlphabet=o}set enableMiscue(o){const a=o?"true":"false";this.properties.setProperty(r.PropertyId.PronunciationAssessment_EnableMiscue,a)}get enableMiscue(){return this.properties.getProperty(r.PropertyId.PronunciationAssessment_EnableMiscue,"false").toLowerCase()==="true"}set nbestPhonemeCount(o){this.privNBestPhonemeCount=o}set enableProsodyAssessment(o){this.privEnableProsodyAssessment=o}enableContentAssessmentWithTopic(o){this.privContentAssessmentTopic=o}get properties(){return this.privProperties}updateJson(){const o=this.privProperties.getProperty(r.PropertyId.PronunciationAssessment_Json,"{}"),a=JSON.parse(o),n=this.privProperties.getProperty(r.PropertyId.PronunciationAssessment_ReferenceText);n&&(a.referenceText=n);const e=this.privProperties.getProperty(r.PropertyId.PronunciationAssessment_GradingSystem);e&&(a.gradingSystem=e);const s=this.privProperties.getProperty(r.PropertyId.PronunciationAssessment_Granularity);s&&(a.granularity=s),this.privPhonemeAlphabet&&(a.phonemeAlphabet=this.privPhonemeAlphabet),this.privNBestPhonemeCount&&(a.nbestPhonemeCount=this.privNBestPhonemeCount),a.enableProsodyAssessment=this.privEnableProsodyAssessment,a.dimension="Comprehensive",this.privProperties.getProperty(r.PropertyId.PronunciationAssessment_EnableMiscue)&&(a.enableMiscue=this.enableMiscue),this.privProperties.setProperty(r.PropertyId.PronunciationAssessment_Params,JSON.stringify(a))}};return kr.PronunciationAssessmentConfig=i,kr}var me={},jc;function rf(){if(jc)return me;
18jc=1,Object.defineProperty(me,"__esModule",{value:!0}),me.PronunciationAssessmentResult=me.ContentAssessmentResult=void 0;const t=T(),r=y();class i{constructor(a){this.privPronJson=a}get grammarScore(){return this.privPronJson.ContentAssessment.GrammarScore}get vocabularyScore(){return this.privPronJson.ContentAssessment.VocabularyScore}get topicScore(){return this.privPronJson.ContentAssessment.TopicScore}}me.ContentAssessmentResult=i;let u=class td{constructor(a){const n=JSON.parse(a);t.Contracts.throwIfNullOrUndefined(n.NBest[0],"NBest"),this.privPronJson=n.NBest[0]}static fromResult(a){t.Contracts.throwIfNullOrUndefined(a,"result");const n=a.properties.getProperty(r.PropertyId.SpeechServiceResponse_JsonResult);return t.Contracts.throwIfNullOrUndefined(n,"json"),new td(n)}get detailResult(){return this.privPronJson}get accuracyScore(){var a;return(a=this.detailResult.PronunciationAssessment)==null?void 0:a.AccuracyScore}get pronunciationScore(){var a;return(a=this.detailResult.PronunciationAssessment)==null?void 0:a.PronScore}get completenessScore(){var a;return(a=this.detailResult.PronunciationAssessment)==null?void 0:a.CompletenessScore}get fluencyScore(){var a;return(a=this.detailResult.PronunciationAssessment)==null?void 0:a.FluencyScore}get prosodyScore(){var a;return(a=this.detailResult.PronunciationAssessment)==null?void 0:a.ProsodyScore}get contentAssessmentResult(){if(this.detailResult.ContentAssessment!==void 0)return new i(this.detailResult)}};return me.PronunciationAssessmentResult=u,me}var Nr={},qc;function nf(){if(qc)return Nr;
18qc=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.AvatarConfig=void 0;const t=T(),r=y();let i=class{constructor(o,a,n){this.privCustomized=!1,t.Contracts.throwIfNullOrWhitespace(o,"character"),this.character=o,this.style=a,n===void 0&&(n=new r.AvatarVideoFormat),this.videoFormat=n}get customized(){return this.privCustomized}set customized(o){this.privCustomized=o}get backgroundColor(){return this.privBackgroundColor}set backgroundColor(o){this.privBackgroundColor=o}};return Nr.AvatarConfig=i,Nr}var Ln={},Lc;function sf(){return Lc||(Lc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.AvatarEventArgs=t.AvatarEventTypes=void 0,(function(i){i.SwitchedToSpeaking="SwitchedToSpeaking",i.SwitchedToIdle="SwitchedToIdle",i.SessionClosed="SessionClosed"})(t.AvatarEventTypes||(t.AvatarEventTypes={}));class r{constructor(u,o){this.privOffset=u,this.privDescription=o}get type(){return this.privType}get offset(){return this.privOffset}get description(){return this.privDescription}}t.AvatarEventArgs=r})(Ln)),Ln}var zr={},jr={},Bc;function rd(){if(Bc)return jr;Bc=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.SpeechSynthesisConnectionFactory=void 0;const t=D(),r=y(),i=H(),u=E(),o=N(),a=Y();let n=class{constructor(){this.synthesisUri="/cognitiveservices/websocket/v1"}create(s,c,p){let d=s.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint,void 0);const h=s.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Region,void 0),l=i.ConnectionFactoryBase.getHostSuffix(h),v=s.parameters.getProperty(r.PropertyId.SpeechServiceConnection_EndpointId,void 0),f=v===void 0?"tts":"voice",g=s.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host,"wss://"+h+"."+f+".speech"+l),m={},S={};c.token!==void 0&&c.token!==""&&(S[c.headerName]=c.token),S[o.HeaderNames.ConnectionId]=p,v!==void 0&&v!==""&&(!d||d.search(a.QueryParameterNames.CustomVoiceDeploymentId)===-1)&&(m[a.QueryParameterNames.CustomVoiceDeploymentId]=v),s.avatarEnabled&&(!d||d.search(a.QueryParameterNames.EnableAvatar)===-1)&&(m[a.QueryParameterNames.EnableAvatar]="true"),d||(d=g+this.synthesisUri),s.parameters.setProperty(r.PropertyId.SpeechServiceConnection_Url,d);const C=s.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new t.WebsocketConnection(d,m,S,new u.WebsocketMessageFormatter,t.ProxyInfo.fromParameters(s.parameters),C,p)}};return jr.SpeechSynthesisConnectionFactory=n,jr}var xc;function of(){if(xc)return zr;xc=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.AvatarSynthesizer=void 0;const t=rd(),r=E(),i=I(),u=Bi(),o=y(),a=T(),n=ls();let e=class extends o.Synthesizer{constructor(c,p){super(c),a.Contracts.throwIfNullOrUndefined(p,"avatarConfig"),this.privConnectionFactory=new t.SpeechSynthesisConnectionFactory,this.privAvatarConfig=p,this.implCommonSynthesizeSetup()}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=u.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(o.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm)}async startAvatarAsync(c){a.Contracts.throwIfNullOrUndefined(c,"peerConnection"),this.privIceServers=c.getConfiguration().iceServers,a.Contracts.throwIfNullOrUndefined(this.privIceServers,"Ice servers must be set.");const p=new i.Deferred;c.onicegatheringstatechange=()=>{i.Events.instance.onEvent(new i.PlatformEvent("peer connection: ice gathering state: "+c.iceGatheringState,i.EventType.Debug)),c.iceGatheringState==="complete"&&(i.Events.instance.onEvent(new i.PlatformEvent("peer connection: ice gathering complete.",i.EventType.Info)),p.resolve())},c.onicecandidate=f=>{f.candidate?i.Events.instance.onEvent(new i.PlatformEvent("peer connection: ice candidate: "+f.candidate.candidate,i.EventType.Debug)):(i.Events.instance.onEvent(new i.PlatformEvent("peer connection: ice candidate: complete",i.EventType.Debug)),p.resolve())},setTimeout(()=>{c.iceGatheringState!=="complete"&&(i.Events.instance.onEvent(new i.PlatformEvent("peer connection: ice gathering timeout.",i.EventType.Warning)),p.resolve())},2e3);const d=await c.createOffer();await c.setLocalDescription(d),await p.promise,i.Events.instance.onEvent(new i.PlatformEvent("peer connection: got local SDP.",i.EventType.Info)),this.privProperties.setProperty(o.PropertyId.TalkingAvatarService_WebRTC_SDP,JSON.stringify(c.localDescription));const h=await this.speak("",!1);if(h.reason!==o.ResultReason.SynthesizingAudioCompleted)return new o.SynthesisResult(h.resultId,h.reason,h.errorDetails,h.properties);const l=atob(h.properties.getProperty(o.PropertyId.TalkingAvatarService_WebRTC_SDP)),v=new RTCSessionDescription(JSON.parse(l));return await c.setRemoteDescription(v),new o.SynthesisResult(h.resultId,h.reason,void 0,h.properties)}async speakTextAsync(c){const p=await this.speak(c,!1);return new o.SynthesisResult(p.resultId,p.reason,p.errorDetails,p.properties)}async speakSsmlAsync(c){const p=await this.speak(c,!0);return new o.SynthesisResult(p.resultId,p.reason,p.errorDetails,p.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 a.Contracts.throwIfDisposed(this.privDisposed),this.dispose(!0)}async close(){if(!this.privDisposed)return this.dispose(!0)}get iceServers(){return this.privIceServers}createSynthesisAdapter(c,p,d){return new r.AvatarSynthesisAdapter(c,p,d,this,this.privAvatarConfig)}createRestSynthesisAdapter(c,p){}createSynthesizerConfig(c){const p=super.createSynthesizerConfig(c);return p.avatarEnabled=!0,p}async speak(c,p){const d=i.createNoDashGuid(),h=new i.Deferred;return this.synthesisRequestQueue.enqueue(new n.SynthesisRequest(d,c,p,l=>{h.resolve(l),this.privSynthesizing=!1,this.adapterSpeak()},l=>{h.reject(l),this.privSynthesizing=!1})),this.adapterSpeak(),h.promise}};return zr.AvatarSynthesizer=e,zr}var Se={},Fc;function af(){if(Fc)return Se;
18Fc=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.AvatarVideoFormat=Se.Coordinate=void 0;class t{constructor(u,o){this.x=u,this.y=o}}Se.Coordinate=t;let r=class{constructor(u="H264",o=2e6,a=1920,n=1080){this.codec=u,this.bitrate=o,this.width=a,this.height=n}setCropRange(u,o){this.cropRange={bottomRight:o,topLeft:u}}};return Se.AvatarVideoFormat=r,Se}var qr={},Uc;function cf(){if(Uc)return qr;Uc=1,Object.defineProperty(qr,"__esModule",{value:!0}),qr.AvatarWebRTCConnectionResult=void 0;const t=y();let r=class extends t.SynthesisResult{constructor(u,o,a,n,e){super(o,a,n,e),this.privSDPAnswer=u}get SDPAnswer(){return this.privSDPAnswer}};return qr.AvatarWebRTCConnectionResult=r,qr}var Lr={},Wc;function uf(){if(Wc)return Lr;Wc=1,Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.Diagnostics=void 0;const t=D(),r=I();let i=class{static SetLoggingLevel(o){this.privListener=new t.ConsoleLoggingListener(o),r.Events.instance.attachConsoleListener(this.privListener)}static StartConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!0)}static StopConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!1)}static SetLogOutputPath(o){if(typeof window>"u")this.privListener&&(this.privListener.logPath=o);else throw new Error("File system logging not available in browser.")}static set onLogOutput(o){this.privListener&&(this.privListener.logCallback=o)}};return Lr.Diagnostics=i,i.privListener=void 0,Lr}var Hc;function y(){return Hc||(Hc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});var r=Mp();Object.defineProperty(t,"AudioConfig",{enumerable:!0,get:function(){return r.AudioConfig}});var i=we();Object.defineProperty(t,"AudioStreamFormat",{enumerable:!0,get:function(){return i.AudioStreamFormat}}),Object.defineProperty(t,"AudioFormatTag",{enumerable:!0,get:function(){return i.AudioFormatTag}});var u=wp();Object.defineProperty(t,"AudioInputStream",{enumerable:!0,get:function(){return u.AudioInputStream}}),Object.defineProperty(t,"PullAudioInputStream",{enumerable:!0,get:function(){return u.PullAudioInputStream}}),Object.defineProperty(t,"PushAudioInputStream",{enumerable:!0,get:function(){return u.PushAudioInputStream}});var o=Me();Object.defineProperty(t,"AudioOutputStream",{enumerable:!0,get:function(){return o.AudioOutputStream}}),Object.defineProperty(t,"PullAudioOutputStream",{enumerable:!0,get:function(){return o.PullAudioOutputStream}}),Object.defineProperty(t,"PushAudioOutputStream",{enumerable:!0,get:function(){return o.PushAudioOutputStream}});var a=Rl();Object.defineProperty(t,"CancellationReason",{enumerable:!0,get:function(){return a.CancellationReason}});var n=Pl();Object.defineProperty(t,"PullAudioInputStreamCallback",{enumerable:!0,get:function(){return n.PullAudioInputStreamCallback}});var e=El();Object.defineProperty(t,"PushAudioOutputStreamCallback",{enumerable:!0,get:function(){return e.PushAudioOutputStreamCallback}});var s=Il();Object.defineProperty(t,"KeywordRecognitionModel",{enumerable:!0,get:function(){return s.KeywordRecognitionModel}});var c=Tl();Object.defineProperty(t,"SessionEventArgs",{enumerable:!0,get:function(){return c.SessionEventArgs}});var p=Al();Object.defineProperty(t,"RecognitionEventArgs",{enumerable:!0,get:function(){return p.RecognitionEventArgs}});var d=wl();Object.defineProperty(t,"OutputFormat",{enumerable:!0,get:function(){return d.OutputFormat}});var h=_l();Object.defineProperty(t,"IntentRecognitionEventArgs",{enumerable:!0,get:function(){return h.IntentRecognitionEventArgs}});var l=bl();Object.defineProperty(t,"RecognitionResult",{enumerable:!0,get:function(){return l.RecognitionResult}});var v=Ml();Object.defineProperty(t,"SpeechRecognitionResult",{enumerable:!0,get:function(){return v.SpeechRecognitionResult}});var f=Ol();Object.defineProperty(t,"IntentRecognitionResult",{enumerable:!0,get:function(){return f.IntentRecognitionResult}});var g=Dl();Object.defineProperty(t,"LanguageUnderstandingModel",{enumerable:!0,get:function(){return g.LanguageUnderstandingModel}});var m=kl();Object.defineProperty(t,"SpeechRecognitionEventArgs",{enumerable:!0,get:function(){return m.SpeechRecognitionEventArgs}}),Object.defineProperty(t,"ConversationTranscriptionEventArgs",{enumerable:!0,get:function(){return m.ConversationTranscriptionEventArgs}}),Object.defineProperty(t,"MeetingTranscriptionEventArgs",{enumerable:!0,get:function(){return m.MeetingTranscriptionEventArgs}});var S=Nl();Object.defineProperty(t,"SpeechRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return S.SpeechRecognitionCanceledEventArgs}});var C=zl();Object.defineProperty(t,"TranslationRecognitionEventArgs",{enumerable:!0,get:function(){return C.TranslationRecognitionEventArgs}});var R=jl();Object.defineProperty(t,"TranslationSynthesisEventArgs",{enumerable:!0,get:function(){return R.TranslationSynthesisEventArgs}});var P=Dp();Object.defineProperty(t,"TranslationRecognitionResult",{enumerable:!0,get:function(){return P.TranslationRecognitionResult}});var A=ql();Object.defineProperty(t,"TranslationSynthesisResult",{enumerable:!0,get:function(){return A.TranslationSynthesisResult}});var M=Ll();Object.defineProperty(t,"ResultReason",{enumerable:!0,get:function(){return M.ResultReason}});var _=Bl();Object.defineProperty(t,"SpeechConfig",{enumerable:!0,get:function(){return _.SpeechConfig}}),Object.defineProperty(t,"SpeechConfigImpl",{enumerable:!0,get:function(){return _.SpeechConfigImpl}});var j=xl();Object.defineProperty(t,"SpeechTranslationConfig",{enumerable:!0,get:function(){return j.SpeechTranslationConfig}}),Object.defineProperty(t,"SpeechTranslationConfigImpl",{enumerable:!0,get:function(){return j.SpeechTranslationConfigImpl}});var _e=Np();Object.defineProperty(t,"PropertyCollection",{enumerable:!0,get:function(){return _e.PropertyCollection}});
18var Fi=ps();Object.defineProperty(t,"PropertyId",{enumerable:!0,get:function(){return Fi.PropertyId}});var Ui=Fl();Object.defineProperty(t,"Recognizer",{enumerable:!0,get:function(){return Ui.Recognizer}});var q=Ul();Object.defineProperty(t,"SpeechRecognizer",{enumerable:!0,get:function(){return q.SpeechRecognizer}});var gs=Wl();Object.defineProperty(t,"IntentRecognizer",{enumerable:!0,get:function(){return gs.IntentRecognizer}});var Cd=Hl();Object.defineProperty(t,"VoiceProfileType",{enumerable:!0,get:function(){return Cd.VoiceProfileType}});var yd=Vl();Object.defineProperty(t,"TranslationRecognizer",{enumerable:!0,get:function(){return yd.TranslationRecognizer}});var Rd=$l();Object.defineProperty(t,"Translations",{enumerable:!0,get:function(){return Rd.Translations}});var Pd=Kl();Object.defineProperty(t,"NoMatchReason",{enumerable:!0,get:function(){return Pd.NoMatchReason}});var Ed=Jl();Object.defineProperty(t,"NoMatchDetails",{enumerable:!0,get:function(){return Ed.NoMatchDetails}});var Id=Gl();Object.defineProperty(t,"TranslationRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return Id.TranslationRecognitionCanceledEventArgs}});var Td=Ql();Object.defineProperty(t,"IntentRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return Td.IntentRecognitionCanceledEventArgs}});var Ad=Fp();Object.defineProperty(t,"CancellationDetailsBase",{enumerable:!0,get:function(){return Ad.CancellationDetailsBase}});var wd=Xl();Object.defineProperty(t,"CancellationDetails",{enumerable:!0,get:function(){return wd.CancellationDetails}});var _d=Zl();Object.defineProperty(t,"CancellationErrorCode",{enumerable:!0,get:function(){return _d.CancellationErrorCode}});var bd=Yl();Object.defineProperty(t,"ConnectionEventArgs",{enumerable:!0,get:function(){return bd.ConnectionEventArgs}});var Md=ev();Object.defineProperty(t,"ServiceEventArgs",{enumerable:!0,get:function(){return Md.ServiceEventArgs}});var Od=Lp();Object.defineProperty(t,"Connection",{enumerable:!0,get:function(){return Od.Connection}});var Dd=tv();Object.defineProperty(t,"PhraseListGrammar",{enumerable:!0,get:function(){return Dd.PhraseListGrammar}});var kd=ds();Object.defineProperty(t,"DialogServiceConfig",{enumerable:!0,get:function(){return kd.DialogServiceConfig}});var Nd=rv();Object.defineProperty(t,"BotFrameworkConfig",{enumerable:!0,get:function(){return Nd.BotFrameworkConfig}});var zd=iv();Object.defineProperty(t,"CustomCommandsConfig",{enumerable:!0,get:function(){return zd.CustomCommandsConfig}});var jd=sv();Object.defineProperty(t,"DialogServiceConnector",{enumerable:!0,get:function(){return jd.DialogServiceConnector}});var qd=ov();Object.defineProperty(t,"ActivityReceivedEventArgs",{enumerable:!0,get:function(){return qd.ActivityReceivedEventArgs}});var Ld=cv();Object.defineProperty(t,"TurnStatusReceivedEventArgs",{enumerable:!0,get:function(){return Ld.TurnStatusReceivedEventArgs}});var Bd=uv();Object.defineProperty(t,"ServicePropertyChannel",{enumerable:!0,get:function(){return Bd.ServicePropertyChannel}});var xd=pv();Object.defineProperty(t,"ProfanityOption",{enumerable:!0,get:function(){return xd.ProfanityOption}});var Fd=dv();Object.defineProperty(t,"BaseAudioPlayer",{enumerable:!0,get:function(){return Fd.BaseAudioPlayer}});var Ud=hv();Object.defineProperty(t,"ConnectionMessageEventArgs",{enumerable:!0,get:function(){return Ud.ConnectionMessageEventArgs}});var Wd=qp();Object.defineProperty(t,"ConnectionMessage",{enumerable:!0,get:function(){return Wd.ConnectionMessage}});var Hd=lv();Object.defineProperty(t,"VoiceProfile",{enumerable:!0,get:function(){return Hd.VoiceProfile}});var ms=vv();Object.defineProperty(t,"VoiceProfileEnrollmentResult",{enumerable:!0,get:function(){return ms.VoiceProfileEnrollmentResult}}),Object.defineProperty(t,"VoiceProfileEnrollmentCancellationDetails",{enumerable:!0,get:function(){return ms.VoiceProfileEnrollmentCancellationDetails}});var Ss=fv();Object.defineProperty(t,"VoiceProfileResult",{enumerable:!0,get:function(){return Ss.VoiceProfileResult}}),Object.defineProperty(t,"VoiceProfileCancellationDetails",{enumerable:!0,get:function(){return Ss.VoiceProfileCancellationDetail
18s}});var Vd=gv();Object.defineProperty(t,"VoiceProfilePhraseResult",{enumerable:!0,get:function(){return Vd.VoiceProfilePhraseResult}});var $d=mv();Object.defineProperty(t,"VoiceProfileClient",{enumerable:!0,get:function(){return $d.VoiceProfileClient}});var Kd=Sv();Object.defineProperty(t,"SpeakerRecognizer",{enumerable:!0,get:function(){return Kd.SpeakerRecognizer}});var Jd=Cv();Object.defineProperty(t,"SpeakerIdentificationModel",{enumerable:!0,get:function(){return Jd.SpeakerIdentificationModel}});var Gd=yv();Object.defineProperty(t,"SpeakerVerificationModel",{enumerable:!0,get:function(){return Gd.SpeakerVerificationModel}});var Qd=Rv();Object.defineProperty(t,"AutoDetectSourceLanguageConfig",{enumerable:!0,get:function(){return Qd.AutoDetectSourceLanguageConfig}});var Xd=Pv();Object.defineProperty(t,"AutoDetectSourceLanguageResult",{enumerable:!0,get:function(){return Xd.AutoDetectSourceLanguageResult}});var Zd=Ev();Object.defineProperty(t,"SourceLanguageConfig",{enumerable:!0,get:function(){return Zd.SourceLanguageConfig}});var Ji=Iv();Object.defineProperty(t,"SpeakerRecognitionResult",{enumerable:!0,get:function(){return Ji.SpeakerRecognitionResult}}),Object.defineProperty(t,"SpeakerRecognitionResultType",{enumerable:!0,get:function(){return Ji.SpeakerRecognitionResultType}}),Object.defineProperty(t,"SpeakerRecognitionCancellationDetails",{enumerable:!0,get:function(){return Ji.SpeakerRecognitionCancellationDetails}});var z=hs();Object.defineProperty(t,"Conversation",{enumerable:!0,get:function(){return z.Conversation}}),Object.defineProperty(t,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return z.ConversationExpirationEventArgs}}),Object.defineProperty(t,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return z.ConversationParticipantsChangedEventArgs}}),Object.defineProperty(t,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return z.ConversationTranslationCanceledEventArgs}}),Object.defineProperty(t,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return z.ConversationTranslationEventArgs}}),Object.defineProperty(t,"ConversationTranslationResult",{enumerable:!0,get:function(){return z.ConversationTranslationResult}}),Object.defineProperty(t,"ConversationTranslator",{enumerable:!0,get:function(){return z.ConversationTranslator}}),Object.defineProperty(t,"ConversationTranscriber",{enumerable:!0,get:function(){return z.ConversationTranscriber}}),Object.defineProperty(t,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return z.ConversationTranscriptionResult}}),Object.defineProperty(t,"Meeting",{enumerable:!0,get:function(){return z.Meeting}}),Object.defineProperty(t,"MeetingTranscriber",{enumerable:!0,get:function(){return z.MeetingTranscriber}}),Object.defineProperty(t,"Participant",{enumerable:!0,get:function(){return z.Participant}}),Object.defineProperty(t,"ParticipantChangedReason",{enumerable:!0,get:function(){return z.ParticipantChangedReason}}),Object.defineProperty(t,"User",{enumerable:!0,get:function(){return z.User}});var Yd=ls();Object.defineProperty(t,"Synthesizer",{enumerable:!0,get:function(){return Yd.Synthesizer}});var eh=_p();Object.defineProperty(t,"SpeechSynthesisOutputFormat",{enumerable:!0,get:function(){return eh.SpeechSynthesisOutputFormat}});var th=xv();Object.defineProperty(t,"SpeechSynthesizer",{enumerable:!0,get:function(){return th.SpeechSynthesizer}});var rh=Fv();Object.defineProperty(t,"SynthesisResult",{enumerable:!0,get:function(){return rh.SynthesisResult}});var ih=Uv();Object.defineProperty(t,"SpeechSynthesisResult",{enumerable:!0,get:function(){return ih.SpeechSynthesisResult}});var nh=Wv();Object.defineProperty(t,"SpeechSynthesisEventArgs",{enumerable:!0,get:function(){return nh.SpeechSynthesisEventArgs}});var sh=Hv();Object.defineProperty(t,"SpeechSynthesisWordBoundaryEventArgs",{enumerable:!0,get:function(){return sh.SpeechSynthesisWordBoundaryEventArgs}});var oh=Vv();Object.defineProperty(t,"SpeechSynthesisBookmarkEventArgs",{enumerable:!0,get:function(){return oh.SpeechSynthesisBookmarkEventArgs}});var ah=$v();Object.defineProperty(t,"SpeechSynthesisVisemeEventArgs",{enumerable:!0,get:function(){return ah.SpeechSynthesisVisemeEventArgs}});var ch=Kv();Object.defineProperty(t,"SpeechSynthesisBoundaryType",{enumerable:!0,get:function(){return ch.SpeechSynthesisBoundaryType}});var uh=Jv();Object.defineProperty(t,"SynthesisVoicesResult",{enumerable:!0,get:function(){return uh.SynthesisVoicesResult}});var ph=Gv();Object.defineProperty(t,"VoiceInfo",{enumerable:!0,get:function(){return ph.VoiceInfo}});var dh=Qv();Object.defineProperty(t,"SpeakerAudioDestination",{enumerable:!0,get:function(){return dh.SpeakerAudioDestination}});var hh=Xv();Object.defineProperty(t,"ConversationTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return hh.ConversationTranscriptionCanceledEventArgs}});var lh=Zv();Object.defineProperty(t,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return lh.MeetingTranscriptionCanceledEventArgs}});var vh=Yv();Object.defineProperty(t,"PronunciationAssessmentGradingSystem",{enumerable:!0,get:function(){return vh.PronunciationAssessmentGradingSystem}});var fh=ef();Object.defineProperty(t,"PronunciationAssessmentGranularity",{enumerable:!0,get:function(){return fh.PronunciationAssessmentGranularity}});var gh=tf();Object.defineProperty(t,"PronunciationAssessmentConfig",{enumerable:!0,get:function(){return gh.PronunciationAssessmentConfig}});var mh=rf();Object.defineProperty(t,"PronunciationAssessmentResult",{enumerable:!0,get:function(){return mh.PronunciationAssessmentResult}});var Sh=$p();Object.defineProperty(t,"LanguageIdMode",{enumerable:!0,get:function(){return Sh.LanguageIdMode}});var Ch=nf();Object.defineProperty(t,"AvatarConfig",{enumerable:!0,get:function(){return Ch.AvatarConfig}});var yh=sf();Object.defineProperty(t,"AvatarEventArgs",{enumerable:!0,get:function(){return yh.AvatarEventArgs}});var Rh=of();Object.defineProperty(t,"AvatarSynthesizer",{enumerable:!0,get:function(){return Rh.AvatarSynthesizer}});var Cs=af();Object.defineProperty(t,"AvatarVideoFormat",{enumerable:!0,get:function(){return Cs.AvatarVideoFormat}}
18),Object.defineProperty(t,"Coordinate",{enumerable:!0,get:function(){return Cs.Coordinate}});var Ph=cf();Object.defineProperty(t,"AvatarWebRTCConnectionResult",{enumerable:!0,get:function(){return Ph.AvatarWebRTCConnectionResult}});var Eh=uf();Object.defineProperty(t,"Diagnostics",{enumerable:!0,get:function(){return Eh.Diagnostics}});var Ih=Ip();Object.defineProperty(t,"LogLevel",{enumerable:!0,get:function(){return Ih.LogLevel}})})(Sn)),Sn}var Vc;function pf(){if(Vc)return ht;Vc=1,Object.defineProperty(ht,"__esModule",{value:!0}),ht.ProxyInfo=void 0;const t=y();let r=class id{constructor(u,o,a,n){this.privProxyHostName=u,this.privProxyPort=o,this.privProxyUserName=a,this.privProxyPassword=n}static fromParameters(u){return new id(u.getProperty(t.PropertyId.SpeechServiceConnection_ProxyHostName),parseInt(u.getProperty(t.PropertyId.SpeechServiceConnection_ProxyPort),10),u.getProperty(t.PropertyId.SpeechServiceConnection_ProxyUserName),u.getProperty(t.PropertyId.SpeechServiceConnection_ProxyPassword))}static fromRecognizerConfig(u){return this.fromParameters(u.parameters)}get HostName(){return this.privProxyHostName}get Port(){return this.privProxyPort}get UserName(){return this.privProxyUserName}get Password(){return this.privProxyPassword}};return ht.ProxyInfo=r,ht}var Br={},Bn,$c;function df(){if($c)return Bn;$c=1;const t=new Set(["json","buffer","string"]);return Bn=r=>(...i)=>{const u=new Set;let o,a,n,e="";return i.forEach(s=>{if(typeof s=="string")if(s.toUpperCase()===s)if(o){const c=`Can't set method to ${s}, already set to ${o}.`;throw new Error(c)}else o=s;else if(s.startsWith("http:")||s.startsWith("https:"))e=s;else if(t.has(s))a=s;else throw new Error(`Unknown encoding, ${s}`);else if(typeof s=="number")u.add(s);else if(typeof s=="object")if(Array.isArray(s)||s instanceof Set)s.forEach(c=>u.add(c));else{if(n)throw new Error("Cannot set headers twice.");n=s}else throw new Error(`Unknown type: ${typeof s}`)}),o||(o="GET"),u.size===0&&u.add(200),r(u,o,a,n,e)},Bn}var xn,Kc;function hf(){if(Kc)return xn;Kc=1;const t=df();class r extends Error{constructor(o,...a){super(...a),Error.captureStackTrace&&Error.captureStackTrace(this,r),this.name="StatusError",this.message=o.statusMessage,this.statusCode=o.status,this.res=o,this.json=o.json.bind(o),this.text=o.text.bind(o),this.arrayBuffer=o.arrayBuffer.bind(o);let n;Object.defineProperty(this,"responseBody",{get:()=>(n||(n=this.arrayBuffer()),n)}),this.headers={};for(const[s,c]of o.headers.entries())this.headers[s.toLowerCase()]=c}}return xn=t((u,o,a,n,e)=>async(s,c,p={})=>{s=e+(s||"");let d=new URL(s);if(n||(n={}),d.username&&(n.Authorization="Basic "+btoa(d.username+":"+d.password),d=new URL(d.protocol+"//"+d.host+d.pathname+d.search)),d.protocol!=="https:"&&d.protocol!=="http:")throw new Error(`Unknown protocol, ${d.protocol}`);if(c&&!(c instanceof ArrayBuffer||ArrayBuffer.isView(c)||typeof c=="string"))if(typeof c=="object")c=JSON.stringify(c),n["Content-Type"]="application/json";else throw new Error("Unknown body type.");p=new Headers({...n||{},...p});const h=await fetch(d,{method:o,headers:p,body:c});if(h.statusCode=h.status,!u.has(h.status))throw new r(h);return a==="json"?h.json():a==="buffer"?h.arrayBuffer():a==="string"?h.text():h}),xn}var Jc;function lf(){return Jc||(Jc=1,(function(t){var r=Br&&Br.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(t,"__esModule",{value:!0}),t.RestMessageAdapter=t.RestRequestType=void 0;const i=r(hf()),u=I();var o;(function(n){n.Get="GET",n.Post="POST",n.Delete="DELETE",n.File="file"})(o=t.RestRequestType||(t.RestRequestType={}));let a=class{constructor(e){if(!e)throw new u.ArgumentNullError("configParams");this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}static extractHeaderValue(e,s){let c="";try{const p=s.trim().split(/[\r\n]+/),d={};p.forEach(h=>{const l=h.split(": "),v=l.shift().toLowerCase(),f=l.join(": ");d[v]=f}),c=d[e.toLowerCase()]}catch{}return c}set options(e){this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}setHeaders(e,s){this.privHeaders[e]=s}request(e,s,c={},p=null){const d=new u.Deferred,h=e===o.File?"POST":e,l=(f,g={})=>{const m=f;return{data:JSON.stringify(g),headers:JSON.stringify(f.headers),json:g,ok:f.statusCode>=200&&f.statusCode<300,status:f.statusCode,statusText:g.error?g.error.message:m.statusText?m.statusText:m.statusMessage}},v=f=>{const g=i.default(s,h,this.privHeaders,200,201,202,204,400,401,402,403,404),m=this.queryParams(c)===""?"":`?${this.queryParams(c)}`;g(m,f).then(async S=>{if(e===o.Delete||S.statusCode===204)d.resolve(l(S));else try{const C=await S.json();d.resolve(l(S,C))}catch{d.resolve(l(S))}}).catch(S=>{d.reject(S)})};return this.privIgnoreCache&&(this.privHeaders["Cache-Control"]="no-cache"),e===o.Post&&p&&(this.privHeaders["content-type"]="application/json",this.privHeaders["Content-Type"]="application/json"),v(p),d.promise}queryParams(e={}){return Object.keys(e).map(s=>encodeURIComponent(s)+"="+encodeURIComponent(e[s])).join("&")}};t.RestMessageAdapter=a})(Br)),Br}var xr={},Gc;
18function nd(){if(Gc)return xr;Gc=1,Object.defineProperty(xr,"__esModule",{value:!0}),xr.RestConfigBase=void 0;let t=class Vi{static get requestOptions(){return Vi.privDefaultRequestOptions}static get configParams(){return Vi.privDefaultParams}static get restErrors(){return Vi.privRestErrors}};return xr.RestConfigBase=t,t.privDefaultRequestOptions={headers:{Accept:"application/json"},ignoreCache:!1,timeout:1e4},t.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."},t.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"},xr}var Qc;function D(){return Qc||(Qc=1,(function(t){var r=se&&se.__createBinding||(Object.create?(function(u,o,a,n){n===void 0&&(n=a),Object.defineProperty(u,n,{enumerable:!0,get:function(){return o[a]}})}):(function(u,o,a,n){n===void 0&&(n=a),u[n]=o[a]})),i=se&&se.__exportStar||function(u,o){for(var a in u)a!=="default"&&!o.hasOwnProperty(a)&&r(o,u,a)};Object.defineProperty(t,"__esModule",{value:!0}),i(vl(),t),i(fl(),t),i(gl(),t),i(ml(),t),i(Sl(),t),i(Cl(),t),i(Tp(),t),i(yl(),t),i(pf(),t),i(lf(),t),i(nd(),t)})(se)),se}var Xc;function vf(){if(Xc)return ot;
18Xc=1,Object.defineProperty(ot,"__esModule",{value:!0}),ot.IntentConnectionFactory=void 0;const t=D(),r=y(),i=H(),u=E(),o=N();let a=class extends i.ConnectionFactoryBase{create(e,s,c){let p=e.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint);if(!p){const v=e.parameters.getProperty(r.PropertyId.SpeechServiceConnection_IntentRegion),f=i.ConnectionFactoryBase.getHostSuffix(v);p=e.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host,"wss://"+v+".sr.speech"+f)+"/speech/recognition/interactive/cognitiveservices/v1"}const d={format:"simple",language:e.parameters.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,d,p);const h={};s.token!==void 0&&s.token!==""&&(h[s.headerName]=s.token),h[o.HeaderNames.ConnectionId]=c,e.parameters.setProperty(r.PropertyId.SpeechServiceConnection_Url,p);const l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new t.WebsocketConnection(p,d,h,new u.WebsocketMessageFormatter,t.ProxyInfo.fromRecognizerConfig(e),l,c)}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}}};return ot.IntentConnectionFactory=a,ot}var Ce={},Zc;function ff(){if(Zc)return Ce;Zc=1,Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.VoiceProfileConnectionFactory=Ce.SpeakerRecognitionConnectionFactory=void 0;const t=D(),r=y(),i=H(),u=E(),o=N();class a extends i.ConnectionFactoryBase{create(c,p,d,h){let l=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint);if(!l){const m=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Region),S=i.ConnectionFactoryBase.getHostSuffix(m),C=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host,`wss://${m}.spr-frontend.speech${S}`),R=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_SpeakerIdMode,"TextIndependentIdentification");l=`${C}/speaker/ws/${this.scenarioToPath(R)}/${d}`}const v={format:"simple",language:c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(c,v,l);const f={};p.token!==void 0&&p.token!==""&&(f[p.headerName]=p.token),f[o.HeaderNames.ConnectionId]=h,f[o.HeaderNames.SpIDAuthKey]=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Key),c.parameters.setProperty(r.PropertyId.SpeechServiceConnection_Url,l);const g=c.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new t.WebsocketConnection(l,v,f,new u.WebsocketMessageFormatter,t.ProxyInfo.fromRecognizerConfig(c),g,h)}scenarioToPath(c){switch(c){case"TextIndependentVerification":case"2":return"verification/text-independent";case"TextDependentVerification":case"1":return"verification/text-dependent";default:return"identification/text-independent"}}}let n=class extends a{create(c,p,d){return super.create(c,p,"recognition",d)}};Ce.SpeakerRecognitionConnectionFactory=n;class e extends a{create(c,p,d){return super.create(c,p,"profile",d)}}return Ce.VoiceProfileConnectionFactory=e,Ce}var Fn={},Yc;function vs(){return Yc||(Yc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.RecognitionEndedEvent=t.RecognitionCompletionStatus=t.RecognitionStartedEvent=t.ConnectingToServiceEvent=t.ListeningStartedEvent=t.RecognitionTriggeredEvent=t.SpeechRecognitionEvent=void 0;const r=I();class i extends r.PlatformEvent{constructor(p,d,h,l=r.EventType.Info){super(p,l),this.privRequestId=d,this.privSessionId=h}get requestId(){return this.privRequestId}get sessionId(){return this.privSessionId}}t.SpeechRecognitionEvent=i;class u extends i{constructor(p,d,h,l){super("RecognitionTriggeredEvent",p,d),this.privAudioSourceId=h,this.privAudioNodeId=l}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}}t.RecognitionTriggeredEvent=u;class o extends i{constructor(p,d,h,l){super("ListeningStartedEvent",p,d),this.privAudioSourceId=h,this.privAudioNodeId=l}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}}t.ListeningStartedEvent=o;class a extends i{constructor(p,d,h){super("ConnectingToServiceEvent",p,h),this.privAuthFetchEventid=d}get authFetchEventid(){return this.privAuthFetchEventid}}t.ConnectingToServiceEvent=a;
18class n extends i{constructor(p,d,h,l,v){super("RecognitionStartedEvent",p,v),this.privAudioSourceId=d,this.privAudioNodeId=h,this.privAuthFetchEventId=l}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}}t.RecognitionStartedEvent=n;var e;(function(c){c[c.Success=0]="Success",c[c.AudioSourceError=1]="AudioSourceError",c[c.AudioSourceTimeout=2]="AudioSourceTimeout",c[c.AuthTokenFetchError=3]="AuthTokenFetchError",c[c.AuthTokenFetchTimeout=4]="AuthTokenFetchTimeout",c[c.UnAuthorized=5]="UnAuthorized",c[c.ConnectTimeout=6]="ConnectTimeout",c[c.ConnectError=7]="ConnectError",c[c.ClientRecognitionActivityTimeout=8]="ClientRecognitionActivityTimeout",c[c.UnknownError=9]="UnknownError"})(e=t.RecognitionCompletionStatus||(t.RecognitionCompletionStatus={}));class s extends i{constructor(p,d,h,l,v,f,g,m){super("RecognitionEndedEvent",p,v,g===e.Success?r.EventType.Info:r.EventType.Error),this.privAudioSourceId=d,this.privAudioNodeId=h,this.privAuthFetchEventId=l,this.privStatus=g,this.privError=m,this.privServiceTag=f}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}}t.RecognitionEndedEvent=s})(Fn)),Fn}var Fr={},Ur={},eu;function Oe(){if(eu)return Ur;
18eu=1,Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.SpeechConnectionMessage=void 0;const t=I(),r=N();class i extends t.ConnectionMessage{constructor(o,a,n,e,s,c,p,d){if(!a)throw new t.ArgumentNullError("path");if(!n)throw new t.ArgumentNullError("requestId");const h={};if(h[r.HeaderNames.Path]=a,h[r.HeaderNames.RequestId]=n,h[r.HeaderNames.RequestTimestamp]=new Date().toISOString(),e&&(h[r.HeaderNames.ContentType]=e),c&&(h[r.HeaderNames.RequestStreamId]=c),p)for(const l in p)l&&(h[l]=p[l]);d?super(o,s,h,d):super(o,s,h),this.privPath=a,this.privRequestId=n,this.privContentType=e,this.privStreamId=c,this.privAdditionalHeaders=p}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(o){let a=null,n=null,e=null,s=null;const c={};if(o.headers)for(const p in o.headers)p&&(p.toLowerCase()===r.HeaderNames.Path.toLowerCase()?a=o.headers[p]:p.toLowerCase()===r.HeaderNames.RequestId.toLowerCase()?n=o.headers[p]:p.toLowerCase()===r.HeaderNames.ContentType.toLowerCase()?e=o.headers[p]:p.toLowerCase()===r.HeaderNames.RequestStreamId.toLowerCase()?s=o.headers[p]:c[p]=o.headers[p]);return new i(o.messageType,a,n,e,o.body,s,c,o.id)}}return Ur.SpeechConnectionMessage=i,Ur}var tu;function gf(){if(tu)return Fr;tu=1,Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.ServiceRecognizerBase=void 0;const t=D(),r=I(),i=y(),u=E(),o=Oe();let a=class qi{constructor(e,s,c,p,d){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 r.ArgumentNullError("authentication");if(!s)throw new r.ArgumentNullError("connectionFactory");if(!c)throw new r.ArgumentNullError("audioSource");if(!p)throw new r.ArgumentNullError("recognizerConfig");this.privEnableSpeakerId=p.isSpeakerDiarizationEnabled,this.privMustReportEndOfStream=!1,this.privAuthentication=e,this.privConnectionFactory=s,this.privAudioSource=c,this.privRecognizerConfig=p,this.privIsDisposed=!1,this.privRecognizer=d,this.privRequestSession=new u.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new r.EventSource,this.privServiceEvents=new r.EventSource,this.privDynamicGrammar=new u.DynamicGrammarBuilder,this.privSpeechContext=new u.SpeechContext(this.privDynamicGrammar),this.privAgentConfig=new u.AgentConfig,this.privRecognizerConfig.parameters.getProperty(i.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?this.privSetTimeout=r.Timeout.setTimeout:(typeof window<"u"&&(this.privSetTimeout=window.setTimeout.bind(window)),typeof globalThis<"u"&&(this.privSetTimeout=globalThis.setTimeout.bind(globalThis))),this.connectionEvents.attach(l=>{if(l.name==="ConnectionClosedEvent"){const v=l;(v.statusCode===1003||v.statusCode===1007||v.statusCode===1002||v.statusCode===4e3||this.privRequestSession.numConnectionAttempts>this.privRecognizerConfig.maxRetryCount)&&this.cancelRecognitionLocal(i.CancellationReason.Error,v.statusCode===1007?i.CancellationErrorCode.BadRequestParameters:i.CancellationErrorCode.ConnectionFailure,`${v.reason} websocket error code: ${v.statusCode}`)}}),this.privEnableSpeakerId&&(this.privDiarizationSessionId=r.createNoDashGuid()),this.setLanguageIdJson(),this.setOutputDetailLevelJson()}setTranslationJson(){const e=this.privRecognizerConfig.parameters.getProperty(i.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0);if(e!==void 0){const s=e.split(","),c=this.privRecognizerConfig.parameters.getProperty(i.PropertyId.SpeechServiceConnection_TranslationVoice,void 0),p=c!==void 0?"Synthesize":"None";if(this.privSpeechContext.setSection("translation",{onSuccess:{action:p},output:{interimResults:{mode:"Always"}},targetLanguages:s}),c!==void 0){const d={};for(const h of s)d[h]=c;this.privSpeechContext.setSection("synthesis",{defaultVoices:d})}}}setSpeechSegmentationTimeoutJson(){const e=this.privRecognizerConfig.parameters.getProperty(i.PropertyId.Speech_SegmentationSilenceTimeoutMs,void 0);if(e!==void 0){const s=this.recognitionMode===u.RecognitionMode.Conversation?"CONVERSATION":this.recognitionMode===u.RecognitionMode.Dictation?"DICTATION":"INTERACTIVE",c=parseInt(e,10),p=this.privSpeechContext.getSection("phraseDetection");p.mode=s,p[s]={segmentation:{mode:"Custom",segmentationSilenceTimeoutMs:c}},this.privSpeechContext.setSection("phraseDetection",p)}}setLanguageIdJson(){const e=this.privSpeechContext.getSection("phraseDetection");if(this.privRecognizerConfig.autoDetectSourceLanguages!==void 0){const c=this.privRecognizerConfig.autoDetectSourceLanguages.split(",");let p;this.privRecognizerConfig.languageIdMode==="Continuous"?p="DetectContinuous":p="DetectAtAudioStart",this.privSpeechContext.setSection("languageId",{Priority:"PrioritizeLatency",languages:c,mode:p,onSuccess:{action:"Recognize"},onUnknown:{action:"None"}}),this.privSpeechContext.setSection("phraseOutput",{interimResults:{resultType:"Auto"},phraseResults:{resultType:"Always"}}
18);const d=this.privRecognizerConfig.sourceLanguageModels;d!==void 0&&(e.customModels=d,e.onInterim={action:"None"},e.onSuccess={action:"None"})}this.privRecognizerConfig.parameters.getProperty(i.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(i.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true"?this.privSpeechContext.setWordLevelTimings():this.privRecognizerConfig.parameters.getProperty(u.OutputFormatPropertyName,i.OutputFormat[i.OutputFormat.Simple]).toLowerCase()===i.OutputFormat[i.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(i.PropertyId.ConversationTranslator_Token,e)}set voiceProfileType(e){this.privRecognizerConfig.parameters.setProperty(i.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,s,c){if(this.recognizeOverride!==void 0){await this.recognizeOverride(e,s,c);return}this.privConnectionConfigurationPromise=void 0,this.privRecognizerConfig.recognitionMode=e,this.setSpeechSegmentationTimeoutJson(),this.setTranslationJson(),this.privSuccessCallback=s,this.privErrorCallback=c,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events);const p=this.connectImpl();let d;try{const v=await this.audioSource.attach(this.privRequestSession.audioNodeId),f=await this.audioSource.format,g=await this.audioSource.deviceInfo;this.privIsLiveAudio=g.type&&g.type===u.type.Microphones,d=new t.ReplayableAudioNode(v,f.avgBytesPerSec),await this.privRequestSession.onAudioSourceAttachCompleted(d,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:g}}
18catch(v){throw await this.privRequestSession.onStopRecognizing(),v}try{await p}catch(v){await this.cancelRecognitionLocal(i.CancellationReason.Error,i.CancellationErrorCode.ConnectionFailure,v);return}const h=new i.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,h),this.receiveMessage(),this.sendAudio(d).catch(async v=>{await this.cancelRecognitionLocal(i.CancellationReason.Error,i.CancellationErrorCode.RuntimeError,v)})}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,s){this.connectImpl().then(()=>{try{e&&e()}catch(c){s&&s(c)}},c=>{try{s&&s(c)}catch{}})}async disconnect(){if(await this.cancelRecognitionLocal(i.CancellationReason.Error,i.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,s){const c=typeof s=="string"?r.MessageType.Text:r.MessageType.Binary,p=typeof s=="string"?"application/json":"";return(await this.fetchConnection()).send(new o.SpeechConnectionMessage(c,e,this.privRequestSession.requestId,p,s))}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set expectContentAssessmentResponse(e){this.privExpectContentAssessmentResponse=e}async sendTelemetryData(){const e=this.privRequestSession.getTelemetry();if(qi.telemetryDataEnabled!==!0||this.privIsDisposed||e===null)return;if(qi.telemetryData)try{qi.telemetryData(e)}catch{}await(await this.fetchConnection()).send(new o.SpeechConnectionMessage(r.MessageType.Text,"telemetry",this.privRequestSession.requestId,"application/json",e))}async cancelRecognitionLocal(e,s,c){this.privRequestSession.isRecognizing&&(await this.privRequestSession.onStopRecognizing(
18),this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,e,s,c))}async receiveMessage(){try{if(this.privIsDisposed)return;let e=await this.fetchConnection();const s=await e.read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(!s)return this.receiveMessage();this.privServiceHasSentMessage=!0;const c=o.SpeechConnectionMessage.fromConnectionMessage(s);if(c.requestId.toLowerCase()===this.privRequestSession.requestId.toLowerCase())switch(c.path.toLowerCase()){case"turn.start":this.privMustReportEndOfStream=!0,this.privRequestSession.onServiceTurnStartResponse();break;case"speech.startdetected":const p=u.SpeechDetected.fromJSON(c.textBody),d=new i.RecognitionEventArgs(p.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,d);break;case"speech.enddetected":let h;c.textBody.length>0?h=c.textBody:h="{ Offset: 0 }";const l=u.SpeechDetected.fromJSON(h),v=new i.RecognitionEventArgs(l.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,v);break;case"turn.end":await this.sendTelemetryData(),this.privRequestSession.isSpeechEnded&&this.privMustReportEndOfStream&&(this.privMustReportEndOfStream=!1,await this.cancelRecognitionLocal(i.CancellationReason.EndOfStream,i.CancellationErrorCode.NoError,void 0));const f=new i.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,f);return}else e=await this.fetchConnection(),await this.sendPrePayloadJSON(e);break;default:await this.processTypeSpecificMessages(c)||this.privServiceEvents&&this.serviceEvents.onEvent(new r.ServiceEvent(c.path.toLowerCase(),c.textBody))}return this.receiveMessage()}catch{return null}}updateSpeakerDiarizationAudioOffset(){const s=this.privRequestSession.recognitionBytesSent/this.privAverageBytesPerMs;this.privSpeechContext.setSpeakerDiarizationAudioOffsetMs(s)}sendSpeechContext(e,s){this.privEnableSpeakerId&&this.updateSpeakerDiarizationAudioOffset();const c=this.speechContext.toJSON();if(s&&this.privRequestSession.onSpeechContext(),c)return e.send(new o.SpeechConnectionMessage(r.MessageType.Text,"speech.context",this.privRequestSession.requestId,"application/json",c))}noOp(){}async sendPrePayloadJSON(e,s=!0){if(this.sendPrePayloadJSONOverride!==void 0)return this.sendPrePayloadJSONOverride(e);await this.sendSpeechContext(e,s),await this.sendWaveHeader(e)}async sendWaveHeader(e){const s=await this.audioSource.format;return e.send(new o.SpeechConnectionMessage(r.MessageType.Binary,"audio",this.privRequestSession.requestId,"audio/x-wav",s.header))}connectImpl(){return this.privConnectionPromise!==void 0?this.privConnectionPromise.then(e=>e.state()===r.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,s,c){if(s.onSpeechContext(),qi.telemetryDataEnabled!==!0){const d={context:{system:JSON.parse(c).context.system}};c=JSON.stringify(d)}if(this.privRecognizerConfig.parameters.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()==="true"){const p=JSON.parse(c);p.context.DisableReferenceChannel="True",p.context.MicSpec="1_0_0",c=JSON.stringify(p)}if(c)return e.send(new o.SpeechConnectionMessage(r.MessageType.Text,"speech.config",s.requestId,"application/json",c))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===r.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async sendAudio(e){const s=await this.audioSource.format;this.privAverageBytesPerMs=s.avgBytesPerSec/1e3;let c=Date.now();const p=this.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs","5000"),d=s.avgBytesPerSec/1e3*parseInt(p,10),h=this.privRequestSession.recogNumber,l=async()=>
18{if(!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===h){const v=await this.fetchConnection(),f=await e.read();if(this.privRequestSession.isSpeechEnded)return;let g,m;if(!f||f.isEnd?(g=null,m=0):(g=f.buffer,this.privRequestSession.onAudioSent(g.byteLength),d>=this.privRequestSession.bytesSent?m=0:m=Math.max(0,c-Date.now())),m!==0&&await this.delay(m),g!==null&&(c=Date.now()+g.byteLength*1e3/(s.avgBytesPerSec*2)),!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===h)if(v.send(new o.SpeechConnectionMessage(r.MessageType.Binary,"audio",this.privRequestSession.requestId,null,g)).catch(()=>{this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition).catch(()=>{})}),f!=null&&f.isEnd)this.privIsLiveAudio||this.privRequestSession.onSpeechEnded();else return l()}};return l()}async retryableConnect(){let e=!1;this.privAuthFetchEventId=r.createNoDashGuid();const s=this.privRequestSession.sessionId;this.privConnectionId=s!==void 0?s:r.createNoDashGuid(),this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId,this.privConnectionId);let c=0,p="";for(;this.privRequestSession.numConnectionAttempts<=this.privRecognizerConfig.maxRetryCount;){const h=await(e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId));await this.privRequestSession.onAuthCompleted(!1);const l=this.privConnectionFactory.create(this.privRecognizerConfig,h,this.privConnectionId);this.privRequestSession.listenForServiceTelemetry(l.events),l.events.attach(f=>{this.connectionEvents.onEvent(f)});const v=await l.open();if(v.statusCode===200)return await this.privRequestSession.onConnectionEstablishCompleted(v.statusCode),Promise.resolve(l);v.statusCode===1006&&(e=!0),c=v.statusCode,p=v.reason,this.privRequestSession.onRetryConnection()}return await this.privRequestSession.onConnectionEstablishCompleted(c,p),Promise.reject(`Unable to contact server. StatusCode: ${c}, ${this.privRecognizerConfig.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${p}`)}delay(e){return new Promise(s=>this.privSetTimeout(s,e))}writeBufferToConsole(e){let s="Buffer Size: ";if(e===null)s+="null";else{const c=new Uint8Array(e);s+=`${e.byteLength}\r
19`;for(let p=0;p<e.byteLength;p++)s+=c[p].toString(16).padStart(2,"0")+" ",(p+1)%16===0&&(console.info(s),s="")}console.info(s)}async sendFinalAudio(){await(await this.fetchConnection()).send(new o.SpeechConnectionMessage(r.MessageType.Binary,"audio",this.privRequestSession.requestId,null,null))}async configureConnection(){const 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)}};return Fr.ServiceRecognizerBase=a,a.telemetryDataEnabled=!0,Fr}var Wr={},ru;function mf(){if(ru)return Wr;ru=1,Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.ConversationServiceRecognizer=void 0;const t=y(),r=E();let i=class extends r.ServiceRecognizerBase{constructor(o,a,n,e,s){super(o,a,n,e,s),this.handleSpeechPhraseMessage=async c=>this.handleSpeechPhrase(c),this.handleSpeechHypothesisMessage=c=>this.handleSpeechHypothesis(c)}processTypeSpecificMessages(o){}handleRecognizedCallback(o,a,n){}handleRecognizingCallback(o,a,n){}async processSpeechMessages(o){let a=!1;switch(o.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":this.handleSpeechHypothesisMessage&&this.handleSpeechHypothesisMessage(o.textBody),a=!0;break;case"speech.phrase":this.handleSpeechPhraseMessage&&await this.handleSpeechPhraseMessage(o.textBody),a=!0;break}return a}cancelRecognition(o,a,n,e,s){}async handleSpeechPhrase(o){const a=r.SimpleSpeechPhrase.fromJSON(o),n=r.EnumTranslation.implTranslateRecognitionResult(a.RecognitionStatus);let e;const s=new t.PropertyCollection;s.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult,o);const c=a.Offset+this.privRequestSession.currentTurnAudioOffset;let p=c;if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+a.Offset+a.Duration),t.ResultReason.Canceled===n){const d=r.EnumTranslation.implTranslateCancelResult(a.RecognitionStatus),h=r.EnumTranslation.implTranslateCancelErrorCode(a.RecognitionStatus);await this.cancelRecognitionLocal(d,h,r.EnumTranslation.implTranslateErrorDetails(h))}else if(!(this.privRequestSession.isSpeechEnded&&n===t.ResultReason.NoMatch&&a.RecognitionStatus!==r.RecognitionStatus.InitialSilenceTimeout)){
19if(this.privRecognizerConfig.parameters.getProperty(r.OutputFormatPropertyName)===t.OutputFormat[t.OutputFormat.Simple])e=new t.SpeechRecognitionResult(this.privRequestSession.requestId,n,a.DisplayText,a.Duration,c,a.Language,a.LanguageDetectionConfidence,a.SpeakerId,void 0,o,s);else{const d=r.DetailedSpeechPhrase.fromJSON(o),h=d.Offset+this.privRequestSession.currentTurnAudioOffset,l=d.getJsonWithCorrectedOffsets(h);e=new t.SpeechRecognitionResult(this.privRequestSession.requestId,n,d.Text,d.Duration,h,d.Language,d.LanguageDetectionConfidence,d.SpeakerId,void 0,l,s),p=e.offset}this.handleRecognizedCallback(e,p,this.privRequestSession.sessionId)}}handleSpeechHypothesis(o){const a=r.SpeechHypothesis.fromJSON(o),n=a.Offset+this.privRequestSession.currentTurnAudioOffset,e=new t.PropertyCollection;e.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult,o);const s=new t.SpeechRecognitionResult(this.privRequestSession.requestId,t.ResultReason.RecognizingSpeech,a.Text,a.Duration,n,a.Language,a.LanguageDetectionConfidence,a.SpeakerId,void 0,o,e);this.privRequestSession.onHypothesis(n),this.handleRecognizingCallback(s,a.Duration,this.privRequestSession.sessionId)}};return Wr.ConversationServiceRecognizer=i,Wr}var Un={},iu;function Sf(){return iu||(iu=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.RecognizerConfig=t.SpeechResultFormat=t.RecognitionMode=void 0;const r=y(),i=E();var u;(function(a){a[a.Interactive=0]="Interactive",a[a.Conversation=1]="Conversation",a[a.Dictation=2]="Dictation"})(u=t.RecognitionMode||(t.RecognitionMode={})),(function(a){a[a.Simple=0]="Simple",a[a.Detailed=1]="Detailed"})(t.SpeechResultFormat||(t.SpeechResultFormat={}));class o{constructor(n,e){this.privSpeechServiceConfig=n||new i.SpeechServiceConfig(new i.Context(null)),this.privParameters=e,this.privMaxRetryCount=parseInt(e.getProperty("SPEECH-Error-MaxRetryCount","4"),10),this.privLanguageIdMode=e.getProperty(r.PropertyId.SpeechServiceConnection_LanguageIdMode,void 0),this.privEnableSpeakerId=!1}get parameters(){return this.privParameters}get recognitionMode(){return this.privRecognitionMode}set recognitionMode(n){this.privRecognitionMode=n,this.privRecognitionActivityTimeout=n===u.Interactive?8e3:25e3,this.privSpeechServiceConfig.Recognition=u[n]}get SpeechServiceConfig(){return this.privSpeechServiceConfig}get recognitionActivityTimeout(){return this.privRecognitionActivityTimeout}get isContinuousRecognition(){return this.privRecognitionMode!==u.Interactive}get languageIdMode(){return this.privLanguageIdMode}get autoDetectSourceLanguages(){return this.parameters.getProperty(r.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,void 0)}get recognitionEndpointVersion(){return this.parameters.getProperty(r.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,void 0)}get sourceLanguageModels(){const n=[];let e=!1;if(this.autoDetectSourceLanguages!==void 0)for(const s of this.autoDetectSourceLanguages.split(",")){const c=s+r.PropertyId.SpeechServiceConnection_EndpointId.toString(),p=this.parameters.getProperty(c,void 0);p!==void 0?(n.push({language:s,endpoint:p}),e=!0):n.push({language:s,endpoint:""})}return e?n:void 0}get maxRetryCount(){return this.privMaxRetryCount}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}set isSpeakerDiarizationEnabled(n){this.privEnableSpeakerId=n}}t.RecognizerConfig=o})(Un)),Un}var Wn={},nu;function Cf(){return nu||(nu=1,Object.defineProperty(Wn,"__esModule",{value:!0})),Wn}var Hr={},su;function yf(){if(su)return Hr;su=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.WebsocketMessageFormatter=void 0;const t=I(),r=`\r
20`;let i=class{toConnectionMessage(o){const a=new t.Deferred;try{if(o.messageType===t.MessageType.Text){const n=o.textContent;let e={},s=null;if(n){const c=n.split(`\r
21\r
22`);c&&c.length>0&&(e=this.parseHeaders(c[0]),c.length>1&&(s=c[1]))}a.resolve(new t.ConnectionMessage(o.messageType,s,e,o.id))}else if(o.messageType===t.MessageType.Binary){const n=o.binaryContent;let e={},s=null;if(!n||n.byteLength<2)throw new Error("Invalid binary message format. Header length missing.");const c=new DataView(n),p=c.getInt16(0);if(n.byteLength<p+2)throw new Error("Invalid binary message format. Header content missing.");let d="";for(let h=0;h<p;h++)d+=String.fromCharCode(c.getInt8(h+2));e=this.parseHeaders(d),n.byteLength>p+2&&(s=n.slice(2+p)),a.resolve(new t.ConnectionMessage(o.messageType,s,e,o.id))}}catch(n){a.reject(`Error formatting the message. Error: ${n}`)}return a.promise}fromConnectionMessage(o){const a=new t.Deferred;try{if(o.messageType===t.MessageType.Text){const n=`${this.makeHeaders(o)}${r}${o.textBody?o.textBody:""}`;a.resolve(new t.RawWebsocketMessage(t.MessageType.Text,n,o.id))}else if(o.messageType===t.MessageType.Binary){const n=this.makeHeaders(o),e=o.binaryBody,s=this.stringToArrayBuffer(n),c=new Int8Array(s),p=c.byteLength,d=new Int8Array(2+p+(e?e.byteLength:0));if(d[0]=p>>8&255,d[1]=p&255,d.set(c,2),e){const l=new Int8Array(e);d.set(l,2+p)}const h=d.buffer;a.resolve(new t.RawWebsocketMessage(t.MessageType.Binary,h,o.id))}}catch(n){a.reject(`Error formatting the message. ${n}`)}return a.promise}makeHeaders(o){let a="";if(o.headers)for(const n in o.headers)n&&(a+=`${n}: ${o.headers[n]}${r}`);return a}parseHeaders(o){const a={};if(o){const n=o.match(/[^\r\n]+/g);if(a){for(const e of n)if(e){const s=e.indexOf(":"),c=s>0?e.substr(0,s).trim().toLowerCase():e,p=s>0&&e.length>s+1?e.substr(s+1).trim():"";a[c]=p}}}return a}stringToArrayBuffer(o){const a=new ArrayBuffer(o.length),n=new DataView(a);for(let e=0;e<o.length;e++)n.setUint8(e,o.charCodeAt(e));return a}};return Hr.WebsocketMessageFormatter=i,Hr}var Vr={},ou;function Rf(){if(ou)return Vr;
22ou=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.SpeechConnectionFactory=void 0;const t=D(),r=E(),i=y(),u=H(),o=E(),a=N(),n=Y();let e=class extends u.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(c,p,d){let h=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Endpoint,void 0);const l=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Region,void 0),v=u.ConnectionFactoryBase.getHostSuffix(l),f=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Host,"wss://"+l+".stt.speech"+v),g={},m=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_EndpointId,void 0),S=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(m?(!h||h.search(n.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(g[n.QueryParameterNames.CustomSpeechDeploymentId]=m):S&&(!h||h.search(n.QueryParameterNames.Language)===-1)&&(g[n.QueryParameterNames.Language]=S),(!h||h.search(n.QueryParameterNames.Format)===-1)&&(g[n.QueryParameterNames.Format]=c.parameters.getProperty(r.OutputFormatPropertyName,i.OutputFormat[i.OutputFormat.Simple]).toLowerCase()),c.autoDetectSourceLanguages!==void 0&&(g[n.QueryParameterNames.EnableLanguageId]="true"),this.setCommonUrlParams(c,g,h),!h)switch(c.recognitionMode){case o.RecognitionMode.Conversation:c.parameters.getProperty(r.ForceDictationPropertyName,"false")==="true"?h=f+this.dictationRelativeUri:c.recognitionEndpointVersion!==void 0&&parseInt(c.recognitionEndpointVersion,10)>1?h=`${f}${this.universalUri}${c.recognitionEndpointVersion}`:h=f+this.conversationRelativeUri;break;case o.RecognitionMode.Dictation:h=f+this.dictationRelativeUri;break;default:c.recognitionEndpointVersion!==void 0&&parseInt(c.recognitionEndpointVersion,10)>1?h=`${f}${this.universalUri}${c.recognitionEndpointVersion}`:h=f+this.interactiveRelativeUri;break}const C={};p.token!==void 0&&p.token!==""&&(C[p.headerName]=p.token),C[a.HeaderNames.ConnectionId]=d;const R=c.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",P=new t.WebsocketConnection(h,g,C,new o.WebsocketMessageFormatter,t.ProxyInfo.fromRecognizerConfig(c),R,d),A=P.uri;return c.parameters.setProperty(i.PropertyId.SpeechServiceConnection_Url,A),P}};return Vr.SpeechConnectionFactory=e,Vr}var $r={},au;function Pf(){if(au)return $r;au=1,Object.defineProperty($r,"__esModule",{value:!0}),$r.ConversationTranscriberConnectionFactory=void 0;const t=D(),r=y(),i=E(),u=H(),o=E(),a=N(),n=Y();let e=class extends u.ConnectionFactoryBase{constructor(){super(...arguments),this.universalUri="/speech/universal/v2"}create(c,p,d){let h=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint,void 0);const l=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Region,void 0),v=u.ConnectionFactoryBase.getHostSuffix(l),f=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host,"wss://"+l+".stt.speech"+v),g={},m=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_EndpointId,void 0),S=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);m?(!h||h.search(n.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(g[n.QueryParameterNames.CustomSpeechDeploymentId]=m):S&&(!h||h.search(n.QueryParameterNames.Language)===-1)&&(g[n.QueryParameterNames.Language]=S),c.autoDetectSourceLanguages!==void 0&&(g[n.QueryParameterNames.EnableLanguageId]="true"),this.setV2UrlParams(c,g,h),h||(h=`${f}${this.universalUri}`);const C={};p.token!==void 0&&p.token!==""&&(C[p.headerName]=p.token),C[a.HeaderNames.ConnectionId]=d;const R=c.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",P=new t.WebsocketConnection(h,g,C,new o.WebsocketMessageFormatter,t.ProxyInfo.fromRecognizerConfig(c),R,d),A=P.uri;return c.parameters.setProperty(r.PropertyId.SpeechServiceConnection_Url,A),P}setV2UrlParams(c,p,d){new Map([[r.PropertyId.Speech_SegmentationSilenceTimeoutMs,n.QueryParameterNames.SegmentationSilenceTimeoutMs],[r.PropertyId.SpeechServiceConnection_EnableAudioLogging,n.QueryParameterNames.EnableAudioLogging],[r.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,n.QueryParameterNames.EndSilenceTimeoutMs],[r.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,n.QueryParameterNames.InitialSilenceTimeoutMs],[r.PropertyId.SpeechServiceResponse_PostProcessingOption,n.QueryParameterNames.Postprocessing],[r.PropertyId.SpeechServiceResponse_ProfanityOption,n.QueryParameterNames.Profanity],[r.PropertyId.SpeechServiceResponse_StableParti
22alResultThreshold,n.QueryParameterNames.StableIntermediateThreshold]]).forEach((v,f)=>{this.setUrlParameter(f,v,c,p,d)});const l=JSON.parse(c.parameters.getProperty(i.ServicePropertiesPropertyName,"{}"));Object.keys(l).forEach(v=>{p[v]=l[v]})}};return $r.ConversationTranscriberConnectionFactory=e,$r}var Kr={},cu;function Ef(){if(cu)return Kr;cu=1,Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.TranscriberConnectionFactory=void 0;const t=D(),r=y(),i=H(),u=E(),o=N(),a=Y();let n=class extends i.ConnectionFactoryBase{constructor(){super(...arguments),this.multiaudioRelativeUri="/speech/recognition/multiaudio"}create(s,c,p){let d=s.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint,void 0);const h=s.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Region,"centralus"),l=i.ConnectionFactoryBase.getHostSuffix(h),v="wss://transcribe."+h+".cts.speech"+l+this.multiaudioRelativeUri,f=s.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host,v),g={};this.setQueryParams(g,s,d),d||(d=f);const m={};c.token!==void 0&&c.token!==""&&(m[c.headerName]=c.token),m[o.HeaderNames.ConnectionId]=p,s.parameters.setProperty(r.PropertyId.SpeechServiceConnection_Url,d);const S=s.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new t.WebsocketConnection(d,g,m,new u.WebsocketMessageFormatter,t.ProxyInfo.fromRecognizerConfig(s),S,p)}setQueryParams(s,c,p){const d=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_EndpointId,void 0),h=c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);d&&!(a.QueryParameterNames.CustomSpeechDeploymentId in s)&&(s[a.QueryParameterNames.CustomSpeechDeploymentId]=d),h&&!(a.QueryParameterNames.Language in s)&&(s[a.QueryParameterNames.Language]=h);const l=c.parameters.getProperty(r.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true",v=c.parameters.getProperty(u.OutputFormatPropertyName,r.OutputFormat[r.OutputFormat.Simple])!==r.OutputFormat[r.OutputFormat.Simple];(l||v)&&(s[a.QueryParameterNames.Format]=r.OutputFormat[r.OutputFormat.Detailed].toLowerCase()),this.setCommonUrlParams(c,s,p)}};return Kr.TranscriberConnectionFactory=n,Kr}var Jr={},uu;function If(){if(uu)return Jr;uu=1,Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.TranslationConnectionFactory=void 0;const t=D(),r=Gp(),i=y(),u=H(),o=E(),a=N(),n=Y();let e=class extends u.ConnectionFactoryBase{create(c,p,d){const h=this.getEndpointUrl(c),l={};c.autoDetectSourceLanguages!==void 0&&(l[n.QueryParameterNames.EnableLanguageId]="true"),this.setQueryParams(l,c,h);const v={};p.token!==void 0&&p.token!==""&&(v[p.headerName]=p.token),v[a.HeaderNames.ConnectionId]=d,c.parameters.setProperty(i.PropertyId.SpeechServiceConnection_Url,h);const f=c.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new t.WebsocketConnection(h,l,v,new o.WebsocketMessageFormatter,t.ProxyInfo.fromRecognizerConfig(c),f,d)}getEndpointUrl(c,p){const d=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Region),h=u.ConnectionFactoryBase.getHostSuffix(d);let l=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Endpoint,void 0);return l||(c.autoDetectSourceLanguages!==void 0?l=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Host,"wss://{region}.stt.speech"+h)+"/speech/universal/v2":l=c.parameters.getProperty(i.PropertyId.SpeechServiceConnection_Host,"wss://{region}.s2s.speech"+h)+"/speech/translation/cognitiveservices/v1"),p===!0?l:r.StringUtils.formatString(l,{region:d})}setQueryParams(c,p,d){c.from=p.parameters.getProperty(i.PropertyId.SpeechServiceConnection_RecoLanguage),c.to=p.parameters.getProperty(i.PropertyId.SpeechServiceConnection_TranslationToLanguages),c.scenario=p.recognitionMode===o.RecognitionMode.Interactive?"interactive":p.recognitionMode===o.RecognitionMode.Conversation?"conversation":"",this.setCommonUrlParams(p,c,d),this.setUrlParameter(i.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,n.QueryParameterNames.StableTranslation,p,c,d);const h=p.parameters.getProperty(i.PropertyId.SpeechServiceConnection_TranslationVoice,void 0);h!==void 0&&(c.voice=h,c.features="texttospeech")}};return Jr.TranslationConnectionFactory=e,Jr}var Gr={},pu;function Tf(){if(pu)return Gr;
22pu=1,Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.EnumTranslation=void 0;const t=y(),r=E();let i=class{static implTranslateRecognitionResult(o,a=!1){let n=t.ResultReason.Canceled;switch(o){case r.RecognitionStatus.Success:n=t.ResultReason.RecognizedSpeech;break;case r.RecognitionStatus.EndOfDictation:n=a?t.ResultReason.RecognizedSpeech:t.ResultReason.NoMatch;break;case r.RecognitionStatus.NoMatch:case r.RecognitionStatus.InitialSilenceTimeout:case r.RecognitionStatus.BabbleTimeout:n=t.ResultReason.NoMatch;break;case r.RecognitionStatus.Error:case r.RecognitionStatus.BadRequest:case r.RecognitionStatus.Forbidden:default:n=t.ResultReason.Canceled;break}return n}static implTranslateCancelResult(o){let a=t.CancellationReason.EndOfStream;switch(o){case r.RecognitionStatus.Success:case r.RecognitionStatus.EndOfDictation:case r.RecognitionStatus.NoMatch:a=t.CancellationReason.EndOfStream;break;case r.RecognitionStatus.InitialSilenceTimeout:case r.RecognitionStatus.BabbleTimeout:case r.RecognitionStatus.Error:case r.RecognitionStatus.BadRequest:case r.RecognitionStatus.Forbidden:default:a=t.CancellationReason.Error;break}return a}static implTranslateCancelErrorCode(o){let a=t.CancellationErrorCode.NoError;switch(o){case r.RecognitionStatus.Error:a=t.CancellationErrorCode.ServiceError;break;case r.RecognitionStatus.TooManyRequests:a=t.CancellationErrorCode.TooManyRequests;break;case r.RecognitionStatus.BadRequest:a=t.CancellationErrorCode.BadRequestParameters;break;case r.RecognitionStatus.Forbidden:a=t.CancellationErrorCode.Forbidden;break;default:a=t.CancellationErrorCode.NoError;break}return a}static implTranslateErrorDetails(o){let a="The speech service encountered an internal error and could not continue.";switch(o){case t.CancellationErrorCode.Forbidden:a="The recognizer is using a free subscription that ran out of quota.";break;case t.CancellationErrorCode.BadRequestParameters:a="Invalid parameter or unsupported audio format in the request.";break;case t.CancellationErrorCode.TooManyRequests:a="The number of parallel requests exceeded the number of allowed concurrent transcriptions.";break}return a}};return Gr.EnumTranslation=i,Gr}var Hn={},du;function Af(){return du||(du=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.RecognitionStatus=t.SynthesisStatus=void 0,(function(r){r[r.Success=0]="Success",r[r.SynthesisEnd=1]="SynthesisEnd",r[r.Error=2]="Error"})(t.SynthesisStatus||(t.SynthesisStatus={})),(function(r){r[r.Success=0]="Success",r[r.NoMatch=1]="NoMatch",r[r.InitialSilenceTimeout=2]="InitialSilenceTimeout",r[r.BabbleTimeout=3]="BabbleTimeout",r[r.Error=4]="Error",r[r.EndOfDictation=5]="EndOfDictation",r[r.TooManyRequests=6]="TooManyRequests",r[r.BadRequest=7]="BadRequest",r[r.Forbidden=8]="Forbidden"})(t.RecognitionStatus||(t.RecognitionStatus={}))})(Hn)),Hn}var Qr={},hu;function wf(){if(hu)return Qr;hu=1,Object.defineProperty(Qr,"__esModule",{value:!0}),Qr.TranslationSynthesisEnd=void 0;const t=E();let r=class sd{constructor(u){this.privSynthesisEnd=JSON.parse(u),this.privSynthesisEnd.SynthesisStatus&&(this.privSynthesisEnd.SynthesisStatus=t.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]),this.privSynthesisEnd.Status&&(this.privSynthesisEnd.SynthesisStatus=t.SynthesisStatus[this.privSynthesisEnd.Status])}static fromJSON(u){return new sd(u)}get SynthesisStatus(){return this.privSynthesisEnd.SynthesisStatus}get FailureReason(){return this.privSynthesisEnd.FailureReason}};return Qr.TranslationSynthesisEnd=r,Qr}var Xr={},lu;function _f(){if(lu)return Xr;lu=1,Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.TranslationHypothesis=void 0;const t=T(),r=cs();let i=class ss{constructor(o){this.privTranslationHypothesis=o,this.privTranslationHypothesis.Translation.TranslationStatus=r.TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus]}static fromJSON(o){return new ss(JSON.parse(o))}static fromTranslationResponse(o){t.Contracts.throwIfNullOrUndefined(o,"translationHypothesis");const a=o.SpeechHypothesis;return o.SpeechHypothesis=void 0,a.Translation=o,new ss(a)}get Duration(){return this.privTranslationHypothesis.Duration}
22get Offset(){return this.privTranslationHypothesis.Offset}get Text(){return this.privTranslationHypothesis.Text}get Translation(){return this.privTranslationHypothesis.Translation}get Language(){var o;return(o=this.privTranslationHypothesis.PrimaryLanguage)==null?void 0:o.Language}};return Xr.TranslationHypothesis=i,Xr}var Zr={},vu;function bf(){if(vu)return Zr;vu=1,Object.defineProperty(Zr,"__esModule",{value:!0}),Zr.TranslationPhrase=void 0;const t=T(),r=E(),i=cs();let u=class os{constructor(a){this.privTranslationPhrase=a,this.privTranslationPhrase.RecognitionStatus=r.RecognitionStatus[this.privTranslationPhrase.RecognitionStatus],this.privTranslationPhrase.Translation!==void 0&&(this.privTranslationPhrase.Translation.TranslationStatus=i.TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus])}static fromJSON(a){return new os(JSON.parse(a))}static fromTranslationResponse(a){t.Contracts.throwIfNullOrUndefined(a,"translationResponse");const n=a.SpeechPhrase;return a.SpeechPhrase=void 0,n.Translation=a,n.Text=n.DisplayText,new os(n)}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(){var a;return(a=this.privTranslationPhrase.PrimaryLanguage)==null?void 0:a.Language}get Confidence(){var a;return(a=this.privTranslationPhrase.PrimaryLanguage)==null?void 0:a.Confidence}get Translation(){return this.privTranslationPhrase.Translation}};return Zr.TranslationPhrase=u,Zr}var Yr={},fu;function Mf(){if(fu)return Yr;fu=1,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.TranslationServiceRecognizer=void 0;const t=I(),r=y(),i=E();let u=class extends i.ConversationServiceRecognizer{constructor(a,n,e,s,c){super(a,n,e,s,c),this.privTranslationRecognizer=c,this.connectionEvents.attach(p=>{p.name==="ConnectionEstablishedEvent"&&this.privTranslationRecognizer.onConnection()})}async processTypeSpecificMessages(a){const n=new r.PropertyCollection;let e=await this.processSpeechMessages(a);if(e)return!0;const s=async p=>{if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+p.Offset+p.Duration),p.RecognitionStatus===i.RecognitionStatus.Success){const d=this.fireEventForResult(p,n);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,d)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(d.result)}catch(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}else{const d=i.EnumTranslation.implTranslateRecognitionResult(p.RecognitionStatus),h=new r.TranslationRecognitionResult(void 0,this.privRequestSession.requestId,d,p.Text,p.Duration,this.privRequestSession.currentTurnAudioOffset+p.Offset,p.Language,p.Confidence,void 0,a.textBody,n);if(d===r.ResultReason.Canceled){const l=i.EnumTranslation.implTranslateCancelResult(p.RecognitionStatus),v=i.EnumTranslation.implTranslateCancelErrorCode(p.RecognitionStatus);await this.cancelRecognitionLocal(l,v,i.EnumTranslation.implTranslateErrorDetails(v))}else{if(!(this.privRequestSession.isSpeechEnded&&d===r.ResultReason.NoMatch&&p.RecognitionStatus!==i.RecognitionStatus.InitialSilenceTimeout)){const l=new r.TranslationRecognitionEventArgs(h,h.offset,this.privRequestSession.sessionId);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,l)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(h)}catch(l){this.privErrorCallback&&this.privErrorCallback(l)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}e=!0}},c=(p,d)=>{const h=this.fireEventForResult(p,d);if(this.privRequestSession.onHypothesis(this.privRequestSession.currentTurnAudioOffset+h.offset),this.privTranslationRecognizer.recognizing)try{this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,h)}catch{}e=!0};switch(a.messageType===t.MessageType.Text&&n.setProperty(r.PropertyId.SpeechServiceResponse_JsonResult,a.textBody),a.path.toLowerCase()){case"translation.hypothesis":c(i.TranslationHypothesis.fromJSON(a.textBody),n);break;case"translation.response":const p=JSON.parse(a.textBody);if(p.SpeechPhrase)await s(i.TranslationPhrase.fromTranslationResponse(p));else{const h=JSON.parse(a.textBody);h.SpeechHypothesis&&c(i.TranslationHypothesis.fromTranslationResponse(h),n)}break;case"translation.phrase":await s(i.TranslationPhrase.fromJSON(a.textBody));break;case"translation.synthesis":this.sendSynthesisAudio(a.binaryBody,this.privRequestSession.sessionId),e=!0;break;case"audio.end":case"translation.synthesis.end":const d=i.TranslationSynthesisEnd.fromJSON(a.textBody);switch(d.SynthesisStatus){case i.SynthesisStatus.Error:if(this.privTranslationRecognizer.synthesizing){const h=new r.TranslationSynthesisResult(r.ResultReason.Canceled,void 0),l=new r.TranslationSynthesisEventArgs(h,this.privRequestSession.sessionId);try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,l)}catch{}}if(this.privTranslationRecognizer.canceled){const h=new r.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId,r.CancellationReason.Error,d.FailureReason,r.CancellationErrorCode.ServiceError,null);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,h)}catch{}}break;case i.SynthesisStatus.Success:this.sendSynthesisAudio(void 0,this.privRequestSession.sessionId);break}e=!0;break}return e}cancelRecognition(a,n,e,s,c){const p=new r.PropertyCollection;if(p.setProperty(i.CancellationErrorCodePropertyName,r.CancellationErrorCode[s]),this.privTranslationRecognizer.canceled){const d=new r.TranslationRecognitionCanceledEventArgs(a,e,c,s,void 0);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,d)}catch{}}if(this.privSuccessCallback){const d=new r.TranslationRecognitionResult(void 0,n,r.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,c,void 0,p);try{this.privSuccessCallback(d),this.privSuccessCallback=void 0}catch{}}}handleRecognizingCallback(a,n,e){try{const s=new r.TranslationRecognitionEventArgs(r.TranslationRecognitionResult.fromSpeechRecognitionResult(a),n,e);this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,s)}catch{}}handleRecognizedCallback(a,n,e){try{const s=new r.TranslationRecognitionEventArgs(r.TranslationRecognitionResult.fromSpeechRecognitionResult(a),n,e);this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,s)}catch{}}fireEventForResult(a,n){let e;if(a.Translation.Translations!==void 0){e=new r.Translations;for(const v of a.Translation.Translations)e.set(v.Language,v.Text||v.DisplayText)}let s,c;a instanceof i.TranslationPhrase?(a.Translation&&a.Translation.TranslationStatus===t.TranslationStatus.Success?s=r.Re
22sultReason.TranslatedSpeech:s=r.ResultReason.RecognizedSpeech,c=a.Confidence):s=r.ResultReason.TranslatingSpeech;const p=a.Language,d=a.Offset+this.privRequestSession.currentTurnAudioOffset,h=new r.TranslationRecognitionResult(e,this.privRequestSession.requestId,s,a.Text,a.Duration,d,p,c,a.Translation.FailureReason,JSON.stringify(a),n);return new r.TranslationRecognitionEventArgs(h,d,this.privRequestSession.sessionId)}sendSynthesisAudio(a,n){const e=a===void 0?r.ResultReason.SynthesizingAudioCompleted:r.ResultReason.SynthesizingAudio,s=new r.TranslationSynthesisResult(e,a),c=new r.TranslationSynthesisEventArgs(s,n);if(this.privTranslationRecognizer.synthesizing)try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,c)}catch{}}};return Yr.TranslationServiceRecognizer=u,Yr}var ei={},gu;function Of(){if(gu)return ei;gu=1,Object.defineProperty(ei,"__esModule",{value:!0}),ei.SpeechDetected=void 0;let t=class od{constructor(i){this.privSpeechStartDetected=JSON.parse(i)}static fromJSON(i){return new od(i)}get Offset(){return this.privSpeechStartDetected.Offset}};return ei.SpeechDetected=t,ei}var ti={},mu;function Df(){if(mu)return ti;mu=1,Object.defineProperty(ti,"__esModule",{value:!0}),ti.SpeechHypothesis=void 0;let t=class ad{constructor(i){this.privSpeechHypothesis=JSON.parse(i)}static fromJSON(i){return new ad(i)}get Text(){return this.privSpeechHypothesis.Text}
22get 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}};return ti.SpeechHypothesis=t,ti}var ri={},Su;function kf(){if(Su)return ri;Su=1,Object.defineProperty(ri,"__esModule",{value:!0}),ri.SpeechKeyword=void 0;let t=class cd{constructor(i){this.privSpeechKeyword=JSON.parse(i)}static fromJSON(i){return new cd(i)}get Status(){return this.privSpeechKeyword.Status}get Text(){return this.privSpeechKeyword.Text}get Offset(){return this.privSpeechKeyword.Offset}get Duration(){return this.privSpeechKeyword.Duration}};return ri.SpeechKeyword=t,ri}var ii={},Cu;function Nf(){if(Cu)return ii;Cu=1,Object.defineProperty(ii,"__esModule",{value:!0}),ii.SpeechServiceRecognizer=void 0;const t=y(),r=E();let i=class extends r.ServiceRecognizerBase{constructor(o,a,n,e,s){super(o,a,n,e,s),this.privSpeechRecognizer=s}async processTypeSpecificMessages(o){let a;const n=new t.PropertyCollection;n.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult,o.textBody);let e=!1;switch(o.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":const s=r.SpeechHypothesis.fromJSON(o.textBody),c=s.Off
22set+this.privRequestSession.currentTurnAudioOffset;a=new t.SpeechRecognitionResult(this.privRequestSession.requestId,t.ResultReason.RecognizingSpeech,s.Text,s.Duration,c,s.Language,s.LanguageDetectionConfidence,void 0,void 0,o.textBody,n),this.privRequestSession.onHypothesis(c);const p=new t.SpeechRecognitionEventArgs(a,s.Duration,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognizing)try{this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer,p)}catch{}e=!0;break;case"speech.phrase":const d=r.SimpleSpeechPhrase.fromJSON(o.textBody),h=r.EnumTranslation.implTranslateRecognitionResult(d.RecognitionStatus,this.privExpectContentAssessmentResponse);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+d.Offset+d.Duration),t.ResultReason.Canceled===h){const l=r.EnumTranslation.implTranslateCancelResult(d.RecognitionStatus),v=r.EnumTranslation.implTranslateCancelErrorCode(d.RecognitionStatus);await this.cancelRecognitionLocal(l,v,r.EnumTranslation.implTranslateErrorDetails(v))}else{if(!(this.privRequestSession.isSpeechEnded&&h===t.ResultReason.NoMatch&&d.RecognitionStatus!==r.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(r.OutputFormatPropertyName)===t.OutputFormat[t.OutputFormat.Simple])a=new t.SpeechRecognitionResult(this.privRequestSession.requestId,h,d.DisplayText,d.Duration,d.Offset+this.privRequestSession.currentTurnAudioOffset,d.Language,d.LanguageDetectionConfidence,void 0,void 0,o.textBody,n);else{const v=r.DetailedSpeechPhrase.fromJSON(o.textBody),f=v.Offset+this.privRequestSession.currentTurnAudioOffset,g=v.getJsonWithCorrectedOffsets(f);a=new t.SpeechRecognitionResult(this.privRequestSession.requestId,h,v.RecognitionStatus===r.RecognitionStatus.Success?v.NBest[0].Display:void 0,v.Duration,f,v.Language,v.LanguageDetectionConfidence,void 0,void 0,g,n)}const l=new t.SpeechRecognitionEventArgs(a,a.offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognized)try{this.privSpeechRecognizer.recognized(this.privSpeechRecognizer,l)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(a)}catch(l){this.privErrorCallback&&this.privErrorCallback(l)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}e=!0;break}return e}cancelRecognition(o,a,n,e,s){const c=new t.PropertyCollection;if(c.setProperty(r.CancellationErrorCodePropertyName,t.CancellationErrorCode[e]),this.privSpeechRecognizer.canceled){const p=new t.SpeechRecognitionCanceledEventArgs(n,s,e,void 0,o);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,p)}catch{}}if(this.privSuccessCallback){const p=new t.SpeechRecognitionResult(a,t.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,c);try{this.privSuccessCallback(p),this.privSuccessCallback=void 0}catch{}}}};return ii.SpeechServiceRecognizer=i,ii}var ni={},yu;function zf(){if(yu)return ni;yu=1,Object.defineProperty(ni,"__esModule",{value:!0}),ni.ConversationTranscriptionServiceRecognizer=void 0;const t=y(),r=E();let i=class extends r.ServiceRecognizerBase{constructor(o,a,n,e,s){super(o,a,n,e,s),this.privConversationTranscriber=s,this.setSpeakerDiarizationJson()}setSpeakerDiarizationJson(){if(this.privEnableSpeakerId){const o=this.privSpeechContext.getSection("phraseDetection");o.mode="Conversation";const a={};a.mode="Anonymous",a.audioSessionId=this.privDiarizationSessionId,a.audioOffsetMs=0,o.speakerDiarization=a,this.privSpeechContext.setSection("phraseDetection",o)}}async processTypeSpecificMessages(o){let a;const n=new t.PropertyCollection;n.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult,o.textBody);let e=!1;switch(o.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":const s=r.SpeechHypothesis.fromJSON(o.textBody),c=s.Off
22set+this.privRequestSession.currentTurnAudioOffset;a=new t.ConversationTranscriptionResult(this.privRequestSession.requestId,t.ResultReason.RecognizingSpeech,s.Text,s.Duration,c,s.Language,s.LanguageDetectionConfidence,void 0,void 0,o.textBody,n),this.privRequestSession.onHypothesis(c);const p=new t.ConversationTranscriptionEventArgs(a,s.Duration,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribing)try{this.privConversationTranscriber.transcribing(this.privConversationTranscriber,p)}catch{}e=!0;break;case"speech.phrase":const d=r.SimpleSpeechPhrase.fromJSON(o.textBody),h=r.EnumTranslation.implTranslateRecognitionResult(d.RecognitionStatus);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+d.Offset+d.Duration),t.ResultReason.Canceled===h){const l=r.EnumTranslation.implTranslateCancelResult(d.RecognitionStatus),v=r.EnumTranslation.implTranslateCancelErrorCode(d.RecognitionStatus);await this.cancelRecognitionLocal(l,v,r.EnumTranslation.implTranslateErrorDetails(v))}else if(!(this.privRequestSession.isSpeechEnded&&h===t.ResultReason.NoMatch&&d.RecognitionStatus!==r.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(r.OutputFormatPropertyName)===t.OutputFormat[t.OutputFormat.Simple])a=new t.ConversationTranscriptionResult(this.privRequestSession.requestId,h,d.DisplayText,d.Duration,d.Offset+this.privRequestSession.currentTurnAudioOffset,d.Language,d.LanguageDetectionConfidence,d.SpeakerId,void 0,o.textBody,n);else{const v=r.DetailedSpeechPhrase.fromJSON(o.textBody),f=v.Offset+this.privRequestSession.currentTurnAudioOffset,g=v.getJsonWithCorrectedOffsets(f);a=new t.ConversationTranscriptionResult(this.privRequestSession.requestId,h,v.RecognitionStatus===r.RecognitionStatus.Success?v.NBest[0].Display:void 0,v.Duration,f,v.Language,v.LanguageDetectionConfidence,d.SpeakerId,void 0,g,n)}const l=new t.ConversationTranscriptionEventArgs(a,a.offset,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribed)try{this.privConversationTranscriber.transcribed(this.privConversationTranscriber,l)}catch{}}e=!0;break}return e}cancelRecognition(o,a,n,e,s){if(new t.PropertyCollection().setProperty(r.CancellationErrorCodePropertyName,t.CancellationErrorCode[e]),this.privConversationTranscriber.canceled){const p=new t.ConversationTranscriptionCanceledEventArgs(n,s,e,void 0,o);try{this.privConversationTranscriber.canceled(this.privConversationTranscriber,p)}catch{}}}};return ni.ConversationTranscriptionServiceRecognizer=i,ni}var si={},Ru;function jf(){if(Ru)return si;Ru=1,Object.defineProperty(si,"__esModule",{value:!0}),si.TranscriptionServiceRecognizer=void 0;const t=I(),r=y(),i=E(),u=Oe();let o=class extends i.ConversationServiceRecognizer{constructor(n,e,s,c,p){super(n,e,s,c,p),this.privTranscriberRecognizer=p,this.sendPrePayloadJSONOverride=d=>this.sendTranscriptionStartJSON(d),this.privRecognizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps)==="true"&&this.privSpeechContext.setWordLevelTimings()}async sendSpeechEventAsync(n,e){if(this.privRequestSession.isRecognizing){const s=await this.fetchConnection();await this.sendSpeechEvent(s,this.createSpeechEventPayload(n,e))}}async sendMeetingSpeechEventAsync(n,e){if(this.privRequestSession.isRecognizing){const s=await this.fetchConnection();await this.sendSpeechEvent(s,this.createMeetingSpeechEventPayload(n,e))}}processTypeSpecificMessages(n){return this.processSpeechMessages(n)}handleRecognizedCallback(n,e,s){try{const c=new r.SpeechRecognitionEventArgs(n,e,s);if(this.privTranscriberRecognizer.recognized(this.privTranscriberRecognizer,c),this.privSuccessCallback){try{this.privSuccessCallback(n)}catch(p){this.privErrorCallback&&this.privErrorCallback(p)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}catch{}}handleRecognizingCallback(n,e,s){try{const c=new r.SpeechRecognitionEventArgs(n,e,s);this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer,c)}catch{}}cancelRecognition(n,e,s,c,p){const d=new r.PropertyCollection;if(d.setProperty(i.CancellationErrorCodePropertyName,r.CancellationErrorCode[c]),this.privTranscriberRecognizer.IsMeetingRecognizer()){if(this.privTranscriberRecognizer.canceled){const h=new r.MeetingTranscriptionCanceledEventArgs(s,p,c,void 0,n);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,h)}catch{}}}else if(this.privTranscriberRecognizer.canceled){const h=new r.ConversationTranscriptionCanceledEventArgs(s,p,c,void 0,n);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,h)}catch{}}if(this.privSuccessCallback){const h=new r.SpeechRecognitionResult(e,r.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,p,void 0,d);try{this.privSuccessCallback(h),this.privSuccessCallback=void 0}catch{}}}async sendTranscriptionStartJSON(n){if(await this.sendSpeechContext(n,!0),this.privTranscriberRecognizer.IsMeetingRecognizer()){const e=this.privTranscriberRecognizer.getMeetingInfo(),s=this.createMeetingSpeechEventPayload(e,"start");await this.sendSpeechEvent(n,s)}else{const e=this.privTranscriberRecognizer.getConversationInfo(),s=this.createSpeechEventPayload(e,"start");await this.sendSpeechEvent(n,s)}await this.sendWaveHeader(n)}sendSpeechEvent(n,e){const s=JSON.stringify(e);if(s)return n.send(new u.SpeechConnectionMessage(t.MessageType.Text,"speech.event",this.privRequestSession.requestId,"application/json",s))}createSpeechEventPayload(n,e){const s={id:"meeting",name:e,meeting:n.conversationProperties};return s.meeting.id=n.id,s.meeting.attendees=n.participants,s}createMeetingSpeechEventPayload(n,e){const s={id:"meeting",name:e,meeting:n.meetingProperties};return s.meeting.id=n.id,s.meeting.attendees=n.participants,s}};return si.TranscriptionServiceRecognizer=o,si}var oi={},Pu;
22function qf(){if(Pu)return oi;Pu=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.DetailedSpeechPhrase=void 0;const t=E();let r=class ud{constructor(u){this.privDetailedSpeechPhrase=JSON.parse(u),this.privDetailedSpeechPhrase.RecognitionStatus=t.RecognitionStatus[this.privDetailedSpeechPhrase.RecognitionStatus]}static fromJSON(u){return new ud(u)}getJsonWithCorrectedOffsets(u){if(this.privDetailedSpeechPhrase.NBest){let o;for(const a of this.privDetailedSpeechPhrase.NBest)if(a.Words&&a.Words[0]){o=a.Words[0].Offset;break}if(o&&o<u){const a=u-o;for(const n of this.privDetailedSpeechPhrase.NBest){if(n.Words)for(const e of n.Words)e.Offset+=a;if(n.DisplayWords)for(const e of n.DisplayWords)e.Offset+=a}}}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}};return oi.DetailedSpeechPhrase=r,oi}var ai={},Eu;function Lf(){if(Eu)return ai;Eu=1,Object.defineProperty(ai,"__esModule",{value:!0}),ai.SimpleSpeechPhrase=void 0;const t=E();let r=class pd{constructor(u){this.privSimpleSpeechPhrase=JSON.parse(u),this.privSimpleSpeechPhrase.RecognitionStatus=t.RecognitionStatus[this.privSimpleSpeechPhrase.RecognitionStatus]}static fromJSON(u){return new pd(u)}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}};return ai.SimpleSpeechPhrase=r,ai}var ci={},Iu;function Bf(){if(Iu)return ci;Iu=1,Object.defineProperty(ci,"__esModule",{value:!0}),ci.AddedLmIntent=void 0;let t=class{constructor(i,u){this.modelImpl=i,this.intentName=u}};return ci.AddedLmIntent=t,ci}var ui={},Tu;function xf(){if(Tu)return ui;Tu=1,Object.defineProperty(ui,"__esModule",{value:!0}),ui.IntentServiceRecognizer=void 0;const t=I(),r=y(),i=E();let u=class extends i.ServiceRecognizerBase{constructor(a,n,e,s,c){super(a,n,e,s,c),this.privIntentRecognizer=c,this.privIntentDataSent=!1}setIntents(a,n){this.privAddedLmIntents=a,this.privUmbrellaIntent=n,this.privIntentDataSent=!0}processTypeSpecificMessages(a){let n,e,s=!1;const c=new r.PropertyCollection;switch(a.messageType===t.MessageType.Text&&c.setProperty(r.PropertyId.SpeechServiceResponse_JsonResult,a.textBody),a.path.toLowerCase()){case"speech.hypothesis":const d=i.SpeechHypothesis.fromJSON(a.textBody);if(n=new r.IntentRecognitionResult(void 0,this.privRequestSession.requestId,r.ResultReason.RecognizingIntent,d.Text,d.Duration,d.Offset+this.privRequestSession.currentTurnAudioOffset,d.Language,d.LanguageDetectionConfidence,void 0,a.textBody,c),this.privRequestSession.onHypothesis(n.offset),e=new r.IntentRecognitionEventArgs(n,d.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId),this.privIntentRecognizer.recognizing)try{this.privIntentRecognizer.recognizing(this.privIntentRecognizer,e)}catch{}s=!0;break;case"speech.phrase":const h=i.SimpleSpeechPhrase.fromJSON(a.textBody);n=new r.IntentRecognitionResult(void 0,this.privRequestSession.requestId,i.EnumTranslation.implTranslateRecognitionResult(h.RecognitionStatus),h.DisplayText,h.Duration,h.Offset+this.privRequestSession.currentTurnAudioOffset,h.Language,h.LanguageDetectionConfidence,void 0,a.textBody,
22c),e=new r.IntentRecognitionEventArgs(n,n.offset,this.privRequestSession.sessionId);const l=()=>{if(this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,e)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(n)}catch(f){this.privErrorCallback&&this.privErrorCallback(f)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}};this.privIntentDataSent===!1||r.ResultReason.NoMatch===e.result.reason?(this.privRequestSession.onPhraseRecognized(e.offset+e.result.duration),l()):this.privPendingIntentArgs=e,s=!0;break;case"response":if(e=this.privPendingIntentArgs,this.privPendingIntentArgs=void 0,e===void 0){if(a.textBody==="")return;e=new r.IntentRecognitionEventArgs(new r.IntentRecognitionResult,0,this.privRequestSession.sessionId)}const v=i.IntentResponse.fromJSON(a.textBody);if(v!==null&&v.topScoringIntent&&v.topScoringIntent.intent){let f=this.privAddedLmIntents[v.topScoringIntent.intent];if(this.privUmbrellaIntent!==void 0&&(f=this.privUmbrellaIntent),f){const g=f===void 0||f.intentName===void 0?v.topScoringIntent.intent:f.intentName;let m=e.result.reason;g!==void 0&&(m=r.ResultReason.RecognizedIntent);const S=e.result.properties!==void 0?e.result.properties:new r.PropertyCollection;S.setProperty(r.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,a.textBody),e=new r.IntentRecognitionEventArgs(new r.IntentRecognitionResult(g,e.result.resultId,m,e.result.text,e.result.duration,e.result.offset,void 0,void 0,e.result.errorDetails,e.result.json,S),e.offset,e.sessionId)}}if(this.privRequestSession.onPhraseRecognized(e.offset+e.result.duration),this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,e)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(e.result)}catch(f){this.privErrorCallback&&this.privErrorCallback(f)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}s=!0;break}const p=new t.Deferred;return p.resolve(s),p.promise}cancelRecognition(a,n,e,s,c){const p=new r.PropertyCollection;if(p.setProperty(i.CancellationErrorCodePropertyName,r.CancellationErrorCode[s]),this.privIntentRecognizer.canceled){const d=new r.IntentRecognitionCanceledEventArgs(e,c,s,void 0,void 0,a);try{this.privIntentRecognizer.canceled(this.privIntentRecognizer,d)}catch{}}if(this.privSuccessCallback){const d=new r.IntentRecognitionResult(void 0,n,r.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,c,void 0,p);try{this.privSuccessCallback(d),this.privSuccessCallback=void 0}catch{}}}};return ui.IntentServiceRecognizer=u,ui}var pi={},Au;function Ff(){if(Au)return pi;Au=1,Object.defineProperty(pi,"__esModule",{value:!0}),pi.IntentResponse=void 0;let t=class dd{constructor(i){i===""?this.privIntentResponse={}:this.privIntentResponse=JSON.parse(i)}static fromJSON(i){return new dd(i)}get query(){return this.privIntentResponse.query}get topScoringIntent(){return this.privIntentResponse.topScoringIntent}get entities(){return this.privIntentResponse.entities}};return pi.IntentResponse=t,pi}var Vn={},wu;function Uf(){return wu||(wu=1,Object.defineProperty(Vn,"__esModule",{value:!0})),Vn}var di={},hi={},_u;function Wf(){if(_u)return hi;_u=1,Object.defineProperty(hi,"__esModule",{value:!0}),hi.ServiceTelemetryListener=void 0;const t=I(),r=vs();class i{constructor(o,a,n){this.privIsDisposed=!1,this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privRequestId=o,this.privAudioSourceId=a,this.privAudioNodeId=n,this.privReceivedMessages={},this.privPhraseLatencies=[],this.privHypothesisLatencies=[]}phraseReceived(o){o>0&&this.privPhraseLatencies.push(Date.now()-o)}hypothesisReceived(o){o>0&&this.privHypothesisLatencies.push(Date.now()-o)}onEvent(o){this.privIsDisposed||(o instanceof r.RecognitionTriggeredEvent&&o.requestId===this.privRequestId&&(this.privListeningTriggerMetric={End:o.eventTime,Name:"ListeningTrigger",Start:o.eventTime}),o instanceof t.AudioStreamNodeAttachingEvent&&o.audioSourceId===this.privAudioSourceId&&o.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=o.eventTime),o instanceof t.AudioStreamNodeAttachedEvent&&o.audioSourceId===this.privAudioSourceId&&o.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=o.eventTime),o instanceof t.AudioSourceErrorEvent&&o.audioSourceId===this.privAudioSourceId&&(this.privMicMetric||(this.privMicMetric={End:o.eventTime,Error:o.error,Name:"Microphone",Start:this.privMicStartTime})),o instanceof t.AudioStreamNodeErrorEvent&&o.audioSourceId===this.privAudioSourceId&&o.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:o.eventTime,Error:o.error,Name:"Microphone",Start:this.privMicStartTime})),o instanceof t.AudioStreamNodeDetachedEvent&&o.audioSourceId===this.privAudioSourceId&&o.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:o.eventTime,Name:"Microphone",Start:this.privMicStartTime})),o instanceof r.ConnectingToServiceEvent&&o.requestId===this.privRequestId&&(this.privConnectionId=o.sessionId),o instanceof t.ConnectionStartEvent&&o.connectionId===this.privConnectionId&&(this.privConnectionStartTime=o.eventTime),o instanceof t.ConnectionEstablishedEvent&&o.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:o.eventTime,Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),o instanceof t.ConnectionEstablishErrorEvent&&o.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:o.eventTime,Error:this.getConnectionError(o.statusCode),Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),o instanceof t.ConnectionMessageReceivedEvent&&o.connectionId===this.privConnectionId&&o.message&&o.message.headers&&o.message.headers.path&&(this.privReceivedMessages[o.message.headers.path]||(this.privReceivedMessages[o.message.headers.path]=new Array),this.privReceivedMessages[o.message.headers.path].length<50&&this.privReceivedMessages[o.message.headers.path].push(o.networkReceivedTime)))}getTelemetry(){const o=new Array;this.privListeningTriggerMetric&&o.push(this.privListeningTriggerMetric),this.privMicMetric&&o.push(this.privMicMetric),this.privConnectionEstablishMetric&&o.push(this.privConnectionEstablishMetric),this.privPhraseLatencies.length>0&&o.push({PhraseLatencyMs:this.privPhraseLatencies}),this.privHypothesisLatencies.length>0&&o.push({FirstHypothesisLatencyMs:this.privHypothesisLatencies});const a={Metrics:o,ReceivedMessages:this.privReceivedMessages},n=JSON.stringify(a);return this.privReceivedMessages={},this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privPhraseLatencies=[],this.privHypothesisLatencies=[],n}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(o){switch(o){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:"+o.toString()}}}return hi.ServiceTelemetryListener=i,hi}var bu;function Hf(){if(bu)return di;bu=1,Object.defineProperty(di,"__esModule",{value:!0}),di.RequestSession=void 0;const t=I(),r=vs(),i=Wf();let u=class{constructor(a){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=a,this.privRequestId=t.createNoDashGuid(),this.privAudioNodeId=t.createNoDashGuid(),this.privTurnDeferral=new t.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}
22get 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(a){this.privServiceTelemetryListener&&this.privDetachables.push(a.attachListener(this.privServiceTelemetryListener))}startNewRecognition(){this.privRecognitionBytesSent=0,this.privIsSpeechEnded=!1,this.privIsRecognizing=!0,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privRecogNumber++,this.privServiceTelemetryListener=new i.ServiceTelemetryListener(this.privRequestId,this.privAudioSourceId,this.privAudioNodeId),this.onEvent(new r.RecognitionTriggeredEvent(this.requestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}async onAudioSourceAttachCompleted(a,n){this.privAudioNode=a,this.privIsAudioNodeDetached=!1,n?await this.onComplete():this.onEvent(new r.ListeningStartedEvent(this.privRequestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}onPreConnectionStart(a,n){this.privAuthFetchEventId=a,this.privSessionId=n,this.onEvent(new r.ConnectingToServiceEvent(this.privRequestId,this.privAuthFetchEventId,this.privSessionId))}async onAuthCompleted(a){a&&await this.onComplete()}async onConnectionEstablishCompleted(a,n){if(a===200){this.onEvent(new r.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 a===403&&await this.onComplete()}async onServiceTurnEndResponse(a){this.privTurnDeferral.resolve(),!a||this.isSpeechEnded?(await this.onComplete(),this.privInTurn=!1):(this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privAudioNode.replay())}onSpeechContext(){this.privRequestId=t.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 t.Deferred}onHypothesis(a){this.privHypothesisReceived||(this.privHypothesisReceived=!0,this.privServiceTelemetryListener.hypothesisReceived(this.privAudioNode.findTimeAtOffset(a)))}onPhraseRecognized(a){this.privServiceTelemetryListener.phraseReceived(this.privAudioNode.findTimeAtOffset(a)),this.onServiceRecognized(a)}onServiceRecognized(a){this.privLastRecoOffset=a,this.privHypothesisReceived=!1,this.privAudioNode.shrinkBuffers(a),this.privConnectionAttempts=0}onAudioSent(a){this.privBytesSent+=a,this.privRecognitionBytesSent+=a}onRetryConnection(){this.privConnectionAttempts++}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(const a of this.privDetachables)await a.detach();this.privServiceTelemetryListener&&this.privServiceTelemetryListener.dispose(),this.privIsRecognizing=!1}}getTelemetry(){return this.privServiceTelemetryListener.hasTelemetry?this.privServiceTelemetryListener.getTelemetry():null}
22async onStopRecognizing(){await this.onComplete()}onSpeechEnded(){this.privIsSpeechEnded=!0}onEvent(a){this.privServiceTelemetryListener&&this.privServiceTelemetryListener.onEvent(a),t.Events.instance.onEvent(a)}async onComplete(){this.privIsRecognizing&&(this.privIsRecognizing=!1,await this.detachAudioNode())}async detachAudioNode(){this.privIsAudioNodeDetached||(this.privIsAudioNodeDetached=!0,this.privAudioNode&&await this.privAudioNode.detach())}};return di.RequestSession=u,di}var li={},Mu;function Vf(){if(Mu)return li;Mu=1,Object.defineProperty(li,"__esModule",{value:!0}),li.SpeechContext=void 0;let t=class{constructor(i){this.privContext={},this.privDynamicGrammar=i}getSection(i){return this.privContext[i]||{}}setSection(i,u){this.privContext[i]=u}setPronunciationAssessmentParams(i,u,o=!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(i),o&&(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"),u&&(this.privContext.phraseDetection.enrichment.contentAssessment={topic:u},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(i){this.privContext.phraseDetection.speakerDiarization.audioOffsetMs=i}toJSON(){const i=this.privDynamicGrammar.generateGrammarObject();return this.setSection("dgi",i),JSON.stringify(this.privContext)}};return li.SpeechContext=t,li}var vi={},Ou;function $f(){if(Ou)return vi;Ou=1,Object.defineProperty(vi,"__esModule",{value:!0}),vi.DynamicGrammarBuilder=void 0;let t=class{addPhrase(i){this.privPhrases||(this.privPhrases=[]),i instanceof Array?this.privPhrases=this.privPhrases.concat(i):this.privPhrases.push(i)}clearPhrases(){this.privPhrases=void 0}addReferenceGrammar(i){this.privGrammars||(this.privGrammars=[]),i instanceof Array?this.privGrammars=this.privGrammars.concat(i):this.privGrammars.push(i)}clearGrammars(){this.privGrammars=void 0}generateGrammarObject(){if(this.privGrammars===void 0&&this.privPhrases===void 0)return;const i={};if(i.ReferenceGrammars=this.privGrammars,this.privPhrases!==void 0&&this.privPhrases.length!==0){const u=[];this.privPhrases.forEach(o=>{u.push({Text:o})}),i.Groups=[{Type:"Generic",Items:u}]}return i}};return vi.DynamicGrammarBuilder=t,vi}var $n={},Du;function Kf(){return Du||(Du=1,Object.defineProperty($n,"__esModule",{value:!0})),$n}var fi={},gi={},mi={},Kn={},ku;function hd(){return ku||(ku=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.MessageDataStreamType=t.ActivityPayloadResponse=void 0;class r{constructor(u){this.privActivityResponse=JSON.parse(u)}static fromJSON(u){return new r(u)}get conversationId(){return this.privActivityResponse.conversationId}get messageDataStreamType(){return this.privActivityResponse.messageDataStreamType}get messagePayload(){return this.privActivityResponse.messagePayload}get version(){return this.privActivityResponse.version}}t.ActivityPayloadResponse=r,(function(i){i[i.None=0]="None",i[i.TextToSpeechAudio=1]="TextToSpeechAudio"})(t.MessageDataStreamType||(t.MessageDataStreamType={}))})(Kn)),Kn}var Nu;function Jf(){if(Nu)return mi;
22Nu=1,Object.defineProperty(mi,"__esModule",{value:!0}),mi.DialogServiceTurnState=void 0;const t=Bi(),r=Me(),i=hd();let u=class{constructor(a,n){this.privRequestId=n,this.privIsCompleted=!1,this.privAudioStream=null,this.privTurnManager=a,this.resetTurnEndTimeout()}get audioStream(){return this.resetTurnEndTimeout(),this.privAudioStream}processActivityPayload(a,n){return a.messageDataStreamType===i.MessageDataStreamType.TextToSpeechAudio&&(this.privAudioStream=r.AudioOutputStream.createPullStream(),this.privAudioStream.format=n!==void 0?n:t.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)}};return mi.DialogServiceTurnState=u,mi}var zu;function Gf(){if(zu)return gi;zu=1,Object.defineProperty(gi,"__esModule",{value:!0}),gi.DialogServiceTurnStateManager=void 0;const t=V(),r=Jf();let i=class{constructor(){this.privTurnMap=new Map}StartTurn(o){if(this.privTurnMap.has(o))throw new t.InvalidOperationError("Service error: There is already a turn with id:"+o);const a=new r.DialogServiceTurnState(this,o);return this.privTurnMap.set(o,a),this.privTurnMap.get(o)}GetTurn(o){return this.privTurnMap.get(o)}CompleteTurn(o){if(!this.privTurnMap.has(o))throw new t.InvalidOperationError("Service error: Received turn end for an unknown turn id:"+o);const a=this.privTurnMap.get(o);return a.complete(),this.privTurnMap.delete(o),a}};return gi.DialogServiceTurnStateManager=i,gi}var ju;function Qf(){if(ju)return fi;ju=1,Object.defineProperty(fi,"__esModule",{value:!0}),fi.DialogServiceAdapter=void 0;const t=D(),r=Cp(),i=I(),u=Bi(),o=y(),a=Gf(),n=E(),e=hd(),s=Oe();let c=class extends n.ServiceRecognizerBase{constructor(d,h,l,v,f){super(d,h,l,v,f),this.privEvents=new i.EventSource,this.privDialogServiceConnector=f,this.receiveMessageOverride=()=>this.receiveDialogMessageOverride(),this.privTurnStateManager=new a.DialogServiceTurnStateManager,this.recognizeOverride=(g,m,S)=>this.listenOnce(g,m,S),this.postConnectImplOverride=g=>this.dialogConnectImpl(g),this.configConnectionOverride=g=>this.configConnection(g),this.disconnectOverride=()=>this.privDisconnect(),this.privDialogAudioSource=l,this.agentConfigSent=!1,this.privLastResult=null,this.connectionEvents.attach(g=>{g.name==="ConnectionClosedEvent"&&(this.terminateMessageLoop=!0)})}async sendMessage(d){const h=i.createGuid(),l=i.createNoDashGuid(),v={context:{interactionId:h},messagePayload:JSON.parse(d),version:.5},f=JSON.stringify(v);await(await this.fetchConnection()).send(new s.SpeechConnectionMessage(i.MessageType.Text,"agent",l,"application/json",f))}async privDisconnect(){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,o.CancellationReason.Error,o.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.agentConfigSent=!1}processTypeSpecificMessages(d){const h=new o.PropertyCollection;d.messageType===i.MessageType.Text&&h.setProperty(o.PropertyId.SpeechServiceResponse_JsonResult,d.textBody);let l,v;switch(d.path.toLowerCase()){case"speech.phrase":const g=n.SimpleSpeechPhrase.fromJSON(d.textBody);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+g.Offset+g.Duration),g.RecognitionStatus!==n.RecognitionStatus.TooManyRequests&&g.RecognitionStatus!==n.RecognitionStatus.Error){const A=this.fireEventForResult(g,h);if(this.privLastResult=A.result,this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,A)}catch{}}v=!0;break;case"speech.hypothesis":const m=n.SpeechHypothesis.fromJSON(d.textBody),S=m.Offset+this.privRequestSession.currentTurnAudioOffset;l=new o.SpeechRecognitionResult(this.privRequestSession.requestId,o.ResultReason.RecognizingSpeech,m.Text,m.Duration,S,m.Language,m.LanguageDetectionConfidence,void 0,void 0,d.textBody,h),this.privRequestSession.onHypothesis(S);const C=new o.SpeechRecognitionEventArgs(l,m.Duration,this.privRequestSession.sessionId);
22if(this.privDialogServiceConnector.recognizing)try{this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector,C)}catch{}v=!0;break;case"speech.keyword":const R=n.SpeechKeyword.fromJSON(d.textBody);l=new o.SpeechRecognitionResult(this.privRequestSession.requestId,R.Status==="Accepted"?o.ResultReason.RecognizedKeyword:o.ResultReason.NoMatch,R.Text,R.Duration,R.Offset,void 0,void 0,void 0,void 0,d.textBody,h),R.Status!=="Accepted"&&(this.privLastResult=l);const P=new o.SpeechRecognitionEventArgs(l,l.duration,l.resultId);if(this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,P)}catch{}v=!0;break;case"audio":{const A=d.requestId.toUpperCase(),M=this.privTurnStateManager.GetTurn(A);try{d.binaryBody?M.audioStream.write(d.binaryBody):M.endAudioStream()}catch{}}v=!0;break;case"response":this.handleResponseMessage(d),v=!0;break}const f=new i.Deferred;return f.resolve(v),f.promise}async cancelRecognition(d,h,l,v,f){if(this.terminateMessageLoop=!0,this.privRequestSession.isRecognizing&&await this.privRequestSession.onStopRecognizing(
22),this.privDialogServiceConnector.canceled){const g=new o.PropertyCollection;g.setProperty(n.CancellationErrorCodePropertyName,o.CancellationErrorCode[v]);const m=new o.SpeechRecognitionCanceledEventArgs(l,f,v,void 0,d);try{this.privDialogServiceConnector.canceled(this.privDialogServiceConnector,m)}catch{}if(this.privSuccessCallback){const S=new o.SpeechRecognitionResult(void 0,o.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,f,void 0,g);try{this.privSuccessCallback(S),this.privSuccessCallback=void 0}catch{}}}}async listenOnce(d,h,l){this.privRecognizerConfig.recognitionMode=d,this.privSuccessCallback=h,this.privErrorCallback=l,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privDialogAudioSource.events),this.privRecognizerConfig.parameters.setProperty(o.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);const v=this.connectImpl(),f=this.sendPreAudioMessages(),g=await this.privDialogAudioSource.attach(this.privRequestSession.audioNodeId),m=await this.privDialogAudioSource.format,S=await this.privDialogAudioSource.deviceInfo,C=new t.ReplayableAudioNode(g,m.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(C,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:S};try{await v,await f}catch(A){return await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,o.CancellationReason.Error,o.CancellationErrorCode.ConnectionFailure,A),Promise.resolve()}const R=new o.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,R),this.sendAudio(C).then(()=>{},async A=>{await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,o.CancellationReason.Error,o.CancellationErrorCode.RuntimeError,A)})}dialogConnectImpl(d){return this.privConnectionLoop=this.startMessageLoop(),d}receiveDialogMessageOverride(){const d=new i.Deferred,h=async()=>{try{const l=this.isDisposed(),v=!this.isDisposed()&&this.terminateMessageLoop;if(l||v){d.resolve(void 0);return}const g=await(await this.fetchConnection()).read();if(!g)return h();const m=s.SpeechConnectionMessage.fromConnectionMessage(g);switch(m.path.toLowerCase()){case"turn.start":{const _=m.requestId.toUpperCase(),j=this.privRequestSession.requestId.toUpperCase();_!==j?this.privTurnStateManager.StartTurn(_):this.privRequestSession.onServiceTurnStartResponse()}break;case"speech.startdetected":const C=n.SpeechDetected.fromJSON(m.textBody),R=new o.RecognitionEventArgs(C.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,R);break;case"speech.enddetected":let P;m.textBody.length>0?P=m.textBody:P="{ Offset: 0 }";const A=n.SpeechDetected.fromJSON(P);this.privRequestSession.onServiceRecognized(A.Offset+this.privRequestSession.currentTurnAudioOffset);const M=new o.RecognitionEventArgs(A.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,M);break;case"turn.end":{const _=m.requestId.toUpperCase(),j=this.privRequestSession.requestId.toUpperCase();if(_!==j)this.privTurnStateManager.CompleteTurn(_);else{const _e=new o.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(!1),(!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing)&&this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,_e),this.privSuccessCallback&&this.privLastResult){try{this.privSuccessCallback(this.privLastResult),this.privLastResult=null}catch(Fi){this.privErrorCallback&&this.privErrorCallback(Fi)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}}break;default:try{await this.processTypeSpecificMessages(m)||this.serviceEvents&&this.serviceEvents.onEvent(new i.ServiceEvent(m.path.toLowerCase(),m.textBody))}catch{}}return h()}catch{this.terminateMessageLoop=!0,d.resolve()}};return h().catch(l=>
22{i.Events.instance.onEvent(new i.BackgroundEvent(l))}),d.promise}async startMessageLoop(){this.terminateMessageLoop=!1;try{await this.receiveDialogMessageOverride()}catch(d){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,o.CancellationReason.Error,o.CancellationErrorCode.RuntimeError,d)}return Promise.resolve()}async configConnection(d){return this.terminateMessageLoop?(this.terminateMessageLoop=!1,Promise.reject("Connection to service terminated.")):(await this.sendSpeechServiceConfig(d,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendAgentConfig(d),d)}async sendPreAudioMessages(){const d=await this.fetchConnection();this.addKeywordContextData(),await this.sendSpeechContext(d,!0),await this.sendAgentContext(d),await this.sendWaveHeader(d)}sendAgentConfig(d){if(this.agentConfig&&!this.agentConfigSent){if(this.privRecognizerConfig.parameters.getProperty(o.PropertyId.Conversation_DialogType)===o.DialogServiceConfig.DialogTypes.CustomCommands){const l=this.agentConfig.get();l.botInfo.commandsCulture=this.privRecognizerConfig.parameters.getProperty(o.PropertyId.SpeechServiceConnection_RecoLanguage,"en-us"),this.agentConfig.set(l)}this.onEvent(new r.SendingAgentContextMessageEvent(this.agentConfig));const h=this.agentConfig.toJsonString();return this.agentConfigSent=!0,d.send(new s.SpeechConnectionMessage(i.MessageType.Text,"agent.config",this.privRequestSession.requestId,"application/json",h))}}sendAgentContext(d){const h=i.createGuid(),l=this.privDialogServiceConnector.properties.getProperty(o.PropertyId.Conversation_Speech_Activity_Template),f=JSON.stringify({channelData:"",context:{interactionId:h},messagePayload:typeof l===void 0?void 0:l,version:.5});return d.send(new s.SpeechConnectionMessage(i.MessageType.Text,"speech.agent.context",this.privRequestSession.requestId,"application/json",f))}fireEventForResult(d,h){const l=n.EnumTranslation.implTranslateRecognitionResult(d.RecognitionStatus),v=d.Offset+this.privRequestSession.currentTurnAudioOffset,f=new o.SpeechRecognitionResult(this.privRequestSession.requestId,l,d.DisplayText,d.Duration,v,d.Language,d.LanguageDetectionConfidence,void 0,void 0,JSON.stringify(d),h);return new o.SpeechRecognitionEventArgs(f,v,this.privRequestSession.sessionId)}handleResponseMessage(d){const h=JSON.parse(d.textBody);switch(h.messageType.toLowerCase()){case"message":const l=d.requestId.toUpperCase(),v=e.ActivityPayloadResponse.fromJSON(d.textBody),f=this.privTurnStateManager.GetTurn(l);if(v.conversationId){const S=this.agentConfig.get();S.botInfo.conversationId=v.conversationId,this.agentConfig.set(S)}const g=f.processActivityPayload(v,u.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(o.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0))),m=new o.ActivityReceivedEventArgs(v.messagePayload,g);if(this.privDialogServiceConnector.activityReceived)try{this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector,m)}catch{}break;case"messagestatus":if(this.privDialogServiceConnector.turnStatusReceived)try{this.privDialogServiceConnector.turnStatusReceived(this.privDialogServiceConnector,new o.TurnStatusReceivedEventArgs(d.textBody))}catch{}break;default:i.Events.instance.onEvent(new i.BackgroundEvent(`Unexpected response of type ${h.messageType}. Ignoring.`));break}}onEvent(d){this.privEvents.onEvent(d),i.Events.instance.onEvent(d)}addKeywordContextData(){const d=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect");if(d===void 0)return;const h=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Offsets"),l=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Durations"),v=d.split(";"),f=h===void 0?[]:h.split(";"),g=l===void 0?[]:l.split(";"),m=[];for(let S=0;S<v.length;S++){const C={};C.text=v[S],S<f.length&&(C.offset=Number(f[S])),S<g.length&&(C.duration=Number(g[S])),m.push(C)}this.speechContext.setSection("invocationSource","VoiceActivationWithKeyword"),this.speechContext.setSection("keywordDetection",[{clientDetectedKeywords:m,onReject:{action:"EndOfTurn"},type:"startTrigger"}])}};return fi.DialogServiceAdapter=c,fi}var Si={},qu;function Xf(){if(qu)return Si;qu=1,Object.defineProperty(Si,"__esModule",{value:!0}),Si.AgentConfig=void 0;let t=class{toJsonString(){return JSON.stringify(this.iPrivConfig)}get(){return this.iPrivConfig}set(i){this.iPrivConfig=i}};return Si.AgentConfig=t,Si}var Jn={},Ci={},yi={},Lu;function fs(){if(Lu)return yi;Lu=1,Object.defineProperty(yi,"__esModule",{value:!0}),yi.ConversationConnectionConfig=void 0;const t=nd();let r=class Z extends t.RestConfigBase{static get host(){return Z.privHost}static get apiVersion(){return Z.privApiVersion}static get clientAppId(){return Z.privClientAppId}static get defaultLanguageCode(){return Z.privDefaultLanguageCode}static get restPath(){return Z.privRestPath}static get webSocketPath(){return Z.privWebSocketPath}static get transcriptionEventKeys(){return Z.privTranscriptionEventKeys}};return yi.ConversationConnectionConfig=r,r.privHost="dev.microsofttranslator.com",r.privRestPath="/capito/room",r.privApiVersion="2.0",r.privDefaultLanguageCode="en-US",r.privClientAppId="FC539C22-1767-4F1F-84BC-B4D811114F15",r.privWebSocketPath="/capito/translate",r.privTranscriptionEventKeys=["iCalUid","callId","organizer","FLAC","MTUri","DifferentiateGuestSpeakers","audiorecording","Threadid","OrganizerMri","OrganizerTenantId","UserToken"],yi}var Bu;function Zf(){if(Bu)return Ci;Bu=1,Object.defineProperty(Ci,"__esModule",{value:!0}),Ci.ConversationManager=void 0;const t=D(),r=T(),i=y(),u=fs();
vendor: 1,134 bytes, line 22
22let o=class{constructor(){this.privRequestParams=u.ConversationConnectionConfig.configParams,this.privErrors=u.ConversationConnectionConfig.restErrors,this.privHost=u.ConversationConnectionConfig.host,this.privApiVersion=u.ConversationConnectionConfig.apiVersion,this.privRestPath=u.ConversationConnectionConfig.restPath,this.privRestAdapter=new t.RestMessageAdapter({})}createOrJoin(n,e,s,c){try{r.Contracts.throwIfNullOrUndefined(n,"args");const p=n.getProperty(i.PropertyId.SpeechServiceConnection_RecoLanguage,u.ConversationConnectionConfig.defaultLanguageCode),d=n.getProperty(i.PropertyId.ConversationTranslator_Name,"conversation_host"),h=n.getProperty(i.PropertyId.ConversationTranslator_Host,this.privHost),l=n.getProperty(i.PropertyId.ConversationTranslator_CorrelationId),v=n.getProperty(i.PropertyId.SpeechServiceConnection_Key),f=n.getProperty(i.PropertyId.SpeechServiceConnection_Region),g=n.getProperty(i.PropertyId.SpeechServiceAuthorization_Token);r.Contracts.throwIfNullOrWhitespace(p,"languageCode"),r.Contracts.throwIfNullOrWhitespace(d,"nickname"),r.Contracts.throwIfNullOrWhitespace(h,"endpointHost");const m={};
22m[this.privRequestParams.apiVersion]=this.privApiVersion,m[this.privRequestParams.languageCode]=p,m[this.privRequestParams.nickname]=d;const S={};l&&(S[this.privRequestParams.correlationId]=l),S[this.privRequestParams.clientAppId]=u.ConversationConnectionConfig.clientAppId,e!==void 0?m[this.privRequestParams.roomId]=e:(r.Contracts.throwIfNullOrUndefined(f,this.privErrors.authInvalidSubscriptionRegion),S[this.privRequestParams.subscriptionRegion]=f,v?S[this.privRequestParams.subscriptionKey]=v:g?S[this.privRequestParams.authorization]=`Bearer ${g}`:r.Contracts.throwIfNullOrUndefined(v,this.privErrors.authInvalidSubscriptionKey));const C={};C.headers=S,this.privRestAdapter.options=C;const R=`https://${h}${this.privRestPath}`;this.privRestAdapter.request(t.RestRequestType.Post,R,m,null).then(P=>{const A=t.RestMessageAdapter.extractHeaderValue(this.privRequestParams.requestId,P.headers);if(!P.ok){if(c){let _=this.privErrors.invalidCreateJoinConversationResponse.replace("{status}",P.status.toString()),j;try{j=JSON.parse(P.data),_+=` [${j.error.code}: ${j.error.message}]`}catch{_+=` [${P.data}]`}A&&(_+=` ${A}`),c(_)}return}const M=JSON.parse(P.data);if(M&&(M.requestId=A),s){try{s(M)}catch(_){c&&c(_)}s=void 0}}).catch(()=>{})}catch(p){if(c)if(p instanceof Error){const d=p;c(d.name+": "+d.message)}else c(p)}}leave(n,e){return new Promise((s,c)=>{try{r.Contracts.throwIfNullOrUndefined(n,this.privErrors.invalidArgs.replace("{arg}","config")),r.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","token"));const p=n.getProperty(i.PropertyId.ConversationTranslator_Host,this.privHost),d=n.getProperty(i.PropertyId.ConversationTranslator_CorrelationId),h={};
22h[this.privRequestParams.apiVersion]=this.privApiVersion,h[this.privRequestParams.sessionToken]=e;const l={};d&&(l[this.privRequestParams.correlationId]=d);const v={};v.headers=l,this.privRestAdapter.options=v;const f=`https://${p}${this.privRestPath}`;this.privRestAdapter.request(t.RestRequestType.Delete,f,h,null).then(g=>{g.ok,s()}).catch(()=>{})}catch(p){if(p instanceof Error){const d=p;c(d.name+": "+d.message)}else c(p)}})}};return Ci.ConversationManager=o,Ci}var ye={},Ri={},Pi={},Ei={},xu;function ld(){if(xu)return Ei;xu=1,Object.defineProperty(Ei,"__esModule",{value:!0}),Ei.ConversationConnectionMessage=void 0;const t=I();let r=class extends t.ConnectionMessage{constructor(u,o,a,n){super(u,o,a,n);const e=JSON.parse(this.textBody);e.type!==void 0&&(this.privConversationMessageType=e.type)}get conversationMessageType(){return this.privConversationMessageType}};return Ei.ConversationConnectionMessage=r,Ei}var Fu;function Yf(){if(Fu)return Pi;Fu=1,Object.defineProperty(Pi,"__esModule",{value:!0}),Pi.ConversationWebsocketMessageFormatter=void 0;const t=I(),r=ld();let i=class{toConnectionMessage(o){const a=new t.Deferred;try{if(o.messageType===t.MessageType.Text){const n=new r.ConversationConnectionMessage(o.messageType,o.textContent,{},o.id);a.resolve(n)}else o.messageType===t.MessageType.Binary&&a.resolve(new r.ConversationConnectionMessage(o.messageType,o.binaryContent,void 0,o.id))}catch(n){a.reject(`Error formatting the message. Error: ${n}`)}return a.promise}fromConnectionMessage(o){const a=new t.Deferred;try{if(o.messageType===t.MessageType.Text){const n=`${o.textBody?o.textBody:""}`;a.resolve(new t.RawWebsocketMessage(t.MessageType.Text,n,o.id))}}catch(n){a.reject(`Error formatting the message. ${n}`)}return a.promise}};return Pi.ConversationWebsocketMessageFormatter=i,Pi}var Uu;function eg(){if(Uu)return Ri;Uu=1,Object.defineProperty(Ri,"__esModule",{value:!0}),Ri.ConversationConnectionFactory=void 0;const t=D(),r=I(),i=T(),u=y(),o=H(),a=fs(),n=Yf();let e=class extends o.ConnectionFactoryBase{create(c,p,d){const h=c.parameters.getProperty(u.PropertyId.ConversationTranslator_Host,a.ConversationConnectionConfig.host),l=c.parameters.getProperty(u.PropertyId.ConversationTranslator_CorrelationId,r.createGuid()),v=`wss://${h}${a.ConversationConnectionConfig.webSocketPath}`,f=c.parameters.getProperty(u.PropertyId.ConversationTranslator_Token,void 0);i.Contracts.throwIfNullOrUndefined(f,"token");const g={};g[a.ConversationConnectionConfig.configParams.apiVersion]=a.ConversationConnectionConfig.apiVersion,g[a.ConversationConnectionConfig.configParams.token]=f,g[a.ConversationConnectionConfig.configParams.correlationId]=l;const m=c.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new t.WebsocketConnection(v,g,{},new n.ConversationWebsocketMessageFormatter,t.ProxyInfo.fromRecognizerConfig(c),m,d)}};return Ri.ConversationConnectionFactory=e,Ri}var Ii={},Ti={},Wu;function tg(){if(Wu)return Ti;Wu=1,Object.defineProperty(Ti,"__esModule",{value:!0}),Ti.ConversationRequestSession=void 0;const t=I();let r=class{constructor(u){this.privIsDisposed=!1,this.privDetachables=new Array,this.privSessionId=u,this.privRequestId=t.createNoDashGuid(),this.privRequestCompletionDeferral=new t.Deferred}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get completionPromise(){return this.privRequestCompletionDeferral.promise}onPreConnectionStart(u,o){this.privSessionId=o}onAuthCompleted(u){u&&this.onComplete()}onConnectionEstablishCompleted(u){u!==200&&u===403&&this.onComplete()}onServiceTurnEndResponse(u){u?this.privRequestId=t.createNoDashGuid():this.onComplete()}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(const u of this.privDetachables)await u.detach()}}onComplete(){}};return Ti.ConversationRequestSession=r,Ti}var k={},Hu;function vd(){if(Hu)return k;Hu=1,Object.defineProperty(k,"__esModule",{value:!0}),k.ConversationReceivedTranslationEventArgs=k.ParticipantsListEventArgs=k.ParticipantAttributeEventArgs=k.ParticipantEventArgs=k.LockRoomEventArgs=k.MuteAllEventArgs=void 0;const t=y();class r extends t.SessionEventArgs{constructor(s,c){super(c),this.privIsMuted=s}get isMuted(){return this.privIsMuted}}k.MuteAllEventArgs=r;class i extends t.SessionEventArgs{constructor(s,c){super(c),this.privIsLocked=s}get isMuted(){return this.privIsLocked}}k.LockRoomEventArgs=i;class u extends t.SessionEventArgs{constructor(s,c){super(c),this.privParticipant=s}get participant(){return this.privParticipant}}k.ParticipantEventArgs=u;
22class o extends t.SessionEventArgs{constructor(s,c,p,d){super(d),this.privKey=c,this.privValue=p,this.privParticipantId=s}get value(){return this.privValue}get key(){return this.privKey}get id(){return this.privParticipantId}}k.ParticipantAttributeEventArgs=o;class a extends t.SessionEventArgs{constructor(s,c,p,d,h,l,v,f,g){super(g),this.privRoomId=s,this.privSessionToken=c,this.privTranslateTo=p,this.privProfanityFilter=d,this.privRoomProfanityFilter=h,this.privIsRoomLocked=l,this.privIsRoomLocked=v,this.privParticipants=f}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}}k.ParticipantsListEventArgs=a;class n{constructor(s,c,p){this.privPayload=c,this.privCommand=s,this.privSessionId=p}get payload(){return this.privPayload}get command(){return this.privCommand}get sessionId(){return this.privSessionId}}return k.ConversationReceivedTranslationEventArgs=n,k}var G={},Vu;function fd(){if(Vu)return G;Vu=1,Object.defineProperty(G,"__esModule",{value:!0}),G.ConversationTranslatorCommandTypes=G.ConversationTranslatorMessageTypes=G.InternalParticipants=void 0;class t{constructor(i=[],u){this.participants=i,this.meId=u}addOrUpdateParticipant(i){if(i===void 0)return;const u=this.getParticipantIndex(i.id);return u>-1?this.participants.splice(u,1,i):this.participants.push(i),this.getParticipant(i.id)}getParticipantIndex(i){return this.participants.findIndex(u=>u.id===i)}getParticipant(i){return this.participants.find(u=>u.id===i)}deleteParticipant(i){this.participants=this.participants.filter(u=>u.id!==i)}get host(){return this.participants.find(i=>i.isHost===!0)}get me(){return this.getParticipant(this.meId)}}return G.InternalParticipants=t,G.ConversationTranslatorMessageTypes={command:"command",final:"final",info:"info",instantMessage:"instant_message",keepAlive:"keep_alive",partial:"partial",participantCommand:"participant_command",translatedMessage:"translated_message"},G.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"},G}var Gn={},Ai={},$u;function rg(){if($u)return Ai;$u=1,Object.defineProperty(Ai,"__esModule",{value:!0}),Ai.CommandResponsePayload=void 0;const t=i=>JSON.parse(i);let r=class gd{constructor(u){this.privCommandResponse=t(u)}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(u){return new gd(u)}};return Ai.CommandResponsePayload=r,Ai}var Re={},Ku;function ig(){if(Ku)return Re;Ku=1,Object.defineProperty(Re,"__esModule",{value:!0}),Re.ParticipantPayloadResponse=Re.ParticipantsListPayloadResponse=void 0;const t=o=>JSON.parse(o),r=o=>JSON.parse(o);class i{constructor(a){this.privParticipantsPayloadResponse=t(a)}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(a){return new i(a)}}Re.ParticipantsListPayloadResponse=i;class u{constructor(a){this.privParticipantPayloadResponse=r(a)}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(a){return new u(a)}}return Re.ParticipantPayloadResponse=u,Re}var Pe={},Ju;function ng(){if(Ju)return Pe;
22Ju=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.TextResponsePayload=Pe.SpeechResponsePayload=void 0;const t=o=>JSON.parse(o),r=o=>JSON.parse(o);class i{constructor(a){this.privSpeechResponse=t(a)}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(a){return new i(a)}}Pe.SpeechResponsePayload=i;class u{constructor(a){this.privTextResponse=r(a)}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(a){return new u(a)}}return Pe.TextResponsePayload=u,Pe}var Gu;function sg(){return Gu||(Gu=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});var r=rg();Object.defineProperty(t,"CommandResponsePayload",{enumerable:!0,get:function(){return r.CommandResponsePayload}});var i=ig();Object.defineProperty(t,"ParticipantsListPayloadResponse",{enumerable:!0,get:function(){return i.ParticipantsListPayloadResponse}}),Object.defineProperty(t,"ParticipantPayloadResponse",{enumerable:!0,get:function(){return i.ParticipantPayloadResponse}});var u=ng();Object.defineProperty(t,"SpeechResponsePayload",{enumerable:!0,get:function(){return u.SpeechResponsePayload}}),Object.defineProperty(t,"TextResponsePayload",{enumerable:!0,get:function(){return u.TextResponsePayload}})})(Gn)),Gn}var Qu;function og(){if(Qu)return Ii;Qu=1,Object.defineProperty(Ii,"__esModule",{value:!0}),Ii.ConversationServiceAdapter=void 0;const t=I(),r=y(),i=E(),u=ld(),o=tg(),a=vd(),n=fd(),e=sg();let s=class extends i.ServiceRecognizerBase{constructor(p,d,h,l,v){super(p,d,h,l,v),this.privConnectionConfigPromise=void 0,this.privLastPartialUtteranceId="",this.privConversationServiceConnector=v,this.privConversationAuthentication=p,this.receiveMessageOverride=()=>this.receiveConversationMessageOverride(),this.recognizeOverride=()=>this.noOp(),this.postConnectImplOverride=f=>this.conversationConnectImpl(f),this.configConnectionOverride=()=>this.configConnection(),this.disconnectOverride=()=>this.privDisconnect(),this.privConversationRequestSession=new o.ConversationRequestSession(t.createNoDashGuid()),this.privConversationConnectionFactory=d,this.privConversationIsDisposed=!1}isDisposed(){return super.isDisposed()||this.privConversationIsDisposed}async dispose(p){this.privConversationIsDisposed=!0,this.privConnectionConfigPromise!==void 0&&await(await this.privConnectionConfigPromise).dispose(p),await super.dispose(p)}async sendMessage(p){return(await this.fetchConnection()).send(new u.ConversationConnectionMessage(t.MessageType.Text,p))}async sendMessageAsync(p){await(await this.fetchConnection()).send(new u.ConversationConnectionMessage(t.MessageType.Text,p))}privDisconnect(){if(!this.terminateMessageLoop)return this.cancelRecognition(this.privConversationRequestSession.sessionId,this.privConversationRequestSession.requestId,r.CancellationReason.Error,r.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,Promise.resolve()}async processTypeSpecificMessages(){return!0}cancelRecognition(p,d,h,l,v){this.terminateMessageLoop=!0;const f=new r.ConversationTranslationCanceledEventArgs(h,v,l,void 0,p);try{this.privConversationServiceConnector.canceled&&this.privConversationServiceConnector.canceled(this.privConversationServiceConnector,f)}catch{}}async conversationConnectImpl(p){return this.privConnectionLoop=this.startMessageLoop(),p}async receiveConversationMessageOverride(){if(this.isDisposed()||this.terminateMessageLoop)return Promise.resolve();const p=new t.Deferred;try{const h=await(await this.fetchConnection()).read();if(this.isDisposed()||this.terminateMessageLoop)return p.resolve(),Promise.resolve();if(!h)return this.receiveConversationMessageOverride();const l=this.privConversationRequestSession.sessionId,v=h.conversationMessageType.toLowerCase();let f=!1;try{switch(v){case"info":case"participant_command":case"command":const g=e.CommandResponsePayload.fromJSON(h.textBody);switch(g.command.toLowerCase()){case"participantlist":const A=e.ParticipantsListPayloadResponse.fromJSON(h.textBody),M=A.participants.map(q=>({avatar:q.avatar,displayName:q.nickname,id:q.participantId,isHost:q.ishost,isMuted:q.ismuted,isUsingTts:q.usetts,preferredLanguage:q.locale}));this.privConversationServiceConnector.participantsListReceived&&this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector,new a.ParticipantsListEventArgs(A.roomid,A.token,A.translateTo,A.profanityFilter,A.roomProfanityFilter,A.roomLocked,A.muteAll,M,l));break;case"settranslatetolanguages":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new a.ParticipantAttributeEventArgs(g.participantId,n.ConversationTranslatorCommandTypes.setTranslateToLanguages,g.value,l));break;case"setprofanityfiltering":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new a.ParticipantAttributeEventArgs(g.participantId,n.ConversationTranslatorCommandTypes.setProfanityFiltering,g.value,l));break;case"setmute":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new a.ParticipantAttributeEventArgs(g.participantId,n.ConversationTranslatorCommandTypes.setMute,g.value,l));break;case"setmuteall":this.privConversationServiceConnector.muteAllCommandReceived&&this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector,new a.MuteAllEventArgs(g.value,l));break;case"roomexpirationwarning":this.privConversationServiceConnector.conversationExpiration&&this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector,new r.ConversationExpirationEventArgs(g.value,this.privConversationRequestSession.sessionId));break;case"setusetts":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new a.ParticipantAttributeEventArgs(g.participantId,n.ConversationTranslatorCommandTypes.setUseTTS,g.value,l));break;case"setlockstate":this.privConversationServiceConnector.lockRoomCommandReceived&&this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector,new a.LockRoomEventArgs(g.value,l));break;case"changenickname":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new a.ParticipantAttributeEventArgs(g.participantId,n.ConversationTranslatorCommandTypes.changeNickname,g.value,l));break;case"joinsession":const _=e.ParticipantPayloadResponse.fromJSON(h.textBody),j={avatar:_.avatar,displayName:_.nickname,id:_.participantId,isHost:_.ishost,isMuted:_.ismuted,isUsingTts:_.usetts,preferredLanguage:_.locale};this.privConversationServiceConnector.participantJoinCommandReceived&&this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector,new a.ParticipantEventArgs(j,l));break;case"leavesession":const _e={id:g.participantId};this.privConversationServiceConnector.participantLeaveCommandReceived&&this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector,new a.ParticipantEventArgs(_e,l));break;case"disconnectsession":const Fi={id:g.participantId};break;case"token":const Ui=new i.CognitiveTokenAuthentication(()=>{const q=g.token;return Promise.resolve(q)},()=>{const q=g.token;return Promise.resolve(q)});this.authentication=Ui,this.privConversationServiceConnector.onToken(Ui);break;default:break}break;case"partial":case"final":const m=e.SpeechResponsePayload.fromJSON(h.textBody),S=v==="final"?r.ResultReason.TranslatedParticipantSpeech:r.ResultReason.TranslatingParticipantSpeech,C=new r.ConversationTranslationResult(m.participantId,this.getTranslations(m.translations),m.language,m.id,S,m.recognition,void 0,void 0,h.textBody,void 0);
22m.isFinal?((C.text!==void 0&&C.text.length>0||m.id===this.privLastPartialUtteranceId)&&(f=!0),f&&this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new a.ConversationReceivedTranslationEventArgs(n.ConversationTranslatorMessageTypes.final,C,l))):C.text!==void 0&&(this.privLastPartialUtteranceId=m.id,this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new a.ConversationReceivedTranslationEventArgs(n.ConversationTranslatorMessageTypes.partial,C,l)));break;case"translated_message":const R=e.TextResponsePayload.fromJSON(h.textBody),P=new r.ConversationTranslationResult(R.participantId,this.getTranslations(R.translations),R.language,void 0,void 0,R.originalText,void 0,void 0,void 0,h.textBody,void 0);this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new a.ConversationReceivedTranslationEventArgs(n.ConversationTranslatorMessageTypes.instantMessage,P,l));break;default:break}}catch{}return this.receiveConversationMessageOverride()}catch{this.terminateMessageLoop=!0}return p.promise}async startMessageLoop(){if(this.isDisposed())return Promise.resolve();this.terminateMessageLoop=!1;const p=this.receiveConversationMessageOverride();try{return await p}catch(d){return this.cancelRecognition(this.privRequestSession?this.privRequestSession.sessionId:"",this.privRequestSession?this.privRequestSession.requestId:"",r.CancellationReason.Error,r.CancellationErrorCode.RuntimeError,d),null}}configConnection(){return this.isDisposed()?Promise.resolve(void 0):this.privConnectionConfigPromise!==void 0?this.privConnectionConfigPromise.then(p=>p.state()===t.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(p=>p),this.privConnectionConfigPromise)}getTranslations(p){let d;if(p!==void 0){d=new r.Translations;for(const h of p)d.set(h.lang,h.translation)}return d}};return Ii.ConversationServiceAdapter=s,Ii}var Xu;function ag(){if(Xu)return ye;Xu=1,Object.defineProperty(ye,"__esModule",{value:!0}),ye.ConversationTranslatorRecognizer=ye.ConversationRecognizerFactory=void 0;const t=E(),r=I(),i=T(),u=y(),o=eg(),a=og();class n{static fromConfig(c,p,d){return new e(c,p,d)}}ye.ConversationRecognizerFactory=n;let e=class extends u.Recognizer{constructor(c,p,d){const h=p;i.Contracts.throwIfNull(h,"speechConfig");const l=c;i.Contracts.throwIfNull(l,"conversationImpl"),super(d,h.properties,new o.ConversationConnectionFactory),this.privConversation=l,this.privIsDisposed=!1,this.privProperties=h.properties.clone(),this.privConnection=u.Connection.fromRecognizer(this),this.privProperties.getProperty(u.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?(this.privSetTimeout=r.Timeout.setTimeout,this.privClearTimeout=r.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(c){this.privConnection.connected=c}set disconnected(c){this.privConnection.disconnected=c}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get properties(){return this.privProperties}isDisposed(){return this.privIsDisposed}connect(c,p,d){try{i.Contracts.throwIfDisposed(this.privIsDisposed),i.Contracts.throwIfNullOrWhitespace(c,"token"),this.privReco.conversationTranslatorToken=c,this.resetConversationTimeout(),this.privReco.connectAsync(p,d)}catch(h){if(d)if(h instanceof Error){const l=h;d(l.name+": "+l.message)}else d(h)}}disconnect(c,p){try{i.Contracts.throwIfDisposed(this.privIsDisposed),this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privReco.disconnect().then(()=>{c&&c()},d=>{p&&p(d)})}catch(d){if(p)if(d instanceof Error){const h=d;p(h.name+": "+h.message)}else p(d);this.dispose(!0).catch(h=>
22{r.Events.instance.onEvent(new r.BackgroundEvent(h))})}}sendRequest(c,p,d){try{i.Contracts.throwIfDisposed(this.privIsDisposed),this.sendMessage(c,p,d)}catch(h){if(d)if(h instanceof Error){const l=h;d(l.name+": "+l.message)}else d(h);this.dispose(!0).catch(l=>{r.Events.instance.onEvent(new r.BackgroundEvent(l))})}}onToken(c){this.privConversation.onToken(c)}async close(){this.privIsDisposed||(this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close()),this.privConnection=void 0,await this.dispose(!0))}async dispose(c){this.privIsDisposed||c&&(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(c))}createRecognizerConfig(c){return new t.RecognizerConfig(c,this.privProperties)}createServiceRecognizer(c,p,d,h){const l=d;return new a.ConversationServiceAdapter(c,p,l,h,this)}sendMessage(c,p,d){const h=this.privReco;((v,f,g)=>{v!==void 0?v.then(()=>{try{f&&f()}catch(m){g&&g(`'Unhandled error on promise callback: ${m}'`)}},m=>{try{g&&g(m)}catch{}}):g&&g("Null promise")})(h.sendMessageAsync(c),p,d),this.resetConversationTimeout()}resetConversationTimeout(){this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privTimeoutToken=this.privSetTimeout(()=>{this.sendRequest(this.privConversation.getKeepAlive())},6e4)}};return ye.ConversationTranslatorRecognizer=e,ye}var wi={},Zu;function cg(){if(Zu)return wi;Zu=1,Object.defineProperty(wi,"__esModule",{value:!0}),wi.TranscriberRecognizer=void 0;const t=I(),r=T(),i=y(),u=E();let o=class extends i.Recognizer{constructor(n,e){const s=n;r.Contracts.throwIfNull(s,"speechTranslationConfig");const c=e;r.Contracts.throwIfNull(c,"audioConfigImpl"),r.Contracts.throwIfNullOrWhitespace(s.speechRecognitionLanguage,i.PropertyId[i.PropertyId.SpeechServiceConnection_RecoLanguage]),super(e,s.properties,new u.TranscriberConnectionFactory),this.privDisposedRecognizer=!1,this.isMeetingRecognizer=!1}get speechRecognitionLanguage(){return r.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(i.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(i.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(n){r.Contracts.throwIfNullOrWhitespace(n,"token"),this.properties.setProperty(i.PropertyId.SpeechServiceAuthorization_Token,n)}set conversation(n){r.Contracts.throwIfNullOrUndefined(n,"Conversation"),this.isMeetingRecognizer=!1,this.privConversation=n}getConversationInfo(){return r.Contracts.throwIfNullOrUndefined(this.privConversation,"Conversation"),this.privConversation.conversationInfo}set meeting(n){r.Contracts.throwIfNullOrUndefined(n,"Meeting"),this.isMeetingRecognizer=!0,this.privMeeting=n}getMeetingInfo(){return r.Contracts.throwIfNullOrUndefined(this.privMeeting,"Meeting"),this.privMeeting.meetingInfo}IsMeetingRecognizer(){return this.isMeetingRecognizer}startContinuousRecognitionAsync(n,e){t.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(u.RecognitionMode.Conversation),n,e)}stopContinuousRecognitionAsync(n,e){t.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),n,e)}async close(){this.privDisposedRecognizer||await this.dispose(!0)}async pushConversationEvent(n,e){const s=this.privReco;r.Contracts.throwIfNullOrUndefined(s,"serviceRecognizer"),await s.sendSpeechEventAsync(n,e)}async pushMeetingEvent(n,e){const s=this.privReco;r.Contracts.throwIfNullOrUndefined(s,"serviceRecognizer"),await s.sendMeetingSpeechEventAsync(n,e)}async enforceAudioGating(){const s=(await this.audioConfig.format).channels;if(s===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 [email protected] for more details")}else if(s!==8)throw new Error(`Unsupported audio configuration: Detected ${s}-channel audio`)}connectMeetingCallbacks(n){this.isMeetingRecognizer=!0,this.canceled=(e,s)=>{n.canceled&&n.canceled(n,s)},this.recognizing=(e,s)=>{n.transcribing&&n.transcribing(n,s)},this.recognized=(e,s)=>{n.transcribed&&n.transcribed(n,s)},this.sessionStarted=(e,s)=>{n.sessionStarted&&n.sessionStarted(n,s)},this.sessionStopped=(e,s)=>{n.sessionStopped&&n.sessionStopped(n,s)}}disconnectCallbacks(){this.canceled=void 0,this.recognizing=void 0,this.recognized=void 0,this.sessionStarted=void 0,this.sessionStopped=void 0}async dispose(n){this.privDisposedRecognizer||(n&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(n))}createRecognizerConfig(n){return new u.RecognizerConfig(n,this.properties)}createServiceRecognizer(n,e,s,c){const p=s;return new u.TranscriptionServiceRecognizer(n,e,p,c,this)}};return wi.TranscriberRecognizer=o,wi}var Yu;function ug(){return Yu||(Yu=1,(function(t){Object.defineProperty(t,"__esMo
22dule",{value:!0});var r=Zf();Object.defineProperty(t,"ConversationManager",{enumerable:!0,get:function(){return r.ConversationManager}});var i=fs();Object.defineProperty(t,"ConversationConnectionConfig",{enumerable:!0,get:function(){return i.ConversationConnectionConfig}});var u=ag();Object.defineProperty(t,"ConversationRecognizerFactory",{enumerable:!0,get:function(){return u.ConversationRecognizerFactory}});var o=cg();Object.defineProperty(t,"TranscriberRecognizer",{enumerable:!0,get:function(){return o.TranscriberRecognizer}});var a=vd();Object.defineProperty(t,"ConversationReceivedTranslationEventArgs",{enumerable:!0,get:function(){return a.ConversationReceivedTranslationEventArgs}}),Object.defineProperty(t,"LockRoomEventArgs",{enumerable:!0,get:function(){return a.LockRoomEventArgs}}),Object.defineProperty(t,"MuteAllEventArgs",{enumerable:!0,get:function(){return a.MuteAllEventArgs}}),Object.defineProperty(t,"ParticipantAttributeEventArgs",{enumerable:!0,get:function(){return a.ParticipantAttributeEventArgs}}),Object.defineProperty(t,"ParticipantEventArgs",{enumerable:!0,get:function(){return a.ParticipantEventArgs}}),Object.defineProperty(t,"ParticipantsListEventArgs",{enumerable:!0,get:function(){return a.ParticipantsListEventArgs}});var n=fd();Object.defineProperty(t,"ConversationTranslatorCommandTypes",{enumerable:!0,get:function(){return n.ConversationTranslatorCommandTypes}}),Object.defineProperty(t,"ConversationTranslatorMessageTypes",{enumerable:!0,get:function(){return n.ConversationTranslatorMessageTypes}}),Object.defineProperty(t,"InternalParticipants",{enumerable:!0,get:function(){return n.InternalParticipants}})})(Jn)),Jn}var Qn={},ep;function md(){return ep||(ep=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesisAudioMetadata=t.MetadataType=void 0,(function(i){i.WordBoundary="WordBoundary",i.Bookmark="Bookmark",i.Viseme="Viseme",i.SentenceBoundary="SentenceBoundary",i.SessionEnd="SessionEnd",i.AvatarSignal="TalkingAvatarSignal"})(t.MetadataType||(t.MetadataType={}));class r{constructor(u){this.privSynthesisAudioMetadata=JSON.parse(u)}static fromJSON(u){return new r(u)}get Metadata(){return this.privSynthesisAudioMetadata.Metadata}}t.SynthesisAudioMetadata=r})(Qn)),Qn}var _i={},W={},tp;function pg(){if(tp)return W;tp=1,Object.defineProperty(W,"__esModule",{value:!0}),W.SynthesisStartedEvent=W.ConnectingToSynthesisServiceEvent=W.SynthesisTriggeredEvent=W.SpeechSynthesisEvent=void 0;const t=I();class r extends t.PlatformEvent{constructor(n,e,s=t.EventType.Info){super(n,s),this.privRequestId=e}get requestId(){return this.privRequestId}}W.SpeechSynthesisEvent=r;class i extends r{constructor(n,e,s){super("SynthesisTriggeredEvent",n),this.privSessionAudioDestinationId=e,this.privTurnAudioDestinationId=s}get audioSessionDestinationId(){return this.privSessionAudioDestinationId}get audioTurnDestinationId(){return this.privTurnAudioDestinationId}}W.SynthesisTriggeredEvent=i;class u extends r{constructor(n,e){super("ConnectingToSynthesisServiceEvent",n),this.privAuthFetchEventId=e}get authFetchEventId(){return this.privAuthFetchEventId}}W.ConnectingToSynthesisServiceEvent=u;class o extends r{constructor(n,e){super("SynthesisStartedEvent",n),this.privAuthFetchEventId=e}get authFetchEventId(){return this.privAuthFetchEventId}}return W.SynthesisStartedEvent=o,W}var rp;function dg(){if(rp)return _i;rp=1,Object.defineProperty(_i,"__esModule",{value:!0}),_i.SynthesisTurn=void 0;const t=I(),r=Me(),i=y(),u=md(),o=pg();let a=class as{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=t.createNoDashGuid(),this.privTurnDeferral=new t.Deferred,this.privTurnDeferral.resolve()}get requestId(){return this.privRequestId}get streamId(){return this.privStreamId}set streamId(e){this.privStreamId=e}get audioOutputFormat(){return this.privAudioOutputFormat}set audioOutputFormat(e){this.privAudioOutputFormat=e}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSynthesisEnded(){return this.privIsSynthesisEnded}get isSynthesizing(){return this.privIsSynthesizing}get currentTextOffset(){return this.privTextOffset}get currentSentenceOffset(){return this.privSentenceOffset}get bytesReceived(){return this.privBytesReceived}get audioDuration(){return this.privAudioDuration}get extraProperties(){if(this.privWebRTCSDP){const e=new i.PropertyCollection;return e.setProperty(i.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}
22async getAllReceivedAudioWithHeader(){if(this.privReceivedAudioWithHeader)return this.privReceivedAudioWithHeader;if(!this.privIsSynthesisEnded)return null;if(this.audioOutputFormat.hasHeader){const e=await this.getAllReceivedAudio();return this.privReceivedAudioWithHeader=this.audioOutputFormat.addHeader(e),this.privReceivedAudioWithHeader}else return this.getAllReceivedAudio()}startNewSynthesis(e,s,c,p){this.privIsSynthesisEnded=!1,this.privIsSynthesizing=!0,this.privRequestId=e,this.privRawText=s,this.privIsSSML=c,this.privAudioOutputStream=new r.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="",p!==void 0&&(this.privTurnAudioDestination=p,this.privTurnAudioDestination.format=this.privAudioOutputFormat),this.onEvent(new o.SynthesisTriggeredEvent(this.requestId,void 0,p===void 0?void 0:p.id()))}onPreConnectionStart(e){this.privAuthFetchEventId=e,this.onEvent(new o.ConnectingToSynthesisServiceEvent(this.privRequestId,this.privAuthFetchEventId))}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){if(e===200){this.onEvent(new o.SynthesisStartedEvent(this.requestId,this.privAuthFetchEventId)),this.privBytesReceived=0;return}else e===403&&this.onComplete()}onServiceResponseMessage(e){const s=JSON.parse(e);this.streamId=s.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 t.Deferred;const s=JSON.parse(e);s.webrtc&&(this.privWebRTCSDP=s.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(){const e=await this.getAllReceivedAudioWithHeader();return new i.SpeechSynthesisResult(this.requestId,i.ResultReason.SynthesizingAudioCompleted,e,void 0,this.extraProperties,this.audioDuration)}dispose(){this.privIsDisposed||(this.privIsDisposed=!0)}onStopSynthesizing(){this.onComplete()}getAndClearVisemeAnimation(){const e=this.privPartialVisemeAnimation;return this.privPartialVisemeAnimation="",e}onEvent(e){t.Events.instance.onEvent(e)}static isXmlTag(e){return e.length>=2&&e[0]==="<"&&e[e.length-1]===">"}updateTextOffset(e,s){s===u.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)&&!as.isXmlTag(e)&&this.updateTextOffset(e,s))):(this.privSentenceOffset=this.privRawText.indexOf(e,this.privNextSearchSentenceIndex),this.privSentenceOffset>=0&&(this.privNextSearchSentenceIndex=this.privSentenceOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privSentenceOffset)&&!as.isXmlTag(e)&&this.updateTextOffset(e,s)))}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)}};return _i.SynthesisTurn=a,_i}var bi={},ip;function hg(){if(ip)return bi;ip=1,Object.defineProperty(bi,"__esModule",{value:!0}),bi.SynthesisAdapterBase=void 0;const t=I(),r=y(),i=E(),u=Oe();let o=class{constructor(n,e,s,c){if(this.speakOverride=void 0,this.receiveMessageOverride=void 0,this.connectImplOverride=void 0,this.configConnectionOverride=void 0,this.privConnectionConfigurationPromise=void 0,!n)throw new t.ArgumentNullError("authentication");if(!e)throw new t.ArgumentNullError("connectionFactory");if(!s)throw new t.ArgumentNullError("synthesizerConfig");this.privAuthentication=n,this.privConnectionFactory=e,this.privSynthesizerConfig=s,this.privIsDisposed=!1,this.privSessionAudioDestination=c,this.privSynthesisTurn=new i.SynthesisTurn,this.privConnectionEvents=new t.EventSource,this.privServiceEvents=new t.EventSource,this.privSynthesisContext=new i.SynthesisContext,this.privAgentConfig=new i.AgentConfig,this.connectionEvents.attach(p=>{if(p.name==="ConnectionClosedEvent"){const d=p;d.statusCode!==1e3&&this.cancelSynthesisLocal(r.CancellationReason.Error,d.statusCode===1007?r.CancellationErrorCode.BadRequestParameters:r.CancellationErrorCode.ConnectionFailure,`${d.reason} websocket error code: ${d.statusCode}`)}})}get synthesisContext(){return this.privSynthesisContext}get agentConfig(){return this.privAgentConfig}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}set activityTemplate(n){this.privActivityTemplate=n}get activityTemplate(){return this.privActivityTemplate}set audioOutputFormat(n){this.privAudioOutputFormat=n,this.privSynthesisTurn.audioOutputFormat=n,this.privSessionAudioDestination!==void 0&&(this.privSessionAudioDestination.format=n),this.synthesisContext!==void 0&&(this.synthesisContext.audioOutputFormat=n)}isDisposed(){return this.privIsDisposed}async dispose(n){this.privIsDisposed=!0,this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.close(),this.privConnectionConfigurationPromise!==void 0&&await(await this.privConnectionConfigurationPromise).dispose(n)}async connect(){await this.connectImpl()}async sendNetworkMessage(n,e){const s=typeof e=="string"?t.MessageType.Text:t.MessageType.Binary,c=typeof e=="string"?"application/json":"";return(await this.fetchConnection()).send(new u.SpeechConnectionMessage(s,n,this.privSynthesisTurn.requestId,c,e))}async Speak(n,e,s,c,p,d){let h;if(e?h=n:h=this.privSynthesizer.buildSsml(n),this.speakOverride!==void 0)return this.speakOverride(h,s,c,p);this.privSuccessCallback=c,this.privErrorCallback=p,this.privSynthesisTurn.startNewSynthesis(s,n,e,d);try{await this.connectImpl();const l=await this.fetchConnection();await this.sendSynthesisContext(l),await this.sendSsmlMessage(l,h,s),this.onSynthesisStarted(s),this.receiveMessage()}catch(l){return this.cancelSynthesisLocal(r.CancellationReason.Error,r.CancellationErrorCode.ConnectionFailure,l),Promise.reject(l)}}async stopSpeaking(){return await this.connectImpl(),(await this.fetchConnection()).send(new u.SpeechConnectionMessage(t.MessageType.Text,"synthesis.control",this.privSynthesisTurn.requestId,"application/json",JSON.stringify({action:"stop"})))}
22cancelSynthesis(n,e,s,c){const p=new r.PropertyCollection;p.setProperty(i.CancellationErrorCodePropertyName,r.CancellationErrorCode[s]);const d=new r.SpeechSynthesisResult(n,r.ResultReason.Canceled,void 0,c,p);if(this.onSynthesisCancelled(d),this.privSuccessCallback)try{this.privSuccessCallback(d)}catch{}}cancelSynthesisLocal(n,e,s){this.privSynthesisTurn.isSynthesizing&&(this.privSynthesisTurn.onStopSynthesizing(),this.cancelSynthesis(this.privSynthesisTurn.requestId,n,e,s))}processTypeSpecificMessages(n){return!0}async receiveMessage(){try{const e=await(await this.fetchConnection()).read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(this.privIsDisposed)return;if(!e)return this.privSynthesisTurn.isSynthesizing?this.receiveMessage():void 0;const s=u.SpeechConnectionMessage.fromConnectionMessage(e);if(s.requestId.toLowerCase()===this.privSynthesisTurn.requestId.toLowerCase())switch(s.path.toLowerCase()){case"turn.start":this.privSynthesisTurn.onServiceTurnStartResponse(s.textBody);break;case"response":this.privSynthesisTurn.onServiceResponseMessage(s.textBody);break;case"audio":this.privSynthesisTurn.streamId.toLowerCase()===s.streamId.toLowerCase()&&s.binaryBody&&(this.privSynthesisTurn.onAudioChunkReceived(s.binaryBody),this.onSynthesizing(s.binaryBody),this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.write(s.binaryBody));break;case"audio.metadata":const c=i.SynthesisAudioMetadata.fromJSON(s.textBody).Metadata;for(const d of c)switch(d.Type){case i.MetadataType.WordBoundary:case i.MetadataType.SentenceBoundary:this.privSynthesisTurn.onTextBoundaryEvent(d);const h=new r.SpeechSynthesisWordBoundaryEventArgs(d.Data.Offset,d.Data.Duration,d.Data.text.Text,d.Data.text.Length,d.Type===i.MetadataType.WordBoundary?this.privSynthesisTurn.currentTextOffset:this.privSynthesisTurn.currentSentenceOffset,d.Data.text.BoundaryType);this.onWordBoundary(h);break;case i.MetadataType.Bookmark:const l=new r.SpeechSynthesisBookmarkEventArgs(d.Data.Offset,d.Data.Bookmark);this.onBookmarkReached(l);break;case i.MetadataType.Viseme:if(this.privSynthesisTurn.onVisemeMetadataReceived(d),d.Data.IsLastAnimation){const v=new r.SpeechSynthesisVisemeEventArgs(d.Data.Offset,d.Data.VisemeId,this.privSynthesisTurn.getAndClearVisemeAnimation());this.onVisemeReceived(v)}break;case i.MetadataType.AvatarSignal:this.onAvatarEvent(d);break;case i.MetadataType.SessionEnd:this.privSynthesisTurn.onSessionEnd(d);break}break;case"turn.end":this.privSynthesisTurn.onServiceTurnEndResponse();let p;try{p=await this.privSynthesisTurn.constructSynthesisResult(),this.privSuccessCallback&&this.privSuccessCallback(p)}catch(d){this.privErrorCallback&&this.privErrorCallback(d)}this.onSynthesisCompleted(p);break;default:this.processTypeSpecificMessages(s)||this.privServiceEvents&&this.serviceEvents.onEvent(new t.ServiceEvent(s.path.toLowerCase(),s.textBody))}return this.receiveMessage()}catch{}}sendSynthesisContext(n){this.setSynthesisContextSynthesisSection();const e=this.synthesisContext.toJSON();if(e)return n.send(new u.SpeechConnectionMessage(t.MessageType.Text,"synthesis.context",this.privSynthesisTurn.requestId,"application/json",e))}setSpeechConfigSynthesisSection(){}connectImpl(n=!1){if(this.privConnectionPromise!=null)return this.privConnectionPromise.then(s=>s.state()===t.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()));this.privAuthFetchEventId=t.createNoDashGuid(),this.privConnectionId=t.createNoDashGuid(),this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId);const e=n?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId);return this.privConnectionPromise=e.then(async s=>{this.privSynthesisTurn.onAuthCompleted(!1);const c=this.privConnectionFactory.create(this.privSynthesizerConfig,s,this.privConnectionId);c.events.attach(d=>{this.connectionEvents.onEvent(d)});const p=await c.open();return p.statusCode===200?(this.privSynthesisTurn.onConnectionEstablishCompleted(p.statusCode),Promise.resolve(c)):p.statusCode===403&&!n?this.connectImpl(!0):(this.privSynthesisTurn.onConnectionEstablishCompleted(p.statusCode),Promise.reject(`Unable to contact server. StatusCode: ${p.statusCode},
23                    ${this.privSynthesizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Url)} Reason: ${p.reason}`))},s=>{throw this.privSynthesisTurn.onAuthCompleted(!0),new Error(s)}),this.privConnectionPromise.catch(()=>{}),this.privConnectionPromise}sendSpeechServiceConfig(n,e){if(e)return n.send(new u.SpeechConnectionMessage(t.MessageType.Text,"speech.config",this.privSynthesisTurn.requestId,"application/json",e))}sendSsmlMessage(n,e,s){return n.send(new u.SpeechConnectionMessage(t.MessageType.Text,"ssml",s,"application/ssml+xml",e))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(n=>n.state()===t.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async configureConnection(){const n=await this.connectImpl();return this.configConnectionOverride!==void 0?this.configConnectionOverride(n):(this.setSpeechConfigSynthesisSection(),await this.sendSpeechServiceConfig(n,this.privSynthesizerConfig.SpeechServiceConfig.serialize()),n)}onAvatarEvent(n){}onSynthesisStarted(n){}onSynthesizing(n){}onSynthesisCancelled(n){}onSynthesisCompleted(n){}onWordBoundary(n){}onVisemeReceived(n){}onBookmarkReached(n){}};return bi.SynthesisAdapterBase=o,o.telemetryDataEnabled=!0,bi}var Mi={},np;function lg(){if(np)return Mi;np=1,Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.AvatarSynthesisAdapter=void 0;const t=y(),r=E();let i=class extends r.SynthesisAdapterBase{constructor(o,a,n,e,s){super(o,a,n,void 0),this.privAvatarSynthesizer=e,this.privSynthesizer=e,this.privAvatarConfig=s}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(void 0)}setSpeechConfigSynthesisSection(){var o,a,n,e,s,c,p,d,h,l,v,f,g,m,S,C;this.privSynthesizerConfig.synthesisVideoSection={format:{bitrate:(o=this.privAvatarConfig.videoFormat)==null?void 0:o.bitrate,codec:(a=this.privAvatarConfig.videoFormat)==null?void 0:a.codec,crop:{bottomRight:{x:(s=(e=(n=this.privAvatarConfig.videoFormat)==null?void 0:n.cropRange)==null?void 0:e.bottomRight)==null?void 0:s.x,y:(d=(p=(c=this.privAvatarConfig.videoFormat)==null?void 0:c.cropRange)==null?void 0:p.bottomRight)==null?void 0:d.y},topLeft:{x:(v=(l=(h=this.privAvatarConfig.videoFormat)==null?void 0:h.cropRange)==null?void 0:l.topLeft)==null?void 0:v.x,y:(m
23=(g=(f=this.privAvatarConfig.videoFormat)==null?void 0:f.cropRange)==null?void 0:g.topLeft)==null?void 0:m.y}},resolution:{height:(S=this.privAvatarConfig.videoFormat)==null?void 0:S.height,width:(C=this.privAvatarConfig.videoFormat)==null?void 0:C.width}},protocol:{name:"WebRTC",webrtcConfig:{clientDescription:btoa(this.privSynthesizerConfig.parameters.getProperty(t.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(o){if(this.privAvatarSynthesizer.avatarEventReceived){const a=new t.AvatarEventArgs(o.Data.Offset,o.Data.Name);try{this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer,a)}catch{}}}};return Mi.AvatarSynthesisAdapter=i,Mi}var Oi={},sp;function vg(){if(sp)return Oi;sp=1,Object.defineProperty(Oi,"__esModule",{value:!0}),Oi.SpeechSynthesisAdapter=void 0;const t=y(),r=E();let i=class extends r.SynthesisAdapterBase{constructor(o,a,n,e,s){super(o,a,n,s),this.privSpeechSynthesizer=e,this.privSynthesizer=e}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(this.privSpeechSynthesizer)}onSynthesisStarted(o){const a=new t.SpeechSynthesisEventArgs(new t.SpeechSynthesisResult(o,t.ResultReason.SynthesizingAudioStarted));this.privSpeechSynthesizer.synthesisStarted&&this.privSpeechSynthesizer.synthesisStarted(this.privSpeechSynthesizer,a)}onSynthesizing(o){if(this.privSpeechSynthesizer.synthesizing)try{const a=this.privSynthesisTurn.audioOutputFormat.addHeader(o),n=new t.SpeechSynthesisEventArgs(new t.SpeechSynthesisResult(this.privSynthesisTurn.requestId,t.ResultReason.SynthesizingAudio,a));this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer,n)}catch{}}onSynthesisCancelled(o){if(this.privSpeechSynthesizer.SynthesisCanceled){const a=new t.SpeechSynthesisEventArgs(o);try{this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer,a)}catch{}}}onSynthesisCompleted(o){if(this.privSpeechSynthesizer.synthesisCompleted)try{this.privSpeechSynthesizer.synthesisCompleted(this.privSpeechSynthesizer,new t.SpeechSynthesisEventArgs(o))}catch{}}onWordBoundary(o){if(this.privSpeechSynthesizer.wordBoundary)try{this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer,o)}catch{}}onVisemeReceived(o){if(this.privSpeechSynthesizer.visemeReceived)try{this.privSpeechSynthesizer.visemeReceived(this.privSpeechSynthesizer,o)}catch{}}onBookmarkReached(o){if(this.privSpeechSynthesizer.bookmarkReached)try{this.privSpeechSynthesizer.bookmarkReached(this.privSpeechSynthesizer,o)}catch{}}};return Oi.SpeechSynthesisAdapter=i,Oi}var Di={},op;function fg(){if(op)return Di;op=1,Object.defineProperty(Di,"__esModule",{value:!0}),Di.SynthesisRestAdapter=void 0;const t=D(),r=y(),i=H(),u=N();let o=class{constructor(n,e){let s=n.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint,void 0);if(!s){const p=n.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Region,"westus"),d=i.ConnectionFactoryBase.getHostSuffix(p);s=n.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host,`https://${p}.tts.speech${d}`)}this.privUri=`${s}/cognitiveservices/voices/list`;const c=t.RestConfigBase.requestOptions;this.privRestAdapter=new t.RestMessageAdapter(c),this.privAuthentication=e}getVoicesList(n){return this.privRestAdapter.setHeaders(u.HeaderNames.ConnectionId,n),this.privAuthentication.fetch(n).then(e=>(this.privRestAdapter.setHeaders(e.headerName,e.token),this.privRestAdapter.request(t.RestRequestType.Get,this.privUri)))}};return Di.SynthesisRestAdapter=o,Di}var Xn={},ap;function gg(){return ap||(ap=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SynthesizerConfig=t.SynthesisServiceType=void 0;const r=E();var i;(function(o){o[o.Standard=0]="Standard",o[o.Custom=1]="Custom"})(i=t.SynthesisServiceType||(t.SynthesisServiceType={}));class u{constructor(a,n){this.privSynthesisServiceType=i.Standard,this.avatarEnabled=!1,this.privSpeechServiceConfig=a||new r.SpeechServiceConfig(new r.Context(null)),this.privParameters=n}get parameters(){return this.privParameters}get synthesisServiceType(){return this.privSynthesisServiceType}set synthesisServiceType(a){this.privSynthesisServiceType=a}set synthesisVideoSection(a){this.privSpeechServiceConfig.Context.synthesis={video:a}}get SpeechServiceConfig(){return this.privSpeechServiceConfig}}t.SynthesizerConfig=u})(Xn)),Xn}var ki={},cp;function mg(){if(cp)return ki;cp=1,Object.defineProperty(ki,"__esModule",{value:!0}),ki.SynthesisContext=void 0;const t=y();let r=class{constructor(){this.privContext={}}setSection(u,o){this.privContext[u]=o}set audioOutputFormat(u){this.privAudioOutputFormat=u}toJSON(){return JSON.stringify(this.privContext)}setSynthesisSection(u){const o=this.buildSynthesisContext(u);this.setSection("synthesis",o)}buildSynthesisContext(u){return{audio:{metadataOptions:{bookmarkEnabled:!!(u!=null&&u.bookmarkReached),punctuationBoundaryEnabled:u==null?void 0:u.properties.getProperty(t.PropertyId.SpeechServiceResponse_RequestPunctuationBoundary,!!(u!=null&&u.wordBoundary)),sentenceBoundaryEnabled:u==null?void 0:u.properties.getProperty(t.PropertyId.SpeechServiceResponse_RequestSentenceBoundary,!1),sessionEndEnabled:!0,visemeEnabled:!!(u!=null&&u.visemeReceived),wordBoundaryEnabled:u==null?void 0:u.properties.getProperty(t.PropertyId.SpeechServiceResponse_RequestWordBoundary,!!(u!=null&&u.wordBoundary))},outputFormat:this.privAudioOutputFormat.requestAudioFormatString},language:{autoDetection:u==null?void 0:u.autoDetectSourceLanguage}}}};return ki.SynthesisContext=r,ki}var Ni={},up;function Sg(){if(up)return Ni;up=1,Object.defineProperty(Ni,"__esModule",{value:!0}),Ni.SpeakerRecognitionConfig=void 0;const t=E();let r=class{constructor(u,o){this.privContext=u||new t.Context(null),this.privParameters=o}get parameters(){return this.privParameters}get Context(){return this.privContext}};return Ni.SpeakerRecognitionConfig=r,Ni}var zi={},pp;function Cg(){if(pp)return zi;pp=1,Object.defineProperty(zi,"__esModule",{value:!0}),zi.SpeakerServiceRecognizer=void 0;const t=D(),r=I(),i=y(),u=E(),o=Oe();let a=class extends u.ServiceRecognizerBase{constructor(e,s,c,p,d){super(e,s,c,p,d),this.privSpeakerRecognizer=d,this.privSpeakerAudioSource=c,this.recognizeSpeaker=h=>this.recognizeSpeakerOnce(h),this.sendPrePayloadJSONOverride=()=>this.noOp()}processTypeSpecificMessages(e){let s=!1;const c=new i.PropertyCollection;switch(e.messageType===r.MessageType.Text&&c.setProperty(i.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.response":const d=JSON.parse(e.textBody);let h;d.status.statusCode.toLowerCase()!=="success"?h=new i.SpeakerRecognitionResult(d,i.ResultReason.Canceled,i.CancellationErrorCode.ServiceError,d.status.reason):h=new i.SpeakerRecognitionResult(d,i.ResultReason.RecognizedSpeaker),this.privResultDeferral&&this.privResultDeferral.resolve(h),s=!0;break}const p=new r.Deferred;return p.resolve(s),p.promise}cancelRecognition(e,s,c,p,d){if(new i.PropertyCollection().setProperty(u.CancellationErrorCodePropertyName,i.CancellationErrorCode[p]),this.privResultDeferral){const l=new i.SpeakerRecognitionResult({scenario:this.privSpeakerModel.sce
23nario,status:{statusCode:d,reason:d}},i.ResultReason.Canceled,p,d);try{this.privResultDeferral.resolve(l)}catch(v){this.privResultDeferral.reject(v)}}}async recognizeSpeakerOnce(e){this.privSpeakerModel=e,this.voiceProfileType=e.scenario,this.privResultDeferral||(this.privResultDeferral=new r.Deferred),this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(i.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);const s=this.connectImpl(),c=this.sendPreAudioMessages(this.extractSpeakerContext(e)),p=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),d=await this.privSpeakerAudioSource.format,h=await this.privSpeakerAudioSource.deviceInfo,l=new t.ReplayableAudioNode(p,d.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(l,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:h};try{await s,await c}catch(g){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,i.CancellationReason.Error,i.CancellationErrorCode.ConnectionFailure,g)}const v=new i.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,v),this.receiveMessage(),this.sendAudio(l).then(()=>{},g=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,i.CancellationReason.Error,i.CancellationErrorCode.RuntimeError,g)}),this.privResultDeferral.promise}async sendPreAudioMessages(e){const s=await this.fetchConnection();await this.sendSpeakerRecognition(s,e)}async sendSpeakerRecognition(e,s){const c=JSON.stringify(s);return e.send(new o.SpeechConnectionMessage(r.MessageType.Text,"speaker.context",this.privRequestSession.requestId,"application/json; charset=utf-8",c))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}};return zi.SpeakerServiceRecognizer=a,zi}var ji={},dp;function yg(){if(dp)return ji;dp=1,Object.defineProperty(ji,"__esModule",{value:!0}),ji.VoiceServiceRecognizer=void 0;const t=D(),r=I(),i=y(),u=E(),o=Oe();let a=class extends u.ServiceRecognizerBase{constructor(e,s,c,p,d){super(e,s,c,p,d),this.privDeferralMap=new r.DeferralMap,this.privSpeakerAudioSource=c,this.sendPrePayloadJSONOverride=()=>this.noOp()}set SpeakerAudioSource(e){this.privSpeakerAudioSource=e}processTypeSpecificMessages(e){let s=!1;const c=new i.PropertyCollection;switch(e.messageType===r.MessageType.Text&&c.setProperty(i.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.profiles":const d=JSON.parse(e.textBody);switch(d.operation.toLowerCase()){case"create":this.handleCreateResponse(d,e.requestId);break;case"delete":case"reset":this.handleResultResponse(d,e.requestId);break;case"fetch":const f=JSON.parse(e.textBody);this.handleFetchResponse(f,e.requestId);break}s=!0;break;case"speaker.phrases":const h=JSON.parse(e.textBody);this.handlePhrasesResponse(h,e.requestId),s=!0;break;case"speaker.profile.enrollment":const l=JSON.parse(e.textBody),v=new i.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(l.enrollment?l.enrollment.enrollmentStatus:l.status.statusCode),l.enrollment?JSON.stringify(l.enrollment):void 0,l.status.reason);this.privDeferralMap.getId(e.requestId)&&this.privDeferralMap.complete(e.requestId,v),this.privRequestSession.onSpeechEnded(),s=!0;break}const p=new r.Deferred;return p.resolve(s),p.promise}cancelRecognition(e,s,c,p,d){new i.PropertyCollection().setProperty(u.CancellationErrorCodePropertyName,i.CancellationErrorCode[p]);const l=new i.VoiceProfileEnrollmentResult(i.ResultReason.Canceled,d,d);this.privDeferralMap.getId(s)&&this.privDeferralMap.complete(s,l)}async createProfile(e,s){this.voiceProfileType=e.toString();const c=this.connectImpl();try{const p=new r.Deferred;return await c,await this.sendCreateProfile(p,e,s),this.receiveMessage(),p.promise}catch(p){throw p}}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,s){this.voiceProfileType=e.toString();const c=this.connectImpl();try{const p=new r.Deferred;return await c,await this.sendPhrasesRequest(p,e,s),this.receiveMessage(),p.promise}catch(p){throw p}}async enrollProfile(e){this.voiceProfileType=e.profileType.toString();const s=new r.Deferred;this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(i.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);const c=this.connectImpl(),p=this.sendPreAudioMessages(e,s),d=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),h=await this.privSpeakerAudioSource.format,l=await this.privSpeakerAudioSource.deviceInfo,v=new t.ReplayableAudioNode(d,h.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(v,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:l};try{await c,await p}catch(m){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,i.CancellationReason.Error,i.CancellationErrorCode.ConnectionFailure,m)}const f=new i.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,f),this.receiveMessage(),this.sendAudio(v).then(()=>{},m=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,i.CancellationReason.Error,i.CancellationErrorCode.RuntimeError,m)}),s.promise}async sendPreAudioMessages(e,s){const c=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,s),await this.sendBaseRequest
23(c,"enroll",this.scenarioFrom(e.profileType),e)}async sendPhrasesRequest(e,s,c){const p=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);const d=this.scenarioFrom(s),h={locale:c,scenario:d};return p.send(new o.SpeechConnectionMessage(r.MessageType.Text,"speaker.profile.phrases",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(h)))}async sendCreateProfile(e,s,c){const p=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);const d=s===i.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":s===i.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification",h={locale:c,number:"1",scenario:d};return p.send(new o.SpeechConnectionMessage(r.MessageType.Text,"speaker.profile.create",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(h)))}async sendCommonRequest(e,s,c=void 0){const p=this.connectImpl();try{const d=new r.Deferred;this.privRequestSession.onSpeechContext(),await p;const h=await this.fetchConnection();return this.privDeferralMap.add(this.privRequestSession.requestId,d),await this.sendBaseRequest
23(h,e,this.scenarioFrom(s),c),this.receiveMessage(),d.promise}catch(d){throw d}}async sendBaseRequest(e,s,c,p){const d={scenario:c};return p?d.profileIds=[p.profileId]:d.maxPageSize=-1,e.send(new o.SpeechConnectionMessage(r.MessageType.Text,`speaker.profile.${s}`,this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(d)))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}handlePhrasesResponse(e,s){if(this.privDeferralMap.getId(s))if(e.status.statusCode.toLowerCase()!=="success"){const c=i.ResultReason.Canceled,p=new i.VoiceProfilePhraseResult(c,e.status.statusCode,e.passPhraseType,[]);this.privDeferralMap.complete(s,p)}else if(e.phrases&&e.phrases.length>0){const c=i.ResultReason.EnrollingVoiceProfile,p=new i.VoiceProfilePhraseResult(c,e.status.statusCode,e.passPhraseType,e.phrases);this.privDeferralMap.complete(s,p)}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 ${s} not found`)}handleCreateResponse(e,s){if(e.profiles&&e.profiles.length>0)if(this.privDeferralMap.getId(s)){const c=e.profiles.map(p=>p.profileId);this.privDeferralMap.complete(s,c)}else throw new Error(`Voice Profile create request for requestID ${s} not found`);else throw new Error("Voice Profile create failed, no profile id received")}handleResultResponse(e,s){if(this.privDeferralMap.getId(s)){const c=e.operation.toLowerCase()==="delete"?i.ResultReason.DeletedVoiceProfile:i.ResultReason.ResetVoiceProfile,p=e.status.statusCode.toLowerCase()==="success"?c:i.ResultReason.Canceled,d=new i.VoiceProfileResult(p,`statusCode: ${e.status.statusCode}, errorDetails: ${e.status.reason}`);this.privDeferralMap.complete(s,d)}else throw new Error(`Voice Profile create request for requestID ${s} not found`)}handleFetchResponse(e,s){if(this.privDeferralMap.getId(s)&&e.profiles[0]){if(this.privExpectedProfileId&&e.profiles.length===1&&e.profiles[0].profileId===this.privExpectedProfileId){this.privExpectedProfileId=void 0;const c=e.profiles[0],p=new i.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(c.enrollmentStatus),JSON.stringify(c),e.status.reason);this.privDeferralMap.complete(s,p)}else if(e.profiles.length>0){const c=e.profiles,p=[];for(const d of c)p.push(new i.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(d.enrollmentStatus),JSON.stringify(d),e.status.reason));this.privDeferralMap.complete(s,p)}}else throw new Error(`Voice Profile fetch request for requestID ${s} not found`)}enrollmentReasonFrom(e){switch(e.toLowerCase()){case"enrolled":return i.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 i.ResultReason.Canceled;default:return i.ResultReason.EnrollingVoiceProfile}}scenarioFrom(e){return e===i.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":e===i.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification"}};return ji.VoiceServiceRecognizer=a,ji}var Zn={},hp;function Rg(){return hp||(hp=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.type=t.connectivity=t.Device=t.OS=t.System=t.Context=t.SpeechServiceConfig=void 0;class r{constructor(e){this.context=e}serialize(){return JSON.stringify(this,(e,s)=>{if(s&&typeof s=="object"&&!Array.isArray(s)){const c={};for(const p in s)Object.hasOwnProperty.call(s,p)&&(c[p&&p.charAt(0).toLowerCase()+p.substring(1)]=s[p]);return c}return s})}get Context(){return this.context}get Recognition(){return this.recognition}set Recognition(e){this.recognition=e.toLowerCase()}}t.SpeechServiceConfig=r;class i{constructor(e){this.system=new u,this.os=e}}t.Context=i;class u{constructor(){const e="1.38.0";this.name="SpeechSDK",this.version=e,this.build="JavaScript",this.lang="JavaScript"}}t.System=u;class o{constructor(e,s,c){this.platform=e,this.name=s,this.version=c}}t.OS=o;class a{constructor(e,s,c){this.manufacturer=e,this.model=s,this.version=c}}t.Device=a,(function(n){n.Bluetooth="Bluetooth",n.Wired="Wired",n.WiFi="WiFi",n.Cellular="Cellular",n.InBuilt="InBuilt",n.Unknown="Unknown"})(t.connectivity||(t.connectivity={})),(function(n){n.Phone="Phone",n.Speaker="Speaker",n.Car="Car",n.Headset="Headset",n.Thermostat="Thermostat",n.Microphones="Microphones",n.Deskphone="Deskphone",n.RemoteControl="RemoteControl",n.Unknown="Unknown",n.File="File",n.Stream="Stream"})(t.type||(t.type={}))})(Zn)),Zn}var lp;function E(){return lp||(lp=1,(function(t){var r=te&&te.__createBinding||(Object.create?(function(a,n,e,s){s===void 0&&(s=e),Object.defineProperty(a,s,{enumerable:!0,get:function(){return n[e]}})}):(function(a,n,e,s){s===void 0&&(s=e),a[s]=n[e]})),i=te&&te.__exportStar||function(a,n){for(var e in a)e!=="default"&&!n.hasOwnProperty(e)&&r(n,a,e)};
23Object.defineProperty(t,"__esModule",{value:!0}),t.AutoDetectSourceLanguagesOpenRangeOptionName=t.ForceDictationPropertyName=t.ServicePropertiesPropertyName=t.CancellationErrorCodePropertyName=t.OutputFormatPropertyName=void 0,i(pl(),t),i(dl(),t),i(us(),t),i(hl(),t),i(ll(),t),i(vf(),t),i(ff(),t),i(vs(),t),i(gf(),t),i(mf(),t),i(Sf(),t),i(Cf(),t),i(yf(),t),i(Rf(),t),i(Pf(),t),i(Ef(),t),i(If(),t),i(rd(),t),i(Tf(),t),i(Af(),t),i(wf(),t),i(_f(),t),i(bf(),t),i(Mf(),t),i(Of(),t),i(Df(),t),i(kf(),t),i(Nf(),t),i(zf(),t),i(jf(),t),i(qf(),t),i(Lf(),t),i(Bf(),t),i(xf(),t),i(Ff(),t),i(Uf(),t),i(Hf(),t),i(Vf(),t),i($f(),t),i(Kf(),t),i(Qf(),t),i(Xf(),t),i(ug(),t),i(md(),t),i(dg(),t),i(hg(),t);var u=lg();Object.defineProperty(t,"AvatarSynthesisAdapter",{enumerable:!0,get:function(){return u.AvatarSynthesisAdapter}});var o=vg();Object.defineProperty(t,"SpeechSynthesisAdapter",{enumerable:!0,get:function(){return o.SpeechSynthesisAdapter}}),i(fg(),t),i(gg(),t),i(mg(),t),i(Sg(),t),i(Cg(),t),i(yg(),t),i(Rg(),t),t.OutputFormatPropertyName="OutputFormat",t.CancellationErrorCodePropertyName="CancellationErrorCode",t.ServicePropertiesPropertyName="ServiceProperties",t.ForceDictationPropertyName="ForceDictation",t.AutoDetectSourceLanguagesOpenRangeOptionName="OpenRange"})(te)),te}var vp;function Pg(){return vp||(vp=1,(function(t){var r=ee&&ee.__createBinding||(Object.create?(function(o,a,n,e){e===void 0&&(e=n),Object.defineProperty(o,e,{enumerable:!0,get:function(){return a[n]}})}):(function(o,a,n,e){e===void 0&&(e=n),o[e]=a[n]})),i=ee&&ee.__exportStar||function(o,a){for(var n in o)n!=="default"&&!a.hasOwnProperty(n)&&r(a,o,n)};Object.defineProperty(t,"__esModule",{value:!0});const u=E();new u.AgentConfig,i(y(),t)})(ee)),ee}var Sd=Pg();const Eg=Ah(Sd),FS=wh({__proto__:null,default:Eg},[Sd]);export{FS as m};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.